Created
January 9, 2014 08:30
-
-
Save adammw/8331124 to your computer and use it in GitHub Desktop.
This file has been truncated, but you can view the full file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
parseUri 1.2.2. | |
@author Steven Levithan <stevenlevithan.com> | |
@license MIT License. | |
sdk: v2.0.1 | |
corejs: v1.2.14 | |
bridge: v2.9.4 | |
cosmos: v0.3.1 | |
*/ | |
var Spotify = Spotify || {}; | |
Spotify.Ads = Spotify.Ads || {}; | |
Spotify.Cache = Spotify.Cache || {}; | |
Spotify.Logging = Spotify.Logging || {}; | |
Spotify.App = Spotify.App || {}; | |
Spotify.Utils = Spotify.Utils || {}; | |
Spotify.Flash = Spotify.Flash || {}; | |
Spotify.Services = Spotify.Services || {}; | |
Spotify.Services.CollectionStorageImplementation = Spotify.Services.CollectionStorageImplementation || {}; | |
Spotify.Services.CollectionSuggestionsImplementation = Spotify.Services.CollectionSuggestionsImplementation || {}; | |
Spotify.Services.CollectionViewImplementation = Spotify.Services.CollectionViewImplementation || {}; | |
Spotify.Services.CurrentFavoritesImplementation = Spotify.Services.CurrentFavoritesImplementation || {}; | |
Spotify.WebSockets = Spotify.WebSockets || {}; | |
Spotify.Protobuf = Spotify.Protobuf || {}; | |
Spotify.Hermes = Spotify.Hermes || {}; | |
Spotify.Parsers = Spotify.Parsers || {}; | |
Spotify.Models = Spotify.Models || {}; | |
Spotify.HTML5 = Spotify.HTML5 || {}; | |
Spotify.Audio = Spotify.Audio || {}; | |
Spotify.Proto = Spotify.Proto || {}; | |
Spotify.Errors = Spotify.Errors || {}; | |
Spotify.Errors.Domains = Spotify.Errors.Domains || {}; | |
Spotify.Errors.Codes = Spotify.Errors.Codes || {}; | |
Spotify.Calls = Spotify.Calls || {}; | |
Spotify.Managers = Spotify.Managers || {}; | |
DebuggerJS = Spotify.DebuggerJS = new function () { | |
this.Parsers = {}; | |
this.Loggers = {}; | |
this.Parsers = {}; | |
this.Utils = { | |
isArray: Array.isArray || function (b) { | |
return "[object Array]" == Object.prototype.toString.call(b) | |
} | |
}; | |
var b = !1, | |
l = {}, f = {}, n = {}, p = function (p, a, q, m) { | |
if (b) { | |
var h; | |
if (!DebuggerJS.Utils.isArray(q)) throw Error("The message argument should be an array"); | |
a = "string" === typeof a ? a : ""; | |
m = "string" === typeof m ? m : ""; | |
h = a; | |
var g = !1, | |
d = !1, | |
g = 0 === l.tags.length ? !0 : 0 <= l.tags.indexOf(m) ? !0 : !1, | |
d = 0 === l.modules.length ? !0 : 0 <= l.modules.indexOf(h) ? !0 : !1; | |
if (g && d) | |
for (var c in f) h = n[c].parse(a, q, m), "log" === p ? f[c].log.apply(this, h) : "warn" === p ? f[c].warn.apply(this, h) : "error" === p && f[c].error.apply(this, h); | |
else return !1; | |
return !0 | |
} | |
return !1 | |
}; | |
this.register = function (b, a, q) { | |
if ("string" !== typeof b || "undefined" === typeof a || null === a) throw Error("Not valid arguments"); | |
f[b] || (f[b] = a); | |
n[b] || (n[b] = q || new DebuggerJS.Parsers.Console); | |
return !0 | |
}; | |
this.log = function (b, a, q) { | |
return p("log", b, a, q) | |
}; | |
this.warn = function (b, a, q) { | |
return p("warn", b, a, q) | |
}; | |
this.error = function (b, | |
a, q) { | |
return p("error", b, a, q) | |
}; | |
this.on = function (f, a) { | |
if ("undefined" !== typeof f && !DebuggerJS.Utils.isArray(f) && null !== f) throw Error("The modules argument should be an array"); | |
if ("undefined" !== typeof a && !DebuggerJS.Utils.isArray(a) && null !== a) throw Error("The tags argument should be an array"); | |
b = !0; | |
l = { | |
modules: f || [], | |
tags: a || [] | |
} | |
}; | |
this.off = function () { | |
b = !1; | |
l = {} | |
} | |
}; | |
DebuggerJS.Parsers.Default = function () { | |
this.parse = function (b, l, f) { | |
return [b + " |"].concat(l).concat("| Tag: " + f) | |
} | |
}; | |
DebuggerJS.Loggers.Console = function () { | |
this.log = function () { | |
console.log.apply(console, arguments); | |
return !0 | |
}; | |
this.error = function () { | |
console.error.apply(console, arguments); | |
return !0 | |
}; | |
this.warn = function () { | |
console.warn.apply(console, arguments); | |
return !0 | |
} | |
}; | |
DebuggerJS.Loggers.Memory = function () { | |
this.log = function () { | |
return !0 | |
}; | |
this.error = function () { | |
return !0 | |
}; | |
this.warn = function () { | |
return !0 | |
} | |
}; | |
Spotify.Storage = { | |
localStorage: null, | |
indexedDB: { | |
storage: null, | |
IDBKeyRange: null, | |
IDBTransaction: null | |
} | |
}; | |
(function () { | |
var b = [].slice; | |
"bind" in Function.prototype || (Function.prototype.bind = function (f) { | |
var n = this, | |
l = null; | |
1 < arguments.length && (l = b.call(arguments, 1)); | |
return function () { | |
var r; | |
arguments.length || l ? n.apply(f, l ? arguments.length ? l.concat(b.call(arguments)) : l : arguments) : r = n.call(f); | |
return r | |
} | |
}); | |
"indexOf" in Array.prototype || (Array.prototype.indexOf = function () { | |
for (var b = this.length >>> 0, n = 0 > from ? Math.max(0, b + from) : from || 0; n < b; n++) | |
if (this[n] === item) return n; | |
return -1 | |
}); | |
var l; | |
Spotify.Utils = { | |
isArray: Array.isArray || | |
function (b) { | |
return "[object Array]" == Object.prototype.toString.call(b) | |
}, | |
inherit: function (b, n) { | |
function l() {} | |
l.prototype = new b; | |
n.prototype = new l; | |
return n.prototype.constructor = n | |
}, | |
isFunction: function (b) { | |
return "function" == typeof b | |
}, | |
toFixed: function (b, n) { | |
n = n || 0; | |
var l = 0 > b, | |
r = Math.pow(10, n); | |
b = Math.round(b * r); | |
var a = String((l ? Math.ceil : Math.floor)(b / r)), | |
l = String((l ? -b : b) % r), | |
r = Array(Math.max(n - l.length, 0) + 1).join("0"); | |
return n ? a + "." + r + l : a | |
}, | |
convertStringToXML: function (b) { | |
if (window.DOMParser) return l = new DOMParser, | |
l.parseFromString(b.replace(/\n/g, ""), "text/xml"); | |
var n = new ActiveXObject("Microsoft.XMLDOM"); | |
n.async = !1; | |
return n.loadXML(b.replace(/\n/g, "")) | |
}, | |
convertXMLToJSON: function (b) { | |
var n = {}, l = 1 == b.nodeType && 0 < b.attributes.length, | |
r = b.hasChildNodes(); | |
if (!l && !r) return b.data || ""; | |
if (l) | |
for (n["@attributes"] = {}, l = 0; l < b.attributes.length; l++) { | |
var a = b.attributes.item(l); | |
n["@attributes"][a.nodeName] = a.nodeValue | |
} | |
if (r) { | |
if (1 == b.childNodes.length && "#text" == b.childNodes[0].nodeName) return b.childNodes[0].data; | |
for (r = 0; r < | |
b.childNodes.length; r++) a = b.childNodes[r], l = a.nodeName, a = this.convertXMLToJSON(a), "#text" != l && ("undefined" === typeof n[l] ? n[l] = a : (this.isArray(n[l]) || (n[l] = Array(n[l])), n[l].push(a))) | |
} | |
return n | |
}, | |
hex2str: function (b) { | |
for (var n = [], l = 0, r = b.length; l < r - 1; l += 2) n.push(String.fromCharCode(parseInt(b.substr(l, 2), 16))); | |
return n.join("") | |
}, | |
str2hex: function (b) { | |
for (var n = "", l = 0, r = b.length; l < r; ++l) n += (b.charCodeAt(l) + 256).toString(16).slice(-2); | |
return n | |
}, | |
parseURL: function (b) { | |
var n = "source protocol authority userInfo user password host port relative path directory file query anchor".split(" "); | |
b = RegExp("^(?:(?![^:@]+:[^:@/]*@)([^:/?#.]+):)?(?://)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:/?#]*)(?::(\\d*))?)(((/(?:[^?#](?![^?#/]*\\.[^?#/.]+(?:[?#]|$)))*/?)?([^?#/]*))(?:\\?([^#]*))?(?:#(.*))?)").exec(b); | |
for (var l = {}, r = 14; r--;) l[n[r]] = b[r] || ""; | |
l.queryKey = {}; | |
l[n[12]].replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function (a, q, m) { | |
q && (l.queryKey[q] = m) | |
}); | |
return l | |
}, | |
formatPlaylistRevision: function (b) { | |
var n = parseInt(b.substr(0, 8), 16); | |
b = b.substr(8); | |
return n + "," + b | |
} | |
} | |
})(); | |
Spotify.Utils.Base62 = function () { | |
function b(a, q, m) { | |
for (var h = [0], g = [1], d = 0; d < a.length; ++d) { | |
for (var c = h, k = g, s = a[d], b = m, z = 0, t = 0; t < k.length; ++t) { | |
var v = ~~c[t] + k[t] * s + z, | |
z = ~~ (v / b); | |
c[t] = v - z * b | |
} | |
for (; z;) v = ~~c[t] + z, z = ~~ (v / b), c[t] = v - z * b, ++t; | |
c = g; | |
k = q; | |
s = m; | |
for (z = b = 0; z < c.length; ++z) t = c[z] * k + b, b = ~~ (t / s), c[z] = t - b * s; | |
for (; b;) t = ~~ (b / s), c.push(b - t * s), b = t | |
} | |
return h | |
} | |
function l(a, q) { | |
for (var m = 0, h = []; m < a.length; ++m) h.push(q[a[m]]); | |
return h.reverse() | |
} | |
function f(a, q) { | |
for (; a.length < q;) a.push(0); | |
return a | |
} | |
for (var n = {}, p = {}, r = 0; 62 > | |
r; ++r) p["0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" [r]] = r; | |
for (r = 0; 16 > r; ++r) n["0123456789abcdef" [r]] = r; | |
for (r = 0; 16 > r; ++r) n["0123456789ABCDEF" [r]] = r; | |
return { | |
fromBytes: function (a, q) { | |
var m = b(a.slice(0).reverse(), 256, 62); | |
return l(f(m, q), "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ").join("") | |
}, | |
toBytes: function (a, q) { | |
var m = b(l(a, p), 62, 256); | |
return f(m, q).reverse() | |
}, | |
toHex: function (a, q) { | |
var m = b(l(a, p), 62, 16); | |
return l(f(m, q), "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ").join("") | |
}, | |
fromHex: function (a, q) { | |
var m = b(l(a, n), 16, 62); | |
return l(f(m, q), "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ").join("") | |
} | |
} | |
}(); | |
Spotify.Utils.Base64 = function () { | |
for (var b = [], l = 0; 256 > l; ++l) b[l] = 255; | |
for (l = 0; 64 > l; ++l) b["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charCodeAt(l)] = l; | |
var f = String.fromCharCode.apply(String, b); | |
return { | |
encode: function (b) { | |
var f, l, a, q, m, h; | |
a = b.length; | |
l = 0; | |
for (f = ""; l < a;) { | |
q = b.charCodeAt(l++) & 255; | |
if (l == a) { | |
f += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(q >> 2); | |
f += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt((q & 3) << 4); | |
f += "=="; | |
break | |
} | |
m = | |
b.charCodeAt(l++); | |
if (l == a) { | |
f += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(q >> 2); | |
f += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt((q & 3) << 4 | (m & 240) >> 4); | |
f += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt((m & 15) << 2); | |
f += "="; | |
break | |
} | |
h = b.charCodeAt(l++); | |
f += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(q >> 2); | |
f += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt((q & 3) << 4 | (m & | |
240) >> 4); | |
f += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt((m & 15) << 2 | (h & 192) >> 6); | |
f += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(h & 63) | |
} | |
return f | |
}, | |
decode: function (b) { | |
for (var l = [], r = b.length, a, q, m = 0;;) { | |
do a = f.charCodeAt(b.charCodeAt(m++) & 255); while (255 === a && m < r); | |
do q = f.charCodeAt(b.charCodeAt(m++) & 255); while (255 === q && m < r); | |
if (255 === q) break; | |
l.push((a << 2 | q >> 4) & 255); | |
do a = f.charCodeAt(b.charCodeAt(m++) & 255); while (255 === a && m < r); | |
if (255 === a) break; | |
l.push((q << | |
4 | a >> 2) & 255); | |
do q = f.charCodeAt(b.charCodeAt(m++) & 255); while (255 === q && m < r); | |
if (255 === q) break; | |
l.push((a << 6 | q) & 255) | |
} | |
if (4096 > l.length) l = String.fromCharCode.apply(String, l); | |
else { | |
b = 0; | |
r = []; | |
do r.push(String.fromCharCode.apply(String, l.slice(b, b + 4096))), b += 4096; while (b < l.length); | |
l = r.join("") | |
} | |
return l | |
} | |
} | |
}(); | |
Spotify.Calls.Hermes = function (b, l, f) { | |
this.calleeId = ""; | |
this.success = l || function () {}; | |
this.error = f || function () {}; | |
this.type = b.type || ""; | |
this.persistent = "undefined" === typeof b.persistent ? !0 : b.persistent; | |
this.bypassCache = "undefined" === typeof b.bypassCache ? !1 : b.bypassCache; | |
this.context = b.context || null; | |
this.isMultiGet = "undefined" === typeof b.isMultiGet ? !1 : b.isMultiGet; | |
this.header = { | |
uri: "", | |
method: "", | |
source: "", | |
content_type: this.isMultiGet ? "vnd.spotify/mercury-mget-request" : "" | |
}; | |
this.payload = []; | |
this.payloadSchemas = []; | |
this.responseSchemas = []; | |
this.mercuryMultiGetPayloadSchemas = ["mercury#MercuryMultiGetRequest"]; | |
this.mercuryMultiGetResponseSchemas = ["mercury#MercuryMultiGetReply"]; | |
b.header && (this.header.uri = b.header.uri || "", this.header.method = b.header.method || "", this.header.source = b.header.source || ""); | |
this.payload = b.payload || []; | |
this.payloadSchemas = b.payloadSchemas || []; | |
this.responseSchemas = b.responseSchemas || [] | |
}; | |
Spotify.Calls.Simple = function (b, l, f) { | |
this.calleeId = ""; | |
this.success = l || function () {}; | |
this.error = f || function () {}; | |
this.type = b.type || ""; | |
this.payload = b.payload || []; | |
this.persistent = b.persistent || !0; | |
this.bypassCache = b.bypassCache || !1; | |
this.method = b.method || ""; | |
this.context = b.context || null; | |
this.retries = b.retries || 2 | |
}; | |
Spotify.Errors.Domains.HERMES_ERROR = 13; | |
Spotify.Errors.Domains.HERMES_SERVICE_ERROR = 14; | |
Spotify.Errors.Codes.HM_TOO_MANY_REQUESTS = 429; | |
Spotify.Errors.Codes.HM_TIMEOUT = 408; | |
Spotify.Errors.Codes.HM_FAILED_TO_SEND_TO_BACKEND = 1; | |
Spotify.Errors.Domains.TRACK_ERROR = 12; | |
Spotify.Errors.Codes.TRACK_REQUEST_RATE_LIMITED = 8; | |
Spotify.Errors.Codes.TRACK_CAP = 11; | |
Spotify.Errors.Codes.TIME_CAP = 12; | |
Spotify.Errors.Codes.ADS_ERROR = 15; | |
Spotify.Errors.Codes.ADS_SERVER_ERROR = 500; | |
Spotify.Errors.Codes.ADS_NOT_FOUND = 404; | |
Spotify.Errors.Codes.MALFORMED_RESPONSE = 520; | |
Spotify.Errors.Error = function (b) { | |
b = b || []; | |
this.domain = b[0] || 0; | |
this.code = b[1] || 0; | |
this.description = b[2] || ""; | |
this.data = b[3] || null | |
}; | |
Spotify.RateLimiter = function (b, l) { | |
Spotify.EventTarget.call(this); | |
var f = this, | |
n = !1, | |
p = [], | |
r = new Spotify.Events, | |
a = 0; | |
this.totalPendingRequests = function () { | |
return p.length | |
}; | |
this.getItemAtIndex = function (a) { | |
return p[a] | |
}; | |
this.addToBucket = function (a, h) { | |
"undefined" === typeof h && (h = !0); | |
"undefined" !== typeof a && (h ? p.push(a) : p[0] = a) | |
}; | |
this.isStarted = function () { | |
return n | |
}; | |
this.start = function () { | |
n || (n = !0, clearInterval(a), a = setInterval(q, b)) | |
}; | |
var q = function () { | |
var m = 0, | |
h, g = l; | |
l > p.length && (g = p.length); | |
for (; m < g; m++) h = p.shift(), | |
f.trigger(r.RATE_LIMIT_CALL, h); | |
f.trigger(r.RATE_LIMIT_AFTER_INTERVAL); | |
0 === p.length && (n = !1, clearInterval(a), f.trigger(r.RATE_LIMIT_DISABLED)) | |
} | |
}; | |
Spotify.CallsManager = function () { | |
var b = 0, | |
l = {}, f = [0]; | |
this.addCall = function (f, p, r, a, q, m, h, g) { | |
var d = (new Date).getTime(); | |
b++; | |
l[b] = { | |
method: f, | |
params: p, | |
callback: r, | |
errback: a, | |
context: q, | |
persistent: m, | |
retries: "undefined" === typeof h ? 2 : h, | |
timestamp: d, | |
callType: g | |
}; | |
return b | |
}; | |
this.getCall = function (b, f) { | |
"undefined" === typeof f && (f = !0); | |
if (void 0 !== typeof l[b]) { | |
var r = l[b]; | |
f && delete l[b]; | |
return r | |
} | |
}; | |
this.getCalls = function () { | |
var b, f, r = []; | |
for (f in l) b = f, b = this.getCall(b), 0 < b.retries && r.push(b); | |
return r | |
}; | |
this.getPersistentCalls = | |
function () { | |
for (var b = 0, l = f.length, r, a = []; b < l; b++) null !== f[b] && 0 !== f[b] && (r = f[b], a.push(this.getCall(r))); | |
f = [0]; | |
return a | |
}; | |
this.setPersistent = function (b, l) { | |
!0 === l ? f.push(b) : f[0] = b | |
} | |
}; | |
Spotify.Managers.ProtobufSchemasManager = function () { | |
var b = Spotify.DebuggerJS, | |
l = {}; | |
this.registerSchema = function (f, n) { | |
b.log("Spotify.Managers.ProtobufSchemasManager", ["Registering schema with id", f], "corejs"); | |
if ("undefined" !== typeof l[f]) b.error("Spotify.Managers.ProtobufSchemasManager", ["Schema with id", f, "already exists"], "corejs"); | |
else return n instanceof Spotify.Protobuf.Schema ? l[f] = n : (l[f] = new Spotify.Protobuf.Schema([], null, null, null), l[f].id = f, l[f].type = "proto", l[f].setData(n), l[f].encode()), | |
l[f] | |
}; | |
this.getProtobufMsgParser = function (b, n) { | |
return "undefined" === typeof l[b] ? null : l[b].msg(n) | |
} | |
}; | |
Spotify.ConnectionManager = function () { | |
Spotify.EventTarget.call(this); | |
var b = this, | |
l = 0, | |
f, n = new Spotify.Events, | |
p, r = function () { | |
b.trigger(n.ON_TRY_TO_CONNECT) | |
}, a = function () { | |
l = 0; | |
"undefined" !== typeof f && clearTimeout(f) | |
}; | |
this.reset = function () { | |
"undefined" !== typeof f && clearTimeout(f); | |
l = 0; | |
f = setTimeout(r, 0) | |
}; | |
var q = function (a) { | |
var h = []; | |
"undefined" !== typeof a && (h = a.params || []); | |
a = 1E3 * Math.pow(2, l); | |
0 === l % 2 && 0 !== l && b.trigger(n.NOTIFY_OF_DISCONNECT, h); | |
3E4 < a && (a = 3E4); | |
l++; | |
f && clearTimeout(f); | |
1E3 === a && (a = 0); | |
f = setTimeout(r, | |
a) | |
}; | |
this.initialize = function (m) { | |
p = m; | |
p.bind(n.CONNECTION_ESTABLISHED, a, this); | |
p.bind(n.FAILED_CONNECTING, q, this) | |
} | |
}; | |
Spotify.Worker = function () { | |
Spotify.EventTarget.call(this); | |
var b = this, | |
l, f, n, p = new Spotify.Events, | |
r = function (a) { | |
eval(a.params) | |
}, a = function (a) {}, q = function (a) {}; | |
this.reply = function () { | |
var m = Array.prototype.slice.call(arguments); | |
n.rpc("work_done", m, q, a, b, !1, 0, "work_done") | |
}; | |
this.run = function (a) { | |
f.onReady(function () { | |
var h = "undefined 0"; | |
l || (l = f.getInterface()); | |
try { | |
h = l.run(a) | |
} catch (g) {} | |
n.rpc("pong_flash", [h], function () {}, function () {}, b, !1, 0, "pong_flash") | |
}, this) | |
}; | |
this.initialize = function (a, h) { | |
n = a; | |
f = h; | |
n.bind(p.WORK, | |
r, this); | |
n.bind(p.PING_FLASH, r, this) | |
} | |
}; | |
(function () { | |
Spotify.LinkedList = function () { | |
this.length = 0; | |
this.last = this.first = null | |
}; | |
Spotify.LinkedList.prototype.append = function (b) { | |
if (null === b) throw Error("Node is null!"); | |
if (null !== b.list) throw Error("Node already exists in another list!"); | |
b.list = this; | |
null === this.first ? this.first = b : (b.prev = this.last, b.next = null, this.last.next = b); | |
this.last = b; | |
this.length++ | |
}; | |
Spotify.LinkedList.prototype.insertAfter = function (b, l) { | |
if (null === b || null === l) throw Error("Node is null!"); | |
if (null !== l.list) throw Error("Node already exists in another list!"); | |
l.list = this; | |
l.prev = b; | |
l.next = b.next; | |
b.next.prev = l; | |
b.next = l; | |
l.prev === this.last && (this.last = l); | |
this.length++ | |
}; | |
Spotify.LinkedList.prototype.remove = function (b) { | |
if (null === b) throw Error("Node is null!"); | |
if (0 == this.length || b.list !== this) return !1; | |
1 < this.length ? (null !== b.prev && (b.prev.next = b.next), null !== b.next && (b.next.prev = b.prev), b === this.first ? this.first = b.next : b === this.last && (this.last = b.prev)) : this.last = this.first = null; | |
delete b.list; | |
delete b.prev; | |
delete b.next; | |
b.list = null; | |
b.prev = null; | |
b.next = null; | |
this.length--; | |
return !0 | |
}; | |
Spotify.LinkedList.Node = function (b) { | |
this.next = this.prev = this.list = null; | |
this.value = b || null | |
} | |
})(); | |
(function () { | |
Spotify.SimpleCache = function (b, l) { | |
this._limit = b || 100; | |
this._map = {}; | |
this._lru = new Spotify.LinkedList; | |
this._stats = { | |
hits: 0, | |
misses: 0 | |
} | |
}; | |
Spotify.SimpleCache.prototype.get = function (b) { | |
if (b = this._map[b]) return this._lru.remove(b), this._lru.append(b), this._stats.hits++, b.value; | |
this._stats.misses++; | |
return null | |
}; | |
Spotify.SimpleCache.prototype.put = function (b, l) { | |
if ("undefined" == typeof b || null == b || "" == b) throw Error("Cache key can't be empty!"); | |
this._lru.length >= this._limit && (delete this._map[this._lru.first.key], | |
this._lru.remove(this._lru.first)); | |
var f = this._map[b]; | |
f ? (this._lru.remove(f), f.value = l) : (f = new Spotify.LinkedList.Node(l), f.key = b); | |
this._lru.append(f); | |
this._map[b] = f | |
}; | |
Spotify.SimpleCache.prototype.remove = function (b) { | |
var l = this._map[b]; | |
return l ? (this._lru.remove(l), delete this._map[b], l.value) : null | |
}; | |
Spotify.SimpleCache.prototype.removeAllContaining = function (b) { | |
var l, f = [], | |
n; | |
for (n in this._map) 0 <= n.indexOf(b) && (l = this._map[n]) && (this._lru.remove(l), delete this._map[n], f.push(n)); | |
return f | |
}; | |
Spotify.SimpleCache.prototype.size = | |
function () { | |
return this._lru.length | |
}; | |
Spotify.SimpleCache.prototype.clear = function () { | |
this._lru = new Spotify.LinkedList; | |
this._map = {} | |
} | |
})(); | |
Spotify.Cache.PackageStore = function (b) { | |
var l = function (b) { | |
return b | |
}, f = function (b) { | |
return b | |
}, n = "PackageStore", | |
p = function () { | |
var b = {}; | |
null !== Spotify.Storage.localStorage.getItem(n) && (b = JSON.parse(f(Spotify.Storage.localStorage.getItem(n)))); | |
return b | |
}; | |
"undefined" !== typeof b && ("undefined" !== typeof b.storageKey && (n = b.storageKey), "function" === typeof b.encrypt && (l = b.encrypt), "function" === typeof b.decrypt && (f = b.decrypt)); | |
this.setItem = function (b, a) { | |
var q = p(); | |
q[b] = a; | |
return Spotify.Storage.localStorage.setItem(n, | |
l(JSON.stringify(q))) | |
}; | |
this.getItem = function (b) { | |
var a = p(); | |
return "undefined" === typeof a[b] ? null : a[b] | |
}; | |
this.removeItem = function (b) { | |
var a = p(); | |
delete a[b]; | |
return Spotify.Storage.localStorage.setItem(n, l(JSON.stringify(a))) | |
}; | |
this.clear = function () { | |
return Spotify.Storage.localStorage.removeItem(n) | |
}; | |
this.length = function () { | |
var b = p(), | |
a = 0, | |
q; | |
for (q in b) b.hasOwnProperty(q) && (a += 1); | |
return a | |
}; | |
this.key = function (b) { | |
var a = p(), | |
q = 0, | |
m; | |
for (m in a) | |
if (a.hasOwnProperty(m)) { | |
if (q === b) return m; | |
q += 1 | |
} | |
return null | |
} | |
}; | |
Spotify.Cache.Default = function (b, l) { | |
this._limit = b || 100; | |
this._storage = l || new Spotify.Cache.MemoryStorage; | |
this._keyToNode = {}; | |
this._lru = new Spotify.LinkedList; | |
this._stats = { | |
hits: 0, | |
misses: 0 | |
}; | |
this.initialize = function (b, n, l) { | |
if (!Spotify.Utils.isFunction(b) || !Spotify.Utils.isFunction(n)) throw new TypeError("Argument is not a function!"); | |
var r = function (a, m) { | |
var h = new Spotify.LinkedList.Node(m); | |
h.key = a; | |
this._lru.append(h); | |
this._keyToNode[a] = h | |
}, a = function () { | |
b.call(l, this) | |
}; | |
this._storage.initialize(function () { | |
this._storage.each(r, | |
a, this) | |
}, n, this) | |
}; | |
this.get = function (b, n, l) { | |
if (!Spotify.Utils.isFunction(n)) throw new TypeError("Argument is not a function!"); | |
this._storage.get(b, function (b, a) { | |
var q = this._keyToNode[b] || null; | |
null !== a && null !== q ? (this._lru.remove(q), this._lru.append(q), this._stats.hits++, n.call(l, b, a)) : (this._stats.misses++, n.call(l, b, null)) | |
}, this) | |
}; | |
this.put = function (b, n, l, r, a, q) { | |
if ("undefined" == typeof b || null == b || "" == b) throw Error("Cache key can't be empty!"); | |
var m = function (h, g, d) { | |
if (null === g) | |
if (Spotify.Utils.isFunction(a) && | |
a.call(q, d), g = Math.floor(0.9 * this._lru.length), 0 == g) r.call(q, h, null); | |
else { | |
for (; this._lru.length > g;) this._storage.remove(this._lru.first.key), this._lru.remove(this._lru.first); | |
this._storage.set(h, n, m, this) | |
} else Spotify.Utils.isFunction(l) && l.call(q, h, g) | |
}; | |
this._lru.length >= this._limit && (this._storage.remove(this._lru.first.key), this._lru.remove(this._lru.first)); | |
this._storage.get(b, function (a, g) { | |
var d = this._keyToNode[a] || null; | |
null !== g && null !== d ? (this._lru.remove(d), d.value = n) : (d = new Spotify.LinkedList.Node(n), | |
d.key = a); | |
this._lru.append(d); | |
this._keyToNode[a] = d; | |
this._storage.set(a, n, m, this) | |
}, this) | |
}; | |
this.remove = function (b, n, l) { | |
this._storage.get(b, function (b, a) { | |
var q = this._keyToNode[b] || null; | |
null !== a && null !== q ? (this._lru.remove(q), this._storage.remove(b, n, l)) : Spotify.Utils.isFunction(n) && n.call(l, b) | |
}, this) | |
}; | |
this.removeAllContaining = function (b, n, l) { | |
this._storage.removeAllContaining(b, function (b) { | |
for (var a = 0; a < b.length; a++) { | |
var q = this._keyToNode[b[a]] || null; | |
null !== q && this._lru.remove(q) | |
} | |
Spotify.Utils.isFunction(n) && | |
n.call(l, b) | |
}, this) | |
}; | |
this.size = function () { | |
return this._lru.length | |
}; | |
this.clear = function (b, n) { | |
this._lru = new Spotify.LinkedList; | |
this._storage.clear(b, n) | |
} | |
}; | |
Spotify.Cache.DummyStorage = function () { | |
this.initialize = function (b, l, f) { | |
if (!Spotify.Utils.isFunction(b) || !Spotify.Utils.isFunction(l)) throw new TypeError("Argument is not a function!"); | |
l.call(f) | |
}; | |
this.isSupported = function () { | |
return !0 | |
} | |
}; | |
Spotify.Cache.MemoryStorage = function () { | |
this._data = {}; | |
this.get = function (b, l, f) { | |
if (!Spotify.Utils.isFunction(l)) throw new TypeError(ERROR_NOT_A_FUNCTION); | |
l.call(f, b, this._data[b] || null) | |
}; | |
this.set = function (b, l, f, n) { | |
this._data[b] = l; | |
Spotify.Utils.isFunction(f) && f.call(n, b, l) | |
}; | |
this.remove = function (b, l, f) { | |
delete this._data[b]; | |
Spotify.Utils.isFunction(l) && l.call(f, b) | |
}; | |
this.removeAllContaining = function (b, l, f) { | |
var n = [], | |
p = this._data, | |
r; | |
for (r in p) 0 <= r.indexOf(b) && (n.push(r), delete this._data[r]); | |
Spotify.Utils.isFunction(l) && | |
l.call(f, n) | |
}; | |
this.clear = function (b, l) { | |
this._data = {}; | |
Spotify.Utils.isFunction(b) && b.call(l) | |
}; | |
this.each = function (b, l, f) { | |
if (!Spotify.Utils.isFunction(b)) throw new TypeError(ERROR_NOT_A_FUNCTION); | |
var n = this._data, | |
p; | |
for (p in n) b.call(f, p, n[p]); | |
Spotify.Utils.isFunction(l) && l.call(f) | |
}; | |
this.initialize = function (b, l, f) { | |
if (!Spotify.Utils.isFunction(b) || !Spotify.Utils.isFunction(l)) throw new TypeError(ERROR_NOT_A_FUNCTION); | |
b.call(f) | |
}; | |
this.isSupported = function () { | |
return !0 | |
} | |
}; | |
Spotify.Cache.LocalStorage = function (b) { | |
this._prefix = "com.spotify.cache." + (b || "generic") + "."; | |
this.get = function (b, f, n) { | |
if (!Spotify.Utils.isFunction(f)) throw new TypeError("Argument is not a function!"); | |
var p = Spotify.Storage.localStorage.getItem(this._prefix + b); | |
f.call(n, b, p ? JSON.parse(p) : null) | |
}; | |
this.set = function (b, f, n, p) { | |
try { | |
Spotify.Storage.localStorage.setItem(this._prefix + b, JSON.stringify(f)), Spotify.Utils.isFunction(n) && n.call(p, b, f) | |
} catch (r) { | |
Spotify.Utils.isFunction(n) && n.call(p, b, null, r) | |
} | |
}; | |
this.remove = | |
function (b, f, n) { | |
Spotify.Storage.localStorage.removeItem(this._prefix + b); | |
Spotify.Utils.isFunction(f) && f.call(n, b) | |
}; | |
this.removeAllContaining = function (b, f, n, p) { | |
p = []; | |
var r = Spotify.Storage.localStorage; | |
b = this._prefix + b; | |
for (var a, q = 0, m = r.length; q < m; q++) a = r.key(q), 0 <= a.indexOf(b) && (p.push(a.substring(this._prefix.length)), r.removeItem(a), q--, m--); | |
Spotify.Utils.isFunction(f) && f.call(n, p) | |
}; | |
this.clear = function (b, f) { | |
for (var n = Spotify.Storage.localStorage, p = n.length - 1; 0 <= p; --p) { | |
var r = n.key(p); | |
0 == r.indexOf(this._prefix) && | |
n.removeItem(r) | |
} | |
Spotify.Utils.isFunction(b) && b.call(f) | |
}; | |
this.each = function (b, f, n) { | |
if (!Spotify.Utils.isFunction(b)) throw new TypeError("Argument is not a function!"); | |
for (var p = Spotify.Storage.localStorage, r = 0, a = p.length; r < a; ++r) { | |
var q = p.key(r); | |
if (0 == q.indexOf(this._prefix)) { | |
var m = p.getItem(q); | |
b.call(n, q.slice(this._prefix.length), m ? JSON.parse(m) : null) | |
} | |
} | |
Spotify.Utils.isFunction(f) && f.call(n) | |
}; | |
this.initialize = function (b, f, n) { | |
if (!Spotify.Utils.isFunction(b) || !Spotify.Utils.isFunction(f)) throw new TypeError("Argument is not a function!"); | |
b.call(n) | |
}; | |
this.isSupported = function () { | |
return "undefined" !== typeof Spotify.Storage.localStorage | |
} | |
}; | |
Spotify.Cache.IndexedDBStorage = function (b) { | |
var l = null, | |
f = function (b, f, a, q, m) { | |
var h = Spotify.Storage.indexedDB.storage.open(b, f); | |
h.onsuccess = function (g) { | |
var d = g.target.result; | |
Spotify.Utils.isFunction(d.setVersion) ? (g = parseInt(d.version || "0", 10), g < f ? (g = d.setVersion(f.toString()), g.onsuccess = function (c) { | |
d.objectStoreNames.contains(b) || d.createObjectStore(b); | |
a.call(m, d) | |
}, g.onerror = function (a) { | |
q.call(m) | |
}) : g == f ? a.call(m, d) : q.call(m)) : a.call(m, d) | |
}; | |
h.onerror = function (a) { | |
q.call() | |
}; | |
h.onupgradeneeded = function (a) { | |
a = | |
a.target.result; | |
a.objectStoreNames.contains(b) || a.createObjectStore(b) | |
} | |
}, n = function (b, f) { | |
return function (a) { | |
l = a; | |
b.call(f) | |
} | |
}; | |
this._open = function (l, r, a) { | |
f(b, 1, n(l, a), r) | |
}; | |
this._transaction = function (f) { | |
return l.transaction(b, f).objectStore(b) | |
}; | |
this.get = function (b, f, a) { | |
if (!Spotify.Utils.isFunction(f)) throw new TypeError(ERROR_NOT_A_FUNCTION); | |
var q = this._transaction("readonly").get(b); | |
q.onsuccess = function (m) { | |
f.call(a, b, m.target.result) | |
}; | |
q.onerror = function (m) { | |
f.call(a, b, null, m.target.errorCode) | |
} | |
}; | |
this.set = | |
function (b, f, a, q) { | |
var m = this._transaction("readwrite").put(f, b); | |
Spotify.Utils.isFunction(a) && (m.onsuccess = function (h) { | |
a.call(q, b, f) | |
}, m.onerror = function (h) { | |
a.call(q, b, null, h.target.errorCode) | |
}) | |
}; | |
this.remove = function (b, f, a) { | |
var q = this._transaction("readwrite")["delete"](b); | |
Spotify.Utils.isFunction(f) && (q.onsuccess = function () { | |
f.call(a, b) | |
}, q.onerror = function () { | |
f.call(a, null, e.target.errorCode) | |
}) | |
}; | |
this.removeAllContaining = function (b, f, a, q) { | |
var m = []; | |
this._transaction("readwrite").openCursor().onsuccess = | |
function (h) { | |
(h = h.target.result) ? (0 <= h.key.indexOf(b) && (m.push(h.key), h["delete"]()), h["continue"]()) : Spotify.Utils.isFunction(f) && f.call(a, m) | |
} | |
}; | |
this.clear = function (b, f) { | |
var a = this._transaction("readwrite").clear(); | |
Spotify.Utils.isFunction(b) && (a.onsuccess = function () { | |
b.call(f) | |
}, a.onerror = function () { | |
b.call(f) | |
}) | |
}; | |
this.each = function (b, f, a) { | |
if (!Spotify.Utils.isFunction(b)) throw new TypeError(ERROR_NOT_A_FUNCTION); | |
this._transaction("readonly").openCursor().onsuccess = function (q) { | |
(q = q.target.result) ? (b.call(a, | |
q.key, q.value), q["continue"]()) : Spotify.Utils.isFunction(f) && f.call(a) | |
} | |
}; | |
this.initialize = function (b, f, a) { | |
if (!Spotify.Utils.isFunction(b) || !Spotify.Utils.isFunction(f)) throw new TypeError(ERROR_NOT_A_FUNCTION); | |
this._open(b, f, a) | |
}; | |
this.isSupported = function () { | |
return Spotify.Storage.indexedDB.storage ? !0 : !1 | |
} | |
}; | |
Spotify.Cache.FileSystemStorage = function (b) { | |
throw Error("Not implemented!"); | |
}; | |
Spotify.Cache.PackageStore = function (b) { | |
var l = function (b) { | |
return b | |
}, f = function (b) { | |
return b | |
}, n = "PackageStore", | |
p = function () { | |
var b = {}; | |
null !== Spotify.Storage.localStorage.getItem(n) && (b = JSON.parse(f(Spotify.Storage.localStorage.getItem(n)))); | |
return b | |
}; | |
"undefined" !== typeof b && ("undefined" !== typeof b.storageKey && (n = b.storageKey), "function" === typeof b.encrypt && (l = b.encrypt), "function" === typeof b.decrypt && (f = b.decrypt)); | |
return { | |
setItem: function (b, a) { | |
var q = p(); | |
q[b] = a; | |
return Spotify.Storage.localStorage.setItem(n, | |
l(JSON.stringify(q))) | |
}, | |
getItem: function (b) { | |
var a = p(); | |
return "undefined" === typeof a[b] ? null : a[b] | |
}, | |
removeItem: function (b) { | |
var a = p(); | |
delete a[b]; | |
return Spotify.Storage.localStorage.setItem(n, l(JSON.stringify(a))) | |
}, | |
clear: function () { | |
return Spotify.Storage.localStorage.remove(n) | |
}, | |
length: function () { | |
var b = p(), | |
a = 0, | |
q; | |
for (q in b) b.hasOwnProperty(q) && (a += 1); | |
return a | |
}, | |
key: function (b) { | |
var a = p(), | |
q = 0, | |
m; | |
for (m in a) | |
if (a.hasOwnProperty(m)) { | |
if (q === b) return m; | |
q += 1 | |
} | |
return null | |
} | |
} | |
}; | |
Spotify.Cache.Types = { | |
PERSISTENT: "persistent", | |
TEMPORARY: "temporary" | |
}; | |
(function () { | |
var b; | |
Spotify.Events = function () { | |
return "undefined" !== typeof b ? b : b = { | |
REQUEST: "REQUEST", | |
DATA_ERROR: "DATA_ERROR", | |
TRACK_PLAY_REQUEST: "TRACK_PLAY_REQUEST", | |
WAIT_FOR_COMMERCIAL_TO_FINISH: "WAIT_FOR_COMMERCIAL_TO_FINISH", | |
INTERCEPTED: "intercepted", | |
USER_INFO_CHANGE: "USER_INFO_CHANGE", | |
TRACK_ENDED: "TRACK_ENDED", | |
PLAYER_STATE: "PLAYER_STATE", | |
BEFORE_END: "BEFORE_END", | |
BEFORE_SEEK: "BEFORE_SEEK", | |
LOAD: "LOAD", | |
SONG_LOADED: "SONG_LOADED", | |
FIRST_BYTES: "FIRST_BYTES", | |
POSITION_CHANGED: "POSITION_CHANGED", | |
VOLUME_CHANGED: "VOLUME_CHANGED", | |
PLAYING: "PLAYING", | |
PAUSED: "PAUSED", | |
STOPPED: "STOPPED", | |
ACTIVE_PLAYER_CHANGED: "ACTIVE_PLAYER_CHANGED", | |
CONNECTION_ESTABLISHED: "CONNECTION_ESTABLISHED", | |
CONNECTION_CLOSED: "CONNECTION_CLOSED", | |
CONNECTED: "CONNECTED", | |
DISCONNECTED: "DISCONNECTED", | |
STREAM_INITIALIZED: "STREAM_INITIALIZED", | |
PLAYER_LOADED: "PLAYER_LOADED", | |
PLAYER_EVENT: "PLAYER_EVENT", | |
STREAM_LIMIT_REACHED: "STREAM_LIMIT_REACHED", | |
AUTHENTICATED: "AUTHENTICATED", | |
ERROR: "ERROR", | |
SUCCESS: "SUCCESS", | |
FAILED_CONNECTING: "FAILED_CONNECTING", | |
INVALID_TRACK_URI: "INVALID_TRACK_URI", | |
CANNOT_PLAY_TRACK: "CANNOT_PLAY_TRACK", | |
REGION_BLOCKED: "REGION_BLOCKED", | |
ACCOUNT_IN_USE: "ACCOUNT_IN_USE", | |
PLAYBACK_FAILED: "PLAYBACK_FAILED", | |
SECURITY_ERROR: "SECURITY_ERROR", | |
UNKNOWN_ERROR: "UNKNOWN_ERROR", | |
RPC_CALLBACK: "RPC_CALLBACK", | |
RPC_ERRBACK: "RPC_ERRBACK", | |
RPC_LOGGING_LATENCY_CALLBACK: "RPC_LOGGING_LATENCY_CALLBACK", | |
RPC_LOGGING_LATENCY_ERRBACK: "RPC_LOGGING_LATENCY_ERRBACK", | |
RPC_SUCCESS: "RPC_SUCCESS", | |
RPC_ERROR: "RPC_ERROR", | |
REAUTHORIZE_SUCCESS: "REAUTHORIZE_SUCCESS", | |
REAUTHORIZE_FAILED: "REAUTHORIZE_FAILED", | |
FLASH_LOADED: "FLASH_LOADED", | |
FLASH_UNAVAILABLE: "FLASH_UNAVAILABLE", | |
FLASH_AVAILABLE: "FLASH_AVAILABLE", | |
INITIALIZED: "INITIALIZED", | |
READY: "READY", | |
NOT_READY: "NOT_READY", | |
TOKEN_ACQUIRED: "TOKEN_ACQUIRED", | |
TOKEN_NOT_ACQUIRED: "TOKEN_NOT_ACQUIRED", | |
ON_TRY_TO_CONNECT: "ON_TRY_TO_CONNECT", | |
NOTIFY_OF_DISCONNECT: "NOTIFY_OF_DISCONNECT", | |
FATAL_ERROR: "FATAL_ERROR", | |
TOKEN_LOST: "TOKEN_LOST", | |
WORK: "WORK", | |
PING_FLASH: "PING_FLASH", | |
LOGIN_COMPLETE: "LOGIN_COMPLETE", | |
HERMES_B64_MESSAGE: "HERMES_B64_MESSAGE", | |
TIMEOUT: "TIMEOUT", | |
NO_SOUND_CAPABILITIES: "NO_SOUND_CAPABILITIES", | |
ON_REAUTHENTICATION_SUCCESS: "ON_REAUTHENTICATION_SUCCESS", | |
ON_REAUTHENTICATION_FAILED: "ON_REAUTHENTICATION_FAILED", | |
STORAGE_FULL: "STORAGE_FULL", | |
RATE_LIMIT_CALL: "RATE_LIMIT_CALL", | |
RATE_LIMIT_DISABLED: "RATE_LIMIT_DISABLED", | |
RATE_LIMIT_AFTER_INTERVAL: "RATE_LIMIT_AFTER_INTERVAL", | |
REMOTE_SERVICE_DOWN: "REMOTE_SERVICE_DOWN", | |
NOTIFICATION: "NOTIFICATION", | |
RELATIONS_SUBSCRIBE: "RELATIONS_SUBSCRIBE", | |
RELATIONS_UNSUBSCRIBE: "RELATIONS_UNSUBSCRIBE", | |
RELATIONS_DISMISS: "RELATIONS_DISMISS", | |
RELATIONS_UNDISMISS: "RELATIONS_UNDISMISS", | |
RELATIONS_BLOCK: "RELATIONS_BLOCK", | |
RELATIONS_UNBLOCK: "RELATIONS_UNBLOCK", | |
CHANGED: "CHANGED", | |
DURATION: "DURATION", | |
PLAYER_CREATED: "PLAYER_CREATED", | |
PLAYLIST_SUBSCRIBE: "PLAYLIST_SUBSCRIBE", | |
TIME_CAP: "TIME_CAP", | |
CHANGE: "CHANGE", | |
RECORD_AD_EVENT: "RECORD_AD_EVENT", | |
AD_BREAK_STARTED: "AD_BREAK_STARTED", | |
AD_BREAK_ENDED: "AD_BREAK_ENDED", | |
AD_AVAILABLE: "AD_AVAILABLE", | |
AD_NOT_AVAILABLE: "AD_NOT_AVAILABLE", | |
AD_RECEIVED: "AD_RECEIVED", | |
AD_CLEAR: "AD_CLEAR", | |
AD_DEBUG: "AD_DEBUG" | |
} | |
} | |
})(); | |
Spotify.Resolvers = { | |
STORAGE_RESOLVER: "STORAGE_RESOLVER", | |
AD_RESOLVER: "AD_RESOLVER", | |
PREVIEW_RESOLVER: "PREVIEW_RESOLVER" | |
}; | |
Spotify.Ajax = function (b) { | |
var l = Spotify.DebuggerJS; | |
b = b || {}; | |
var f = {}; | |
f.method = b.method || "GET"; | |
f.dataType = b.dataType || "text"; | |
f.url = b.url || void 0; | |
f.data = b.data || ""; | |
f.async = void 0 !== b.async ? b.async : !0; | |
f.success = b.success || void 0; | |
f.error = b.error || void 0; | |
f.context = b.context || void 0; | |
this.POST = "POST"; | |
this.GET = "GET"; | |
this.JSON = "json"; | |
this.XML = "xml"; | |
this.TEXT = "text"; | |
this.execute = function () { | |
var b, p = f.url, | |
r = "", | |
a, q = function (a) { | |
void 0 !== f.context ? f.error.call(f.context, a) : f.error(a) | |
}, m = function () { | |
if ("undefined" !== | |
typeof f.success) { | |
if ("xml" === f.dataType) try { | |
a = b.responseXML || Spotify.Utils.convertStringToXML(b.responseText) | |
} catch (c) { | |
q(c) | |
} | |
if ("json" === f.dataType) try { | |
a = JSON.parse(b.responseText) | |
} catch (d) { | |
q(d) | |
} | |
"text" === f.dataType && (a = b.responseText); | |
void 0 !== f.context ? f.success.call(f.context, a, b) : f.success(a, b) | |
} | |
}, h = function () { | |
"undefined" !== typeof f.error && q() | |
}, g = function () { | |
m() | |
}, d = function (a) { | |
h(a) | |
}; | |
b = XMLHttpRequest ? new XMLHttpRequest : new ActiveXObject("Microsoft.XMLHTTP"); | |
f.method === this.POST ? r = f.data : p += "" !== f.data ? | |
"?" + f.data : ""; | |
try { | |
try { | |
b.open(f.method, p, f.async) | |
} catch (c) { | |
if (XDomainRequest) l.log("Spotify.Ajax", ["Trying Cors"], "corejs"), b = new XDomainRequest, b.onprogress = function () {}, b.onload = g, b.onerror = d, b.open(f.method, p, f.async); | |
else throw Error("CORS not supported"); | |
} | |
b.send(r) | |
} catch (k) { | |
l.error("Spotify.Ajax", [k], "corejs"), q(k) | |
} | |
b.onreadystatechange = function () { | |
4 === b.readyState && (200 <= b.status && 300 > b.status ? m() : 400 <= b.status && h()) | |
}; | |
return b | |
} | |
}; | |
Spotify.Service = function () { | |
Spotify.EventTarget.call(this); | |
this.url = ""; | |
this.method = "GET"; | |
this.dataType = "text"; | |
this.data = ""; | |
this.async = !0; | |
this.fetch = function () { | |
(new Spotify.Ajax({ | |
method: this.method, | |
dataType: this.dataType, | |
url: this.url, | |
data: this.data, | |
success: b, | |
error: l, | |
context: this | |
})).execute() | |
}; | |
var b = function (b, n) { | |
this.trigger("onSuccess", { | |
result: b, | |
request: n | |
}) | |
}, l = function (b) { | |
this.trigger("onError", { | |
error: b | |
}) | |
} | |
}; | |
Spotify.Proto.Data = function (b, l) { | |
Spotify.EventTarget.call(this); | |
var f = this, | |
n, p = {}, r = new Spotify.Events; | |
this.initialize = function () { | |
var m = new Spotify.Service; | |
m.url = b + "data.xml" + l; | |
m.async = !1; | |
m.dataType = "text"; | |
m.bind("onSuccess", a, this); | |
m.bind("onError", q, this); | |
m.fetch() | |
}; | |
this.getDefinition = function (a) { | |
if ("undefined" !== typeof p[a]) return p[a]; | |
var h = n.getElementsByTagName(a); | |
return "undefined" !== typeof h && h[0] && h[0].firstChild ? (p[a] = h[0].firstChild.data + "\n", p[a]) : "" | |
}; | |
this.getMultipleDefinitions = function (a) { | |
var h = | |
"", | |
g = 0, | |
d, c; | |
if (!Spotify.Utils.isArray(a)) throw Error("Definition identifiers must be an array with strings"); | |
for (; g < a.length; g++) c = a[g], "undefined" !== typeof p[c] ? h += p[c] : (d = n.getElementsByTagName(c), "undefined" !== typeof d && d[0] && d[0].firstChild && (p[c] = d[0].firstChild.data + "\n", h += p[c])); | |
return h | |
}; | |
var a = function (a) { | |
n = Spotify.Utils.convertStringToXML(a.params.result); | |
f.trigger(r.SUCCESS) | |
}, q = function (a) { | |
f.trigger(r.ERROR, a.params) | |
} | |
}; | |
(function () { | |
Spotify.Link = function (a, b) { | |
this.type = a; | |
for (var m in b) this[m] = b[m] | |
}; | |
var b = Spotify.Link; | |
b.Type = { | |
EMPTY: "empty", | |
ALBUM: "album", | |
AD: "ad", | |
APPLICATION: "application", | |
ARTIST: "artist", | |
ARTIST_TOPLIST: "artist-toplist", | |
AUDIO_FILE: "audiofile", | |
COLLECTION: "collection", | |
COLLECTION_ALBUM: "collection-album", | |
COLLECTION_MISSING_ALBUM: "collection-missing-album", | |
COLLECTION_ARTIST: "collection-artist", | |
CONTEXT_GROUP: "context-group", | |
FACEBOOK: "facebook", | |
FOLLOWERS: "followers", | |
FOLLOWING: "following", | |
IMAGE: "image", | |
INBOX: "inbox", | |
LOCAL_ARTIST: "local-artist", | |
LOCAL_ALBUM: "local-album", | |
LOCAL: "local", | |
LIBRARY: "library", | |
MOSAIC: "mosaic", | |
PLAYLIST: "playlist", | |
PROFILE: "profile", | |
PUBLISHED_ROOTLIST: "published-rootlist", | |
RADIO: "radio", | |
ROOTLIST: "rootlist", | |
COLLECTION_TRACK_LIST: "collectiontracklist", | |
SEARCH: "search", | |
STARRED: "starred", | |
TEMP_PLAYLIST: "temp-playlist", | |
TOPLIST: "toplist", | |
TRACK: "track", | |
TRACKSET: "trackset", | |
USER_TOPLIST: "user-toplist", | |
USET_TOP_TRACKS: "user-top-tracks" | |
}; | |
var l = function (a) { | |
return !!a | |
}, f = function (a, b) { | |
var m, h = 1; | |
if (0 == a.indexOf("spotify:")) m = | |
a.slice(8).split(":"), h = 0; | |
else if (0 == a.indexOf("http://play.spotify.com/")) m = a.slice(24).split("/"); | |
else if (0 == a.indexOf("https://play.spotify.com/")) m = a.slice(25).split("/"); | |
else if (0 == a.indexOf("http://open.spotify.com/")) m = a.slice(24).split("/"); | |
else if (0 == a.indexOf("https://open.spotify.com/")) m = a.slice(25).split("/"); | |
else throw "Invalid Spotify URI!"; | |
Array.prototype.push.apply(b, m); | |
return h | |
}, n = function (a, b) { | |
a = encodeURIComponent(a); | |
return 0 == b ? a.replace(/%20/g, "+") : a | |
}, p = function (a, b) { | |
return decodeURIComponent(0 == | |
b ? a.replace(/\+/g, "%20") : a) | |
}, r = function (a, q) { | |
var m, h, g; | |
a.id && (m = Spotify.Utils.Base62.fromHex(a.id, 22)); | |
switch (a.type) { | |
case b.Type.ALBUM: | |
return h = ["album", m], a.disc && h.push(a.disc), h; | |
case b.Type.AD: | |
return ["ad", a.id]; | |
case b.Type.ARTIST: | |
return ["artist", m]; | |
case b.Type.ARTIST_TOPLIST: | |
return ["artist", m, "top", a.toplist]; | |
case b.Type.SEARCH: | |
return ["search", n(a.query, q)]; | |
case b.Type.TRACK: | |
return ["track", m]; | |
case b.Type.TRACKSET: | |
h = []; | |
m = 0; | |
for (g = a.tracks.length; m < g; m++) h.push(Spotify.Utils.Base62.fromHex(a.tracks[m].id, | |
22)); | |
h = [h.join(",")]; | |
null !== a.index && h.push("#", a.index); | |
return ["trackset", n(a.name)].concat(h); | |
case b.Type.FACEBOOK: | |
return ["user", "facebook", a.uid]; | |
case b.Type.AUDIO_FILE: | |
return ["audiofile", a.extension, a.id]; | |
case b.Type.FOLLOWERS: | |
return ["user", n(a.username), "followers"]; | |
case b.Type.FOLLOWING: | |
return ["user", n(a.username), "following"]; | |
case b.Type.PLAYLIST: | |
return ["user", n(a.username), "playlist", m]; | |
case b.Type.STARRED: | |
return ["user", n(a.username), "starred"]; | |
case b.Type.TEMP_PLAYLIST: | |
return ["temp-playlist", | |
a.origin, a.data]; | |
case b.Type.CONTEXT_GROUP: | |
return ["context-group", a.origin, a.name]; | |
case b.Type.USER_TOPLIST: | |
return ["user", n(a.username), "top", a.toplist]; | |
case b.Type.USET_TOP_TRACKS: | |
return ["user", n(a.username), "toplist"]; | |
case b.Type.TOPLIST: | |
return ["top", a.toplist].concat(a.global ? ["global"] : ["country", a.country]); | |
case b.Type.INBOX: | |
return ["user", n(a.username), "inbox"]; | |
case b.Type.ROOTLIST: | |
return ["user", n(a.username), "rootlist"]; | |
case b.Type.PUBLISHED_ROOTLIST: | |
return ["user", n(a.username), "publishedrootlist"]; | |
case b.Type.COLLECTION_TRACK_LIST: | |
return ["user", n(a.username), "collectiontracklist", m]; | |
case b.Type.PROFILE: | |
return a.args && 0 < a.args.length ? ["user", n(a.username)].concat(a.args) : ["user", n(a.username)]; | |
case b.Type.LOCAL_ARTIST: | |
return ["local", n(a.artist, q)]; | |
case b.Type.LOCAL_ALBUM: | |
return ["local", n(a.artist, q), n(a.album, q)]; | |
case b.Type.LOCAL: | |
return ["local", n(a.artist, q), n(a.album, q), n(a.track, q), a.duration]; | |
case b.Type.LIBRARY: | |
return ["user", n(a.username), "library"].concat(a.category ? [a.category] : []); | |
case b.Type.IMAGE: | |
return ["image", | |
a.id]; | |
case b.Type.MOSAIC: | |
return h = a.ids.slice(0), h.unshift("mosaic"), h; | |
case b.Type.RADIO: | |
return ["radio", a.args]; | |
case b.Type.APPLICATION: | |
h = ["app", a.id]; | |
var d = a.args || []; | |
m = 0; | |
for (g = d.length; m < g; ++m) h.push(n(d[m], q)); | |
return h; | |
case b.Type.COLLECTION_ALBUM: | |
return ["user", n(a.username), "collection", "album", m]; | |
case b.Type.COLLECTION_MISSING_ALBUM: | |
return ["user", n(a.username), "collection", "album", m, "missing"]; | |
case b.Type.COLLECTION_ARTIST: | |
return ["user", n(a.username), "collection", "artist", m]; | |
case b.Type.COLLECTION: | |
return ["user", | |
n(a.username), "collection"].concat(a.category ? [a.category] : []); | |
default: | |
throw "Invalid Spotify URI!"; | |
} | |
}; | |
b.prototype.toURI = function () { | |
return "spotify:" + r(this, 0).join(":") | |
}; | |
b.prototype.toAppLink = function () { | |
if (this.type == b.Type.APPLICATION) return b.applicationLink(this.id, this.args); | |
var a = r(this, 1), | |
q = a.shift(); | |
a.length && (a = a.map(function (a) { | |
return p(a, 1) | |
})); | |
return b.applicationLink(q, this.type == b.Type.RADIO ? a.shift().split(":") : a) | |
}; | |
b.prototype.toAppURI = function () { | |
return this.type == b.Type.APPLICATION ? this.toURI() : | |
"spotify:" + ["app"].concat(r(this, 0)).join(":") | |
}; | |
b.prototype.toURLPath = function () { | |
var a = r(this, 1); | |
"app" === a[0] && a.shift(); | |
"trackset" != a[0] && (a = a.filter(l)); | |
return a.join("/") | |
}; | |
b.prototype.toURL = function (a) { | |
"undefined" === typeof a && (a = !0); | |
return a ? "http://play.spotify.com/" + this.toURLPath() : "/" + this.toURLPath() | |
}; | |
b.prototype.toSecureURL = function () { | |
return "https://play.spotify.com/" + this.toURLPath() | |
}; | |
b.prototype.toString = function () { | |
return this.toURI() | |
}; | |
b.prototype.idToByteString = function () { | |
for (var a = Spotify.Utils.Base62.fromHex(this.id), | |
a = Spotify.Utils.Base62.toBytes(a), a = a.map(function (a) { | |
return String.fromCharCode(a) | |
}).join(""); 16 > a.length;) a = String.fromCharCode(0) + a; | |
return a | |
}; | |
b.fromString = function (a) { | |
var q = [], | |
m = f(a, q), | |
h = 0, | |
g = function () { | |
return q[h++] | |
}; | |
a = function () { | |
var a = g(); | |
return 22 == a.length ? Spotify.Utils.Base62.toHex(a, 32) : a | |
}; | |
var d = function () { | |
return q.slice(h).join(0 == m ? ":" : "/") | |
}, c = g(); | |
switch (c) { | |
case "album": | |
return b.albumLink(a(), parseInt(g(), 10)); | |
case "ad": | |
return b.adLink(a()); | |
case "artist": | |
return c = a(), "top" == g() ? b.artistToplistLink(c, | |
g()) : b.artistLink(c); | |
case "audiofile": | |
return b.audioFileLink(g(), g()); | |
case "temp-playlist": | |
return b.temporaryPlaylistLink(g(), d()); | |
case "search": | |
return b.searchLink(p(d(), m)); | |
case "track": | |
return b.trackLink(a()); | |
case "trackset": | |
var c = p(g()), | |
k = g(); | |
a = g(); | |
var s = parseInt(g(), 10); | |
if ("%23" !== a || isNaN(s)) s = null; | |
var x = []; | |
if (k) | |
for (k = p(k).split(","), a = 0, d = k.length; a < d; a++) x.push(b.trackLink(Spotify.Utils.Base62.toHex(k[a], 32))); | |
return b.tracksetLink(x, c, s); | |
case "context-group": | |
return b.contextGroupLink(g(), | |
g()); | |
case "top": | |
return a = g(), "global" == g() ? b.toplistLink(a, null, !0) : b.toplistLink(a, g(), !1); | |
case "user": | |
d = p(g(), m); | |
c = g(); | |
if ("facebook" == d && null != c) return b.facebookLink(parseInt(c, 10)); | |
if (null != c) switch (c) { | |
case "playlist": | |
return b.playlistLink(d, a()); | |
case "collectiontracklist": | |
return b.collectionTrackList(d, a()); | |
case "collection": | |
switch (c = g(), c) { | |
case "album": | |
return c = a(), "missing" === g() ? b.collectionMissingAlbumLink(d, c) : b.collectionAlbumLink(d, c); | |
case "artist": | |
return b.collectionArtistLink(d, a()); | |
default: | |
return b.collectionLink(d, c) | |
} | |
case "starred": | |
return b.starredLink(d); | |
case "followers": | |
return b.followersLink(d); | |
case "following": | |
return b.followingLink(d); | |
case "top": | |
return b.userToplistLink(d, g()); | |
case "inbox": | |
return b.inboxLink(d); | |
case "rootlist": | |
return b.rootlistLink(d); | |
case "publishedrootlist": | |
return b.publishedRootlistLink(d); | |
case "toplist": | |
return b.userTopTracksLink(d); | |
case "library": | |
return b.libraryLink(d, g()) | |
} | |
a = q.slice(h); | |
return null != c && 0 < a.length ? b.profileLink(d, [c].concat(a)) : null != | |
c ? b.profileLink(d, [c]) : b.profileLink(d); | |
case "local": | |
return a = (a = g()) && p(a, m), c = (d = g()) && p(d, m), s = (k = g()) && p(k, m), x = g(), x = parseInt(x, 10), void 0 !== k ? b.localLink(a, c, s, x) : void 0 !== d ? b.localAlbumLink(a, c) : b.localArtistLink(a); | |
case "image": | |
return b.imageLink(a()); | |
case "mosaic": | |
return b.mosaicLink(q.slice(h)); | |
case "radio": | |
return b.radioLink(d()); | |
default: | |
c = "app" === c ? g() : c; | |
k = q.slice(h); | |
a = 0; | |
for (d = k.length; a < d; ++a) k[a] = p(k[a], m); | |
return b.applicationLink(c, k) | |
} | |
throw "Invalid Spotify URI!"; | |
}; | |
b.emptyLink = function () { | |
return new b(b.Type.EMPTY, {}) | |
}; | |
b.albumLink = function (a, q) { | |
return new b(b.Type.ALBUM, { | |
id: a, | |
disc: q | |
}) | |
}; | |
b.adLink = function (a) { | |
return new b(b.Type.AD, { | |
id: a | |
}) | |
}; | |
b.artistLink = function (a) { | |
return new b(b.Type.ARTIST, { | |
id: a | |
}) | |
}; | |
b.artistToplistLink = function (a, q) { | |
return new b(b.Type.ARTIST_TOPLIST, { | |
id: a, | |
toplist: q | |
}) | |
}; | |
b.searchLink = function (a) { | |
return new b(b.Type.SEARCH, { | |
query: a | |
}) | |
}; | |
b.trackLink = function (a) { | |
return new b(b.Type.TRACK, { | |
id: a | |
}) | |
}; | |
b.tracksetLink = function (a, q, m) { | |
return new b(b.Type.TRACKSET, { | |
tracks: a, | |
name: q || "", | |
index: isNaN(m) ? null : m | |
}) | |
}; | |
b.facebookLink = function (a) { | |
return new b(b.Type.FACEBOOK, { | |
uid: a | |
}) | |
}; | |
b.audioFileLink = function (a, q) { | |
return new b(b.Type.AUDIO_FILE, { | |
id: q, | |
extension: a | |
}) | |
}; | |
b.followersLink = function (a) { | |
return new b(b.Type.FOLLOWERS, { | |
username: a | |
}) | |
}; | |
b.followingLink = function (a) { | |
return new b(b.Type.FOLLOWING, { | |
username: a | |
}) | |
}; | |
b.playlistLink = function (a, q) { | |
return new b(b.Type.PLAYLIST, { | |
username: a, | |
id: q | |
}) | |
}; | |
b.collectionTrackList = function (a, q) { | |
return new b(b.Type.COLLECTION_TRACK_LIST, { | |
username: a, | |
id: q | |
}) | |
}; | |
b.starredLink = function (a) { | |
return new b(b.Type.STARRED, { | |
username: a | |
}) | |
}; | |
b.userToplistLink = function (a, q) { | |
return new b(b.Type.USER_TOPLIST, { | |
username: a, | |
toplist: q | |
}) | |
}; | |
b.userTopTracksLink = function (a) { | |
return new b(b.Type.USET_TOP_TRACKS, { | |
username: a | |
}) | |
}; | |
b.toplistLink = function (a, q, m) { | |
return new b(b.Type.TOPLIST, { | |
toplist: a, | |
country: q, | |
global: !! m | |
}) | |
}; | |
b.inboxLink = function (a) { | |
return new b(b.Type.INBOX, { | |
username: a | |
}) | |
}; | |
b.rootlistLink = function (a) { | |
return new b(b.Type.ROOTLIST, { | |
username: a | |
}) | |
}; | |
b.publishedRootlistLink = function (a) { | |
return new b(b.Type.PUBLISHED_ROOTLIST, { | |
username: a | |
}) | |
}; | |
b.localArtistLink = function (a) { | |
return new b(b.Type.LOCAL_ARTIST, { | |
artist: a | |
}) | |
}; | |
b.localAlbumLink = function (a, q) { | |
return new b(b.Type.LOCAL_ALBUM, { | |
artist: a, | |
album: q | |
}) | |
}; | |
b.localLink = function (a, q, m, h) { | |
return new b(b.Type.LOCAL, { | |
artist: a, | |
album: q, | |
track: m, | |
duration: h | |
}) | |
}; | |
b.libraryLink = function (a, q) { | |
return new b(b.Type.LIBRARY, { | |
username: a, | |
category: q | |
}) | |
}; | |
b.collectionLink = function (a, q) { | |
return new b(b.Type.COLLECTION, { | |
username: a, | |
category: q | |
}) | |
}; | |
b.temporaryPlaylistLink = function (a, q) { | |
return new b(b.Type.TEMP_PLAYLIST, { | |
origin: a, | |
data: q | |
}) | |
}; | |
b.contextGroupLink = function (a, q) { | |
return new b(b.Type.CONTEXT_GROUP, { | |
origin: a, | |
name: q | |
}) | |
}; | |
b.profileLink = function (a, q) { | |
return new b(b.Type.PROFILE, { | |
username: a, | |
args: q | |
}) | |
}; | |
b.imageLink = function (a) { | |
return new b(b.Type.IMAGE, { | |
id: a | |
}) | |
}; | |
b.mosaicLink = function (a) { | |
return new b(b.Type.MOSAIC, { | |
ids: a | |
}) | |
}; | |
b.radioLink = function (a) { | |
a = "undefined" === typeof a ? [] : a; | |
return new b(b.Type.RADIO, { | |
args: a | |
}) | |
}; | |
b.applicationLink = function (a, q) { | |
q = "undefined" === typeof q ? [] : q; | |
return new b(b.Type.APPLICATION, { | |
id: a, | |
args: q | |
}) | |
}; | |
b.collectionAlbumLink = | |
function (a, q) { | |
return new b(b.Type.COLLECTION_ALBUM, { | |
username: a, | |
id: q | |
}) | |
}; | |
b.collectionMissingAlbumLink = function (a, q) { | |
return new b(b.Type.COLLECTION_MISSING_ALBUM, { | |
username: a, | |
id: q | |
}) | |
}; | |
b.collectionArtistLink = function (a, q) { | |
return new b(b.Type.COLLECTION_ARTIST, { | |
username: a, | |
id: q | |
}) | |
}; | |
b.fromByteString = function (a, q, m) { | |
for (var h = [], g = 0; g < q.length; g++) h.push(q.charCodeAt(g)); | |
q = Spotify.Utils.Base62.fromBytes(h, 22); | |
q = Spotify.Utils.Base62.toHex(q); | |
m = m || {}; | |
m.id = q; | |
return new b(a, m) | |
} | |
})(); | |
(function () { | |
var b; | |
Spotify.Logging.Types = function () { | |
return "undefined" !== typeof b ? b : b = { | |
TRACK_END: "TRACK_END", | |
PREVIEW_END: "PREVIEW_END", | |
TRACK_EVENT: "TRACK_EVENT", | |
TRACK_PROGRESS: "TRACK_PROGRESS", | |
REQUEST_TIME: "REQUEST_TIME", | |
AD_END: "EndAd" | |
} | |
} | |
})(); | |
Spotify.Logging.TrackEnd = function () { | |
Spotify.EventTarget.call(this); | |
var b, l = function (b) {}, f = function (b) {}; | |
this.serviceIsReady = !0; | |
this.log = function (n) { | |
b.rpc("track_end", [n.lid, n.ms_played, n.ms_played_union, n.n_seeks_forward, n.n_seeks_backward, n.ms_seeks_forward, n.ms_seeks_backward, n.ms_latency, n.display_track, n.play_context, n.source_start, n.source_end, n.reason_start, n.reason_end, n.referrer, n.referrer_version, n.referrer_vendor, n.max_continuous, n.gaia_dev_id, n.accepted_tc], l, f, this, !0, 2, "track_end") | |
}; | |
this.init = function (f) { | |
b = f | |
} | |
}; | |
Spotify.Logging.PreviewEnd = function () { | |
Spotify.EventTarget.call(this); | |
new Spotify.Logging.Logger; | |
this.serviceIsReady = !0; | |
this.log = function (b) {}; | |
this.init = function () {} | |
}; | |
Spotify.Logging.TrackEvent = function () { | |
Spotify.EventTarget.call(this); | |
var b, l = function (b) {}, f = function (b) {}; | |
this.serviceIsReady = !0; | |
this.log = function (n) { | |
b.rpc("track_event", [n.lid, n.event, n.ms_where], l, f, this, !0, 2, "track_event") | |
}; | |
this.init = function (f) { | |
b = f | |
} | |
}; | |
Spotify.Logging.TrackProgress = function () { | |
Spotify.EventTarget.call(this); | |
var b = Spotify.DebuggerJS, | |
l, f = function (f) { | |
b.log("Spotify.Logging.TrackProgress", ["Track progress success", f], "corejs") | |
}, n = function (f) { | |
b.error("Spotify.Logging.TrackProgress", ["On track progress error", f], "corejs") | |
}; | |
this.serviceIsReady = !0; | |
this.log = function (b) { | |
l.rpc("track_progress", [b.lid, b.source_start, b.reason_start, b.ms_played, b.ms_latency, b.play_context, b.display_track, b.referrer, b.referrer_version, b.referrer_vendor], f, n, this, !0, 2, "track_progress") | |
}; | |
this.init = function (b) { | |
l = b | |
} | |
}; | |
Spotify.Logging.ClientEvent = function () { | |
this.log = function (b, l, f) { | |
this.services.logging_logger.logClientEvent(b, l, f) | |
} | |
}; | |
Spotify.Logging.AdEnd = function () { | |
Spotify.EventTarget.call(this); | |
var b, l = function (b) {}, f = function (b) {}; | |
this.serviceIsReady = !0; | |
this.log = function (n) { | |
b.rpc("log_ad", ["5", String(n.ad_file_id), String(n.song_id), String(n.source_start), String(n.reason_start), String(n.source_end), String(n.reason_end), String(n.bytes_played), String(n.content_length), String(n.ms_played), String(n.ms_played_union), String(n.ms_rcv_latency), String(n.n_seeks_backward), String(n.ms_seeks_backward), String(n.n_seeks_forward), String(n.ms_seeks_forward), | |
String(n.ms_latency), String(n.num_stutter), String(n.p_lowbuffer), String(n.skipped), String(n.clicked), String(n.token), String(n.last_stream_started_at), String(n.client_ad_count), String(n.client_campaign_count) | |
], l, f, this, !0, 2, "log_ad") | |
}; | |
this.init = function (f) { | |
b = f | |
} | |
}; | |
Spotify.Logging.View = function () { | |
var b = function (b) {}, l = function (b) {}; | |
this.log = function (f, n, p, r) { | |
if ("string" !== typeof f) throw Error("Uri must be a string"); | |
if ("string" !== typeof n) throw Error("View version must be a string"); | |
if ("string" !== typeof p) throw Error("View vendor must be a string"); | |
if ("number" !== typeof r) throw Error("Duration must be a number"); | |
f = new Spotify.Calls.Simple({ | |
method: "log_view", | |
payload: [f, n, p, r], | |
context: this, | |
persistent: !0, | |
retries: 2, | |
type: "log_view" | |
}, b, l); | |
this.send(f) | |
} | |
}; | |
(function () { | |
var b; | |
Spotify.Logging.Logger = function () { | |
if ("undefined" !== typeof b) return b; | |
b = this; | |
var l = Spotify.DebuggerJS, | |
f = new Spotify.Events, | |
n = new Spotify.RateLimiter(3E4, 100), | |
p = {}, r = ["ad_id", "campaign_id", "duration", "token"], | |
a = function (a) { | |
l.log("Spotify.Logging.Logger", ["Logging was successfull", a], "corejs") | |
}, q = function (a) { | |
l.error("Spotify.Logging.Logger", ["Logging was NOT successfull", a], "corejs") | |
}, m = function (a, c) { | |
return void 0 === a || null === a ? c : a | |
}; | |
this.logClientEvent = function (d, c, k) { | |
if ("string" !== | |
typeof d.source) throw Error("Source must be a string"); | |
"string" !== typeof d.context && (d.context = ""); | |
if ("string" !== typeof d.event) throw Error("Event name must be a string"); | |
"string" !== typeof d.event_version && (d.event_version = ""); | |
"string" !== typeof d.test_version && (d.test_version = ""); | |
if ("string" !== typeof d.source_version) throw Error("Source version name must be a string"); | |
if ("string" !== typeof d.source_vendor) throw Error("Source vendor name must be a string"); | |
"string" !== typeof d.data && (d.data = JSON.stringify(d.data) || | |
"{}"); | |
d = new Spotify.Calls.Simple({ | |
method: "log", | |
payload: [151, 3, d.source, d.context, d.event, d.event_version, d.test_version, d.source_version, d.source_vendor, d.data], | |
context: this, | |
persistent: !0, | |
retries: 2, | |
type: "ClientEvent" | |
}, c || a, k || q); | |
this.send(d); | |
l.log("Spotify.Logging.Logger", ["Logged client event", d], "corejs") | |
}; | |
this.logJSExceptions = function (d, c, k, g) { | |
if ("undefined" !== typeof d && "undefined" !== typeof c && "undefined" !== typeof k && "undefined" !== typeof g) { | |
var h = new Spotify.Calls.Simple({ | |
method: "log", | |
payload: [202, | |
1, d, c, k, g | |
], | |
context: this, | |
persistent: !0, | |
retries: 2, | |
type: "js_exceptions" | |
}, a, q); | |
this.send(h); | |
l.log("Spotify.Logging.Logger", ["js_exceptions", arguments], "corejs") | |
} | |
}; | |
this.logWindowSize = function (d, c) { | |
var k = new Spotify.Calls.Simple({ | |
method: "log", | |
payload: [41, 1, d, c, 0, 0], | |
context: this, | |
persistent: !0, | |
retries: 0, | |
type: "window_size" | |
}, a, q); | |
this.send(k); | |
l.log("Spotify.Logging.Logger", ["window_size", arguments], "corejs") | |
}; | |
this.logRequestTime = function (d, c, k, g, h) { | |
if ("undefined" !== typeof d && "undefined" !== typeof c && "undefined" !== | |
typeof k && "undefined" !== typeof g && "undefined" !== typeof h) { | |
var b = new Spotify.Calls.Simple({ | |
method: "log", | |
payload: [30, 1, d, c, k, g, h], | |
context: this, | |
persistent: !0, | |
retries: 2, | |
type: "request_time" | |
}, a, q); | |
this.send(b); | |
l.log("Spotify.Logging.Logger", ["request_time", arguments], "corejs") | |
} | |
}; | |
this.logEndPreview = function (d, c, k, g, h, b, m, f, w) { | |
var u = new Spotify.Calls.Simple({ | |
method: "log", | |
payload: [216, 1, d, c, k, g, h, b, m, f, w], | |
context: this, | |
persistent: !0, | |
retries: 2, | |
type: "end_preview" | |
}, a, q); | |
this.send(u); | |
l.log("Spotify.Logging.Logger", ["end_preview", arguments], "corejs") | |
}; | |
this.logBannerShown = function (d) { | |
for (var c = 0, k = r.length; c < k; c++) | |
if (!d.hasOwnProperty(r[c])) { | |
q("required logEntry parameter missing: " + r[c]); | |
return | |
} | |
d = [5, d.ad_id, d.campaign_id, d.token, Math.floor(d.duration), m(d.window_width, 0), m(d.window_height, 0), m(d.original_width, 0), m(d.original_height, 0), m(d.available_width, 0), m(d.available_height, 0), String( !! d.ad_clicked), m(d.error, ""), m(d.seconds_lost, 0), m(d.time_started, 0), m(d.client_ad_count, 0), m(d.client_campaign_count, 0)]; | |
c = new Spotify.Calls.Simple({ | |
method: "log_bannershown", | |
payload: d, | |
context: this, | |
persistent: !0, | |
retries: 2, | |
type: "log_bannershown" | |
}, a, q); | |
this.send(c); | |
l.log("Spotify.Logging.Logger", ["banner_shown", d], "corejs") | |
}; | |
this.logAggregatedRequestTime = function (a, c) { | |
"undefined" !== typeof a && "undefined" !== typeof c && (n.addToBucket({ | |
messageType: 30, | |
messageVersion: 1, | |
type: a, | |
latency: c | |
}), n.isStarted() || n.start()) | |
}; | |
this.log = function (d, c) { | |
var k = Array.prototype.slice.call(arguments); | |
if ("undefined" !== typeof d && "undefined" !== typeof c) { | |
var g = | |
new Spotify.Calls.Simple({ | |
method: "log", | |
payload: k, | |
context: this, | |
persistent: !0, | |
retries: 2, | |
type: "log" | |
}, a, q); | |
this.send(g); | |
l.log("Spotify.Logging.Logger", ["Log", k], "corejs") | |
} | |
}; | |
var h = function (a) { | |
a = a.params; | |
"undefined" === typeof p[a.type] && (p[a.type] = { | |
min: Number.MAX_VALUE, | |
max: 0, | |
sum: 0, | |
sumpow2: 0, | |
count: 0, | |
mean: 0, | |
std_deviation: 0 | |
}); | |
p[a.type].count++; | |
p[a.type].sum += a.latency; | |
p[a.type].sumpow2 += Math.pow(a.latency, 2); | |
p[a.type].min > a.latency && (p[a.type].min = a.latency); | |
p[a.type].max < a.latency && (p[a.type].max = a.latency) | |
}, | |
g = function (d) { | |
for (var c in p) d = p[c], d.mean = Math.floor(d.sum / d.count), d.std_deviation = Math.floor(Math.sqrt(d.sumpow2 - Math.pow(d.mean, 2), 2)), d = new Spotify.Calls.Simple({ | |
method: "log", | |
payload: [232, 1, c, d.count, d.sum, d.sumpow2, d.min, d.max, d.mean, d.std_deviation], | |
context: this, | |
persistent: !0, | |
retries: 2, | |
type: "aggregated_request_latencies" | |
}, a, q), this.send(d); | |
l.log("Spotify.Logging.Logger", ["Aggregated Request Latencies", p], "corejs"); | |
p = {}; | |
n.isStarted() || n.start() | |
}; | |
this.setup = function () { | |
n.bind(f.RATE_LIMIT_CALL, | |
h, this); | |
n.bind(f.RATE_LIMIT_AFTER_INTERVAL, g, this) | |
} | |
} | |
})(); | |
Spotify.PlayerTracker = function (b, l, f) { | |
Spotify.EventTarget.call(this); | |
this.id = b; | |
var n = Spotify.DebuggerJS, | |
p = !1, | |
r, a = new Spotify.Events, | |
q = {}, m, h = 0, | |
g = 0, | |
d = 0, | |
c = 0, | |
k = [], | |
s = 0, | |
x = 0, | |
z = 0, | |
t = 0, | |
v = 0, | |
w = 0, | |
u = "", | |
A = "unknown", | |
y = "unknown", | |
B = "unknown", | |
E = "unknown", | |
C = "unknown", | |
H = "unknown", | |
I = "unknown", | |
G = "unknown", | |
M = "na", | |
N = "none", | |
K = "", | |
J = new Spotify.Logging.Types, | |
D = new Spotify.Cache.Default(100, new Spotify.Cache.LocalStorage("tracker")), | |
F = !1, | |
L = !1, | |
Q = !1, | |
O = {}, Y = 0, | |
W = -1, | |
R = function (c) { | |
var b = q[c], | |
f = 0, | |
p = {}; | |
if ("" !== K || "" === K && Q) { | |
d = F ? d : S(k); | |
u = u || ""; | |
A = A || "unknown"; | |
y = y || "unknown"; | |
E = E || "unknown"; | |
H = H || "unknown"; | |
I = I || "unknown"; | |
G = G || "unknown"; | |
0 !== s || 0 !== x || c !== J.TRACK_END && c !== J.AD_END || (h = g = d); | |
c === J.AD_END && void 0 !== l.ad ? (p.ad_file_id = l.ad.file_id, p.song_id = l.ad.ad_id, p.bytes_played = 0, p.content_length = 0, p.ms_rcv_latency = 0, p.num_stutter = 0, p.p_lowbuffer = 0, p.skipped = 0, p.last_stream_started_at = (new Date(v)).toISOString(), p.token = l.ad.token, p.clicked = l.ad.has_been_clicked ? 1 : 0, p.client_ad_count = l.ad.adPlayCount, p.client_campaign_count = l.ad.campaignPlayCount, | |
p.source_start = "pendad", p.source_end = "trackdone", p.reason_end = "albumtrackdone") : c === J.TRACK_END ? (p.lid = K, p.source_start = y, p.source_end = B, p.reason_end = C) : c === J.TRACK_PROGRESS ? (p.lid = K, p.play_track = m, p.source_start = y, p.bitrate = l.bitrate, p.audiocodec = l.audiocodec) : c === J.PREVIEW_END && (p.bitrate = l.bitrate, p.audiocodec = l.audiocodec, p.reason_end = C); | |
p.max_continuous = h; | |
p.ms_played = g; | |
p.ms_played_union = d; | |
p.n_seeks_forward = s; | |
p.n_seeks_backward = x; | |
p.ms_seeks_forward = z; | |
p.ms_seeks_backward = t; | |
p.ms_latency = w; | |
p.display_track = | |
u; | |
p.play_context = A; | |
p.reason_start = E; | |
p.referrer = H; | |
p.referrer_version = I; | |
p.referrer_vendor = G; | |
p.gaia_dev_id = N; | |
for (p.accepted_tc = M; f < b.length; f++) b[f].log(p); | |
c === J.AD_END && void 0 !== l.ad && (F || r.trigger(a.RECORD_AD_EVENT, { | |
playerId: l.id, | |
adUri: "spotify:ad:" + l.ad.file_id, | |
type: "impression" | |
}), delete l.ad); | |
F && (F = !1); | |
n.log("Spotify.PlayerTracker", ["Logging song data -> Type:", c, "-> Arguments:", p, " of player", l.id], "corejs") | |
} | |
}, Z = function (a) { | |
var c = q[J.TRACK_EVENT], | |
d = 0; | |
if ("" !== K) | |
for (a = { | |
lid: K, | |
event: a, | |
ms_where: l.position() | |
}; d < | |
c.length; d++) c[d].log(a) | |
}, aa = function (a) { | |
g += a.params.interval; | |
c = l.getPlayerState().position; | |
a = 1E3 * Math.floor(0.001 * g); | |
(0 === a % 15E3 || 1E3 > g) && 4 > Y && !L && W !== a && (l.isPreview || R(J.TRACK_PROGRESS), Y++, W = a) | |
}, ha = function (a) { | |
k.push({ | |
type: "START", | |
time: parseInt(a) | |
}); | |
p = !0 | |
}, ba = function (a) { | |
k.push({ | |
type: "END", | |
time: parseInt(a) | |
}); | |
p = !1 | |
}, la = function () { | |
n.log("Spotify.PlayerTracker", ["Cache is initialized..."], "corejs"); | |
D.get(Spotify.Utils.Base64.encode(f) + ":stats:" + l.id, ca, r) | |
}, pa = function () {}, qa = function (a) { | |
n.log("Spotify.PlayerTracker", ["endSongData are now stored", arguments], "corejs") | |
}, U = function (a) { | |
n.error("Spotify.PlayerTracker", ["endSongData are NOT stored", arguments], "corejs") | |
}, ca = function (a, c) { | |
if (null !== c) { | |
D.remove(a, ma, r); | |
var k; | |
k = JSON.parse(Spotify.Utils.Base64.decode(c)); | |
if (L = k.isAd) l.ad || (l.ad = {}), l.ad.file_id = k.ad_file_id, l.ad.ad_id = k.ad_id, v = k.last_stream_started_at, l.ad.token = k.token, l.ad.has_been_clicked = k.clicked, l.ad.adPlayCount = k.client_ad_count, l.ad.campaignPlayCount = k.client_campaign_count; | |
K = k.lid; | |
Q = k.isPreview; | |
h = k.max_continuous; | |
d = k.ms_played_union; | |
g = k.ms_played; | |
s = k.n_seeks_forward; | |
x = k.n_seeks_backward; | |
z = k.ms_seeks_forward; | |
t = k.ms_seeks_backward; | |
w = k.ms_latency; | |
u = k.display_track; | |
A = k.play_context; | |
y = k.source_start; | |
B = k.source_end; | |
E = k.reason_start; | |
C = k.reason_end; | |
H = k.referrer; | |
I = k.referrer_version; | |
G = k.referrer_vendor; | |
N = k.gaia_dev_id; | |
M = k.accepted_tc; | |
F = !0; | |
L ? R(J.AD_END) : Q ? R(J.PREVIEW_END) : R(J.TRACK_END); | |
da() | |
} | |
}, ma = function () {}, da = function () { | |
Q = L = !1; | |
K = ""; | |
g = 0; | |
m = ""; | |
d = h = 0; | |
k = []; | |
w = t = z = x = s = 0; | |
u = ""; | |
G = I = H = C = E = B = y = A = "unknown"; | |
N = "none"; | |
M = "na" | |
}, ia = function (a, c) { | |
return a.time - c.time | |
}, S = function (a) { | |
for (var c = 0, d = 0, k = 0, g = 0, s = 0, b = 0; s < a.length; s++) 0 !== s % 2 && "undefined" !== typeof a[s - 1] && "START" === a[s - 1].type && (b = a[s].time - a[s - 1].time, h = b > h ? b : h); | |
n.log("Spotify.PlayerTracker", ["max continuous", h], "corejs"); | |
for (a.sort(ia); g < a.length; g++) "START" === a[g].type && (0 === d && (k = g), ++d), "END" === a[g].type && (--d, 0 === d && (c += a[g].time - a[k].time)); | |
n.log("Spotify.PlayerTracker", ["Union calculated:", c, "Segments:", a], "corejs"); | |
return c | |
}, T = function () { | |
ba(c); | |
var a = {}; | |
L ? (a.ad_file_id = l.ad.file_id, a.lid = l.ad.ad_id, a.last_stream_started_at = v, a.token = l.ad.token, a.clicked = l.ad.has_been_clicked, a.client_ad_count = l.ad.adPlayCount, a.client_campaign_count = l.ad.campaignPlayCount, a.source_start = "pendad") : (a.source_start = y || "unknown", a.lid = K); | |
a.isAd = L; | |
a.isPreview = Q; | |
a.source_end = a.source_start; | |
a.max_continuous = h; | |
a.ms_played = g; | |
a.ms_played_union = S(k); | |
a.n_seeks_forward = s; | |
a.n_seeks_backward = x; | |
a.ms_seeks_forward = z; | |
a.ms_seeks_backward = t; | |
a.ms_latency = w; | |
a.display_track = u || | |
""; | |
a.play_track = a.display_track; | |
a.play_context = A || "unknown"; | |
a.reason_start = E || "unknown"; | |
a.reason_end = "reload"; | |
a.referrer = H || "unknown"; | |
a.referrer_version = I || "unknown"; | |
a.referrer_vendor = G || "unknown"; | |
a.accepted_tc = M || "na"; | |
a.gaia_dev_id = N || "none"; | |
D.put(Spotify.Utils.Base64.encode(f) + ":stats:" + l.id, Spotify.Utils.Base64.encode(JSON.stringify(a)), qa, U, null, this) | |
}, ja = function () { | |
if ("" !== K) { | |
n.log("Spotify.PlayerTracker", ["Tracking the position changed event of player", l.id], "corejs"); | |
var a = parseInt(l.getPlayerState().position); | |
a !== c && (p && (n.log("Spotify.PlayerTracker", ["Union End from _onPositionChanged", c], "corejs"), ba(c)), a > c ? (s++, z += a - c, n.log("Spotify.PlayerTracker", ["Went forward", a - c, "ms"], "corejs")) : a < c && (x++, t += c - a, n.log("Spotify.PlayerTracker", ["Went back", c - a, "ms"], "corejs")), c = a, n.log("Spotify.PlayerTracker", ["Union Start from _onPositionChanged", c], "corejs"), ha(c)) | |
} | |
}; | |
this.onConnected = function () { | |
n.log("Spotify.PlayerTracker", ["Tracking the on connect event"], "corejs"); | |
"" !== K && (l.isPlaying ? (n.log("Spotify.PlayerTracker", ["Tracking the reconnect while playing event"], "corejs"), Z(1)) : l.isPaused && (n.log("Spotify.PlayerTracker", ["Tracking the reconnect while being paused event"], "corejs"), Z(2))) | |
}; | |
var X = function (a) { | |
v = a.params.timestamp | |
}, ea = function (a) { | |
n.log("Spotify.PlayerTracker", ["Tracking the on song loaded event", a], "corejs") | |
}, P = function (a) { | |
n.log("Spotify.PlayerTracker", ["Tracking the on load event of player", l.id], "corejs"); | |
K = l.lid; | |
m = l.trackUri; | |
L = l.isAd; | |
Q = l.isPreview; | |
w = (new Date).getTime() - v; | |
u = O.display_track || ""; | |
A = O.play_context || "unknown"; | |
y = O.source_start || "unknown"; | |
E = O.reason_start || "unknown"; | |
H = O.referrer || "unknown"; | |
I = O.referrer_version || "unknown"; | |
G = O.referrer_vendor || "unknown"; | |
M = O.accepted_tc || "na"; | |
c = l.getPlayerState().position; | |
n.log("Spotify.PlayerTracker", ["Union Start from _onLoaded", c], "corejs"); | |
ha(c) | |
}, ka = function () { | |
l.getPlayerState(); | |
Z(3); | |
n.log("Spotify.PlayerTracker", ["Tracking the on play event of player", l.id], "corejs") | |
}, fa = function () { | |
Z(4); | |
n.log("Spotify.PlayerTracker", ["Tracking the on pause event of player", | |
l.id | |
], "corejs") | |
}, ga = function () { | |
n.log("Spotify.PlayerTracker", ["Tracking the invalid track uri event of player", l.id], "corejs") | |
}, V = function () { | |
da(); | |
n.log("Spotify.PlayerTracker", ["Tracking the playback failed event of player", l.id], "corejs") | |
}; | |
this.setEndSongStartLog = function (a) { | |
"undefined" !== typeof a && (O = a) | |
}; | |
this.setEndSongStopLog = function (a) { | |
"undefined" !== typeof a && (B = a.source_end || "unknown", C = a.reason_end || "unknown") | |
}; | |
this.stopTrackingAndLog = function () { | |
n.log("Spotify.PlayerTracker", ["Stopping tracking and logging", | |
l.id | |
], "corejs"); | |
Y = 0; | |
W = -1; | |
n.log("Spotify.PlayerTracker", ["Union End from _logEndSongData", c], "corejs"); | |
ba(c); | |
L ? R(J.AD_END) : Q ? R(J.PREVIEW_END) : R(J.TRACK_END); | |
da() | |
}; | |
this.dispose = function (c) { | |
n.log("Spotify.PlayerTracker", ["Disposing tracker with id", this.id], "corejs"); | |
"undefined" !== typeof c && c || T(); | |
n.log("Spotify.PlayerTracker", ["Unbind event listeners"], "corejs"); | |
l.unbind(a.POSITION_CHANGED, ja, r); | |
l.unbind(a.PLAYING, ka, r); | |
l.unbind(a.PAUSED, fa, r); | |
l.unbind(a.INVALID_TRACK_URI, ga, r); | |
l.unbind(a.PLAYBACK_FAILED, | |
V, r); | |
l.unbind(a.TRACK_PLAY_REQUEST, X, r); | |
l.unbind(a.SONG_LOADED, ea, r); | |
l.unbind(a.LOAD, P, r); | |
l.unbind(a.PLAYER_STATE, aa, r) | |
}; | |
this.addLogger = function (a, c) { | |
"undefined" === typeof q[a] && (q[a] = []); | |
q[a].push(c) | |
}; | |
this.initialize = function () { | |
r = this; | |
D.initialize(la, pa, this); | |
n.log("Spotify.PlayerTracker", ["Binding event listeners"], "corejs"); | |
l.bind(a.POSITION_CHANGED, ja, r); | |
l.bind(a.PLAYING, ka, r); | |
l.bind(a.PAUSED, fa, r); | |
l.bind(a.INVALID_TRACK_URI, ga, r); | |
l.bind(a.PLAYBACK_FAILED, V, r); | |
l.bind(a.TRACK_PLAY_REQUEST, X, r); | |
l.bind(a.SONG_LOADED, ea, r); | |
l.bind(a.LOAD, P, r); | |
l.bind(a.PLAYER_STATE, aa, r) | |
} | |
}; | |
Spotify.Protobuf.Ieee754 = function () { | |
var b = {}, l = 1 / Math.LN2; | |
b.decodeFloat = function (b) { | |
if (0 === b) return 0; | |
var l = b >>> 31, | |
p = b >> 23 & 255; | |
b &= 8388607; | |
return 255 != p ? p ? (1 - (l << 1)) * Math.pow(2, p - 127 - 23) * (8388608 + b) : b ? (1 - (l << 1)) * Math.pow(2, -149) * b : l ? -0 : 0 : 0 === b ? Infinity * (1 - (l << 1)) : NaN | |
}; | |
b.encodeFloat = function (b) { | |
if (0 === b) return -Infinity === 1 / b ? -2147483648 : 0; | |
if (b !== b) return 2147483647; | |
if (2 * b !== b) { | |
for (var n = 0 > b, p = Math.abs(b), r = Math.log(p) * l | 0, a = Math.pow(2, r); a <= p; ++r, a *= 2); | |
a = r - 1 + 127; | |
if (0 < a) { | |
if (255 > a) return b = p * Math.pow(2, | |
150 - a) & 8388607, n << 31 | a << 23 | b | |
} else return b = p * Math.pow(2, 149) & 8388607, n << 31 | b | |
} | |
return 0 > b ? -8388608 : 2139095040 | |
}; | |
return b | |
}(); | |
Spotify.Protobuf.Parser = function () { | |
function b() {} | |
function l(b) { | |
var h = a[b.current.value], | |
g = b.next().value, | |
d = b.next().value; | |
b.expectToken("="); | |
var c = ~~b.next().value; | |
b.skipUntil(";"); | |
return { | |
name: d, | |
number: c, | |
label: h, | |
type: q[g], | |
type_name: q[g] ? void 0 : g, | |
default_value: void 0 | |
} | |
} | |
function f(a, h) { | |
h = { | |
name: a.next().value, | |
field: [], | |
nested_type: [], | |
enum_type: [] | |
}; | |
for (a.expectToken("{"); | |
"}" != a.next().type;) switch (a.current.value) { | |
case "optional": | |
case "repeated": | |
case "required": | |
h.field.push(l(a)); | |
break; | |
case "message": | |
h.nested_type.push(f(a)); | |
break; | |
case "enum": | |
h.enum_type.push(n(a)); | |
break; | |
case "extensions": | |
a.skipUntil(";"); | |
break; | |
case ";": | |
break; | |
default: | |
a.fail("Unrecognized message token: " + a.current.value) | |
} | |
return h | |
} | |
function n(a) { | |
var h = a.next().value; | |
a.expectToken("{"); | |
for (var g = []; | |
"}" != a.next().type;) { | |
var d = a.current.value; | |
a.expectToken("="); | |
var c = ~~a.next().value; | |
g.push({ | |
name: d, | |
number: c | |
}); | |
a.skipUntil(";") | |
} | |
return { | |
name: h, | |
value: g | |
} | |
} | |
var p = {}; | |
b.Label = { | |
LABEL_OPTIONAL: 1, | |
LABEL_REQUIRED: 2, | |
LABEL_REPEATED: 3 | |
}; | |
b.Type = { | |
TYPE_DOUBLE: 1, | |
TYPE_FLOAT: 2, | |
TYPE_INT64: 3, | |
TYPE_UINT64: 4, | |
TYPE_INT32: 5, | |
TYPE_FIXED64: 6, | |
TYPE_FIXED32: 7, | |
TYPE_BOOL: 8, | |
TYPE_STRING: 9, | |
TYPE_MESSAGE: 11, | |
TYPE_BYTES: 12, | |
TYPE_UINT32: 13, | |
TYPE_ENUM: 14, | |
TYPE_SFIXED32: 15, | |
TYPE_SFIXED64: 16, | |
TYPE_SINT32: 17, | |
TYPE_SINT64: 18 | |
}; | |
var r = function (a) { | |
this.text = a; | |
this.ptr = 0; | |
this.current = { | |
value: "", | |
type: "", | |
ptr: 0 | |
} | |
}; | |
r.prototype = { | |
where: function (a) { | |
a = void 0 === a ? this.current.ptr : a; | |
for (var h = 0, g = -1; g && g <= a;) g = this.text.indexOf("\n", g) + 1, ++h; | |
return "line: " + h | |
}, | |
fail: function (a, h) { | |
throw this.where(h) + ": " + a; | |
}, | |
skipWhitespace: function () { | |
for (var a = | |
this.text[this.ptr]; a && -1 != " \t\r\n".indexOf(a);) a = this.text[++this.ptr] | |
}, | |
skipLineComment: function () { | |
for (var a = this.text[this.ptr]; a && "\r" !== a && "\n" !== a;) a = this.text[++this.ptr]; | |
"\r" === a && (a = this.text[++this.ptr]); | |
"\n" === a && ++this.ptr | |
}, | |
skipBlockComment: function () { | |
for (var a = this.ptr, h = this.text[this.ptr], g = !1; h && (!g || "/" !== h);) g = "*" === h, h = this.text[++this.ptr]; | |
h || this.fail("Expected end of block comment", a); | |
++this.ptr | |
}, | |
skipUntil: function (a) { | |
for (var h = this.ptr; this.next().type !== a;) "" === this.current.type && | |
this.fail("Expected: " + a + "(Unexpected end of data)", h) | |
}, | |
expectToken: function (a) { | |
this.next().type !== a && this.fail("Expected: " + a) | |
}, | |
extractWord: function () { | |
for (var a = this.ptr, h = this.text[this.ptr]; h && -1 === "{}[]=; \t\r\n/".indexOf(h);) h = this.text[++this.ptr]; | |
this.current.type = "word"; | |
this.current.value = this.text.substring(a, this.ptr) | |
}, | |
extractString: function () { | |
var a = this.text.indexOf('"', this.ptr + 1); | |
this.current.type = "string"; | |
this.current.value = this.text.substring(this.ptr + 1, a - 1); | |
this.ptr = a + 1 | |
}, | |
next: function () { | |
this.skipWhitespace(); | |
for (var a = this.text[this.ptr]; | |
"/" === a;) a = this.text[++this.ptr], "/" === a ? (++this.ptr, this.skipLineComment()) : "*" === a ? (++this.ptr, this.skipBlockComment()) : this.fail("Expecting // or /*", this.ptr - 1), this.skipWhitespace(), a = this.text[this.ptr]; | |
this.current.ptr = this.ptr; | |
this.ptr >= this.text.length ? (this.current.value = "", this.current.type = "") : -1 !== "{}[]=;".indexOf(a) ? (this.current.value = this.current.type = a, ++this.ptr) : '"' === a ? this.extractString() : this.extractWord(); | |
return this.current | |
} | |
}; | |
var a = { | |
optional: "LABEL_OPTIONAL", | |
required: "LABEL_REQUIRED", | |
repeated: "LABEL_REPEATED" | |
}, q = { | |
"double": "TYPE_DOUBLE", | |
"float": "TYPE_FLOAT", | |
int64: "TYPE_INT64", | |
uint64: "TYPE_UINT64", | |
int32: "TYPE_INT32", | |
fixed64: "TYPE_FIXED64", | |
fixed32: "TYPE_FIXED32", | |
bool: "TYPE_BOOL", | |
string: "TYPE_STRING", | |
bytes: "TYPE_BYTES", | |
uint32: "TYPE_UINT32", | |
sfixed32: "TYPE_SFIXED32", | |
sfixed64: "TYPE_SFIXED64", | |
sint32: "TYPE_SINT32", | |
sint64: "TYPE_SINT64" | |
}; | |
p.parseFileDescriptor = function (a) { | |
a = new r(a); | |
for (var h = { | |
message_type: [], | |
enum_type: [] | |
}; | |
"" != a.next().type;) switch (a.current.value) { | |
case "package": | |
case "option": | |
a.skipUntil(";"); | |
break; | |
case "message": | |
h.message_type.push(f(a)); | |
break; | |
case "enum": | |
h.enum_type.push(n(a)); | |
break; | |
default: | |
a.fail("Unrecognized proto token: " + a.current.value) | |
} | |
return h | |
}; | |
p.FieldDescriptorProto = b; | |
return p | |
}(); | |
Spotify.Protobuf.Serialization = function () { | |
function b(a) { | |
var c = function (a) { | |
this.msg = a | |
}; | |
c.prototype.toString = function () { | |
return this.msg ? a + ": " + this.msg : a | |
}; | |
return c | |
} | |
function l(a, c) { | |
if (!a) throw c || "Assert fail"; | |
} | |
function f() { | |
this._data = [] | |
} | |
function n(a, c, d) { | |
this._data = a; | |
this._ptr = c; | |
this._end = this._ptr + d | |
} | |
function p(a, c, d, k) { | |
switch (c.type) { | |
case "int32": | |
k.writeVarint(c.id << 3 | 0); | |
k.writeVarint64(d >> 31, d); | |
break; | |
case "uint32": | |
k.writeVarint(c.id << 3 | 0); | |
k.writeVarint(~~d); | |
break; | |
case "sint32": | |
k.writeVarint(c.id << | |
3 | 0); | |
k.writeVarint(d << 1 ^ d >> 31); | |
break; | |
case "fixed32": | |
case "sfixed32": | |
k.writeVarint(c.id << 3 | 5); | |
k.writeFixed32(d); | |
break; | |
case "float": | |
k.writeVarint(c.id << 3 | 5); | |
k.writeFixed32(z.encodeFloat(d)); | |
break; | |
case "int64": | |
case "uint64": | |
k.writeVarint(c.id << 3 | 0); | |
k.writeVarint64(Math.floor(d / 4294967296), ~~d); | |
break; | |
case "sint64": | |
k.writeVarint(c.id << 3 | 0); | |
c = Math.abs(d) - (0 > d); | |
k.writeVarint64(Math.floor(c / 2147483648), (c << 1) + (0 > d)); | |
break; | |
case "fixed64": | |
case "sfixed64": | |
k.writeVarint(c.id << 3 | 1); | |
k.writeFixed64(Math.floor(d / | |
4294967296), d); | |
break; | |
case "bool": | |
k.writeVarint(c.id << 3 | 0); | |
k.writeVarint(d ? 1 : 0); | |
break; | |
case "string": | |
k.writeVarint(c.id << 3 | 2); | |
c = []; | |
for (a = 0; a < d.length; ++a) { | |
var g = d.charCodeAt(a); | |
if (128 > g) c.push(g); | |
else { | |
if (55296 === (g & 64512)) { | |
var h = d.charCodeAt(++a); | |
l(56320 === (h & 64512), "Inproperly encoded surrogate pair"); | |
g = ((g & 1023) << 10 | h & 1023) + 65536 | |
} | |
2048 > g ? c.push(192 | g >> 6) : (65536 > g ? c.push(224 | g >> 12) : (l(1114112 > g, "Invalid unicode"), c.push(240 | g >> 18), c.push(128 | g >> 12 & 63)), c.push(128 | g >> 6 & 63)); | |
c.push(128 | g & 63) | |
} | |
} | |
d = c; | |
k.writeVarint(d.length); | |
k.writeAll(d); | |
break; | |
case "bytes": | |
k.writeVarint(c.id << 3 | 2); | |
c = []; | |
for (a = 0; a < d.length; ++a) c.push(d.charCodeAt(a)); | |
d = c; | |
k.writeVarint(d.length); | |
k.writeAll(d); | |
break; | |
case "*": | |
for (g = 0; g < d.length; ++g) p(a, c.subField, d[g], k); | |
break; | |
case "#": | |
l(c.enumMap.toNumber.hasOwnProperty(d), "value " + d + " not in enum"); | |
d = c.enumMap.toNumber[d]; | |
k.writeVarint(c.id << 3 | 0); | |
k.writeVarint64(d >> 31, d); | |
break; | |
default: | |
a.hasOwnProperty(c.type) ? (g = new f, a[c.type].serializeToStream(d, g), k.writeVarint(c.id << 3 | 2), k.writeVarint(g._data.length), | |
k.writeAll(g._data)) : l(!1, "Unsupported type " + c.type) | |
} | |
} | |
function r(a) { | |
for (var c = [], d = 0; d < a.length;) { | |
var k = a.charCodeAt(d++); | |
if (128 > k) c.push(a[d - 1]); | |
else { | |
if (128 === (k & 192)) throw new t("Invalid utf-8"); | |
var g; | |
if (224 > k) k &= -225, g = 2; | |
else if (240 > k) k &= -241, g = 3; | |
else { | |
if (248 <= k) throw new t("Invalid utf-8"); | |
k &= -249; | |
g = 4 | |
} | |
for (; --g && d < a.length;) { | |
var h = a.charCodeAt(d++); | |
if (128 !== (h & 192)) throw new t("Invalid utf-8"); | |
k = k << 6 | h & -193 | |
} | |
if (g) throw new t("Unexpected end of utf-8"); | |
if (65536 > k) c.push(String.fromCharCode(k)); | |
else { | |
if (1114112 <= | |
k) throw new t("Invalid utf-8"); | |
k -= 65536; | |
c.push(String.fromCharCode(55296 | k >> 10, 56320 | k & 1023)) | |
} | |
} | |
} | |
return c.join("") | |
} | |
function a(a) { | |
return decodeURIComponent(escape(a)) | |
} | |
function q(a) { | |
return 2 * (a >>> 1) + (a & 1) | |
} | |
function m(a, c) { | |
var d = c.name; | |
switch (c.type) { | |
case "int32": | |
return function (a, c, k, g) { | |
return 0 === a ? (k[d || g] = c.readVarint(), !0) : !1 | |
}; | |
case "uint32": | |
return function (a, c, k, g) { | |
return 0 === a ? (k[d || g] = q(c.readVarint()), !0) : !1 | |
}; | |
case "sint32": | |
return function (a, c, k, g) { | |
return 0 === a ? (a = d || g, c = c.readVarint(), k[a] = c >>> | |
1 ^ -(c & 1), !0) : !1 | |
}; | |
case "fixed32": | |
return function (a, c, k, g) { | |
return 5 === a ? (k[d || g] = c.readFixed32(), !0) : !1 | |
}; | |
case "sfixed32": | |
return function (a, c, k, g) { | |
return 5 === a ? (k[d || g] = ~~c.readFixed32(), !0) : !1 | |
}; | |
case "float": | |
return function (a, c, k, g) { | |
return 5 === a ? (k[d || g] = z.decodeFloat(c.readFixed32()), !0) : !1 | |
}; | |
case "int64": | |
return function (a, c, k, g) { | |
return 0 === a ? (a = c.readVarint64(), k[d || g] = 4294967296 * a.hi + q(a.lo), !0) : !1 | |
}; | |
case "uint64": | |
return function (a, c, k, g) { | |
return 0 === a ? (a = c.readVarint64(), k[d || g] = 4294967296 * q(a.hi) + | |
q(a.lo), !0) : !1 | |
}; | |
case "sint64": | |
return function (a, c, k, g) { | |
return 0 === a ? (a = c.readVarint64(), c = 2147483648 * q(a.hi) + (a.lo >>> 1), k[d || g] = a.lo & 1 ? -1 - c : c, !0) : !1 | |
}; | |
case "fixed64": | |
return function (a, c, k, g) { | |
return 1 === a ? (a = c.readFixed64(), k[d || g] = 4294967296 * a.hi + a.lo, !0) : !1 | |
}; | |
case "sfixed64": | |
return function (a, c, k, g) { | |
return 1 === a ? (a = c.readFixed64(), k[d || g] = 4294967296 * ~~a.hi + a.lo, !0) : !1 | |
}; | |
case "bool": | |
return function (a, c, k, g) { | |
return 0 === a ? (k[d || g] = 0 !== c.readVarint(), !0) : !1 | |
}; | |
case "string": | |
return function (a, c, k, g) { | |
return 2 === | |
a ? (a = c.readVarint(), k[d || g] = B(c.bytes(a)), !0) : !1 | |
}; | |
case "bytes": | |
return function (a, c, k, g) { | |
return 2 === a ? (a = c.readVarint(), k[d || g] = c.bytes(a), !0) : !1 | |
}; | |
case "*": | |
var k = m(a, c.subField); | |
return d ? function (a, c, g, h) { | |
g = g[d] ? g[d] : g[d] = []; | |
return k(a, c, g, g.length) | |
} : function (a, c, d, g) { | |
d = d[g] ? d[g] : d[g] = []; | |
return k(a, c, d, d.length) | |
}; | |
case "#": | |
var g = c.enumMap.toName; | |
return function (a, c, k, h) { | |
return 0 === a ? (a = c.readVarint64().lo, g.hasOwnProperty(a) ? k[d || h] = g[a] : k[d || h] = a, !0) : !1 | |
} | |
} | |
return function (k, g, h, s) { | |
return 2 === k ? (k = g.readVarint(), | |
g = g.substream(k), a[c.type].parseFromStream(g, h[d || s] = {}), !0) : !1 | |
} | |
} | |
function h(a) { | |
for (var c = this, d = 0; d < a.length; ++d)(function (a) { | |
for (var d = [], k = {}, g = a.fields, h = 0; h < g.length; ++h) { | |
var s = g[h]; | |
if ("*" === s.type[0]) var b = { | |
type: s.type.substr(1), | |
id: s.id, | |
enumMap: s.enumMap | |
}, s = { | |
type: "*", | |
id: s.id, | |
name: s.name, | |
subField: b | |
}; | |
d[s.id] = m(c, s); | |
k[s.name] = s | |
} | |
c[a.name] = { | |
serializeToStream: function (a, d) { | |
for (var g in a) k.hasOwnProperty(g) && p(c, k[g], a[g], d) | |
}, | |
parseFromStream: function (c, k) { | |
for (; !c.empty();) { | |
var g = c.readVarint(), | |
h = g >>> | |
3, | |
g = g & 7, | |
s = d[h]; | |
try { | |
if (!s || !s(g, c, k)) switch (s = c, g) { | |
case 0: | |
s.skipVarint(); | |
break; | |
case 1: | |
s.skip(8); | |
break; | |
case 2: | |
var b = s.readVarint(); | |
s.skip(b); | |
break; | |
case 3: | |
case 4: | |
throw new t("Deprecated wire type"); | |
case 5: | |
s.skip(4); | |
break; | |
default: | |
throw new t("Unsupported wire type"); | |
} | |
} catch (m) { | |
throw x.error("Spotify.Protobuf.Serialization", ["Error in", a, h, g], "corejs"), m; | |
} | |
} | |
}, | |
serializeToString: function (a, c) { | |
c(serializeToStringSync(a)) | |
}, | |
serializeToStringSync: function (d) { | |
var k = new f; | |
c[a.name].serializeToStream(d, k); | |
return k.toString() | |
}, | |
parseFromString: function (a, c) { | |
c(parseFromStringSync(a)) | |
}, | |
parseFromStringSync: function (d) { | |
d = new n(d, 0, d.length); | |
var k = {}; | |
c[a.name].parseFromStream(d, k); | |
return k | |
} | |
} | |
})(a[d]) | |
} | |
function g(a, c, d, k) { | |
var g = null; | |
if (a.type_name) g = a.type_name, g = d.hasOwnProperty(k + g) ? d[k + g] : d.hasOwnProperty(g) ? d[g] : null, c = g ? c ? "int32" : "#" : a.type_name; | |
else if (c = E[a.type], !c) throw new w(a.type); | |
return { | |
id: a.number, | |
type: ("LABEL_REPEATED" === a.label ? "*" : "") + c, | |
name: a.name, | |
typeName: a.type_name, | |
enumMap: g | |
} | |
} | |
function d(a, c, d, k) { | |
for (var h = { | |
name: a.name, | |
fields: [] | |
}, s = 0; s < a.field.length; ++s) h.fields.push(g(a.field[s], c, d, k + a.name + ".")); | |
return h | |
} | |
function c(a, c, d) { | |
for (var k = 0; k < a.length; ++k) { | |
for (var g = d + a[k].name, h = c, s = g, b = a[k].value, m = {}, q = {}, x = 0; x < b.length; ++x) { | |
var t = b[x]; | |
m[t.number] = t.name; | |
q[t.name] = t.number | |
} | |
h[s] = { | |
name: g, | |
toName: m, | |
toNumber: q | |
} | |
} | |
} | |
function k(a, d, g) { | |
for (var h = 0; h < a.length; ++h) { | |
var s = g + a[h].name + "."; | |
k(a[h].nested_type, d, s); | |
c(a[h].enum_type, d, s) | |
} | |
} | |
var s = {}, x = Spotify.DebuggerJS, | |
z = Spotify.Protobuf.Ieee754, | |
t = b("BadDataError"), | |
v = b("OutOfDataError"), | |
w = b("UnsupportedError"); | |
f.prototype.write = function (a) { | |
this._data.push(a) | |
}; | |
f.prototype.writeAll = function (a) { | |
Array.prototype.push.apply(this._data, a) | |
}; | |
f.prototype.writeVarint = function (a) { | |
for (l(~~a === a, "Unexpected argument to OutputStream.writeVarint"); a & -128;) this.write(a & 127 | 128), a >>>= 7; | |
this.write(a) | |
}; | |
f.prototype.writeVarint64 = function (a, c) { | |
a ? (this.write(c & 127 | 128), this.write(c >>> 7 & 127 | 128), this.write(c >>> 14 & 127 | 128), this.write(c >>> 21 & 127 | 128), a & -8 ? (this.write((a << 4 | c >>> 28) & 127 | 128), this.writeVarint(a >>> | |
3)) : this.write((a << 4 | c >>> 28) & 127)) : this.writeVarint(c) | |
}; | |
f.prototype.writeFixed32 = function (a) { | |
this.write(a & 255); | |
this.write(a >>> 8 & 255); | |
this.write(a >>> 16 & 255); | |
this.write(a >>> 24 & 255) | |
}; | |
f.prototype.writeFixed64 = function (a, c) { | |
this.writeFixed32(c); | |
this.writeFixed32(a) | |
}; | |
f.prototype.toString = function () { | |
var a; | |
a = this._data; | |
if (a.length < y) a = String.fromCharCode.apply(String, a); | |
else { | |
var c = 0, | |
d = []; | |
do d.push(String.fromCharCode.apply(String, a.slice(c, c + y))), c += y; while (c < a.length); | |
a = d.join("") | |
} | |
return a | |
}; | |
n.prototype.check = | |
function () { | |
if (this._ptr > this._data.length) throw new v; | |
if (this._ptr > this._end) throw new t("Reading out of bounds"); | |
}; | |
n.prototype.empty = function () { | |
return this._ptr >= this._end | |
}; | |
n.prototype.skipVarint = function (a) { | |
for (; 128 <= this._data.charCodeAt(this._ptr++);); | |
this.check() | |
}; | |
n.prototype.readVarint = function () { | |
var a = 0, | |
c = 1; | |
do var d = this._data.charCodeAt(this._ptr++), | |
a = a | (d & 127) * c, c = 128 * c; | |
while (128 <= d); | |
this.check(); | |
return a | |
}; | |
var u = function () { | |
this.lo = this.hi = 0 | |
}; | |
u.prototype = {}; | |
var A = new u; | |
n.prototype.readVarint64 = | |
function () { | |
var a = 0, | |
c = 1 / 4294967296, | |
d = 0, | |
k = 1; | |
do var g = this._data.charCodeAt(this._ptr++), | |
a = a | (g & 127) * c, d = d | (g & 127) * k, c = 128 * c, k = 128 * k; | |
while (128 <= g); | |
this.check(); | |
A.hi = a; | |
A.lo = d; | |
return A | |
}; | |
n.prototype.readFixed32 = function () { | |
var a = this._data.charCodeAt(this._ptr++), | |
c = this._data.charCodeAt(this._ptr++), | |
d = this._data.charCodeAt(this._ptr++), | |
k = this._data.charCodeAt(this._ptr++); | |
this.check(); | |
return a + 256 * c + 65536 * d + 16777216 * k | |
}; | |
n.prototype.readFixed64 = function () { | |
A.lo = this.readFixed32(); | |
A.hi = this.readFixed32(); | |
return A | |
}; | |
n.prototype.skip = function (a) { | |
this._ptr += a; | |
this.check() | |
}; | |
n.prototype.substream = function (a) { | |
var c = this._ptr; | |
this._ptr += a; | |
return new n(this._data, c, a) | |
}; | |
n.prototype.bytes = function (a) { | |
var c = this._ptr; | |
this._ptr += a; | |
this.check(); | |
return this._data.substr(c, a) | |
}; | |
var y = 4096, | |
B = decodeURIComponent && escape ? a : r, | |
E = { | |
TYPE_INT32: "int32", | |
TYPE_SINT32: "sint32", | |
TYPE_UINT32: "uint32", | |
TYPE_FIXED32: "fixed32", | |
TYPE_SFIXED32: "sfixed32", | |
TYPE_FLOAT: "float", | |
TYPE_STRING: "string", | |
TYPE_BYTES: "bytes", | |
TYPE_BOOL: "bool", | |
TYPE_DOUBLE: "double", | |
TYPE_INT64: "int64", | |
TYPE_UINT64: "uint64", | |
TYPE_SINT64: "sint64", | |
TYPE_FIXED64: "fixed64", | |
TYPE_SFIXED64: "sfixed64" | |
}; | |
s.createFromJson = function (a) { | |
return new h(a) | |
}; | |
s.createFromFileDescriptor = function (a, g) { | |
var s = void 0 === g ? !1 : g, | |
b = [], | |
m = {}; | |
c(a.enum_type, m, ""); | |
k(a.message_type, m, ""); | |
for (var q = 0; q < a.message_type.length; ++q) b.push(d(a.message_type[q], s, m, "")); | |
return new h(b) | |
}; | |
return s | |
}(); | |
Spotify.Heartbeat = function () { | |
var b = new Spotify.Events, | |
l = null, | |
f = this; | |
this.start = function () { | |
this.stop(); | |
l = setInterval(r, 18E4) | |
}; | |
this.stop = function () { | |
null !== l && (clearInterval(l), l = null) | |
}; | |
var n = function () {}, p = function () {}, r = function () { | |
var a = new Spotify.Calls.Simple({ | |
method: "echo", | |
payload: ["h"], | |
context: f, | |
persistent: !1, | |
retries: 0, | |
type: "heartbeat" | |
}, n, p); | |
f.send(a) | |
}; | |
this.onNotify = function (a) { | |
switch (a.type) { | |
case b.DISCONNECTED: | |
this.stop(); | |
break; | |
case b.CONNECTED: | |
this.start() | |
} | |
} | |
}; | |
Spotify.Gateway = function (b) { | |
Spotify.EventTarget.call(this); | |
var l = Spotify.DebuggerJS, | |
f = new Spotify.Logging.Logger, | |
n = new Spotify.Events, | |
p = this; | |
this.isReady = !1; | |
this.bridge = null; | |
var r, a, q = !1, | |
m; | |
this.isConnected = !1; | |
this.rpc = function (c, d, k, g, h, s, b, x) { | |
k = r.addCall(c, d, k, g, h, s, b, x); | |
l.log("Spotify.Gateway", ["Call with method", c, "calltype", x, "params", d, "and request id", k, "was executed"], "corejs"); | |
this.isConnected ? q ? m.addToBucket(k) : this.bridge.rpc(c, d, k) : (s ? r.setPersistent(k, !0) : r.setPersistent(k, !1), a.reset()) | |
}; | |
this.disconnect = function () { | |
this.bridge.disconnect() | |
}; | |
this.connect = function (a, c) { | |
this.bridge.connect(c, a) | |
}; | |
var h = function (a) { | |
this.isConnected = !0 | |
}, g = function (a) { | |
l.log("Spotify.Gateway", ["onTimeout", a], "corejs") | |
}, d = function (a) { | |
p.trigger(n.HERMES_B64_MESSAGE, a.params) | |
}, c = function (a) { | |
p.trigger(n.USER_INFO_CHANGE) | |
}, k = function (a) { | |
try { | |
f.logWindowSize(window.innerWidth, window.innerHeight) | |
} catch (c) {} | |
a = 0; | |
for (var d = r.getPersistentCalls(), k = d.length, g; a < k; a++) g = d[a], p.rpc(g.method, g.params, g.callback, g.errback, | |
g.context, g.persistent); | |
a = 0; | |
d = r.getCalls(); | |
for (k = d.length; a < k; a++) g = d[a], "work_done" !== g.method && p.rpc(g.method, g.params, g.callback, g.errback, g.context, g.persistent, g.retries--); | |
p.trigger(n.CONNECTED) | |
}, s = function (a) { | |
this.isConnected = !1 | |
}, x = function () { | |
p.trigger(n.ON_TRY_TO_CONNECT) | |
}, z = function (a) { | |
p.trigger(n.DISCONNECTED, a.params) | |
}, t = function (a) { | |
var c = r.getCall(a.params.requestId), | |
d; | |
"undefined" !== typeof c && (d = (new Date).getTime() - c.timestamp, l.log("Spotify.Gateway", ["Latency of call with request id", | |
a.params.requestId, "is", d, "ms" | |
], "corejs"), c.callback.call(c.context, a.params), "request_time" !== c.callType && "aggregated_request_latencies" !== c.callType && "userdata" !== c.callType && "log_view" !== c.callType && "track_end" !== c.callType && "track_progress" !== c.callType && "end_preview" !== c.callType && "log_ad" !== c.callType && "js_exceptions" !== c.callType && "log" !== c.callType && "log_ce" !== c.callType && f.logAggregatedRequestTime(c.callType, d)) | |
}, v = function (a) { | |
var c = [], | |
d = !0; | |
l.error("Spotify.Gateway", ["Got an RPC Error", a], | |
"corejs"); | |
"undefined" !== typeof a.params.response && (c = a.params.response); | |
3 <= c.length && (c[0] !== Spotify.Errors.Domains.HERMES_ERROR && c[0] !== Spotify.Errors.Domains.HERMES_SERVICE_ERROR || c[1] !== Spotify.Errors.Codes.HM_TOO_MANY_REQUESTS && c[1] !== Spotify.Errors.Codes.HM_FAILED_TO_SEND_TO_BACKEND || (d = !1)); | |
var d = r.getCall(a.params.requestId, d), | |
k; | |
"undefined" !== typeof d && (k = (new Date).getTime() - d.timestamp, l.log("Spotify.Gateway", ["Latency of call with request id", a.params.requestId, "is", k, "ms"], "corejs"), 3 <= | |
c.length ? c[0] !== Spotify.Errors.Domains.HERMES_ERROR && c[0] !== Spotify.Errors.Domains.HERMES_SERVICE_ERROR || c[1] !== Spotify.Errors.Codes.HM_TOO_MANY_REQUESTS ? c[0] !== Spotify.Errors.Domains.HERMES_ERROR && c[0] !== Spotify.Errors.Domains.HERMES_SERVICE_ERROR || c[1] !== Spotify.Errors.Codes.HM_TIMEOUT && c[1] !== Spotify.Errors.Codes.HM_FAILED_TO_SEND_TO_BACKEND || !(0 < d.retries) ? (c.push(a.params.method), d.errback.call(d.context, new Spotify.Errors.Error(c))) : p.rpc(d.method, d.params, d.callback, d.errback, d.context, d.persistent, | |
d.retries - 1, d.callType) : (q = !0, m.start(), m.addToBucket(a.params.requestId)) : (l.log("Spotify.Gateway", ["RPC Error callback for method with id:", d.callType, d.params], "corejs"), d.errback.call(d.context, new Spotify.Errors.Error([1, 0, "", a.params]))), "request_time" !== d.callType && "aggregated_request_latencies" !== d.callType && "userdata" !== d.callType && "log_view" !== d.callType && "track_end" !== d.callType && "track_progress" !== d.callType && "end_preview" !== d.callType && "log_ad" !== d.callType && "js_exceptions" !== d.callType && | |
"log" !== d.callType && "log_ce" !== d.callType && f.logAggregatedRequestTime(d.callType, k)) | |
}, w = function (a) { | |
p.isReady = !0; | |
p.trigger(n.READY) | |
}, u = function (a) { | |
this.trigger(a.type, a.params) | |
}, A = function (a) { | |
p.trigger(n.TOKEN_LOST) | |
}, y = function (a) { | |
a = a.params; | |
var c = r.getCall(a, !1); | |
l.log("Spotify.Gateway", ["onRateLimitCall Will try run the callback with id", a, c], "corejs"); | |
c && p.bridge.rpc(c.method, c.params, a) | |
}, B = function (a) { | |
q = !1 | |
}, E = function (a) { | |
p.trigger(a.type, a.params) | |
}; | |
this.dispose = function () {}; | |
this.initialize = function (q, | |
f) { | |
r = new Spotify.CallsManager; | |
m = new Spotify.RateLimiter(1E3, 90); | |
m.bind(n.RATE_LIMIT_CALL, y, this); | |
m.bind(n.RATE_LIMIT_DISABLED, B, this); | |
b === Spotify.GatewayTypes.FLASH ? this.bridge = new Spotify.Flash.Bridge(q, f) : b === Spotify.GatewayTypes.WEBSOCKETS && (this.bridge = new Spotify.WebSockets.Bridge(q)); | |
this.bridge.bind(n.CONNECTION_ESTABLISHED, h, this); | |
this.bridge.bind(n.FAILED_CONNECTING, s, this); | |
this.bridge.bind(n.RPC_CALLBACK, t, this); | |
this.bridge.bind(n.RPC_ERRBACK, v, this); | |
this.bridge.bind(n.TOKEN_LOST, A, this); | |
this.bridge.bind(n.HERMES_B64_MESSAGE, d, this); | |
this.bridge.bind(n.USER_INFO_CHANGE, c, this); | |
this.bridge.bind(n.LOGIN_COMPLETE, k, this); | |
this.bridge.bind(n.TIMEOUT, g, this); | |
this.bridge.bind(n.READY, w, this); | |
this.bridge.bind(n.FLASH_AVAILABLE, u, p); | |
this.bridge.bind(n.FLASH_UNAVAILABLE, u, p); | |
this.bridge.bind(n.WORK, E, p); | |
this.bridge.bind(n.PING_FLASH, E, p); | |
a = new Spotify.ConnectionManager; | |
a.bind(n.ON_TRY_TO_CONNECT, x, this); | |
a.bind(n.NOTIFY_OF_DISCONNECT, z, this); | |
a.initialize(this.bridge); | |
this.bridge.initialize() | |
} | |
}; | |
Spotify.Ads.Core = function () { | |
Spotify.EventTarget.call(this); | |
this._inventory = {}; | |
var b = Spotify.DebuggerJS, | |
l = this, | |
f = new Spotify.Events, | |
n = {}, p = Spotify.Ads.SourceType, | |
r = p.INTERNAL, | |
a = Spotify.Ads.InventoryType, | |
q = function () { | |
b.error("Spotify.Ads.Core", Array.prototype.slice.call(arguments, 0), "corejs") | |
}, m = function () { | |
b.log("Spotify.Ads.Core", Array.prototype.slice.call(arguments, 0), "corejs") | |
}; | |
this._setSource = function (a) { | |
var g = !1, | |
d; | |
for (d in p) p[d] === a && (g = !0); | |
if (!g) throw Error("Source not defined on Spotify.Ads.SourceType: " + | |
a); | |
r = a | |
}; | |
this._fetchAdTag = function (h, g, d, c, k) { | |
"function" === typeof c && "function" === typeof k ? h === a.AUDIO && "object" === typeof _audioMockTag ? c(_audioMockTag) : h !== a.LEADERBOARD && h !== a.BANNER || "object" !== typeof _bannerMockTag || c(_bannerMockTag) : q("invalid callbacks specified for _fetchAdTagResponse") | |
}; | |
this._onAdBreakStarted = function (a) { | |
this._adBreakInProgress = !0; | |
this.trigger(f.AD_BREAK_STARTED, a || {}); | |
this._pauseAllSlotTimeouts() | |
}; | |
this._onAdBreakEnded = function (a) { | |
this._adBreakInProgress = !1; | |
this.trigger(f.AD_BREAK_ENDED, | |
a || {}); | |
this._resumeAllSlotTimeouts() | |
}; | |
this._startCompanionAds = function (a) { | |
m("startCompanionAds", a) | |
}; | |
this._endCompanionAds = function () { | |
this._haveCompanionAds && (this._haveCompanionAds = !1) | |
}; | |
this._normalizeSlotId = function (a, g) { | |
return g ? g + "_" + a : "chrome_" + a | |
}; | |
this._refreshInventory = function (a) { | |
this._inventory[a] && this._populateInventory(a) | |
}; | |
this._renderInventory = function (a, g) { | |
var d = this._inventory[a]; | |
d ? g && (g.payload || g.imageUrl) ? (l.trigger(f.AD_AVAILABLE, { | |
slotId: d.slotId, | |
type: d.type.id, | |
appFrameId: d.appFrameId, | |
contextInfo: d.contextInfo, | |
size: d.size | |
}), l.trigger(f.AD_RECEIVED, { | |
payload: g.payload, | |
adId: g.adId, | |
appFrameId: d.appFrameId, | |
type: d.type.id, | |
iframe: !! g.iframe, | |
targetUrl: g.targetUrl, | |
imageUrl: g.imageUrl, | |
slotId: d.slotId, | |
contextInfo: d.contextInfo, | |
size: d.size | |
})) : (l.trigger(f.AD_NOT_AVAILABLE, { | |
slotId: d.slotId, | |
type: d.type.id, | |
appFrameId: d.appFrameId, | |
contextInfo: d.contextInfo | |
}), l._beginSlotTimeout(a, 18E4)) : q("inventory not registered: " + a) | |
}; | |
this._buildAd = function (a) { | |
var g; | |
switch (r) { | |
case p.INTERNAL: | |
g = { | |
adId: a.ad_id | |
}, | |
a.html ? (g.payload = a.html, g.iframe = !0) : a.image_id ? (g.imageUrl = Spotify.SourceURLs.original + a.image_id, g.targetUrl = a.target_url || "", g.payload = '<a target="_blank" href="' + g.targetUrl + '"><img src="' + g.imageUrl + '" /></a>') : (g = !1, q("Ad entry does not have image_id or html component: " + a.ad_id)) | |
} | |
return g | |
}; | |
this._populateInventory = function (h, g) { | |
var d = !1, | |
c = this._inventory[h]; | |
if (c) switch (this._resetSlotTimeout(h), r) { | |
case p.INTERNAL: | |
c.adId = null; | |
c.sentBannerShown = !1; | |
var k = null; | |
if (g) k = g; | |
else if (c.type === a.BANNER || | |
c.type === a.LEADERBOARD) k = this.adChooser.getBannerAd(); | |
k && (c.adId = k.ad_id, c.duration = 0 < k.duration ? 1E3 * k.duration : 0, c.sentBannerShown = !1, d = this._buildAd(k)); | |
l._renderInventory(h, d) | |
} else q("inventory not defined: " + h) | |
}; | |
this._getInventoryByAdId = function (a) { | |
var g = [], | |
d; | |
for (d in this._inventory) this._inventory.hasOwnProperty(d) && this._inventory[d].adId === a && g.push(this._inventory[d]); | |
if (!g.length) return null; | |
g.sort(function (a, d) { | |
return a.timeRegistered < d.timeRegistered ? 1 : -1 | |
}); | |
return g[0] | |
}; | |
this._beginSlotTimeout = | |
function (a, g) { | |
var d = this._inventory[a]; | |
return d ? (g = g || d.duration || 3E4, m("beginSlotTimeout", a, g), d.timeoutId && this._resetSlotTimeout(a), d.timeoutDuration || (d.timeoutDuration = g), d.timeoutBegin = Date.now(), d.paused = 0, d.timeoutId = setTimeout(function () { | |
l._refreshInventory(a) | |
}, g), g) : !1 | |
}; | |
this._pauseSlotTimeout = function (a) { | |
var g = this._inventory[a]; | |
g && g.timeoutId ? (m("pauseSlotTimeout", a), clearTimeout(g.timeoutId), g.timeoutId = null, g.timeoutProgress += Date.now() - g.timeoutBegin, g.paused = 1) : g || q("pause: slot not found", | |
a) | |
}; | |
this._resumeSlotTimeout = function (a) { | |
var g = this._inventory[a]; | |
if (0 < g.timeoutDuration && g.timeoutProgress < g.timeoutDuration) return g = g.timeoutDuration - g.timeoutProgress, this._beginSlotTimeout(a, g); | |
q("cannot resume slot", a, g); | |
return !1 | |
}; | |
this._resetSlotTimeout = function (a) { | |
var g = this._inventory[a]; | |
g && (m("resetSlotTimeout", a), g.timeoutId && (clearTimeout(g.timeoutId), g.timeoutId = null), g.timeoutProgress = 0, g.timeoutDuration = 0, g.timeoutBegin = 0, g.paused = 0) | |
}; | |
this._deregisterSlot = function (a) { | |
var g = this._inventory[a]; | |
g && (delete this._inventory[a], g.timeoutId && clearTimeout(g.timeoutId)) | |
}; | |
this._pauseAllSlotTimeouts = function () { | |
for (var a in this._inventory) this._inventory.hasOwnProperty(a) && this._inventory[a].timeoutId && this._pauseSlotTimeout(a) | |
}; | |
this._resumeAllSlotTimeouts = function () { | |
for (var a in this._inventory) this._inventory.hasOwnProperty(a) && this._inventory[a].paused && this._resumeSlotTimeout(a) | |
}; | |
this.initialize = function (a, g, d, c, k) { | |
this._gateway = g; | |
r === p.INTERNAL && (this.adChooser = a.services.adChooser, this.adChooser.init(g, | |
d, c, k), l.adChooser.bind(f.AD_BREAK_STARTED, l._onAdBreakStarted.bind(l)), l.adChooser.bind(f.AD_BREAK_ENDED, l._onAdBreakEnded.bind(l))) | |
}; | |
this.recordAdEvent = function (a, g, d, c, k) { | |
var s = !1; | |
a = this._normalizeSlotId(a, d); | |
d = this._inventory[a]; | |
if (!d) return q("slotId not found: " + a), s; | |
if (this.adChooser && r === p.INTERNAL) { | |
if (!c && (c = d.adId, !c)) return q("adId must be defined to record ad event"), s; | |
s = this.adChooser.recordAdEventById(c, g); | |
"render" === g ? this.adChooser.recordImpression(c) : "click" === g ? this.adChooser.recordImpression(c, !0) : "error" === g && this.adChooser.recordImpression(c, !1, k) | |
} | |
"render" === g ? (d.timeRendered = (new Date).getTime(), d.preview || this._beginSlotTimeout(a)) : "error" === g && (this._resetSlotTimeout(a), d.preview || this._refreshInventory(a)); | |
return s | |
}; | |
this.previewInventory = function (a, g, d, c, k) { | |
var s; | |
if (c && k) { | |
if (g && (s = l._normalizeSlotId(g, d), !l._inventory[s])) { | |
k("Registered slot not found: " + g); | |
return | |
} | |
l.adChooser.lookupAdEntry("banner", a, function (d) { | |
var g = l._buildAd(d), | |
b; | |
if (g) { | |
if (d.banner_type) | |
for (b in Spotify.Ads.InventoryType) Spotify.Ads.InventoryType.hasOwnProperty(b) && | |
Spotify.Ads.InventoryType[b].adChooserBannerType === d.banner_type && (g.type = Spotify.Ads.InventoryType[b].id); | |
c(g); | |
s ? (l._inventory[s].preview = !0, l._populateInventory(s, d)) : l._pauseAllSlotTimeouts() | |
} else k("ad unit could not be built from metadata: " + a) | |
}, function (a) { | |
k(a) | |
}) | |
} else q("previewInventory: success and fail callbacks must be defined.") | |
}; | |
this.setUserActive = function () { | |
var a, g, d, c = 0; | |
if (this._userInactivePaused && !this._adBreakInProgress) | |
for (a = 0, g = this._userInactivePaused.length; a < g; a++) d = this._userInactivePaused[a], | |
this._inventory.hasOwnProperty(d) && (this._resumeSlotTimeout(d), c++); | |
this._userInactivePaused = null; | |
return c | |
}; | |
this.setUserInactive = function () { | |
var a; | |
this._userInactivePaused = []; | |
for (a in this._inventory) this._inventory.hasOwnProperty(a) && !this._inventory[a].paused && (this._pauseSlotTimeout(a), this._userInactivePaused.push(a)); | |
return this._userInactivePaused.length | |
}; | |
this.registerInventory = function (a, g, d, c) { | |
var k = d ? d.frameId : null, | |
s = this._normalizeSlotId(a, k), | |
b = null, | |
q = null; | |
if ("object" !== typeof g || !g.id) throw Error("inventoryType not valid: " + | |
JSON.stringify(g)); | |
g.sizes && (b = { | |
width: g.sizes[0][0], | |
height: g.sizes[0][1] | |
}); | |
d && (q = d.bundleId ? d.bundleId : null, d.publisher && (d.publisher.addEvent("deactivate", function () { | |
m("app deactivate: " + d.frameId); | |
l._pauseSlotTimeout(s) | |
}), d.publisher.addEvent("activate", function () { | |
m("app activate: " + d.frameId); | |
l._inventory[s].timeoutBegin ? l._resumeSlotTimeout(s) : l._populateInventory(s) | |
}), d.publisher.addEvent("destroy", function () { | |
m("app destroy: " + d.frameId); | |
l.deregisterAppInventory(k); | |
delete n[k] | |
}))); | |
this._inventory[s] = { | |
slotId: a, | |
type: g, | |
size: b, | |
bundleId: q, | |
appFrameId: k, | |
contextInfo: c, | |
timeRegistered: Date.now(), | |
timeRendered: null, | |
duration: null | |
}; | |
this._populateInventory(s) | |
}; | |
this.deregisterInventory = function (a, g) { | |
this._deregisterSlot(this._normalizeSlotId(a, g)) | |
}; | |
this.deregisterAppInventory = function (a) { | |
var g = this._inventory, | |
d; | |
for (d in g) g.hasOwnProperty(d) && g[d].appFrameId === a && this._deregisterSlot(d) | |
}; | |
this.appListening = function (a) { | |
n[a] || (n[a] = !0) | |
}; | |
this.adBreakInProgress = function () { | |
return this._adBreakInProgress ? !0 : !1 | |
}; | |
this.getMaximumAdBreakLengthInSeconds = | |
function () { | |
return 180 | |
} | |
}; | |
(function () { | |
Spotify.Ads.InventoryType = { | |
LEADERBOARD: { | |
id: "leaderboard", | |
sizes: [ | |
[728, 90] | |
], | |
adChooserBannerType: "full banner" | |
}, | |
BILLBOARD: { | |
id: "billboard", | |
sizes: [ | |
[970, 250] | |
] | |
}, | |
AUDIO: { | |
id: "audio", | |
sizes: null | |
} | |
}; | |
Spotify.Ads.InventoryTypeById = {}; | |
var b, l; | |
for (b in Spotify.Ads.InventoryType) Spotify.Ads.InventoryType.hasOwnProperty(b) && (l = Spotify.Ads.InventoryType[b], l.key = b, Spotify.Ads.InventoryTypeById[l.id] = l) | |
})(); | |
Spotify.Ads.SourceType = { | |
INTERNAL: "INTERNAL", | |
DFP: "DFP" | |
}; | |
Spotify.Audio.AudioStream = function (b, l, f) { | |
Spotify.EventTarget.call(this); | |
this.id = b; | |
this.lid = ""; | |
this.isReady = !0; | |
this.isPreview = this.isAd = !1; | |
this.trackUrl = this.trackUri = ""; | |
this.bitrate = 160; | |
this.audiocodec = "mp3"; | |
this.isPaused = this.isPlaying = !1; | |
this.isStopped = !0; | |
this.isActive = this.isLoaded = !1; | |
this.limit = -1; | |
var n = 0, | |
p = 0, | |
r = -1, | |
a, q = {}, m = 1, | |
h = this, | |
g = Spotify.DebuggerJS; | |
new Spotify.Logging.Logger; | |
var d = new Spotify.Events, | |
c = "", | |
k = 0, | |
s = !1, | |
x = 1, | |
z = 0, | |
t = 0, | |
v = !1, | |
w = function (c) { | |
g.log("Spotify.Audio.AudioStream", ["Player event:", | |
h.id, c | |
], "corejs"); | |
switch (c.type) { | |
case d.READY: | |
h.isReady = !0; | |
h.isLoaded && h.load(h.trackUri, t, !h.isPaused); | |
break; | |
case d.NOT_READY: | |
h.isReady = !1; | |
B(); | |
break; | |
case d.DURATION: | |
z = c.params; | |
g.log("Spotify.Audio.AudioStream", ["Got duration", c.params], "corejs"); | |
break; | |
case d.LOAD: | |
E(); | |
z = 0; | |
h.isPaused = !0; | |
h.isStopped = !1; | |
h.isPlaying = !1; | |
h.isLoaded = !0; | |
h.onLoad(c); | |
break; | |
case d.PLAYING: | |
B(); | |
a = setInterval(C, 500); | |
h.isPaused = !1; | |
h.isStopped = !1; | |
h.isPlaying = !0; | |
h.isActive || h.trigger(d.ACTIVE_PLAYER_CHANGED, { | |
id: h.id | |
}); | |
h.onPlay(c); | |
break; | |
case d.PAUSED: | |
B(); | |
h.isPaused = !0; | |
h.isStopped = !1; | |
h.isPlaying = !1; | |
h.onPause(c); | |
break; | |
case d.STOPPED: | |
h.isPaused = !1; | |
h.isStopped = !0; | |
h.isPlaying = !1; | |
h.isLoaded = !1; | |
h.onStop(c); | |
E(); | |
break; | |
case d.BEFORE_SEEK: | |
h.isPlaying && B(); | |
break; | |
case d.POSITION_CHANGED: | |
t = parseInt(c.params); | |
h.isPlaying && (B(), a = setInterval(C, 500)); | |
h.onPositionChanged(c); | |
break; | |
case d.TRACK_ENDED: | |
E(); | |
h.isPaused = !1; | |
h.isStopped = !0; | |
h.isPlaying = !1; | |
h.isLoaded = !0; | |
h.stop(); | |
h.onTrackEnded(c); | |
break; | |
case d.SONG_LOADED: | |
h.onSongLoaded(c); | |
break; | |
case d.PLAYBACK_FAILED: | |
E(); | |
h.isStopped = !0; | |
h.isPaused = !1; | |
h.isPlaying = !1; | |
h.isLoaded = !1; | |
h.onPlaybackFailed(c); | |
break; | |
case d.INVALID_TRACK_URI: | |
E(), h.onPlaybackFailed(c) | |
} | |
}, u = function (a) { | |
a.extra.id === h.id && h.trigger(a.type, a.params) | |
}; | |
this.load = function (a, b, m, x, t) { | |
(h.isPaused || h.isPlaying) && h.stop(); | |
g.log("Spotify.Audio.AudioStream", ["Load track", a], "corejs"); | |
var z, f = new Spotify.Link.fromString(a); | |
this.limit = "undefined" !== typeof x ? x : -1; | |
r = "undefined" !== typeof t ? t : -1; | |
this.isAd = this.isPreview = !1; | |
"audiofile" === f.type ? (this.isPreview = !0, | |
this.isAd = !1) : "ad" === f.type && (this.isPreview = !1, this.isAd = !0); | |
this.trigger(d.TRACK_PLAY_REQUEST, { | |
timestamp: (new Date).getTime() | |
}); | |
k = this.isAd ? 0 : b || 0; | |
s = "undefined" === typeof m ? !1 : m; | |
c = a; | |
z = this.isAd ? q[Spotify.Resolvers.AD_RESOLVER] : this.isPreview ? q[Spotify.Resolvers.PREVIEW_RESOLVER] : q[Spotify.Resolvers.STORAGE_RESOLVER]; | |
z.onReady(function () { | |
try { | |
z.list(a, l === Spotify.PlayerTypes.FLASH_RTMPS ? "rtmp" : "", A, y) | |
} catch (c) { | |
g.error("Spotify.Audio.AudioStream", [c.message, c.stack], "corejs") | |
} | |
}, this) | |
}; | |
var A = function (a) { | |
h.lid = | |
a.lid; | |
h.trackUrl = a.uri; | |
h.trackUri = c; | |
g.log("Spotify.Audio.AudioStream", ["Got a result from the resolver", a], "corejs"); | |
f.load(h.id, h.trackUrl, { | |
autoplay: s, | |
startFrom: k, | |
server: a.server, | |
protocol: a.protocol | |
}); | |
t = k; | |
s = !1; | |
k = 0 | |
}, y = function (a) { | |
h.lid = ""; | |
h.trackUrl = ""; | |
c = h.trackUri = ""; | |
k = 0; | |
g.error("Spotify.Audio.AudioStream", ["Got an error from the storage resolver", a], "corejs"); | |
h.trigger(d.INVALID_TRACK_URI, a) | |
}, B = function () { | |
a && (clearInterval(a), a = null); | |
p = 0 | |
}, E = function () { | |
B(); | |
n = 0; | |
v = !1 | |
}, C = function () { | |
var a = (new Date).getTime(), | |
c = a - (0 === p ? a - 500 : p), | |
k = f.getPlayerState(h.id); | |
t = k.position; | |
z = k.duration; | |
k.isPlaying = h.isPlaying; | |
k.isStopped = h.isStopped; | |
k.isPaused = h.isPaused; | |
var s = k.duration; | |
p = a; | |
h.trigger(d.PLAYER_STATE, { | |
state: k, | |
interval: c | |
}); | |
g.log("Spotify.Audio.AudioStream", ["Tracking state:", k, c], "corejs"); - 1 !== h.limit && (s = h.limit); | |
t >= s - r - 500 && -1 !== r && !v && (g.log("Spotify.Audio.AudioStream", ["BEFORE_END event", k.position, k.duration], "corejs"), v = !0, h.trigger(d.BEFORE_END)); | |
n += c; | |
n >= h.limit && -1 !== h.limit && (h.trigger(d.TRACK_ENDED), | |
h.stop()) | |
}; | |
this.play = function (a, c) { | |
"undefined" !== typeof c && -1 !== c && (this.limit = c); | |
h.isReady && (n = 0, f.play(this.id, a)) | |
}; | |
this.pause = function () { | |
h.isPlaying && f.pause(this.id) | |
}; | |
this.resume = function () { | |
!h.isPlaying && h.isPaused && h.isLoaded && f.resume(this.id) | |
}; | |
this.stop = function () { | |
h.isLoaded && (r = this.limit = -1, f.stop(this.id), this.trigger(d.STOPPED, {}, this.id)) | |
}; | |
this.playpause = function () { | |
h.isPaused ? h.resume() : h.pause() | |
}; | |
this.position = function () { | |
return h.isLoaded ? t = f.position(this.id) : 0 | |
}; | |
this.getPlayerState = | |
function () { | |
var a = {}; | |
a.volume = x; | |
a.position = t; | |
a.duration = h.isLoaded ? z : 0; | |
a.trackUri = this.trackUri; | |
a.isPlaying = this.isPlaying; | |
a.isStopped = this.isStopped; | |
a.isPaused = this.isPaused; | |
return a | |
}; | |
this.seek = function (a) { | |
return h.isLoaded ? (h.trigger(d.BEFORE_SEEK), t = a, f.seek(this.id, a)) : 0 | |
}; | |
this.setVolume = function (a) { | |
!isNaN(a) && 0 <= a && 1 >= a && (x = a, f.setVolume(this.id, a * m)) | |
}; | |
this.setMasterVolume = function (a) { | |
!isNaN(a) && 0 <= a && 1 >= a && (m = a, this.setVolume(x)) | |
}; | |
this.getVolume = function () { | |
return x | |
}; | |
this.getDuration = function () { | |
return z | |
}; | |
this.addFileResolver = function (a, c) { | |
q[a] = c | |
}; | |
this.initialize = function () { | |
l === Spotify.PlayerTypes.HTML5_HTTP && (f.bind(d.TRACK_ENDED, u), f.bind(d.POSITION_CHANGED, u), f.bind(d.PLAYING, u), f.bind(d.PAUSED, u), f.bind(d.STOPPED, u), f.bind(d.LOAD, u)); | |
this.bind(d.TRACK_ENDED, w, this, 10); | |
this.bind(d.POSITION_CHANGED, w, this, 10); | |
this.bind(d.PLAYING, w, this, 10); | |
this.bind(d.PAUSED, w, this, 10); | |
this.bind(d.STOPPED, w, this, 10); | |
this.bind(d.PLAYBACK_FAILED, w, this, 10); | |
this.bind(d.SONG_LOADED, w, this, 10); | |
this.bind(d.INVALID_TRACK_URI, | |
w, this, 10); | |
this.bind(d.LOAD, w, this, 10); | |
this.bind(d.READY, w, this, 10); | |
this.bind(d.NOT_READY, w, this, 10); | |
this.bind(d.TRACK_PLAY_REQUEST, w, this, 10); | |
this.bind(d.DURATION, w, this, 10); | |
this.bind(d.BEFORE_SEEK, w, this, 10); | |
this.bind(d.FAILED_CONNECTING, w, this, 10); | |
f.initializePlayerById(this.id) | |
}; | |
this.dispose = function () { | |
l === Spotify.PlayerTypes.HTML5_HTTP && (f.unbind(d.TRACK_ENDED, u), f.unbind(d.POSITION_CHANGED, u), f.unbind(d.PLAYING, u), f.unbind(d.PAUSED, u), f.unbind(d.STOPPED, u), f.unbind(d.LOAD, u)); | |
this.unbind(d.TRACK_ENDED, | |
w, this); | |
this.unbind(d.POSITION_CHANGED, w, this); | |
this.unbind(d.PLAYING, w, this); | |
this.unbind(d.PAUSED, w, this); | |
this.unbind(d.STOPPED, w, this); | |
this.unbind(d.PLAYBACK_FAILED, w, this); | |
this.unbind(d.SONG_LOADED, w, this); | |
this.unbind(d.INVALID_TRACK_URI, w, this); | |
this.unbind(d.LOAD, w, this); | |
this.unbind(d.READY, w, this); | |
this.unbind(d.NOT_READY, w, this); | |
this.unbind(d.TRACK_PLAY_REQUEST, w, this); | |
this.unbind(d.DURATION, w, this); | |
this.unbind(d.BEFORE_SEEK, w, this); | |
this.unbind(d.FAILED_CONNECTING, w, this) | |
}; | |
this.onLoad = function (a) {}; | |
this.onPlay = function (a) {}; | |
this.onPause = function (a) {}; | |
this.onStop = function (a) {}; | |
this.onTrackEnded = function (a) {}; | |
this.onSongLoaded = function (a) {}; | |
this.onPositionChanged = function (a) {}; | |
this.onInvalidTrackUri = function (a) {}; | |
this.onPlaybackFailed = function (a) {} | |
}; | |
Spotify.Audio.AudioManager = function (b, l, f) { | |
Spotify.EventTarget.call(this); | |
this.isInitialized = this.isReady = !1; | |
var n = this, | |
p = 1, | |
r = {}, a = Spotify.DebuggerJS, | |
q, m = new Spotify.Events, | |
h = new Spotify.Logging.Types, | |
g, d, c, k = [], | |
s = [], | |
x = 0, | |
z, t = "", | |
v = function (a) { | |
this.trigger(a.type, a.params) | |
}, w = function (a) { | |
t = a.user; | |
n.addPlayer("Player0"); | |
n.isReady = !0; | |
n.trigger(m.READY) | |
}, u = function (a) {}, A = function (a) { | |
this.hasSound() ? (n.isInitialized = !0, n.trigger(m.INITIALIZED), z.onReady(function () { | |
z.getUserInfo(w, u) | |
})) : this.trigger(m.NO_SOUND_CAPABILITIES) | |
}, | |
y = function (c) { | |
switch (c.type) { | |
case m.STOPPED: | |
case m.TRACK_END: | |
n.getTrackerForPlayerWithId(c.extra).stopTrackingAndLog(); | |
var d = n.getTrackerIndexWithId(c.extra); | |
s[d].dispose(!0); | |
s[d] = null; | |
a.log("Spotify.Audio.AudioManager", ["Stopped event capture", s], "corejs"); | |
C(c.extra, d, n.getPlayerAtIndex(d), t) | |
} | |
n.trigger(c.type, c.params, c.extra) | |
}, B = function (a) { | |
for (var c = 0, d = k.length; c < d; c += 1) { | |
var s = k[c]; | |
s.id === a.params.id ? (s.isActive = !0, g = s, n.trigger(a.type, a.params, a.extra)) : s.isActive = !1 | |
} | |
}; | |
this.onReady = function (a, | |
c) { | |
this.isReady ? a.call(c) : n.bind(m.READY, a, c) | |
}; | |
var E = function (a) { | |
n.trigger(a.type, a.params) | |
}, C = function (c, k, g, b) { | |
var q = new Spotify.Logging.TrackEnd; | |
q.init(d); | |
var x = new Spotify.Logging.PreviewEnd; | |
x.init(); | |
var t = new Spotify.Logging.TrackProgress; | |
t.init(d); | |
var z = new Spotify.Logging.TrackEvent; | |
z.init(d); | |
var f = new Spotify.Logging.AdEnd; | |
f.init(d); | |
c = s[k] = new Spotify.PlayerTracker(c, g, b); | |
c.bind(m.RECORD_AD_EVENT, E, n); | |
c.addLogger(h.TRACK_END, q); | |
c.addLogger(h.PREVIEW_END, x); | |
c.addLogger(h.TRACK_EVENT, z); | |
c.addLogger(h.AD_END, | |
f); | |
c.addLogger(h.TRACK_PROGRESS, t); | |
c.initialize(); | |
a.log("Spotify.Audio.AudioManager", ["Created a new tracker at index", k, s], "corejs") | |
}; | |
this.addPlayer = function (a, d) { | |
var g; | |
if ("string" !== typeof a) throw Error("The id must be a string"); | |
"undefined" === typeof d && (d = f); | |
g = 0; | |
for (var s = k.length; g < s; g += 1) | |
if (k[g].id === a) throw Error("There is already a player with this id: " + a); | |
c.addPlayer(x, a, d); | |
g = k[x] = new Spotify.Audio.AudioStream(a, d, c); | |
g.addFileResolver(Spotify.Resolvers.STORAGE_RESOLVER, r[Spotify.Resolvers.STORAGE_RESOLVER]); | |
g.addFileResolver(Spotify.Resolvers.AD_RESOLVER, r[Spotify.Resolvers.AD_RESOLVER]); | |
g.addFileResolver(Spotify.Resolvers.PREVIEW_RESOLVER, r[Spotify.Resolvers.PREVIEW_RESOLVER]); | |
g.bind(m.ACTIVE_PLAYER_CHANGED, B, n); | |
g.bind(m.TRACK_ENDED, y, n); | |
g.bind(m.POSITION_CHANGED, y, n); | |
g.bind(m.PLAYING, y, n); | |
g.bind(m.PAUSED, y, n); | |
g.bind(m.STOPPED, y, n); | |
g.bind(m.INVALID_TRACK_URI, y, n); | |
g.bind(m.PLAYBACK_FAILED, y, n); | |
g.bind(m.TRACK_PLAY_REQUEST, y, n); | |
g.bind(m.SONG_LOADED, y, n); | |
g.bind(m.LOAD, y, n); | |
g.bind(m.FAILED_CONNECTING, y, | |
n); | |
g.initialize(); | |
C(a, x, g, t); | |
x++; | |
this.trigger(m.PLAYER_CREATED, { | |
id: a | |
}); | |
return g | |
}; | |
this.getPlayers = function () { | |
return k | |
}; | |
this.getActivePlayer = function () { | |
return g | |
}; | |
this.getPlayerById = function (a) { | |
var c; | |
if ("string" === typeof a) | |
for (var d = 0, g = k.length; d < g; d += 1) | |
if (c = k[d], c.id === a) return c | |
}; | |
this.getTrackerIndexWithId = function (a) { | |
var c; | |
if ("string" === typeof a) | |
for (var d = 0, k = s.length; d < k; d += 1) | |
if (c = s[d], c.id === a) return d | |
}; | |
this.getTrackerForPlayerWithId = function (a) { | |
var c; | |
if ("string" === typeof a) | |
for (var d = 0, k = s.length; d < | |
k; d += 1) | |
if (c = s[d], c.id === a) return c | |
}; | |
this.getPlayerAtIndex = function (a) { | |
if ("number" === typeof a && k[a]) return k[a] | |
}; | |
this.getTrackerForPlayerAtIndex = function (a) { | |
if ("number" === typeof a && s[a]) return s[a] | |
}; | |
this.removePlayerById = function (a) { | |
var c; | |
if ("string" === typeof a) { | |
if ("Player0" === a) return !1; | |
for (var d = 0, g = k.length; d < g; d += 1) | |
if (c = k[d], c.id === a && 0 !== d) return this.removePlayerAtIndex(d); | |
return !1 | |
} | |
}; | |
this.removePlayerAtIndex = function (a) { | |
return "number" !== typeof a || 0 === a ? !1 : k[a] ? (k[a].isActive && (g = k[0]), k[a].dispose(), | |
s[a].dispose(!0), delete k[a], delete s[a], k[a] = null, s[a] = null, c.removePlayerAtIndex(a)) : !1 | |
}; | |
this.hasSound = function () { | |
return c.hasSound() | |
}; | |
this.setMasterVolume = function (a) { | |
p = 0 > a ? 0 : 1 < a ? 1 : a; | |
for (var c = 0, d = k.length; c < d; c += 1) a = k[c], a.setMasterVolume(p) | |
}; | |
this.getMasterVolume = function () { | |
return p | |
}; | |
this.crossfade = function (a, c, d, k) { | |
q || (q = new Spotify.Audio.Crossfader); | |
q.crossfade(this.getPlayerById(a), this.getPlayerById(c), d, k) | |
}; | |
this.dispose = function () { | |
for (var a, c = 0, d = k.length; c < d; c += 1) a = k[c], null !== a && void 0 !== | |
a && (a.dispose(), a.isActive && s[c].dispose()) | |
}; | |
this.addFileResolver = function (a, c) { | |
r[a] = c | |
}; | |
this.getInterface = function () { | |
return c | |
}; | |
this.initialize = function (a, k) { | |
z = k; | |
d = a; | |
f === Spotify.PlayerTypes.FLASH_HTTP || f === Spotify.PlayerTypes.FLASH_RTMPS || f === Spotify.PlayerTypes.FLASH_AAC ? (c = new Spotify.Flash.PlayerInterface(b, l), c.bind(m.FLASH_AVAILABLE, v, this), c.bind(m.FLASH_UNAVAILABLE, v, this)) : f === Spotify.PlayerTypes.HTML5_HTTP && (c = new Spotify.HTML5.PlayerInterface("html5audio")); | |
c.bind(m.READY, A, this, 10); | |
c.initialize() | |
} | |
}; | |
Spotify.Audio.Crossfader = function () { | |
var b = this, | |
l = Spotify.DebuggerJS, | |
f, n, p = 1, | |
r = !1, | |
a = 0, | |
q = 0, | |
m, h; | |
this.crossfade = function (g, d, c, k) { | |
r ? (this.stop(), f(), f = null, h = m + (1 - (1 - a) + a) * c) : (d.setVolume(0), m = (new Date).getTime(), h = m + c, p = g.getVolume(), a = 0); | |
l.log("Spotify.Audio.Crossfader", ["Target volume", p], "corejs"); | |
r = !0; | |
f = k; | |
n = setInterval(function () { | |
var s = (new Date).getTime(); | |
q = (h - s) / c; | |
a = Math.floor(100 * (1 - q)) / 100; | |
var s = Math.floor(p * (1 - a) * 100) / 100, | |
m = Math.floor(p * a * 100) / 100, | |
s = 1 < s ? 1 : s, | |
s = 0 > s ? 0 : s, | |
m = 1 < m ? 1 : m, | |
m = 0 > m ? 0 : m; | |
g.setVolume(s); | |
d.setVolume(m); | |
l.log("Spotify.Audio.Crossfader", [g.id, "will have volume", s, d.id, "will have volume", m], "corejs"); | |
1 <= a && (r = !1, b.stop(), k()) | |
}, 100) | |
}; | |
this.stop = function () { | |
return n ? (clearInterval(n), n = null, !0) : !1 | |
} | |
}; | |
Spotify.Flash.Bridge = function (b, l) { | |
Spotify.EventTarget.call(this); | |
var f = Spotify.DebuggerJS, | |
n = new Spotify.Events; | |
this.id = b; | |
var p, r = function (a) { | |
this.trigger(a.type, a.params) | |
}; | |
this.rpc = function (a, b, m) { | |
void 0 !== typeof p ? p.isLoaded ? p.getSWF().sp_rpc.apply(p.getSWF(), [a, m].concat(b)) : f.error("Bridge", ["Core.Bridge:rpc: Bridge is not initialized"], "corejs") : f.error("Bridge", ["Core.Bridge:rpc: Bridge is not initialized"], "corejs") | |
}; | |
this.disconnect = function () { | |
void 0 !== typeof p ? p.isLoaded ? p.getSWF().sp_disconnect.apply(p.getSWF()) : | |
f.error("Bridge", ["Core.Bridge:Disconnect: Bridge is not initialized"], "corejs") : f.error("Bridge", ["Core.Bridge:Disconnect: Bridge is not initialized"], "corejs") | |
}; | |
this.connect = function (a, b) { | |
a = a || ""; | |
void 0 !== typeof p && p.isLoaded && p.getSWF().sp_connect.apply(p.getSWF(), [a, b]) | |
}; | |
this.initialize = function () { | |
p = new Spotify.Flash.SWFObject({ | |
SWFFlashId: b, | |
SWFContainerId: l.SWFContainerId, | |
SWFUrl: l.SWFUrl, | |
SWFMinVersion: l.SWFMinVersion, | |
instanceId: b, | |
logging: l.logging, | |
length: l.valid, | |
valid: 0 | |
}); | |
p.bind(n.FLASH_AVAILABLE, | |
r, this); | |
p.bind(n.FLASH_UNAVAILABLE, r, this); | |
p.initialize() | |
}; | |
this.getFlashObject = function () { | |
return p | |
} | |
}; | |
Spotify.WebSockets.Bridge = function (b, l) { | |
Spotify.EventTarget.call(this); | |
var f = Spotify.DebuggerJS; | |
this.id = b; | |
l = l || {}; | |
var n = this, | |
p = new Spotify.Events, | |
r = { | |
connectionParams: l.connectionParams || "" | |
}, a = null, | |
q = function () { | |
this.activate = function () {}; | |
this.connect = function () {}; | |
this.disconnect = function () {}; | |
this.rpc = function (a, d, g) {}; | |
this.onConnect = function () {}; | |
this.onDisconnect = function () {}; | |
this.onMessage = function (a) {}; | |
this.onError = function () {} | |
}, m = null, | |
h = 0, | |
g = function (a) { | |
m = d[a]; | |
m.activate() | |
}, d = {}; | |
d[0] = new function () { | |
q.call(this); | |
this.activate = function () { | |
clearInterval(h) | |
}; | |
this.connect = function () { | |
g(1) | |
} | |
}; | |
d[1] = new function () { | |
q.call(this); | |
this.activate = function () { | |
clearInterval(h); | |
a.connect(r.connectionUri) | |
}; | |
this.onConnect = function () { | |
f.log("Spotify.WebSockets.Bridge", ["[State.connecting] Socket connected"], "corejs"); | |
g(2) | |
}; | |
this.onDisconnect = function (a) { | |
f.log("Spotify.WebSockets.Bridge", ["[State.connecting] Socket disconnected"], "corejs"); | |
n.trigger(p.FAILED_CONNECTING, a.params || []); | |
g(0) | |
}; | |
this.disconnect = function () { | |
a.disconnect() | |
}; | |
this.onError = function (a) { | |
f.error("Spotify.WebSockets.Bridge", ["[State.connecting] Error", a], "corejs"); | |
n.trigger(p.FAILED_CONNECTING, {}); | |
g(0) | |
} | |
}; | |
d[2] = new function () { | |
q.call(this); | |
this.activate = function () { | |
f.log("Spotify.WebSockets.Bridge", ["[State.authorizing] Sending auth object"], "corejs"); | |
clearInterval(h); | |
var c = r.connectionParams.split(":"); | |
if (200 < parseInt(c[0], 10)) var d = c.shift(), | |
g = c.shift(), c = c.join(":"), c = [d, g, c]; | |
a.sendObject({ | |
name: "connect", | |
id: "0", | |
args: c | |
}) | |
}; | |
this.disconnect = function () { | |
a.disconnect(!1) | |
}; | |
this.onDisconnect = function (a) { | |
f.log("Spotify.WebSockets.Bridge", ["[State.authorizing] Socket disconnected"], "corejs"); | |
n.trigger(p.FAILED_CONNECTING, a.params || []); | |
g(0) | |
}; | |
this.onMessage = function (a) { | |
f.log("Spotify.WebSockets.Bridge", ["[State.authorizing] Got message", a], "corejs"); | |
try { | |
var d = JSON.parse(a); | |
"ok" === d.result ? (n.trigger(p.AUTHENTICATED, {}), n.trigger(p.CONNECTION_ESTABLISHED, {}), g(3)) : d.error && (n.trigger(p.FAILED_CONNECTING, d.error), n.disconnect(), g(0)) | |
} catch (s) {} | |
} | |
}; | |
d[3] = new function () { | |
q.call(this); | |
this.activate = function () { | |
clearInterval(h); | |
h = setInterval(function () { | |
a.isConnected() || (clearInterval(h), a.trigger("ondisconnect", [])) | |
}, 1E3) | |
}; | |
this.onMessage = function (a) { | |
f.log("Spotify.WebSockets.Bridge", ["[State.authorized] Got message", a], "corejs"); | |
try { | |
var d = JSON.parse(a) | |
} catch (g) { | |
n.trigger(p.ERROR, { | |
message: "Response not a JSON object" | |
}); | |
return | |
} | |
a = d.message ? d.message[0] : null; | |
"token_lost" === a ? n.trigger(p.TOKEN_LOST, {}) : "do_work" === a ? n.trigger(p.WORK, d.message[1]) : "ping_flash" === a ? n.trigger(p.PING_FLASH, | |
d.message[1]) : "login_complete" === a ? n.trigger(p.LOGIN_COMPLETE) : "hm_b64" === a ? n.trigger(p.HERMES_B64_MESSAGE, d.message) : "user_info_change" === a ? n.trigger(p.USER_INFO_CHANGE) : d.id ? d.error ? n.trigger(p.RPC_ERRBACK, { | |
requestId: d.id, | |
response: d.error | |
}) : n.trigger(p.RPC_CALLBACK, { | |
requestId: d.id, | |
response: d.result | |
}) : n.trigger(p.ERROR, { | |
error: "Response object invalid" | |
}) | |
}; | |
this.disconnect = function () { | |
a.disconnect() | |
}; | |
this.onDisconnect = function () { | |
f.log("Spotify.WebSockets.Bridge", ["[State.authorized] Socket disconnected"], | |
"corejs"); | |
n.trigger(p.FAILED_CONNECTING, {}); | |
g(0) | |
}; | |
this.rpc = function (c, d, g) { | |
f.log("Spotify.WebSockets.Bridge", ["[State.authorized] Doing an RPC call", c, d], "corejs"); | |
a.sendObject({ | |
id: g, | |
name: "sp/" + c, | |
args: d | |
}) | |
}; | |
this.onError = function (a) { | |
f.error("Spotify.WebSockets.Bridge", ["[State.authorized] onerror", a], "corejs") | |
} | |
}; | |
this.rpc = function (a, d, g) { | |
m.rpc(a, d, g) | |
}; | |
this.connect = function (a, d) { | |
a && (r.connectionParams = a); | |
d && (r.connectionUri = d); | |
m.connect() | |
}; | |
this.disconnect = function () { | |
m.disconnect() | |
}; | |
this.initialize = function () { | |
if ("" === | |
r.connectionUri) throw Error("Spotify.WebSockets.Bridge connectionUri cannot be empty"); | |
a = new Spotify.WebSockets.Client; | |
a.bind("onconnect", function (a) { | |
m.onConnect() | |
}); | |
a.bind("ondisconnect", function (a) { | |
m.onDisconnect(a) | |
}); | |
a.bind("onmessage", function (a) { | |
m.onMessage(a.params.message) | |
}); | |
a.bind("onerror", function (a) { | |
m.onError(a.params.message) | |
}); | |
n.trigger(p.READY, {}); | |
g(0) | |
} | |
}; | |
Spotify.WebSockets.Client = function () { | |
Spotify.EventTarget.call(this); | |
var b = Spotify.DebuggerJS, | |
l = null, | |
f = this; | |
this.connect = function (n) { | |
if ("" === n) throw Error("Spotify.WebSockets.Client connection Uri was not set"); | |
if (this.isConnected()) return !1; | |
if (void 0 === WebSocket) throw Error("Spotify.WebSockets.Client WebSocket interface not supported"); | |
var p = this.currentConnection = (this.currentConnection || 0) + 1; | |
l = new WebSocket(n); | |
l.onopen = function () { | |
b.log("Spotify.WebSockets.Client", ["onopen", p], "corejs"); | |
p == f.currentConnection && | |
f.trigger("onconnect", {}) | |
}; | |
l.onclose = function (l) { | |
b.log("Spotify.WebSockets.Client", ["onclose", p, l], "corejs"); | |
p == f.currentConnection && f.trigger("ondisconnect", [0, l.code, l.reason]) | |
}; | |
l.onmessage = function (l) { | |
b.log("Spotify.WebSockets.Client", ["onmessage", l, p], "corejs"); | |
p == f.currentConnection && f.trigger("onmessage", { | |
message: l.data | |
}) | |
}; | |
l.onerror = function (l) { | |
b.error("Spotify.WebSockets.Client", ["onerror", l, p], "corejs"); | |
p == f.currentConnection && f.trigger("onerror", { | |
message: l | |
}) | |
} | |
}; | |
this.disconnect = function (n) { | |
"undefined" === | |
typeof n && (n = !0); | |
this.isConnected() ? (l.close(), l = null, n && f.trigger("ondisconnect", [0, 0, ""])) : b.error("Spotify.WebSockets.Client", ["Client not connected"], "corejs") | |
}; | |
this.isConnected = function () { | |
return l && 1 === l.readyState | |
}; | |
this.send = function (n) { | |
this.isConnected() ? l.send(n) : (f.trigger("ondisconnect", [0, 0, ""]), b.error("Spotify.WebSockets.Client", ["Client not connected"], "corejs")) | |
}; | |
this.sendObject = function (b) { | |
var l = JSON.stringify(b); | |
32768 < l.length ? f.trigger("onmessage", { | |
message: JSON.stringify({ | |
id: b.id, | |
error: [16, 1, "PACKET_SIZE_EXCEEDED"] | |
}) | |
}) : this.send(l) | |
} | |
}; | |
Spotify.EventTarget = function () { | |
this._listeners = {}; | |
this.bind = this.addEventListener = function (l, f, n, p) { | |
"undefined" === typeof p && (p = 0); | |
if ("undefined" !== typeof f && null !== f) { | |
p = { | |
callback: f, | |
context: n, | |
priority: p | |
}; | |
var r = !1, | |
a; | |
void 0 === this._listeners[l] && (this._listeners[l] = []); | |
a = this._listeners[l]; | |
for (var q = 0; q < a.length; q++) | |
if (a[q].callback === f && a[q].context === n) { | |
r = !0; | |
break | |
}!1 === r && (this._listeners[l].push(p), this._listeners[l].sort(b)) | |
} | |
}; | |
this.bindOnce = function (b, f, n, p) { | |
var r = this, | |
a; | |
a = function () { | |
r.unbind(b, | |
a); | |
f.apply(n, arguments) | |
}; | |
this.bind(b, a, void 0, p) | |
}; | |
var b = function (b, f) { | |
return f.priority - b.priority | |
}; | |
this.trigger = this.dispatchEvent = function (b, f, n) { | |
var p = this._listeners[b]; | |
f = f || {}; | |
if ("undefined" !== typeof p) | |
for (var p = p.concat(), r = 0, a = p.length; r < a; r++) { | |
var q = p[r]; | |
q.context ? q.callback.call(q.context, { | |
type: b, | |
params: f, | |
extra: n || {} | |
}) : q.callback({ | |
type: b, | |
params: f, | |
extra: n || {} | |
}) | |
} | |
}; | |
this._triggerDeferred = function (b, f, n) { | |
var p = this._listeners[b]; | |
f = f || {}; | |
if ("undefined" !== typeof p) | |
for (var r = 0; r < p.length; r++) { | |
var a = | |
p[r]; | |
setTimeout(a.callback.bind(a.context, { | |
type: b, | |
params: f, | |
extra: n || {} | |
}), 0) | |
} | |
}; | |
this.unbind = this.removeEventListener = function (b, f, n) { | |
var p = -1, | |
r = this._listeners[b]; | |
if ("undefined" !== typeof f) { | |
if ("undefined" !== typeof r) { | |
for (var a = 0; a < r.length; a++) | |
if (r[a].callback === f && r[a].context === n) { | |
p = a; | |
break | |
} - 1 !== p && this._listeners[b].splice(p, 1) | |
} | |
} else this._listeners[b] = [] | |
} | |
}; | |
Spotify.Protobuf.Schema = function (b, l, f, n) { | |
Spotify.EventTarget.call(this); | |
var p, r = 0, | |
a = []; | |
this.id = ""; | |
this.PROTO = "proto"; | |
this.type = this.JSON = "json"; | |
this.load = function () { | |
var a, m; | |
if (this.type === this.JSON) m = "json"; | |
else if (this.type === this.PROTO) m = "text"; | |
else throw Error("Not a valid descriptor file for the protobuf schema"); | |
for (a = r = 0; a < b.length; a++) | |
if ("string" === typeof b[a]) { | |
r++; | |
var h = new Spotify.Service; | |
h.url = b[a]; | |
h.dataType = m; | |
h.bind("onSuccess", this.done, this); | |
h.bind("onError", this.error, this); | |
h.fetch() | |
} | |
}; | |
this.reset = function () { | |
a = null | |
}; | |
this.getSchema = function () { | |
return p | |
}; | |
this.msg = function (a) { | |
return p[a] | |
}; | |
this.parse = function (b) { | |
a = null === a ? b : a.concat(b) | |
}; | |
this.encode = function () { | |
var b; | |
this.type == this.JSON ? p = Spotify.Protobuf.Serialization.createFromJson(a) : (b = Spotify.Protobuf.Parser.parseFileDescriptor(a), p = Spotify.Protobuf.Serialization.createFromFileDescriptor(b)) | |
}; | |
this.done = function (a) { | |
this.parse(a.params.result); | |
r--; | |
0 === r && (this.encode(), "undefined" !== typeof n ? "undefined" !== typeof l && l.call(n, this.id, | |
this) : "undefined" !== typeof l && l(this.id, this)) | |
}; | |
this.setData = function (b) { | |
a = b | |
}; | |
this.error = function (a) { | |
"undefined" !== typeof n ? "undefined" !== typeof f && f.call(n, a) : "undefined" !== typeof f && f(a) | |
} | |
}; | |
Spotify.HermesCache = function () { | |
var b = Spotify.Cache.Default, | |
l = ["GET", "HEAD"], | |
f = this, | |
n = [null, null], | |
p = new Spotify.Events, | |
r = function () { | |
return null != n[Spotify.Cache.Types.TEMPORARY] && null != n[Spotify.Cache.Types.PERSISTENT] | |
}, a = function (a) { | |
return function (d) { | |
var c = "com.spotify.cache." + (a || "generic") + ".version", | |
k = function () { | |
localStorage.setItem(c, (5).toString()); | |
n[a] = d; | |
r() && f.trigger(p.READY) | |
}; | |
5 != parseInt(localStorage.getItem(c)) ? d.clear(k) : k() | |
} | |
}, q = function () { | |
throw Error("Failed creating caches!"); | |
}, m = function (a) { | |
return 0 <= | |
a.indexOf("hm://playlist/") ? n[Spotify.Cache.Types.PERSISTENT] : n[Spotify.Cache.Types.TEMPORARY] | |
}, h = function (a, d, c, k, s, b) { | |
var h = m(a); | |
h.get(d, function (a, d) { | |
null == d ? k.call(b) : d.expires < (new Date).getTime() ? d.etag ? s.call(b, d.frames, d.etag) : (h.remove(a), k.call(b)) : c.call(b, d.frames) | |
}) | |
}; | |
f.onReady = function (a, d) { | |
r() ? a.call(d) : f.bind(p.READY, a, d) | |
}; | |
f.isRequestCacheable = function (a) { | |
return -1 != l.indexOf(a.getMethod()) | |
}; | |
f.getCacheKey = function (a) { | |
for (var d = [a.getMethod(), a.getURI()], c = 0, k = a.getRequestFrameCount(); c < | |
k; ++c) d.push(a.getRequestFrame(c)); | |
return d.join("") | |
}; | |
f.getCachedFrames = function (a, d, c, k, s, b) { | |
r() ? h(a, d, c, k, s, b) : (console.warn("Mercury cache not ready."), k.call(b)) | |
}; | |
f.setCachedFrames = function (a, d, c, k, s, b) { | |
r() ? !k || "CACHE_PRIVATE" != c && "CACHE_PUBLIC" != c || (c = { | |
frames: b, | |
expires: (new Date).getTime() + 1E3 * k | |
}, s && (c.etag = s), m(a).put(d, c, null, null, f.onfull)) : console.warn("Mercury cache not ready.") | |
}; | |
f.removeAllContaining = function (a, d) { | |
m(a).removeAllContaining(a, d) | |
}; | |
f.onfull = function () {}; | |
f.migrateToIndexedDB = | |
function (a, d, c) { | |
if (JSON.parse(localStorage.getItem("indexeddb") || !1)) a.call(c); | |
else { | |
var k = n[Spotify.Cache.Types.PERSISTENT], | |
s = new b(5E3, new Spotify.Cache.IndexedDBStorage("Spotify.Mercury.Cache")); | |
delete n[Spotify.Cache.Types.PERSISTENT]; | |
var h = function (a, c) { | |
s.put(a, c) | |
}, m = function () { | |
n[Spotify.Cache.Types.PERSISTENT] = s; | |
k.clear(); | |
localStorage.setItem("indexeddb", "true"); | |
a.call(c, this) | |
}; | |
s.initialize(function () { | |
k._storage.each(h, m, this) | |
}, d, c) | |
} | |
}; | |
(function () { | |
Spotify.EventTarget.call(f); | |
var g = new b(500, new Spotify.Cache.MemoryStorage("Spotify.Mercury.Cache")); | |
g.initialize(a(Spotify.Cache.Types.TEMPORARY), q); | |
g = JSON.parse(localStorage.getItem("indexeddb") || !1) ? new b(5E3, new Spotify.Cache.IndexedDBStorage("Spotify.Mercury.Cache")) : new b(5E3, new Spotify.Cache.LocalStorage("Spotify.Mercury.Cache")); | |
g.initialize(a(Spotify.Cache.Types.PERSISTENT), q) | |
})() | |
}; | |
(function () { | |
"function" !== typeof window.btoa && (window.btoa = Spotify.Utils.Base64.encode); | |
"function" !== typeof window.atob && (window.atob = Spotify.Utils.Base64.decode); | |
var b = Spotify.DebuggerJS, | |
l = Spotify.Protobuf.Serialization.createFromJson([{ | |
name: "Header", | |
fields: [{ | |
id: 1, | |
type: "string", | |
name: "uri" | |
}, { | |
id: 2, | |
type: "string", | |
name: "content_type" | |
}, { | |
id: 3, | |
type: "string", | |
name: "method" | |
}, { | |
id: 4, | |
type: "sint32", | |
name: "status_code" | |
}, { | |
id: 5, | |
type: "string", | |
name: "source" | |
}, { | |
id: 6, | |
type: "*UserField", | |
name: "user_fields" | |
}] | |
}, { | |
name: "UserField", | |
fields: [{ | |
id: 1, | |
type: "string", | |
name: "name" | |
}, { | |
id: 2, | |
type: "bytes", | |
name: "value" | |
}] | |
}]).Header; | |
Spotify.Hermes.Header = l; | |
Spotify.Hermes.Request = function (f) { | |
if (void 0 == f.uri) throw Error("URI not specified!"); | |
var n = Spotify.Hermes.Cache; | |
this.getMethod = function () { | |
return f.method | |
}; | |
this.getURI = function () { | |
return f.uri | |
}; | |
this.getRequestFrameCount = function () { | |
return 0 | |
}; | |
this.getRequestFrameData = function (a) { | |
return null | |
}; | |
this.setRequestFrameData = function (a, c) {}; | |
this.getRequestFrame = function (a) { | |
return null | |
}; | |
this.parseResponseFrame = | |
function (a, c) { | |
return c | |
}; | |
var p = function (a) { | |
for (var c = [], d = (new Date).getTime(), g = 1, h = a.length; g < h; ++g) c.push(this.parseResponseFrame(g - 1, a[g])); | |
b.log("Spotify.Hermes.Request", ["It took", (new Date).getTime() - d, "ms to parse the frames"], "parsing_times"); | |
return c | |
}, r = function (a) { | |
for (var c = [], d = 0, g = a.length; d < g; ++d) c.push(window.atob(a[d])); | |
return c | |
}, a = function (a) { | |
var c = {}; | |
if (a.user_fields) | |
for (var d = 0, g = a.user_fields.length; d < g; ++d) { | |
var b = a.user_fields[d]; | |
switch (b.name) { | |
case "MC-Cache-Policy": | |
"private" == | |
b.value ? c.cache_policy = "CACHE_PRIVATE" : "public" == b.value && (c.cache_policy = "CACHE_PUBLIC"); | |
break; | |
case "MC-TTL": | |
c.ttl = b.value; | |
break; | |
case "MC-ETag": | |
c.etag = b.value | |
} | |
} | |
return c | |
}, q = function (a, c, d) { | |
a.user_fields = a.user_fields || []; | |
a.user_fields.push({ | |
name: c, | |
value: d | |
}) | |
}, m = function (a) { | |
switch (a) { | |
case "SUB": | |
return 1; | |
case "UNSUB": | |
return 2 | |
} | |
return 0 | |
}, h = function (c, d, g, h, q, v, w) { | |
null != h && null != q ? f.user_fields = [{ | |
name: "MC-ETag", | |
value: q | |
}] : delete f.user_fields; | |
var u = m(this.getMethod()); | |
q = (new Date).getTime(); | |
for (var u = [u, | |
window.btoa(l.serializeToStringSync(f)) | |
], A = 0, y = this.getRequestFrameCount(); A < y; ++A) u.push(window.btoa(this.getRequestFrame(A))); | |
b.log("Spotify.Hermes.Request", ["It took", (new Date).getTime() - q, "ms to serialize the request"], "parsing_times"); | |
c.rpc("hm_b64", u, function (c) { | |
c = r(c.response); | |
var k = l.parseFromStringSync(c[0]), | |
b = k.status_code; | |
if (200 <= b && 299 >= b) { | |
var m = a(k); | |
n.setCachedFrames(this.getURI(), n.getCacheKey(this), m.cache_policy, m.ttl, m.etag, c); | |
d(p.call(this, c), b, k) | |
} else 304 == b ? d(p.call(this, h), b, | |
k) : g(new Spotify.Errors.Error([13, b, null, k])) | |
}, g, this, v || !1, 2, w) | |
}, g = function (c) { | |
if (2 != c.length) throw Error("Invalid number of frames!"); | |
var d = l.parseFromStringSync(c[0]); | |
c = { | |
content_type: d.content_type, | |
status_code: d.status_code, | |
body: c[1] | |
}; | |
var d = a(d), | |
g; | |
for (g in d) c[g] = d[g]; | |
return c | |
}, d = function (a, c) { | |
var d = { | |
uri: c, | |
content_type: a.content_type, | |
status_code: a.status_code | |
}; | |
"CACHE_PUBLIC" == a.cache_policy ? q(d, "MC-Cache-Policy", "public") : "CACHE_PRIVATE" == a.cache_policy && q(d, "MC-Cache-Policy", "private"); | |
void 0 !== | |
a.ttl && q(d, "MC-TTL", a.ttl); | |
void 0 !== a.etag && q(d, "MC-ETag", a.etag); | |
return [l.serializeToStringSync(d), a.body] | |
}, c = function (a, c, h, m, q, v) { | |
q = "undefined" !== typeof q ? q : !1; | |
if (1 != this.getRequestFrameCount()) throw Error("Invalid number of request frames!"); | |
var w = this.getRequestFrameData(0).request, | |
u = w.length, | |
A = [], | |
y = [], | |
p = Array(u), | |
E = function (a) { | |
var k = r(a.response), | |
m = l.parseFromStringSync(k[0]); | |
a = m.status_code; | |
if (Spotify.Hermes.Request.isSuccess(a)) | |
if ("vnd.spotify/mercury-mget-reply" != m.content_type) h(new Spotify.Errors.Error([Spotify.Errors.Domains.HERMES_ERROR, | |
500, "Server didn't send a multi-GET reply!" | |
])); | |
else if (2 != k.length) h(new Spotify.Errors.Error([Spotify.Errors.Domains.HERMES_ERROR, 500, "Invalid number of frames in multi-GET reply!"])); | |
else { | |
for (var k = this.parseResponseFrame(0, k[1]).reply, m = (new Date).getTime(), q = 0, t = k.length; q < t; ++q) { | |
var z = A[q], | |
f = k[q], | |
v = y.shift(); | |
304 == f.status_code ? (p[v] = g(z.cachedFrames), p[v].status_code = 200) : Spotify.Hermes.Request.isSuccess(f.status_code) ? (p[v] = f, n.setCachedFrames(z.uri, "GET" + z.uri + (z.body || ""), f.cache_policy, f.ttl, | |
f.etag, d(f, z.uri))) : delete p[v] | |
} | |
b.log("Spotify.Hermes.Request", ["It took", (new Date).getTime() - m, "ms to parse the frames"], "parsing_times"); | |
c([{ | |
reply: p | |
}], a) | |
} else h(new Spotify.Errors.Error([Spotify.Errors.Domains.HERMES_ERROR, a])) | |
}, C = function () { | |
if (0 == A.length) c([{ | |
reply: p | |
}], 200); | |
else { | |
var d = (new Date).getTime(), | |
g = [0, window.btoa(l.serializeToStringSync(f))]; | |
this.setRequestFrameData(0, { | |
request: A | |
}); | |
g.push(window.btoa(this.getRequestFrame(0))); | |
b.log("Spotify.Hermes.Request", ["It took", (new Date).getTime() - | |
d, "ms to serialize the request" | |
], "parsing_times"); | |
a.rpc("hm_b64", g, E, h, this, m || !1, 2, v) | |
} | |
}, H = function (a) { | |
return function (c) { | |
p[a] = g(c); | |
0 >= --u && C.call(this) | |
} | |
}, I = function (a) { | |
return function () { | |
A.push(w[a]); | |
y.push(a); | |
0 >= --u && C.call(this) | |
} | |
}, G = function (a) { | |
return function (c, d) { | |
w[a].etag = d; | |
w[a].cachedFrames = c; | |
A.push(w[a]); | |
y.push(a); | |
0 >= --u && C.call(this) | |
} | |
}; | |
if (q) { | |
q = 0; | |
for (var M = w.length; q < M; ++q) I(q).call(this) | |
} else | |
for (q = 0, M = w.length; q < M; ++q) { | |
var N = w[q]; | |
n.getCachedFrames(N.uri, "GET" + N.uri + (N.body || ""), H(q), I(q), | |
G(q), this) | |
} | |
}; | |
this.send = function (a, d, g, b, m, q) { | |
m = "undefined" !== typeof m ? m : !1; | |
if ("vnd.spotify/mercury-mget-request" == f.content_type) c.call(this, a, d, g, b, m, q); | |
else { | |
var w = function (a) { | |
var c = l.parseFromStringSync(a[0]); | |
d(p.call(this, a), 200, c) | |
}, u = function () { | |
h.call(this, a, d, g, null, null, b, q) | |
}, A = function (c, m) { | |
h.call(this, a, d, g, c, m, b, q) | |
}; | |
m || !n.isRequestCacheable(this) ? u.call(this) : n.getCachedFrames(this.getURI(), n.getCacheKey(this), w, u, A, this) | |
} | |
} | |
}; | |
Spotify.Hermes.Request.isSuccess = function (b) { | |
return 200 <= b && 300 > | |
b | |
}; | |
Spotify.Hermes.Request.isRedirect = function (b) { | |
return 300 <= b && 400 > b | |
}; | |
Spotify.Hermes.Request.isClientError = function (b) { | |
return 400 <= b && 500 > b | |
}; | |
Spotify.Hermes.Request.isServerError = function (b) { | |
return 500 <= b && 600 > b | |
}; | |
Spotify.Hermes.StringRequest = function (b, l) { | |
var p = new Spotify.Hermes.Request(b); | |
p.getRequestFrameCount = function () { | |
return l.length | |
}; | |
p.getRequestFrameData = function (b) { | |
return l[b] | |
}; | |
p.setRequestFrameData = function (b, a) { | |
l[b] = a | |
}; | |
p.getRequestFrame = function (b) { | |
return l[b] | |
}; | |
p.parseResponseFrame = function (b, | |
a) { | |
return a | |
}; | |
return p | |
}; | |
Spotify.Hermes.ProtobufRequest = function (b, l, p, r) { | |
b = new Spotify.Hermes.Request(b); | |
b.getRequestFrameCount = function () { | |
return l.length | |
}; | |
b.getRequestFrameData = function (a) { | |
return l[a] | |
}; | |
b.setRequestFrameData = function (a, b) { | |
l[a] = b | |
}; | |
b.getRequestFrame = function (a) { | |
return p[a] ? p[a].serializeToStringSync(l[a]) : l[a] | |
}; | |
b.parseResponseFrame = function (a, b) { | |
return a < r.length ? r[a].parseFromStringSync(b) : b | |
}; | |
return b | |
} | |
})(); | |
Spotify.Hermes.Handler = function (b) { | |
Spotify.EventTarget.call(this); | |
var l = {}, f = function (f) { | |
var l; | |
if (void 0 !== typeof f && (l = f.split("#"), Spotify.Utils.isArray(l) && 2 == l.length)) return f = l[0], l = l[1], b.getProtobufMsgParser(f, l); | |
throw Error("Not a valid message!"); | |
}; | |
this.send = function (b, l, r, a, q, m, h, g, d) { | |
g = g || !1; | |
var c = [], | |
k = []; | |
if (!Spotify.Utils.isArray(r) && !Spotify.Utils.isArray(a)) throw "Hermes:send Wrong arguments"; | |
for (var s = 0; s < r.length; s++) c.push(f(r[s])); | |
for (s = 0; s < a.length; s++) k.push(f(a[s])); | |
(new Spotify.Hermes.ProtobufRequest({ | |
uri: b, | |
method: l | |
}, q, c, k)).send(_gateway, m, h, g, d, "hermes") | |
}; | |
this.loadSchemas = function (f, p, r, a) { | |
var q; | |
if (Spotify.Utils.isArray(f)) | |
if (q = (new Date).getTime() + Math.floor(1E3 * Math.random()), q = Spotify.Utils.Base64.encode(q.toString()) + "_", "undefined" !== typeof l[q]) r(q); | |
else { | |
var m = function (a, c) { | |
b.registerSchema(a, c); | |
r(a) | |
}; | |
try { | |
var h = new Spotify.Protobuf.Schema(f, m, a, null); | |
l[q] = h; | |
p !== h.PROTO && p !== h.JSON && (p = h.JSON); | |
h.id = q; | |
h.type = p; | |
h.reset(); | |
h.load() | |
} catch (g) { | |
throw "undefined" !== typeof a && a(g), g; | |
} | |
} else a(Error("Schemas is not an array")) | |
}; | |
this.loadSchemaData = function (f, p, r) { | |
var a = (new Date).getTime() + Math.floor(1E3 * Math.random()), | |
a = Spotify.Utils.Base64.encode(a.toString()) + "_", | |
q, m; | |
if (Spotify.Utils.isArray(f)) { | |
f = f.join("\n"); | |
for (q in l) r = l[q], r === f[0] && (m = r, a = q); | |
"undefined" === typeof m && (m = b.registerSchema(a, f), l[a] = m); | |
p(a) | |
} else r(Error("Schemas is not an array")) | |
}; | |
this.init = function (b) { | |
_gateway = b | |
} | |
}; | |
Spotify.GatewayTypes = { | |
FLASH: "FLASH", | |
WEBSOCKETS: "WEBSOCKETS" | |
}; | |
Spotify.PlayerTypes = { | |
FLASH_RTMPS: "FLASH_RTMPS", | |
FLASH_HTTP: "FLASH_HTTP", | |
FLASH_AAC: "FLASH_AAC", | |
WEBSOCKETS_STREAMING: "WEBSOCKETS_STREAMING", | |
HTML5_HTTP: "HTML5_HTTP" | |
}; | |
Spotify.Protocols = { | |
RTMPS: "RTMPS", | |
RTMP: "RTMP", | |
HTTP: "HTTP", | |
HTTPS: "HTTPS" | |
}; | |
Spotify.Instances = function () { | |
var b = {}; | |
return { | |
add: function (l) { | |
l.id = "SPFBIn_" + Math.floor(1E4 * Math.random()); | |
b[l.id] = l; | |
return !0 | |
}, | |
get: function (l) { | |
if (void 0 !== typeof b[l]) return b[l] | |
} | |
} | |
}(); | |
Spotify.Features = function (b) { | |
var l = b || {}; | |
this.isEnabled = function (b) { | |
return !!l[b] | |
}; | |
this.getNumber = function (b) { | |
return Number(l[b]) | |
}; | |
this.getAll = function () { | |
return l | |
} | |
}; | |
Spotify.Flash.SWFObject = function (b) { | |
Spotify.EventTarget.call(this); | |
var l = Spotify.DebuggerJS, | |
f = this; | |
this.isLoaded = !1; | |
var n = new Spotify.Events; | |
this.getSWF = function () { | |
if (this.isLoaded) { | |
if (window.document[b.SWFFlashId]) return window.document[b.SWFFlashId]; | |
if (-1 === navigator.appName.indexOf("Microsoft Internet")) { | |
if (document.embeds && document.embeds[b.SWFFlashId]) return document.embeds[b.SWFFlashId] | |
} else return document.getElementById(b.SWFFlashId) | |
} else l.error("Spotify.Flash.SWFObject", ["SWF Object is not loaded...."], | |
"corejs") | |
}; | |
this.initialize = function () { | |
swfobject.hasFlashPlayerVersion("11.0.0") ? swfobject.embedSWF(b.SWFUrl, b.SWFContainerId, "1", "1", "11.0.0", "", { | |
playerType: b.playerType || "", | |
valid: 0, | |
id: b.SWFFlashId || "", | |
length: 0, | |
instanceId: b.instanceId, | |
logging: b.logging | |
}, { | |
quality: "high", | |
allowscriptaccess: "always", | |
wmode: "window", | |
bgcolor: "#2c2c2d" | |
}, { | |
id: b.SWFFlashId, | |
name: b.SWFFlashId, | |
align: "middle" | |
}, p) : (f.trigger(n.FLASH_UNAVAILABLE), l.error("Spotify.Flash.SWFObject", ["Your Flash is not up to date: 11.0.0"], "corejs")) | |
}; | |
var p = function (b) { | |
!1 === b.success ? (f.trigger(n.FLASH_UNAVAILABLE), l.error("Spotify.Flash.SWFObject", ["Cannot load SWF object"], "corejs")) : (f.trigger(n.FLASH_AVAILABLE), f.isLoaded = !0) | |
} | |
}; | |
Spotify.Flash.PlayerInterface = function (b, l) { | |
Spotify.EventTarget.call(this); | |
var f = this, | |
n = new Spotify.Events, | |
p; | |
this.hasSoundCapabilities = !0; | |
var r = function (a) { | |
this.trigger(a.type, a.params) | |
}; | |
this.run = function (a) { | |
return "undefined" !== typeof p && p.isLoaded ? p.getSWF().sp_run(a) : !1 | |
}; | |
this.playpause = function (a) { | |
return "undefined" !== typeof p && p.isLoaded && this.hasSoundCapabilities ? p.getSWF().sp_playpause(a) : !1 | |
}; | |
this.position = function (a) { | |
try { | |
if ("undefined" !== typeof p && p.isLoaded && this.hasSoundCapabilities) return p.getSWF().sp_time(a) | |
} catch (b) { | |
return 0 | |
} | |
}; | |
this.getPlayerState = function (a) { | |
"undefined" !== typeof p && p.isLoaded && this.hasSoundCapabilities && (response = p.getSWF().sp_playerState(a)); | |
return response | |
}; | |
this.seek = function (a, b) { | |
if ("undefined" !== typeof p && p.isLoaded && this.hasSoundCapabilities) return p.getSWF().sp_seek(a, b) | |
}; | |
this.pause = function (a) { | |
"undefined" !== typeof p && p.isLoaded && this.hasSoundCapabilities && p.getSWF().sp_pause(a) | |
}; | |
this.resume = function (a) { | |
"undefined" !== typeof p && p.isLoaded && this.hasSoundCapabilities && p.getSWF().sp_resume(a) | |
}; | |
this.stop = | |
function (a) { | |
"undefined" !== typeof p && p.isLoaded && this.hasSoundCapabilities && p.getSWF().sp_stop(a) | |
}; | |
this.load = function (a, b, m) { | |
m = m || {}; | |
"undefined" !== typeof p && p.isLoaded && f.hasSoundCapabilities && p.getSWF().sp_load(a, b, m) | |
}; | |
this.play = function (a, b) { | |
"undefined" !== typeof p && p.isLoaded && f.hasSoundCapabilities && p.getSWF().sp_play(a, b) | |
}; | |
this.setVolume = function (a, b) { | |
if ("undefined" !== typeof p && p.isLoaded && this.hasSoundCapabilities) try { | |
p.getSWF().sp_setVolume(a, b) | |
} catch (m) {} | |
}; | |
this.getVolume = function (a) { | |
if ("undefined" !== | |
typeof p && p.isLoaded && this.hasSoundCapabilities) try { | |
return p.getSWF().sp_getVolume(a) | |
} catch (b) {} | |
return 1 | |
}; | |
this.getDuration = function (a) { | |
if ("undefined" !== typeof p && p.isLoaded && this.hasSoundCapabilities) try { | |
return p.getSWF().sp_getDuration(a) | |
} catch (b) {} | |
return 0 | |
}; | |
this.hasSound = function () { | |
return "undefined" !== typeof p && p.isLoaded ? this.hasSoundCapabilities = p.getSWF().sp_hasSound() : !1 | |
}; | |
this.addPlayer = function (a, b, m) { | |
if ("undefined" !== typeof p && p.isLoaded && f.hasSoundCapabilities) return p.getSWF().sp_addPlayer(a, | |
b, m) | |
}; | |
this.removePlayerAtIndex = function (a) { | |
return "undefined" !== typeof p && p.isLoaded && f.hasSoundCapabilities ? (p.getSWF().sp_removePlayerAtIndex(a), !0) : !1 | |
}; | |
this.initializePlayerById = function (a) { | |
"undefined" !== typeof p && p.isLoaded && f.hasSoundCapabilities && p.getSWF().sp_initializePlayerById(a) | |
}; | |
this.initialize = function () { | |
p = new Spotify.Flash.SWFObject({ | |
playerType: l.playerType, | |
SWFFlashId: b + "_player", | |
SWFContainerId: l.SWFPlayerContainerId, | |
SWFUrl: l.SWFPlayerUrl, | |
SWFMinVersion: l.SWFMinVersion, | |
instanceId: b, | |
logging: l.logging, | |
length: l.valid, | |
valid: 0 | |
}); | |
p.bind(n.FLASH_AVAILABLE, r, this); | |
p.bind(n.FLASH_UNAVAILABLE, r, this); | |
p.initialize() | |
}; | |
this.onLoad = function (a) {}; | |
this.onPlay = function (a) {}; | |
this.onPause = function (a) {}; | |
this.onStop = function (a) {}; | |
this.onTrackEnded = function (a) {}; | |
this.onSongLoaded = function (a) {}; | |
this.onPositionChanged = function (a) {}; | |
this.onInvalidTrackUri = function (a) {}; | |
this.onPlaybackFailed = function (a) {} | |
}; | |
Spotify.HTML5.PlayerInterface = function (b) { | |
Spotify.EventTarget.call(this); | |
document.getElementById(b); | |
var l = new Spotify.Events; | |
this.hasSoundCapabilities = !0; | |
this.playpause = function (b) {}; | |
this.position = function (b) { | |
return 0 | |
}; | |
this.getPlayerState = function (b) { | |
return { | |
position: 0, | |
duration: 0, | |
isPaused: !1, | |
isPlaying: !1, | |
isStopped: !0 | |
} | |
}; | |
this.seek = function (b, l) {}; | |
this.pause = function (b) {}; | |
this.resume = function (b) {}; | |
this.stop = function (b) {}; | |
this.load = function (b, l) {}; | |
this.play = function (b, l) {}; | |
this.setVolume = function (b, l) {}; | |
this.getVolume = function (b) { | |
return 0 | |
}; | |
this.getDuration = function (b) { | |
return 0 | |
}; | |
this.hasSound = function () { | |
return !0 | |
}; | |
this.addPlayer = function (b, l, p) {}; | |
this.removePlayerAtIndex = function (b) {}; | |
this.initializePlayerById = function (b) {}; | |
this.initialize = function () { | |
this.trigger(l.READY) | |
}; | |
this.onLoad = function (b) {}; | |
this.onPlay = function (b) {}; | |
this.onPause = function (b) {}; | |
this.onStop = function (b) {}; | |
this.onTrackEnded = function (b) {}; | |
this.onSongLoaded = function (b) {}; | |
this.onPositionChanged = function (b) {}; | |
this.onInvalidTrackUri = | |
function (b) {}; | |
this.onPlaybackFailed = function (b) {} | |
}; | |
Spotify.Parsers.Facebook = function () { | |
this.makeCredential = function (b, l) { | |
var f = {}; | |
if (b || l) { | |
var n = f.credential = {}; | |
b && (n.facebook_uid = b); | |
l && (n.access_token = l) | |
} | |
return f | |
}; | |
this.parseConfig = function (b) { | |
return b[0] | |
}; | |
this.parseCredential = function (b, l) { | |
var f, n = null, | |
p = null; | |
l || (l = "credential"); | |
b && b[0] && (f = b[0][l]); | |
f && (f.facebook_uid && (n = f.facebook_uid), f.access_token && (p = f.access_token)); | |
return { | |
facebookUid: n, | |
accessToken: p | |
} | |
}; | |
this.parseCredentialInspection = function (b) { | |
var l = b[0], | |
f = null; | |
l.alternative_credential && | |
(f = this.parseCredential(b, "alternative_credential")); | |
return { | |
alternativeCredential: f, | |
appUser: l.app_user || null, | |
permanentError: l.permanent_error || !1, | |
transientError: l.transient_error || !1 | |
} | |
}; | |
this.parseFriend = function (b) { | |
return { | |
facebookUid: b.facebook_uid, | |
appUser: b.app_user || null, | |
username: b.spotify_username || null, | |
name: b.display_name || null, | |
picture: b.picture_large || null | |
} | |
}; | |
this.parseFriendList = function (b) { | |
var l = []; | |
b = b[0].friends; | |
for (var f = 0; f < b.length; f++) l.push(this.parseFriend(b[f])); | |
return l | |
}; | |
this.parsePermissions = | |
function (b) { | |
return b[0].permissions | |
}; | |
this.parsePostId = function (b) { | |
return b[0].post_id | |
} | |
}; | |
Spotify.Parsers.Metadata = function () { | |
var b = Spotify.Utils, | |
l = ["album_group", "single_group", "compilation_group", "appears_on_group"], | |
f = function (b, f) { | |
for (var l = 0, a = f.length; l < a; l += 2) | |
if (b[0] == f[l] && b[1] == f[l + 1]) return !0; | |
return !1 | |
}; | |
this.isPlayable = function (b, f) { | |
return "premium" == b && "premium" == f.catalogue ? !0 : "available" == b | |
}; | |
this.parseAlbum = function (f, l) { | |
void 0 != f.gid && (f.id = b.str2hex(f.gid), delete f.gid); | |
if (void 0 != f.artist) | |
for (var r = 0, a = f.artist.length; r < a; ++r) f.artist[r] = this.parseArtist(f.artist[r], null); | |
if (void 0 != f.disc) | |
for (r = 0, a = f.disc.length; r < a; ++r) f.disc[r] = this.parseDisc(f.disc[r]); | |
null != l && (f.availability = this.parseRestrictions(f.restriction, l), f.playable = this.isPlayable(f.availability, l)); | |
void 0 != f.restriction && delete f.restriction; | |
if (void 0 != f.related) | |
for (r = 0, a = f.related.length; r < a; ++r) f.related[r] = this.parseAlbum(f.related[r], null); | |
void 0 != f.cover && delete f.cover; | |
return f | |
}; | |
this.parseAlbumGroup = function (b, f) { | |
var l = []; | |
if (void 0 != b.album) | |
for (var l = b.album, a = 0, q = l.length; a < q; ++a) l[a] = this.parseAlbum(l[a], | |
f); | |
return l | |
}; | |
this.parseArtist = function (f, p) { | |
void 0 != f.gid && (f.id = b.str2hex(f.gid), delete f.gid); | |
void 0 != f.top_track && (f.top_track = this.parseTopTracks(f.top_track, p)); | |
for (var r = 0, a = l.length; r < a; ++r) { | |
var q = l[r]; | |
if (void 0 != f[q]) { | |
for (var m = f[q], h = 0, g = m.length; h < g; ++h) m[h] = this.parseAlbumGroup(m[h], p); | |
f[q] = m | |
} | |
} | |
if (void 0 != f.biography) | |
for (r = 0, a = f.biography.length; r < a; ++r) q = f.biography, m = r, h = f.biography[r], void 0 != h.portrait && delete h.portrait, q[m] = h; | |
null != p && (f.availability = this.parseRestrictions(f.restriction, | |
p), f.playable = this.isPlayable(f.availability, p)); | |
void 0 != f.restriction && delete f.restriction; | |
if (void 0 != f.related) | |
for (r = 0, a = f.related.length; r < a; ++r) f.related[r] = this.parseArtist(f.related[r], null); | |
void 0 != f.portrait && delete f.portrait; | |
return f | |
}; | |
this.parseDisc = function (b) { | |
if (void 0 != b.track) | |
for (var f = 0, l = b.track.length; f < l; ++f) b.track[f] = this.parseTrack(b.track[f], null); | |
return b | |
}; | |
this.parseRestrictions = function (b, l) { | |
var r = {}, a = !1; | |
if ("undefined" === typeof b || 0 == b.length) return "available"; | |
for (var q = | |
0, m = b.length; q < m; ++q) { | |
var h = b[q], | |
g, d = !0; | |
void 0 != h.countries_allowed ? (d = 0 != h.countries_allowed.length, g = f(l.country, h.countries_allowed)) : g = void 0 !== h.countries_forbidden ? !f(l.country, h.countries_forbidden) : !0; | |
if (g && void 0 != h.catalogue) | |
for (g = 0; g < h.catalogue.length; ++g) { | |
var c = h.catalogue[g]; | |
if ("ad" == c.toLowerCase() || "free" == c.toLowerCase()) r.free = !0; | |
else if ("subscription" == c.toLowerCase() || "premium" == c.toLowerCase()) r.premium = !0 | |
} | |
if (void 0 == h.type || "streaming" == h.type.toLowerCase()) a |= d | |
} | |
return a && "all" == | |
l.catalogue ? "available" : r[l.catalogue] ? "premium" == l.catalogue ? "premium" : "available" : r.premium ? "premium" : a ? "regional" : "unavailable" | |
}; | |
this.parseTopTracks = function (b, f) { | |
for (var l = [], a = 0, q = b.length; a < q; ++a) { | |
var m = b[a]; | |
if (void 0 != m.country && m.country == f.country) { | |
void 0 != m.track && (l = b[a].track); | |
break | |
} | |
} | |
a = 0; | |
for (q = l.length; a < q; ++a) l[a] = this.parseTrack(l[a], null); | |
return l | |
}; | |
this.parseTrack = function (f, l) { | |
void 0 != f.gid && (f.id = b.str2hex(f.gid), delete f.gid); | |
void 0 != f.album && (f.album = this.parseAlbum(f.album, null)); | |
if (void 0 != f.artist) | |
for (var r = 0, a = f.artist.length; r < a; ++r) f.artist[r] = this.parseArtist(f.artist[r], null); | |
if (null != l) { | |
var r = this.parseRestrictions(f.restriction, l), | |
a = this.isPlayable(r, l), | |
q; | |
if (q = a) { | |
a: { | |
if (void 0 != f.file) { | |
q = 0; | |
for (var m = f.file.length; q < m; ++q) | |
if ("MP3_160" == f.file[q].format) { | |
q = !0; | |
break a | |
} | |
delete f.file | |
} | |
q = !1 | |
} | |
q = !q | |
} | |
q && (r = "unavailable", a = !1); | |
f.availability = r; | |
f.playable = a | |
} | |
void 0 != f.restriction && delete f.restriction; | |
if (f.playable) f.playableId = f.id; | |
else if (void 0 != f.alternative) { | |
r = 0; | |
for (a = f.alternative.length; r < | |
a; ++r) | |
if (q = this.parseTrack(f.alternative[r], l), q.playable) { | |
f.availability = q.availability; | |
f.playable = q.playable; | |
f.playableId = q.id; | |
break | |
} | |
delete f.alternative | |
} | |
return f | |
} | |
}; | |
Spotify.Parsers.AdMetadata = function () { | |
this.toTrackMetadata = function (b) { | |
return { | |
__pid: b.file_id, | |
name: b.title, | |
disc: 1, | |
duration: parseInt(1E3 * b.duration, 10), | |
number: 1, | |
popularity: b.tracking_url, | |
availability: "available", | |
playable: !0, | |
explicit: !1, | |
image: Spotify.SourceURLs.normal + b.image_id, | |
starred: !1, | |
advertisement: !0, | |
ad_metadata: { | |
type: b.ad_type, | |
embed: { | |
width: b.embed ? b.embed.width : 100, | |
height: b.embed ? b.embed.height : 100, | |
background_image: b.embed ? Spotify.SourceURLs.original + b.embed.background_image : "" | |
}, | |
targetUrl: b.target_url | |
}, | |
artists: [{ | |
uri: b.target_url, | |
name: b.advertiser | |
}] | |
} | |
} | |
}; | |
Spotify.Parsers.Search = function () { | |
var b = Spotify.DebuggerJS, | |
l = new Spotify.Parsers.Metadata, | |
f = function (a) { | |
return a ? Spotify.Utils.isArray(a) ? a : [a] : [] | |
}, n = function (a, d) { | |
if (!a.id) return {}; | |
a["album-type"] && (a.type = a["album-type"].toUpperCase()); | |
if (a["artist-id"] && a["artist-name"]) { | |
var c = a.artists = []; | |
if (Spotify.Utils.isArray(a["artist-id"]) && Spotify.Utils.isArray(a["artist-name"])) | |
for (var k = Math.min(a["artist-id"].length, a["artist-name"].length), b = 0; b < k; ++b) c.push({ | |
id: a["artist-id"][b], | |
name: a["artist-name"][b] | |
}); | |
else c.push({ | |
id: a["artist-id"], | |
name: a["artist-name"] | |
}) | |
} | |
a.cover = r(a); | |
a.popularity && (a.popularity = Math.round(100 * parseFloat(a.popularity))); | |
a.restrictions && (a.restrictions = q(a.restrictions.restriction)); | |
a.availability = l.parseRestrictions(a.restrictions, d); | |
a.playable = l.isPlayable(a.availability, d); | |
delete a.restrictions; | |
delete a["album-type"]; | |
delete a["artist-id"]; | |
delete a["artist-name"]; | |
delete a["external-ids"]; | |
delete a["cover-small"]; | |
delete a["cover-large"]; | |
return a | |
}, p = function (a, d) { | |
if (!a.id) return {}; | |
if (a.portrait) { | |
var c = a.portrait, | |
k = []; | |
c.id && k.push({ | |
size: "DEFAULT", | |
file_id: c.id, | |
width: parseInt(c.width), | |
height: parseInt(c.height) | |
}); | |
c.small && k.push({ | |
size: "SMALL", | |
file_id: c.small | |
}); | |
c.large && k.push({ | |
size: "LARGE", | |
file_id: c.large | |
}); | |
a.portrait = k | |
} | |
a.popularity && (a.popularity = Math.round(100 * parseFloat(a.popularity))); | |
a.restrictions && (a.restrictions = q(a.restrictions.restriction)); | |
a.availability = l.parseRestrictions(a.restrictions, d); | |
a.playable = l.isPlayable(a.availability, d); | |
delete a.restrictions; | |
return a | |
}, r = | |
function (a) { | |
var d = []; | |
a.cover && (d.push({ | |
size: "DEFAULT", | |
file_id: a.cover | |
}), delete a.cover); | |
a["cover-small"] && (d.push({ | |
size: "SMALL", | |
file_id: a["cover-small"] | |
}), delete a["cover-small"]); | |
a["cover-large"] && (d.push({ | |
size: "LARGE", | |
file_id: a["cover-large"] | |
}), delete a["cover-large"]); | |
return d | |
}, a = function (a, d) { | |
return a.uri ? a : {} | |
}, q = function (a) { | |
a = f(a); | |
for (var d = 0, c = a.length; d < c; ++d) { | |
var k = a[d]["@attributes"], | |
b = {}; | |
void 0 !== k.allowed && (b.countries_allowed = k.allowed.replace(/,/g, "")); | |
void 0 !== k.forbidden && (b.countries_forbidden = | |
k.forbidden.replace(/,/g, "")); | |
void 0 !== k.catalogues && (b.catalogue = k.catalogues.split(",")); | |
a[d] = b | |
} | |
return a | |
}, m = function (a, d) { | |
if (!a.id) return {}; | |
a.album && a["album-id"] && (a.album = { | |
name: a.album, | |
id: a["album-id"], | |
artist: { | |
name: a["album-artist"], | |
id: a["album-artist-id"] | |
}, | |
cover: r(a) | |
}); | |
if (a["album-artist"] && a["album-artist-id"]) { | |
a.album = a.album || {}; | |
var c = a.album.artists = []; | |
if (Spotify.Utils.isArray(a["album-artist"]) && Spotify.Utils.isArray(a["album-artist-id"])) | |
for (var k = Math.min(a["album-artist"].length, a["album-artist-id"].length), | |
b = 0; b < k; ++b) c.push({ | |
id: a["album-artist-id"][b], | |
name: a["album-artist"][b] | |
}); | |
else c.push({ | |
id: a["album-artist-id"], | |
name: a["album-artist"] | |
}) | |
} | |
if (a.artist && a["artist-id"]) | |
if (c = a.artists = [], Spotify.Utils.isArray(a.artist) && Spotify.Utils.isArray(a["artist-id"])) | |
for (k = Math.min(a.artist.length, a["artist-id"].length), b = 0; b < k; ++b) c.push({ | |
id: a["artist-id"][b], | |
name: a.artist[b] | |
}); | |
else c.push({ | |
id: a["artist-id"], | |
name: a.artist | |
}); | |
a.length && (a.length = parseInt(a.length)); | |
a.popularity && (a.popularity = Math.round(100 * parseFloat(a.popularity))); | |
a.number && (a.number = parseInt(a["track-number"])); | |
a.year && (a.year = parseInt(a.year)); | |
a.title && (a.name = a.title); | |
a.restrictions && (a.restrictions = q(a.restrictions.restriction)); | |
a.availability = l.parseRestrictions(a.restrictions, d); | |
a.playable = l.isPlayable(a.availability, d); | |
if (a.playable) a.playableId = a.id; | |
else if (a.alternatives) | |
for (c = f(a.alternatives.track), b = 0, k = c.length; b < k; ++b) { | |
var h = m(c[b], d); | |
if (h.playable) { | |
a.availability = h.availability; | |
a.playable = h.playable; | |
a.playableId = h.id; | |
break | |
} | |
} | |
delete a.alternatives; | |
delete a.restrictions; | |
delete a["album-id"]; | |
delete a["album-artist"]; | |
delete a["album-artist-id"]; | |
delete a.artist; | |
delete a.cover; | |
delete a["cover-small"]; | |
delete a["cover-large"]; | |
delete a["artist-id"]; | |
delete a["external-ids"]; | |
delete a.files; | |
delete a["track-number"]; | |
delete a.title; | |
return a | |
}, h = function (a, d, c) { | |
a = f(a); | |
for (var k = 0, b = a.length; k < b; ++k) a[k] = c(a[k], d); | |
return a | |
}; | |
this.parse = function (g, d) { | |
var c = (new Date).getTime(), | |
k = Spotify.Utils.convertStringToXML(g), | |
k = Spotify.Utils.convertXMLToJSON(k.documentElement); | |
k.albums && (k.albums = h(k.albums.album, d, n)); | |
k.artists && (k.artists = h(k.artists.artist, d, p)); | |
k.tracks && (k.tracks = h(k.tracks.track, d, m)); | |
k.playlists && (k.playlists = h(k.playlists.playlist, d, a)); | |
k["did-you-mean"] && (k.didYouMean = k["did-you-mean"], delete k["did-you-mean"]); | |
k.total = { | |
albums: parseInt(k["total-albums"]), | |
artists: parseInt(k["total-artists"]), | |
tracks: parseInt(k["total-tracks"]), | |
playlists: parseInt(k["total-playlists"]) | |
}; | |
delete k["total-albums"]; | |
delete k["total-artists"]; | |
delete k["total-tracks"]; | |
delete k["total-playlists"]; | |
delete k.version; | |
b.log("Spotify.Parsers.Search", ["It took", (new Date).getTime() - c, "ms to parse the search result"], "parsing_times"); | |
return k | |
} | |
}; | |
Spotify.Parsers.Suggest = function () { | |
var b = Spotify.Link, | |
l = Spotify.Utils, | |
f = function (f) { | |
for (var p = 0, r = f.length; p < r; ++p) { | |
var a = f[p]; | |
a.gid && (a.id = l.str2hex(a.gid), delete a.gid); | |
a.image && (a.image = l.str2hex(a.image)); | |
if (a.image_uri) { | |
var q = b.fromString(a.image_uri); | |
a.image = q.id || q.ids[0]; | |
delete a.image_uri | |
} | |
q = a.artists = []; | |
if (Spotify.Utils.isArray(a.artist_gid) && Spotify.Utils.isArray(a.artist_name)) | |
for (var m = Math.min(a.artist_name.length, a.artist_gid.length), h = 0; h < m; ++h) q.push({ | |
id: l.str2hex(a.artist_gid[h]), | |
name: a.artist_name[h] | |
}); | |
delete a.artist_gid; | |
delete a.artist_name; | |
a.owner_uri && a.owner_name && (a.user = { | |
uri: a.owner_uri, | |
name: a.owner_name | |
}); | |
delete a.owner_name; | |
delete a.owner_uri; | |
a.rank && (a.popularity = Math.round(100 * a.rank / 2147483647), delete a.rank) | |
} | |
return f | |
}; | |
this.parse = function (b) { | |
return { | |
artists: f(b.artist || []), | |
albums: f(b.album || []), | |
tracks: f(b.track || []), | |
playlist: f(b.playlist || []) | |
} | |
} | |
}; | |
Spotify.Parsers.Playlist = function () { | |
var b = function (b, f) { | |
var n = [], | |
p = {}; | |
if ("undefined" !== typeof b && "undefined" !== typeof b.items) | |
for (var r = 0; r < b.items.length; r++) { | |
var a; | |
a = b.items[r]; | |
var q = f, | |
m = null, | |
h = {}; | |
if ("undefined" !== typeof a && "undefined" !== typeof a.uri) try { | |
m = Spotify.Link.fromString(a.uri), "collectiontracklist" === m.type && (m = Spotify.Link.starredLink(m.username)), a.attributes && (h = a.attributes), h.added_by || (h.added_by = decodeURIComponent(q)), h.timestamp || (h.timestamp = 0), m.username && encodeURIComponent(m.username) == | |
m.username && (m.username = decodeURIComponent(m.username)) | |
} catch (g) { | |
m = Spotify.Link.emptyLink() | |
} | |
a = { | |
link: m || Spotify.Link.emptyLink(), | |
attributes: h | |
}; | |
if ("starred" === a.link.type) | |
if ("undefined" === typeof p[a.link.username]) p[a.link.username] = !0; | |
else continue; | |
null !== a && n.push({ | |
uri: a.link, | |
attributes: a.attributes | |
}) | |
} | |
return { | |
contents: n | |
} | |
}; | |
this.parsePlaylist = function (l, f) { | |
if ("undefined" !== typeof l.contents) { | |
var n = b(l.contents, f); | |
l.contents = n.contents | |
} | |
"undefined" !== typeof l.revision && (l.revision = Spotify.Utils.str2hex(l.revision)); | |
return l | |
}; | |
this.parsePublishedPlaylist = function (l, f) { | |
if ("undefined" !== typeof l.contents) { | |
var n = b(l.contents, f); | |
l.contents = n.contents; | |
l.length = l.contents.length | |
} | |
"undefined" !== typeof l.revision && (l.revision = Spotify.Utils.str2hex(l.revision)); | |
return l | |
}; | |
this.parseMetadata = function (b) { | |
return b.attributes | |
} | |
}; | |
Spotify.Parsers.AdChooser = function () { | |
var b = Spotify.DebuggerJS, | |
l = function () { | |
b.error("Spotify.Parsers.AdChooser", [].slice.apply(arguments), "corejs") | |
}; | |
this.parseServerResponse = function (b) { | |
b = Spotify.Utils.convertStringToXML(b); | |
return Spotify.Utils.convertXMLToJSON(b.documentElement) | |
}; | |
this.parseAdEntryVersion1 = function (b, l, p, r) { | |
var a = null; | |
"string" === typeof b.html ? a = b.html : "object" === typeof b.html && "string" === typeof b.html["#cdata-section"] && (a = b.html["#cdata-section"]); | |
b = { | |
ad_type: l, | |
has_been_played: !1, | |
has_been_clicked: !1, | |
adPlayCount: 0, | |
campaignPlayCount: 0, | |
ids_valid: !0, | |
non_explicit: b["non-explicit-only"] || 0, | |
is_test_ad: !1, | |
priority: parseFloat(b.priority), | |
duration: parseInt(b.duration, 10), | |
min_duration: 0, | |
ad_version: b.ad_version || 1, | |
start_time_earliest: parseInt(b.starttime), | |
start_time_latest: parseInt(b.endtime), | |
campaign_expiry: parseInt(b.expiry), | |
adclass: 0, | |
adkind: null, | |
adchooserkind: null, | |
rules: r, | |
ad_id: b.id, | |
campaign_id: b.campaign, | |
advertiser: b.advertiser, | |
target_url: b.url, | |
token: b.token, | |
tracking_url: "string" === | |
typeof b["tracking-url"] ? b["tracking-url"] : null, | |
files: b.files, | |
image_id: b.image, | |
embed: { | |
width: b["embed-width"], | |
height: b["embed-height"], | |
background_image: "string" === typeof b["embed-background-image"] ? b["embed-background-image"] : "" | |
}, | |
banner_size: null, | |
banner_type: "string" === typeof b["banner-type"] ? b["banner-type"] : null, | |
banner_mode: "string" === typeof b["banner-mode"] ? b["banner-mode"] : null, | |
html: a, | |
title: "string" === typeof b.title ? b.title : null, | |
caption: "string" === typeof b.caption ? b.caption : null, | |
file_id: p, | |
large_bgcolor: null, | |
large_image_id: null, | |
fullscreen_delay: null, | |
fullscreen_inactivity_timeout: null, | |
background_target_url: null, | |
message: null, | |
level: null | |
}; | |
"audio" === l && (b.adkind = "ENC_AD_AUDIO"); | |
return b | |
}; | |
this.parseAudioAdsVersion1 = function (b, l) { | |
return this.parseAdsVersion1(b, "audio") | |
}; | |
this.parseBannerAdRpcResponse = function (b) { | |
return this.parseAdsVersion1(this.parseServerResponse(b.response), "banner") | |
}; | |
this.parseBannerAdHermesResponse = function (b) { | |
if (!b || !b[0]) return l("no response frame from hermes request"), !1; | |
var n = b[0], | |
p, r, a, q, m, h; | |
b = { | |
AdQueueEntry: [] | |
}; | |
var g, d; | |
if (!n.adQueueEntry || 0 === n.adQueueEntry.length) return l("empty ad queue response"), !1; | |
p = 0; | |
for (r = n.adQueueEntry.length; p < r; p++) { | |
g = n.adQueueEntry[p]; | |
d = { | |
ad_version: g.version, | |
"tracking-url": g.tracking_url, | |
priority: g.priority, | |
duration: g.duration, | |
starttime: g.start_time, | |
endtime: g.end_time, | |
expiry: g.expiry, | |
html: g.html, | |
id: g.id, | |
campaign: g.campaign, | |
advertiser: g.advertiser, | |
url: g.url, | |
token: g.token, | |
image: g.image, | |
"banner-type": g.banner_type | |
}; | |
g.rule = g.rule || []; | |
m = []; | |
a = 0; | |
for (q = | |
g.rule.length; a < q; a++) h = g.rule[a], m.push({ | |
type: h.type, | |
interval: h.interval, | |
times: h.times | |
}); | |
b.AdQueueEntry.push(this.parseAdEntryVersion1(d, "banner", null, m)) | |
} | |
return b | |
}; | |
this.parseAdsVersion1 = function (b, n) { | |
var p = { | |
AdQueueEntry: [] | |
}; | |
"audio" === n && (p["audio-ad-break"] = {}); | |
var r = {}; | |
try { | |
if ("undefined" !== typeof b.rules.rule) | |
for (var a = 0, q = b.rules.rule.length; a < q; a += 1) { | |
var m = b.rules.rule[a]; | |
r[m.id] = m | |
} | |
"audio" === n && (p["audio-ad-break"] = b["audio-ad-break"]); | |
var h = void 0; | |
"audio" === n ? h = b.ads["audio-ad"] : "banner" === | |
n && (h = b.ads["banner-ad"]); | |
if (h) { | |
var g = []; | |
0 < h.length ? g = h : "undefined" !== h.ad_version && (g = [h]); | |
a = 0; | |
for (q = g.length; a < q; a += 1) { | |
for (var d = g[a], h = [], c = 0, k = d.rules.id.length; c < k; c += 1) m = d.rules.id[c], h.push(r[m]); | |
c = null; | |
if ("audio" === n) | |
for (var s = 0, x = d.files.file.length; s < x; s += 1) { | |
var z = d.files.file[s]; | |
if (z["@attributes"] && "MPEG 1 layer 3,160000,0,1,1" === z["@attributes"].format) { | |
c = z["@attributes"].id; | |
break | |
} | |
} | |
s = n; | |
"audio" === s && (s = "string" === typeof d["embed-width"] ? "lightbox" : "audio"); | |
var t = this.parseAdEntryVersion1(d, | |
s, c, h); | |
p.AdQueueEntry.push(t) | |
} | |
} | |
} catch (v) { | |
l(v) | |
} | |
return p | |
} | |
}; | |
Spotify.Parsers.Social = function () { | |
var b = Spotify.DebuggerJS; | |
this.parse = function (l) { | |
var f = (new Date).getTime(); | |
l.username || (l.username = ""); | |
l.full_name || (l.full_name = ""); | |
l.image_url || (l.image_url = ""); | |
l.large_image_url || (l.large_image_url = ""); | |
l.first_name || (l.first_name = ""); | |
l.last_name || (l.last_name = ""); | |
l.facebook_uid || (l.facebook_uid = ""); | |
b.log("Spotify.Parsers.Social", ["It took", (new Date).getTime() - f, "ms to parse the social result"], "parsing_times"); | |
return l | |
} | |
}; | |
Spotify.Parsers.URL = function () { | |
this.parseRTMPUrl = function (b) { | |
var l = Spotify.Utils.parseURL(b); | |
return { | |
server: l.protocol + "://" + l.host + ("" !== l.port ? ":" + l.port : "") + "/cfx/st", | |
protocol: l.protocol, | |
url: b, | |
file: "mp3:" + l.relative.replace("/cfx/st/", "") | |
} | |
}; | |
this.parseHTTPUrl = function (b) { | |
var l = Spotify.Utils.parseURL(b); | |
return { | |
server: l.protocol + "://" + l.host + ("" !== l.port ? ":" + l.port : ""), | |
protocol: l.protocol, | |
url: b, | |
file: l.relative | |
} | |
} | |
}; | |
Spotify.Services.Base = function (b) { | |
Spotify.EventTarget.call(this); | |
this.id = ""; | |
this.serviceIsReady = !1; | |
this.services = {}; | |
this._totalDependenciesReady = 0; | |
this._dependencies = []; | |
var l = new Spotify.Events; | |
this._onServiceReady = function () { | |
this._totalDependenciesReady++; | |
this._totalDependenciesReady >= this._dependencies.length && (delete this._dependencies, delete this._totalDependenciesReady, this.serviceIsReady = !0, this.setup(), this.trigger(l.READY)) | |
}; | |
this.setup = function () {}; | |
this.onReady = function (b, n) { | |
this.serviceIsReady ? | |
b.call(n) : this.bind(l.READY, b, n) | |
}; | |
this._initialize = function (b) { | |
0 === b.length && this._onServiceReady(); | |
for (var l = 0, p = b.length; l < p; l += 1) this.services[b[l].id] = b[l], b[l].onReady(this._onServiceReady, this) | |
}; | |
this.send = function (b) { | |
b.calleeId = this.id; | |
this.trigger(l.REQUEST, b) | |
}; | |
this.onNotify = function (b) {}; | |
this.getProtobufMsgParser = b.getProtobufMsgParser; | |
this.dispose = function () {} | |
}; | |
Spotify.Services.Time = function () { | |
var b; | |
this.getServerTime = function (l, f, n) { | |
this.serviceIsReady ? ("undefined" === typeof n && (n = !1), "undefined" === typeof b || n ? (f = new Spotify.Calls.Simple({ | |
method: "time", | |
payload: [], | |
context: this, | |
persistent: !1, | |
retries: 2, | |
type: "time" | |
}, function (f) { | |
var n = Math.floor((new Date).getTime() / 1E3); | |
b = f.response - n; | |
l(f.response) | |
}, f), this.send(f)) : l(Math.floor((new Date).getTime() / 1E3) + b)) : f(new Spotify.Errors.Error([503, 0, "Time service not ready!"])) | |
} | |
}; | |
Spotify.Services.Suggest = function () { | |
var b = this, | |
l = new Spotify.Parsers.Suggest; | |
this.suggest = function (f, n, p) { | |
this.serviceIsReady ? this.services.user.getUserInfo(function (r) { | |
r = new Spotify.Calls.Hermes({ | |
header: { | |
uri: "hm://searchsuggest/suggest/" + encodeURIComponent(f) + "?country=" + r.country + "&catalogues=" + r.catalogue, | |
method: "GET" | |
}, | |
responseSchemas: ["suggest#Suggestions"], | |
type: "searchsuggest" | |
}, function (a, b) { | |
if (200 == b) { | |
var m = l.parse(a[0]); | |
n(m, b) | |
} else p(new Spotify.Errors.Error([13, b, ""])) | |
}, p); | |
b.send(r) | |
}, function (b) { | |
p(b) | |
}) : | |
p(new Spotify.Errors.Error([13, 503, "Suggest service not ready!"])) | |
} | |
}; | |
Spotify.Services.AppStore = function () { | |
var b = Spotify.DebuggerJS; | |
this.list = function (b, f, n) { | |
this.serviceIsReady ? (b = new Spotify.Calls.Hermes({ | |
header: { | |
uri: "hm://appstore/app/list", | |
method: "GET" | |
}, | |
payload: b, | |
payloadSchemas: ["appstore#RequestHeader"], | |
responseSchemas: ["appstore#AppList"], | |
type: "appstore" | |
}, f, n), this.send(b)) : n(new Spotify.Errors.Error([13, 503, "Appstore service not ready!"])) | |
}; | |
this.getAppVersionsForCurrentUser = function (l, f, n, p, r) { | |
if (this.serviceIsReady) { | |
l = [{ | |
market: l, | |
bridge_identifier: "bridge-web", | |
bridge_version: { | |
major: n.major, | |
minor: n.minor, | |
patch: n.patch | |
}, | |
device_class: "WEB" | |
}]; | |
for (n = 0; n < f.length; n++) l.push(f[n]); | |
f = new Spotify.Calls.Hermes({ | |
header: { | |
uri: "hm://appstore/1.0/apps_deps", | |
method: "GET" | |
}, | |
payload: l, | |
payloadSchemas: ["appstore#RequestHeader"], | |
responseSchemas: [], | |
type: "appstore" | |
}, function (a) { | |
try { | |
p(JSON.parse(a)) | |
} catch (q) { | |
var m = Spotify.Errors.Codes.MALFORMED_RESPONSE; | |
b.error("Spotify.Services.AppStore", ["Malformed response from appstore.apps_deps", a], "corejs"); | |
r(new Spotify.Errors.Error([13, | |
m, "Malformed response from appstore.apps_deps", a | |
])) | |
} | |
}, r); | |
this.send(f) | |
} else r(new Spotify.Errors.Error([13, 503, "Appstore service not ready!"])) | |
} | |
}; | |
Spotify.Services.PopCount = function () { | |
this.get = function (b, l, f, n, p, r) { | |
this.serviceIsReady ? (l = "number" === typeof l ? l : 100, f = "boolean" === typeof f ? "&friendsFirst=" + f : "", n = "string" === typeof n ? "&afterUser=" + n : "", b = Spotify.Link.fromString(b).toURLPath(), l = new Spotify.Calls.Hermes({ | |
header: { | |
uri: "hm://popcount/" + b + "?maxUsers=" + l + f + n, | |
method: "GET" | |
}, | |
payload: [], | |
payloadSchemas: [], | |
responseSchemas: ["popcount#PopcountResult"], | |
type: "PopCount" | |
}, p, r), this.send(l)) : r(new Spotify.Errors.Error([13, 503, "PopCount service not ready!"])) | |
} | |
}; | |
Spotify.Services.Metadata = function () { | |
var b = Spotify.Link, | |
l = this, | |
f = new Spotify.Parsers.Metadata; | |
new Spotify.Events; | |
var n = "", | |
p = function (a) { | |
l.services.user.getUserInfo(function (c) { | |
a("?country=" + c.country + "&catalogue=" + c.catalogue + "&locale=" + ("" !== c.preferred_locale ? c.preferred_locale : n)) | |
}, function (c) { | |
a("") | |
}) | |
}, r = function (a) { | |
switch (a.type) { | |
case b.Type.TRACK: | |
return "hm://metadata/track/" + a.id; | |
case b.Type.ALBUM: | |
return "hm://metadata/album/" + a.id; | |
case b.Type.ARTIST: | |
return "hm://metadata/artist/" + a.id; | |
default: | |
throw Error("Unsupported link type!"); | |
} | |
}, a = function (a) { | |
switch (a) { | |
case b.Type.TRACK: | |
return "metadata#Track"; | |
case b.Type.ALBUM: | |
return "metadata#Album"; | |
case b.Type.ARTIST: | |
return "metadata#Artist"; | |
default: | |
throw Error("Unsupported link type!"); | |
} | |
}, q = function (a) { | |
switch (a) { | |
case b.Type.TRACK: | |
return f.parseTrack.bind(f); | |
case b.Type.ALBUM: | |
return f.parseAlbum.bind(f); | |
case b.Type.ARTIST: | |
return f.parseArtist.bind(f); | |
default: | |
throw Error("Unsupported link type!"); | |
} | |
}, m = function (d, c, k) { | |
var b = function (a, b) { | |
if (Spotify.Hermes.Request.isSuccess(b)) { | |
var g = a[0], | |
h = q(d.type); | |
l.services.user.getUserInfo(function (a) { | |
g = h(g, a); | |
c(g, b) | |
}, function (a) { | |
k(a) | |
}) | |
} else k(b) | |
}; | |
this.send = function () { | |
p(function (c) { | |
c = new Spotify.Calls.Hermes({ | |
header: { | |
uri: r(d) + c, | |
method: "GET" | |
}, | |
payload: [], | |
payloadSchemas: [], | |
responseSchemas: [a(d.type)], | |
type: "metadata", | |
persistent: !1, | |
bypassCache: !1 | |
}, b, k); | |
l.send(c) | |
}) | |
} | |
}, h = function (d, c, k) { | |
var g = d[0].type, | |
h = q(g), | |
m = function (a, d) { | |
var b = []; | |
l.services.user.getUserInfo(function (k) { | |
for (var g = 0, s = a.length; g < s; g += 1) | |
if (a[g]) { | |
var m = h(a[g], k); | |
b.push(m) | |
} | |
c(b, d) | |
}, function (a) { | |
k(a) | |
}) | |
}; | |
this.send = function () { | |
var c = []; | |
p(function (h) { | |
for (var q = 0, x = d.length; q < x; ++q) c.push({ | |
uri: r(d[q]) + h | |
}); | |
q = Spotify.Calls.Hermes; | |
a: switch (g) { | |
case b.Type.TRACK: | |
x = "hm://metadata/tracks"; | |
break a; | |
case b.Type.ALBUM: | |
x = "hm://metadata/albums"; | |
break a; | |
case b.Type.ARTIST: | |
x = "hm://metadata/artists"; | |
break a; | |
default: | |
throw Error("Unsupported link type!"); | |
} | |
h = new q({ | |
header: { | |
uri: x + h, | |
method: "GET" | |
}, | |
payload: [{ | |
request: c | |
}], | |
payloadSchemas: [], | |
responseSchemas: [a(g)], | |
type: "metadata", | |
isMultiGet: !0, | |
persistent: !1, | |
bypassCache: !1 | |
}, m, k); | |
l.send(h) | |
}) | |
} | |
}, g = function (a) { | |
if (a instanceof Spotify.Link) return a; | |
if ("string" === typeof a || a instanceof String) return b.fromString(a); | |
throw Error("Invalid argument!"); | |
}; | |
this.setLocale = function (a) { | |
n = a | |
}; | |
this.lookup = function (a, c, k) { | |
if (l.serviceIsReady) | |
if (Spotify.Utils.isArray(a)) | |
if (1 < a.length) { | |
for (var b = Math.ceil(a.length / 100), q = !1, f = [], t = Array(b), v = function (a) { | |
return function (d, k) { | |
q || (t[a] = d, 0 == --b && c(Array.prototype.concat.apply([], t), 200)) | |
} | |
}, w = function (a) { | |
q = !0; | |
k(a) | |
}, u = 0, A = a.length; u < A; ++u) f.push(g(a[u])); | |
a = 0; | |
do(new h(f.splice(0, 100), v(a++), w)).send(); while (0 < f.length) | |
} else 1 == a.length ? (new m(g(a[0]), function (a, d) { | |
c([a], d) | |
}, k)).send() : k(Error("Array does not contain any items!")); | |
else(new m(g(a), c, k)).send(); | |
else k(Error("Service not ready!")) | |
} | |
}; | |
Spotify.Services.Search = function () { | |
var b = this, | |
l = new Spotify.Parsers.Search; | |
this.DEFAULT_TOTAL_RESULTS = 50; | |
this.TRACKS = 1; | |
this.ALBUMS = 2; | |
this.ARTISTS = 4; | |
this.PLAYLISTS = 8; | |
this.ALL = this.TRACKS | this.ALBUMS | this.ARTISTS | this.PLAYLISTS; | |
this.search = function (f, n, p, r) { | |
this.serviceIsReady ? "undefined" === typeof f || "" === f ? r(new Spotify.Errors.Error([403, 0, "You haven't provided a valid query"])) : (n = n || {}, n.type = n.type || this.ALL, n.total = n.total || this.DEFAULT_TOTAL_RESULTS, n.offset = n.offset || 0, n.total > this.DEFAULT_TOTAL_RESULTS && | |
(n.total = this.DEFAULT_TOTAL_RESULTS), f = new Spotify.Calls.Simple({ | |
method: "search", | |
payload: [f, n.type, n.total, n.offset], | |
context: this, | |
persistent: !1, | |
retries: 2, | |
type: "search" | |
}, function (a) { | |
b.services.user.getUserInfo(function (b) { | |
b = l.parse(a.response, b); | |
p(b) | |
}, function (a) { | |
r(a) | |
}) | |
}, r), this.send(f)) : r(new Spotify.Errors.Error([503, 0, "Search service not ready!"])) | |
} | |
}; | |
Spotify.Services.SearchHermes = function () { | |
this.TRACKS = "TRACK"; | |
this.ALBUMS = "ALBUM"; | |
this.ARTISTS = "ARTIST"; | |
this.PLAYLISTS = "PLAYLIST"; | |
this.USERS = "USER"; | |
this.DEFAULT_TOTAL_RESULTS = 200; | |
this.search = function (b, l, f, n) { | |
this.serviceIsReady ? "undefined" === typeof b || "" === b ? n(new Spotify.Errors.Error([403, 0, "You haven't provided a valid query"])) : (l = l || {}, l.query = b, l.type = l.type || this.TRACKS, l.limit = l.total || this.DEFAULT_TOTAL_RESULTS, delete l.total, l.offset = l.offset || 0, b = new Spotify.Calls.Hermes({ | |
header: { | |
uri: "hm://search/search", | |
method: "GET" | |
}, | |
payload: [l], | |
payloadSchemas: ["searchHermes_FULL#SearchRequest"], | |
responseSchemas: ["searchHermes_FULL#SearchReply"], | |
type: "search_hermes" | |
}, f, n), this.send(b)) : n(new Spotify.Errors.Error([503, 0, "Search service not ready!"])) | |
} | |
}; | |
Spotify.Services.Toplist = function () { | |
var b = this, | |
l = {}; | |
this.TRACK = "track"; | |
this.ALBUM = "album"; | |
this.ARTIST = "artist"; | |
this.PLAYLIST = "playlist"; | |
this.GLOBAL = "global"; | |
var f = { | |
track: Spotify.Link.trackLink, | |
album: Spotify.Link.albumLink, | |
artist: Spotify.Link.artistLink, | |
playlist: Spotify.Link.playlistLink | |
}, n = function (n, r, a, q, m, h, g) { | |
var d = function (c, d) { | |
var b; | |
if (void 0 != c[0].items) { | |
b = c[0].items; | |
for (var g = 0, h = b.length; g < h; ++g) b[g] = f[a](b[g]); | |
l[n] = b; | |
q(b, a, 200) | |
} else if (void 0 != c[0].uris) { | |
b = c[0].uris; | |
g = 0; | |
for (h = b.length; g < | |
h; ++g) b[g] = Spotify.Link.fromString(b[g]); | |
l[n] = b; | |
q(b, a, 200) | |
} else l[n] = [], q([], a, 200) | |
}, c = function (c, h) { | |
if (null != h) q(h, a, 200); | |
else { | |
var x = [], | |
f = [], | |
t = []; | |
"playlist" === a ? (x = ["socialgraph#TopPlaylistsRequest"], f = ["socialgraph#TopPlaylistsReply"], t.push({ | |
username: g | |
})) : f = ["toplist#Toplist"]; | |
x = new Spotify.Calls.Hermes({ | |
header: { | |
uri: r, | |
method: "GET" | |
}, | |
payload: t, | |
payloadSchemas: x, | |
responseSchemas: f, | |
type: "toplist" | |
}, d, m); | |
b.send(x) | |
} | |
}; | |
h ? c(n, null) : c(n, l[n]) | |
}; | |
this.lookupForUser = function (b, f, a, q, m) { | |
this.serviceIsReady ? this.services.user.getUserInfo(function (h) { | |
b = | |
b ? b : h.user; | |
h = Spotify.Link.userToplistLink(b, f).toURI(); | |
var g = "hm://toplist/toplist/user/" + encodeURIComponent(b) + "?type=" + f; | |
"playlist" === f && (g = "hm://socialgraph/suggestions/topplaylists"); | |
n(h, g, f, a, q, m, b) | |
}, q) : q(new Spotify.Errors.Error([13, 503, "Toplist service not ready!"])) | |
}; | |
this.lookupForRegion = function (b, f, a, q, m) { | |
this.serviceIsReady ? this.services.user.getUserInfo(function (h) { | |
b = b ? b : h.country; | |
h = "global" == b; | |
var g = Spotify.Link.toplistLink(f, h ? null : b, h).toURI(); | |
n(g, h ? "hm://toplist/toplist/region?type=" + | |
f : "hm://toplist/toplist/region/" + b + "?type=" + f, f, a, q, m) | |
}, q) : q(new Spotify.Errors.Error([13, 503, "Toplist service not ready!"])) | |
} | |
}; | |
Spotify.Services.Playlist = function () { | |
this.DEFAULT_TOTAL_RESULTS = 200; | |
var b = Spotify.Utils.isArray, | |
l = Spotify.DebuggerJS, | |
f = this, | |
n = new Spotify.Events, | |
p = new Spotify.Parsers.Playlist, | |
r = [], | |
a = null, | |
q = {}, m = function (a, c) { | |
c = "undefined" !== typeof c && c.length ? "?" + c.join("&") : ""; | |
return "hm://playlist/" + a.split(":").join("/").substr(8) + c | |
}, h = function (a) { | |
return function () { | |
for (var c = 0; c < a.length; c++) "function" === typeof a[c] && a[c].apply(this, arguments) | |
} | |
}, g = function (a, d, k, b, g, h) { | |
var s = []; | |
"ADD" === a && s.push("add_first=true"); | |
a = "APPEND" === a ? "ADD" : a; | |
"REMOVE" !== a && "MODIFY" !== a || "inbox" === Spotify.Link.fromString(d).type || s.push("syncpublished=true"); | |
var x = [], | |
x = "REMOVE" === a || "ADD" === a || "APPEND" === a ? [] : ["playlist_FULL#OpList"], | |
l = []; | |
"MODIFY" === a ? l = ["playlist_FULL#ModifyReply"] : "PUT" === a && (l = ["playlist_FULL#CreateListReply"]); | |
k && "MODIFY" === a && (k = Spotify.Utils.formatPlaylistRevision(k.revision), s.push("revision=" + k)); | |
var n = 0, | |
p = 0, | |
r = function () { | |
var k = new Spotify.Calls.Hermes({ | |
header: { | |
uri: m(d, s), | |
method: a | |
}, | |
payload: [b], | |
payloadSchemas: x, | |
responseSchemas: l, | |
type: "playlist", | |
persistent: !1, | |
bypassCache: !1 | |
}, function (s) { | |
f.services.user.getUserInfo(function (h) { | |
q[d] = Spotify.Utils.formatPlaylistRevision(Spotify.Utils.str2hex(s[0].revision || s[0])); | |
var m = [], | |
x = []; | |
"string" === typeof b && (m = b.split(",")); | |
for (var f = 0, v = m.length; f < v; f += 1) { | |
var l = { | |
uri: Spotify.Link.fromString(m[f]) | |
}; | |
"ADD" === a && d !== Spotify.Link.publishedRootlistLink(h.user).toURI() && "playlist" === l.uri.type && x.push(l) | |
} | |
0 < x.length && c(x); | |
"function" === typeof g && ("PUT" === a ? g(s, { | |
revision: q[d] | |
}) : | |
g(!0, { | |
revision: q[d] | |
})); | |
h = k.header.uri.split("?")[0]; | |
m = "GET"; | |
"MODIFY" !== a || !b.ops.length || "UPDATE_LIST_ATTRIBUTES" !== b.ops[0].kind && "UPDATE_ITEM_ATTRIBUTES" !== b.ops[0].kind || (m = "HEAD"); | |
Spotify.Hermes.Cache.removeAllContaining(m + h) | |
}, h) | |
}, G); | |
f.send(k) | |
}, G = function () { | |
4 <= p ? "function" === typeof h && h.apply(this, arguments) : (n = 500 * Math.floor(2 * p * Math.random()), p++, setTimeout(r, n)) | |
}; | |
return r | |
}, d = function () { | |
var a; | |
f.serviceIsReady ? f.services.user.getUserInfo(function (d) { | |
a = Spotify.Link.profileLink(d.user); | |
l.log("Spotify.Services.Playlist", ["Will try to subscribe to", a.username], "corejs"); | |
c([{ | |
uri: a | |
}]); | |
f.rootlist({ | |
total: -1, | |
offset: 0 | |
}, function (a) { | |
for (var k = [], b = 0, g = a.contents.length; b < g; b += 1) { | |
var h = a.contents[b]; | |
h.username !== d.user && k.push(h) | |
} | |
0 < k.length && (l.log("Spotify.Services.Playlist", ["Will try to subscribe to", k], "corejs"), c(k)) | |
}, s) | |
}, s) : l.error("Spotify.Services.Playlist", ["Playlist service not ready"], "corejs") | |
}, c = function (a) { | |
var c = []; | |
if (!Spotify.Utils.isArray(a)) throw "Playlists argument must be an array"; | |
if (0 !== a.length) { | |
for (var d = | |
0, b = a.length; d < b; d += 1) "undefined" !== typeof a[d] && "undefined" !== typeof a[d].uri && c.push("hm://playlist/" + a[d].uri.toURLPath()); | |
f.services.pubsub.subscribe("hm://playlist/", [{ | |
uris: c | |
}], ["playlist_FULL#SubscribeRequest"], [], k, s, x, f) | |
} | |
}, k = function (a) { | |
l.log("Spotify.Services.Playlist", ["Subscription was a success", a], "corejs") | |
}, s = function (a) { | |
l.error("Spotify.Services.Playlist", ["Subscription failed", a], "corejs") | |
}, x = function (a, c) { | |
var d; | |
0 < a.length && (d = f.getProtobufMsgParser("playlist4service", "PlaylistModificationInfo").parseFromStringSync(Spotify.Utils.Base64.decode(a[3])), | |
"undefined" !== typeof d.new_revision && (d.new_revision = Spotify.Utils.formatPlaylistRevision(Spotify.Utils.str2hex(d.new_revision))), l.log("Spotify.Services.Playlist", ["Got a notification", d], "corejs"), "undefined" !== typeof d.uri && (f.trigger(n.CHANGE, { | |
localRevision: q[d.uri], | |
revision: d.new_revision, | |
uri: d.uri | |
}), l.log("Spotify.Services.Playlist", ["Triggered change event for ", d.uri, " with new revision: ", d.new_revision], "corejs"))) | |
}; | |
this.metadata = function (a, c, d) { | |
if (f.serviceIsReady) { | |
"string" == typeof a && | |
(a = Spotify.Link.fromString(a)); | |
var k = new Spotify.Calls.Hermes({ | |
header: { | |
uri: m(a.toURI()), | |
method: "HEAD" | |
}, | |
payload: [], | |
payloadSchemas: [], | |
responseSchemas: ["playlist_FULL#SelectedListContent"], | |
type: "playlist", | |
persistent: !1, | |
bypassCache: !1 | |
}, function (k) { | |
var b = a.toURI(); | |
if ("undefined" == typeof k || "undefined" == typeof k[0]) d(new Spotify.Errors.Error([13, 404, "No results", b])); | |
else { | |
var g = p.parseMetadata(k[0]); | |
g.owner = Spotify.Link.fromString(b).username; | |
g.uri = b; | |
g.revision = Spotify.Utils.formatPlaylistRevision(Spotify.Utils.str2hex(k[0].revision)); | |
c(g) | |
} | |
}, function (c) { | |
c.data = a.toURI(); | |
d(c) | |
}); | |
this.send(k) | |
} else d(new Spotify.Errors.Error([13, 503, "Playlist service not ready!"])) | |
}; | |
this.getChangesBetweenRevisionAndHead = function (a, c, d, k) { | |
c = new Spotify.Calls.Hermes({ | |
header: { | |
uri: m(a) + "?revision=" + c, | |
method: "DIFF" | |
}, | |
payload: [], | |
payloadSchemas: [], | |
responseSchemas: ["playlist_FULL#SelectedListContent"], | |
type: "playlist", | |
persistent: !1, | |
bypassCache: !1 | |
}, function (c) { | |
var k = {}; | |
k.operations = c[0].diff.ops; | |
k.uri = a; | |
k.revision = Spotify.Utils.formatPlaylistRevision(Spotify.Utils.str2hex(c[0].revision)); | |
q[a] = k.revision; | |
d(k) | |
}, k); | |
f.send(c) | |
}; | |
this.subscribe = function (c, d, k) { | |
clearTimeout(a); | |
if (f.serviceIsReady) { | |
"undefined" === typeof c.publish && (c.publish = !1); | |
for (var s = b(c.uri) ? c.uri : [c.uri], m = s.length; m--;) { | |
var q = Spotify.Link.fromString(s[m]); | |
s[m] = q.toURI() | |
} | |
r.push({ | |
username: c.username, | |
uri: s, | |
callback: d, | |
errback: k | |
}); | |
var x = this, | |
B; | |
a = setTimeout(function () { | |
B = r.slice(0); | |
a = null; | |
r = []; | |
for (var d = {}, k = {}, b = {}, s = {}, m = 0; m < B.length; m++) s = B[m], d[s.username] = d[s.username] || [], k[s.username] = k[s.username] || [], b[s.username] = | |
b[s.username] || [], d[s.username] = d[s.username].concat(s.uri), k[s.username].push(s.callback), b[s.username].push(s.errback); | |
for (var q in d) { | |
var t = d[s.username], | |
v = h(k[s.username]), | |
w = h(b[s.username]), | |
u = Spotify.Link.rootlistLink(c.username).toURI(); | |
x.list({ | |
uri: u, | |
total: -1 | |
}, function (a) { | |
for (var c = u, d = v, k = w, b = t.slice(0), h = 0; h < a.contents.length; h++) { | |
var s = a.contents[h].uri; | |
if ("empty" != s.type) | |
for (var m = 0; m < b.length; m++) s.toURI() == b[m] && delete b[m] | |
} | |
a = []; | |
for (h = 0; h < b.length; h++) b[h] && a.push(b[h]); | |
0 < a.length ? (g("ADD", | |
c, null, a.join(","), d, k)(), f.trigger(n.PLAYLIST_SUBSCRIBE, { | |
uris: a | |
})) : "function" === typeof d && d(!0) | |
}, w); | |
c.publish && setTimeout(function () { | |
x.publishPlaylists(t, function () { | |
l.log("Spotify.Services.Playlist", ["Playlists were published too", t], "corejs") | |
}, function (a) { | |
l.error("Spotify.Services.Playlist", ["Playlists couldn't be published", t], "corejs") | |
}) | |
}, 2E3) | |
} | |
}, 100) | |
} else k(new Spotify.Errors.Error([13, 503, "Playlist service not ready!"])) | |
}; | |
this.list = function (a, c, d) { | |
if (f.serviceIsReady) { | |
a.total > this.DEFAULT_TOTAL_RESULTS ? | |
a.total = this.DEFAULT_TOTAL_RESULTS : a.total || (a.total = -1); | |
"undefined" === typeof a.offset && (a.offset = 0); | |
var k = Spotify.Link.fromString(a.uri), | |
b = { | |
uri: m(k.toURI()), | |
method: "GET" | |
}; | |
"undefined" !== typeof a.offset && "undefined" !== typeof a.total && (b.uri += "?from=" + a.offset, -1 !== a.total && (b.uri += "&length=" + a.total)); | |
a = new Spotify.Calls.Hermes({ | |
header: b, | |
payload: [], | |
payloadSchemas: [], | |
responseSchemas: ["playlist_FULL#SelectedListContent"], | |
type: "playlist", | |
persistent: !1, | |
bypassCache: !1 | |
}, function (a) { | |
if ("undefined" == typeof a || | |
"undefined" == typeof a[0]) d(new Spotify.Errors.Error([13, 404, "No results"])); | |
else { | |
var b; | |
b = "published-rootlist" === k.type ? p.parsePublishedPlaylist(a[0], k.username) : p.parsePlaylist(a[0], k.username); | |
q[k.toURI()] = Spotify.Utils.formatPlaylistRevision(a[0].revision) || ""; | |
"starred" == k.type && b.contents.reverse(); | |
c(b, { | |
revision: q[k.toURI()] | |
}) | |
} | |
}, d); | |
this.send(a) | |
} else d(new Spotify.Errors.Error([13, 503, "Playlist service not ready!"])) | |
}; | |
this.rootlist = function (a, c, d) { | |
this.services.user.getUserInfo(function (k) { | |
a.username = | |
k.user; | |
a.uri = Spotify.Link.rootlistLink(a.username).toURI(); | |
f.list(a, c, d) | |
}, d) | |
}; | |
this.publishedRootlist = function (a, c, d) { | |
a.offset && delete a.offset; | |
a.total = -1; | |
a.uri = Spotify.Link.publishedRootlistLink(a.username).toURI(); | |
this.list(a, c, d) | |
}; | |
this.starredPlaylist = function (a, c, d) { | |
a.uri = Spotify.Link.starredLink(a.username).toURI(); | |
this.list(a, c, d) | |
}; | |
this.publishPlaylists = function (a, c, d) { | |
this.services.user.getUserInfo(function (k) { | |
k = Spotify.Link.publishedRootlistLink(k.user).toURI(); | |
g("ADD", k, null, a.join(","), c, | |
d)() | |
}, d) | |
}; | |
this.unpublishPlaylists = function (a, c, d) { | |
this.services.user.getUserInfo(function (k) { | |
k = Spotify.Link.publishedRootlistLink(k.user).toURI(); | |
f.removeFromPlaylistByUri(k, a, c, d) | |
}, d) | |
}; | |
this.addToPlaylist = function (a, c, d, k) { | |
g("APPEND", a, null, c.join(","), d, k)() | |
}; | |
this.addToPlaylistWithAttributes = function (a, c, d, k) { | |
for (var b = [], h = 0, s = c.length; h < s; h += 1) { | |
var m = c[h]; | |
b.push({ | |
uri: m.uri, | |
attributes: { | |
added_by: m.addedBy || "" | |
} | |
}); | |
m.message && (b[b.length - 1].attributes.message = m.message) | |
} | |
g("MODIFY", a, null, { | |
ops: [{ | |
kind: "ADD", | |
add: { | |
addLast: !0, | |
items: b | |
} | |
}] | |
}, d, k)() | |
}; | |
this.modifyPlaylist = function (a, c, d, k) { | |
var b = { | |
ops: c | |
}; | |
this.list({ | |
uri: a, | |
total: -1 | |
}, function (c) { | |
g("MODIFY", a, c, b, d, k)() | |
}) | |
}; | |
this.addTracksInPlaylist = function (a, c, d, k) { | |
f.addToPlaylist(a, c, d, k) | |
}; | |
this.removeFromPlaylistByUri = function (a, c, d, k) { | |
g("REMOVE", a, null, c.join(","), d, k)() | |
}; | |
this.removeFromPlaylist = function (a, c, d, k, b) { | |
this.list({ | |
uri: a, | |
total: -1 | |
}, function (h) { | |
g("MODIFY", a, h, { | |
ops: [{ | |
kind: "REM", | |
rem: { | |
fromIndex: c, | |
length: d | |
} | |
}] | |
}, k, b)() | |
}, function (a) { | |
b(a) | |
}) | |
}; | |
this.starTracks = function (a, | |
c, d) { | |
this.services.user.getUserInfo(function (k) { | |
k = Spotify.Link.starredLink(k.user).toURI(); | |
f.addToPlaylist(k, a, c, d) | |
}, d) | |
}; | |
this.unstarTracks = function (a, c, d) { | |
this.services.user.getUserInfo(function (k) { | |
k = Spotify.Link.starredLink(k.user).toURI(); | |
f.removeFromPlaylistByUri(k, a, c, d) | |
}, d) | |
}; | |
this.createPlaylist = function (a, c, d) { | |
this.services.user.getUserInfo(function (k) { | |
var b = Spotify.Link.profileLink(k.user).toURI(), | |
h = "undefined" === typeof a.subscribe ? !0 : a.subscribe; | |
g("PUT", b, null, { | |
ops: [{ | |
kind: "UPDATE_LIST_ATTRIBUTES", | |
update_list_attributes: { | |
new_attributes: { | |
values: { | |
name: a.name | |
} | |
} | |
} | |
}] | |
}, function (b, g) { | |
h ? f.subscribe({ | |
username: k.user, | |
uri: b[0].uri, | |
publish: a.publish | |
}, function () { | |
c(b[0].uri, { | |
revision: Spotify.Utils.formatPlaylistRevision(g.revision) | |
}) | |
}, d) : c(b[0].uri, { | |
revision: Spotify.Utils.formatPlaylistRevision(g.revision) | |
}) | |
}, d)() | |
}, d) | |
}; | |
this.renamePlaylist = function (a, c, d, k) { | |
g("MODIFY", a, null, { | |
ops: [{ | |
kind: "UPDATE_LIST_ATTRIBUTES", | |
update_list_attributes: { | |
new_attributes: { | |
values: { | |
name: c | |
} | |
} | |
} | |
}] | |
}, function (a, c) { | |
d(!0, c) | |
}, k)() | |
}; | |
this.updateItemAttributes = | |
function (a, c, d, k, b) { | |
var h = { | |
ops: [{ | |
kind: "UPDATE_ITEM_ATTRIBUTES", | |
update_item_attributes: { | |
index: c, | |
new_attributes: { | |
values: d | |
} | |
} | |
}] | |
}; | |
this.list({ | |
uri: a, | |
total: -1 | |
}, function (c) { | |
g("MODIFY", a, c, h, function (a, c) { | |
k(!0, c) | |
}, b)() | |
}, b) | |
}; | |
this.synchronize = function (a, c, d, k) { | |
a = new Spotify.Calls.Hermes({ | |
header: { | |
uri: m(a), | |
method: "CALL" | |
}, | |
payload: requestData, | |
payloadSchemas: ["playlist_FULL#Playlist4ServiceCall"], | |
responseSchemas: ["playlist_FULL#Playlist4ServiceReturn"], | |
type: "playlist", | |
persistent: !1, | |
bypassCache: !1 | |
}, d, k); | |
this.send(a) | |
}; | |
this.onNotify = function (a) { | |
switch (a.type) { | |
case n.CONNECTED: | |
d() | |
} | |
} | |
}; | |
Spotify.Services.User = function () { | |
var b = this, | |
l = new Spotify.Events, | |
f = null, | |
n = !1, | |
p = []; | |
this.getUserInfo = function (b, a, q) { | |
"undefined" === typeof q && (q = !1); | |
null === f || q ? (p.push({ | |
onSuccess: b, | |
onError: a | |
}), n || (n = !0, b = new Spotify.Calls.Simple({ | |
method: "user_info", | |
payload: [], | |
context: this, | |
persistent: !1, | |
retries: 2, | |
type: "userdata" | |
}, function (a) { | |
f = a.response; | |
n = !1; | |
a = 0; | |
for (var b = p.length; a < b; a += 1) p[a].onSuccess(f); | |
p = [] | |
}, function (a) { | |
n = !1; | |
for (var b = 0, g = p.length; b < g; b += 1) p[b].onError(a); | |
p = [] | |
}), this.send(b))) : b(f) | |
}; | |
this.setUserAttribute = | |
function (n, a, q, m) { | |
m = new Spotify.Calls.Simple({ | |
method: "set_ua", | |
payload: [n, a], | |
context: this, | |
persistent: !1, | |
retries: 2, | |
type: "userdata" | |
}, function (h) { | |
f[n] = a; | |
q(!0, 200); | |
b.trigger(l.USER_INFO_CHANGE) | |
}, m); | |
this.send(m) | |
}; | |
this.onNotify = function (b) { | |
switch (b.type) { | |
case l.USER_INFO_CHANGE: | |
this.trigger(l.USER_INFO_CHANGE) | |
} | |
} | |
}; | |
Spotify.Services.Social = function () { | |
new Spotify.Parsers.Social; | |
this.getUsers = function (b, l, f, n) { | |
var p = 0, | |
r = [], | |
a = 0; | |
"undefined" === typeof l ? l = "fast" : "fast" !== l && "complete" !== l && (l = "fast"); | |
for (p = b.length; a < p; ++a) r.push({ | |
uri: "hm://social/decoration/user/" + encodeURIComponent(b[a]) | |
}); | |
b = new Spotify.Calls.Hermes({ | |
header: { | |
uri: "hm://social/decorations/" + l, | |
method: "GET" | |
}, | |
isMultiGet: !0, | |
payload: [{ | |
request: r | |
}], | |
responseSchemas: ["social#DecorationData"], | |
type: "social" | |
}, f, n); | |
this.send(b) | |
} | |
}; | |
Spotify.SourceURLs = { | |
normal: "https://d3rt1990lpmkn.cloudfront.net/300/", | |
original: "https://d3rt1990lpmkn.cloudfront.net/unbranded/" | |
}; | |
Spotify.Services.SongUriResolver = function () { | |
var b = Spotify.DebuggerJS, | |
l = new Spotify.Events, | |
f = this, | |
n = new Spotify.Parsers.URL, | |
p, r = !1; | |
this.IN_CDN = 0; | |
this.ONLY_ON_STORAGE = 1; | |
this.RATE_LIMIT_REACHED = 2; | |
this.TRACK_RESTRICTED = 3; | |
var a = function (a) { | |
var h = a.params.trackUri, | |
g = a.params.callback, | |
d = a.params.errback; | |
a = a.params.schema; | |
b.log("Spotify.Services.SongUriResolver", ["Rate limit is calling again:", h], "corejs"); | |
f.list(h, a, g, d) | |
}, q = function (a) { | |
b.log("Spotify.Services.SongUriResolver", ["Rate limit is disabled"], | |
"corejs"); | |
r = !1 | |
}; | |
this.list = function (a, h, g, d) { | |
var c = Spotify.Link.fromString(a); | |
if (this.serviceIsReady) { | |
if (!(c instanceof Spotify.Link)) return b.error("Spotify.Services.SongUriResolver", ["Invalid arguments"], "corejs"), d(Error("Services:SongUriResolver:list Invalid arguments")), !1; | |
if (r && 0 !== p.totalPendingRequests()) { | |
c = p.getItemAtIndex(0); | |
if (null !== c && "undefined" !== typeof c) { | |
var k = new Spotify.Errors.Error([Spotify.Errors.Domains.TRACK_ERROR, Spotify.Errors.Codes.TRACK_REQUEST_RATE_LIMITED, ""]); | |
c.errback(k) | |
} | |
p.addToBucket({ | |
trackUri: a, | |
schema: h, | |
callback: g, | |
errback: d | |
}, !1) | |
} else c = new Spotify.Calls.Simple({ | |
method: "track_uri", | |
payload: ["mp3160", c.id, h], | |
context: f, | |
persistent: !0, | |
retries: 2, | |
type: "track_uri" | |
}, function (c) { | |
if (null !== c.response) { | |
var k = c.response.type; | |
k === f.IN_CDN ? ("rtmp" === h ? (k = n.parseRTMPUrl(c.response.uri), c.response.uri = k.file) : k = n.parseHTTPUrl(c.response.uri), c.response.server = k.server, c.response.protocol = k.protocol, g(c.response, 200), b.log("Spotify.Services.SongUriResolver", ["Song can be loaded", c.response], "corejs")) : (c = | |
new Spotify.Errors.Error([Spotify.Errors.Domains.TRACK_ERROR, 0, ""]), c.code = k, k === f.ONLY_ON_STORAGE ? c.description = "Song only on storage" : k === f.RATE_LIMIT_REACHED ? c.description = "Rate limit reached" : k === f.TRACK_RESTRICTED && (c.description = "Track restricted"), c.data = a, d(c), b.error("Spotify.Services.SongUriResolver", ["I could not load the song", c], "corejs")) | |
} else c = new Spotify.Errors.Error([Spotify.Errors.Domains.TRACK_ERROR, 0, "Response was null"]), c.data = a, d(c), b.error("Spotify.Services.SongUriResolver", ["I could not load the song", c], "corejs") | |
}, function (c) { | |
c.data = a; | |
c.domain === Spotify.Errors.Domains.TRACK_ERROR && c.code === Spotify.Errors.Codes.TRACK_REQUEST_RATE_LIMITED ? (b.warn("Spotify.Services.SongUriResolver", ["Rate limit is enabled"], "corejs"), r = !0, p.start(), p.addToBucket({ | |
trackUri: a, | |
callback: g, | |
errback: d | |
}, !1)) : (c.domain === Spotify.Errors.Domains.TRACK_ERROR && c.code === Spotify.Errors.Codes.TIME_CAP && f.trigger(l.TIME_CAP, c), d(c)); | |
b.error("Spotify.Services.SongUriResolver", ["I could not load the song", | |
c | |
], "corejs") | |
}), f.send(c) | |
} else b.error("Spotify.Services.SongUriResolver", ["Service is not ready"], "corejs"), d(Error("Services.SongUriResolver:list Service is not ready")) | |
}; | |
this.initialize = function () { | |
p = new Spotify.RateLimiter(1E4, 1); | |
p.bind(l.RATE_LIMIT_CALL, a, this); | |
p.bind(l.RATE_LIMIT_DISABLED, q, this) | |
}; | |
this.initialize.call(this) | |
}; | |
Spotify.Services.AdUriResolver = function () { | |
var b = Spotify.DebuggerJS, | |
l = new Spotify.Parsers.URL, | |
f = this; | |
this.list = function (n, p, r, a) { | |
var q = Spotify.Link.fromString(n); | |
if (this.serviceIsReady) { | |
if (!(q instanceof Spotify.Link)) return a(new Spotify.Errors.Error([15, 400, "Invalid arguments"])), !1; | |
var q = { | |
method: "ad_uri", | |
response: { | |
type: 0, | |
uri: "rtmp" === p ? "rtmp://saa23rvd7l5c6.cloudfront.net/cfx/st/mp3-ad/" + q.id : "http://d7zatysqm84hv.cloudfront.net/mp3-ad/" + q.id | |
} | |
}, m = q.response.type; | |
0 === m ? ("rtmp" === p ? (n = l.parseRTMPUrl(q.response.uri), | |
q.response.uri = n.file) : n = l.parseHTTPUrl(q.response.uri), q.response.server = n.server, q.response.protocol = n.protocol, r(q.response, 200)) : (r = { | |
method: "ad_uri", | |
response: q | |
}, m === f.ONLY_ON_STORAGE ? r.response = "Song only on storage" : m === f.RATE_LIMIT_REACHED ? r.response = "Rate limit reached" : m === f.TRACK_RESTRICTED && (r.response = "Track restricted"), r.adUri = n, b.error("Spotify.Services.AdUriResolver", ["Error with track", r], "corejs"), a(r)) | |
} else a(new Spotify.Errors.Error([15, 503, "AdUriResolver service not ready!"])) | |
} | |
}; | |
Spotify.Services.PreviewsUriResolver = function () { | |
var b = new Spotify.Parsers.URL; | |
new Spotify.Events; | |
this.list = function (l, f, n, p) { | |
p = {}; | |
l = Spotify.Link.fromString(l).id; | |
"rtmp" === f ? (f = b.parseRTMPUrl("rtmp://soamh0g9lumcr.cloudfront.net/cfx/st/mp3-preview/" + l), p.uri = f.file) : (f = b.parseHTTPUrl("http://d318706lgtcm8e.cloudfront.net/mp3-preview/" + l), p.uri = "http://d318706lgtcm8e.cloudfront.net/mp3-preview/" + l); | |
p.server = f.server; | |
p.protocol = f.protocol; | |
p.lid = ""; | |
p.type = 0; | |
n(p) | |
} | |
}; | |
Spotify.Services.AdChooser = function () { | |
Spotify.EventTarget.call(this); | |
var b = Date.now() / 1E3 + 604800, | |
l = Spotify.DebuggerJS, | |
f = this, | |
n = new Spotify.Parsers.AdChooser, | |
p = new Spotify.Parsers.AdMetadata, | |
r, a, q, m, h = new Spotify.Events, | |
g = [], | |
d = [], | |
c = 0, | |
k = [0, 60], | |
s = 35, | |
x = 0, | |
z = 0, | |
t = 0, | |
v = 600, | |
w = 0, | |
u = [], | |
A = [], | |
y = {}, B = [], | |
E = null, | |
C = null, | |
H = !1, | |
I = !1, | |
G = !1, | |
M = ["has_been_played", "has_been_clicked", "has_been_rendered", "adPlayCount", "campaignPlayCount"], | |
N = {}, K = 0; | |
this.serviceIsReady = !1; | |
var J = function (a) { | |
a = ["Domain: " + a.domain, "Code: " + a.code, | |
"Description: " + JSON.stringify(a.description), "Data: " + JSON.stringify(a.data) | |
]; | |
l.error("Spotify.Services.AdChooser", ["AdChooser Error.. " + a.join(",")], "corejs") | |
}, D = function (a, c) { | |
c && c.stack && (a += "\n Stack: " + JSON.stringify(c.stack)); | |
J(new Spotify.Errors.Error([Spotify.Errors.Codes.ADS_ERROR, Spotify.Errors.Codes.ADS_SERVER_ERROR, a, { | |
extra: c | |
}])) | |
}, F = function () { | |
l.log("Spotify.Services.AdChooser", [].slice.apply(arguments), "corejs") | |
}, L = function (a, c, d) { | |
try { | |
var k = { | |
source: "Ads.Core", | |
context: "Spotify.Services.AdChooser", | |
event: a, | |
event_version: c, | |
source_version: "0.0.1", | |
source_vendor: "ads", | |
data: "undefined" !== typeof d ? JSON.stringify(d) : "" | |
}; | |
q.logClientEvent(k, function () { | |
F("Logged Client Event", k) | |
}) | |
} catch (b) { | |
D("Could not logClientEvent", b) | |
} | |
}, Q = function () { | |
return [{ | |
name: "audio", | |
queue: u | |
}, { | |
name: "banner", | |
queue: A | |
}] | |
}, O = function (a, c) { | |
a.push(c.ad_id); | |
Y(c) | |
}, Y = function (a) { | |
"undefined" === typeof y[a.ad_id] && (y[a.ad_id] = { | |
campaign_id: a.campaign_id, | |
expiry_time: a.campaign_expiry, | |
rules: a.rules, | |
event_history: [], | |
entry: a | |
}); | |
var c = P(a.ad_id); | |
if (c) | |
for (var d = | |
0, k = M.length; d < k; d++) a[M[d]] = c[M[d]]; | |
y[a.ad_id].entry = a | |
}, W = function (c, d) { | |
if ("function" === typeof c && "function" === typeof d) { | |
var k = R(A); | |
if (I) { | |
var b = [1, 1, k.length]; | |
f._bannerAvoid = k; | |
b.push.apply(b, k); | |
F("Retrieving Banner Ads", "ads", b); | |
try { | |
a.rpc("ads", b, function (a) { | |
c(a, "rpc") | |
}, d, this) | |
} catch (g) { | |
T({ | |
serverError: !0, | |
banner: !0 | |
}), D("Exception thrown communicating with ad server", g) | |
} | |
} else Z({ | |
type: "leaderboard", | |
avoidAds: k | |
}, function (a) { | |
c(a, "hermes") | |
}, function (a) { | |
D("Hermes leaderboard call failed", a); | |
d(a) | |
}) | |
} else D("Invalid callbacks specified for _retrieveBannerAdsFromServer") | |
}, | |
R = function (a) { | |
var c = [], | |
d, k, b = {}; | |
d = 0; | |
for (k = B.length; d < k; d++) c.push(B[d]), b[B[d]] = !0; | |
if (a) | |
for (d = 0, k = a.length; d < k; d++) b[a[d]] || (c.push(a[d]), b[a[d]] = !0); | |
ga(function (a) { | |
b[a.ad_id] || X(a) || (c.push(a.ad_id), b[a.ad_id] = !0) | |
}, a === A ? "banner" : "audio"); | |
1020 < c.length && (offset = c.length - 1020, c = c.slice(offset, c.length)); | |
return f._avoidAdsList = c | |
}, Z = function (a, c, d) { | |
a.client_language = m.preferred_locale || "en"; | |
a.product = m.product; | |
a.type = a.type || "leaderboard"; | |
a.version = 1; | |
H && delete a.avoidAds; | |
c = new Spotify.Calls.Hermes({ | |
header: { | |
uri: "hm://ad-hermes-proxy/adqueue", | |
method: "GET" | |
}, | |
payload: [a], | |
payloadSchemas: ["ad-hermes-proxy#AdRequest"], | |
responseSchemas: ["ad-hermes-proxy#AdQueueResponse"], | |
type: "ADQUEUE" | |
}, c, d); | |
F("_sendAdHermesCall", a); | |
return f.send(c) | |
}, aa = function (a, c) { | |
var d = null; | |
T({ | |
banner: !0 | |
}); | |
"rpc" === c ? d = n.parseBannerAdRpcResponse(a) : (F("ad-chooser-proxy responded"), d = n.parseBannerAdHermesResponse(a)); | |
var k = null, | |
b = null, | |
g = null, | |
h = null, | |
s = [], | |
m = [], | |
q = []; | |
if (d.AdQueueEntry && d.AdQueueEntry.length) { | |
k = 0; | |
for (b = d.AdQueueEntry.length; k < b; k++) g = d.AdQueueEntry[k], h = g.ad_id, s.push(h), | |
"tower" === g.banner_type ? (ma(h), q.push(h)) : (O(A, g), m.push(h)); | |
ca(A) | |
} | |
}, ha = function (c, d) { | |
if ("function" === typeof c && "function" === typeof d) { | |
var k = R(u), | |
b = [0, 1, k.length]; | |
b.push.apply(b, k); | |
F("Retrieving Audio Ads", "ads", b); | |
try { | |
a.rpc("ads", b, c, d, this) | |
} catch (g) { | |
T({ | |
serverError: !0 | |
}), D("Exception thrown communicating with ad server", g) | |
} | |
} else D("Invalid callbacks specified for _retrieveAudioAdsFromServer") | |
}, ba = function (a) { | |
var c = null; | |
T(); | |
pa(); | |
c = n.parseServerResponse(a.response); | |
var d = parseInt(c["@attributes"].version, | |
10) | 0, | |
k = null, | |
b = null, | |
k = null; | |
a = []; | |
var g = null, | |
h = null; | |
if (0 === d) D("Missing version attribute from audio queue data structure"); | |
else if (k = n["parseAudioAdsVersion" + d].bind(n), "function" === typeof k) { | |
k = k(c); | |
c = parseInt(k["audio-ad-break"].length, 10); | |
try { | |
s = c, C.setItem("defaultAdBreakLength", s) | |
} catch (m) { | |
D("Unable to set audio ad break length", m) | |
} | |
da(parseInt(k["audio-ad-break"].time_between, 10)); | |
if (typeof ("undefined" !== k.AdQueueEntry && 0 < k.AdQueueEntry.length)) { | |
g = 0; | |
for (h = k.AdQueueEntry.length; g < h; g += 1) b = k.AdQueueEntry[g], | |
f._avoidAdsList && 0 <= f._avoidAdsList.indexOf(b.ad_id) && a.push(b.ad_id), b.file_id ? O(u, b) : _logError("Entry missing file_id", b); | |
ca(u); | |
a.length && F("Avoided ads included in response", a.length, a); | |
f.getNextAd() | |
} else T({ | |
serverError: !0 | |
}), D("No ads received from the ad server") | |
} else D("No parser exists for audio queue version " + d) | |
}, la = function (c, d, k) { | |
if ("function" === typeof d && "function" === typeof k) { | |
c = [c]; | |
try { | |
a.rpc("get_ad", c, d, k, this) | |
} catch (b) { | |
_onAdserverError("Exception thrown communicating with ad metadata server", | |
b) | |
} | |
} else _onAdserverError("Invalid callbacks specified for _retrievedMetadataFromServer") | |
}, pa = function () { | |
qa(function (a) { | |
a = a.response; | |
0 < parseInt(a, 10) ? w = S() - a : _onAdserverError("Invalid server time specified") | |
}, function (a) { | |
J(new Spotify.Errors.Error([Spotify.Errors.Codes.ADS_ERROR, Spotify.Errors.Codes.ADS_SERVER_ERROR, "Exception thrown retrieving server time", { | |
extra: a | |
}])) | |
}) | |
}, qa = function (c, d) { | |
"function" === typeof c && "function" === typeof d ? a.rpc("time", [0], c, d, this) : D("Invalid callbacks for retrieveAdServerTime") | |
}, | |
U = function () { | |
return S() + w | |
}, ca = function (a, c) { | |
try { | |
"undefined" === typeof c ? a.sort(function (a, c) { | |
return y[c].entry.priority - y[a].entry.priority | |
}) : a.sort(c) | |
} catch (d) { | |
D("Unable to prioritize ad queue", d) | |
} | |
}, ma = function (a) { | |
try { | |
1020 <= B.length && (B = B.slice(1 + B.length - 1020, B.length)), B.push(a) | |
} catch (c) { | |
_onAdserverError("Unable to add forbidden ad", c) | |
} | |
}, da = function (a) { | |
try { | |
v = a, C.setItem("timeBetweenAdBreak", v) | |
} catch (c) { | |
_onAdserverError("Unable to set audio ad break time between", c) | |
} | |
}, ia = function (a) { | |
try { | |
x += a, x > 2 * | |
s && (x = 2 * s), C.setItem("audioAdBreakAvailableTime", x) | |
} catch (c) { | |
D("Unable to set audio ad break available time", c) | |
} | |
}, S = function () { | |
return Math.round((new Date).getTime() / 1E3) | |
}, T = function (a) { | |
var c = !1, | |
d = !1, | |
b = S(), | |
g = Math.floor(Math.random() * k[1] + k[0]); | |
"undefined" !== typeof a && (!0 === a.serverError && (c = !0), !0 === a.banner && (d = !0)); | |
d ? t = b + (!1 === c ? 600 : 3600) + g : z = b + (!1 === c ? 600 : 3600) + g | |
}, ja = function () { | |
var a = Object.keys(y), | |
c; | |
try { | |
for (var d = 0, k = a.length; d < k; d++)(c = y[a[d]]) && c.expiry_time <= U() && (c.event_history = [], c.start_time_latest <= | |
U() && delete y[a[d]]); | |
fa(); | |
return !0 | |
} catch (b) { | |
D("Unable to purge expired ad history", b) | |
} | |
}, X = function (a) { | |
var c = null, | |
d = null, | |
d = null, | |
k = [], | |
b = y[a.ad_id], | |
g = U(), | |
h = { | |
max_campaign_repeats_within: function (c, d) { | |
var k = g - c, | |
b = [], | |
h = a.campaign_id, | |
s = null; | |
for (s in y) y.hasOwnProperty(s) && y[s].campaign_id === h && y[s].event_history.map(function (a) { | |
"impression" === a.event && a.timestamp >= k && b.push(a) | |
}); | |
return b.length < d | |
}, | |
max_repeats_within: function (a, c) { | |
var d = g - a, | |
k = []; | |
b.event_history.map(function (a) { | |
"impression" === a.event && a.timestamp >= | |
d && k.push(a) | |
}); | |
return k.length < c | |
}, | |
max_attempts_within: function (a, c) { | |
var d = g - a, | |
k = []; | |
b.event_history.map(function (a) { | |
"attempt" === a.event && a.timestamp >= d && k.push(a) | |
}); | |
return k.length < c | |
}, | |
max_clicks_within: function (a, c) { | |
var d = g - a, | |
k = []; | |
b.event_history.map(function (a) { | |
"click" === a.event && a.timestamp >= d && k.push(a) | |
}); | |
return k.length < c | |
} | |
}; | |
if (0 < b.entry.rules.length) | |
for (c in b.entry.rules) b.entry.rules.hasOwnProperty(c) && (d = b.entry.rules[c], d = h[d.type](parseInt(d.interval, 10), parseInt(d.times, 10)), k.push(d)); | |
return -1 === | |
k.indexOf(!1) | |
}, ea = function (a) { | |
try { | |
var c = [], | |
d = null, | |
k = 0, | |
b = 0, | |
g = null, | |
h = null, | |
s = Q(); | |
F("clear invalid ads in queue"); | |
k = 0; | |
for (b = s.length; k < b; k++) | |
if (a === s[k].queue) { | |
c = []; | |
g = 0; | |
for (h = a.length; g < h; g += 1) d = P(a[g]), d.start_time_latest <= U() ? (F("Removing expired ad", d.ad_id), ma(d.ad_id)) : c.push(d.ad_id); | |
a.splice(0, a.length); | |
for (g = 0; g < c.length; g++) a.push(c[g]); | |
break | |
} | |
} catch (m) { | |
D("Unable to clear invalid ads in ad queue", m) | |
} | |
}, P = function (a) { | |
return y[a] && y[a].entry ? y[a].entry : null | |
}, ka = function () { | |
var a = [], | |
c = null, | |
d = null, | |
k = []; | |
ea(u); | |
for (ca(u); c = u.shift();) | |
if ((d = P(c)) && X(d)) | |
if (d.duration <= x) { | |
if (a.push(d), ia(-1 * d.duration), 0 >= x) break | |
} else k.unshift(c); | |
for (; c = k.shift();) u.unshift(c); | |
3 > u.length && f.maybeRetrieveAudioAds(); | |
return a | |
}, fa = function () { | |
C.setItem("adHistory", JSON.stringify(y)) | |
}, ga = function (a, c) { | |
var d, k; | |
for (d in y) | |
if (y.hasOwnProperty(d) && (k = y[d].entry) && (!c || k.ad_type === c) && a(k) === N) break | |
}, V = function (a, c) { | |
null !== P(a) ? ("undefined" !== typeof c && y[a].event_history.push({ | |
timestamp: U(), | |
event: c | |
}), fa()) : D("Unable to locate ad queue entry") | |
}, | |
sa = function (a) { | |
var c = null, | |
d, k, b; | |
if (y[a]) | |
for (c = {}, d = 0, k = y[a].event_history.length; d < k; d++) b = y[a].event_history[d], c[b.event] = c[b.event] || [], c[b.event].push(b.timestamp); | |
return c | |
}, na = function (a, c) { | |
var d = [], | |
k, b, g; | |
if (y[a]) { | |
k = 0; | |
for (b = y[a].event_history.length; k < b; k++) g = y[a].event_history[k], "*" !== c && g.event !== c && d.push(g); | |
y[a].event_history = d; | |
fa() | |
} | |
}, ta = function (a, c) { | |
var d; | |
d = a.split("spotify:ad:")[1]; | |
d = ra(d); | |
null === d ? D("Unable to locate ad to record ad event: " + a) : oa(d.ad_id, c) | |
}, oa = function (a, c) { | |
var d = | |
P(a), | |
k = !1; | |
if (!d) return D("ad entry not found", a), !1; | |
k = !0; | |
switch (c) { | |
case "click": | |
d.has_been_clicked = !0; | |
V(a, "click"); | |
break; | |
case "attempt": | |
V(a, "attempt"); | |
break; | |
case "render": | |
d.has_been_rendered = !0; | |
V(a, "render"); | |
break; | |
case "impression": | |
d.has_been_played = !0; | |
d.adPlayCount += 1; | |
ga(function (a) { | |
a.campaign_id === d.campaign_id && (a.campaignPlayCount += 1) | |
}); | |
V(a, "impression"); | |
break; | |
case "error": | |
V(a, "error"); | |
break; | |
default: | |
D("Invalid ad event", c), k = !1 | |
} | |
return k | |
}, ua = function (a) { | |
ta(a.params.adUri, a.params.type) | |
}, va = function (a) { | |
var d = { | |
playerId: a.id, | |
active: !1, | |
interval: null, | |
start: function () { | |
d.active || (d.active = !0, d.interval = setInterval(function () { | |
!0 === a.isPlaying && !1 === a.isAd && (c++, 0 === c % 10 && (C.setItem("streamTimeSinceLastAdBreak", c), F("Stream time: ", c), f.getNextAd())) | |
}, 1E3)) | |
}, | |
stop: function () { | |
d.active && (d.active = !1, clearInterval(d.interval)) | |
} | |
}; | |
a.bind(h.PLAYING, d.start); | |
a.bind(h.PAUSED, d.stop); | |
return d | |
}, wa = function (a) { | |
var c = r.getPlayerById(a.params.id); | |
d.push(c); | |
c = va(c); | |
g.push(c); | |
F("player created", a.params.id) | |
}, xa = function (a) { | |
try { | |
K = | |
Date.now(), f.trigger(a.type, a.params), f.trigger(h.AD_BREAK_STARTED), L("getNextAd", "triggered:AD_BREAK_STARTED") | |
} catch (c) { | |
D("Error on triggering interception events.", c) | |
} | |
}, ra = function (a) { | |
var c = null; | |
Q(); | |
F("lookupAdByFileId", a); | |
ga(function (d) { | |
if (!c && d.file_id === a) return c = d, N | |
}); | |
return c | |
}; | |
this._setDebugNoBannerRules = function (a) { | |
H = !! a | |
}; | |
this._setDebugBannerRpc = function (a) { | |
I = !! a | |
}; | |
this._setBannerEnabled = function (a) { | |
G = !! a; | |
!this._bannerInitialized && this.serviceIsReady && this.maybeRetrieveBannerAds() | |
}; | |
this._lookupQueueEntry = | |
function (a, c, d, k) { | |
d && k ? (P(c), la(c, function (c) { | |
c = n.parseServerResponse(c.response); | |
var b = parseInt(c["@attributes"].version, 10) | 0, | |
b = n["parseAdsVersion" + b].bind(n); | |
try { | |
var g = b(c, a === u ? "audio" : "banner"); | |
if (g && g.AdQueueEntry && g.AdQueueEntry[0]) Y(g.AdQueueEntry[0]), d(g.AdQueueEntry[0]); | |
else throw Error("No AdQueueEntry in response"); | |
} catch (h) { | |
k(h) | |
} | |
}, function (a) { | |
k(a) | |
})) : D("_lookupQueueEntry: success and fail callbacks are required") | |
}; | |
this._lookupAndAppendQueueEntry = function (a, c, d, k, g) { | |
k && g ? this._lookupQueueEntry(a, | |
c, function (c) { | |
d && (c.start_time_latest = b); | |
F("Manual Entry", c); | |
c.file_id ? O(a, c) : _logError("No file_id in entry", c); | |
k() | |
}, function (a) { | |
g(a) | |
}) : D("success and fail callbacks are required") | |
}; | |
this._defineQueue = function (a, c, d) { | |
"string" === typeof a && (a = "banner" === a ? A : "audio" === a ? u : null); | |
a === A ? a = A = [] : a === u ? a = u = [] : D("First parameter to _defineQueue must be an internal queue array reference, or the strings 'audio' or 'banner'"); | |
var k = function () { | |
var b = c.shift(); | |
b && (d && na(b, "*"), f._lookupAndAppendQueueEntry(a, b, d, | |
k, function () { | |
D("Could not retrieve ad: " + b); | |
k() | |
})) | |
}; | |
k() | |
}; | |
this.onReady = function (a, c) { | |
this.serviceIsReady ? a.call(c) : this.bind(h.READY, a, c) | |
}; | |
this.recordAdEvent = function (a, c) { | |
ta(a, c) | |
}; | |
this.recordAdEventById = function (a, c) { | |
return !!oa(a, c) | |
}; | |
this.getBannerAd = function () { | |
ja(); | |
l.log("Spotify.Services.AdChooser", ["Fetching banner ad"], "corejs"); | |
var a, c = a = null, | |
c = null; | |
ea(A); | |
for (ca(A); c = A.shift();) | |
if ((c = P(c)) && (H || X(c))) { | |
a = c; | |
break | |
} | |
3 > A.length && f.maybeRetrieveBannerAds(); | |
a && l.log("Spotify.Services.AdChooser", ["Found banner ad", | |
a | |
], "corejs"); | |
return a || null | |
}; | |
this.recordImpression = function (a, c, d) { | |
var k = P(a); | |
if (k) { | |
var b = sa(a), | |
g = 0, | |
h = 0; | |
b && b.render || d ? (d || (oa(a, "impression"), k.tracking_url && "undefined" !== typeof Image && ((new Image).src = k.tracking_url.replace(/\[(timestamp|ord|cachebuster)\]/i, Date.now())), g = b.render[b.render.length - 1], h = Date.now() / 1E3 - g, 1 > h && (h = 1)), void 0 === d && (d = ""), c = { | |
ad_id: a, | |
campaign_id: k.campaign_id, | |
token: k.token, | |
time_started: g, | |
ad_clicked: c || !! b.click && b.click.length && b.click[b.click.length - 1] >= g, | |
client_ad_count: k.adPlayCount, | |
client_campaign_count: k.campaignPlayCount, | |
duration: Math.floor(h), | |
error: d | |
}, F("recordImpression:logEntry", c), q.logBannerShown(c), na(a, "click")) : D(b ? "render event was not found in ad history for: " + a : "ad history not found for: " + a) | |
} else D("attempt to log banner shown on unqueued ad: " + a) | |
}; | |
this.getNextAd = function () { | |
var a = null, | |
k = null; | |
ja(); | |
F("getNextAd", c, v); | |
!f._checkAd && c >= v ? (f._checkAd = !0, E.getLength().then(function (b) { | |
f._checkAd = !1; | |
F("adContext.getLength()", b); | |
if (0 === b && (F("canInjectAd"), ia(s), a = ka(), | |
0 < a.length)) { | |
L("getNextAd", "willInject", a[0].file_id); | |
L("getNextAd", "streamTimeSinceLastAdBreak", c); | |
F("Injecting ad!", a[0]); | |
k = p.toTrackMetadata(a[0]); | |
F("Track Meta", JSON.stringify(k)); | |
k.uri = k.playableURI = Spotify.Link.adLink(k.__pid).toURI(); | |
b = 0; | |
for (var g = d.length; b < g; b++) d[b].ad = a[0]; | |
b = E.createMutator(); | |
b.add([k]); | |
b.apply(); | |
L("getNextAd", "injected", { | |
file_id: a[0].file_id, | |
ad_id: a[0].ad_id | |
}); | |
E.setOwner(k.artists[0].uri) | |
} | |
}, function (a) { | |
D("cannot retrieve context length", a) | |
})) : F(v - c + " seconds of streaming left until ad can play...") | |
}; | |
this.lookup = function (a, c, d) { | |
var k = [], | |
b = d = null; | |
Spotify.Utils.isArray(a) && 1 === a.length ? (b = Spotify.Link.fromString(a[0]), d = ra(b.id), null !== d ? (k.push(p.toTrackMetadata(d)), c(k, 200)) : la(b.id, function (a) { | |
a = n.parseServerResponse(a.response); | |
var d = parseInt(a["@attributes"].version, 10) | 0; | |
a = n["parseAudioAdsVersion" + d].bind(n)(a); | |
k.push(p.toTrackMetadata(a.AdQueueEntry[0])); | |
c(k, 200) | |
}, function (a) { | |
D(a) | |
})) : D("Array (first parameter) does not contain any items!") | |
}; | |
this.lookupAdEntry = function (a, c, d, k) { | |
this._lookupQueueEntry("banner" === | |
a ? A : "audio" === a ? u : null, c, d, k) | |
}; | |
this.maybeRetrieveAudioAds = function () { | |
z <= S() && (F("Retrieving audio ads from server"), ha(ba, function (a) { | |
T({ | |
serverError: !0 | |
}) | |
})) | |
}; | |
this.maybeRetrieveBannerAds = function () { | |
F("Maybe retrieve banner ads?", S() - t, G); | |
G && (I || H || t <= S()) && (this._bannerInitialized = !0, F("Retrieving banner ads from server"), W(function (a, c) { | |
aa(a, c) | |
}, function (a) { | |
T({ | |
serverError: !0, | |
banner: !0 | |
}) | |
})) | |
}; | |
this.maybeRetrieveAds = function () { | |
this.maybeRetrieveBannerAds(); | |
this.maybeRetrieveAudioAds() | |
}; | |
this.init = function (d, | |
k, b, g) { | |
a = d; | |
q = g; | |
r = k; | |
r.bind(h.PLAYER_CREATED, wa, f); | |
r.bind(h.RECORD_AD_EVENT, ua, f); | |
r.onReady(function () { | |
b.onReady(function () { | |
b.getUserInfo(function (a) { | |
m = a; | |
F("SESSION", m); | |
C = new Spotify.Cache.PackageStore({ | |
storageKey: Spotify.Utils.Base64.encode(a.user + "-" + a.catalogue) | |
}); | |
null !== C.getItem("timeBetweenAdBreak") && (v = parseInt(C.getItem("timeBetweenAdBreak"), 10)); | |
null !== C.getItem("defaultAdBreakLength") && (s = parseInt(C.getItem("defaultAdBreakLength"), 10)); | |
null !== C.getItem("streamTimeSinceLastAdBreak") && (c = parseInt(C.getItem("streamTimeSinceLastAdBreak"), | |
10)); | |
null !== C.getItem("adHistory") && (y = JSON.parse(C.getItem("adHistory"))); | |
null !== C.getItem("timeOfLastAdBreak") && (K = parseInt(C.getItem(K), 10)); | |
f.maybeRetrieveAudioAds(); | |
f.maybeRetrieveBannerAds(); | |
f.serviceIsReady = !0; | |
f.trigger(h.READY) | |
}, function (a) { | |
D("Exception thrown gathering user info", a) | |
}) | |
}, this) | |
}, this) | |
}; | |
this.initializeContext = function (a) { | |
E = a.getInterceptList(); | |
a.addEvents({ | |
playIntercepted: xa, | |
playEnd: function (a) { | |
L("trackEnded", "receivedEvent", a.track.uri); - 1 < a.track.uri.indexOf("spotify:ad:") && | |
(L("trackEnded", "call:_onAdEnded"), L("_onAdEnded", "call", c), c = 0, C.setItem("streamTimeSinceLastAdBreak", c), L("_onAdEnded", "persistedStreamTime", c), C.setItem("timeOfLastAdBreak", K), f.trigger(h.AD_BREAK_ENDED), L("_onAdEnded", "triggered:AD_BREAK_ENDED")) | |
} | |
}) | |
}; | |
this.__getAdChooserParser__ = function () { | |
return n | |
}; | |
this.__getAdHistory__ = function () { | |
return y | |
}; | |
this.__getAudioAdQueue__ = function () { | |
return u | |
}; | |
this.__getBannerAdQueue__ = function () { | |
return A | |
}; | |
this.__getMonitors__ = function () { | |
return g | |
}; | |
this.__getPlayers__ = | |
function () { | |
return d | |
}; | |
this.__retrieveBannerAdsFromServer__ = function () { | |
W(aa, function (a) { | |
console.error(a) | |
}) | |
}; | |
this.__retrieveAudioAdsFromServer__ = function () { | |
ha(ba, function (a) { | |
console.error(a) | |
}) | |
}; | |
this.__setAudioAdBreakAvailableTime__ = function (a) { | |
x = a | |
}; | |
this.__adEvaluateRules__ = X; | |
this.__calculateServerTime__ = U; | |
this.__clearAdEventHistory__ = na; | |
this.__clearInvalidAdsInQueue__ = ea; | |
this.__getAdEventHistory__ = sa; | |
this.__getAdQueues__ = Q; | |
this.__getAvoidAdsList__ = R; | |
this.__incrementAudioAdbreakAvailableTime__ = ia; | |
this.__lookupAdByFileId__ = | |
ra; | |
this.__lookupAdById__ = P; | |
this.__resetBannerQueue__ = function () { | |
A = []; | |
W(aa, function (a) { | |
D("Could not retrieve banner ads in resetBannerQueue", a) | |
}) | |
}; | |
this.__retrieveAudioAdsForAdBreak__ = ka; | |
this.__setAudioAdBreakTimeBetween__ = da | |
}; | |
Spotify.Services.Pubsub = function () { | |
var b = this, | |
l = new Spotify.Events, | |
f = {}; | |
this.subscribe = function (l, p, r, a, q, m, h, g) { | |
function d(d) { | |
var s = b.getProtobufMsgParser("pubsub", "Subscription"), | |
m = []; | |
if (d) { | |
for (var l = !1, t = 0; t < d.length; ++t) { | |
var v = s.parseFromStringSync(d[t]); | |
200 === v.status_code && (l = v.uri, m.push(l), "undefined" === typeof f[l] && (f[l] = []), f[l].push({ | |
callback: h, | |
context: g, | |
uri: l, | |
responseSchemas: a, | |
arguments: [] | |
}), l = !0) | |
} | |
if (!l) { | |
c(); | |
return | |
} | |
} | |
q.call(g, m) | |
} | |
function c(a) { | |
m.call(g, a) | |
} | |
"undefined" === typeof l || "undefined" === | |
typeof h || "undefined" === typeof q || "undefined" === typeof m || "undefined" === typeof g ? m.call(g, new Spotify.Errors.Error([0, 16, "Not all argments are provided"])) : (Spotify.Utils.isArray(p) || (p = []), Spotify.Utils.isArray(a) || (a = []), Spotify.Utils.isArray(r) || (r = []), this.serviceIsReady ? (l = new Spotify.Calls.Hermes({ | |
header: { | |
uri: l, | |
method: "SUB" | |
}, | |
payload: p, | |
payloadSchemas: r, | |
responseSchemas: [], | |
type: "pubsub", | |
persistent: !1, | |
bypassCache: !0 | |
}, d, c), this.send(l)) : m.call(g, new Spotify.Errors.Error([13, 503, "Pubsub service not ready!"]))) | |
}; | |
this.onNotify = function (n) { | |
switch (n.type) { | |
case l.HERMES_B64_MESSAGE: | |
var p = Spotify.Hermes.Header.parseFromStringSync(Spotify.Utils.Base64.decode(n.params[2])); | |
if (p) { | |
var r = f[p.uri], | |
a, q = [], | |
m = 0; | |
if (200 === p.status_code) | |
for (var h = 0, g = r.length; h < g; h += 1) { | |
a = r[h]; | |
for (var p = 3, d = n.params.length; p < d; p += 1) a.responseSchemas[m] && q.push(b.getProtobufMsgParser.apply(b, a.responseSchemas[m].split("#")).parseFromStringSync(Spotify.Utils.Base64.decode(n.params[p]))), m++; | |
a.callback.call(a.context, n.params, q) | |
} else | |
for (h = 0, | |
g = r.length; h < g; h += 1) a = r[h], a.errorCallback.call(a.context, p) | |
} | |
} | |
} | |
}; | |
Spotify.Services.Presence = function () { | |
var b = Spotify.DebuggerJS, | |
l = this, | |
f = new Spotify.Events, | |
n = { | |
PLAYLIST_PUBLISHED: { | |
name: "playlist_published", | |
id: 1, | |
decorator: function (a, d) { | |
a.item_uri = d.uri | |
} | |
}, | |
PLAYLIST_TRACK_ADDED: { | |
name: "playlist_track_added", | |
id: 2, | |
decorator: function (a, d) { | |
a.item_uri = d.playlist_uri; | |
a.context_uri = d.track_uri | |
} | |
}, | |
TRACK_FINISHED_PLAYING: { | |
name: "track_finished_playing", | |
id: 3, | |
decorator: function (a, d) { | |
a.item_uri = d.uri; | |
a.context_uri = d.context_uri; | |
a.referrer_uri = d.referrer_uri | |
} | |
}, | |
FAVORITE_APP_ADDED: { | |
name: "favorite_app_added", | |
id: 4, | |
decorator: function (a, d) { | |
a.item_uri = d.app_uri | |
} | |
}, | |
TRACK_STARTED_PLAYING: { | |
name: "track_started_playing", | |
id: 5, | |
decorator: function (a, d) { | |
a.item_uri = d.uri; | |
a.context_uri = d.context_uri; | |
a.referrer_uri = d.referrer_uri | |
} | |
}, | |
URI_SHARED: { | |
name: "uri_shared", | |
id: 6, | |
decorator: function (a, d) { | |
a.item_uri = d.uri; | |
a.message = d.message | |
} | |
}, | |
ARTIST_FOLLOWED: { | |
name: "artist_followed", | |
id: 7, | |
decorator: function (a, d) { | |
a.item_uri = d.uri; | |
a.item_name = d.artist_name; | |
a.item_image = d.artist_cover_uri | |
} | |
}, | |
GENERIC: { | |
name: "generic", | |
id: 11, | |
decorator: function (a, | |
d) { | |
a.type = d.type; | |
a.timestamp = d.timestamp; | |
a.item_uri = d.item_uri; | |
a.item_name = d.item_name; | |
a.item_image = d.item_image; | |
a.context_uri = d.context_uri; | |
a.context_name = d.context_name; | |
a.context_image = d.context_image; | |
a.referrer_uri = d.referrer_uri; | |
a.referrer_name = d.referrer_name; | |
a.referrer_image = d.referrer_image; | |
a.message = d.message; | |
a.device_information = d.device_information | |
} | |
} | |
}, p = function (a, d) { | |
var c; | |
0 < a.length && (c = l.getProtobufMsgParser("presence", "State").parseFromStringSync(Spotify.Utils.Base64.decode(a[3])), l.trigger(f.NOTIFICATION, | |
c)) | |
}, r = function (a) { | |
b.log("Spotify.Services.Presence", ["Broadcast success", a], "corejs") | |
}, a = function (a) { | |
b.error("Spotify.Services.Presence", ["Broadcast error", a], "corejs") | |
}, q = function (a) { | |
b.error("Spotify.Services.Presence", ["Statuses error", a], "corejs") | |
}, m = function (b, d) { | |
l.services.user.getUserInfo(function (c) { | |
c = new Spotify.Calls.Hermes({ | |
header: { | |
uri: "hm://presence/user/" + encodeURIComponent(c.user), | |
method: "SET" | |
}, | |
payload: [b], | |
payloadSchemas: ["presence#State"], | |
responseSchemas: [], | |
type: "Presence", | |
bypassCache: !1, | |
persistent: !1 | |
}, d || r, a); | |
l.send(c) | |
}, a) | |
}, h = function (a, d, c) { | |
c = new Spotify.Calls.Hermes({ | |
header: { | |
uri: "hm://presence/user/", | |
method: "GET" | |
}, | |
payload: [a], | |
payloadSchemas: [], | |
responseSchemas: ["presence#State"], | |
type: "Presence", | |
bypassCache: !1, | |
persistent: !1 | |
}, function (c, b) { | |
var h = [], | |
m = c[0]; | |
if (m && "object" === typeof m) { | |
for (var q in m) | |
if (m.hasOwnProperty(q)) { | |
var f = m[q], | |
l = n[q.toUpperCase()], | |
u = { | |
timestamp: f.timestamp, | |
type: l.id, | |
username: a | |
}; | |
l.decorator(u, f); | |
u.device_information || h.push(u) | |
} | |
d(h, b) | |
} else d([]) | |
}, q); | |
l.send(c) | |
}; | |
this.subscribe = | |
function (a, d, c, k) { | |
this.serviceIsReady ? "undefined" === typeof a ? c.call(k, new Spotify.Errors.Error([0, 16, "Not all argments are provided"])) : Spotify.Utils.isArray(a) ? this.services.pubsub.subscribe("hm://presence/user/", a, [], [], d, c, p, l) : c.call(k, new Spotify.Errors.Error([0, 16, "Users arguments must be an array"])) : c.call(k, new Spotify.Errors.Error([13, 503, "Presence service not ready!"])) | |
}; | |
this.broadcastPlaylistPublished = function (a, d) { | |
var c = { | |
generic: { | |
type: n.PLAYLIST_PUBLISHED.id, | |
item_uri: a, | |
timestamp: (new Date).getTime() / | |
1E3 | |
} | |
}; | |
m(c, d) | |
}; | |
this.broadcastTrackAdded = function (a, d, c) { | |
a = { | |
generic: { | |
type: n.PLAYLIST_TRACK_ADDED.id, | |
context_uri: a, | |
item_uri: d, | |
timestamp: (new Date).getTime() / 1E3 | |
} | |
}; | |
m(a, c) | |
}; | |
this.broadcastTrackStartedPlaying = function (a, d, c, k) { | |
a = { | |
generic: { | |
type: n.TRACK_STARTED_PLAYING.id, | |
item_uri: a, | |
context_uri: d, | |
referrer_uri: c, | |
timestamp: (new Date).getTime() / 1E3 | |
} | |
}; | |
m(a, k) | |
}; | |
this.broadcastTrackFinishedPlaying = function (a, d, c, k) { | |
a = { | |
generic: { | |
type: n.TRACK_FINISHED_PLAYING.id, | |
item_uri: a, | |
context_uri: d, | |
referrer_uri: c, | |
timestamp: (new Date).getTime() / | |
1E3 | |
} | |
}; | |
m(a, k) | |
}; | |
this.broadcastFavoriteAppAdded = function (a, d) { | |
var c = { | |
generic: { | |
type: n.FAVORITE_APP_ADDED.id, | |
item_uri: a, | |
timestamp: (new Date).getTime() / 1E3 | |
} | |
}; | |
m(c, d) | |
}; | |
this.broadcastUriShared = function (a, d, c) { | |
a = { | |
generic: { | |
type: n.URI_SHARED.id, | |
item_uri: a, | |
message: d, | |
timestamp: (new Date).getTime() / 1E3 | |
} | |
}; | |
m(a, c) | |
}; | |
this.broadcastArtistFollowed = function (a, d, c, k) { | |
a = { | |
generic: { | |
type: n.ARTIST_FOLLOWED.id, | |
item_uri: a, | |
item_name: d, | |
item_image: c, | |
timestamp: (new Date).getTime() / 1E3 | |
} | |
}; | |
m(a, k) | |
}; | |
this.getStatuses = function (a, d, c) { | |
h(a, | |
d, c) | |
} | |
}; | |
Spotify.Services.SocialGraph = function () { | |
var b = Spotify.DebuggerJS, | |
l = this, | |
f = new Spotify.Events, | |
n = { | |
subscriptions: { | |
add: f.RELATIONS_SUBSCRIBE, | |
remove: f.RELATIONS_UNSUBSCRIBE | |
}, | |
dismissed: { | |
add: f.RELATIONS_DISMISS, | |
remove: f.RELATIONS_UNDISMISS | |
}, | |
blocked: { | |
add: f.RELATIONS_BLOCK, | |
remove: f.RELATIONS_UNBLOCK | |
} | |
}, p = function (c, d) { | |
d = d || 0; | |
var g = function (b, g) { | |
var h = b[0].users; | |
if (h) { | |
for (var s = 0, m = h.length; s < m; s++) a[c][h[s].username] = s; | |
1E3 === h.length && (d += h.length, p(c, d)) | |
} | |
}, h = function () { | |
b.error("Spotify.Services.SocialGraph", ["We failed to cache the user's " + | |
c, arguments | |
], "corejs") | |
}; | |
l.services.user.getUserInfo(function (a) { | |
m(c, a.user, 1E3, d, g, h) | |
}, h) | |
}, r = { | |
subscribers: {}, | |
subscriptions: {}, | |
dismissed: {}, | |
blocked: {} | |
}, a = { | |
subscribers: {}, | |
subscriptions: {}, | |
dismissed: {}, | |
blocked: {} | |
}, q = function (a, d) { | |
var b = r[a], | |
g = ""; | |
b[d] && b[d].lastResult && (g = b[d].lastResult); | |
return g | |
}, m = function (a, d, b, g, h, m, f) { | |
l.services.user.getUserInfo(function (w) { | |
var u = []; | |
d || (d = w.user); | |
w = "hm://socialgraph/" + a + "/user/" + encodeURIComponent(d); | |
f && (w += "/relevant"); | |
var A = [{ | |
count: b, | |
include_length: !0 | |
}]; | |
f ? A = [] : | |
(u = ["socialgraph#UserListRequest"], A[0].last_result = 0 === g ? "" : q(a, d)); | |
u = new Spotify.Calls.Hermes({ | |
header: { | |
uri: w, | |
method: "GET" | |
}, | |
payload: A, | |
payloadSchemas: u, | |
responseSchemas: ["socialgraph#UserListReply"], | |
type: "socialgraph" | |
}, function (b, g) { | |
var s = b[0].users; | |
if (s) { | |
var m = d, | |
s = s[s.length - 1].username, | |
q = r[a]; | |
q[m] = q[m] || {}; | |
q[m].lastResult = s | |
} | |
h(b, g) | |
}, m); | |
l.send(u) | |
}, m) | |
}, h = function (a, d, b, g) { | |
l.services.user.getUserInfo(function (h) { | |
d || (d = [h.user]); | |
h = new Spotify.Calls.Hermes({ | |
header: { | |
uri: "hm://socialgraph/" + a + "/count/", | |
method: "GET" | |
}, | |
payload: [{ | |
args: d | |
}], | |
payloadSchemas: ["socialgraph#StringListRequest"], | |
responseSchemas: ["socialgraph#CountReply"], | |
type: "socialgraph" | |
}, b, g); | |
l.send(h) | |
}, g) | |
}, g = function (c, d, b, g, h) { | |
h = new Spotify.Calls.Hermes({ | |
header: { | |
uri: "hm://socialgraph/" + c, | |
method: d ? "DELETE" : "POST" | |
}, | |
payload: [{ | |
args: b | |
}], | |
payloadSchemas: ["socialgraph#StringListRequest"], | |
responseSchemas: ["socialgraph#StringListReply"], | |
type: "socialgraph" | |
}, function (h, m) { | |
g(h, m); | |
var q = n[c]; | |
l.trigger(d ? q.remove : q.add, { | |
users: b | |
}); | |
for (var q = 0, f = b.length; q < | |
f; q++) d ? delete a[c][b[q]] : a[c][b[q]] = q | |
}, h); | |
l.send(h) | |
}, d = function (a, d, b, g, h) { | |
a = "hm://socialgraph/" + a + "/user/" + encodeURIComponent(d) + "/exists"; | |
b = new Spotify.Calls.Hermes({ | |
header: { | |
uri: a, | |
method: "GET" | |
}, | |
payload: [{ | |
args: b | |
}], | |
payloadSchemas: ["socialgraph#StringListRequest"], | |
responseSchemas: ["socialgraph#StringListReply"], | |
type: "socialgraph" | |
}, g, h); | |
l.send(b) | |
}; | |
this.setup = function () {}; | |
this.getSubscribers = function (a, d, b, g, h) { | |
m("subscribers", a, d, b, g, h) | |
}; | |
this.getRelevantSubscribers = function (a, d, b, g, h) { | |
m("subscribers", | |
a, d, b, g, h, !0) | |
}; | |
this.getSubscriptions = function (a, d, b, g, h) { | |
m("subscriptions", a, d, b, g, h) | |
}; | |
this.getRelevantSubscriptions = function (a, d, b, g, h) { | |
m("subscriptions", a, d, b, g, h, !0) | |
}; | |
this.getDismissed = function (a, d, b, g, h) { | |
m("dismissed", a, d, b, g, h) | |
}; | |
this.getBlocked = function (a, d, b, g, h) { | |
m("blocked", a, d, b, g, h) | |
}; | |
this.getSubscribersCount = function (a, d, b) { | |
h("subscribers", a, d, b) | |
}; | |
this.getSubscriptionsCount = function (a, d, b) { | |
h("subscriptions", a, d, b) | |
}; | |
this.subscribeTo = function (a, d, b) { | |
g("subscriptions", !1, a, d, b) | |
}; | |
this.unsubscribeFrom = | |
function (a, d, b) { | |
g("subscriptions", !0, a, d, b) | |
}; | |
this.dismiss = function (a, d, b) { | |
g("dismissed", !1, a, d, b) | |
}; | |
this.undismiss = function (a, d, b) { | |
g("dismissed", !0, a, d, b) | |
}; | |
this.block = function (a, d, b) { | |
g("blocked", !1, a, d, b) | |
}; | |
this.unblock = function (a, d, b) { | |
g("blocked", !0, a, d, b) | |
}; | |
this.isSubscribed = function (c) { | |
for (var d = [], b = 0, g = c.length; b < g; b++) d.push(c[b] in a.subscriptions); | |
return d | |
}; | |
this.hasSubscribers = function (a, b, g, h) { | |
d("subscribers", a, b, g, h) | |
}; | |
this.hasSubscriptions = function (a, b, g, h) { | |
d("subscriptions", a, b, g, h) | |
}; | |
this.hasDismissed = | |
function (a, b, g, h) { | |
d("dismissed", a, b, g, h) | |
}; | |
this.hasBlocked = function (a, b, g, h) { | |
d("blocked", a, b, g, h) | |
}; | |
this.hasHidden = function (a, b, g, h) { | |
d("hidden", a, b, g, h) | |
}; | |
this.preloadCurrentUserRelations = function () { | |
for (var c in a) p(c) | |
} | |
}; | |
Spotify.Services.MergedProfile = function () { | |
var b = this, | |
l = function (f, l, p, r) { | |
b.serviceIsReady ? (f = new Spotify.Calls.Hermes({ | |
header: { | |
uri: "hm://mergedprofile/mergedprofile/" + f + "/" + encodeURIComponent(l), | |
method: "GET" | |
}, | |
payload: [], | |
payloadSchemas: [], | |
responseSchemas: ["mergedprofile#MergedProfileReply"], | |
type: "mergedprofile" | |
}, function (a) { | |
for (var b, m = 0, h = a.length; m < h; m += 1) b = a[m], b.artist = "undefined" !== typeof b.artistid ? "spotify:artist:" + b.artistid : null, b.user = "undefined" !== typeof b.username ? Spotify.Link.profileLink(b.username).toURI() : | |
null, delete b.artistid, delete b.username; | |
p(a, 200) | |
}, r), b.send(f)) : r(new Spotify.Errors.Error([13, 503, "MergedProfile service not ready!"])) | |
}; | |
this.forUser = function (b, n, p) { | |
l("user", b, n, p) | |
}; | |
this.forArtist = function (b, n, p) { | |
l("artist", b, n, p) | |
} | |
}; | |
Spotify.Services.Inbox = function () { | |
this.getInbox = function (b, l, f) { | |
this.serviceIsReady ? this.services.playlist.list({ | |
uri: Spotify.Link.inboxLink(b.username).toURI(), | |
offset: b.offset, | |
total: b.total | |
}, l, f) : f(new Spotify.Errors.Error([13, 503, "Inbox service not ready!"])) | |
}; | |
this.addToInbox = function (b, l, f) { | |
if (this.serviceIsReady) | |
if ("undefined" === typeof b.items) f(new Spotify.Errors.Error([13, 503, "You need to provide at least one item to send"])); | |
else if (b.recipient) | |
if (b.sender) { | |
for (var n = 0, p = b.items.length; n < p; n += | |
1) b.items[n].addedBy = b.sender || ""; | |
n = Spotify.Link.inboxLink(b.recipient).toURI(); | |
this.services.playlist.addToPlaylistWithAttributes(n, b.items, l, f) | |
} else f(new Spotify.Errors.Error([13, 503, "You need to provide a sender"])); | |
else f(new Spotify.Errors.Error([13, 503, "You need to provide a recipient"])); | |
else f(new Spotify.Errors.Error([13, 503, "Inbox service not ready!"])) | |
}; | |
this.deleteFromInbox = function (b, l, f) { | |
if ("undefined" === typeof b.username) f(new Spotify.Errors.Error([13, 503, "You need to provide a username"])); | |
else { | |
var n = b.offset || 0, | |
p = b.total || 1; | |
b = Spotify.Link.inboxLink(b.username).toURI(); | |
this.services.playlist.removeFromPlaylist(b, n, p, l, f) | |
} | |
}; | |
this.markAsRead = function (b, l, f) { | |
if ("undefined" === typeof b.username) f(new Spotify.Errors.Error([13, 503, "You need to provide a username"])); | |
else if ("undefined" === typeof b.itemIndex) f(new Spotify.Errors.Error([13, 503, "You need to provide an index for the item you want to mark as read"])); | |
else { | |
var n = Spotify.Link.inboxLink(b.username).toURI(); | |
this.services.playlist.updateItemAttributes(n, | |
b.itemIndex, { | |
seen: 1 | |
}, l, f) | |
} | |
} | |
}; | |
Spotify.InstanceFactory = function (b) { | |
this.createInstance = b.createInstance; | |
this.waitReady = b.waitReady || function (b, f) { | |
if (b.onReady) b.onReady(f.bind(void 0, b)); | |
else f(b) | |
}; | |
this.destroyInstance = b.destroyInstance || function () {} | |
}; | |
Spotify.InstanceFactory.fromService = function (b, l) { | |
return new Spotify.InstanceFactory({ | |
createInstance: function (f) { | |
var n = new b; | |
n.init && n.init.apply(n, (l || []).concat(f || [])); | |
return n | |
}, | |
waitReady: function (b, l) { | |
if (b.onReady) b.onReady(l.bind(void 0, b)); | |
else l(b) | |
}, | |
destroyInstance: function (b) { | |
b.shutdown && b.shutdown() | |
} | |
}) | |
}; | |
Spotify.InstanceFactory.fromFactoryMethod = function (b, l, f) { | |
return new Spotify.InstanceFactory({ | |
createInstance: b, | |
destroyInstance: l, | |
waitReady: f | |
}) | |
}; | |
Spotify.InstanceCache = function (b) { | |
var l = {}, f = b; | |
this.reset = function (b, p) { | |
b && (f = b); | |
if (!p) { | |
for (var r in l) { | |
var a = l[r]; | |
a.factory.destroyInstance(a.instance) | |
} | |
l = {} | |
} | |
}; | |
this.createAwaitReady = function (b, f, r, a) { | |
a = f.createInstance(b); | |
b = l[b] = { | |
instance: a, | |
factory: f | |
}; | |
b.factory.waitReady(b.instance, r.bind(void 0, b.instance)) | |
}; | |
this.get = function (b) { | |
var p = l[b]; | |
if (p) return p.instance; | |
if (f) return p = f.createInstance(b), l[b] = { | |
instance: p, | |
factory: f | |
}, p; | |
throw "No such key and no default factory specified"; | |
}; | |
this.getAwaitReady = | |
function (b, p, r) { | |
var a = l[b]; | |
if (a) a.factory.waitReady(a.instance, p.bind(void 0, a.instance)); | |
else if (f) this.createAwaitReady(b, f, p, r); | |
else if (r) r("No such key and no default factory specified"); | |
else throw "No such key and no default factory specified"; | |
} | |
}; | |
Spotify.DependencyObject = function () { | |
Spotify.EventTarget.call(this); | |
var b = this, | |
l = new Spotify.Events; | |
this.serviceIsReady = !1; | |
this.onReady = function (b, n) { | |
this.serviceIsReady ? b.call(n) : this.bind(l.READY, b, n) | |
}; | |
this.markReady = function () { | |
b.serviceIsReady = !0; | |
b.trigger(l.READY) | |
}; | |
this.dependsOn = function (f, l) { | |
if (!f || 0 == f.length) return b.markReady(); | |
var p = 0, | |
r = function () { | |
p++; | |
p == f.length && (l ? 0 == l.length ? (l(), b.markReady()) : l(function () { | |
b.markReady() | |
}) : b.markReady()) | |
}; | |
f.forEach(function (a) { | |
if ("function" == typeof a) a(r); | |
else a.onReady(r) | |
}) | |
} | |
}; | |
Spotify.Services.Collection2Cache = function () { | |
Spotify.DependencyObject.call(this); | |
new Spotify.Events; | |
var b, l, f; | |
this.init = function (n, p, r) { | |
f = r; | |
if (!r) throw "Username must be defined"; | |
l = new Spotify.Protobuf.Schema([], null, null, null); | |
l.id = "collection2cache"; | |
l.type = "proto"; | |
l.setData(n); | |
l.encode(); | |
b = p; | |
this.markReady() | |
}; | |
this.getTracks = function (n, p, r) { | |
(new Spotify.Hermes.ProtobufRequest({ | |
uri: "hm://collection-cache/tracks/" + encodeURIComponent(f) + "?union=" + !! n, | |
method: "GET" | |
}, [], [], [l.msg("CollectionTracks")])).send(b, function (a) { | |
p(a[0]) | |
}, | |
function (a) { | |
404 == a.code ? p({}) : r(a) | |
}, !1, !1, "collection2cache") | |
}; | |
this.getAlbums = function (n, p, r) { | |
(new Spotify.Hermes.ProtobufRequest({ | |
uri: "hm://collection-cache/albums/" + encodeURIComponent(f) + "?union=" + !! n, | |
method: "GET" | |
}, [], [], [l.msg("CollectionAlbums")])).send(b, function (a) { | |
p(a[0].album || []) | |
}, function (a) { | |
404 == a.code ? p({}) : r(a) | |
}, !1, !1, "collection2cache") | |
}; | |
this.getArtists = function (n, p, r) { | |
(new Spotify.Hermes.ProtobufRequest({ | |
uri: "hm://collection-cache/artists/" + encodeURIComponent(f) + "?union=" + !! n, | |
method: "GET" | |
}, [], [], [l.msg("CollectionArtists")])).send(b, function (a) { | |
p(a[0].artist || []) | |
}, function (a) { | |
404 == a.code ? p({}) : r(a) | |
}, !1, !1, "collection2cache") | |
} | |
}; | |
Spotify.Services.CollectionStorageImplementation.Backend = function () { | |
Spotify.DependencyObject.call(this); | |
var b = this, | |
l = new Spotify.Events, | |
f, n, p, r, a = Spotify.DebuggerJS, | |
q = function (b) { | |
return b.map(function (d) { | |
"TRACK" == d.type ? d.uri = Spotify.Link.fromByteString(Spotify.Link.Type.TRACK, d.identifier).toURI() : "ALBUM" == d.type ? d.uri = Spotify.Link.fromByteString(Spotify.Link.Type.ALBUM, d.identifier).toURI() : (a.error("Spotify.Services.CollectionStorageImplementation.Backend", ["Not supported type: ", d.type], "corejs"), | |
d = void 0); | |
return d | |
}).filter(function (a) { | |
return a | |
}) | |
}, m = function (a, d) { | |
if (0 < a.length) { | |
var c = p.msg("CollectionItems").parseFromStringSync(Spotify.Utils.Base64.decode(a[3])); | |
c.item && (c = q(c.item), b.trigger(l.CHANGED, { | |
items: c | |
})) | |
} | |
}, h = function (a) { | |
f.subscribe("hm://collection/collection/" + encodeURIComponent(r), [], [], [], a, function () {}, m, b) | |
}; | |
this.init = function (a, d, c, b) { | |
f = a; | |
r = b; | |
if (!b) throw "Username must be defined"; | |
p = new Spotify.Protobuf.Schema([], null, null, null); | |
p.id = "collection2"; | |
p.type = "proto"; | |
p.setData(d); | |
p.encode(); | |
n = c; | |
n.bind(l.CONNECTED, function (a) { | |
h(function () {}) | |
}, this); | |
this.dependsOn([a], h) | |
}; | |
this.get = function (a, d) { | |
(new Spotify.Hermes.ProtobufRequest({ | |
uri: "hm://collection/collection/" + encodeURIComponent(r) + "?sort=descending", | |
method: "GET", | |
content_type: "vnd.spotify/collection-items" | |
}, [], [], [p.msg("CollectionItems")])).send(n, function (c) { | |
c = c[0].item || []; | |
c = q(c); | |
a(c) | |
}, d, !1, !1, "collection") | |
}; | |
this.change = function (a, d, c) { | |
a.forEach(function (a) { | |
a.type = "TRACK"; | |
a.identifier = Spotify.Link.fromString(a.uri).idToByteString() | |
}); | |
(new Spotify.Hermes.ProtobufRequest({ | |
uri: "hm://collection/collection/" + encodeURIComponent(r), | |
method: "PATCH", | |
content_type: "vnd.spotify/collection-items" | |
}, [{ | |
item: a | |
}], [p.msg("CollectionItems")], [])).send(n, function (a) { | |
d(a) | |
}, c, !0, !1, "collection") | |
} | |
}; | |
Spotify.Services.CollectionStorageImplementation.Mock = function () { | |
Spotify.DependencyObject.call(this); | |
var b = this, | |
l = {}; | |
[{ | |
uri: "spotify:track:7pYInkuxFsh625wA82Uf8W", | |
name: "Away From The Sun - 17 Days Acoustic Version" | |
}, { | |
uri: "spotify:track:7i6x7pxU92f9Lazp4Y1dbZ", | |
name: "Warsaw Or The First Breath You Take After You Give Up" | |
}, { | |
uri: "spotify:track:7e5B4aloHuniGxtxSV83g0", | |
name: "Vem" | |
}, { | |
uri: "spotify:track:7bTiNxyu4FlHwBes8eG8sE", | |
name: "Jag tror p\u00e5 dig" | |
}, { | |
uri: "spotify:track:7KonowmHhdoW6gn0ZNvgOn", | |
name: "Spinning In Daffodils" | |
}, { | |
uri: "spotify:track:7E680BITbk5khHVIE0DrIV", | |
name: "Sober - Bimbo Jones Radio Edit" | |
}, { | |
uri: "spotify:track:7980zwuuUReCHIjSVcItPy", | |
name: "Big Pimpin' - Live" | |
}, { | |
uri: "spotify:track:6pi0NzmQkouL2R5EDIV7YH", | |
name: "Bonito" | |
}, { | |
uri: "spotify:track:6kmewkv1yTxyUD963qiEbQ", | |
name: "Linger" | |
}, { | |
uri: "spotify:track:6ZqvAJ2SBUqscWtqjZr0EA", | |
name: "Criminal Intent" | |
}, { | |
uri: "spotify:track:6T1Xc4BNJO7bkgiEyH7vCm", | |
name: "For an Angel - Radio Mix '09" | |
}, { | |
uri: "spotify:track:65lMlV6eqqFQ9Eskj0f9Me", | |
name: "Caligulove" | |
}, { | |
uri: "spotify:track:62duQFVb51gug9ajR6Qdiz", | |
name: "Gangsta Rap Made Me Do It" | |
}, { | |
uri: "spotify:track:5qXxGJlfiAh0aKCRYHL2V0", | |
name: "Up Where We Belong" | |
}, { | |
uri: "spotify:track:5hIjE1vig7y1rb2LRLgRfp", | |
name: "The Crying Light" | |
}, { | |
uri: "spotify:track:5TTiXxO7SPIYHulRCSyYzR", | |
name: "Harder Now That It's Over" | |
}, { | |
uri: "spotify:track:5NaV3m1KmpygBsCUkaVIK0", | |
name: "How To Save A Life (made famous by The Fray)" | |
}, { | |
uri: "spotify:track:4ni0Vt7dQev9fS1O97a7jw", | |
name: "Wonderful Tonight" | |
}, { | |
uri: "spotify:track:4ibFD6UnSsExXMV0Ptycsq", | |
name: "Smells Like Teen Spirit (made famous by Nirvana)" | |
}, { | |
uri: "spotify:track:4dhAjyKOEc5YPIk6tTY3Q8", | |
name: "Interlude With Ludes" | |
}, { | |
uri: "spotify:track:4VBmMhjrJ1Bu7ebnl0Gbmj", | |
name: "The Lovers Are Losing" | |
}, { | |
uri: "spotify:track:48s2DVrUoICD8B37y6H06g", | |
name: "Show Me What You Got - Album Version (Edited)" | |
}, { | |
uri: "spotify:track:3f5BGbxhywHIV7gVrqtVqI", | |
name: "Sail Away (made famous by Enya)" | |
}, { | |
uri: "spotify:track:3NT4deyIUzzqL63rNHgYNM", | |
name: "Foolish - Mainstream Edit" | |
}, { | |
uri: "spotify:track:3I8dxmjvDQNyiWXMcScsCv", | |
name: "Secret Smile - Album Edit" | |
}, { | |
uri: "spotify:track:3DjPNEk6Yd5xhXs6RGNKNs", | |
name: "No Diggity" | |
}, { | |
uri: "spotify:track:2udjspYLl1PvGV7gERAuxg", | |
name: "That Ole Devil Called Love - Single Version" | |
}, { | |
uri: "spotify:track:2l5k6k0XYdjtZslUibsPeA", | |
name: "Show Me Heaven" | |
}, { | |
uri: "spotify:track:2aRnHc1Q8ydUOSEYo68ztS", | |
name: "Hot N Cold (Manhattan Clique Remix Radio Edit)" | |
}, { | |
uri: "spotify:track:2DemiHqRL0bAa0e3JEnaW8", | |
name: "Congratulations - Revisited" | |
}, { | |
uri: "spotify:track:18HLZDh4NyDHcAn7gwZrb2", | |
name: "Black Girls (feat. Travis Barker)" | |
}, { | |
uri: "spotify:track:15Cl88mjOLGp3uM2Opm5iT", | |
name: "On The Wings Of Love" | |
}, { | |
uri: "spotify:track:0oHKGL4obpVZlFxZb5AeKW", | |
name: "Include Me Out" | |
}, { | |
uri: "spotify:track:7oSwuLOwlCMqTQi30ME0zR", | |
name: "Unchained Melody" | |
}, { | |
uri: "spotify:track:7nNTYx6f54SUPX2GaTUcf7", | |
name: "5th Avenue Bar" | |
}].forEach(function (b) { | |
l[b.uri] = { | |
uri: b.uri, | |
starred: !1, | |
unheard: !0, | |
added_at: Math.floor(Date.now() / 1E3), | |
starred_at: Math.floor(Date.now() / 1E3) | |
} | |
}); | |
var f = new Spotify.Events; | |
this.init = function (b) { | |
this.markReady() | |
}; | |
this.get = function (b, f) { | |
var r = [], | |
a; | |
for (a in l) r.push(l[a]); | |
b(r) | |
}; | |
this.change = function (n, p, r) { | |
n.forEach(function (a) { | |
a.removed ? | |
delete l[a.uri] : (void 0 === a.added_at && (a.added_at = Math.floor(Date.now() / 1E3)), l[a.uri] = a) | |
}); | |
p(); | |
b.trigger(f.CHANGED, { | |
items: n | |
}) | |
} | |
}; | |
Spotify.Services.CollectionStorageImplementation.CacheAttributes = function () { | |
Spotify.DependencyObject.call(this); | |
var b = this, | |
l = {}, f = new Spotify.Events, | |
n = function (a) { | |
var m = [], | |
h = !1; | |
a.forEach(function (a) { | |
var d = l[a.uri]; | |
m.push(d); | |
a.removed ? (delete l[a.uri], d && (h = !0)) : (l[a.uri] = a, d && a.unheard == d.unheard || (h = !0)) | |
}); | |
h && b.trigger(f.CHANGED, { | |
items: a, | |
oldItems: m | |
}) | |
}, p, r, a = function (a) { | |
n(a.params.items) | |
}; | |
this.init = function (b, m) { | |
p = b; | |
r = m; | |
p.bind(f.CHANGED, a); | |
this.dependsOn([p], function (a) { | |
p.get(function (b) { | |
b.forEach(function (a) { | |
l[a.uri] = | |
a | |
}); | |
a() | |
}, function () { | |
a() | |
}) | |
}) | |
}; | |
this.get = function (a, b) { | |
var h = [], | |
g; | |
for (g in l) h.push(JSON.parse(JSON.stringify(l[g]))); | |
a(h) | |
}; | |
this.change = function (a, b, h) { | |
r.getServerTime(function (g) { | |
a = a.map(function (a) { | |
var c = l[a.uri]; | |
c ? (void 0 === a.unheard && (a.unheard = c.unheard), a.added_at = c.added_at) : (void 0 === a.unheard && (a.unheard = !0), void 0 === a.removed && (a.removed = !1), a.added_at = g); | |
return a | |
}); | |
n(a); | |
p.change(a, function () {}, h); | |
b() | |
}, h) | |
} | |
}; | |
Spotify.Services.CollectionStorage = function (b, l) { | |
Spotify.DependencyObject.call(this); | |
var f = b || {}; | |
f.implementation = f.implementation || "backend"; | |
var n = {}, p; | |
this.config = function (b) { | |
f = b; | |
p.reset(n[f.implementation]) | |
}; | |
this.init = function (b, a, q) { | |
n.mock = new Spotify.InstanceFactory({ | |
createInstance: function (a, b, g) { | |
a = new Spotify.Services.CollectionStorageImplementation.Mock; | |
a.init(); | |
b = new Spotify.Services.CollectionStorageImplementation.CacheAttributes; | |
b.init(a, q); | |
return b | |
} | |
}); | |
n.backend = new Spotify.InstanceFactory({ | |
createInstance: function (m, | |
h, g) { | |
h = new Spotify.Services.CollectionStorageImplementation.Backend; | |
h.init(a, l, b, m); | |
m = new Spotify.Services.CollectionStorageImplementation.CacheAttributes; | |
m.init(h, q); | |
return m | |
} | |
}); | |
p = new Spotify.InstanceCache; | |
this.config(f); | |
this.markReady() | |
}; | |
this.getInstance = function (b, a, q) { | |
p.getAwaitReady(b, function (b) { | |
a(b) | |
}, q) | |
} | |
}; | |
Spotify.Services.CollectionViewImplementation.CollectionViewForUser = function () { | |
Spotify.DependencyObject.call(this); | |
var b = this, | |
l; | |
this.init = function (a, b, k, s, q, f, x, t) { | |
c = s; | |
l = x; | |
d = new Spotify.Services.Collection2Cache; | |
d.init(q, f, x); | |
m = a; | |
h = k; | |
this.dependsOn([d, a, b, k], function (a) { | |
t && k.bind(n.CHANGE, w); | |
b.getInstance(x, function (c) { | |
g = c; | |
g.bind(n.CHANGED, B); | |
N(t, a, function () { | |
p.error("Spotify.Services.CollectionViewImplementation.CollectionViewForUser", ["Load data failed"], "corejs") | |
}) | |
}) | |
}) | |
}; | |
this.artistsSnapshot = function (a, | |
c, d, b) { | |
H("artists", a, c, d, b) | |
}; | |
this.albumsSnapshot = function (a, c, d, b) { | |
H("albums", a, c, d, b) | |
}; | |
this.tracksSnapshot = function (a, c, d, b) { | |
H("tracks", a, c, d, b) | |
}; | |
var f = function (a, c, d, b) { | |
var k = []; | |
c.forEach(function (c) { | |
k.push( !! r[a][c]) | |
}); | |
d(k) | |
}; | |
this.tracksContains = function (a, c, d) { | |
f("tracks", a, c, d) | |
}; | |
this.albumsContains = function (a, c, d) { | |
f("albums", a, c, d) | |
}; | |
this.tracksAdd = function (a, d, b) { | |
s(a, function (k) { | |
var h = [], | |
s = []; | |
a.forEach(function (a) { | |
h.push({ | |
uri: a, | |
sources: { | |
collection: !0, | |
playlists: {} | |
} | |
}); | |
s.push({ | |
uri: a | |
}) | |
}); | |
c.getServerTime(function (a) { | |
t(h, | |
k, a); | |
g.change(s, d, b) | |
}, b) | |
}, b) | |
}; | |
this.albumsAdd = function (a, c, d) { | |
m.lookup(a, function (a) { | |
var k = {}; | |
a.forEach(function (a) { | |
a && a.disc.forEach(function (a) { | |
a.track.forEach(function (a) { | |
a = Spotify.Link.trackLink(a.id).toURI(); | |
k[a] = a | |
}) | |
}) | |
}); | |
k = Object.keys(k); | |
b.tracksAdd(k, c, d) | |
}, d) | |
}; | |
this.tracksRemove = function (a, c, d) { | |
s(a, function (b) { | |
var k = [], | |
s = [], | |
m = []; | |
a.forEach(function (a) { | |
var c = r.tracks[a]; | |
if (c) { | |
m.push({ | |
uri: a, | |
sources: c.sources | |
}); | |
c.sources.collection && s.push({ | |
uri: a, | |
removed: !0 | |
}); | |
for (var d in c.sources.playlists) k.push(h.removeFromPlaylistByUri.bind(h, | |
d, [a])) | |
} | |
}); | |
v(m, b); | |
0 < s.length && k.push(g.change.bind(g, s)); | |
E(k, c, d) | |
}, d) | |
}; | |
this.albumsRemove = function (a, c, d) { | |
m.lookup(a, function (a) { | |
var k = {}; | |
a.forEach(function (a) { | |
a && a.disc.forEach(function (a) { | |
a.track.forEach(function (a) { | |
a = Spotify.Link.trackLink(a.id).toURI(); | |
r.tracks[a] && (k[a] = a) | |
}) | |
}) | |
}); | |
k = Object.keys(k); | |
b.tracksRemove(k, c, d) | |
}, d) | |
}; | |
this.tracksClear = function (a, c) { | |
var d = r; | |
r = { | |
tracks: {}, | |
albums: {}, | |
artists: {} | |
}; | |
q = {}; | |
g.get(function (k) { | |
k = k.map(function (a) { | |
return { | |
uri: a.uri, | |
removed: !0 | |
} | |
}); | |
0 == k.length ? a() : g.change(k, | |
a, c); | |
k = { | |
source: "all", | |
removed: { | |
artists: { | |
uris: Object.keys(d.artists), | |
indices: Object.keys(d.artists).map(function (a, c) { | |
return c | |
}) | |
}, | |
albums: { | |
uris: Object.keys(d.albums), | |
indices: Object.keys(d.albums).map(function (a, c) { | |
return c | |
}) | |
}, | |
tracks: { | |
uris: Object.keys(d.tracks), | |
indices: Object.keys(d.tracks).map(function (a, c) { | |
return c | |
}) | |
} | |
} | |
}; | |
b.trigger(n.CHANGED, k) | |
}, c) | |
}; | |
this.getSources = function (a, c, d) { | |
var b = Spotify.Link.fromString(a); | |
b.type === Spotify.Link.Type.ALBUM ? m.lookup(a, function (a) { | |
var d = { | |
collection: !1, | |
playlists: {} | |
}; | |
a.disc.forEach(function (a) { | |
a.track.forEach(function (a) { | |
a = Spotify.Link.trackLink(a.id).toURI(); | |
if (a = r.tracks[a]) | |
if (a.sources.collection && (d.collection = !0), a.sources.playlists) | |
for (var c in a.sources.playlists) d.playlists[c] = (d.playlists[c] || 0) + a.sources.playlists[c] | |
}) | |
}); | |
c(d) | |
}, d) : b.type === Spotify.Link.Type.TRACK ? (a = r.tracks[a]) ? c(a.sources) : c({ | |
collection: !1, | |
playlists: {} | |
}) : d("Unsupported type: " + b.type) | |
}; | |
var n = new Spotify.Events, | |
p = Spotify.DebuggerJS, | |
r = { | |
tracks: {}, | |
albums: {}, | |
artists: {} | |
}, a = {}, q = {}, m, h, g, | |
d, c, k = { | |
tracks: function (a) { | |
var c = [], | |
d; | |
for (d in a) c.push(a[d]); | |
return c.sort(function (a, c) { | |
var d = (c.added_at || 0) - (a.added_at || 0); | |
return 0 === d ? a.uri > c.uri ? 1 : -1 : 0 < d ? 1 : -1 | |
}).map(function (a) { | |
return a.uri | |
}) | |
}, | |
albums: function (a) { | |
var c = [], | |
d; | |
for (d in a) c.push(a[d]); | |
return c.sort(function (a, c) { | |
var d = (a.artistNames[0] || a.name).toLowerCase(), | |
b = (c.artistNames[0] || c.name).toLowerCase(); | |
if (d === b) { | |
if (a.uri > c.uri) return 1; | |
if (a.uri < c.uri) return -1 | |
} else { | |
if (d > b) return 1; | |
if (d < b) return -1 | |
} | |
return 0 | |
}).map(function (a) { | |
return a.uri | |
}) | |
}, | |
artists: function (a) { | |
var c = [], | |
d; | |
for (d in a) c.push(a[d]); | |
return c.sort(function (a, c) { | |
var d = a.name.toLowerCase(), | |
b = c.name.toLowerCase(); | |
if (d === b) { | |
if (a.uri > c.uri) return 1; | |
if (a.uri < c.uri) return -1 | |
} else { | |
if (d > b) return 1; | |
if (d < b) return -1 | |
} | |
return 0 | |
}).map(function (a) { | |
return a.uri | |
}) | |
} | |
}, s = function (a, c, d) { | |
m.lookup(a, function (a) { | |
var d = {}; | |
a.forEach(function (a) { | |
d[Spotify.Link.trackLink(a.id).toURI()] = a | |
}); | |
c(d) | |
}, d) | |
}, x = function (a, c) { | |
return c.map(function (c) { | |
return a.indexOf(c) | |
}) | |
}, z = function (a, c) { | |
var d = { | |
uris: [], | |
indices: [] | |
}; | |
x(C(a), c).map(function (a, d) { | |
return { | |
index: a, | |
uri: c[d] | |
} | |
}).sort(function (a, c) { | |
return a.index - c.index | |
}).map(function (a, c) { | |
d.uris.push(a.uri); | |
d.indices.push(a.index - c) | |
}); | |
return d | |
}, t = function (a, c, d) { | |
q = {}; | |
var k = []; | |
a.forEach(function (a) { | |
var b = r.tracks[a.uri]; | |
if (b) { | |
!0 === a.sources.collection && (b.sources.collection = !0); | |
for (var g in a.sources.playlists) b.sources.playlists[g] = (b.sources.playlists[g] || 0) + a.sources.playlists[g] | |
} else r.tracks[a.uri] = b = { | |
uri: a.uri, | |
added_at: d, | |
name: c[a.uri].name, | |
sources: { | |
collection: a.sources.collection, | |
playlists: a.sources.playlists || {} | |
} | |
}, k.push(b.uri) | |
}); | |
if (0 < k.length) { | |
var g = [], | |
h = []; | |
k.forEach(function (a) { | |
a = c[a]; | |
var d = Spotify.Link.albumLink(a.album.id).toURI(), | |
b = r.albums[d]; | |
b || (b = { | |
uri: d, | |
name: a.album.name, | |
artistNames: a.album.artist ? a.album.artist.map(function (a) { | |
return a.name | |
}) : [], | |
count: 0 | |
}, r.albums[d] = b, g.push(d)); | |
b.count++; | |
d = Spotify.Link.artistLink(a.artist[0].id).toURI(); | |
b = r.artists[d]; | |
b || (b = { | |
uri: d, | |
name: a.artist[0].name, | |
count: 0 | |
}, r.artists[d] = b, h.push(d)); | |
b.count++ | |
}); | |
a = { | |
source: "all", | |
inserted: { | |
artists: z("artists", | |
h), | |
albums: z("albums", g), | |
tracks: z("tracks", k) | |
} | |
}; | |
b.trigger(n.CHANGED, a) | |
} | |
}, v = function (a, c) { | |
var d = q; | |
q = {}; | |
var k = []; | |
a.forEach(function (a) { | |
var c = r.tracks[a.uri]; | |
if (c) { | |
!0 === a.sources.collection && (c.sources.collection = !1); | |
for (var d in a.sources.playlists) c.sources.playlists[d] -= a.sources.playlists[d] || 0, 0 === c.sources.playlists[d] && delete c.sources.playlists[d]; | |
c.sources.collection || 0 !== Object.keys(c.sources.playlists).length || (delete r.tracks[c.uri], k.push(c.uri)) | |
} | |
}); | |
if (0 < k.length) { | |
var g = [], | |
h = []; | |
k.forEach(function (a) { | |
a = | |
c[a]; | |
var d = Spotify.Link.albumLink(a.album.id).toURI(), | |
b = r.albums[d]; | |
b && (b.count--, 0 >= b.count && (delete r.albums[d], g.push(d))); | |
a = Spotify.Link.artistLink(a.artist[0].id).toURI(); | |
if (d = r.artists[a]) d.count--, 0 >= d.count && (delete r.artists[a], h.push(a)) | |
}); | |
d = { | |
source: "all", | |
removed: { | |
artists: { | |
uris: h, | |
indices: x(d.artists || [], h) | |
}, | |
albums: { | |
uris: g, | |
indices: x(d.albums || [], g) | |
}, | |
tracks: { | |
uris: k, | |
indices: x(d.tracks || [], k) | |
} | |
} | |
}; | |
b.trigger(n.CHANGED, d) | |
} | |
}, w = function (c) { | |
if (!(0 < c.params.uri.indexOf(":starred"))) { | |
var d = a[c.params.uri] || | |
c.params.localRevision; | |
a[c.params.uri] = c.params.revision; | |
h.getChangesBetweenRevisionAndHead(c.params.uri, d, function (d) { | |
a[c.params.uri] = d.revision; | |
d.operations && (Spotify.Link.fromString(c.params.uri).type == Spotify.Link.Type.ROOTLIST ? A(c.params.uri, d.operations) : y(c.params.uri, d.operations)) | |
}, function () { | |
p.error("Spotify.Services.CollectionViewImplementation.CollectionViewForUser", ["Playlist changed: Can't get changes"], "corejs") | |
}) | |
} | |
}, u = function (a) { | |
var c = [], | |
d; | |
for (d in r.tracks) - 1 != Object.keys(r.tracks[d].sources.playlists).indexOf(a) && | |
c.push(d); | |
return c | |
}, A = function (a, c) { | |
c.forEach(function (a) { | |
"REM" == a.kind && a.rem.items.forEach(function (a) { | |
var c = a.uri; | |
a = u(c); | |
var d = a.map(function (a) { | |
var d = { | |
uri: a, | |
sources: { | |
playlists: {} | |
} | |
}; | |
d.sources.playlists[c] = r.tracks[a].sources.playlists[c]; | |
return d | |
}); | |
s(a, function (a) { | |
v(d, a) | |
}, function () { | |
p.error("Spotify.Services.CollectionViewImplementation.CollectionViewForUser", ["Playlist changed: Can't load metadata"], "corejs") | |
}) | |
}) | |
}) | |
}, y = function (a, d) { | |
d.forEach(function (d) { | |
var b = []; | |
if ("ADD" == d.kind) { | |
var k = []; | |
d.add.items.forEach(function (c) { | |
if (Spotify.Link.fromString(c.uri).type == | |
Spotify.Link.Type.TRACK) { | |
var d = { | |
uri: c.uri, | |
sources: { | |
collection: !1, | |
playlists: {} | |
} | |
}; | |
d.sources.playlists[a] = 1; | |
k.push(d); | |
b.push(c.uri) | |
} | |
}); | |
s(b, function (a) { | |
c.getServerTime(function (c) { | |
t(k, a, c) | |
}, function () { | |
p.error("Spotify.Services.CollectionViewImplementation.CollectionViewForUser", ["Playlist changed: Can't load server time"], "corejs") | |
}) | |
}, function () { | |
p.error("Spotify.Services.CollectionViewImplementation.CollectionViewForUser", ["Playlist changed: Can't load metadata"], "corejs") | |
}) | |
} else if ("REM" == d.kind) { | |
var g = []; | |
d.rem.items.forEach(function (c) { | |
if (Spotify.Link.fromString(c.uri).type == Spotify.Link.Type.TRACK) { | |
var d = { | |
uri: c.uri, | |
sources: { | |
playlists: {} | |
} | |
}; | |
d.sources.playlists[a] = 1; | |
g.push(d); | |
b.push(c.uri) | |
} | |
}); | |
s(b, function (a) { | |
v(g, a) | |
}, function () { | |
p.error("Spotify.Services.CollectionViewImplementation.CollectionViewForUser", ["Playlist changed: Can't load metadata"], "corejs") | |
}) | |
} | |
}) | |
}, B = function (a) { | |
var d = [], | |
b = []; | |
a.params.items.forEach(function (c, k) { | |
"TRACK" == c.type && (c.removed ? b.push(c.uri) : void 0 === a.params.oldItems[k] && | |
d.push(c.uri)) | |
}); | |
if (0 < d.length) { | |
var k = d.map(function (a) { | |
return { | |
uri: a, | |
sources: { | |
collection: !0, | |
playlists: {} | |
} | |
} | |
}); | |
s(d, function (a) { | |
c.getServerTime(function (c) { | |
t(k, a, c) | |
}, function () { | |
p.error("Spotify.Services.CollectionViewImplementation.CollectionViewForUser", ["Playlist changed: Can't load server time"], "corejs") | |
}) | |
}, function () { | |
p.error("Spotify.Services.CollectionViewImplementation.CollectionViewForUser", ["Collection changed: Can't load metadata"], "corejs") | |
}) | |
} | |
if (0 < b.length) { | |
var g = b.map(function (a) { | |
return { | |
uri: a, | |
sources: { | |
collection: !0, | |
playlists: {} | |
} | |
} | |
}); | |
s(b, function (a) { | |
v(g, a) | |
}, function () { | |
p.error("Spotify.Services.CollectionViewImplementation.CollectionViewForUser", ["Collection changed: Can't load metadata"], "corejs") | |
}) | |
} | |
}, E = function (a, c, d) { | |
var b = 0, | |
k = Array(a.length); | |
a.forEach(function (g, h) { | |
g(function (d) { | |
k[h] = d; | |
b++; | |
b == a.length && c(k) | |
}, function () { | |
d() | |
}) | |
}) | |
}, C = function (a) { | |
q[a] || (q[a] = k[a](r[a])); | |
return q[a] | |
}, H = function (a, c, d, b, k) { | |
a = C(a); | |
c = 0 <= c && 0 <= d ? a.slice(c, c + d) : 0 <= c ? a.slice(c) : a; | |
b(c, a.length) | |
}, I = function (a, c, b) { | |
d.getTracks(a, | |
function (a) { | |
var d = {}, b = {}, k = {}; | |
a.playlist && a.playlist.forEach(function (a, c) { | |
if (a.identifier) { | |
var d; | |
if (a.type && "PLAYLIST" != a.type) | |
if ("COLLECTION_TRACK_LIST" == a.type) d = Spotify.Link.starredLink(l).toURI(); | |
else return; | |
else d = Spotify.Link.fromByteString(Spotify.Link.Type.PLAYLIST, a.identifier, { | |
username: l | |
}).toURI(); | |
b[d] = Spotify.Utils.formatPlaylistRevision(Spotify.Utils.str2hex(a.revision)); | |
k[c] = d | |
} | |
}); | |
a.track && a.track.forEach(function (a) { | |
var c = {}; | |
c.uri = Spotify.Link.fromByteString(Spotify.Link.Type.TRACK, | |
a.identifier).toURI(); | |
c.added_at = a.added_at; | |
c.name = a.name; | |
c.sources = { | |
collection: void 0 === a.in_collection ? !0 : a.in_collection, | |
playlists: {} | |
}; | |
a.playlists && a.playlists.forEach(function (a) { | |
void 0 !== a.playlist_index && (c.sources.playlists[k[a.playlist_index]] = a.count || 1) | |
}); | |
d[c.uri] = c | |
}); | |
c(d, b) | |
}, b) | |
}, G = function (a, c, b) { | |
d.getAlbums(a, function (a) { | |
var d = {}; | |
a.forEach(function (a) { | |
var c = {}; | |
c.uri = Spotify.Link.fromByteString(Spotify.Link.Type.ALBUM, a.identifier).toURI(); | |
c.count = a.track_count; | |
c.artistNames = a.artist_names; | |
c.name = a.name; | |
d[c.uri] = c | |
}); | |
c(d) | |
}, b) | |
}, M = function (a, c, b) { | |
d.getArtists(a, function (a) { | |
var d = {}; | |
a.forEach(function (a) { | |
var c = {}; | |
c.uri = Spotify.Link.fromByteString(Spotify.Link.Type.ARTIST, a.identifier).toURI(); | |
c.count = a.track_count; | |
c.name = a.name; | |
d[c.uri] = c | |
}); | |
c(d) | |
}, b) | |
}, N = function (c, d, b) { | |
E([ | |
function (d) { | |
I(c, function (c, b) { | |
r.tracks = c; | |
a = b; | |
d() | |
}, b) | |
}, | |
function (a) { | |
G(c, function (c) { | |
r.albums = c; | |
a() | |
}, b) | |
}, | |
function (a) { | |
M(c, function (c) { | |
r.artists = c; | |
a() | |
}, b) | |
} | |
], d, b) | |
} | |
}; | |
Spotify.Services.CollectionView = function (b) { | |
Spotify.DependencyObject.call(this); | |
var l = b || {}; | |
void 0 === l.union && (l.union = !0); | |
var f, n, p, r = {}, a; | |
this.config = function (b) { | |
l = b; | |
a.reset(r.collection) | |
}; | |
this.init = function (b, m, h, g, d, c, k) { | |
f = b; | |
n = m; | |
p = h; | |
r.collection = Spotify.InstanceFactory.fromFactoryMethod(function (a, g, f) { | |
g = new Spotify.Services.CollectionViewImplementation.CollectionViewForUser; | |
g.init(m, b, h, d, k, c, a, l.union); | |
return g | |
}); | |
a = new Spotify.InstanceCache; | |
this.config(l); | |
this.dependsOn([f, n, p, g], function (c) { | |
g.getUserInfo(function (d) { | |
a.getAwaitReady(d.user, | |
function () {}, function () { | |
throw arguments; | |
}); | |
c() | |
}) | |
}) | |
}; | |
this.getInstance = function (b, m, h) { | |
a.getAwaitReady(b, function (a) { | |
m(a) | |
}, h) | |
} | |
}; | |
Spotify.Services.CollectionUnplayed = function (b) { | |
Spotify.DependencyObject.call(this); | |
var l = this, | |
f, n, p = {}, r, a, q, m, h = new Spotify.Events, | |
g = function () { | |
var a = m.getState().track.uri, | |
c; | |
c = a ? Spotify.Link.fromString(a).type == Spotify.Link.Type.TRACK ? !0 : !1 : !1; | |
if (c) l.onReady(function () { | |
f.get(function (c) { | |
for (var d, b = 0, g = c.length; b < g; b++) | |
if (c[b].uri === a) { | |
d = c[b]; | |
break | |
} | |
d ? !1 !== d.unheard && f.change([{ | |
uri: a, | |
unheard: !1 | |
}], function () {}) : p[a] = !0 | |
}) | |
}) | |
}, d = function (c) { | |
f.get(function (d) { | |
a = d; | |
q = {}; | |
for (d = 0; d < a.length; d++) q[a[d].uri] = | |
a[d].unheard; | |
c() | |
}) | |
}, c = function (a) { | |
var c = a.params.oldItems, | |
b = [], | |
g = !1, | |
m = { | |
inserted: [], | |
removed: [] | |
}; | |
a.params.items.forEach(function (a, d) { | |
var k = !c[d], | |
h = k || a.unheard != c[d].unheard; | |
if (a.unheard && p[a.uri]) a.unheard = !1, delete p[a.uri], b.push({ | |
uri: a.uri, | |
unheard: !1 | |
}); | |
else if (k || h) g = !0, k ? m.inserted.push(a.uri) : h && m[a.unheard ? "inserted" : "removed"].push(a.uri) | |
}); | |
0 < b.length && f.change(b, function () {}); | |
g && d(function () { | |
l.trigger(h.CHANGED, { | |
insertedItems: m.inserted, | |
removedItems: m.removed | |
}) | |
}) | |
}; | |
this.init = function (a, b) { | |
n = | |
b; | |
this.dependsOn([a, n], function (b) { | |
n.getUserInfo(function (g) { | |
r = g.user; | |
a.getInstance(r, function (a) { | |
f = a; | |
a.bind(h.CHANGED, c); | |
d(b) | |
}) | |
}) | |
}) | |
}; | |
this.initializeContext = function (a) { | |
m = a; | |
m.addEvent("play", g) | |
}; | |
this.isUnplayed = function (a, c, d, b) { | |
if (a != r) throw Error("Only supported for current user"); | |
var g = []; | |
c.forEach(function (a) { | |
g.push(q[a]) | |
}); | |
d(g) | |
} | |
}; | |
Spotify.Services.Facebook = function () { | |
function b(b) { | |
return function (f) { | |
f = n.parseCredential(f); | |
b(f) | |
} | |
} | |
var l = this, | |
f = Spotify.DebuggerJS, | |
n = new Spotify.Parsers.Facebook; | |
this.enable = function (f, r, a) { | |
this.services.user.getUserInfo(function (q) { | |
q = new Spotify.Calls.Hermes({ | |
header: { | |
uri: "hm://facebook/user/" + encodeURIComponent(q.user), | |
method: "CREATE" | |
}, | |
payload: [n.makeCredential(null, f)], | |
payloadSchemas: ["facebook#EnableRequest"], | |
responseSchemas: ["facebook#EnableReply"], | |
type: "facebook", | |
bypassCache: !0, | |
persistent: !1 | |
}, | |
b(r), a); | |
l._sendRetry(q) | |
}, a) | |
}; | |
this.disable = function (b, f, a, q) { | |
this.services.user.getUserInfo(function (m) { | |
m = new Spotify.Calls.Hermes({ | |
header: { | |
uri: "hm://facebook/user/" + encodeURIComponent(m.user), | |
method: "DELETE" | |
}, | |
payload: [n.makeCredential(b, f)], | |
payloadSchemas: ["facebook#DisableRequest"], | |
responseSchemas: [], | |
type: "facebook", | |
bypassCache: !0, | |
persistent: !1 | |
}, a, q); | |
l._sendRetry(m) | |
}, q) | |
}; | |
this.getState = function (f, r, a, q) { | |
this.services.user.getUserInfo(function (m) { | |
m = new Spotify.Calls.Hermes({ | |
header: { | |
uri: "hm://facebook/user/" + | |
encodeURIComponent(m.user), | |
method: "GET" | |
}, | |
payload: [n.makeCredential(f, r)], | |
payloadSchemas: ["facebook#UserState"], | |
responseSchemas: ["facebook#UserState"], | |
type: "facebook", | |
bypassCache: !0, | |
persistent: !1 | |
}, b(a), q); | |
l._sendRetry(m) | |
}, q) | |
}; | |
this.updateState = function (f, r, a, q) { | |
this.services.user.getUserInfo(function (m) { | |
m = new Spotify.Calls.Hermes({ | |
header: { | |
uri: "hm://facebook/user/" + encodeURIComponent(m.user), | |
method: "GET" | |
}, | |
payload: [n.makeCredential(f, r)], | |
payloadSchemas: ["facebook#UpdateUserStateRequest"], | |
responseSchemas: ["facebook#UserState"], | |
type: "facebook", | |
bypassCache: !0, | |
persistent: !1 | |
}, b(a), q); | |
l._sendRetry(m) | |
}, q) | |
}; | |
this.getFriends = function (b, f) { | |
this.services.user.getUserInfo(function (a) { | |
a = new Spotify.Calls.Hermes({ | |
header: { | |
uri: "hm://facebook/user/" + encodeURIComponent(a.user) + "/friends", | |
method: "GET" | |
}, | |
payload: [{ | |
fields: { | |
app_user: !0, | |
display_name: !0, | |
picture_large: !0 | |
} | |
}], | |
payloadSchemas: ["facebook#FriendsRequest"], | |
responseSchemas: ["facebook#FriendsReply"], | |
type: "facebook" | |
}, function (a) { | |
a = n.parseFriendList(a); | |
b(a) | |
}, f); | |
l._sendRetry(a) | |
}, f) | |
}; | |
this.getConfig = | |
function (b, f) { | |
var a = new Spotify.Calls.Hermes({ | |
header: { | |
uri: "hm://facebook/config", | |
method: "GET" | |
}, | |
responseSchemas: ["facebook#ConfigReply"], | |
type: "facebook" | |
}, function (a) { | |
a = n.parseConfig(a); | |
b(a) | |
}, f); | |
l._sendRetry(a) | |
}; | |
this.share = function (b, f, a, q, m, h) { | |
this.services.user.getUserInfo(function (g) { | |
var d = n.makeCredential(b, f); | |
d.uri = a; | |
q && (d.message_text = q); | |
g = new Spotify.Calls.Hermes({ | |
header: { | |
uri: "hm://facebook/user/" + encodeURIComponent(g.user) + "/share", | |
method: "POST" | |
}, | |
payload: [d], | |
payloadSchemas: ["facebook#ShareRequest"], | |
responseSchemas: ["facebook#ShareReply"], | |
type: "facebook", | |
bypassCache: !0 | |
}, function (a) { | |
a = n.parsePostId(a); | |
m(a) | |
}, h); | |
l._sendRetry(g) | |
}, h) | |
}; | |
this.getPermissions = function (b, f, a, q) { | |
this.services.user.getUserInfo(function (m) { | |
var h = n.makeCredential(b, f); | |
h.options = { | |
cache_is_king: !1 | |
}; | |
m = new Spotify.Calls.Hermes({ | |
header: { | |
uri: "hm://facebook/user/" + encodeURIComponent(m.user) + "/permissions", | |
method: "GET" | |
}, | |
payload: [h], | |
payloadSchemas: ["facebook#PermissionsRequest"], | |
responseSchemas: ["facebook#PermissionsReply"], | |
type: "facebook", | |
bypassCache: !0 | |
}, function (b) { | |
b = n.parsePermissions(b); | |
a(b) | |
}, q); | |
l._sendRetry(m) | |
}, q) | |
}; | |
this._sendRetry = function (b, n) { | |
var a = 0, | |
q = b.error; | |
n = n || 3; | |
var m = function () { | |
l.send(b) | |
}; | |
b.error = function (h) { | |
var g; | |
a + 1 < n && (statusCode = h.code || 0, Spotify.Hermes.Request.isServerError(statusCode) && (g = Math.pow(a, 2) + Math.random(), a++)); | |
void 0 !== g ? (f.log("Spotify.Services.Facebook", ["Scheduling retry to request", b.header.method, b.header.uri, "in", g, "second(s) due to error", h], "corejs"), setTimeout(m, 1E3 * g)) : q(h) | |
}; | |
m() | |
}; | |
this.inspectCredential = | |
function (b, f, a, q) { | |
this.services.user.getUserInfo(function (m) { | |
m = new Spotify.Calls.Hermes({ | |
header: { | |
uri: "hm://facebook/user/" + encodeURIComponent(m.user) + "/inspect", | |
method: "POST" | |
}, | |
payload: [n.makeCredential(b, f)], | |
payloadSchemas: ["facebook#InspectCredentialRequest"], | |
responseSchemas: ["facebook#InspectCredentialReply"], | |
type: "facebook", | |
bypassCache: !0 | |
}, function (b) { | |
b = n.parseCredentialInspection(b); | |
a(b) | |
}, q); | |
l._sendRetry(m) | |
}, q) | |
} | |
}; | |
Spotify.Services.FacebookPublish = function (b) { | |
var l = this, | |
f = new Spotify.Events, | |
n, p = [], | |
r = function (a, b, d, c, k, s) { | |
l.serviceIsReady ? (n.addToBucket({ | |
uri: a, | |
startTime: b, | |
eventName: d, | |
event: c, | |
callback: k, | |
errback: s | |
}), n.isStarted() || n.start()) : s(new Spotify.Errors.Error([13, 503, "Facebook-publish service not ready!"])) | |
}, a = function (a) { | |
l.services.user.getUserInfo(function (b) { | |
for (var d = [], c = [], k = [], s = 0; s < a.length; s++) { | |
var m = a[s], | |
q = { | |
id: { | |
uri: m.uri, | |
startTime: m.startTime | |
} | |
}; | |
q[m.eventName] = m.event; | |
d.push(q); | |
c.push("facebook-publish#Event"); | |
k.push("facebook-publish#EventReply") | |
} | |
b = new Spotify.Calls.Hermes({ | |
header: { | |
uri: "hm://facebook-publish/user/" + encodeURIComponent(b.user) + "/music/listen", | |
method: "POST" | |
}, | |
payload: d, | |
payloadSchemas: c, | |
responseSchemas: k, | |
type: "facebook-publish", | |
bypassCache: !1, | |
persistent: !1 | |
}, function () { | |
for (var c = 0; c < a.length; c++) a[c].callback.apply(this, arguments) | |
}, function () { | |
for (var c = 0; c < a.length; c++) a[c].errback.apply(this, arguments) | |
}); | |
l.send(b) | |
}, function () {}) | |
}, q = function (a) { | |
p.push(a.params) | |
}, m = function (b) { | |
a(p); | |
p = [] | |
}; | |
this.scrobbleStart = | |
function (a, b, d, c, k, s, m) { | |
c = { | |
length: k, | |
end_time: c | |
}; | |
b && (c.context_uri = b); | |
r(a, d, "start", c, s, m) | |
}; | |
this.scrobbleSeek = function (a, b, d, c, k) { | |
r(a, b, "seek", { | |
end_time: d | |
}, c, k) | |
}; | |
this.scrobblePause = function (a, b, d, c, k, s) { | |
r(a, b, "pause", { | |
seconds_played: d, | |
end_time: c | |
}, k, s) | |
}; | |
this.scrobbleResume = function (a, b, d, c, k, s) { | |
r(a, b, "resume", { | |
seconds_played: d, | |
end_time: c | |
}, k, s) | |
}; | |
this.scrobbleEnd = function (a, b, d, c, k, s) { | |
r(a, b, "end", { | |
seconds_played: d, | |
end_time: c | |
}, k, s) | |
}; | |
this.setup = function () { | |
n = new Spotify.RateLimiter(1E3, 25); | |
n.bind(f.RATE_LIMIT_CALL, | |
q); | |
n.bind(f.RATE_LIMIT_AFTER_INTERVAL, m) | |
} | |
}; | |
Spotify.Services.SPIRC = function () { | |
var b = this, | |
l = !1, | |
f, n = Spotify.DebuggerJS, | |
p = function () { | |
var a, c = {}, d = !1; | |
return { | |
addDevice: function (a) { | |
c.hasOwnProperty(a) || (c[a] = !0) | |
}, | |
getConnectedDevice: function () { | |
return a | |
}, | |
getDeviceList: function () { | |
var a = [], | |
d; | |
for (d in c) a.push(d); | |
return a | |
}, | |
isConnecting: function () { | |
return d | |
}, | |
setConnectedDevice: function (c) { | |
a = c | |
}, | |
startConnect: function () { | |
d = !0; | |
c = {} | |
}, | |
stopConnect: function () { | |
d = !1 | |
} | |
} | |
}(), | |
r, a = new Spotify.Events, | |
q, m = {}, h = document.cookie.substring(0, document.cookie.indexOf("=")), | |
g, d = | |
null, | |
c = function () { | |
r.is_active = !1; | |
f = "Running"; | |
n.log("Spotify.Services.SPIRC", ["State -> Running"], "corejs") | |
}, k = function () { | |
var a = (new Date).getTime(); | |
r.is_active = !0; | |
r.became_active_at = a; | |
f = "Playing"; | |
n.log("Spotify.Services.SPIRC", ["State -> Playing"], "corejs") | |
}, s = function (d, s) { | |
if (0 !== d.length) { | |
var q = s[0], | |
x = { | |
message: q | |
}, t = q.recipient && -1 == q.recipient.indexOf(h), | |
l = q.state_update_id && 0 !== q.state_update_id && g > q.state_update_id; | |
if (q.ident !== h && !t && !l) switch (n.log("Spotify.Services.SPIRC", ["Handling message", | |
q.type | |
], "corejs"), q.type) { | |
case "kMessageTypeHello": | |
"kMessageTypeHello" === q.type && (x = (new Date).getTime(), m.hasOwnProperty(q.ident) && 500 > x - m[q.ident] ? n.log("Spotify.Services.SPIRC", ["Ignoring hello from", q.ident], "corejs") : (m[q.ident] = x, p.isConnecting() && p.addDevice(q.ident), w("kMessageTypeHello", [q.ident]))); | |
break; | |
case "kMessageTypeNotify": | |
"kMessageTypeNotify" === q.type && (t = q.device_state.became_active_at, "Playing" === f ? t && t > r.became_active_at && c() : "Running" === f && "undefined" !== typeof q.state && (n.log("Spotify.Services.SPIRC", ["Sending", q.type, "to bridge"], "corejs"), b.trigger(a.NOTIFICATION, x))); | |
break; | |
case "kMessageTypeLoad": | |
"kMessageTypeLoad" === q.type && ("Playing" !== f && k(), "undefined" !== typeof q.state && (n.log("Spotify.Services.SPIRC", ["Sending", q.type, "to bridge"], "corejs"), b.trigger(a.NOTIFICATION, x))); | |
break; | |
default: | |
n.log("Spotify.Services.SPIRC", ["Sending", q.type, "to bridge"], "corejs"), b.trigger(a.NOTIFICATION, x) | |
} | |
} | |
}, x = function (a) { | |
d = a; | |
l = !0; | |
r = { | |
is_active: !1, | |
can_play: !0, | |
volume: null, | |
name: d.user + "'s Web Player", | |
became_active_at: 0 | |
}; | |
g = 0; | |
f = "Subbing"; | |
n.log("Spotify.Services.SPIRC", ["State -> Subscribing"], "corejs"); | |
b.services.pubsub.subscribe("hm://remote/user/" + encodeURIComponent(d.user) + "/r" + h + "/", [], [], ["spirc#Frame"], t, v, s, b) | |
}, z = function (a) { | |
n.error("Spotify.Services.SPIRC", ["User load failed", a], "corejs") | |
}, t = function () { | |
c(); | |
w("kMessageTypeHello") | |
}, v = function (a) { | |
n.error("Spotify.Services.SPIRC", ["SPIRC subscription failed", a], "corejs") | |
}, w = function (a, c) { | |
c = c || []; | |
n.log("Spotify.Services.SPIRC", ["Sending", a, "to", 0 < c.length ? c.join() : | |
"everyone." | |
], "corejs"); | |
var k = { | |
version: 1, | |
ident: h, | |
protocol_version: "2.0.0", | |
seq_nr: (new Date).getTime(), | |
type: a, | |
device_state: r, | |
recipient: c, | |
state: q, | |
state_update_id: g | |
}, k = new Spotify.Calls.Hermes({ | |
header: { | |
uri: "hm://remote/user/" + encodeURIComponent(d.user), | |
method: "SEND" | |
}, | |
payload: [k], | |
payloadSchemas: ["spirc#Frame"], | |
responseSchemas: ["spirc#Frame"], | |
type: "spirc", | |
bypassCache: !1, | |
persistent: !1 | |
}, u, A); | |
n.log("Spotify.Services.SPIRC", ["Sending Hermes request", k], "corejs"); | |
b.send(k) | |
}, u = function (a) { | |
n.log("Spotify.Services.SPIRC", ["Broadcast success", a], "corejs") | |
}, A = function (a) { | |
n.error("Spotify.Services.SPIRC", ["Broadcast error", a], "corejs") | |
}, y = function (a) { | |
"Running" !== f ? n.error("Spotify.Services.SPIRC", ["Send command error. Not in running state."], "corejs") : w(a) | |
}; | |
this.getServiceState = function () { | |
return f | |
}; | |
this.onTokenLost = function () { | |
l && b.trigger(a.TOKEN_LOST) | |
}; | |
this.notify = function () { | |
n.log("Spotify.Services.SPIRC", ["Notify being called"], "corejs"); | |
g = (new Date).getTime(); | |
w("kMessageTypeNotify") | |
}; | |
this.sendNext = function () { | |
y("kMessageTypeNext") | |
}; | |
this.sendPause = function () { | |
y("kMessageTypePause") | |
}; | |
this.sendPlay = function () { | |
y("kMessageTypePlay") | |
}; | |
this.sendPrev = function () { | |
y("kMessageTypePrev") | |
}; | |
this.sendSeek = function () { | |
"undefined" === typeof q ? n.error("Spotify.Services.SPIRC", ["No frame state set"], "corejs") : y("kMessageTypeSeek") | |
}; | |
this.setDeviceVolume = function (a) { | |
r.volume = a | |
}; | |
this.setFrameState = function (a) { | |
q = a; | |
"Running" === f && "kPlayStatusPlay" === q.status && k() | |
}; | |
this.subscribe = function () { | |
var a = b.services.user; | |
a.onReady(function () { | |
a.getUserInfo(x, z) | |
}) | |
} | |
}; | |
Spotify.Core = function (b, l) { | |
Spotify.EventTarget.call(this); | |
Spotify.DebuggerJS.register("console", new Spotify.DebuggerJS.Loggers.Console, new Spotify.DebuggerJS.Parsers.Default); | |
Spotify.Hermes.Cache = new Spotify.HermesCache; | |
var f = this, | |
n = Spotify.DebuggerJS, | |
p, r, a = !1, | |
q = "undefined" !== typeof swfobject ? Spotify.PlayerTypes.FLASH_RTMPS : Spotify.PlayerTypes.HTML5_HTTP, | |
m = { | |
playerType: q, | |
SWFContainerId: l.SWFContainerId || "", | |
SWFPlayerContainerId: l.SWFPlayerContainerId || "", | |
SWFPlayerUrl: l.SWFPlayerUrl || "player.swf", | |
SWFUrl: l.SWFUrl || | |
"bridge.swf", | |
SWFMinVersion: l.SWFMinVersion || "10.2.0", | |
logging: l.logging || 0, | |
length: l.length || 0, | |
valid: l.valid || 0, | |
cdn: l.cdn || "", | |
protoSchemasLocation: l.protoSchemasLocation || "proto/", | |
protoSchemasLocationRandomizer: l.protoSchemasLocationRandomizer || "", | |
services: l.services || {} | |
}; | |
this.id = ""; | |
var h = b || Spotify.GatewayTypes.FLASH, | |
g, d = new Spotify.Events, | |
c, k = {}, s = new Spotify.Managers.ProtobufSchemasManager; | |
this.services = {}; | |
this.previewUriResolver = this.adUriResolver = this.storageResolver = this._bridge = this.facebookPublish = | |
this.mergedProfile = this.adChooser = this.presence = this.hermes = this.collectionUnplayed = this.collectionView = this.collectionStorage = this.facebook = this.socialGraph = this.social = this.toplist = this.user = this.search = this.popcount = this.appstore = this.playlist = this.metadata = this.pubsub = this.spirc = this.time = this.suggest = this.player = null; | |
this.logging = {}; | |
this.isReady = !1; | |
this.onConnect = function (a) {}; | |
this.onDisconnect = function (a) {}; | |
this.onTokenLost = function (a) {}; | |
this.connect = function (a, c) { | |
g.connect(a, c) | |
}; | |
this.connectWithToken = | |
function (a, c) { | |
g.connect(a, c) | |
}; | |
this.connectWithCredentials = function (a, c, d) { | |
g.connect(a, "1:" + c + ":" + d) | |
}; | |
this.disconnect = function () { | |
g.disconnect() | |
}; | |
this.migrateToIndexedDBStorage = function (a, c, d) { | |
Spotify.Hermes.Cache.migrateToIndexedDB(a, c, d) | |
}; | |
this.initialize = function () { | |
c = new Spotify.Proto.Data(m.protoSchemasLocation, m.protoSchemasLocationRandomizer); | |
c.bind(d.SUCCESS, u); | |
c.bind(d.ERROR, E); | |
c.initialize() | |
}; | |
var x = function (a) { | |
var c = a.params; | |
if (c instanceof Spotify.Calls.Hermes) { | |
a = c.success; | |
for (var d = c.isMultiGet ? | |
c.mercuryMultiGetPayloadSchemas : c.payloadSchemas, b = c.isMultiGet ? c.mercuryMultiGetResponseSchemas : c.responseSchemas, k = [], h = [], m = 0, q = d.length; m < q; m += 1) k.push(s.getProtobufMsgParser.apply(f, d[m].split("#"))); | |
d = 0; | |
for (q = b.length; d < q; d += 1) h.push(s.getProtobufMsgParser.apply(f, b[d].split("#"))); | |
c.isMultiGet && (a = function (a, d) { | |
for (var b = 0; b < a.length; b += 1) { | |
var k = a[b], | |
g = []; | |
if ("undefined" === typeof k.reply) { | |
c.error(new Spotify.Errors.Error([13, 400])); | |
return | |
} | |
if (c.responseSchemas[b]) var h = s.getProtobufMsgParser.apply(f, | |
c.responseSchemas[b].split("#")); | |
for (var k = k.reply, m = 0, q = k.length; m < q; m += 1) { | |
var x = k[m], | |
x = x && x.status_code ? 200 <= x.status_code && 300 > x.status_code ? h ? h.parseFromStringSync(x.body) : x : null : null; | |
g.push(x) | |
} | |
} | |
c.success(g, d) | |
}); | |
(new Spotify.Hermes.ProtobufRequest(c.header, c.payload, k, h)).send(g, a, c.error, c.persistent, c.bypassCache, c.type) | |
} else c instanceof Spotify.Calls.Simple && g.rpc(c.method, c.payload, c.success, c.error, c.context, c.persistent, c.retries, c.type) | |
}; | |
this.registerService = function (a, c, b, g, h) { | |
if ("undefined" !== | |
typeof this.services[a]) return n.error("Spotify.Core", ["A service with id", a, "already exists"], "corejs"), null; | |
"undefined" === typeof h && (h = Spotify.Services.Base); | |
g = Spotify.Utils.inherit(h.bind(this, s), g); | |
k[a] = b; | |
b = new g; | |
this.services[a] = b; | |
b._dependencies = c; | |
b.id = a; | |
b.bind(d.REQUEST, x, this); | |
return this.services[a] | |
}; | |
this.dispose = function () { | |
for (var a in this.services) { | |
try { | |
this.services[a].dispose() | |
} catch (c) {} | |
this.services[a] = null | |
} | |
this.audioManager.dispose(); | |
g.dispose() | |
}; | |
this.onReady = function (a, c) { | |
this.isReady ? | |
a.call(c) : this.bind(d.READY, a, c) | |
}; | |
var z = function (a) { | |
var c = f.audioManager.getActivePlayer(); | |
c && c.pause(); | |
f.onTokenLost(a) | |
}, t = function (a) { | |
v(a) | |
}, v = function (a) { | |
for (var c in f.services) try { | |
f.services[c].onNotify(a) | |
} catch (d) {} | |
}, w = function (a) { | |
v(a) | |
}, u = function () { | |
Spotify.Instances.add(f); | |
s.registerSchema("mercury", c.getDefinition("mercury")); | |
s.registerSchema("pubsub", c.getDefinition("pubsub")); | |
f.registerService("user", [], [], Spotify.Services.User); | |
f.user = f.services.user; | |
f.registerService("logging_clientEvent", ["logging_logger"], [], Spotify.Logging.ClientEvent); | |
f.logging.clientEvent = f.services.logging_clientEvent; | |
f.registerService("logging_view", [], [], Spotify.Logging.View); | |
f.logging.view = f.services.logging_view; | |
f.registerService("logging_logger", [], [], Spotify.Logging.Logger); | |
f.logging.logger = f.services.logging_logger; | |
f.registerService("heartbeat", [], [], Spotify.Heartbeat); | |
f.registerService("storageResolver", [], [], Spotify.Services.SongUriResolver); | |
f.storageResolver = f.services.storageResolver; | |
f.storageResolver.bind(d.TIME_CAP, | |
A, f); | |
f.registerService("adResolver", [], [], Spotify.Services.AdUriResolver); | |
f.adUriResolver = f.services.adResolver; | |
f.registerService("previewResolver", [], [], Spotify.Services.PreviewsUriResolver); | |
f.previewUriResolver = f.services.previewResolver; | |
f.registerService("pubsub", [], ["pubsub"], Spotify.Services.Pubsub); | |
f.pubsub = f.services.pubsub; | |
g = new Spotify.Gateway(h); | |
g.bind(d.READY, K, f); | |
g.bind(d.ON_TRY_TO_CONNECT, D, f); | |
g.bind(d.CONNECTED, I, f); | |
g.bind(d.DISCONNECTED, f.onDisconnect, f); | |
g.bind(d.TOKEN_LOST, z, f); | |
g.bind(d.FLASH_AVAILABLE, | |
B, f); | |
g.bind(d.FLASH_UNAVAILABLE, B, f); | |
g.bind(d.HERMES_B64_MESSAGE, t, f); | |
g.bind(d.USER_INFO_CHANGE, y, f); | |
Spotify.Hermes.Cache.onfull = H; | |
f.features = new Spotify.Features(l.features); | |
f.hermes = new Spotify.Hermes.Handler(s); | |
f.hermes.init(g); | |
f.audioManager = new Spotify.Audio.AudioManager(f.id, m, q); | |
f.audioManager.bind(d.FLASH_AVAILABLE, B, f); | |
f.audioManager.bind(d.FLASH_UNAVAILABLE, B, f); | |
f.audioManager.bind(d.NO_SOUND_CAPABILITIES, C); | |
f.audioManager.bind(d.INITIALIZED, J, f); | |
f.audioManager.bind(d.TRACK_ENDED, w, f); | |
f.audioManager.bind(d.POSITION_CHANGED, | |
w, f); | |
f.audioManager.bind(d.PLAYING, w, f); | |
f.audioManager.bind(d.PAUSED, w, f); | |
f.audioManager.bind(d.STOPPED, w, f); | |
f.audioManager.bind(d.LOAD, w, f); | |
f.audioManager.addFileResolver(Spotify.Resolvers.STORAGE_RESOLVER, f.services.storageResolver); | |
f.audioManager.addFileResolver(Spotify.Resolvers.AD_RESOLVER, f.services.adResolver); | |
f.audioManager.addFileResolver(Spotify.Resolvers.PREVIEW_RESOLVER, f.services.previewResolver); | |
f.audioManager.initialize(g, f.user); | |
p = new Spotify.Worker; | |
p.initialize(g, f.audioManager); | |
g.initialize(f.id, m); | |
f._bridge = g.bridge | |
}, A = function (a) { | |
f.trigger(d.TIME_CAP, a.params) | |
}, y = function (a) { | |
v(a) | |
}, B = function (a) { | |
a.type === d.UNAVAILABLE ? f.trigger(d.FLASH_UNAVAILABLE) : (r && clearTimeout(r), r = setTimeout(function () { | |
g.isReady && f.audioManager.isInitialized ? n.log("Spotify.Core", ["Flash is available"], "corejs") : (n.error("Spotify.Core", ["Flash is NOT available"], "corejs"), f.trigger(d.FLASH_UNAVAILABLE)) | |
}, 1E4)) | |
}, E = function (a) { | |
f.trigger(d.DATA_ERROR, a) | |
}, C = function (a) { | |
f.trigger(d.NO_SOUND_CAPABILITIES) | |
}, | |
H = function (a) { | |
f.trigger(d.STORAGE_FULL) | |
}, I = function (b) { | |
if (!a) { | |
a = !0; | |
f.registerService("appstore", [], ["appstore"], Spotify.Services.AppStore); | |
f.appstore = f.services.appstore; | |
f.registerService("mergedProfile", [], ["mergedprofile"], Spotify.Services.MergedProfile); | |
f.mergedProfile = f.services.mergedProfile; | |
f.registerService("popcount", [], ["popcount"], Spotify.Services.PopCount); | |
f.popcount = f.services.popcount; | |
f.registerService("social", [], ["social"], Spotify.Services.Social); | |
f.social = f.services.social; | |
f.registerService("searchHermes", [], ["metadata", "search"], Spotify.Services.SearchHermes); | |
f.registerService("suggest", ["user"], ["suggest"], Spotify.Services.Suggest); | |
f.suggest = f.services.suggest; | |
f.registerService("toplist", ["user"], ["toplist", "socialgraph"], Spotify.Services.Toplist); | |
f.toplist = f.services.toplist; | |
f.registerService("search", ["user"], [], Spotify.Services.Search); | |
f.search = f.services.search; | |
f.registerService("playlist", ["user", "toplist", "pubsub"], "playlist4changes playlist4content playlist4issues playlist4meta playlist4ops playlist4service".split(" "), | |
Spotify.Services.Playlist); | |
f.playlist = f.services.playlist; | |
f.registerService("presence", ["pubsub", "user"], ["presence"], Spotify.Services.Presence); | |
f.presence = f.services.presence; | |
f.registerService("socialGraph", ["user", "playlist"], ["socialgraph"], Spotify.Services.SocialGraph); | |
f.socialGraph = f.services.socialGraph; | |
f.registerService("facebook", ["user"], ["facebook"], Spotify.Services.Facebook); | |
f.facebook = f.services.facebook; | |
f.registerService("facebookPublish", ["user"], ["facebook-publish"], Spotify.Services.FacebookPublish); | |
f.facebookPublish = f.services.facebookPublish; | |
f.registerService("metadata", ["user"], ["metadata"], Spotify.Services.Metadata); | |
f.metadata = f.services.metadata; | |
f.metadata.setLocale(l.locale || "en"); | |
f.registerService("time", [], [], Spotify.Services.Time); | |
f.time = f.services.time; | |
f.registerService("inbox", ["playlist"], [], Spotify.Services.Inbox); | |
f.registerService("spirc", ["pubsub", "user"], ["spirc"], Spotify.Services.SPIRC); | |
f.spirc = f.services.spirc; | |
g.bind(d.TOKEN_LOST, f.spirc.onTokenLost, f); | |
f.registerService("adChooser", [], ["ad-hermes-proxy"], Spotify.Services.AdChooser); | |
f.registerService("adsCore", [], [], Spotify.Ads.Core); | |
f.adsCore = f.services.adsCore; | |
f.adsCore.initialize(f, g, f.audioManager, f.user, f.logging.logger); | |
f.adsCore.adChooser && (f.adChooser = f.adsCore.adChooser, f.adChooser.bind(d.INTERCEPTED, M), g.playerTracker && g.playerTracker.bind(d.RECORD_AD_EVENT, G, f)); | |
f.collectionStorage = new Spotify.Services.CollectionStorage(m.services.collection_storage, c.getDefinition("collection2")); | |
f.services.collectionStorage = f.collectionStorage; | |
f.collectionStorage.init(g, f.pubsub, f.time); | |
var h; | |
"undefined" !== typeof settings && settings.services && (h = settings.services.collection_view); | |
h || (h = {}); | |
"undefined" === typeof h.union && (h.union = 2 === f.features.getNumber("collection")); | |
f.collectionView = new Spotify.Services.CollectionView(h); | |
f.services.collectionView = f.collectionView; | |
f.collectionView.init(f.collectionStorage, f.metadata, f.playlist, f.user, f.time, g, c.getDefinition("collection2cache")); | |
f.collectionUnplayed = new Spotify.Services.CollectionUnplayed(m.services.collection_unplayed); | |
f.collectionUnplayed.init(f.collectionStorage, f.user); | |
for (var q in f.services) { | |
var x = !1; | |
h = []; | |
if (f.services[q]._dependencies) { | |
for (var t = 0, w = f.services[q]._dependencies.length; t < w; t += 1) { | |
var u = f.services[f.services[q]._dependencies[t]]; | |
if ("undefined" === typeof u) { | |
x = !0; | |
console.log("problem"); | |
break | |
} | |
h.push(u) | |
} | |
if (!x) { | |
x = 0; | |
for (t = k[q].length; x < t; x += 1) w = k[q][x], s.registerSchema(w, c.getMultipleDefinitions([w])); | |
1 < k[q].length && s.registerSchema(q + "_FULL", c.getMultipleDefinitions(k[q])); | |
f.services[q]._initialize.call(f.services[q], | |
h) | |
} | |
} | |
} | |
} | |
v(b); | |
f.onConnect(b); | |
f.trigger(d.CONNECTION_ESTABLISHED) | |
}, G = function (a) { | |
f.adsCore.adChooser.onReady(function () { | |
f.adsCore.adChooser.recordAdEvent(a.params.adUri, a.params.type) | |
}) | |
}, M = function (a) { | |
f.trigger(d.WAIT_FOR_COMMERCIAL_TO_FINISH) | |
}, N = function () { | |
!f.isReady && g.isReady && f.audioManager.isInitialized && (f.isReady = !0, f.trigger(d.READY)) | |
}, K = function (a) { | |
N() | |
}, J = function (a) { | |
N() | |
}, D = function (a) { | |
v({ | |
type: d.DISCONNECTED, | |
params: {}, | |
extra: {} | |
}); | |
f.trigger(a.type) | |
}; | |
this.initialize.call(this) | |
}; | |
(function (b, l) { | |
var f = function (a) { | |
a = a.replace(/[^\/]*$/, ""); | |
return a.substring(0, a.length - 1) | |
}, n = f(location.pathname); | |
window.process = { | |
cwd: function () { | |
return n || "/" | |
} | |
}; | |
for (var p = {}, r = function (a) { | |
var b = p[a]; | |
if (!b) { | |
var h = l[a]; | |
if (!h) throw Error("module " + a + " not found"); | |
var g = f(a), | |
d = {}, b = d.exports = {}, c = n + "/" + a, | |
g = g ? n + "/" + g : process.cwd(); | |
h.call(b, r, d, b, window, c, g); | |
b = p[a] = d.exports | |
} | |
return b | |
}, a = 0; a < b.length; a++) r(b[a]) | |
})(["src/builder.js"], { | |
"src/app-view-logger.js": function (b, l, f, n, p, r) { | |
function a(b, m) { | |
if (!(this instanceof a)) return new a(b, m); | |
this._logger = b; | |
this._applicationManager = m; | |
this._previousEntry = null; | |
this._log = this._log.bind(this); | |
this.attach() | |
} | |
f.ApplicationViewLogger = a; | |
a.prototype._log = function (a) { | |
var b = this._previousEntry, | |
h = (new Date).getTime(); | |
b && this._logger.log(b.uri, b.version, b.vendor, h - b.timestamp); | |
this._previousEntry = { | |
uri: a.link.toURI(), | |
version: "0.1.0", | |
vendor: "com.spotify", | |
timestamp: h | |
} | |
}; | |
a.prototype.attach = function () { | |
this._applicationManager.addEvents({ | |
create: this._log, | |
update: this._log | |
}) | |
}; | |
a.prototype.detach = | |
function () { | |
this._applicationManager.removeEvents({ | |
create: this._log, | |
update: this._log | |
}) | |
} | |
}, | |
"node_modules/spotify-bridge/src/bridge/sourceurls.js": function (b, l, f, n, p, r) { | |
l.exports = { | |
unbranded: "https://d3rt1990lpmkn.cloudfront.net/unbranded/", | |
tiny: "https://d3rt1990lpmkn.cloudfront.net/60/", | |
normal: "https://d3rt1990lpmkn.cloudfront.net/300/", | |
small: "https://d3rt1990lpmkn.cloudfront.net/120/", | |
large: "https://d3rt1990lpmkn.cloudfront.net/640/", | |
avatar: "https://d3rt1990lpmkn.cloudfront.net/artist_image/" | |
} | |
}, | |
"node_modules/cosmos-router-js/src/pattern.js": function (b, | |
l, f, n, p, r) { | |
(function () { | |
f.Predicate; | |
var a = {}, b = function () { | |
var a = /(?=[\-\[\]{}()*+?.\\\^$|,#\s])/g; | |
return function (d) { | |
return d.replace(a, "\\") | |
} | |
}(), | |
m = { | |
"*": "__STAR_ESCAPE__", | |
"?": "__QMARK_ESCAPE__", | |
"\\": "__ESCAPE_ESCAPE__" | |
}, h = /\\([^]?)/g, | |
g = { | |
__STAR_ESCAPE__: "*", | |
__QMARK_ESCAPE__: "?", | |
__ESCAPE_ESCAPE__: "\\" | |
}, d = function () { | |
var a = ["__SEPARATOR_ESCAPE__"], | |
d; | |
for (d in g) a.push(d); | |
return RegExp("(" + a.join("|") + ")", "g") | |
}(); | |
a.parse = function (a, k) { | |
k = k || "/"; | |
var s = b(k), | |
f = "[^" + k + "]*", | |
l = "[^" + k + "]{1}"; | |
a = a.replace(h, function (a, | |
c) { | |
return c == k ? "__SEPARATOR_ESCAPE__" : m[c] || c | |
}); | |
a = a.replace(/\*\*/g, "__ALL_CHARS_ESCAPE__").replace(/\*/g, "__ANY_CHARS_ESCAPE__").replace(/\?/g, "__ANY_CHAR_ESCAPE__"); | |
a = a.replace(d, function (a, c) { | |
return "__SEPARATOR_ESCAPE__" == c ? s : g[c] || c | |
}); | |
a = b(a); | |
a = a.replace(/__ALL_CHARS_ESCAPE__/g, "[^]*").replace(/__ANY_CHARS_ESCAPE__/g, f).replace(/__ANY_CHAR_ESCAPE__/g, l); | |
return RegExp("^" + a + "$") | |
}; | |
a.createPredicate = function (c, d) { | |
var b = a.parse(c, d); | |
return function (a) { | |
return b.test(a) | |
} | |
}; | |
f.Pattern = a | |
})() | |
}, | |
"node_modules/cosmos-router-js/src/messagerouter.js": function (b, | |
l, f, n, p, r) { | |
function a() { | |
if (!(this instanceof a)) return new a; | |
this._token = 0; | |
this._listeners = {} | |
} | |
var q = b("node_modules/cosmos-router-js/src/pattern.js").Pattern; | |
f.MessageRouter = a; | |
a.prototype.sendMessage = function (a, b, g) { | |
var d = Object.keys(this._listeners), | |
c; | |
b = b || []; | |
for (var k = 0, s = d.length; k < s; k++) c = this._listeners[d[k]], c.topicPredicate(a) && this._realmsIntersect(c.realms, b) && c.callback(g) | |
}; | |
a.prototype.subscribe = function (a, b, g) { | |
if (a && "function" === typeof g) { | |
b = b || []; | |
a = q.createPredicate(a); | |
var d = this._token++; | |
this._listeners[d] = { | |
topicPredicate: a, | |
realms: b, | |
callback: g | |
}; | |
return d | |
} | |
}; | |
a.prototype.unsubscribe = function (a) { | |
this._listeners[a] && (this._listeners[a] = null, delete this._listeners[a]) | |
}; | |
a.prototype._realmsIntersect = function (a, b) { | |
return !a.length || !b.length || a.filter(function (a) { | |
return -1 < b.indexOf(a) | |
}).length | |
} | |
}, | |
"node_modules/cosmos-router-js/src/requestfilter.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(a, b) { | |
a = a || {}; | |
this._actionPredicate = "action" in a ? q.createPredicate(a.action) : null; | |
this._typePredicate = | |
"type" in a ? q.createPredicate(a.type) : null; | |
this._uriPredicate = "uri" in a ? q.createPredicate(a.uri, a.uriSeparator) : null; | |
this._priority = Math.min(m.HIGHEST, Math.max(m.LOWEST, b || m.DEFAULT)) | |
} | |
var q = b("node_modules/cosmos-router-js/src/pattern.js").Pattern; | |
f.RequestFilterOptions; | |
var m = { | |
LOWEST: -1E3, | |
LOW: -500, | |
DEFAULT: 0, | |
HIGH: 500, | |
HIGHEST: 1E3 | |
}; | |
f.RequestFilterPriority = m; | |
a.prototype.getPriority = function () { | |
return this._priority | |
}; | |
a.prototype.match = function (a) { | |
return this._actionPredicate && !this._actionPredicate(a.getAction()) || | |
this._typePredicate && !this._typePredicate(a.getMimeType()) || this._uriPredicate && !this._uriPredicate(a.getURI()) ? !1 : !0 | |
}; | |
f.RequestFilter = a | |
})() | |
}, | |
"node_modules/cosmos-router-js/src/channel.js": function (b, l, f, n, p, r) { | |
function a(b) { | |
if (!(this instanceof a)) return new a(b); | |
this._queue = []; | |
this._open = a.Status.KEEP_OPEN; | |
this._sink = new q(this); | |
this._source = new m(this); | |
this._consumeCallback = null; | |
this._closeCallbacks = []; | |
b && this._sink.push(b) | |
} | |
function q(a) { | |
if (!(this instanceof q)) return new q(a); | |
this._channel = a | |
} | |
function m(a) { | |
if (!(this instanceof m)) return new m(a); | |
this._channel = a | |
} | |
f.Channel = a; | |
a.Sink = q; | |
a.Source = m; | |
a.Status = { | |
CLOSE: "CLOSE", | |
KEEP_OPEN: "KEEP_OPEN" | |
}; | |
a.prototype.getSink = function () { | |
return this._sink | |
}; | |
a.prototype.getSource = function () { | |
return this._source | |
}; | |
a.prototype._onMessagePushed = function (b) { | |
this._open === a.Status.KEEP_OPEN && this._queue.push(b); | |
this._invokeConsumeCallback(); | |
return this._open | |
}; | |
a.prototype._onConsumeRequest = function (b) { | |
this._consumeCallback = b; | |
this._open === a.Status.KEEP_OPEN && this._invokeConsumeCallback() | |
}; | |
a.prototype._onClose = function () { | |
this._queue = []; | |
this._open = a.Status.CLOSE; | |
this._invokeCloseCallbacks() | |
}; | |
a.prototype._invokeConsumeCallback = function () { | |
if (this._consumeCallback && "function" === typeof this._consumeCallback) | |
for (var b; b = this._queue.shift();) this._consumeCallback.call(this, b) === a.Status.CLOSE && this._source.close() | |
}; | |
a.prototype._invokeCloseCallbacks = function () { | |
for (var a; a = this._closeCallbacks.shift();) a.call(this) | |
}; | |
a.prototype._addCloseCallback = function (b) { | |
b && "function" === typeof b && (this._closeCallbacks.push(b), | |
this._open === a.Status.CLOSE && this._invokeCloseCallbacks()) | |
}; | |
q.prototype.push = function (a) { | |
if (this._channel) return this._channel._onMessagePushed(a) | |
}; | |
q.prototype.addCloseCallback = function (a) { | |
this._channel && this._channel._addCloseCallback(a) | |
}; | |
m.prototype.consume = function (a) { | |
this._channel && this._channel._onConsumeRequest(a) | |
}; | |
m.prototype.forward = function (a) { | |
this.consume(function (b) { | |
a.push(b); | |
return !0 | |
}) | |
}; | |
m.prototype.close = function () { | |
this._channel && this._channel._onClose() | |
}; | |
m.prototype.addCloseCallback = | |
function (a) { | |
this._channel && this._channel._addCloseCallback(a) | |
} | |
}, | |
"node_modules/cosmos-router-js/src/resolver.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(a) { | |
this._filter = a || new m({ | |
action: "" | |
}) | |
} | |
var q = b("node_modules/cosmos-router-js/src/channel.js").Channel, | |
m = b("node_modules/cosmos-router-js/src/requestfilter.js").RequestFilter; | |
f.Filter; | |
f.Resolver = a; | |
a.prototype._createChannel = function () { | |
return new q | |
}; | |
a.prototype.resolve = function (a) { | |
return this._createChannel().getSource() | |
}; | |
a.prototype.getRequestFilter = | |
function () { | |
return this._filter | |
} | |
})() | |
}, | |
"node_modules/cosmos-router-js/src/requesthandler.js": function (b, l, f, n, p, r) { | |
function a(b) { | |
if (!(this instanceof a)) return new a(b); | |
if (!b) throw new TypeError("Missing `router` param"); | |
this._router = b; | |
this._requests = {} | |
} | |
f.RequestHandler = a; | |
a.prototype.openRequest = function (a, b, h) { | |
if (!this._isValidId(a) || !b) throw new TypeError("Missing params for `openRequest`"); | |
if (this._requests[a]) throw Error("Request ID already in use"); | |
b = this._router.resolve(b); | |
if (!b) throw Error("Could not open the request"); | |
this._requests[a] = b; | |
b.consume(h); | |
return this | |
}; | |
a.prototype.closeRequest = function (a, b) { | |
if (!this._isValidId(a)) throw new TypeError("Missing id for `closeRequest`"); | |
var h = this._requests[a]; | |
if (!h) throw Error("Request does not exist"); | |
h.addCloseCallback(b); | |
h.close(); | |
this._requests[a] = null; | |
delete this._requests[a]; | |
return this | |
}; | |
a.prototype._isValidId = function (a) { | |
return a && "string" === typeof a || "number" === typeof a | |
}; | |
a.prototype.closeAll = function () { | |
for (var a = Object.keys(this._requests), b = 0, h = a.length; b < h; b++) this.closeRequest(a[b]) | |
} | |
}, | |
"node_modules/spotify-bridge/src/shell/lists/core.js": function (b, l, f, n, p, r) { | |
(function () { | |
var a = {}; | |
a.LIST_START = new function () {}; | |
a.LIST_END = new function () {}; | |
a.NULL_VALUE = new function () {}; | |
a.OUT_OF_BOUNDS = new function () {}; | |
a.LoadResponse; | |
a.LoadedState = { | |
UNLOADED: "unloaded", | |
LOADING: "loading", | |
PARTIAL: "partial", | |
COMPLETE: "complete" | |
}; | |
a.ListIndex; | |
a.ListLength; | |
a.IndexResolver; | |
a.VersionNumber; | |
a.VersionComparator; | |
a.VersionedAccessor; | |
l.exports = a | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/lists/comparators.js": function (b, | |
l, f, n, p, r) { | |
(function () { | |
function a(a, c) { | |
return a - c | |
} | |
function b(a, c) { | |
return c - a | |
} | |
function m(a, c) { | |
return a > c ? 1 : a == c ? 0 : -1 | |
} | |
function h(a, c) { | |
return a > c ? -1 : a == c ? 0 : 1 | |
} | |
var g = { | |
forNumber: function () { | |
return a | |
}, | |
forNumberReversed: function () { | |
return b | |
}, | |
forString: function () { | |
return m | |
}, | |
forStringReversed: function () { | |
return h | |
} | |
}, d = {}, c = {}; | |
g.forNumberProperty = function (a) { | |
return d[a] || (d[a] = function (c, d) { | |
c = c[a]; | |
d = d[a]; | |
return c - d | |
}) | |
}; | |
g.forNumberPropertyReversed = function (a) { | |
var c = a + "_reverse"; | |
return d[c] || (d[c] = function (c, d) { | |
c = c[a]; | |
d = d[a]; | |
return d - c | |
}) | |
}; | |
g.forStringProperty = function (a) { | |
return c[a] || (c[a] = function (c, d) { | |
c = (c[a] || "").toString(); | |
d = (d[a] || "").toString(); | |
return c > d ? 1 : c == d ? 0 : -1 | |
}) | |
}; | |
g.forStringPropertyReversed = function (a) { | |
var d = a + "_reverse"; | |
return c[d] || (c[d] = function (c, d) { | |
c = (c[a] || "").toString(); | |
d = (d[a] || "").toString(); | |
return c > d ? -1 : c == d ? 0 : 1 | |
}) | |
}; | |
g.forProperty = function (a, c) { | |
return function (d, b) { | |
return c(d[a], b[a]) | |
} | |
}; | |
g.forComparators = function (a) { | |
return 1 == a.length ? a[0] : function (c, d) { | |
for (var b = 0, g = 0; 0 == b && g < a.length;) b = a[g](c, | |
d), ++g; | |
return b | |
} | |
}; | |
l.exports = { | |
SortingOrder: { | |
ASC: "asc", | |
DESC: "desc" | |
}, | |
ComparisonResult: { | |
GREATER: 1, | |
EQUAL: 0, | |
LESS: -1 | |
}, | |
Comparators: g, | |
Comparator: void 0, | |
ComparatorMap: void 0 | |
} | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/lists/predicates.js": function (b, l, f, n, p, r) { | |
(function () { | |
l.exports = { | |
Predicate: void 0, | |
PredicateMap: void 0, | |
PredicateOperator: { | |
EQUAL: "=", | |
NOT_EQUAL: "!=", | |
GREATER_THAN: ">", | |
LESS_THAN: "<", | |
GREATER_THAN_OR_EQUAL: ">=", | |
LESS_THAN_OR_EQUAL: "<=", | |
STARTS_WITH: "startswith", | |
CONTAINS: "contains" | |
}, | |
Predicates: { | |
forOperator: function (a, | |
b) { | |
switch (a) { | |
case "=": | |
return this.forEqual(b); | |
case "!=": | |
return this.forNotEqual(b); | |
case ">": | |
return this.forGreaterThan(b); | |
case "<": | |
return this.forLessThan(b); | |
case ">=": | |
return this.forGreaterThanOrEqual(b); | |
case "<=": | |
return this.forLessThanOrEqual(b); | |
case "startswith": | |
return this.forBeginsWith(b); | |
case "contains": | |
return this.forContains(b); | |
default: | |
return null | |
} | |
}, | |
forPropertyOperator: function (a, b, m) { | |
switch (b) { | |
case "=": | |
return this.forPropertyEqual(a, m); | |
case "!=": | |
return this.forPropertyNotEqual(a, m); | |
case ">": | |
return this.forPropertyGreaterThan(a, | |
m); | |
case "<": | |
return this.forPropertyLessThan(a, m); | |
case ">=": | |
return this.forPropertyGreaterThanOrEqual(a, m); | |
case "<=": | |
return this.forPropertyLessThanOrEqual(a, m); | |
case "startswith": | |
return this.forPropertyBeginsWith(a, m); | |
case "contains": | |
return this.forPropertyContains(a, m); | |
default: | |
return null | |
} | |
}, | |
forNotNull: function () { | |
return function (a) { | |
return null != a | |
} | |
}, | |
forEqual: function (a) { | |
return function (b) { | |
return b === a | |
} | |
}, | |
forGreaterThan: function (a) { | |
return function (b) { | |
return b > a | |
} | |
}, | |
forLessThan: function (a) { | |
return function (b) { | |
return b < | |
a | |
} | |
}, | |
forGreaterThanOrEqual: function (a) { | |
return function (b) { | |
return b >= a | |
} | |
}, | |
forLessThanOrEqual: function (a) { | |
return function (b) { | |
return b <= a | |
} | |
}, | |
forNotEqual: function (a) { | |
return function (b) { | |
return b != a | |
} | |
}, | |
forBeginsWith: function (a) { | |
return function (b) { | |
return b ? 0 == b.toString().indexOf(a) : !1 | |
} | |
}, | |
forContains: function (a) { | |
return function (b) { | |
return b ? -1 != b.toString().indexOf(a) : !1 | |
} | |
}, | |
forPropertyNotNull: function (a) { | |
return function (b) { | |
return null != b[a] | |
} | |
}, | |
forPropertyEqual: function (a, b) { | |
return function (m) { | |
return m[a] == b | |
} | |
}, | |
forPropertyGreaterThan: function (a, | |
b) { | |
return function (m) { | |
return m[a] > b | |
} | |
}, | |
forPropertyLessThan: function (a, b) { | |
return function (m) { | |
return m[a] < b | |
} | |
}, | |
forPropertyGreaterThanOrEqual: function (a, b) { | |
return function (m) { | |
return m[a] >= b | |
} | |
}, | |
forPropertyLessThanOrEqual: function (a, b) { | |
return function (m) { | |
return m[a] <= b | |
} | |
}, | |
forPropertyNotEqual: function (a, b) { | |
return function (m) { | |
return m[a] != b | |
} | |
}, | |
forPropertyBeginsWith: function (a, b) { | |
return function (m) { | |
return m && m[a] ? 0 == m[a].toString().indexOf(b) : !1 | |
} | |
}, | |
forPropertyContains: function (a, b) { | |
return function (m) { | |
return m && | |
m[a] ? -1 != m[a].toString().indexOf(b) : !1 | |
} | |
} | |
} | |
} | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/lists/snapshot.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(b, h, g, d) { | |
if (!(this instanceof a)) return new a(b, h, g); | |
this._version = b; | |
this._versionedAccessor = h; | |
this._range = g; | |
this._listLength = d | |
} | |
var q = b("node_modules/spotify-bridge/src/shell/lists/core.js"); | |
a.prototype.getOffset = function () { | |
return this._range.begin | |
}; | |
a.prototype.getLength = function () { | |
return this._range.length | |
}; | |
a.prototype.getListLength = function () { | |
return this._listLength | |
}; | |
a.prototype.getVersion = function () { | |
return this._version | |
}; | |
a.prototype.get = function (a) { | |
var b = this._range, | |
g = b.begin + a; | |
return 0 > g || g < b.begin || g > b.end ? q.NULL_VALUE : this._versionedAccessor(this._version, g, a) | |
}; | |
a.prototype.toArray = function () { | |
for (var a = [], b = 0, g = this._range.length; b < g; b++) { | |
var d = this.get(b); | |
d != q.NULL_VALUE && a.push(d) | |
} | |
return a | |
}; | |
a.prototype.toFullArray = function () { | |
for (var a = [], b = 0, g = this._range.length; b < g; b++) { | |
var d = this.get(b); | |
a.push(d) | |
} | |
return a | |
}; | |
l.exports = a | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/lists/descriptor.js": function (b, | |
l, f, n, p, r) { | |
(function () { | |
function a() { | |
this.type = null | |
} | |
function b(a) { | |
if (!(this instanceof b)) return new b(a); | |
if (!a) throw Error("Invalid arguments."); | |
this.type = "list"; | |
this.uri = a | |
} | |
function m(a) { | |
if (!(this instanceof m)) return new m(uri); | |
if (!a) throw Error("Invalid arguments."); | |
this.lists = a; | |
this.type = "lists" | |
} | |
function h(a, c, d) { | |
if (!(this instanceof h)) return new h(uri); | |
if (void 0 == c || void 0 == a || void 0 == d) throw Error("Invalid arguments."); | |
this.args = c; | |
this.list = a; | |
this.type = "sort"; | |
this.version = d; | |
this.params = []; | |
for (a = | |
0; a < c.length; a += 2) this.params.push({ | |
field: c[a], | |
order: c[a + 1] | |
}) | |
} | |
function g(a, c, d) { | |
if (!(this instanceof g)) return new g(uri); | |
if (void 0 == c || void 0 == a || void 0 == d) throw Error("Invalid arguments."); | |
this.args = c; | |
this.list = a; | |
this.type = "filter"; | |
this.version = d; | |
this.operator = c[0]; | |
this.field = c[1]; | |
this.matcher = c[2] | |
} | |
function d(a, c, b) { | |
if (!(this instanceof d)) return new d(uri); | |
if (void 0 == c || void 0 == a || void 0 == b) throw Error("Invalid arguments."); | |
this.args = c; | |
this.list = a; | |
this.type = "range"; | |
this.version = b; | |
this.offset = c[0]; | |
this.length = c[1] | |
} | |
function c(a, d, b) { | |
if (!(this instanceof c)) return new c(uri); | |
if (void 0 == d || void 0 == a || void 0 == b) throw Error("Invalid arguments."); | |
this.args = d; | |
this.list = a; | |
this.type = "shuffle"; | |
this.version = b; | |
this.seed = d[0] | |
} | |
var k = function (a, c) { | |
return "operator" == a || "field" == a || "matcher" == a || "offset" == a || "length" == a || "seed" == a || "order" == a || "params" == a ? void 0 : c | |
}; | |
a.prototype.serialize = function () { | |
return JSON.stringify(this, k) | |
}; | |
b.prototype = new a; | |
m.prototype = new a; | |
h.prototype = new a; | |
g.prototype = new a; | |
d.prototype = | |
new a; | |
c.prototype = new a; | |
l.exports = { | |
from: function (a) { | |
return a ? "string" == typeof descriptor ? this.fromString(a) : this.fromObject(a) : null | |
}, | |
fromString: function (c) { | |
try { | |
var d = this.fromObject(JSON.parse(c)); | |
return d instanceof a ? d : null | |
} catch (b) { | |
return null | |
} | |
}, | |
fromObject: function (k) { | |
if (!k) return null; | |
if (k instanceof a) return k; | |
try { | |
switch (k.type) { | |
case "list": | |
return new b(k.uri); | |
case "lists": | |
for (var f = [], l = 0, t = k.lists.length; l < t; l++) { | |
var v = this.fromObject(k.lists[l]); | |
if (!v) return null; | |
f.push(v) | |
} | |
return new m(f); | |
case "sort": | |
return new h(this.fromObject(k.list), k.args, k.version); | |
case "filter": | |
return new g(this.fromObject(k.list), k.args, k.version); | |
case "range": | |
return new d(this.fromObject(k.list), k.args, k.version); | |
case "shuffle": | |
return new c(this.fromObject(k.list), k.args, k.version); | |
default: | |
return null | |
} | |
} catch (w) { | |
return null | |
} | |
}, | |
occludeFields: k, | |
extractList: function (a) { | |
if (!a) return null; | |
if ("string" == typeof a) return new Spotify.ItemList.Descriptor.List(a); | |
for (; a && "list" != a.type;) a = a.list; | |
return a && "list" == a.type ? | |
a : null | |
}, | |
Base: a, | |
List: b, | |
Concatenated: m, | |
Sorted: h, | |
Filtered: g, | |
Ranged: d, | |
Shuffled: c | |
} | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/extension.js": function (b, l, f, n, p, r) { | |
(function () { | |
var a = Object.prototype.toString, | |
b = Spotify.Link; | |
Array.isArray || (Array.isArray = function (b) { | |
return "[object Array]" == a.call(b) | |
}); | |
Array.prototype.spliceWith || Object.defineProperty(Array.prototype, "spliceWith", { | |
configurable: !0, | |
enumerable: !1, | |
writeable: !0, | |
value: function (a, b, d) { | |
if (void 0 == d) return this.splice(a, b); | |
Array.isArray(d) || (d = [d]); | |
return this.splice.apply(this, [a, b].concat(d)) | |
} | |
}); | |
Array.prototype.insertFrom || Object.defineProperty(Array.prototype, "insertFrom", { | |
configurable: !0, | |
enumerable: !1, | |
writeable: !0, | |
value: function (a, b) { | |
if (void 0 == b) return this; | |
Array.isArray(b) || (b = [b]); | |
for (var d = b.length; d--;) this[d + a] = b[d]; | |
return this | |
} | |
}); | |
var m = {}; | |
m.LinkLike; | |
m.from = function (a) { | |
try { | |
return a instanceof b ? a : "object" == typeof a && a.type ? new b(null, a) : b.fromString(a.toString()) | |
} catch (g) { | |
return null | |
} | |
}; | |
m.clone = function (a) { | |
return a instanceof b ? new Spotify.Link(null, | |
a) : null | |
}; | |
l.exports = { | |
LinkHelper: m, | |
ClassLike: void 0 | |
} | |
})() | |
}, | |
"node_modules/spotify-inheritance/inherit.js": function (b, l, f, n, p, r) { | |
l.exports = function (a, b) { | |
function m() {} | |
m.prototype = a._super = b.prototype; | |
m.prototype.constructor = b; | |
a.prototype = new m | |
} | |
}, | |
"node_modules/spotify-bridge/src/bridge/errors.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(a) { | |
Error.apply(this, arguments); | |
this.message = a | |
} | |
function q(c) { | |
a.call(this, c) | |
} | |
function m(c) { | |
a.call(this, c) | |
} | |
function h(c) { | |
a.call(this, c) | |
} | |
function g(c) { | |
a.call(this, c) | |
} | |
function d(c) { | |
a.call(this, | |
c) | |
} | |
function c(c) { | |
a.call(this, c) | |
} | |
function k(c) { | |
a.call(this, c) | |
} | |
function s(c) { | |
a.call(this, c) | |
} | |
function f(c) { | |
a.call(this, c) | |
} | |
function z(c) { | |
a.call(this, c) | |
} | |
function t(c) { | |
a.call(this, c) | |
} | |
function v(c) { | |
a.call(this, c) | |
} | |
function w(c) { | |
a.call(this, c) | |
} | |
function u(c) { | |
a.call(this, c) | |
} | |
function A(c) { | |
a.call(this, c) | |
} | |
var y = b("node_modules/spotify-inheritance/inherit.js"); | |
y(a, Error); | |
a.prototype.name = "BridgeError"; | |
a.prototype.type = "bridge-error"; | |
a.Aborted = q; | |
a.Forbidden = m; | |
a.Hermes = h; | |
a.InvalidRequest = g; | |
a.InvalidURI = d; | |
a.NotConnected = | |
c; | |
a.NotFound = k; | |
a.NotImplemented = s; | |
a.OutOfDate = f; | |
a.PlayCapped = z; | |
a.RateLimited = t; | |
a.Timeout = v; | |
a.Transient = w; | |
a.Unknown = u; | |
a.Unplayable = A; | |
y(q, a); | |
q.prototype.name = "BridgeAbortedError"; | |
q.prototype.type = "aborted"; | |
y(m, a); | |
m.prototype.name = "BridgeForbiddenError"; | |
m.prototype.type = "forbidden"; | |
y(h, a); | |
h.prototype.name = "BridgeHermesError"; | |
h.prototype.type = "hermes"; | |
y(g, a); | |
g.prototype.name = "BridgeInvalidRequestError"; | |
g.prototype.type = "invalid-request"; | |
y(d, a); | |
d.prototype.name = "BridgeInvalidURIError"; | |
d.prototype.type = | |
"invalid-uri"; | |
y(c, a); | |
c.prototype.name = "BridgeNotConnectedError"; | |
c.prototype.type = "not-connected"; | |
y(k, a); | |
k.prototype.name = "BridgeNotFoundError"; | |
k.prototype.type = "not-found"; | |
y(s, a); | |
s.prototype.name = "BridgeNotImplementedError"; | |
s.prototype.type = "not-implemented"; | |
y(f, a); | |
f.prototype.name = "BridgeOutOfDateError"; | |
f.prototype.type = "out-of-date"; | |
y(z, a); | |
z.prototype.name = "BridgePlayCappedError"; | |
z.prototype.type = "play-capped"; | |
y(t, a); | |
t.prototype.name = "BridgeRateLimitedError"; | |
t.prototype.type = "rate-limited"; | |
y(v, | |
a); | |
v.prototype.name = "BridgeTimeoutError"; | |
v.prototype.type = "timeout"; | |
y(w, a); | |
w.prototype.name = "BridgeTransientError"; | |
w.prototype.type = "transient"; | |
y(u, a); | |
u.prototype.name = "BridgeUnknownError"; | |
u.prototype.type = "unknown"; | |
y(A, a); | |
A.prototype.name = "BridgeUnplayableError"; | |
A.prototype.type = "unplayable"; | |
l.exports = a | |
})() | |
}, | |
"node_modules/spotify-inheritance/extend.js": function (b, l, f, n, p, r) { | |
l.exports = function (a, b) { | |
for (var m, h = 1; h < arguments.length; h++) | |
if (m = arguments[h]) | |
for (var g in m) m.hasOwnProperty(g) && (a[g] = m[g]); | |
return a | |
} | |
}, | |
"node_modules/spotify-weakmap/src/weakmap.js": function (b, l, f, n, p, r) { | |
function a() { | |
this._keys = []; | |
this._values = [] | |
} | |
a.prototype.get = function (a) { | |
a = this._keys.indexOf(a); | |
return -1 == a ? null : this._values[a] | |
}; | |
a.prototype.getKey = function (a) { | |
a = this._values.indexOf(a); | |
return -1 == a ? null : this._keys[a] | |
}; | |
a.prototype.has = function (a) { | |
return -1 !== this._keys.indexOf(a) | |
}; | |
a.prototype.set = function (a, b) { | |
var h = this._keys, | |
g = this._values, | |
d = h.indexOf(a); | |
if (-1 != d) return g[d] = b, this; | |
h.push(a); | |
g.push(b); | |
return this | |
}; | |
a.prototype.remove = | |
function (a) { | |
var b = this._keys, | |
h = this._values; | |
a = b.indexOf(a); | |
if (-1 == a) return this; | |
b.splice(a, 1); | |
h.splice(a, 1); | |
return this | |
}; | |
a.prototype.clear = function () { | |
this._keys.splice(0, this._keys.length); | |
this._values.splice(0, this._values.length); | |
return this | |
}; | |
l.exports = a | |
}, | |
"node_modules/cosmos-router-js/src/weakmap.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a() { | |
this._keys = []; | |
this._values = [] | |
} | |
f.WeakMap = a; | |
a.prototype.get = function (a) { | |
a = this._keys.indexOf(a); | |
return -1 == a ? null : this._values[a] | |
}; | |
a.prototype.getKey = function (a) { | |
a = | |
this._values.indexOf(a); | |
return -1 == a ? null : this._keys[a] | |
}; | |
a.prototype.set = function (a, b) { | |
var h = this._keys, | |
g = this._values, | |
d = h.indexOf(a); | |
if (-1 != d) return g[d] = b, this; | |
h.push(a); | |
g.push(b); | |
return this | |
}; | |
a.prototype.remove = function (a) { | |
var b = this._keys, | |
h = this._values; | |
a = b.indexOf(a); | |
if (-1 == a) return this; | |
b.splice(a, 1); | |
h.splice(a, 1); | |
return this | |
}; | |
a.prototype.clear = function () { | |
this._keys.splice(0, this._keys.length); | |
this._values.splice(0, this._values.length); | |
return this | |
} | |
})() | |
}, | |
"node_modules/cosmos-router-js/src/interface_helper.js": function (b, | |
l, f, n, p, r) { | |
function a(a) { | |
if (!a || "Array" !== a.constructor.name) throw new TypeError("Interface argument should be list of method names."); | |
this._props = []; | |
for (var b = 0, h = a.length; b < h; b++) { | |
if ("string" !== typeof a[b]) throw new TypeError("`" + a[b].toString() + "` is not a string."); | |
this._props.push(a[b]) | |
} | |
} | |
a.prototype.isImplementedBy = function (a) { | |
if (!a || "Array" === a.constructor.name || "object" !== typeof a) throw new TypeError("The argument needs to have a key-value structure."); | |
for (var b = this._props, h = 0, g = b.length; h < | |
g; h++) | |
if (!a[b[h]] || "function" !== typeof a[b[h]]) return !1; | |
return !0 | |
}; | |
f.Interface = a | |
}, | |
"node_modules/spotify-bridge/src/shell/range.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(b, h, g) { | |
if (!(this instanceof a)) return new a(b, h, g); | |
b = null != b ? b : 0; | |
h = null != h ? h : -1; | |
g = null != g ? g : Infinity; | |
var d = -1 == h ? g : h; | |
this.length = h = -1 == h ? g : Math.min(h, g); | |
this.expectedLength = d; | |
this.begin = b; | |
this.last = b + h; | |
this.end = b + h - 1 | |
} | |
var b = Array.prototype.slice; | |
a.prototype.contains = function (a) { | |
return !(a.begin < this.begin || a.begin > this.end || a.end > | |
this.end || a.end < this.begin) | |
}; | |
a.prototype.has = function (a) { | |
return a >= this.begin && a <= this.end | |
}; | |
a.prototype.equals = function (a) { | |
return this.begin == a.begin && this.end == a.end | |
}; | |
a.prototype.intersects = function (a) { | |
return this.begin <= a.end && a.begin <= this.end | |
}; | |
a.prototype.contiguous = function (a) { | |
return this.last == a.begin || a.last == this.begin | |
}; | |
a.prototype.intersect = function (b) { | |
if (this.end < b.begin || b.end < this.begin) return new a(NaN, 0); | |
var h = Math.max(b.begin, this.begin); | |
b = Math.min(b.end, this.end) - h + 1; | |
return new a(h, | |
b) | |
}; | |
a.prototype.add = function (b) { | |
var h = Math.min(b.begin, this.begin); | |
b = Math.max(b.end, this.end) - h + 1; | |
return new a(h, b) | |
}; | |
a.prototype.subtract = function (b) { | |
if (this.equals(b)) return []; | |
if (this.contains(b)) { | |
var h = [], | |
g = new a(this.begin, b.begin - this.begin); | |
b = new a(b.end + 1, this.end - b.end); | |
g.length && h.push(g); | |
b.length && h.push(b); | |
return h | |
} | |
return b.contains(this) ? b.subtract(this) : this.intersects(b) ? this.add(b).subtract(this.intersect(b)) : [this, b] | |
}; | |
a.prototype.subtractMany = function (a) { | |
a = Array.isArray(a) ? a : b.call(arguments); | |
for (var h = [], g = this, d = 0, c = a.length; d < c; d++) { | |
var k = a[d]; | |
if (!g.intersects(k)) break; | |
g = g.subtract(g.intersect(k)); | |
switch (g.length) { | |
case 2: | |
h.push(g[0]); | |
g = g[1]; | |
break; | |
case 1: | |
g = g[0]; | |
break; | |
default: | |
return [] | |
} | |
} | |
h.push(g); | |
return h | |
}; | |
a.prototype.fill = function (b) { | |
if (this.intersects(b)) return new a(NaN, 0); | |
var h; | |
Math.min(this.begin, b.begin) == this.begin ? h = this : (h = b, b = this); | |
return new a(h.end + 1, b.begin - h.end - 1) | |
}; | |
a.prototype.splice = function (b) { | |
if (!this.intersects(b)) return this; | |
b = this.subtract(b); | |
if (b.length) { | |
if (1 == b.length) return new a(0, | |
b[0].length); | |
var h = b[0]; | |
return h.add(new a(h.last, b[1].length)) | |
} | |
return a(NaN, 0) | |
}; | |
a.prototype.split = function (b) { | |
if (b >= this.length) return [new a(this.begin, this.length)]; | |
for (var h = [], g = this.begin, d = this.length; d;) { | |
if (d < b) { | |
h.push(new a(g, d)); | |
break | |
} else h.push(new a(g, b)); | |
d -= b; | |
g += b | |
} | |
return h | |
}; | |
a.prototype.findContainer = function (a) { | |
a = Array.isArray(a) ? a : b.call(arguments); | |
for (var h = 0, g = a.length; h < g; h++) | |
if (a[h].contains(this)) return a[h]; | |
return null | |
}; | |
a.simplify = function (a) { | |
a = Array.isArray(a) ? a : b.call(arguments); | |
var h = [], | |
g = null; | |
a.sort(function (a, c) { | |
return a.begin - c.begin | |
}); | |
for (var d = 0, c = a.length; d < c; d++) { | |
var k = a[d]; | |
if (!isNaN(k.begin) && !isNaN(k.length) && k.length) { | |
if (g) | |
if (g.equals(k)) continue; | |
else g.intersects(k) || g.contiguous(k) ? k = g.add(k) : h.push(g); | |
g = k | |
} | |
} | |
g && h.push(g); | |
return h | |
}; | |
a.splice = function (a, h) { | |
h = Array.isArray(h) ? h : b.call(arguments, 1); | |
var g = [], | |
d = null; | |
h.sort(function (a, c) { | |
return a.begin - c.begin | |
}); | |
for (var c = 0, k = h.length; c < k; c++) { | |
var s = h[c].splice(a); | |
isNaN(s.begin) || isNaN(s.length) || !s.length || (d && (d.intersects(s) || | |
d.contiguous(s) ? s = d.add(s) : g.push(d)), d = s) | |
} | |
d && g.push(d); | |
return g | |
}; | |
l.exports = a | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/requestqueue.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a() { | |
this._ids = []; | |
this._values = {} | |
} | |
a.prototype.push = function (a, b) { | |
var h = this._ids, | |
g = this._values; | |
a = a.toString(); | |
g[a] || h.push(a); | |
(g[a] || (g[a] = [])).push(b); | |
return this | |
}; | |
a.prototype.takeIds = function (a) { | |
var b = this._ids; | |
a = void 0 != a ? a : b.length; | |
return b.splice(0, a) | |
}; | |
a.prototype.takeValues = function (a, b) { | |
var h = this._values[a]; | |
if (!h) return []; | |
b = void 0 != b ? b : h.length; | |
var g = h.splice(0, b); | |
h.length || (this._values[a] = null); | |
return g | |
}; | |
l.exports = a | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/observers/rootlist.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(a, b, h) { | |
this._itemLoader = a; | |
this._list = null; | |
this._property = b; | |
this._suppressEvents = !! h | |
} | |
a.prototype.onBeforeMutate = function (a) { | |
this._list = a.toFullArray() | |
}; | |
a.prototype.onMutate = function (a) { | |
for (var b = 0, h = a.length; b < h; b++) this._applyMutation(a[b]) | |
}; | |
a.prototype._applyMutation = function (a) { | |
if ("move" != | |
a.type) { | |
var b = a.items; | |
"remove" == a.type && (b = this._list.splice(a.begin, a.length)); | |
for (var h = [], g = b.length; g--;) h[g] = b[g].uri; | |
var d = this._property, | |
c = this._suppressEvents; | |
this._itemLoader(h).then(function (b) { | |
for (var g = 0, m = h.length; g < m; g++) { | |
var f = b[h[g]]; | |
if (f) { | |
var t = "insert" == a.type; | |
f[d] != t && (f[d] = "insert" == a.type, c || f.fireEvent("change", { | |
property: d, | |
oldValue: !t, | |
newValue: t | |
})) | |
} | |
} | |
}) | |
} | |
}; | |
l.exports = a | |
})() | |
}, | |
"node_modules/cosmos-router-js/node_modules/js-common/src/helpers.js": function (b, l, f, n, p, r) { | |
f.shallowCopy = | |
function (a) { | |
function b() {} | |
b.prototype = a; | |
return new b | |
}; | |
f.inherit = function (a, b) { | |
function m() {} | |
var h = b.prototype; | |
m.prototype = a._super = h; | |
m.prototype.constructor = b; | |
a.prototype = new m; | |
a.prototype._super = function (a, d) { | |
d = "arguments" == typeof d || Array.isArray(d) ? d : slice.call(arguments, 1); | |
return h[a].apply(this, d) | |
} | |
} | |
}, | |
"node_modules/cosmos-router-js/node_modules/js-common/src/environment.js": function (b, l, f, n, p, r) { | |
b = { | |
addEventListener: function () {}, | |
postMessage: function () {}, | |
location: { | |
hostname: "", | |
origin: "", | |
protocol: "" | |
} | |
}; | |
f.environment = n.window || b | |
}, | |
"node_modules/cosmos-router-js/node_modules/js-common/src/postrouter.js": function (b, l, f, n, p, r) { | |
function a(a) { | |
var b = a.data; | |
if ("string" == typeof b) try { | |
b = JSON.parse(b) | |
} catch (g) { | |
return | |
} | |
var d = q[b.type]; | |
d && d.call(this, a, b) | |
} | |
f.MessageHandler; | |
b = b("node_modules/cosmos-router-js/node_modules/js-common/src/environment.js").environment; | |
var q = {}; | |
b.attachEvent && !b.addEventListener ? b.attachEvent("onmessage", a) : b.addEventListener("message", a, !1); | |
f.addMessageHandler = function (a, b) { | |
if (q[a]) throw Error('Rehandling of message "' + | |
a + '" not allowed.'); | |
q[a] = b | |
}; | |
f.removeMessageHandler = function (a, b) { | |
return q[a] == b ? (q[a] = null, !0) : !1 | |
} | |
}, | |
"node_modules/cosmos-router-js/node_modules/js-common/src/defer.js": function (b, l, f, n, p, r) { | |
l = b("node_modules/cosmos-router-js/node_modules/js-common/src/postrouter.js"); | |
b = b("node_modules/cosmos-router-js/node_modules/js-common/src/environment.js").environment; | |
var a = [], | |
q = b.postMessage.bind(b, '{"type": "execute_deferreds"}', b.location.origin || [b.location.protocol, b.location.hostname].join("//")); | |
l.addMessageHandler("execute_deferreds", | |
function () { | |
var b = a.splice(0); | |
if (b.length) | |
for (var h = 0, g = b.length; h < g; h++) { | |
var d = !0; | |
try { | |
b[h](), d = !1 | |
} finally { | |
d && (d = !a.length, a = b.slice(++h).concat(a), d && q()) | |
} | |
} | |
}); | |
f.defer = function (b) { | |
var h = !a.length; | |
a.push(b); | |
h && q() | |
} | |
}, | |
"node_modules/cosmos-router-js/node_modules/js-common/src/promise.js": function (b, l, f, n, p, r) { | |
function a(a, b) { | |
a.then(function (a) { | |
b.fulfill(a) | |
}, function (a) { | |
b.fail(a) | |
}) | |
} | |
function q() { | |
this._state = h.UNFULFILLED; | |
this._value = null; | |
this._handlers = []; | |
this._deferred = !1 | |
} | |
b = b("node_modules/cosmos-router-js/node_modules/js-common/src/defer.js").defer; | |
var m = Array.prototype.slice, | |
h = { | |
UNFULFILLED: 0, | |
FULFILLED: 1, | |
FAILED: 2 | |
}; | |
f.Promise = q; | |
q.defer = "function" == typeof setImmediate ? function (a) { | |
setImmediate(a) | |
} : b || function (a) { | |
setTimeout(a, 0) | |
}; | |
q.prototype.isUnfulfilled = function () { | |
return this._state == h.UNFULFILLED | |
}; | |
q.prototype.isFulfilled = function () { | |
return this._state == h.FULFILLED | |
}; | |
q.prototype.isFailed = function () { | |
return this._state == h.FAILED | |
}; | |
q.prototype.fulfill = function (a) { | |
var b = this; | |
this._state === h.UNFULFILLED && (this._value = a, this._state = h.FULFILLED, this._deferred || | |
(q.defer(function () { | |
b._runHandlers() | |
}), this._deferred = !0)) | |
}; | |
q.prototype.fail = function (a) { | |
var b = this; | |
this._state === h.UNFULFILLED && (this._value = a, this._state = h.FAILED, this._deferred || (q.defer(function () { | |
b._runHandlers() | |
}), this._deferred = !0)) | |
}; | |
q.prototype.then = function (a, b) { | |
var c = this, | |
k = new q; | |
this._handlers.push({ | |
fulfilled: a, | |
failed: b, | |
promise: k | |
}); | |
this._state === h.UNFULFILLED || this._deferred || (q.defer(function () { | |
c._runHandlers() | |
}), this._deferred = !0); | |
return k | |
}; | |
q.prototype.pipe = function (a) { | |
this.then(function (b) { | |
a.fulfill(b) | |
}, | |
function (b) { | |
a.fail(b) | |
}) | |
}; | |
q.prototype._runHandlers = function () { | |
this._deferred = !1; | |
var b = this._value; | |
if (this._state != h.UNFULFILLED) | |
for (var d = this._state === h.FULFILLED, c = this._handlers.splice(0), k = 0, s = c.length; k < s; k++) { | |
var m = c[k], | |
q = m[d ? "fulfilled" : "failed"], | |
m = m.promise; | |
if (q && "function" == typeof q) { | |
try { | |
var f = q(b) | |
} catch (l) { | |
m.fail(l); | |
continue | |
} | |
f && "function" == typeof f.then ? a(f, m) : m.fulfill(f) | |
} else b && "function" == typeof b.then ? a(b, m) : d ? m.fulfill(b) : m.fail(b) | |
} | |
}; | |
q.prototype.catchError = function (a) { | |
return this.then(null, | |
a) | |
}; | |
q.prototype.get = function (a) { | |
var b = new q; | |
this.then(function (c) { | |
b.fulfill(c[a]) | |
}, function (a) { | |
b.fail(a) | |
}); | |
return b | |
}; | |
q.prototype.call = function (a, b) { | |
var c = m.call(arguments, 1), | |
k = new q; | |
this.then(function (b) { | |
try { | |
k.fulfill(b[a].apply(b, c)) | |
} catch (d) { | |
k.fail(d) | |
} | |
}, function (a) { | |
k.fail(a) | |
}); | |
return k | |
}; | |
q.prototype.thenSpread = function (a, b) { | |
return this.then(function (c) { | |
return Array.isArray(c) ? a.apply(this, c) : a.call(this, c) | |
}, b) | |
}; | |
q.join = function (a) { | |
a = Array.isArray(a) ? a : m.call(arguments); | |
for (var b = new q, c = a.length, | |
k = [], h = function (a, g) { | |
k[a] = g; | |
c--; | |
c || b.fulfill(k) | |
}, f = 0, l = c; f < l; f++) a[f].then(h.bind(null, f)); | |
return b | |
}; | |
q.group = function (a) { | |
a = Array.isArray(a) ? a : m.call(arguments); | |
for (var b = new q, c = 0, k = a.length; c < k; c++) b.pipe(a[c]); | |
return b | |
} | |
}, | |
"node_modules/cosmos-router-js/node_modules/js-common/index.js": function (b, l, f, n, p, r) { | |
f.defer = b("node_modules/cosmos-router-js/node_modules/js-common/src/defer.js"); | |
f.helpers = b("node_modules/cosmos-router-js/node_modules/js-common/src/helpers.js"); | |
f.postrouter = b("node_modules/cosmos-router-js/node_modules/js-common/src/postrouter.js"); | |
f.promise = b("node_modules/cosmos-router-js/node_modules/js-common/src/promise.js"); | |
f.environment = b("node_modules/cosmos-router-js/node_modules/js-common/src/environment.js") | |
}, | |
"node_modules/cosmos-router-js/node_modules/cosmos-common-js/src/message.js": function (b, l, f, n, p, r) { | |
function a(a, b, h) { | |
if (null == a) throw new TypeError("Invalid `uri` argument for Message."); | |
this._uri = a; | |
this._headers = {}; | |
this._body = this._encodeBody(h || ""); | |
b && this._setHeaders(b) | |
} | |
f.Headers; | |
f.Body; | |
f.SerializedMessage; | |
f.Message = a; | |
a.fromObject = | |
function (b) { | |
return b && b.uri ? new a(b.uri, b.headers, b.body) : null | |
}; | |
a.prototype._encodeBody = function (a) { | |
"string" != typeof a && (a = JSON.stringify(a)); | |
return a | |
}; | |
a.prototype.getURI = function () { | |
return this._uri | |
}; | |
a.prototype.getMimeType = function () { | |
return this._headers.accept | |
}; | |
a.prototype.getHeader = function (a) { | |
return this._headers[a.toLowerCase()] || null | |
}; | |
a.prototype.getHeaders = function () { | |
var a = this._headers, | |
b = {}, h; | |
for (h in a) a.hasOwnProperty(h) && (b[h] = a[h]); | |
return b | |
}; | |
a.prototype._setHeaders = function (a) { | |
var b = this._headers, | |
h; | |
for (h in a) a.hasOwnProperty(h) && (b[h.toLowerCase()] = a[h]); | |
return this | |
}; | |
a.prototype.getBody = function () { | |
return this._body | |
}; | |
a.prototype.getJSONBody = function () { | |
try { | |
return JSON.parse(this._body) | |
} catch (a) { | |
return null | |
} | |
}; | |
a.prototype.copy = function (b, m) { | |
return new a(this._uri, this._copyHeaders(b), "undefined" != typeof m ? m : this._body) | |
}; | |
a.prototype._copyHeaders = function (a) { | |
var b; | |
if (a) { | |
var h = this._headers, | |
g; | |
b = {}; | |
for (g in h) h.hasOwnProperty(g) && (b[g] = h[g]); | |
for (g in a) a.hasOwnProperty(g) && (b[g.toLowerCase()] = a[g]) | |
} else b = | |
this._headers; | |
return b | |
}; | |
a.prototype.serialize = function () { | |
return this.toJSON() | |
}; | |
a.prototype.toJSON = function () { | |
return { | |
uri: this._uri, | |
headers: this._headers, | |
body: this._body | |
} | |
} | |
}, | |
"node_modules/spotify-eventemitter/node_modules/spotify-deferred/node_modules/spotify-postrouter/src/postrouter.js": function (b, l, f, n, p, r) { | |
function a(a) { | |
var b = g[a.type]; | |
b && b.fn.call(this, a) | |
} | |
function q(a) { | |
var b = a.data; | |
if ("string" == typeof b) try { | |
b = JSON.parse(b) | |
} catch (d) { | |
return | |
} | |
var h = g[b.type]; | |
!h || "*" != h.origin && a.origin !== h.origin || | |
h.fn.call(this, b, a) | |
} | |
var m = m ? m : setTimeout, | |
h = void 0; | |
"undefined" !== typeof window && (h = window.location.origin || window.location.protocol + "//" + window.location.hostname); | |
var g = {}, d = !1; | |
l.exports = { | |
addMessageHandler: function (a, b, s) { | |
"undefined" === typeof window || d || (window.attachEvent && !window.addEventListener ? window.attachEvent("onmessage", q) : window.addEventListener("message", q, !1), d = !0); | |
s || (s = h); | |
if (g[a]) throw Error('Rehandling of message "' + a + '" not allowed.'); | |
g[a] = { | |
fn: b, | |
origin: s | |
} | |
}, | |
removeMessageHandler: function (a, | |
b) { | |
return !g[a] || b && g[a].fn !== b ? !1 : (g[a] = null, !0) | |
}, | |
sendMessage: function (c, b, d, g) { | |
b = b || {}; | |
b.type = c; | |
if ("undefined" === typeof window) return m(a.bind(null, b)); | |
d = d || window; | |
g || (g = h); | |
d.postMessage(JSON.stringify(b), g) | |
}, | |
WINDOW_ORIGIN: h | |
} | |
}, | |
"node_modules/spotify-eventemitter/node_modules/spotify-deferred/src/deferred.js": function (b, l, f, n, p, r) { | |
var a = b("node_modules/spotify-eventemitter/node_modules/spotify-deferred/node_modules/spotify-postrouter/src/postrouter.js"), | |
q = []; | |
a.addMessageHandler("execute_deferreds", | |
function () { | |
var a = q.splice(0); | |
if (a.length) | |
for (var b = 0, g = a.length; b < g; b++) try { | |
a[b]() | |
} finally { | |
null | |
} | |
}); | |
l.exports = function (b) { | |
var h = !q.length; | |
q.push(b); | |
h && a.sendMessage("execute_deferreds") | |
} | |
}, | |
"node_modules/spotify-eventemitter/src/eventemitter.js": function (b, l, f, n, p, r) { | |
function a() { | |
this._events = {} | |
} | |
var q = b("node_modules/spotify-eventemitter/node_modules/spotify-deferred/src/deferred.js"); | |
a.prototype.addEvent = function (a, b) { | |
var g = this._events[a] || (this._events[a] = []); | |
if (-1 != g.indexOf(b)) return this; | |
g.push(b); | |
return this | |
}; | |
a.prototype.addEvents = function (a) { | |
for (var b in a) a.hasOwnProperty(b) && this.addEvent(b, a[b]) | |
}; | |
a.prototype.addOnceEvent = function (a, b) { | |
var g = this, | |
d = function () { | |
var c = b.apply(this, arguments); | |
g.removeEvent(a, d); | |
return c | |
}; | |
return this.addEvent(a, d) | |
}; | |
a.prototype.removeEvent = function (a, b) { | |
var g = this._events[a]; | |
if (!g || !g.length) return this; | |
var d = g.indexOf(b); | |
if (-1 == d) return this; | |
g.splice(d, 1); | |
return this | |
}; | |
a.prototype.removeEvents = function (a) { | |
for (var b in a) a.hasOwnProperty(b) && this.removeEvent(b, | |
a[b]) | |
}; | |
a.prototype.fireEvent = function (a, b, g) { | |
var d = this; | |
g ? this.fireEventSync(a, b) : q(function () { | |
d.fireEventSync(a, b) | |
}) | |
}; | |
a.prototype.fireEventSync = function (a, b) { | |
var g = this._events[a]; | |
if (!g || !g.length) return this; | |
g = g.slice(0); | |
Array.isArray(b) || (b = [b]); | |
for (var d = g.length; d--;) g[d].apply(this, b); | |
return this | |
}; | |
l.exports = a | |
}, | |
"src/app-manager.js": function (b, l, f, n, p, r) { | |
function a(b, c, k) { | |
if (!(this instanceof a)) return new a(b, c, k); | |
h.call(this); | |
this._frame = b; | |
this._id = c.id; | |
this._uri = c; | |
this._uriApp = m.applicationLink(c.id); | |
this._uriString = c.toURI(); | |
this._args = a.formatArgs(this._id, c.args.slice(0)); | |
this._dispatcher = k; | |
this._data = {} | |
} | |
function q(a) { | |
h.call(this); | |
this._dispatcher = a; | |
this._apps = new g; | |
this._windows = new g; | |
this._multiInstance = {} | |
} | |
var m = Spotify.Link; | |
l = b("node_modules/spotify-inheritance/inherit.js"); | |
var h = b("node_modules/spotify-eventemitter/src/eventemitter.js"), | |
g = b("node_modules/spotify-weakmap/src/weakmap.js"); | |
l(a, h); | |
f.Application = a; | |
a.formatArgs = function (a, c) { | |
if ("user" == a || "playlist" == a) switch (c[1]) { | |
case "playlist": | |
c = [c[0], c[2]]; | |
break; | |
case "starred": | |
c = [c[0], "starred"]; | |
break; | |
case "toplist": | |
c = [c[0], "toplist"]; | |
break; | |
case "top": | |
c = [c[0], "top", c[2]] | |
} | |
for (var b = c.length; b--;) c[b] = encodeURIComponent(c[b]); | |
return c | |
}; | |
a.prototype.setInfo = function (a) { | |
this._id = a.id; | |
this._uri = a; | |
this._uriApp = m.applicationLink(a.id); | |
this._uriString = a.toURI() | |
}; | |
a.prototype.getFrame = function () { | |
return this._frame | |
}; | |
a.prototype.getId = function () { | |
return this._id | |
}; | |
a.prototype.getURI = function () { | |
return this._uriString | |
}; | |
a.prototype.getLink = function () { | |
return this._uri | |
}; | |
a.prototype.getAppLink = function () { | |
return this._uriApp | |
}; | |
a.prototype.setArgs = function (b) { | |
var c = this._args; | |
b = this._args = a.formatArgs(this._id, b.slice(0)); | |
var k = b.length; | |
if (k != c.length) this.fireEventSync("argumentsChange", { | |
arguments: this.getArgsDecoded() | |
}); | |
else | |
for (; k--;) | |
if (b[k] != c[k]) { | |
this.fireEventSync("argumentsChange", { | |
arguments: this.getArgsDecoded() | |
}); | |
break | |
} | |
}; | |
a.prototype.getArgs = function () { | |
return this._args | |
}; | |
a.prototype.getArgsDecoded = function () { | |
var a = this._args; | |
if (!a.length) return []; | |
for (var c = a.length, | |
b = Array(b); c--;) b[c] = decodeURIComponent(a[c]); | |
return b | |
}; | |
a.prototype.getData = function (a) { | |
var b = this._data; | |
return a in b ? b[a] : null | |
}; | |
a.prototype.setData = function (a, b) { | |
this._data[a] = b; | |
return this | |
}; | |
a.prototype.activate = function () { | |
this._active || (this._active = !0, this.fireEventSync("activate")) | |
}; | |
a.prototype.deactivate = function () { | |
this._active && (this._active = !1, this.fireEventSync("deactivate")) | |
}; | |
a.prototype.destroy = function () { | |
this.fireEventSync("destroy"); | |
this._data = this._frame = null | |
}; | |
a.prototype.request = function (a, | |
b, k, g) { | |
k ? k.origin = this._uriString : k = { | |
origin: this._uriString | |
}; | |
return this._dispatcher.request(a, b, k, g) | |
}; | |
a.prototype.create = function (a, b, k) { | |
return this.request("CREATE", a, b, k) | |
}; | |
a.prototype.flush = function (a, b, k) { | |
return this.request("FLUSH", a, b, k) | |
}; | |
a.prototype.get = function (a, b, k) { | |
return this.request("GET", a, b, k) | |
}; | |
a.prototype.remove = function (a, b, k) { | |
return this.request("REMOVE", a, b, k) | |
}; | |
a.prototype.update = function (a, b, k) { | |
return this.request("UPDATE", a, b, k) | |
}; | |
l(q, h); | |
f.ApplicationManager = q; | |
q.prototype.setMultiInstance = | |
function (a) { | |
this._multiInstance[a] = !0 | |
}; | |
q.prototype.unsetMultiInstance = function (a) { | |
this._multiInstance[a] = null | |
}; | |
q.prototype.create = function (b, c) { | |
if (c.contentWindow) this._windows.set(c.contentWindow, c); | |
else { | |
var k = this, | |
g = function () { | |
k._windows.set(c.contentWindow, c); | |
k.fireEvent("windowAssociated", { | |
frame: c, | |
window: c.contentWindow | |
}); | |
this.removeEventListener("load", g, !1) | |
}; | |
c.addEventListener("load", g, !1) | |
} | |
var h = b.id, | |
m = this._apps.get(c); | |
!this._multiInstance[h] && m ? (m.setInfo(b), m.setArgs(b.args), this.fireEventSync("update", { | |
link: b, | |
app: m | |
})) : (m = new a(c, b, this._dispatcher), this._apps.set(c, m), this.fireEventSync("create", { | |
link: b, | |
app: m | |
})); | |
return m | |
}; | |
q.prototype.destroy = function (a) { | |
var b = this._apps, | |
k = this._apps.get(a); | |
this.deactivate(a); | |
k.destroy(); | |
b.remove(a); | |
this._windows.remove(this._windows.getKey(a)); | |
this.fireEventSync("destroy", { | |
link: k.getLink(), | |
app: k | |
}) | |
}; | |
q.prototype.activate = function (a) { | |
var b = this._apps.get(a); | |
if (!b) return !1; | |
this._currentApp && this.deactivate(this._currentApp); | |
b.activate(); | |
this._currentApp = a; | |
return !0 | |
}; | |
a.prototype.isActive = function () { | |
return this._active | |
}; | |
q.prototype.deactivate = function (a) { | |
a = this._apps.get(a); | |
if (!a) return !1; | |
a.deactivate(); | |
return !0 | |
}; | |
q.prototype.getFromFrame = function (a) { | |
return this._apps.get(a) | |
}; | |
q.prototype.getFromWindow = function (a) { | |
return this._apps.get(this._windows.get(a)) | |
} | |
}, | |
"src/shuttle.js": function (b, l, f, n, p, r) { | |
f.Application = b("src/app-manager.js").Application; | |
f.ApplicationManager = b("src/app-manager.js").ApplicationManager; | |
f.ApplicationViewLogger = b("src/app-view-logger.js").ApplicationViewLogger | |
}, | |
"node_modules/spotify-bridge/src/shell/entities/base.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(b) { | |
if (!(this instanceof a)) return new a(b); | |
m.call(this); | |
this.uri = b.toString() | |
} | |
var f = b("node_modules/spotify-inheritance/inherit.js"), | |
m = b("node_modules/spotify-eventemitter/src/eventemitter.js"); | |
f(a, m); | |
l.exports = a | |
})() | |
}, | |
"node_modules/spotify-promise/node_modules/spotify-deferred/node_modules/spotify-postrouter/src/postrouter.js": function (b, l, f, n, p, r) { | |
function a(a) { | |
var b = g[a.type]; | |
b && b.fn.call(this, | |
a) | |
} | |
function q(a) { | |
var b = a.data; | |
if ("string" == typeof b) try { | |
b = JSON.parse(b) | |
} catch (d) { | |
return | |
} | |
var h = g[b.type]; | |
!h || "*" != h.origin && a.origin !== h.origin || h.fn.call(this, b, a) | |
} | |
var m = m ? m : setTimeout, | |
h = void 0; | |
"undefined" !== typeof window && (h = window.location.origin || window.location.protocol + "//" + window.location.hostname); | |
var g = {}, d = !1; | |
l.exports = { | |
addMessageHandler: function (a, b, s) { | |
"undefined" === typeof window || d || (window.attachEvent && !window.addEventListener ? window.attachEvent("onmessage", q) : window.addEventListener("message", | |
q, !1), d = !0); | |
s || (s = h); | |
if (g[a]) throw Error('Rehandling of message "' + a + '" not allowed.'); | |
g[a] = { | |
fn: b, | |
origin: s | |
} | |
}, | |
removeMessageHandler: function (a, b) { | |
return !g[a] || b && g[a].fn !== b ? !1 : (g[a] = null, !0) | |
}, | |
sendMessage: function (b, d, g, f) { | |
d = d || {}; | |
d.type = b; | |
if ("undefined" === typeof window) return m(a.bind(null, d)); | |
g = g || window; | |
f || (f = h); | |
g.postMessage(JSON.stringify(d), f) | |
}, | |
WINDOW_ORIGIN: h | |
} | |
}, | |
"node_modules/spotify-promise/node_modules/spotify-deferred/src/deferred.js": function (b, l, f, n, p, r) { | |
var a = b("node_modules/spotify-promise/node_modules/spotify-deferred/node_modules/spotify-postrouter/src/postrouter.js"), | |
q = []; | |
a.addMessageHandler("execute_deferreds", function () { | |
var a = q.splice(0); | |
if (a.length) | |
for (var b = 0, g = a.length; b < g; b++) try { | |
a[b]() | |
} finally { | |
null | |
} | |
}); | |
l.exports = function (b) { | |
var h = !q.length; | |
q.push(b); | |
h && a.sendMessage("execute_deferreds") | |
} | |
}, | |
"node_modules/spotify-promise/src/promise.js": function (b, l, f, n, p, r) { | |
function a(a, b) { | |
a.then(function (a) { | |
b.fulfill(a) | |
}, function (a) { | |
b.fail(a) | |
}) | |
} | |
function q() { | |
this._state = h.UNFULFILLED; | |
this._value = null; | |
this._handlers = []; | |
this._deferred = !1 | |
} | |
var m = Array.prototype.slice; | |
b = b("node_modules/spotify-promise/node_modules/spotify-deferred/src/deferred.js"); | |
var h = { | |
UNFULFILLED: 0, | |
FULFILLED: 1, | |
FAILED: 2 | |
}; | |
q.defer = "function" == typeof setImmediate ? function (a) { | |
setImmediate(a) | |
} : b; | |
q.prototype.isUnfulfilled = function () { | |
return this._state == h.UNFULFILLED | |
}; | |
q.prototype.isFulfilled = function () { | |
return this._state == h.FULFILLED | |
}; | |
q.prototype.isFailed = function () { | |
return this._state == h.FAILED | |
}; | |
q.prototype.fulfill = function (a) { | |
var b = this; | |
this._state === h.UNFULFILLED && (this._value = a, this._state = h.FULFILLED, this._deferred || (q.defer(function () { | |
b._runHandlers() | |
}), this._deferred = !0)) | |
}; | |
q.prototype.fail = function (a) { | |
var b = this; | |
this._state === h.UNFULFILLED && (this._value = a, this._state = h.FAILED, this._deferred || (q.defer(function () { | |
b._runHandlers() | |
}), this._deferred = !0)) | |
}; | |
q.prototype.then = function (a, b) { | |
var c = this, | |
k = new q; | |
this._handlers.push({ | |
fulfilled: a, | |
failed: b, | |
promise: k | |
}); | |
this._state === h.UNFULFILLED || this._deferred || (q.defer(function () { | |
c._runHandlers() | |
}), this._deferred = !0); | |
return k | |
}; | |
q.prototype.pipe = function (a) { | |
this.then(function (b) { | |
a.fulfill(b) | |
}, function (b) { | |
a.fail(b) | |
}) | |
}; | |
q.prototype._runHandlers = | |
function () { | |
this._deferred = !1; | |
var b = this._value; | |
if (this._state != h.UNFULFILLED) | |
for (var d = this._state === h.FULFILLED, c = this._handlers.splice(0), k = d ? "fulfilled" : "failed", s = 0, m = c.length; s < m; s++) { | |
var f = c[s], | |
q = f[k], | |
f = f.promise; | |
if (q && "function" == typeof q) { | |
try { | |
var l = q(b) | |
} catch (w) { | |
f.fail(w); | |
continue | |
} | |
l && "function" == typeof l.then ? a(l, f) : f.fulfill(l) | |
} else b && "function" == typeof b.then ? a(b, f) : d ? f.fulfill(b) : f.fail(b) | |
} | |
}; | |
q.prototype.catchError = function (a) { | |
return this.then(null, a) | |
}; | |
q.prototype.get = function (a) { | |
var b = | |
new q; | |
this.then(function (c) { | |
a in c ? b.fulfill(c[a]) : b.fail(new TypeError('No property "' + a + '" in object.')) | |
}, function (a) { | |
b.fail(a) | |
}); | |
return b | |
}; | |
q.prototype.access = function (a) { | |
a = Array.isArray(a) ? a : m.call(arguments); | |
for (var b = this, c = 0, k = a.length; c < k; c++) b = b.get(a[c]); | |
return b | |
}; | |
q.prototype.call = function (a, b) { | |
var c = m.call(arguments, 1), | |
k = new q; | |
this.then(function (b) { | |
try { | |
k.fulfill(b[a].apply(b, c)) | |
} catch (d) { | |
k.fail(d) | |
} | |
}, function (a) { | |
k.fail(a) | |
}); | |
return k | |
}; | |
q.prototype.thenSpread = function (a, b) { | |
return this.then(function (b) { | |
return Array.isArray(b) ? | |
a.apply(this, b) : a.call(this, b) | |
}, b) | |
}; | |
q.join = function (a) { | |
a = Array.isArray(a) ? a : m.call(arguments); | |
for (var b = new q, c = a.length, k = [], h = !1, f = function (a, g) { | |
h || (k[a] = g, c--, c || b.fulfill(k)) | |
}, l = function (a) { | |
h || (h = !0, b.fail(a)) | |
}, t = 0, v = c; t < v; t++) { | |
var w = a[t]; | |
w && w.then ? w.then(f.bind(null, t), l) : f(t, w) | |
} | |
return b | |
}; | |
q.group = function (a) { | |
a = Array.isArray(a) ? a : m.call(arguments); | |
for (var b = new q, c = 0, k = a.length; c < k; c++) b.pipe(a[c]); | |
return b | |
}; | |
l.exports = q | |
}, | |
"node_modules/spotify-bridge/src/shell/lists/mutator.js": function (b, l, f, | |
n, p, r) { | |
(function () { | |
function a(b) { | |
if (!(this instanceof a)) return new a(b); | |
if (!b) return this; | |
for (var d in b) this[d] = b[d] | |
} | |
function f(b) { | |
if (!(this instanceof f)) return new f(b); | |
a.call(this, b) | |
} | |
function m(a, b, d, g, h) { | |
if (!(this instanceof m)) return new m(a, b, d, g, h); | |
this._applied = !1; | |
this._applyMutation = a; | |
this._checkVersion = b; | |
this._ruleset = d; | |
this._version = g; | |
this._length = h; | |
this._changes = [] | |
} | |
var h = b("node_modules/spotify-promise/src/promise.js"), | |
g = b("node_modules/spotify-inheritance/inherit.js"), | |
d = { | |
SUCCESS: "success", | |
ALLOWED: "allowed", | |
FORBIDDEN: "forbidden", | |
LIST_FULL: "listFull", | |
OUT_OF_BOUNDS: "outOfBounds", | |
EXPIRED: "expired" | |
}; | |
a.prototype.add = d.ALLOWED; | |
a.prototype.insert = d.ALLOWED; | |
a.prototype.remove = d.ALLOWED; | |
a.prototype.move = d.ALLOWED; | |
g(f, a); | |
a.Immutable = f; | |
f.prototype.add = d.FORBIDDEN; | |
f.prototype.insert = d.FORBIDDEN; | |
f.prototype.remove = d.FORBIDDEN; | |
f.prototype.move = d.FORBIDDEN; | |
m.prototype.isApplied = function () { | |
return !!this._applied | |
}; | |
m.prototype.isExpired = function () { | |
return !this._checkVersion(this._version) | |
}; | |
m.prototype.canInsert = | |
function (a, b) { | |
return this._ruleset.insert == d.FORBIDDEN ? d.FORBIDDEN : this._applied || !this._checkVersion(this._version) ? d.EXPIRED : 0 > a || a > this._length ? d.OUT_OF_BOUNDS : d.ALLOWED | |
}; | |
m.prototype.canAdd = function (a) { | |
return this._ruleset.add == d.FORBIDDEN ? d.FORBIDDEN : this._applied || !this._checkVersion(this._version) ? d.EXPIRED : d.ALLOWED | |
}; | |
m.prototype.canRemove = function (a, b) { | |
return this._ruleset.remove == d.FORBIDDEN ? d.FORBIDDEN : this._applied || !this._checkVersion(this._version) ? d.EXPIRED : 0 > a || a > this._length || a + b > this._length ? | |
d.OUT_OF_BOUNDS : d.ALLOWED | |
}; | |
m.prototype.canMove = function (a, b, g) { | |
return this._ruleset.move == d.FORBIDDEN ? d.FORBIDDEN : this._applied || !this._checkVersion(this._version) ? d.EXPIRED : 0 > a || a > this._length || 0 > b || b > this._length || a + g > this._length ? d.OUT_OF_BOUNDS : d.ALLOWED | |
}; | |
m.prototype.apply = function () { | |
var a = new h; | |
if (this._applied) return a.fulfill(d.EXPIRED), a; | |
this._applied = !0; | |
this._applyMutation(this._version, this._changes).pipe(a); | |
return a | |
}; | |
m.prototype.insert = function (a, b, g) { | |
var h = this.canInsert(a, b.length); | |
if (h != | |
d.ALLOWED) return h; | |
if (!b.length) return d.SUCCESS; | |
this._length += b.length; | |
a = { | |
type: "insert", | |
begin: a, | |
items: b.slice(0) | |
}; | |
this._changes.push(a); | |
g && g.push(a); | |
return d.SUCCESS | |
}; | |
m.prototype.add = function (a, b) { | |
var g = this.canAdd(a.length); | |
return g != d.ALLOWED ? g : a.length ? this.insert(this._length, a, b) : d.SUCCESS | |
}; | |
m.prototype.remove = function (a, b, g) { | |
var h = this.canRemove(a, b); | |
if (h != d.ALLOWED) return h; | |
if (0 == b) return d.SUCCESS; | |
this._length -= b; | |
a = { | |
type: "remove", | |
begin: a, | |
length: b | |
}; | |
this._changes.push(a); | |
g && g.push(a); | |
return d.SUCCESS | |
}; | |
m.prototype.move = function (a, b, g, h) { | |
var m = this.canMove(a, b, g); | |
if (m != d.ALLOWED) return m; | |
if (a == b || 0 == g) return d.SUCCESS; | |
a = { | |
type: "move", | |
begin: a, | |
end: b, | |
length: g | |
}; | |
this._changes.push(a); | |
h && h.push(a); | |
return d.SUCCESS | |
}; | |
l.exports = { | |
Mutation: void 0, | |
MutationResult: d, | |
MutationSet: void 0, | |
MutationRuleset: a, | |
Mutator: m, | |
MutationApplicator: void 0 | |
} | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/lists/base.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(b) { | |
if (!(this instanceof a)) return new a(b); | |
this._base = b || null; | |
this._descriptor = | |
null; | |
this._list = []; | |
this._length = null; | |
this._loadLimit = 200; | |
this._loadedRanges = []; | |
this._loadedState = c.UNLOADED; | |
this._observers = []; | |
this._ruleset = new s; | |
this._snapshotLimit = 1E3; | |
this._snapshotQueue = []; | |
this._version = 0 | |
} | |
var f = b("node_modules/spotify-promise/src/promise.js"), | |
m = b("node_modules/spotify-bridge/src/shell/range.js"), | |
h = b("node_modules/spotify-bridge/src/shell/lists/comparators.js").Comparators, | |
g = b("node_modules/spotify-bridge/src/shell/lists/predicates.js").Predicates, | |
d = b("node_modules/spotify-bridge/src/shell/lists/core.js"), | |
c = d.LoadedState, | |
c = b("node_modules/spotify-bridge/src/shell/lists/core.js").LoadedState, | |
k = b("node_modules/spotify-bridge/src/shell/lists/mutator.js"), | |
s = k.MutationRuleset, | |
x = k.MutationResult, | |
z = k.Mutator, | |
t = b("node_modules/spotify-bridge/src/shell/lists/snapshot.js"); | |
a.prototype.setDescriptor = function (a) { | |
this._descriptor = a; | |
return this | |
}; | |
a.prototype.getDescriptor = function () { | |
return this._descriptor | |
}; | |
a.prototype.setRuleset = function (a) { | |
this._ruleset = a; | |
return this | |
}; | |
a.prototype.makeMutable = function () { | |
this._ruleset = | |
new s | |
}; | |
a.prototype.makeImmutable = function () { | |
this._ruleset = new s.Immutable; | |
return this | |
}; | |
a.prototype.getVersion = function () { | |
return this._version | |
}; | |
a.prototype.getBaseList = function () { | |
return this._base || null | |
}; | |
a.prototype.getRootBaseList = function () { | |
if (!this._base) return this; | |
for (var a = this, b = this; a = a._base;) b = a; | |
return b | |
}; | |
a.prototype.getBaseListType = function (a) { | |
if (!this._base) return this instanceof a ? this : null; | |
var b = this; | |
do | |
if (b instanceof a) return b; while (b = b._base); | |
return null | |
}; | |
a.prototype.layersList = function (a) { | |
if (!this._base) return this == | |
a; | |
var b = this; | |
do | |
if (b == a) return !0; while (b = b._base); | |
return !1 | |
}; | |
a.prototype.layersListType = function (a) { | |
if (!this._base) return this instanceof a; | |
var b = this; | |
do | |
if (b instanceof a) return !0; while (b = b._base); | |
return !1 | |
}; | |
a.prototype.translateIndex = function (a) { | |
return this.getLength().then(function (b) { | |
return 0 > a || a > b ? d.OUT_OF_BOUNDS : a | |
}) | |
}; | |
a.prototype.translateIndexFromBase = function (a) { | |
return this.getLength().then(function (b) { | |
return 0 > a || a > b ? d.OUT_OF_BOUNDS : a | |
}) | |
}; | |
a.prototype.createComparator = function (a, b) { | |
return "asc" == | |
b ? h.forString() : h.forStringReversed() | |
}; | |
a.prototype.createPredicate = function (a, b, c) { | |
return g.forNotNull() | |
}; | |
a.prototype.observe = function (a) { | |
this._observers.push(a); | |
return this | |
}; | |
a.prototype.unobserve = function (a) { | |
a = this._observers.indexOf(a); - 1 != a && this._observers.splice(a, 1); | |
return this | |
}; | |
a.prototype.notify = function (a, b) { | |
for (var c = this._observers.slice(0), d = 0, k = c.length; d < k; d++) { | |
var g = c[d], | |
h = g[a]; | |
h && h.call(g, b, this) | |
} | |
return this | |
}; | |
a.prototype.onBeforeMutate = function () {}; | |
a.prototype.onMutate = function () {}; | |
a.prototype.createMutator = function () { | |
if (this._loadedState != c.COMPLETE) return null; | |
var a = this._createMutationApplicator(), | |
b = this._createVersionComparator(); | |
return new z(a, b, this._ruleset, this._version, this._length) | |
}; | |
a.prototype._createMutationApplicator = function () { | |
var a = this; | |
return function (b, c) { | |
var d = new f; | |
if (a._version != b) return d.fulfill(x.EXPIRED), d; | |
a.notify("onBeforeMutate", new t(a._version, a._createVersionedAccessor(), new m(0, a._length), a._length)); | |
for (var k = [], g = 0, h = c.length; g < h; g++) { | |
var s = | |
c[g], | |
l = null; | |
switch (s.type) { | |
case "insert": | |
l = a._applyInsertMutation(s); | |
break; | |
case "remove": | |
l = a._applyRemoveMutation(s); | |
break; | |
case "move": | |
l = a._applyMoveMutation(s) | |
} | |
l && k.push(l) | |
} | |
a._version++; | |
a.notify("onMutate", k); | |
d.fulfill(x.SUCCESS); | |
return d | |
} | |
}; | |
a.prototype._applyInsertMutation = function (a) { | |
var b = a.items; | |
this._list.spliceWith(a.begin, 0, b); | |
this._length += b.length; | |
return a | |
}; | |
a.prototype._applyRemoveMutation = function (a) { | |
var b = a.length; | |
this._list.splice(a.begin, b); | |
this._length -= b; | |
return a | |
}; | |
a.prototype._applyMoveMutation = | |
function (a) { | |
var b = a.end, | |
c = this._list, | |
d = c.splice(a.begin, a.length); | |
c.spliceWith(b, 0, d); | |
return a | |
}; | |
a.prototype._unqueueSnapshots = function () { | |
for (var a = this._snapshotQueue.splice(0), b = 0, c = a.length; b < c; b++) { | |
var d = a[b]; | |
this.snapshot(d[0], d[1]).pipe(d[2]) | |
} | |
}; | |
a.prototype._queueSnapshot = function (a, b, c) { | |
this._snapshotQueue.push([a, b, c]); | |
return this | |
}; | |
a.prototype._fill = function (a) { | |
var b = this._loadedState, | |
d = this._loadLimit, | |
k = new f; | |
if (b == c.COMPLETE) k.fulfill(this); | |
else { | |
b = Math.floor(1 / d * a.begin) * d; | |
a = Math.ceil(1 / d * | |
a.last) * d; | |
a = new m(b, a - b); | |
b = a.subtractMany(this._loadedRanges); | |
a = []; | |
for (var g = 0, h = b.length; g < h; g++) a.push.apply(a, b[g].split(d)); | |
if (!a.length) return k.fulfill(this), k; | |
d = []; | |
b = 0; | |
for (g = a.length; b < g; b++) d.push(this._load(a[b]).then(this._insertLoadedData.bind(this))); | |
f.join(d).pipe(k) | |
} | |
return k | |
}; | |
a.prototype._insertLoadedData = function (a) { | |
var b = a.range; | |
this._list.insertFrom(b.begin, a.items); | |
this._updateRanges(b); | |
this._updateState(); | |
return a | |
}; | |
a.prototype._updateRanges = function (a) { | |
var b = this._loadedRanges; | |
b.push(a); | |
this._loadedRanges = m.simplify(b) | |
}; | |
a.prototype._updateRemovedRanges = function (a) { | |
this._loadedRanges = m.splice(a, this._loadedRanges) | |
}; | |
a.prototype._updateState = function () { | |
var a = this._loadedRanges; | |
this._loadedState = 1 == a.length && a[0].length >= this._length ? c.COMPLETE : c.PARTIAL | |
}; | |
a.prototype._load = function (a) { | |
a = new f; | |
a.fulfill({ | |
state: c.COMPLETE, | |
range: new m(0, 0), | |
items: [] | |
}); | |
return a | |
}; | |
a.prototype._loadLength = function () { | |
var a = new f, | |
b = this._length = 0; | |
a.fulfill({ | |
length: b | |
}); | |
return a | |
}; | |
a.prototype.fillFromArray = | |
function (a, b, d) { | |
this._list.spliceWith(d.begin, d.length, a); | |
this._length = b; | |
a = this._loadedRanges; | |
a.push(d); | |
this._loadedRanges = a = m.simplify(a); | |
this._loadedState = 1 == a.length && a[0].length == b ? c.COMPLETE : c.PARTIAL | |
}; | |
a.prototype.fillFullFromArray = function (a) { | |
this._list.spliceWith(0, 0, a); | |
this._length = a.length; | |
this._loadedRanges = [new m(0, a.length)]; | |
this._loadedState = c.COMPLETE | |
}; | |
a.prototype._createVersionComparator = function () { | |
var a = this; | |
return function (b) { | |
return a._version == b | |
} | |
}; | |
a.prototype._createVersionedAccessor = | |
function () { | |
var a = this, | |
b = this._list; | |
return function (c, k, g) { | |
if (a._version != c) throw Error("Cannot access item with an expired snapshot."); | |
return k in b ? b[k] : d.NULL_VALUE | |
} | |
}; | |
a.prototype.snapshot = function (a, b) { | |
var d = this, | |
k = this._version, | |
g = new f, | |
h; | |
if (0 == b && null != this._length) return g.fulfill(new t(k, this._createVersionedAccessor(), new m(a, 0), this._length)), g; | |
switch (this._loadedState) { | |
case c.COMPLETE: | |
h = new m(a, b, Math.max(this._length - a, 0)); | |
g.fulfill(new t(k, this._createVersionedAccessor(), h, this._length)); | |
break; | |
case c.PARTIAL: | |
h = new m(a, b, Math.max(this._length - a, 0)); | |
h.findContainer(this._loadedRanges) ? g.fulfill(new t(k, this._createVersionedAccessor(), h, this._length)) : this._fill(h).then(function (c) { | |
d.snapshot(a, b).pipe(g) | |
}).catchError(function (a) { | |
g.fail(a) | |
}); | |
break; | |
case c.UNLOADED: | |
this._loadLength().then(function (k) { | |
k.length ? this._fill(new m(a, b, Math.min(this._snapshotLimit, this._length))).then(function (c) { | |
d.snapshot(a, b).pipe(g) | |
}).catchError(function (a) { | |
g.fail(a) | |
}) : (this._loadedState = c.COMPLETE, this.snapshot(a, | |
b).pipe(g)) | |
}.bind(this)) | |
} | |
return g | |
}; | |
a.prototype.snapshotRange = function (a) { | |
return this.snapshot(a.begin, a.length) | |
}; | |
a.prototype.getLength = function () { | |
return this.snapshot(0, 0).call("getListLength") | |
}; | |
a.prototype.toArray = function () { | |
return this.snapshot(0, -1).call("toArray") | |
}; | |
a.prototype.preload = function () { | |
var a = this, | |
b = new f; | |
this.getLength().then(function (c) { | |
return a.snapshot(0, c).then(function (c) { | |
b.fulfill(a) | |
}) | |
}).catchError(function (a) { | |
b.fail(a) | |
}); | |
return b | |
}; | |
l.exports = a | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/lists/array.js": function (b, | |
l, f, n, p, r) { | |
(function () { | |
function a(b, g) { | |
if (!(this instanceof a)) return new a(b, g); | |
m.call(this, g); | |
this.fillFullFromArray(b || []) | |
} | |
var f = b("node_modules/spotify-inheritance/inherit.js"), | |
m = b("node_modules/spotify-bridge/src/shell/lists/base.js"); | |
f(a, m); | |
l.exports = a | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/lists/layered.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(b) { | |
if (!(this instanceof a)) return new a(b); | |
if (!b) throw Error("Required base argument must not be undefined"); | |
m.call(this, b); | |
this._base.observe(this) | |
} | |
var f = b("node_modules/spotify-inheritance/inherit.js"), | |
m = b("node_modules/spotify-bridge/src/shell/lists/base.js"); | |
f(a, m); | |
a.prototype.createComparator = function (a, b) { | |
return this._base.createComparator(a, b) | |
}; | |
a.prototype.createPredicate = function (a, b, d) { | |
return this._base.createPredicate(a, b, d) | |
}; | |
a.prototype.onBeforeMutate = function (a) { | |
this.notify("onBeforeMutate", a) | |
}; | |
a.prototype.onMutate = function (a) { | |
for (var b = 0, d = a.length; b < d; b++) { | |
var c = a[b]; | |
switch (c.type) { | |
case "insert": | |
this._length += c.items.length; | |
break; | |
case "remove": | |
this._length -= c.length | |
} | |
} | |
this._version++; | |
this.notify("onMutate", a); | |
return a | |
}; | |
a.prototype.createMutator = function () { | |
return this._base.createMutator() | |
}; | |
a.prototype.snapshot = function (a, b) { | |
return this._base.snapshot(a, b) | |
}; | |
a.prototype.getLength = function () { | |
var a = this; | |
return this.snapshot(0, 1).call("getListLength").then(function (b) { | |
return a._length = b | |
}) | |
}; | |
l.exports = a | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/lists/property.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(a, b) { | |
this._property = | |
a; | |
this._baseSnapshot = b; | |
this._range = new c(b.getOffset(), b.getLength()); | |
this._version = b.getVersion(); | |
this._listLength = b.getListLength() | |
} | |
function f(a, b) { | |
if (!(this instanceof f)) return new f(a, b); | |
if (!b) throw new TypeError("PropertyItemList: Argument property must not be undefined."); | |
g.call(this, a); | |
this._property = b | |
} | |
var m = b("node_modules/spotify-inheritance/inherit.js"), | |
h = b("node_modules/spotify-bridge/src/shell/lists/core.js"), | |
g = b("node_modules/spotify-bridge/src/shell/lists/layered.js"), | |
d = b("node_modules/spotify-bridge/src/shell/lists/snapshot.js"), | |
c = b("node_modules/spotify-bridge/src/shell/range.js"); | |
m(a, d); | |
a.prototype.get = function (a) { | |
var b = this._property; | |
a = this._baseSnapshot.get(a); | |
a != h.NULL_VALUE && (a = b in a ? a[b] : h.NULL_VALUE); | |
return a | |
}; | |
m(f, g); | |
f.prototype.onBeforeMutate = function (b) { | |
this.notify("onBeforeMutate", new a(this._property, b)) | |
}; | |
f.prototype.onMutate = function (a) { | |
a.length && this._applyMutations(a) | |
}; | |
f.prototype._applyMutations = function (a) { | |
for (var b = [], c = 0, d = a.length; c < d; c++) { | |
var g = a[c]; | |
switch (g.type) { | |
case "insert": | |
for (var m = this._property, | |
f = g.items, q = f.length, l = Array(q); q--;) l[q] = m in f[q] ? f[q][m] : h.NULL_VALUE; | |
this._length += q; | |
b.push({ | |
type: "insert", | |
begin: g.begin, | |
items: l | |
}); | |
break; | |
case "remove": | |
this._length -= g.length; | |
b.push(g); | |
break; | |
case "move": | |
b.push(g) | |
} | |
} | |
this._version++; | |
this.notify("onMutate", b); | |
return b | |
}; | |
f.prototype.snapshot = function (b, c) { | |
var d = this._property; | |
return this._base.snapshot(b, c).then(function (b) { | |
return new a(d, b) | |
}) | |
}; | |
l.exports = f | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/lists/concatenated.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(b) { | |
if (!(this instanceof a)) return new a(list); | |
if (!b || !b.length) throw new TypeError("ConcatenatedItemList: Argument `lists` cannot be empty."); | |
g.call(this); | |
this._sublists = b.slice(0); | |
this._offsets = []; | |
this._ruleset = new c.Immutable | |
} | |
var f = b("node_modules/spotify-promise/src/promise.js"), | |
m = b("node_modules/spotify-bridge/src/shell/range.js"), | |
h = b("node_modules/spotify-inheritance/inherit.js"), | |
g = b("node_modules/spotify-bridge/src/shell/lists/base.js"); | |
b("node_modules/spotify-bridge/src/shell/lists/core.js"); | |
var d = b("node_modules/spotify-bridge/src/shell/lists/snapshot.js"), | |
c = b("node_modules/spotify-bridge/src/shell/lists/mutator.js").MutationRuleset; | |
h(a, g); | |
a.prototype._load = function (a) { | |
for (var b = this._sublists, c = this._offsets, d = [], g = 0, h = c.length; g < h; g++) { | |
var l = c[g], | |
l = new m(l, (g + 1 in c ? c[g + 1] : this._length) - l); | |
l.intersects(a) && (l = l.intersect(a), d.push(b[g].snapshot(l.begin, l.length))) | |
} | |
return f.join(d).then(function (b) { | |
for (var c = [], d = 0, g = b.length; d < g; d++) c.push.apply(c, b[d].toArray()); | |
return { | |
range: a, | |
items: c | |
} | |
}) | |
}; | |
a.prototype._loadLength = function () { | |
for (var a = this._sublists, | |
b = [], c = 0, d = a.length; c < d; c++) { | |
var g = a[c]; | |
g.observe(this); | |
b.push(g.snapshot(0, -1)) | |
} | |
return f.join(b).then(this._processInitialSnapshots.bind(this)) | |
}; | |
a.prototype._processInitialSnapshots = function (a) { | |
for (var b = this._list, c = this._offsets, d = this._length = 0, g = a.length; d < g; d++) { | |
var h = a[d], | |
f = h.toFullArray(), | |
q = new m(h.getOffset() + this._length, f.length); | |
b.insertFrom(q.begin, f); | |
c[d] = this._length; | |
this._length += h.getListLength(); | |
this._updateRanges(q); | |
this._updateState() | |
} | |
return { | |
length: this._length | |
} | |
}; | |
a.prototype.onMutate = | |
function (a, b) { | |
a.length && this._applyMutations(a, b) | |
}; | |
a.prototype._applyMutations = function (a, b) { | |
this.notify("onBeforeMutate", new d(this._version, this._createVersionedAccessor(), new m(0, this._length), this._length)); | |
var c = this._sublists.indexOf(b); | |
if (-1 != c) { | |
var g = this._offsets[c]; | |
if (null != g) { | |
for (var h = [], f = 0, q = a.length; f < q; f++) { | |
var l = a[f], | |
A = null; | |
switch (l.type) { | |
case "insert": | |
if (A = this._applyInsertMutation({ | |
type: "insert", | |
begin: g + l.begin, | |
items: l.items | |
})) this._incrementOffsets(c + 1, A.items.length), h.push(A); | |
break; | |
case "remove": | |
if (A = this._applyRemoveMutation({ | |
type: "remove", | |
begin: g + l.begin, | |
length: l.length | |
})) this._decrementOffsets(c + 1, A.length), h.push(A); | |
break; | |
case "move": | |
(A = this._applyMoveMutation({ | |
type: "move", | |
begin: g + l.begin, | |
end: g + l.end, | |
length: l.length | |
})) && h.push(A) | |
} | |
} | |
this._version++; | |
this.notify("onMutate", h); | |
return h | |
} | |
} | |
}; | |
a.prototype._incrementOffsets = function (a, b) { | |
for (var c = this._offsets, d = a, g = c.length; d < g; d++) c[d] += b; | |
return this | |
}; | |
a.prototype._decrementOffsets = function (a, b) { | |
for (var c = this._offsets, d = a, | |
g = c.length; d < g; d++) c[d] -= b; | |
return this | |
}; | |
a.prototype.offsetFromListIndex = function (a, b) { | |
var c = this; | |
return this.getLength().then(function (d) { | |
if (b >= d || a >= c._offsets.length) return null; | |
0 > b && (b = 0); | |
return c._offsets[a] + b | |
}) | |
}; | |
a.prototype.getListAt = function (a) { | |
return this._sublists[a] || null | |
}; | |
a.prototype.getListForIndex = function (a) { | |
return this.getLength().then(function (b) { | |
if (a > b) return null; | |
b = this._sublists; | |
for (var c = this._offsets, d = 0, g = c.length; d < g; d++) { | |
var h = c[d]; | |
if (a == h) return b[d]; | |
if (a < h) break | |
} | |
return b[d - | |
1] | |
}.bind(this)) | |
}; | |
a.prototype.translateIndex = function (a) { | |
return this.getLength().then(function (b) { | |
if (a > b) return null; | |
b = this._offsets; | |
for (var c = 0, d = b.length; c < d; c++) { | |
var g = b[c]; | |
if (a == g) return 0; | |
if (a < g) return a - b[c - 1] | |
} | |
return a - g | |
}.bind(this)) | |
}; | |
l.exports = a | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/lists/ranged.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(a, b, c) { | |
g.call(this, a); | |
this._range = new h(b, c); | |
this._baseListLength = 0; | |
this.makeImmutable() | |
} | |
var f = b("node_modules/spotify-inheritance/inherit.js"), | |
m = b("node_modules/spotify-promise/src/promise.js"), | |
h = b("node_modules/spotify-bridge/src/shell/range.js"), | |
g = b("node_modules/spotify-bridge/src/shell/lists/layered.js"), | |
d = b("node_modules/spotify-bridge/src/shell/lists/core.js"), | |
c = b("node_modules/spotify-bridge/src/shell/lists/snapshot.js"); | |
f(a, g); | |
a.prototype.translateIndex = function (a) { | |
var b = this._range, | |
c = new m; | |
return a > b.length ? (c.fulfill(d.OUT_OF_BOUNDS), c) : this.getLength().then(function (c) { | |
return 0 > a || a > c ? d.OUT_OF_BOUNDS : b.begin + a | |
}) | |
}; | |
a.prototype.onBeforeMutate = | |
function (a) { | |
this._list = a.toArray() | |
}; | |
a.prototype.onMutate = function (a) { | |
var b = this; | |
this.snapshot(0, -1).then(function (c) { | |
b._applyMutations(a, c) | |
}) | |
}; | |
a.prototype._applyMutations = function (a, b) { | |
var d = this._version; | |
this.notify("onBeforeMutate", new c(d, this._createVersionedAccessor(d, 0, b), new h(0, this._range.length), this._range.length)); | |
for (var d = [], g = 0, m = a.length; g < m; g++) { | |
var f = a[g], | |
q = null; | |
switch (f.type) { | |
case "insert": | |
q = this._applyInsertMutation(f); | |
break; | |
case "remove": | |
q = this._applyRemoveMutation(f); | |
break; | |
case "move": | |
q = | |
this._applyMoveMutation(f) | |
} | |
q.length && d.push.apply(d, q) | |
} | |
this._version++; | |
this.notify("onMutate", d); | |
return d | |
}; | |
a.prototype._applyInsertMutation = function (a) { | |
var b = this._range, | |
c = []; | |
if (a.begin >= b.last) return this._list.spliceWith(a.begin, 0, a.items), c; | |
var d = new h(a.begin, a.items.length), | |
g = this._list.length, | |
m = Math.max(0, Math.min(b.length, b.last - g)), | |
d = (new h(0, b.last)).intersect(d).length, | |
g = Math.max(0, b.begin - g), | |
g = Math.min(b.length, d - g), | |
d = Math.max(0, g - m), | |
m = b.last - d - m; | |
0 < d && c.push({ | |
type: "remove", | |
begin: m - b.begin, | |
length: d | |
}); | |
this._list.spliceWith(a.begin, 0, a.items); | |
0 < g && (a = Math.max(0, a.begin - b.begin), b = a + b.begin, c.push({ | |
type: "insert", | |
begin: a, | |
items: this._list.slice(b, b + g) | |
})); | |
return c | |
}; | |
a.prototype._applyRemoveMutation = function (a) { | |
var b = this._range, | |
c = null, | |
d = []; | |
if (a.begin >= a.last) return this._list.spliceWith(a.begin, a.length), d; | |
var c = this._list.length, | |
g = c - a.length, | |
h = Math.max(0, c - b.begin), | |
g = Math.max(0, g - b.begin), | |
c = Math.max(0, a.begin - b.begin), | |
c = Math.min(h - g, b.length - c), | |
m = Math.min(b.length, h) - c, | |
h = b.length - m, | |
g = Math.min(h, | |
g - m); | |
0 < c && (c = { | |
type: "remove", | |
begin: Math.max(0, a.begin - b.begin), | |
length: c | |
}, d.push(c)); | |
this._list.spliceWith(a.begin, a.length); | |
0 < g && (a = b.length - h, b = a + b.begin, c = { | |
type: "insert", | |
begin: a, | |
items: this._list.slice(b, b + g) | |
}, d.push(c)); | |
return d | |
}; | |
a.prototype._applyMoveMutation = function (a) { | |
var b = [], | |
c = { | |
type: "remove", | |
begin: a.begin, | |
length: a.length | |
}, d = a.end; | |
d > a.begin && (d -= a.length); | |
a = { | |
type: "insert", | |
begin: d, | |
items: this._list.slice(a.begin, a.begin + a.length) | |
}; | |
d = null; | |
d = this._applyRemoveMutation(c); | |
d.length && b.push.apply(b, | |
d); | |
d = this._applyInsertMutation(a); | |
d.length && b.push.apply(b, d); | |
return b | |
}; | |
a.prototype.snapshot = function (a, b) { | |
var d = this, | |
g = this._base, | |
m = this._range, | |
f = this._version, | |
q = new h(m.begin + (a || 0), b, m.length - a); | |
return g.snapshot(q.begin, q.length).then(function (g) { | |
var q = d._createVersionedAccessor(f, a, g), | |
l = new h(a, b, Math.min(m.length, g.getLength())); | |
g = Math.min(g.getListLength(), m.length); | |
return new c(f, q, l, g) | |
}) | |
}; | |
a.prototype._createVersionedAccessor = function (a, b, c) { | |
var d = this; | |
return function (a, k) { | |
if (d._version != | |
a) throw Error("Cannot access item with an expired snapshot."); | |
return c.get(k - b) | |
} | |
}; | |
l.exports = a | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/lists/sorted.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(a, b) { | |
x.call(this, a); | |
this._baseList = []; | |
this._sortedList = null; | |
this._rawComparator = b || s.forString(); | |
this._comparator = this._wrapComparator(this._rawComparator); | |
this._ruleset = new t({ | |
insert: v.FORBIDDEN, | |
move: v.FORBIDDEN | |
}); | |
this._init() | |
} | |
function f(a, b, c) { | |
this._baseList = a.slice(0); | |
this._sortedList = b.slice(0); | |
this._length = | |
a.length; | |
this._rawComparator = this._comparator = c; | |
this._version = 0 | |
} | |
function m(a, b, c, d, k, g, h) { | |
if (!(this instanceof m)) return new m(a); | |
w.call(this, null, d, k, g, h); | |
this._baseMutator = a; | |
this._resolveIndex = c; | |
this._mutationMock = b | |
} | |
var h = b("node_modules/spotify-inheritance/inherit.js"), | |
g = Array.prototype.slice, | |
d = b("node_modules/spotify-promise/src/promise.js"), | |
c = b("node_modules/spotify-bridge/src/shell/range.js"), | |
k = b("node_modules/spotify-bridge/src/shell/lists/core.js"), | |
s = b("node_modules/spotify-bridge/src/shell/lists/comparators.js").Comparators, | |
x = b("node_modules/spotify-bridge/src/shell/lists/layered.js"), | |
z = b("node_modules/spotify-bridge/src/shell/lists/mutator.js"), | |
t = z.MutationRuleset, | |
v = z.MutationResult, | |
w = z.Mutator, | |
u = b("node_modules/spotify-bridge/src/shell/lists/snapshot.js"); | |
h(a, x); | |
a.prototype._init = function () { | |
this._base.snapshot(0, -1).then(this._buildInitial.bind(this)).catchError(function (a) {}) | |
}; | |
a.prototype._wrapComparator = function (a) { | |
var b = this._baseList; | |
return function (c, d) { | |
var k = a(b[c], b[d], c, d); | |
return 0 == k ? c - d : k | |
} | |
}; | |
a.prototype._buildInitial = | |
function (a) { | |
this._length = a.getListLength(); | |
this._baseList.spliceWith(0, 0, a.toArray()); | |
this._sortInitial(); | |
this._unqueueSnapshots() | |
}; | |
a.prototype._sortInitial = function () { | |
for (var a = this._baseList.length, b = this._sortedList = Array(a); a--;) b[a] = a; | |
b.sort(this._comparator); | |
this._loadedState = k.LoadedState.COMPLETE | |
}; | |
a.prototype.snapshot = function (a, b) { | |
var g = new d, | |
h = new c(a, b, Math.max(this._length - a, 0)); | |
if (0 == h.length && this._loadedState != k.LoadedState.UNLOADED) return h = new u(this._version, this._createVersionedAccessor([]), | |
h, this._length), g.fulfill(h), g; | |
this._loadedState != k.LoadedState.COMPLETE ? this._queueSnapshot(a, b, g) : (h = new u(this._version, this._createVersionedAccessor(), h, this._length), g.fulfill(h)); | |
return g | |
}; | |
a.prototype._createVersionedAccessor = function () { | |
var a = this, | |
b = this._baseList, | |
c = this._sortedList; | |
return function (d, g) { | |
if (a._version != d) throw Error("Cannot access item with an expired snapshot."); | |
return g in c ? b[c[g]] : k.NULL_VALUE | |
} | |
}; | |
a.prototype._createIndexResolver = function () { | |
var a = this._sortedList; | |
return function (b) { | |
return b in | |
a ? a[b] : k.NULL_VALUE | |
} | |
}; | |
a.prototype._createMutationMock = function () { | |
return new f(this._baseList, this._sortedList, this._rawComparator) | |
}; | |
a.prototype.translateIndex = function (a) { | |
return this.getLength().then(function (b) { | |
return 0 > a || a > b ? k.OUT_OF_BOUNDS : this._sortedList[a] | |
}.bind(this)) | |
}; | |
a.prototype.createMutator = function () { | |
var a = this._base.createMutator(); | |
if (!a) return null; | |
var b = this._createMutationMock(), | |
c = this._createIndexResolver(), | |
d = this._createVersionComparator(); | |
return new m(a, b, c, d, this._ruleset, this._version, | |
this._length) | |
}; | |
a.prototype.onMutate = function (a) { | |
a.length && this._applyMutations(a) | |
}; | |
a.prototype._applyMutations = function (a) { | |
this.notify("onBeforeMutate", new u(this._version, this._createVersionedAccessor(), new c(0, this._length), this._length)); | |
for (var b = [], d = 0, k = a.length; d < k; d++) { | |
var g = a[d], | |
h = null, | |
s, m, f; | |
switch (g.type) { | |
case "remove": | |
s = g.begin; | |
m = g.length; | |
g = 0; | |
for (f = m; g < f; g++) h = { | |
type: "remove", | |
begin: s, | |
length: 1 | |
}, (h = this._applyRemoveMutation(h)) && b.push(h); | |
break; | |
case "move": | |
h = this._applyMoveMutation(g); | |
h.length && | |
b.push.apply(b, h); | |
break; | |
case "insert": | |
for (s = g.begin, m = g.items, g = 0, f = m.length; g < f; g++) h = s + g, h = { | |
type: "insert", | |
begin: h, | |
items: [m[g]] | |
}, (h = this._applyInsertMutation(h)) && b.push(h) | |
} | |
} | |
this._version++; | |
this.notify("onMutate", b); | |
return b | |
}; | |
a.prototype._getInsertionIndex = function (a, b) { | |
var c = this._baseList, | |
d = this._sortedList, | |
k = this._length, | |
g = this._rawComparator, | |
h = 0, | |
s = k - 1, | |
m = a, | |
f = 0; | |
if (0 == k) return 0; | |
if (1 == k) return k = g(b, c[0]), 0 == k ? 0 < a ? 1 : -1 : 0 < k ? 1 : 0; | |
for (; h <= s;) | |
if (m = Math.floor((h + s) / 2), k = g(b, c[d[m]]), 0 < k) h = m + 1, f = 1; | |
else if (0 > | |
k) s = m - 1, f = 0; | |
else { | |
if (a == d[m]) break; | |
else m = a > d[m] ? m + 1 : m - 1, f = 1; | |
break | |
} | |
return m + f | |
}; | |
a.prototype._applyInsertMutation = function (a) { | |
var b = a.begin; | |
a = a.items[0]; | |
var c = this._baseList, | |
d = this._sortedList, | |
k = { | |
type: "insert", | |
begin: b, | |
items: [a] | |
}, g = this._getInsertionIndex(b, a); | |
this._incrementSortedIndices(b); | |
d.splice(g, 0, b); | |
k.begin = g; | |
c.splice(b, 0, a); | |
this._length++; | |
return k | |
}; | |
a.prototype._incrementSortedIndices = function (a) { | |
a = a || 0; | |
for (var b = this._sortedList, c = 0, d = b.length; c < d; c++) b[c] >= a && b[c]++ | |
}; | |
a.prototype._decrementSortedIndices = | |
function (a) { | |
a = a || 0; | |
for (var b = this._sortedList, c = 0, d = b.length; c < d; c++) b[c] >= a && b[c]-- | |
}; | |
a.prototype._applyRemoveMutation = function (a) { | |
a = a.begin; | |
var b = this._baseList, | |
c = this._sortedList, | |
d = c.indexOf(a); | |
c.splice(c.indexOf(a), 1); | |
this._decrementSortedIndices(a); | |
b.splice(a, 1); | |
this._length--; | |
return { | |
type: "remove", | |
begin: d, | |
length: 1 | |
} | |
}; | |
a.prototype._applyMoveMutation = function (a) { | |
var b = this._baseList, | |
c = this._sortedList, | |
d = a.begin, | |
k = a.end, | |
g = [], | |
h = 0; | |
for (a = a.length; h < a; h++) { | |
var s = c.indexOf(d), | |
m = b[d], | |
f = s; | |
k < d ? (b.splice(d, | |
1), b.splice(k, 0, m), this._decrementSortedIndices(d), this._incrementSortedIndices(k), c.splice(s, 1), f = this._getInsertionIndex(k, m), c.splice(f, 0, k), k++, d++) : k > d && (b.splice(k, 0, m), b.splice(d, 1), this._incrementSortedIndices(k), this._decrementSortedIndices(d), c.splice(s, 1), f = this._getInsertionIndex(k - 1, m), c.splice(f, 0, k - 1)); | |
f > s && f++; | |
s != f && g.push({ | |
type: "move", | |
begin: s, | |
end: f, | |
length: 1 | |
}) | |
} | |
return g | |
}; | |
f.prototype.applyMutations = function (a) { | |
a = Array.isArray(a) ? a : g.call(arguments); | |
return this._applyMutations(a) | |
}; | |
f.prototype.notify = | |
function () {}; | |
f.prototype._createVersionedAccessor = function () {}; | |
f.prototype._applyMutations = a.prototype._applyMutations; | |
f.prototype._getInsertionIndex = a.prototype._getInsertionIndex; | |
f.prototype._incrementSortedIndices = a.prototype._incrementSortedIndices; | |
f.prototype._decrementSortedIndices = a.prototype._decrementSortedIndices; | |
f.prototype._applyInsertMutation = a.prototype._applyInsertMutation; | |
f.prototype._applyRemoveMutation = a.prototype._applyRemoveMutation; | |
h(m, w); | |
m.prototype.apply = function () { | |
return this._baseMutator.apply() | |
}; | |
m.prototype.add = function (a, b) { | |
var c = this.canAdd(a.length); | |
if (c != v.ALLOWED) return c; | |
if (!a.length) return v.SUCCESS; | |
var c = this._baseMutator, | |
d = c.canAdd(a.length); | |
if (d != v.ALLOWED) return d; | |
d = []; | |
c.add(a, d); | |
c = this._mutationMock.applyMutations(d); | |
b && b.push.apply(b, c); | |
return v.SUCCESS | |
}; | |
m.prototype.remove = function (a, b, c) { | |
var d = this.canRemove(a, b); | |
if (d != v.ALLOWED) return d; | |
if (0 == b) return v.SUCCESS; | |
for (var d = this._baseMutator, k = [], g = 0; g < b; g++) { | |
var h = this._resolveIndex(a + g), | |
m = d.canRemove(h, 1); | |
if (m != v.ALLOWED) return m; | |
k.push(h) | |
} | |
k.sort(s.forNumber()); | |
g = []; | |
for (h = 0; h < b; h++) d.remove(k[h] - h, 1, g); | |
this._length -= b; | |
this._mutationMock.applyMutations(g); | |
a = { | |
type: "remove", | |
begin: a, | |
length: b | |
}; | |
c && c.push(a); | |
return v.SUCCESS | |
}; | |
l.exports = a | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/lists/filtered.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(a, b) { | |
k.call(this, a); | |
this._baseList = []; | |
this._loadedBaseRanges = []; | |
this._predicate = b | |
} | |
function f(a, b, c, d) { | |
this._baseList = a.slice(0); | |
this._list = b.slice(0); | |
this._length = c; | |
this._predicate = d; | |
this._version = | |
0 | |
} | |
function m(a, b, c, d, k, g, h) { | |
if (!(this instanceof m)) return new m(a); | |
t.call(this, null, d, k, g, h); | |
this._baseMutator = a; | |
this._resolveIndex = c; | |
this._mutationMock = b | |
} | |
var h = b("node_modules/spotify-inheritance/inherit.js"), | |
g = b("node_modules/spotify-promise/src/promise.js"), | |
d = b("node_modules/spotify-bridge/src/shell/range.js"), | |
c = b("node_modules/spotify-bridge/src/shell/lists/core.js"), | |
k = b("node_modules/spotify-bridge/src/shell/lists/layered.js"), | |
s = c.LoadedState, | |
x = b("node_modules/spotify-bridge/src/shell/lists/mutator.js"), | |
z = x.MutationResult, | |
t = x.Mutator, | |
v = b("node_modules/spotify-bridge/src/shell/lists/snapshot.js"); | |
h(a, k); | |
a.prototype._buildList = function (a, b) { | |
for (var k = this._list, g = k.length, h = 0, m = this._predicate, f = 0, q = b.length; f < q; f++) { | |
var l = b[f]; | |
l != c.NULL_VALUE && m(l) && (k.push(a.begin + f), h++) | |
} | |
h && this._updateRanges(new d(g, h)); | |
this._baseList.insertFrom(a.begin, b); | |
g = this._loadedBaseRanges; | |
g.push(a); | |
this._loadedBaseRanges = g = d.simplify(g); | |
1 == g.length && g[0].length >= this._baseLength ? (this._length = k.length, this._loadedState = | |
s.COMPLETE) : this._loadedState = s.PARTIAL; | |
return this | |
}; | |
a.prototype._createVersionedAccessor = function (a, b) { | |
var d = this, | |
k = this._list; | |
return function (g, h) { | |
return d._version != g ? c.NULL_VALUE : h in k ? b[k[h] - a] : c.NULL_VALUE | |
} | |
}; | |
a.prototype._snapshot = function (a, b, c) { | |
var k = this, | |
h = new g, | |
m = new d(a, b), | |
f, q; | |
if (0 == m.length && this._loadedState != s.UNLOADED) return b = new v(this._version, this._createVersionedAccessor(0, []), m, this._length), h.fulfill(b), h; | |
switch (this._loadedState) { | |
case s.COMPLETE: | |
-1 == b && (b = this._length); | |
f = this._list.slice(a, | |
a + b); | |
q = (new d(f[0], 0)).add(new d(f[f.length - 1], 1)); | |
this._base.snapshotRange(q).then(function (b) { | |
b = new v(k._version, k._createVersionedAccessor(q.begin, b.toFullArray()), new d(a, f.length), k._length); | |
h.fulfill(b) | |
}); | |
break; | |
case s.PARTIAL: | |
m.findContainer(this._loadedRanges) ? (-1 == b && (b = this._length), f = this._list.slice(a, a + b), q = (new d(f[0], 0)).add(new d(f[f.length - 1], 1)), this._base.snapshotRange(q).then(function (b) { | |
b = new v(k._version, k._createVersionedAccessor(q.begin, b.toFullArray()), new d(a, f.length), f.length); | |
h.fulfill(b) | |
})) : (b = this._loadedBaseRanges, b = new d(b[b.length - 1].last, 10 * c), this._base.snapshotRange(b).then(function (a) { | |
k._buildList(new d(a.getOffset(), a.getLength()), a.toFullArray()); | |
k._snapshot(m.begin, m.length, ++c).pipe(h) | |
})); | |
break; | |
case s.UNLOADED: | |
b = new d(0, m.last - m.begin + 10 * c), this._base.snapshotRange(b).then(function (a) { | |
k._length = k._baseLength = a.getListLength(); | |
k._buildList(new d(a.getOffset(), a.getLength()), a.toFullArray()); | |
k._snapshot(m.begin, m.length, ++c).pipe(h) | |
}) | |
} | |
return h | |
}; | |
a.prototype.snapshot = | |
function (a, b) { | |
return this._snapshot(a, b, 1) | |
}; | |
a.prototype.translateIndex = function (a) { | |
return this.getLength().then(function (b) { | |
return 0 > a || a > b ? c.OUT_OF_BOUNDS : this._list[a] | |
}.bind(this)) | |
}; | |
a.prototype.translateIndexFromBase = function (a) { | |
return this.getLength().then(function (b) { | |
b = this._list.indexOf(a); | |
return -1 == b ? c.OUT_OF_BOUNDS : b | |
}.bind(this)) | |
}; | |
a.prototype.onBeforeMutate = function (a) { | |
this._baseList = a.toFullArray() | |
}; | |
a.prototype.onMutate = function (a) { | |
a.length && this._applyMutations(a) | |
}; | |
a.prototype._applyMutations = | |
function (a) { | |
this.notify("onBeforeMutate", new v(this._version, this._createVersionedAccessor(0, this._baseList), new d(0, this._length), this._length)); | |
for (var b = [], c = 0, k = a.length; c < k; c++) { | |
var g = a[c], | |
h = null; | |
switch (g.type) { | |
case "insert": | |
h = this._applyInsertMutation(g); | |
break; | |
case "remove": | |
h = this._applyRemoveMutation(g); | |
break; | |
case "move": | |
h = this._applyMoveMutation(g) | |
} | |
h && b.push(h) | |
} | |
this._version++; | |
this.notify("onMutate", b); | |
return b | |
}; | |
a.prototype._applyInsertMutation = function (a) { | |
var b = this._list, | |
c = a.begin, | |
d = a.items; | |
if (!d.length) return null; | |
var k = this._filterMutationItems(d); | |
a = k.items; | |
var k = k.indices, | |
g = this._findInsertionIndex(c); | |
this._updateIndices(g, b.length, d.length); | |
for (var d = 0, h = k.length; d < h; d++) b.splice(g + d, 0, c + k[d]); | |
this._length += k.length; | |
return { | |
type: "insert", | |
begin: g, | |
items: a | |
} | |
}; | |
a.prototype._applyRemoveMutation = function (a) { | |
var b = this._list, | |
c = a.begin; | |
a = a.length; | |
var d = c + a; | |
if (!a) return null; | |
for (var k = -1, g = 0, h = 0, m = b.length; h < m; h++) { | |
var s = b[h]; | |
s >= d ? b[h] -= a : s >= c && (-1 == k && (k = h), g++) | |
} | |
b.splice(k, g); | |
this._length -= | |
g; | |
return { | |
type: "remove", | |
begin: k, | |
length: g | |
} | |
}; | |
a.prototype._applyMoveMutation = function (a) { | |
var b = this._list, | |
c = a.begin, | |
k = a.end; | |
a = a.length; | |
if (c == k) return null; | |
var g = this._getIndicesInRange(new d(c, a)), | |
h = this._findInsertionIndex(c), | |
m = this._findInsertionIndex(k); | |
c < k ? (c = k - c - a, this._updateIndices(h + g.length, m, -a), b.spliceWith(m, 0, g), b.splice(h, g.length), this._updateIndices(m - g.length, m, c)) : (c = k - c, this._updateIndices(m, h, a), b.splice(h, g.length), b.spliceWith(m, 0, g), this._updateIndices(m, m + g.length, c)); | |
return h == | |
m ? null : { | |
type: "move", | |
begin: h, | |
end: m, | |
length: g.length | |
} | |
}; | |
a.prototype._filterMutationItems = function (a) { | |
for (var b = [], c = [], d = this._predicate, k = 0, g = a.length; k < g; k++) { | |
var h = a[k]; | |
d(h) && (b.push(h), c.push(k)) | |
} | |
return { | |
items: b, | |
indices: c | |
} | |
}; | |
a.prototype._findInsertionIndex = function (a) { | |
for (var b = this._list, c = 0, d = b.length; c < d; c++) | |
if (b[c] >= a) return c; | |
return d | |
}; | |
a.prototype._getIndicesInRange = function (a) { | |
for (var b = this._list, c = [], d = 0, k = b.length; d < k; d++) { | |
var g = b[d]; | |
a.has(g) && c.push(g) | |
} | |
return c | |
}; | |
a.prototype._createMutationMock = | |
function () { | |
return new f(this._baseList, this._list, this._length, this._predicate) | |
}; | |
a.prototype.createMutator = function () { | |
var a = this._base.createMutator(); | |
if (!a) return null; | |
var b = this._createMutationMock(), | |
c = this._createIndexResolver(), | |
d = this._createVersionComparator(); | |
return new m(a, b, c, d, this._ruleset, this._version, this._length) | |
}; | |
a.prototype._createIndexResolver = function () { | |
var a = this._list; | |
return function (b) { | |
return b in a ? a[b] : c.NULL_VALUE | |
} | |
}; | |
a.prototype._updateIndices = function (a, b, c) { | |
for (var d = this._list; a < | |
b; a++) d[a] += c | |
}; | |
f.prototype.applyMutations = function (a) { | |
a = Array.isArray(a) ? a : slice.call(arguments); | |
return this._applyMutations(a) | |
}; | |
f.prototype.notify = function () {}; | |
f.prototype._createVersionedAccessor = function () {}; | |
f.prototype._applyMutations = a.prototype._applyMutations; | |
f.prototype._applyInsertMutation = a.prototype._applyInsertMutation; | |
f.prototype._applyRemoveMutation = a.prototype._applyRemoveMutation; | |
f.prototype._applyMoveMutation = a.prototype._applyMoveMutation; | |
f.prototype._filterMutationItems = a.prototype._filterMutationItems; | |
f.prototype._findInsertionIndex = a.prototype._findInsertionIndex; | |
f.prototype._getIndicesInRange = a.prototype._getIndicesInRange; | |
f.prototype._updateIndices = a.prototype._updateIndices; | |
h(m, t); | |
m.prototype.apply = function () { | |
return this._baseMutator.apply() | |
}; | |
m.prototype.add = function (a, b) { | |
var c = this.canAdd(a.length); | |
if (c != z.ALLOWED) return c; | |
if (!a.length) return z.SUCCESS; | |
var c = this._baseMutator, | |
d = c.canAdd(a.length); | |
if (d != z.ALLOWED) return d; | |
d = []; | |
c.add(a, d); | |
c = this._mutationMock.applyMutations(d); | |
b && b.push.apply(b, | |
c); | |
return z.SUCCESS | |
}; | |
m.prototype.insert = function (a, b, c) { | |
var d = this.canInsert(a, b.length); | |
if (d != z.ALLOWED) return d; | |
if (!b.length) return z.SUCCESS; | |
a = this._resolveIndex(a); | |
var d = this._baseMutator, | |
k = d.canInsert(a, b.length); | |
if (k != z.ALLOWED) return k; | |
k = []; | |
d.insert(a, b, k); | |
b = this._mutationMock.applyMutations(k); | |
this._length = this._mutationMock._length; | |
c && c.push.apply(c, b); | |
return z.SUCCESS | |
}; | |
m.prototype.remove = function (a, b, c) { | |
var d = this.canRemove(a, b); | |
if (d != z.ALLOWED) return d; | |
if (0 == b) return z.SUCCESS; | |
for (var d = | |
this._baseMutator, k = [], g = 0; g < b; g++) { | |
var h = this._resolveIndex(a + g), | |
m = d.canRemove(h, 1); | |
if (m != z.ALLOWED) return m; | |
k.push(h) | |
} | |
k.sort(function (a, b) { | |
return a - b | |
}); | |
g = []; | |
for (h = 0; h < b; h++) d.remove(k[h] - h, 1, g); | |
this._length -= b; | |
this._mutationMock.applyMutations(g); | |
a = { | |
type: "remove", | |
begin: a, | |
length: b | |
}; | |
c && c.push(a); | |
return z.SUCCESS | |
}; | |
m.prototype.move = function (a, b, c, d) { | |
var k = this.canMove(a, b, c); | |
if (k != z.ALLOWED) return k; | |
if (a == b || 0 == c) return z.SUCCESS; | |
for (var k = this._baseMutator, g = [], h = 0; h < c; h++) { | |
var m = this._resolveIndex(a + | |
h), | |
s = k.canMove(m, a, 1); | |
if (s != z.ALLOWED) return s; | |
g.push(m) | |
} | |
for (var h = this._resolveIndex(b), m = [], s = 0, f = g.length; s < f; s++) k.move(g[s] - s, h, 1, m); | |
this._mutationMock.applyMutations(m); | |
a = { | |
type: "move", | |
begin: a, | |
end: b, | |
length: c | |
}; | |
d && d.push(a); | |
return z.SUCCESS | |
}; | |
l.exports = a | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/entities/session.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(b) { | |
if (!(this instanceof a)) return new a(b); | |
b && this._fill(b) | |
} | |
var f = Spotify.Link, | |
m = b("node_modules/spotify-promise/src/promise.js"); | |
a.prototype._fill = | |
function (a) { | |
this.catalogue = a.catalogue; | |
this.country = a.country; | |
this.device = "web"; | |
this.online = !0; | |
this.preferredLocale = a.preferred_locale; | |
this.product = a.product; | |
this.testGroup = a.ab_test_group; | |
Object.defineProperty(this, "user", { | |
value: { | |
uri: f.profileLink(a.user).toString(), | |
username: a.user | |
} | |
}); | |
this.ads = a.ads; | |
this.appDeveloper = this.developer = "app_developer" in a && "0" != a.app_developer; | |
this.postOpenGraph = a.post_open_graph; | |
this.publicToplist = "public_toplist" in a && "0" != a.public_toplist; | |
this.publishActivity = "publish_activity" in | |
a && "1" == a.publish_activity; | |
this.publishFacebook = "publish_facebook" in a && "1" == a.publish_facebook; | |
this.publishPlaylists = "publish_playlist" in a && "1" == a.publish_playlist | |
}; | |
a.create = function (b) { | |
var g = new m; | |
try { | |
g.fulfill(new a(b)) | |
} catch (d) { | |
g.fail(d) | |
} | |
return g | |
}; | |
l.exports = a | |
})() | |
}, | |
"node_modules/spotify-bridge/node_modules/spotify-queueable/src/queueable.js": function (b, l, f, n, p, r) { | |
var a = b("node_modules/spotify-promise/src/promise.js"), | |
q = function (b, g) { | |
var d = new a; | |
try { | |
var c = b.apply(null, g); | |
c && "function" == typeof c.then ? | |
c.pipe(d) : d.fulfill(c) | |
} catch (k) { | |
d.fail(k) | |
} | |
return d | |
}, m = function (b, g) { | |
if (this._getReady()) return q(b, g); | |
var d = new a; | |
this._requestQueue.push({ | |
fn: b, | |
args: g, | |
promise: d | |
}); | |
return d | |
}; | |
b = function (a, b) { | |
a = a || []; | |
for (var d = 0, c = a.length; d < c; d++) this._makeQueueable(a[d]); | |
this._isReady = !! b; | |
this._requestQueue = [] | |
}; | |
b.prototype._makeQueueable = function (a) { | |
var b = a, | |
d = this; | |
"function" !== typeof b && (b = this[a]); | |
if (b) { | |
var c = function () { | |
return m.call(d, b.bind(this), arguments) | |
}; | |
this[a] && (this[a] = c); | |
return c | |
} | |
}; | |
b.prototype._setReady = | |
function (a) { | |
"undefined" === typeof a && (a = !0); | |
if (this._isReady = a) { | |
this._requestQueue = this._requestQueue.splice(0); | |
a = 0; | |
for (var b = this._requestQueue.length; a < b; a++) { | |
var d = this._requestQueue[a]; | |
q(d.fn, d.args).pipe(d.promise) | |
} | |
} | |
}; | |
b.prototype._getReady = function () { | |
return this._isReady | |
}; | |
l.exports = b | |
}, | |
"node_modules/spotify-bridge/src/shell/dispatcher.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a() { | |
this._handlers = {} | |
} | |
function f(a) { | |
function b() {} | |
if ("object" != typeof a) return a; | |
b.prototype = a; | |
return new b | |
} | |
function m(a, | |
b, c, d) { | |
if (!(this instanceof m)) return new m(a, b, c, d); | |
if (!a) throw new TypeError("DispatcherRequest: Argument `method` missing."); | |
if (!b) throw new TypeError("DispatcherRequest: Argument `path` missing."); | |
this.method = a; | |
this.path = b; | |
this.headers = c ? f(c) : {}; | |
this.body = d ? f(d) : {} | |
} | |
function h(a, b, c) { | |
if (!(this instanceof h)) return new h(a, header, c); | |
this.status = s.OK; | |
this.statusText = x[200]; | |
this.headers = {}; | |
this.body = {}; | |
void 0 != a && this.setStatus(a); | |
void 0 != b && this.setHeaders(b); | |
void 0 != c && this.setBody(c) | |
} | |
function g() { | |
if (!(this instanceof g)) return new g; | |
this._handlers = new a; | |
this._requestSenders = {}; | |
c.call(this, ["request"]) | |
} | |
var d = b("node_modules/spotify-promise/src/promise.js"), | |
c = b("node_modules/spotify-bridge/node_modules/spotify-queueable/src/queueable.js"), | |
k = b("node_modules/spotify-inheritance/inherit.js"), | |
s = { | |
OK: 200, | |
CREATED: 201, | |
ACCEPTED: 202, | |
MULTIPLE_CHOICES: 300, | |
BAD_REQUEST: 400, | |
UNAUTHORIZED: 401, | |
FORBIDDEN: 403, | |
NOT_FOUND: 404, | |
METHOD_NOT_ALLOWED: 405, | |
TIMED_OUT: 408, | |
CONFLICT: 409, | |
GONE: 410, | |
INTERNAL_SERVER_ERROR: 500, | |
NOT_IMPLEMENTED: 501, | |
BAD_GATEWAY: 502, | |
SERVICE_UNAVAILABLE: 503 | |
}, x = { | |
200: "Ok", | |
201: "Created", | |
202: "Accepted", | |
400: "Bad Request", | |
401: "Unauthorized", | |
403: "Forbidden", | |
404: "Not Found", | |
405: "Method Not Allowed", | |
408: "Timed Out", | |
409: "Conflict", | |
410: "Gone", | |
500: "Internal Server Error", | |
501: "Not Implemented", | |
502: "Bad Gateway", | |
503: "Service Unavailable" | |
}, z = { | |
CREATE: "CREATE", | |
FLUSH: "FLUSH", | |
GET: "GET", | |
REMOVE: "REMOVE", | |
UPDATE: "UPDATE" | |
}; | |
a.prototype.get = function (a, b) { | |
var c = this._handlers; | |
a = a.toString().toUpperCase(); | |
return (c = c[a]) ? c[b] || null : null | |
}; | |
a.prototype.set = | |
function (a, b, c) { | |
var d = this._handlers; | |
a = a.toString().toUpperCase(); | |
(d[a] || (d[a] = {}))[b] = c; | |
return this | |
}; | |
a.prototype.remove = function (a, b, c) { | |
var d = this._handlers; | |
a = a.toString().toUpperCase(); | |
a = d[a]; | |
if (!a) return null; | |
d = a[b]; | |
if (!d) return this; | |
d == c && (a[b] = null); | |
return this | |
}; | |
h.prototype.setStatus = function (a) { | |
this.status = a; | |
this.statusText = x[a]; | |
return this | |
}; | |
h.prototype.setHeader = function (a, b) { | |
this.headers[a] = b; | |
return this | |
}; | |
h.prototype.setHeaders = function (a) { | |
for (var b in a) this.headers[b] = a[b]; | |
return this | |
}; | |
h.prototype.setBodyField = function (a, b) { | |
this.body[a] = b; | |
return this | |
}; | |
h.prototype.setBodyFields = function (a) { | |
var b = this.body, | |
c; | |
for (c in a) a.hasOwnProperty(c) && (b[c] = a[c]); | |
return this | |
}; | |
h.prototype.setBody = function (a) { | |
if (!a || "object" != typeof a || Array.isArray(a)) throw Error("DispatcherResponse.setBody: `body` must be an object."); | |
this.body = a; | |
return this | |
}; | |
k(g, c); | |
g.prototype.setReady = function () { | |
this._setReady(); | |
return this | |
}; | |
g.prototype.register = function (a, b, c) { | |
this._handlers.set(a, b, c); | |
return this | |
}; | |
g.prototype.createRequestSender = | |
function (a, b) { | |
var c = this, | |
d = this._requestSenders, | |
k = a + " " + b; | |
return d[k] || (d[k] = function (d, k) { | |
return c.request(a, b, d, k) | |
}) | |
}; | |
g.prototype.request = function (a, b, c, k) { | |
var g = new d; | |
a = (a || "").toString().toUpperCase(); | |
b = b || "/"; | |
var f = this._handlers.get(a, b); | |
if (f) { | |
a = new m(a, b, c, k); | |
try { | |
var q = f.call(null, a, this); | |
q.pipe ? q.pipe(g) : q instanceof h ? q.status >= s.OK && q.status < s.MULTIPLE_CHOICES ? g.fulfill(q) : g.fail(q) : g.fulfill(q) | |
} catch (l) { | |
g.fail(l) | |
} | |
} else g.fail(new h(s.NOT_IMPLEMENTED)); | |
return g | |
}; | |
g.prototype.create = function (a, | |
b, c) { | |
return this.request(z.CREATE, a, b, c) | |
}; | |
g.prototype.get = function (a, b, c) { | |
return this.request(z.GET, a, b, c) | |
}; | |
g.prototype.flush = function (a, b, c) { | |
return this.request(z.FLUSH, a, b, c) | |
}; | |
g.prototype.remove = function (a, b, c) { | |
return this.request(z.REMOVE, a, b, c) | |
}; | |
g.prototype.update = function (a, b, c) { | |
return this.request(z.UPDATE, a, b, c) | |
}; | |
l.exports = { | |
ResponseStatus: s, | |
ResponseStatusText: x, | |
RequestMethod: z, | |
RequestResponseHeader: void 0, | |
RequestResponseBody: void 0, | |
RequestPath: void 0, | |
RequestHandler: void 0, | |
RequestHandlerMap: void 0, | |
RequestSender: void 0, | |
MethodRequestMap: a, | |
DispatcherRequest: m, | |
DispatcherResponse: h, | |
Dispatcher: g | |
} | |
})() | |
}, | |
"node_modules/spotify-bridge/src/bridge/errortranslator.js": function (b, l, f, n, p, r) { | |
(function () { | |
var a = b("node_modules/spotify-bridge/src/bridge/errors.js"), | |
f = b("node_modules/spotify-bridge/src/shell/dispatcher.js").ResponseStatus; | |
l.exports = function (b) { | |
if (b instanceof Error) h = new a.Transient("Operation errored while performing request."); | |
else { | |
var h = b; | |
switch (b.status) { | |
case f.BAD_GATEWAY: | |
case f.CONFLICT: | |
case f.INTERNAL_SERVER_ERROR: | |
case f.SERVICE_UNAVAILABLE: | |
h = | |
new a.Transient("Operation errored while performing request."); | |
break; | |
case f.BAD_REQUEST: | |
h = new a.InvalidRequest("Request failed because of invalid arguments."); | |
break; | |
case f.FORBIDDEN: | |
case f.UNAUTHORIZED: | |
h = new a.Forbidden("Request not allowed."); | |
break; | |
case f.METHOD_NOT_ALLOWED: | |
case f.NOT_IMPLEMENTED: | |
h = new a.NotImplemented("Request is not implemented."); | |
break; | |
case f.GONE: | |
case f.NOT_FOUND: | |
h = new a.NotFound("Resource not found."); | |
break; | |
case f.TIMED_OUT: | |
h = new a.Timeout("Request timed-out.") | |
} | |
} | |
throw h; | |
} | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/lists/iterable.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(a, b) { | |
k.call(this, a); | |
c.call(this, "pop previous next hasPrevious hasNext preload startAt".split(" ")); | |
this._index = -1; | |
this._loadLimit = b || 10; | |
this._currentIndexRemoved = this._infinite = !1; | |
this._init() | |
} | |
var f = b("node_modules/spotify-inheritance/inherit.js"), | |
m = b("node_modules/spotify-inheritance/extend.js"), | |
h = b("node_modules/spotify-promise/src/promise.js"), | |
g = b("node_modules/spotify-bridge/src/shell/range.js"), | |
d = b("node_modules/spotify-bridge/src/shell/lists/core.js"), | |
c = b("node_modules/spotify-bridge/node_modules/spotify-queueable/src/queueable.js"), | |
k = b("node_modules/spotify-bridge/src/shell/lists/layered.js"), | |
s = d.LoadedState, | |
x = b("node_modules/spotify-bridge/src/shell/lists/mutator.js").MutationResult, | |
z = b("node_modules/spotify-bridge/src/shell/lists/snapshot.js"); | |
f(a, k); | |
m(a.prototype, c.prototype); | |
a.prototype._init = function () { | |
this._loadLength().then(this._setReady.bind(this)) | |
}; | |
a.prototype._load = function (a) { | |
return this._base.snapshotRange(a).then(function (a) { | |
return { | |
range: new g(a.getOffset(), | |
a.getLength()), | |
items: a.toArray() | |
} | |
}) | |
}; | |
a.prototype._loadLength = function () { | |
var a = this; | |
return this._base.getLength().then(function (b) { | |
a._length = b; | |
a._loadedState = s.PARTIAL; | |
return { | |
length: b | |
} | |
}) | |
}; | |
a.prototype.makeInfinite = function () { | |
this._infinite = !0 | |
}; | |
a.prototype.makeFinite = function () { | |
this._infinite = !1 | |
}; | |
a.prototype.startAt = function (a) { | |
var b = new h; | |
this._index = -1 == a || a > this._length ? this._length : 0 > a ? -1 : a - 1; | |
this._currentIndexRemoved = !1; | |
b.fulfill(!0); | |
return b | |
}; | |
a.prototype.rewind = function () { | |
this._index = -1; | |
this._currentIndexRemoved = !1; | |
return this | |
}; | |
a.prototype.wasCurrentIndexRemoved = function () { | |
return !!this._currentIndexRemoved | |
}; | |
a.prototype.getIndex = function () { | |
var a = this._index; | |
return 0 > a ? d.LIST_START : a >= this._length ? d.LIST_END : a | |
}; | |
a.prototype.preload = function (a) { | |
var b = this._loadLimit; | |
a = new g((void 0 == a ? 0 : a) - b, 2 * (b || 1)); | |
0 > a.begin && (a = a.subtract(new g(0, 0)), a = a[1].add(new g(a[1].last, a[0].length))); | |
return this._fill(a).then(function () { | |
return !0 | |
}, function () { | |
return !1 | |
}) | |
}; | |
a.prototype.hasNext = function () { | |
var a = this._index, | |
b = new h; | |
return this._infinite ? | |
(b.fulfill(!0), b) : a + 1 >= this.length ? (b.fulfill(!1), b) : this.snapshot(a + 1, 1).then(function (a) { | |
return a.get(0) !== d.NULL_VALUE | |
}, function () { | |
return !1 | |
}) | |
}; | |
a.prototype.hasPrevious = function () { | |
var a = this._index, | |
b = new h; | |
return this._infinite ? (b.fulfill(!0), b) : 0 > a - 1 ? (b.fulfill(!1), b) : this.snapshot(a - 1, 1).then(function (a) { | |
return a.get(0) !== d.NULL_VALUE | |
}, function () { | |
return !1 | |
}) | |
}; | |
a.prototype.next = function () { | |
var a = this._index; | |
if (this._infinite && a + 1 == this._length) this._index = a = 0; | |
else { | |
if (a + 1 > this._length - 1) return this._index = | |
a = this._length, a = new h, a.fulfill(d.LIST_END), a; | |
this._index = a += 1 | |
} | |
this._currentIndexRemoved = !1; | |
return this.snapshot(a, 1).then(function (a) { | |
a = a.get(0); | |
return a == d.NULL_VALUE ? d.LIST_END : a | |
}, function () { | |
return d.LIST_END | |
}) | |
}; | |
a.prototype.previous = function () { | |
var a = this._index; | |
if (this._infinite && -1 == a - 1) this._index = a = this._length - 1; | |
else { | |
if (0 > a - 1) return this._index = a = -1, a = new h, a.fulfill(d.LIST_START), a; | |
this._index = a -= 1 | |
} | |
this._currentIndexRemoved = !1; | |
return this.snapshot(a, 1).then(function (a) { | |
a = a.get(0); | |
return a == | |
d.NULL_VALUE ? d.LIST_START : a | |
}, function () { | |
return d.LIST_START | |
}) | |
}; | |
a.prototype.pop = function () { | |
var a = this, | |
b = new h; | |
this.snapshot(0, 1).then(function (c) { | |
var k = a._base.createMutator(), | |
g = c.get(0); | |
g == d.NULL_VALUE || k.canRemove(0, 1) != x.ALLOWED ? b.fulfill(d.NULL_VALUE) : (k.remove(0, 1), k.apply().then(function (a) { | |
a == x.SUCCESS ? b.fulfill(g) : b.fulfill(d.NULL_VALUE) | |
}, function () { | |
b.fulfill(d.NULL_VALUE) | |
})) | |
}, function () { | |
b.fulfill(d.NULL_VALUE) | |
}); | |
return b | |
}; | |
a.prototype.onMutate = function (a) { | |
a.length && this._applyMutations(a) | |
}; | |
a.prototype._applyMutations = function (a) { | |
this.notify("onBeforeMutate", new z(this._version, this._createVersionedAccessor(), new g(0, this._length), this._length)); | |
if (-1 != this._index) | |
for (var b = 0, c = a.length; b < c; b++) { | |
var d = a[b]; | |
switch (d.type) { | |
case "insert": | |
this._applyInsertMutation(d); | |
break; | |
case "remove": | |
this._applyRemoveMutation(d); | |
break; | |
case "move": | |
this._applyMoveMutation(d) | |
} | |
} | |
this._version++; | |
this.notify("onMutate", a); | |
return a | |
}; | |
a.prototype._applyInsertMutation = function (a) { | |
var b = a.begin, | |
c = a.items.length; | |
if (!c) return a; | |
this._length += c; | |
b <= this._index + 1 && (this._index += c + 1); | |
return a | |
}; | |
a.prototype._applyRemoveMutation = function (a) { | |
var b = a.begin, | |
c = a.length; | |
if (!c) return a; | |
var d = new g(b, c); | |
this._length -= c; | |
b == this._index ? (this._index--, this._currentIndexRemoved = !0) : d.has(this._index) ? (this._index = b - 1, this._currentIndexRemoved = !0) : b < this._index && (this._index -= c); | |
return a | |
}; | |
a.prototype._applyMoveMutation = function (a) { | |
var b = a.begin, | |
c = a.end, | |
d = a.length; | |
if (!d) return a; | |
var k = new g(b, d); | |
k.has(this._index + 1) ? this._index = | |
k.end + (this._index - k.begin) : this._index = b > c ? this._index + d : this._index - d; | |
return a | |
}; | |
l.exports = a | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/lists.js": function (b, l, f, n, p, r) { | |
b = b("node_modules/spotify-inheritance/extend.js")({}, b("node_modules/spotify-bridge/src/shell/lists/core.js"), b("node_modules/spotify-bridge/src/shell/lists/comparators.js"), b("node_modules/spotify-bridge/src/shell/lists/predicates.js"), b("node_modules/spotify-bridge/src/shell/lists/mutator.js"), { | |
Snapshot: b("node_modules/spotify-bridge/src/shell/lists/snapshot.js"), | |
Descriptor: b("node_modules/spotify-bridge/src/shell/lists/descriptor.js"), | |
Base: b("node_modules/spotify-bridge/src/shell/lists/base.js"), | |
Array: b("node_modules/spotify-bridge/src/shell/lists/array.js"), | |
Concatenated: b("node_modules/spotify-bridge/src/shell/lists/concatenated.js"), | |
Layered: b("node_modules/spotify-bridge/src/shell/lists/layered.js"), | |
Ranged: b("node_modules/spotify-bridge/src/shell/lists/ranged.js"), | |
Sorted: b("node_modules/spotify-bridge/src/shell/lists/sorted.js"), | |
Filtered: b("node_modules/spotify-bridge/src/shell/lists/filtered.js"), | |
Iterable: b("node_modules/spotify-bridge/src/shell/lists/iterable.js"), | |
Property: b("node_modules/spotify-bridge/src/shell/lists/property.js") | |
}); | |
l.exports = b | |
}, | |
"node_modules/spotify-bridge/src/shell/listmanager.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a() { | |
this._baseLists = {}; | |
this._cache = new f(100) | |
} | |
b("node_modules/spotify-bridge/src/shell/extension.js"); | |
var f = Spotify.SimpleCache, | |
m = b("node_modules/spotify-bridge/src/shell/lists.js"), | |
h = m.Descriptor; | |
a.prototype._retrieveList = function (a) { | |
var b = null, | |
c = | |
null, | |
k = this._cache, | |
h = a.serialize(), | |
f = k.get(h); | |
if (f) return f; | |
try { | |
switch (a.type) { | |
case "list": | |
return this._baseLists[a.uri] || null; | |
case "concatenate": | |
for (var q = [], l = 0, n = a.lists.length; l < n; l++) { | |
c = this._retrieveList(a.lists[l]); | |
if (!c) return null; | |
q.push(c) | |
} | |
b = new m.Concatenated(q); | |
b.setDescriptor(a); | |
k.put(h, b); | |
break; | |
case "sort": | |
c = this._retrieveList(a.list); | |
if (!c) return null; | |
n = []; | |
for (l = 0; l < a.params.length; ++l) { | |
var q = a.params[l], | |
w = c.createComparator(q.field, q.order); | |
if (!w) return null; | |
n.push(w) | |
} | |
if (0 == n.length) return null; | |
w = Comparators.forComparators(n); | |
b = new m.Sorted(c, w); | |
b.setDescriptor(a); | |
k.put(h, b); | |
break; | |
case "filter": | |
c = this._retrieveList(a.list); | |
if (!c) return null; | |
var u = c.createPredicate(a.field, a.operator, a.matcher); | |
if (!u) return null; | |
b = new m.Filtered(c, u); | |
b.setDescriptor(a); | |
k.put(h, b); | |
break; | |
case "range": | |
c = this._retrieveList(a.list); | |
if (!c) return null; | |
b = new m.Ranged(c, a.offset, a.length); | |
b.setDescriptor(a); | |
k.put(h, b) | |
} | |
return b | |
} catch (p) { | |
return b | |
} | |
}; | |
a.prototype.get = function (a) { | |
return (a = h.fromObject(a)) ? this._retrieveList(a) : | |
null | |
}; | |
a.prototype.set = function (a, b) { | |
if (null == b) return this.unset(a); | |
a = h.extractList(a); | |
if (!a) return !1; | |
b.setDescriptor(a); | |
this._baseLists[a.uri] = b; | |
return !0 | |
}; | |
a.prototype.unset = function (a) { | |
a = h.extractList(a); | |
if (!a) return !1; | |
this._baseLists[a.uri] = void 0; | |
return !0 | |
}; | |
l.exports = a | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/sublists/toplist.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(b, d) { | |
if (!(this instanceof a)) return new a(b, d); | |
if (!d || !Array.isArray(d)) throw new TypeError("ToplistItemList: Argument `array` must be an array."); | |
d = d.slice(0); | |
for (var g = d.length; g--;) d[g] = d[g].toString(); | |
c.call(this, d); | |
this._uri = b.toString() | |
} | |
function f(b, c) { | |
if (!(this instanceof f)) return new f(b, c); | |
a.call(this, b, c) | |
} | |
function m(b, c) { | |
if (!(this instanceof m)) return new m(b, c); | |
a.call(this, b, c) | |
} | |
function h(b, c) { | |
if (!(this instanceof h)) return new h(b, c); | |
a.call(this, b, c) | |
} | |
function g(b, c) { | |
if (!(this instanceof g)) return new g(b, c); | |
a.call(this, b, c) | |
} | |
var d = b("node_modules/spotify-inheritance/inherit.js"), | |
c = b("node_modules/spotify-bridge/src/shell/lists.js").Array; | |
d(a, c); | |
a.create = function (a, b, c) { | |
switch (a) { | |
case "artist": | |
return new m(b, c); | |
case "album": | |
return new f(b, c); | |
case "playlist": | |
return new h(b, c); | |
default: | |
return new g(b, c) | |
} | |
}; | |
d(f, a); | |
d(m, a); | |
d(h, a); | |
d(g, a); | |
l.exports = { | |
ToplistTypes: { | |
ALBUM: "album", | |
ARTIST: "artist", | |
PLAYLIST: "playlist", | |
TRACK: "track" | |
}, | |
Toplist: a, | |
ToplistAlbum: f, | |
ToplistArtist: m, | |
ToplistPlaylist: h, | |
ToplistTrack: g | |
} | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/sublists/context.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(b, d) { | |
if (!(this instanceof a)) return new a(b, | |
d, opt_rules); | |
if (!d) throw new TypeError("ContextItemList: Constructor argument `owner` cannot be undefined."); | |
g.call(this, b, 10); | |
this._owner = d; | |
this._shuffled = !1; | |
this._shuffledList = null | |
} | |
var f = b("node_modules/spotify-inheritance/inherit.js"), | |
m = b("node_modules/spotify-promise/src/promise.js"), | |
h = b("node_modules/spotify-bridge/src/shell/lists.js"), | |
g = h.Iterable, | |
d = h.LoadedState; | |
f(a, g); | |
a.prototype.getOwner = function () { | |
return this._owner | |
}; | |
a.prototype.setOwner = function (a) { | |
this._owner = a; | |
return this | |
}; | |
a.prototype._getIndex = | |
function () { | |
var a = this._index; | |
return 0 > a ? h.LIST_START : a >= this._length ? h.LIST_END : a | |
}; | |
a.prototype.getIndex = function () { | |
var a = this._index; | |
if (0 > a) return h.LIST_START; | |
if (a >= this._length) return h.LIST_END; | |
this._shuffled && this._shuffledList && this._shuffledList.length && (a = this._shuffledList[a]); | |
return a | |
}; | |
a.getDescriptorMap = function (a, b) { | |
var d = this, | |
g = new m; | |
if (!a) return g.fulfill([]), g; | |
b = b == h.OUT_OF_BOUNDS ? -1 : b; | |
var f = a.getDescriptor(), | |
q = f ? [{ | |
descriptor: f, | |
index: b | |
}] : []; | |
if (!a.getBaseList) return q; | |
var l = a.getBaseList(); | |
if (!l || l == a) { | |
if (a instanceof h.Concatenated) return a.getListForIndex(b).then(function (d) { | |
return m.join(d, a.translateIndex(b)) | |
}).thenSpread(function (a, b) { | |
return d.getDescriptorMap(a, b) | |
}).then(function (a) { | |
return q.concat(a) | |
}); | |
g.fulfill(q); | |
return g | |
} | |
return a.translateIndex(b).then(function (a) { | |
return d.getDescriptorMap(l, a) | |
}).then(function (a) { | |
return q.concat(a) | |
}) | |
}; | |
a.prototype.shuffle = function (a) { | |
if (this._loadedState == d.UNLOADED) return this._queueCall(); | |
var b = new m; | |
b.fulfill(!0); | |
if (this._shuffled) return b; | |
this._shuffled = !0; | |
for (var g = this._length, f = Array(g); g--;) f[g] = g; | |
g = this._getIndex(); | |
g == h.LIST_START ? g = -1 : g == h.LIST_END && (g = this._list.length - 2); | |
for (var g = a ? f.splice(g, 1).pop() : f.splice(g + 1, 1).pop(), q = f.length; q;) { | |
var l = Math.floor(Math.random() * q--), | |
n = f[q]; | |
f[q] = f[l]; | |
f[l] = n | |
} | |
null != g && (f.unshift(g), this._index = a ? 0 : -1); | |
this._shuffledList = f; | |
return b | |
}; | |
a.prototype.unshuffle = function () { | |
if (this._loadedState == d.UNLOADED) return this._queueCall(); | |
var a = new m; | |
a.fulfill(!0); | |
if (!this._shuffled) return a; | |
this._shuffled = !1; | |
if (this._shuffledList) { | |
var b = this._getIndex(); | |
if (0 != b || b != h.LIST_START || b != h.LIST_END) this._index = this._shuffledList[b]; | |
return a | |
} | |
}; | |
a.prototype.snapshot = function (a, b) { | |
this._shuffled && this._shuffledList && this._shuffledList.length && (a = this._shuffledList[a]); | |
return g.prototype.snapshot.call(this, a, b) | |
}; | |
l.exports = a | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/sublists/decorator.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(a, b) { | |
d.call(this, a); | |
if (!b) throw new TypeError("Argument requestSender is null."); | |
this._requestSender = b; | |
this._decoratedMap = {}; | |
this._init() | |
} | |
var f = b("node_modules/spotify-inheritance/inherit.js"), | |
m = b("node_modules/spotify-promise/src/promise.js"), | |
h = b("node_modules/spotify-bridge/src/shell/range.js"), | |
g = b("node_modules/spotify-bridge/src/shell/lists.js"), | |
d = g.Layered, | |
c = g.LoadedState, | |
k = g.Snapshot; | |
f(a, d); | |
a.prototype._init = function () { | |
this._base.getLength().then(function (a) { | |
this._length = a; | |
this._loadedState = 0 == a ? c.COMPLETE : c.PARTIAL; | |
this._unqueueSnapshots() | |
}.bind(this)).catchError(function (a) {}) | |
}; | |
a.prototype._buildList = function (a) { | |
var b = this._list, | |
c = new h(a.getOffset(), a.getLength()); | |
a = a.toArray(); | |
b.insertFrom(c.begin, a); | |
return this._decorateItems(a, c) | |
}; | |
a.prototype._decorateItems = function (a, b) { | |
var c = this, | |
d = new m, | |
k = this._decoratedMap; | |
this._requestSender(a).then(function (g) { | |
for (var h = 0, m = a.length; h < m; h++) { | |
var f = a[h]; | |
k[f] = g[f] | |
} | |
c._updateRanges(b); | |
c._updateState(); | |
d.fulfill(a) | |
}); | |
return d | |
}; | |
a.prototype._undecorateItems = function (a, b) { | |
for (var c = this._decoratedMap, d = new m, k = 0, g = a.length; k < g; k++) delete c[a[k]]; | |
d.fulfill(a); | |
return d | |
}; | |
a.prototype.snapshot = function (a, b) { | |
var d = this, | |
g = new m, | |
f = new h(a, b, Math.max(this._length - a, 0)); | |
if (0 == f.length && this._loadedState != c.UNLOADED) return f = new k(this._version, this._createVersionedAccessor([]), f, this._length), g.fulfill(f), g; | |
switch (this._loadedState) { | |
case c.COMPLETE: | |
this._base.snapshot(a, b).then(function (a) { | |
a = new k(d._version, d._createVersionedAccessor(a.toArray()), new h(a.getOffset(), a.getLength(), a.getListLength()), a.getListLength()); | |
g.fulfill(a) | |
}, g.fail.bind(g)); | |
break; | |
case c.PARTIAL: | |
f.findContainer(this._loadedRanges) ? this._base.snapshot(a, b).then(function (a) { | |
a = new k(d._version, d._createVersionedAccessor(a.toArray()), new h(a.getOffset(), a.getLength(), a.getListLength()), a.getListLength()); | |
g.fulfill(a) | |
}, g.fail.bind(g)) : this._base.snapshot(a, b).then(function (a) { | |
return d._buildList(a) | |
}).then(function () { | |
return d.snapshot(a, b).pipe(g) | |
}).catchError(function (a) { | |
g.fail(a) | |
}); | |
break; | |
case c.UNLOADED: | |
this._queueSnapshot(a, b, g) | |
} | |
return g | |
}; | |
a.prototype._createVersionedAccessor = | |
function (a) { | |
var b = this, | |
c = this._decoratedMap; | |
return function (d, k, g) { | |
if (b._version != d) throw Error("Cannot access item with an expired snapshot."); | |
return c[a[g]].metadata | |
} | |
}; | |
a.prototype.onMutate = function (a) { | |
this.notify("onBeforeMutate", new k(this._version, this._createVersionedAccessor(this._list), new h(0, this._length), this._length)); | |
for (var b = [], c = 0, d = a.length; c < d; c++) { | |
var g = a[c]; | |
switch (g.type) { | |
case "insert": | |
b.push(this._applyInsertMutation(g)); | |
break; | |
case "remove": | |
b.push(this._applyRemoveMutation(g)); | |
break; | |
case "move": | |
b.push(this._applyMoveMutation(g)) | |
} | |
} | |
b.length && m.join(b).then(function (a) { | |
this._version++; | |
this.notify("onMutate", a) | |
}.bind(this)) | |
}; | |
a.prototype._applyInsertMutation = function (a) { | |
var b = a.begin; | |
a = a.items; | |
this._list.spliceWith(b, 0, a); | |
this._length += a.length; | |
return this._decorateItems(a, new h(b, a.length)).then(function (a) { | |
return { | |
type: "insert", | |
begin: b, | |
items: a | |
} | |
}) | |
}; | |
a.prototype._applyRemoveMutation = function (a) { | |
var b = new m, | |
c = a.begin, | |
d = a.length, | |
k = this._list.splice(c, d); | |
this._length -= d; | |
b.fulfill(a); | |
return this._undecorateItems(k, new h(c, d)).then(function () { | |
return b | |
}) | |
}; | |
a.prototype._applyMoveMutation = function (a) { | |
var b = new m, | |
c = a.end, | |
d = this._list, | |
k = d.splice(a.begin, a.length); | |
d.spliceWith(c, 0, k); | |
b.fulfill(a); | |
return b | |
}; | |
l.exports = a | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/sublists/metadatadecorator.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(a, b) { | |
m.call(this, a, b) | |
} | |
var f = b("node_modules/spotify-inheritance/inherit.js"), | |
m = b("node_modules/spotify-bridge/src/shell/sublists/decorator.js"); | |
f(a, m); | |
a.prototype._decorateItems = function (a, b) { | |
return this._requestSender(a).then(this._processMetadata.bind(this, a, b), function (a) { | |
console.error(a); | |
console.error(a.stack) | |
}) | |
}; | |
a.prototype._processMetadata = function (a, b, d) { | |
for (var c = this._decoratedMap, k = a.length, f = Array(k); k--;) { | |
var m = a[k], | |
q = c[m]; | |
q ? q.count++ : q = c[m] = { | |
count: 1, | |
metadata: d[m] | |
}; | |
f[k] = q.metadata | |
} | |
this._updateRanges(b); | |
this._updateState(); | |
return f | |
}; | |
a.prototype._createVersionedAccessor = function (a) { | |
var b = this, | |
d = this._decoratedMap; | |
return function (c, k, f) { | |
if (b._version != | |
c) throw Error("Cannot access item with an expired snapshot."); | |
return d[a[f]].metadata | |
} | |
}; | |
l.exports = a | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/sublists/playlistdecorator.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(a, b) { | |
m.call(this, a, b) | |
} | |
var f = b("node_modules/spotify-inheritance/inherit.js"), | |
m = b("node_modules/spotify-bridge/src/shell/sublists/decorator.js"); | |
f(a, m); | |
a.prototype._decorateItems = function (a, b) { | |
for (var d = a.length, c = Array(d); d--;) c[d] = a[d].uri; | |
return this._requestSender(c).then(this._processMetadata.bind(this, | |
a, b), function (a) { | |
console.error(a); | |
console.error(a.stack) | |
}) | |
}; | |
a.prototype._processMetadata = function (a, b, d) { | |
for (var c = a.length, k = Array(c); c--;) { | |
var f = a[c]; | |
f.setTrack(d[f.uri]); | |
k[c] = f | |
} | |
this._updateRanges(b); | |
this._updateState(); | |
return k | |
}; | |
a.prototype._createVersionedAccessor = function () { | |
var a = this, | |
b = this._list; | |
return function (d, c) { | |
if (a._version != d) throw Error("Cannot access item with an expired snapshot."); | |
return b[c] | |
} | |
}; | |
l.exports = a | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/sublists/mappable.js": function (b, | |
l, f, n, p, r) { | |
(function () { | |
function a(a, b) { | |
this._property = b; | |
h.call(this, a, {}) | |
} | |
var f = b("node_modules/spotify-inheritance/inherit.js"), | |
m = b("node_modules/spotify-bridge/src/shell/lists.js"), | |
h = b("node_modules/spotify-bridge/src/shell/sublists/decorator.js"), | |
g = m.LoadedState, | |
d = b("node_modules/spotify-promise/src/promise.js"); | |
f(a, h); | |
a.prototype._init = function () { | |
this._base.getLength().then(function (a) { | |
this._length = a; | |
this._loadedState = g.PARTIAL; | |
this._unqueueSnapshots() | |
}.bind(this)).catchError(function (a) {}) | |
}; | |
a.prototype._decorateItems = function (a, b) { | |
for (var g = this._decoratedMap, h = this._property, f = a.length; f--;) { | |
var m = a[f] && a[f][h]; | |
m && (g[m] || (g[m] = { | |
counter: 0 | |
})).counter++ | |
} | |
this._updateRanges(b); | |
this._updateState(); | |
g = new d; | |
g.fulfill(a); | |
return g | |
}; | |
a.prototype._undecorateItems = function (a, b) { | |
for (var g = this._decoratedMap, h = this._property, f = a.length; f--;) { | |
var m = a[f] && a[f][h]; | |
if (m) { | |
var q = g[m]; | |
q && (q.counter--, 1 > q.counter && delete g[m]) | |
} | |
} | |
g = new d; | |
g.fulfill(a); | |
return g | |
}; | |
a.prototype.contains = function (a) { | |
var b = this._decoratedMap, | |
h = new d; | |
this._loadedState != g.COMPLETE ? this.snapshot(0, -1).then(function () { | |
a in b && b[a].counter ? h.fulfill(!0) : h.fulfill(!1) | |
}) : a in b && b[a].counter ? h.fulfill(!0) : h.fulfill(!1); | |
return h | |
}; | |
a.prototype._createVersionedAccessor = m.Base.prototype._createVersionedAccessor; | |
l.exports = a | |
})() | |
}, | |
"node_modules/spotify-bridge/src/bridge/snapshothelper.js": function (b, l, f, n, p, r) { | |
(function () { | |
var a = b("node_modules/spotify-bridge/src/shell/lists.js"); | |
l.exports = { | |
createListSnapshotter: function (a, b) { | |
return function (h) { | |
return h.body.list.snapshot(a, | |
b) | |
} | |
}, | |
createBaseListSnapshotter: function (a, b) { | |
return function (h) { | |
return h.body.list.getRootBaseList().snapshot(a, b) | |
} | |
}, | |
formatSnapshot: function (b) { | |
for (var f = [], h = [], g = b.getLength(), d = 0; d < g; d++) { | |
var c = b.get(d); | |
c && c != a.NULL_VALUE && (f.push(c.uri), h.push(c)) | |
} | |
return { | |
range: { | |
offset: b.getOffset(), | |
length: g | |
}, | |
length: b.getListLength(), | |
array: f, | |
metadata: h | |
} | |
}, | |
formatTrackRowSnapshot: function (b) { | |
for (var f = [], h = [], g = b.getLength(), d = 0; d < g; d++) { | |
var c = b.get(d); | |
c && c != a.NULL_VALUE && (f.push(c.uri), h.push(c.track || { | |
uri: c.uri | |
})) | |
} | |
return { | |
range: { | |
offset: b.getOffset(), | |
length: g | |
}, | |
length: b.getListLength(), | |
array: f, | |
metadata: h | |
} | |
}, | |
formatArraySnapshot: function (a) { | |
var b = a.toArray(); | |
return { | |
range: { | |
offset: a.getOffset(), | |
length: a.getLength() | |
}, | |
length: a.getListLength(), | |
array: b | |
} | |
}, | |
formatMetadataSnapshot: function (a) { | |
var b = a.toArray(), | |
h = Array(b.length).join("|").split("|"); | |
return { | |
range: { | |
offset: a.getOffset(), | |
length: a.getLength() | |
}, | |
length: a.getListLength(), | |
array: h, | |
metadata: b | |
} | |
} | |
} | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/reactor.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a() { | |
if (!(this instanceof a)) return new a; | |
this._mediator = new k; | |
this._reactors = [] | |
} | |
function f(a) { | |
function b(a, d) { | |
this._mediator = a; | |
var k = c.call(this); | |
d && this.attach(d); | |
return void 0 === k ? this : k | |
} | |
if (!(this instanceof f)) return new f(a); | |
d.call(this); | |
this._mediator; | |
this._registry = []; | |
a = a || {}; | |
var c = a._construct || function () {}; | |
b.prototype = this; | |
b.prototype.constructor = f; | |
var k = /([A-Z]+)\s+(.+)/, | |
g; | |
for (g in a) | |
if (a.hasOwnProperty(g)) { | |
var h = a[g], | |
m = g.match(k); | |
m && "function" == typeof h ? this._createHandler(m[1], m[2], h) : this[g] = h | |
} | |
return b | |
} | |
var m = | |
Array.prototype.slice, | |
h = b("node_modules/spotify-inheritance/inherit.js"), | |
g = b("node_modules/spotify-promise/src/promise.js"), | |
d = b("node_modules/spotify-bridge/node_modules/spotify-queueable/src/queueable.js"), | |
c = b("node_modules/spotify-bridge/src/shell/dispatcher.js").DispatcherResponse, | |
k = b("node_modules/spotify-eventemitter/src/eventemitter.js"); | |
a.prototype.create = function (a) { | |
a = new f(a); | |
this._reactors.push(a); | |
return a | |
}; | |
a.prototype.remove = function (a) { | |
var b = this._reactors, | |
c = b.indexOf(a); - 1 != b.indexOf(a) && | |
b.splice(c, 1); | |
return this | |
}; | |
a.prototype.add = function (a) { | |
if ("function" != typeof a || !(a.prototype instanceof f)) throw new TypeError("Argument `reactor` must be a reactor."); | |
var b = this._reactors; - 1 == b.indexOf(a) && b.push(a); | |
return this | |
}; | |
a.prototype.attach = function (a) { | |
for (var b = this._reactors, c = 0, d = b.length; c < d; c++)(new b[c](this._mediator)).attach(a); | |
return this | |
}; | |
a.prototype.getMediator = function () { | |
return this._mediator | |
}; | |
h(f, d); | |
f.prototype._createHandler = function (a, b, c) { | |
var d = c.name; | |
if (!d || "anonymous" == | |
d) { | |
var k = a.toLowerCase(), | |
d = b.split("/"), | |
k = [k]; | |
if (2 != d.length || d[0] || d[1]) | |
for (var g = function (a) { | |
return a.toUpperCase() | |
}, h = 0, f = d.length; h < f; h++) { | |
var m = d[h]; | |
m && k.push(m.replace(/^[a-z]/, g)) | |
} else k.push("Root"); | |
d = k.join("") | |
} | |
this[d] = c; | |
this._registry.push({ | |
method: a, | |
path: b, | |
handler: d | |
}) | |
}; | |
f.prototype._subscribe = function (a, b) { | |
this._mediator.addEvent(a, b.bind(this)); | |
return this | |
}; | |
f.prototype._subscribeAll = function (a) { | |
for (var b in a) a.hasOwnProperty(b) && this._mediator.addEvent(b, a[b].bind(this)); | |
return this | |
}; | |
f.prototype._unsubscribe = | |
function (a, b) { | |
"object" == typeof a ? this._mediator.removeEvents(a) : this._mediator.removeEvents(a, b); | |
return this | |
}; | |
f.prototype._broadcast = function (a, b) { | |
b = m.call(arguments, 1); | |
this._mediator.fireEvent(a, b); | |
return this | |
}; | |
f.prototype._broadcastFlush = function () { | |
this._broadcast("resources.flush") | |
}; | |
f.prototype._waitForServices = function (a) { | |
var b = 0, | |
c = [], | |
d; | |
for (d in a) c.push(this[d] = a[d]), b++; | |
a = function () { | |
!--b && this._onServicesReady && this._onServicesReady() | |
}.bind(this); | |
for (d = b; d--;) c[d].onReady(a, this); | |
return this | |
}; | |
f.prototype._onServicesReady = function () { | |
this._setReady() | |
}; | |
f.prototype._waitForCalls = function (a) { | |
var b = this, | |
c = m.call(arguments), | |
d = {}, k = c.length; | |
c.forEach(function (a) { | |
var c = b[a]; | |
if (!a || !c || "function" != typeof c) throw Error('No such method "' + a + '" in Reactor.'); | |
b[a] = function () { | |
c.apply(this, arguments); | |
d[a] || (k--, d[a] = !0, k || b._onWaitedCallsDone()) | |
} | |
}) | |
}; | |
f.prototype._onWaitedCallsDone = function () {}; | |
f.prototype._createResponse = function (a, b, d) { | |
return new c(a, b, d) | |
}; | |
f.prototype._createPromise = function () { | |
return new g | |
}; | |
f.prototype._wrapDecoratorRequest = function (a) { | |
return function (b) { | |
return a({ | |
flush: !0 | |
}, { | |
uris: b | |
}).then(function (a) { | |
return a.body.result | |
}) | |
} | |
}; | |
f.prototype.attach = function (a) { | |
if (!a || "function" != typeof a.register) throw new TypeError("Reactor.attach: Argument `dispatcher` must be a Dispatcher object."); | |
for (var b = this._registry, c = [], d = 0, k = b.length; d < k; d++) { | |
var g = b[d], | |
h = g.method, | |
f = g.path, | |
g = this._makeQueueable(this[g.handler].bind(this)); | |
a.register(h, f, g); | |
c.push({ | |
method: h, | |
path: f, | |
handler: g | |
}) | |
} | |
return c | |
}; | |
l.exports = { | |
HandlerDescriptor: void 0, | |
HandlerDescriptorList: void 0, | |
ReactorSet: a, | |
Reactor: f | |
} | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/reactors/lists.js": function (b, l, f, n, p, r) { | |
(function () { | |
var a = b("node_modules/spotify-bridge/src/shell/lists.js").Descriptor, | |
f = b("node_modules/spotify-bridge/src/shell/dispatcher.js").ResponseStatus, | |
m = new(b("node_modules/spotify-bridge/src/shell/reactor.js").Reactor)({ | |
_construct: function () { | |
this._listManager = null; | |
this._subscribeAll({ | |
"resources.listmanager": this._onListManager | |
}); | |
this._setReady() | |
}, | |
_onListManager: function (a) { | |
this._listManager = a | |
}, | |
"GET /list": function (b, g) { | |
var d = this._createPromise(), | |
c = this._createResponse(), | |
k = b.body.descriptor; | |
!k || k instanceof a.Base || (k = a.from(k)); | |
c.setBodyField("descriptor", k); | |
if (!k) return c.setStatus(f.BAD_REQUEST), d.fail(c), d; | |
(k = this._listManager.get(k)) ? (c.setStatus(f.OK).setBodyField("list", k), d.fulfill(c)) : (c.setStatus(f.NOT_FOUND), d.fail(c)); | |
return d | |
}, | |
"UPDATE /list": function (b, g) { | |
var d = this._createPromise(), | |
c = this._createResponse(), | |
k = a.extractList(b.body.descriptor); | |
this._listManager.set(k, b.body.list) ? (c.setStatus(f.OK).setBodyField("descriptor", k), d.fulfill(c)) : (c.setStatus(f.BAD_REQUEST), d.fail(c)); | |
return d | |
} | |
}); | |
l.exports = m | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/reactors/resources.js": function (b, l, f, n, p, r) { | |
(function () { | |
var a = new(b("node_modules/spotify-bridge/src/shell/reactor.js").Reactor)({ | |
_construct: function () { | |
this._trackListResolver = this._storage = this._playerGroup = this._listManager = this._CDNUrls = this._core = null; | |
this._coreRequestPromise = | |
this._createPromise(); | |
this._sourceRequestPromise = this._createPromise(); | |
this._listManagerRequestPromise = this._createPromise(); | |
this._playerGroupPromise = this._createPromise(); | |
this._storageRequestPromise = this._createPromise(); | |
this._trackListResolverPromise = this._createPromise(); | |
this._setReady() | |
}, | |
"FLUSH /resources": function (a, b) { | |
var h = this._createPromise(); | |
h.fulfill(!0); | |
this._broadcastFlush(); | |
return h | |
}, | |
"CREATE /resources/core": function (a, b) { | |
var h = this._createPromise(); | |
this._core || (this._core = a.body.core, | |
this._broadcast("resources.core", this._core), this._coreRequestPromise.fulfill(this._core), h.fulfill(!0)); | |
return h | |
}, | |
"GET /resources/core": function (a, b) { | |
var h = this._createPromise(); | |
this._core ? h.fulfill(this._core) : this._coreRequestPromise.pipe(h); | |
return h | |
}, | |
"CREATE /resources/image": function (a, b) { | |
var h = a.body, | |
g = this._createPromise(); | |
h.sources ? (this._CDNUrls = h.sources, this._broadcast("resources.image", this._CDNUrls), this._sourceRequestPromise.fulfill(this._CDNUrls), g.fulfill(!0)) : g.fulfill(!1); | |
return g | |
}, | |
"GET /resources/image": function (a, b) { | |
var h = this._createPromise(); | |
this._CDNUrls ? h.fulfill(this._CDNUrls) : this._sourceRequestPromise.pipe(h); | |
return h | |
}, | |
"CREATE /resources/listmanager": function (a, b) { | |
var h = a.body, | |
g = this._createPromise(); | |
h.listManager ? (this._listManager = h.listManager, this._broadcast("resources.listmanager", this._listManager), this._listManagerRequestPromise.fulfill(this._listManager), g.fulfill(!0)) : g.fulfill(!1); | |
return g | |
}, | |
"GET /resources/listmanager": function (a, b) { | |
var h = this._createPromise(); | |
this._listManager ? h.fulfill(this._listManager) : this._listManagerRequestPromise.pipe(h); | |
return h | |
}, | |
"CREATE /resources/playergroup": function (a, b) { | |
var h = a.body, | |
g = this._createPromise(); | |
h.playerGroup ? (this._playerGroup = h.playerGroup, this._broadcast("resources.playergroup", this._playerGroup), this._playerGroupPromise.fulfill(this._playerGroup), g.fulfill(!0)) : g.fulfill(!1); | |
return g | |
}, | |
"GET /resources/playergroup": function (a, b) { | |
var h = this._createPromise(); | |
this._playerGroup ? h.fulfill(this._playerGroup) : this._playerGroupPromise.pipe(h); | |
return h | |
}, | |
"CREATE /resources/storage": function (a, b) { | |
var h = a.body, | |
g = this._createPromise(); | |
h.storage ? (this._storage = h.storage, this._broadcast("resources.storage", this._storage), this._storageRequestPromise.fulfill(this._storage), g.fulfill(!0)) : g.fulfill(!1); | |
return g | |
}, | |
"GET /resources/storage": function (a, b) { | |
var h = this._createPromise(); | |
this._storage ? h.fulfill(this._storage) : this._storageRequestPromise.pipe(h); | |
return h | |
}, | |
"CREATE /resources/tracklistresolver": function (a, b) { | |
var h = a.body, | |
g = this._createPromise(); | |
h.trackListResolver ? (this._trackListResolver = h.trackListResolver, this._broadcast("resources.tracklistresolver", this._trackListResolver), this._trackListResolverPromise.fulfill(this._trackListResolver), g.fulfill(!0)) : g.fulfill(!1); | |
return g | |
}, | |
"GET /resources/tracklistresolver": function (a, b) { | |
var h = this._createPromise(); | |
this._trackListResolver ? h.fulfill(this._trackListResolver) : this._trackListResolverPromise.pipe(h); | |
return h | |
} | |
}); | |
l.exports = a | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/reactors/suggest.js": function (b, | |
l, f, n, p, r) { | |
(function () { | |
var a = Spotify.Link, | |
f = b("node_modules/spotify-bridge/src/shell/extension.js").LinkHelper, | |
m = b("node_modules/spotify-bridge/src/shell/dispatcher.js").ResponseStatus, | |
h = new(b("node_modules/spotify-bridge/src/shell/reactor.js").Reactor)({ | |
_construct: function () { | |
this._cdnUrls = this._suggestService = null; | |
this._waitForCalls("_onImageResources", "_onServicesReady"); | |
this._subscribeAll({ | |
"resources.core": this._onCore, | |
"resources.image": this._onImageResources | |
}) | |
}, | |
_onCore: function (a) { | |
this._waitForServices({ | |
_suggestService: a.suggest | |
}) | |
}, | |
_onImageResources: function (a) { | |
this._cdnUrls = a | |
}, | |
_onServicesReady: function () {}, | |
_onWaitedCallsDone: function () { | |
this._setReady() | |
}, | |
_querySuggestions: function (a) { | |
var b = this._createPromise(); | |
this._suggestService.suggest(a, function (a) { | |
b.fulfill(a) | |
}, function (a) { | |
b.fail(a) | |
}); | |
return b | |
}, | |
_getSuggestByType: function (a, b, c) { | |
var k = this._createResponse(); | |
return (b = f.from(b.body.uri)) && this._responseParsers[a] ? this._querySuggestions(b.query).then(this._responseParsers[a].bind(this)).then(function (a) { | |
return k.setBodyField("list", | |
a) | |
}).catchError(function () { | |
return k.setStatus(m.BAD_REQUEST) | |
}) : k.setStatus(m.BAD_REQUEST) | |
}, | |
_createImageLink: function (a) { | |
return this._cdnUrls.small + a | |
}, | |
_responseParsers: { | |
albums: function (b) { | |
b = b.albums; | |
var d = []; | |
if (b) | |
for (var c = 0, k = b.length; c < k; c++) { | |
for (var h = b[c], f = [], m = 0, l = h.artists.length; m < l; m++) { | |
var q = h.artists[m]; | |
f.push({ | |
uri: a.artistLink(q.id).toString(), | |
name: q.name | |
}) | |
} | |
d.push({ | |
uri: a.albumLink(h.id).toString(), | |
name: h.name, | |
image: this._createImageLink(h.image), | |
artists: f, | |
popularity: h.popularity | |
}) | |
} | |
return d | |
}, | |
artists: function (b) { | |
b = b.artists; | |
var d = []; | |
if (b) | |
for (var c = 0, k = b.length; c < k; c++) { | |
var h = b[c]; | |
d.push({ | |
uri: a.artistLink(h.id).toString(), | |
name: h.name, | |
image: this._createImageLink(h.image), | |
popularity: h.popularity | |
}) | |
} | |
return d | |
}, | |
tracks: function (b) { | |
b = b.tracks; | |
var d = []; | |
if (b) | |
for (var c = 0, k = b.length; c < k; c++) { | |
for (var h = b[c], f = [], m = 0, l = h.artists.length; m < l; m++) f.push({ | |
uri: a.artistLink(h.artists[m].id).toString(), | |
name: h.artists[m].name | |
}); | |
d.push({ | |
uri: a.trackLink(h.id).toString(), | |
name: h.name, | |
image: this._createImageLink(h.image), | |
artists: f, | |
popularity: h.popularity | |
}) | |
} | |
return d | |
}, | |
playlists: function (a) { | |
a = a.playlist; | |
var b = []; | |
if (a) | |
for (var c = 0, k = a.length; c < k; c++) { | |
var h = a[c]; | |
b.push({ | |
uri: h.uri, | |
image: this._createImageLink(h.image), | |
name: h.name, | |
popularity: h.popularity | |
}) | |
} | |
return b | |
} | |
}, | |
"GET /suggest/albums": function (a, b) { | |
return this._getSuggestByType("albums", a, b) | |
}, | |
"GET /suggest/artists": function (a, b) { | |
return this._getSuggestByType("artists", a, b) | |
}, | |
"GET /suggest/tracks": function (a, b) { | |
return this._getSuggestByType("tracks", a, b) | |
}, | |
"GET /suggest/playlists": function (a, | |
b) { | |
return this._getSuggestByType("playlists", a, b) | |
} | |
}); | |
l.exports = h | |
})() | |
}, | |
"node_modules/cosmos-router-js/node_modules/cosmos-common-js/src/request.js": function (b, l, f, n, p, r) { | |
function a(b, h, g, d) { | |
if (!(this instanceof a)) return new a(b, h, g, d); | |
if (!b) throw new TypeError("Invalid `action` argument for Request."); | |
q.call(this, h, g, d); | |
this._action = b | |
} | |
l = b("node_modules/cosmos-router-js/node_modules/js-common/index.js").helpers; | |
var q = b("node_modules/cosmos-router-js/node_modules/cosmos-common-js/src/message.js").Message; | |
f.Action = { | |
DELETE: "DELETE", | |
GET: "GET", | |
HEAD: "HEAD", | |
POST: "POST", | |
PUT: "PUT", | |
SUB: "SUB" | |
}; | |
f.SerializedRequest; | |
l.inherit(a, q); | |
f.Request = a; | |
a.fromObject = function (b) { | |
return b && b.action && b.uri ? new a(b.action, b.uri, b.headers, b.body) : null | |
}; | |
a.prototype.getAction = function () { | |
return this._action | |
}; | |
a.prototype.copy = function (b, h) { | |
return new a(this._action, this._uri, this._copyHeaders(b), "undefined" != typeof h ? h : this._body) | |
}; | |
a.prototype.toJSON = function () { | |
return { | |
action: this._action, | |
uri: this._uri, | |
headers: this._headers, | |
body: this._body | |
} | |
} | |
}, | |
"node_modules/cosmos-router-js/node_modules/cosmos-common-js/src/response.js": function (b, l, f, n, p, r) { | |
function a(b, h, g, d) { | |
if (!(this instanceof a)) return new a(b, h, g, d, opt_requestURI); | |
if ("undefined" == typeof h || null == h) throw new TypeError("Invalid `status` argument for Response."); | |
q.call(this, b, g, d); | |
this._status = h | |
} | |
l = b("node_modules/cosmos-router-js/node_modules/js-common/index.js").helpers; | |
var q = b("node_modules/cosmos-router-js/node_modules/cosmos-common-js/src/message.js").Message; | |
f.StatusCode = { | |
OK: 200, | |
CREATED: 201, | |
ACCEPTED: 202, | |
BAD_REQUEST: 400, | |
UNAUTHORIZED: 401, | |
FORBIDDEN: 403, | |
NOT_FOUND: 404, | |
METHOD_NOT_ALLOWED: 405, | |
TIMED_OUT: 408, | |
CONFLICT: 409, | |
GONE: 410, | |
INTERNAL_SERVER_ERROR: 500, | |
NOT_IMPLEMENTED: 501, | |
BAD_GATEWAY: 502, | |
SERVICE_UNAVAILABLE: 503 | |
}; | |
f.SerializedResponse; | |
l.inherit(a, q); | |
f.Response = a; | |
a.fromObject = function (b) { | |
return b && b.uri && b.status ? new a(b.uri, b.status, b.headers, b.body) : null | |
}; | |
a.prototype.getMimeType = function () { | |
return this._headers["content-type"] | |
}; | |
a.prototype.getStatusCode = function () { | |
return this._status | |
}; | |
a.prototype.copy = function (b, h) { | |
return new a(this._uri, this._status, this._copyHeaders(b), "undefined" != typeof h ? h : this._body) | |
}; | |
a.prototype.toJSON = function () { | |
return { | |
uri: this._uri, | |
status: this._status, | |
headers: this._headers, | |
body: this._body | |
} | |
} | |
}, | |
"node_modules/cosmos-router-js/node_modules/cosmos-common-js/src/player_state.js": function (b, l, f, n, p, r) { | |
function a(a) { | |
this._props = "action context tracks index playing loading track position duration volume options play_origin next_page_url prev_page_url".split(" "); | |
a = a || {}; | |
this.action = a.action; | |
this.context = a.context; | |
this.tracks = a.tracks; | |
this.index = a.index; | |
this.playing = a.playing; | |
this.loading = a.loading; | |
this.track = a.track; | |
this.position = a.position; | |
this.volume = a.volume; | |
this.duration = a.duration; | |
this.options = new m(a.options); | |
this.play_origin = new q(a.play_origin); | |
this.next_page_url = a.next_page_url; | |
this.prev_page_url = a.prev_page_url | |
} | |
function q(a) { | |
this._props = ["source", "reason", "referrer", "referrer_version", "referrer_vendor"]; | |
a = a || {}; | |
this.source = a.source || "unknown"; | |
this.reason = | |
a.reason || "unknown"; | |
this.referrer = a.referrer || "unknown"; | |
this.referrer_version = a.referrer_version || "unknown"; | |
this.referrer_vendor = a.referrer_vendor || "unknown" | |
} | |
function m(a) { | |
this._props = "repeat shuffle can_repeat can_shuffle can_skip_prev can_skip_next can_seek use_dmca_rules".split(" "); | |
a = a || {}; | |
this.repeat = void 0 !== a.repeat ? a.repeat : !1; | |
this.shuffle = void 0 !== a.shuffle ? a.shuffle : !1; | |
this.can_repeat = void 0 !== a.can_repeat ? a.can_repeat : !0; | |
this.can_shuffle = void 0 !== a.can_shuffle ? a.can_shuffle : !0; | |
this.can_skip_prev = | |
void 0 !== a.can_skip_prev ? a.can_skip_prev : !0; | |
this.can_skip_next = void 0 !== a.can_skip_next ? a.can_skip_next : !0; | |
this.can_seek = void 0 !== a.can_seek ? a.can_seek : !0; | |
this.use_dmca_rules = void 0 !== a.use_dmca_rules ? a.use_dmca_rules : !1 | |
} | |
function h(a) { | |
this._props = a || [] | |
} | |
b = b("node_modules/cosmos-router-js/node_modules/js-common/index.js").helpers; | |
b.inherit(a, h); | |
a.prototype.serialize = function () { | |
!this.options || this.options instanceof m || (this.options = new m(this.options)); | |
!this.play_origin || this.play_origin instanceof | |
q || (this.play_origin = new q(this.play_origin)); | |
return this._super("serialize", []) | |
}; | |
a.ACTIONS = { | |
UNKNOWN: "unknown", | |
PLAY: "play", | |
UPDATE: "update", | |
STOP: "stop", | |
RESUME: "resume", | |
PAUSE: "pause", | |
SKIP_PREV: "skip_prev", | |
SKIP_NEXT: "skip_next" | |
}; | |
b.inherit(q, h); | |
b.inherit(m, h); | |
h.prototype.serialize = function () { | |
for (var a = {}, b, c = 0, k = this._props.length; c < k; c++) b = this._props[c], void 0 !== this[b] && (a[b] = this[b] instanceof h ? this[b].serialize() : this[b]); | |
return a | |
}; | |
f.PlayerState = a | |
}, | |
"node_modules/cosmos-router-js/node_modules/cosmos-common-js/index.js": function (b, | |
l, f, n, p, r) { | |
f.helpers = b("node_modules/cosmos-router-js/node_modules/js-common/index.js").helpers; | |
f.message = b("node_modules/cosmos-router-js/node_modules/cosmos-common-js/src/message.js"); | |
f.request = b("node_modules/cosmos-router-js/node_modules/cosmos-common-js/src/request.js"); | |
f.response = b("node_modules/cosmos-router-js/node_modules/cosmos-common-js/src/response.js"); | |
f.playerstate = b("node_modules/cosmos-router-js/node_modules/cosmos-common-js/src/player_state.js") | |
}, | |
"node_modules/cosmos-router-js/src/bridge.js": function (b, | |
l, f, n, p, r) { | |
(function () { | |
function a(b, c) { | |
if (!(this instanceof a)) return new a; | |
if ("function" !== typeof c) throw new TypeError("Parameter `routerFactory` needs to be a function"); | |
this._router = h; | |
this._appManager = b; | |
this._routerFactory = c; | |
this._requestHandlers = new s; | |
this._handleMessage = this._handleMessage.bind(this); | |
this.attach() | |
} | |
var l = b("node_modules/cosmos-router-js/node_modules/js-common/index.js"), | |
m = b("node_modules/cosmos-router-js/node_modules/cosmos-common-js/index.js"), | |
h = l.postrouter, | |
g = m.request.Request, | |
l = m.response, | |
d = l.Response, | |
c = l.StatusCode, | |
k = b("node_modules/cosmos-router-js/src/requesthandler.js").RequestHandler, | |
s = b("node_modules/cosmos-router-js/src/weakmap.js").WeakMap; | |
f.Bridge = a; | |
a.prototype.attach = function () { | |
this._router.addMessageHandler("cosmos-request", this._handleMessage) | |
}; | |
a.prototype.detach = function () { | |
this._router.removeMessageHandler("cosmos-request", this._handleMessage) | |
}; | |
a.prototype.registerApp = function (a, b) { | |
if (this._requestHandlers.get(a)) throw Error("Router for " + id + " already exists"); | |
this._requestHandlers.set(a, b); | |
return b | |
}; | |
a.prototype.unregisterApp = function (a) { | |
var b = this._requestHandlers.get(a); | |
if (b) return b.closeAll(), this._requestHandlers.remove(a), !0 | |
}; | |
a.prototype._handleMessage = function (a) { | |
var b; | |
try { | |
b = JSON.parse(a.data) | |
} catch (h) {} | |
var f = b.payload, | |
m = this._createResponder(b.id, b.resolver, b.name, a.source); | |
a = this._appManager.getFromWindow(a.source); | |
var s = this._requestHandlers.get(a); | |
if (!s) { | |
s = this._routerFactory(a); | |
if (!(s = this.registerApp(a, new k(s)))) return; | |
a.addEvent("destroy", | |
this.unregisterApp.bind(this, a)) | |
} | |
switch (b.name) { | |
case "cosmos_request_create": | |
try { | |
var l = g.fromObject(f); | |
s.openRequest(b.id, l, m) | |
} catch (q) { | |
m(new d(q.message, c.BAD_REQUEST)); | |
break | |
} | |
break; | |
case "cosmos_request_cancel": | |
try { | |
s.closeRequest(b.id, m) | |
} catch (n) { | |
m(new d(n.message, c.BAD_REQUEST)); | |
break | |
} | |
break; | |
default: | |
m(new d("Request type not implemented", c.NOT_FOUND)) | |
} | |
}; | |
a.prototype._createResponder = function (a, b, c, d) { | |
return function (k) { | |
k = k || {}; | |
d.postMessage(JSON.stringify({ | |
type: "cosmos-response", | |
id: a, | |
resolver: b, | |
name: c, | |
payload: k.serialize ? k.serialize() : k | |
}), "*") | |
} | |
} | |
})() | |
}, | |
"node_modules/cosmos-router-js/src/router.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(b, c, d) { | |
if (!(this instanceof a)) return new a(b, c, d); | |
this._resolver = b; | |
this._level = c; | |
this._visited = null; | |
this._createVisited(d) | |
} | |
function l() { | |
if (!(this instanceof l)) return l; | |
g.call(this); | |
this._token = 0; | |
this._handlers = {}; | |
this._handlersArray = [] | |
} | |
var m = b("node_modules/cosmos-router-js/node_modules/js-common/index.js"), | |
h = b("node_modules/cosmos-router-js/node_modules/cosmos-common-js/index.js"), | |
m = m.helpers, | |
g = b("node_modules/cosmos-router-js/src/resolver.js").Resolver, | |
h = h.response, | |
d = h.Response, | |
c = h.StatusCode; | |
b("node_modules/cosmos-router-js/src/channel.js"); | |
f.Token; | |
f.Handler; | |
f.ResolversVisited; | |
a.prototype._createVisited = function (a) { | |
if (a) { | |
var b = function () {}; | |
b.prototype = a; | |
this._visited = new b | |
} else this._visited = {} | |
}; | |
a.prototype.getLevel = function () { | |
return this._level | |
}; | |
a.prototype.getVisited = function () { | |
return this._visited | |
}; | |
a.prototype.resolve = function (b) { | |
return this._resolver.resolve(b, new a(this._resolver, | |
this._level + 1), new a(this._resolver, this._level + 1, this._visited)) | |
}; | |
m.inherit(l, g); | |
f.Router = l; | |
l.prototype.registerResolver = function (a, b) { | |
if (!a || "function" != typeof a.resolve || "function" != typeof a.getRequestFilter) throw new TypeError("Invalid arguments for registerResolver."); | |
var c = b && "function" == typeof b.match ? b : a.getRequestFilter(), | |
d = this._token++, | |
c = { | |
filter: c, | |
priority: c.getPriority(), | |
resolver: a, | |
token: d | |
}; | |
this._handlers[d] = c; | |
this._insertIntoHandlersArray(c); | |
return d | |
}; | |
l.prototype._insertIntoHandlersArray = | |
function (a) { | |
for (var b = this._handlersArray, c = a.priority, d = 0, g = b.length; d < g; d++) | |
if (c > b[d].priority) { | |
b.splice(d, 0, a); | |
return | |
} | |
b.push(a) | |
}; | |
l.prototype.unregisterResolver = function (a) { | |
if ("number" != typeof a) throw new TypeError("Invalid arguments for unregisterResolver."); | |
var b = this._handlers, | |
c = this._handlersArray, | |
d = b[a]; | |
if (!d) return !1; | |
b[a] = null; | |
a = c.indexOf(d); - 1 != a && c.splice(a, 1); | |
return !0 | |
}; | |
l.prototype._findMatchingResolver = function (a, b) { | |
for (var c = this._handlersArray, d = 0, g = c.length; d < g; d++) { | |
var h = c[d]; | |
if (!(h.token in | |
b) && (b[h.token] = !0, h.filter.match(a))) return h | |
} | |
return null | |
}; | |
l.prototype._resolveUnmatchedRequest = function (a) { | |
var b = this._createChannel(); | |
a = new d(a.getURI(), c.NOT_FOUND, { | |
"content-type": a.getMimeType() | |
}, null); | |
b.getSink().push(a); | |
return b.getSource() | |
}; | |
l.prototype._resolveInfiniteRequest = function (a) { | |
var b = this._createChannel(); | |
a = new d(a.getURI(), 508, { | |
"content-type": a.getMimeType() | |
}, null); | |
b.getSink().push(a); | |
return b.getSource() | |
}; | |
l.prototype.resolve = function (b, c, d) { | |
c = c || new a(this, 0); | |
d = d || new a(this, 0); | |
if (1E3 <= c.getLevel()) return this._resolveInfiniteRequest(b); | |
var g = this._findMatchingResolver(b, d.getVisited()); | |
return g ? g.resolver.resolve(b, c, d) : this._resolveUnmatchedRequest(b) | |
} | |
})() | |
}, | |
"node_modules/cosmos-router-js/src/services/echo.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a() { | |
if (!(this instanceof a)) return new a; | |
h.call(this, new g({ | |
uri: "sp://echo**" | |
})); | |
this._serviceURI = "sp://echo" | |
} | |
var l = b("node_modules/cosmos-router-js/node_modules/js-common/index.js"), | |
m = b("node_modules/cosmos-router-js/node_modules/cosmos-common-js/index.js"), | |
l = l.helpers, | |
h = b("node_modules/cosmos-router-js/src/resolver.js").Resolver, | |
g = b("node_modules/cosmos-router-js/src/requestfilter.js").RequestFilter, | |
d = m.request.Action, | |
m = m.response, | |
c = m.Response, | |
k = m.StatusCode; | |
l.inherit(a, h); | |
f.EchoService = a; | |
a.prototype.resolve = function (a) { | |
var b = this._createChannel(), | |
c = b.getSink(); | |
a.getURI() == this._serviceURI ? a.getAction() == d.GET ? c.push(this._createEchoResponse(a)) : c.push(this._createFailResponse(k.METHOD_NOT_ALLOWED, a)) : c.push(this._createFailResponse(k.BAD_REQUEST, a)); | |
return b.getSource() | |
}; | |
a.prototype._createEchoResponse = function (a) { | |
return new c(this._serviceURI, k.OK, { | |
"Content-Type": a.getMimeType() | |
}, a.getBody()) | |
}; | |
a.prototype._createFailResponse = function (a, b) { | |
return new c(b.getURI(), a, { | |
"Content-Type": b.getMimeType() | |
}, null) | |
} | |
})() | |
}, | |
"node_modules/cosmos-router-js/src/services/hermes.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(b) { | |
if (!(this instanceof a)) return new a(b); | |
if (!b || "function" != typeof b.send) throw new TypeError("Invalid hermesProvider argument for HermesService."); | |
g.call(this, new h({ | |
uri: "hm**" | |
})); | |
this._provider = b | |
} | |
var l = b("node_modules/cosmos-router-js/node_modules/js-common/index.js"), | |
m = b("node_modules/cosmos-router-js/node_modules/cosmos-common-js/index.js"), | |
l = l.helpers, | |
h = b("node_modules/cosmos-router-js/src/requestfilter.js").RequestFilter, | |
g = b("node_modules/cosmos-router-js/src/resolver.js").Resolver, | |
d = m.response.Response; | |
f.HermesProvider; | |
l.inherit(a, g); | |
f.HermesService = a; | |
a.prototype._sendRequest = function (a) { | |
var b = this._createChannel(), | |
g = b.getSink(), | |
h = a.getBody(), | |
f = this; | |
this._provider.send(a.getURI(), a.getAction(), [], [], h ? [h] : [], function (a, b, c) { | |
c.content_type && (c["content-type"] = c.content_type); | |
a = Array.isArray(a) && 1 == a.length ? a[0] : a; | |
f._isUTF8response(c["content-type"]) && "string" === typeof a && (a = decodeURIComponent(escape(a))); | |
a = new d(c.uri, b, c, a); | |
g.push(a) | |
}, function (b) { | |
b.data && "object" == typeof b.data ? b.data["content-type"] = a.getMimeType() : b.data = { | |
"content-type": a.getMimeType() | |
}; | |
b = new d(a.getURI(), b.code, b.data, null); | |
g.push(b) | |
}); | |
return b.getSource() | |
}; | |
a.prototype.resolve = | |
function (a) { | |
return this._sendRequest(a) | |
}; | |
a.prototype._isUTF8response = function (a) { | |
a && (a = a.replace(/\s+/, ""), a = a.toLowerCase(), a = a.split(";")); | |
return a && -1 < a.indexOf("charset=utf-8") | |
} | |
})() | |
}, | |
"node_modules/cosmos-router-js/src/services/http.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a() {} | |
function l(a) { | |
if (!(this instanceof l)) return new l(a); | |
if (!a) throw new TypeError("Invalid XMLHttpRequestClass argument for HTTPService."); | |
d.call(this, new g({ | |
uri: "http**" | |
})); | |
this._XMLHTTPRequestClass = a | |
} | |
var m = b("node_modules/cosmos-router-js/node_modules/js-common/index.js"), | |
h = b("node_modules/cosmos-router-js/node_modules/cosmos-common-js/index.js"), | |
m = m.helpers, | |
g = b("node_modules/cosmos-router-js/src/requestfilter.js").RequestFilter, | |
d = b("node_modules/cosmos-router-js/src/resolver.js").Resolver, | |
c = h.response, | |
k = h.request.Action, | |
s = c.Response, | |
x = c.StatusCode; | |
a.prototype.open = function (a, b, c) {}; | |
a.prototype.setRequestHeader = function (a, b) {}; | |
a.prototype.getResponseHeader = function (a) {}; | |
a.prototype.getAllResponseHeaders = function () {}; | |
a.prototype.send = function (a) {}; | |
a.prototype.onreadystatechange = | |
function () {}; | |
a.prototype.onerror = function () {}; | |
m.inherit(l, d); | |
f.HTTPService = l; | |
l.prototype._createRequest = function (a) { | |
var b = new this._XMLHTTPRequestClass; | |
b.open(a.getAction().toUpperCase(), a.getURI(), !0); | |
a.getAction() === k.POST && b.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); | |
var c = a.getHeaders(), | |
d; | |
for (d in c) b.setRequestHeader(d, c[d]); | |
b.setRequestHeader("accept", a.getMimeType()); | |
return b | |
}; | |
l.prototype._attachRequestEvents = function (a, b) { | |
var c = this, | |
d = this._createChannel(), | |
k = d.getSink(); | |
b.onreadystatechange = function () { | |
if (4 == b.readyState) { | |
var d = a.getURI(); | |
try { | |
d = b.getResponseHeader("Location") || d | |
} catch (g) {} | |
d = new s(d, b.status, c._parseResponseHeaders(b.getAllResponseHeaders()), b.responseText); | |
k.push(d) | |
} | |
}; | |
b.onerror = function () { | |
var b = new s(a.getURI(), x.BAD_GATEWAY, { | |
"Content-Type": a.getMimeType() | |
}, null); | |
k.push(b) | |
}; | |
return d.getSource() | |
}; | |
l.prototype._parseResponseHeaders = function (a) { | |
a = a.split("\n"); | |
for (var b = {}, c = 0, d = a.length; c < d; c++) { | |
var k = a[c]; | |
k && (k = k.match(/^([^:]+):\s(.*)$/)) && (b[k[1]] = | |
k[2]) | |
} | |
return b | |
}; | |
l.prototype.resolve = function (a) { | |
var b = this._createRequest(a), | |
c = this._attachRequestEvents(a, b); | |
b.send(a.getBody()); | |
return c | |
} | |
})() | |
}, | |
"node_modules/cosmos-router-js/src/services/protobuf.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a() { | |
if (!(this instanceof a)) return new a; | |
c.call(this, new g(null, d.HIGHEST)); | |
this._uri = "sp://protobuf/v1/schemas"; | |
this._uid = 0; | |
this._schemas = {}; | |
this._filters = []; | |
this._schemaRequestFilter = new g({ | |
uri: this._uri + "**" | |
}) | |
} | |
var l = b("node_modules/cosmos-router-js/node_modules/js-common/index.js"), | |
m = b("node_modules/cosmos-router-js/node_modules/cosmos-common-js/index.js"), | |
l = l.helpers, | |
h = b("node_modules/cosmos-router-js/src/requestfilter.js"), | |
g = h.RequestFilter, | |
d = h.RequestFilterPriority, | |
c = b("node_modules/cosmos-router-js/src/resolver.js").Resolver, | |
m = m.response, | |
k = m.Response, | |
s = m.StatusCode; | |
f.ProtobufSchemaString; | |
f.ProtobufSchemaDescriptor; | |
f.ProtobufSchema; | |
f.ProtobufRequestFilter; | |
l.inherit(a, c); | |
f.ProtobufResolver = a; | |
a.prototype._processSchemaRequest = function (a) { | |
switch (a.getAction()) { | |
case "GET": | |
return this._getSchemaRequest(a); | |
case "POST": | |
return this._postSchemaRequest(a); | |
case "DELETE": | |
return this._deleteSchemaRequest(a); | |
default: | |
return this._notAllowedSchemaRequest(a) | |
} | |
}; | |
a.prototype._getSchemaRequest = function (a) { | |
var b = this._createChannel(), | |
c = b.getSink(), | |
d = a.getURI().replace(this._uri + "/", ""); | |
(d = this._schemas[d]) ? c.push(new k(a.getURI(), s.OK, {}, d.descriptor)) : c.push(new k(a.getURI(), s.NOT_FOUND)); | |
return b.getSource() | |
}; | |
a.prototype._postSchemaRequest = function (a) { | |
var b = this._createChannel(), | |
c = b.getSink(), | |
d = a.getJSONBody() || | |
a.getBody(); | |
if (d && d.schema && d.mappings && Array.isArray(d.mappings) && d.mappings.length) { | |
var g = this._uid + 1, | |
h = this._createSchema(d.schema); | |
if (!h) return this._invalidSchemaRequest(a); | |
h = this._createSchemaMappings(g, d.mappings, h); | |
if (!h) return this._invalidSchemaRequest(a); | |
var f = this._uri + "/" + g; | |
this._schemas[g] = { | |
id: g, | |
schema: null, | |
descriptor: d | |
}; | |
this._filters.push.apply(this._filters, h); | |
this._uid++; | |
c.push(new k(a.getURI(), s.CREATED, { | |
location: f | |
})) | |
} else return this._invalidSchemaRequest(a); | |
return b.getSource() | |
}; | |
a.prototype._createSchema = function (a) { | |
var b; | |
try { | |
return b = new Spotify.Protobuf.Schema([], null, null, null), b.type = "proto", b.setData(a), b.encode(), b | |
} catch (c) { | |
return null | |
} | |
}; | |
a.prototype._createSchemaMappings = function (a, b, c) { | |
for (var d = [], k = 0, h = b.length; k < h; k++) { | |
var f = b[k]; | |
if (!f.filter || f.request && !c.msg(f.request) || f.response && !c.msg(f.response)) return null; | |
d.push({ | |
id: a, | |
filter: new g(f.filter), | |
request: c.msg(f.request) || null, | |
response: c.msg(f.response) || null | |
}) | |
} | |
return d | |
}; | |
a.prototype._deleteSchemaRequest = function (a) { | |
var b = | |
this._createChannel(), | |
c = b.getSink(), | |
d = parseInt(a.getURI().replace(this._uri + "/", ""), 10), | |
g = this._schemas; | |
if (g[d]) { | |
g[d] = null; | |
for (var g = this._filters, h = [], f = 0, m = g.length; f < m; f++) { | |
var l = g[f]; | |
l.id != d && h.push(l) | |
} | |
this._filters = h; | |
c.push(new k(a.getURI(), s.OK)) | |
} else c.push(new k(a.getURI(), s.NOT_FOUND)); | |
return b.getSource() | |
}; | |
a.prototype._notAllowedSchemaRequest = function (a) { | |
var b = this._createChannel(); | |
a = new k(a.getURI(), s.METHOD_NOT_ALLOWED); | |
b.getSink().push(a); | |
return b.getSource() | |
}; | |
a.prototype._invalidSchemaRequest = | |
function (a) { | |
var b = this._createChannel(); | |
a = new k(a.getURI(), s.BAD_REQUEST); | |
b.getSink().push(a); | |
return b.getSource() | |
}; | |
a.prototype._processProtoRequest = function (a, b) { | |
for (var c = null, d = this._filters, k = 0, g = d.length; k < g; k++) { | |
var h = d[k]; | |
if (h.filter.match(a)) { | |
c = h; | |
break | |
} | |
} | |
if (c) { | |
var f, d = a.getJSONBody() || a.getBody(); | |
if (c.request) try { | |
f = c.request.serializeToStringSync(d) | |
} catch (m) { | |
return this._invalidSchemaRequest(a) | |
} | |
f = b.resolve(a.copy(null, f)); | |
if (c.response) { | |
var l = this._createChannel(), | |
s = this._createResponseParser(c.response); | |
f.consume(function (a) { | |
var b; | |
try { | |
b = s(a) | |
} catch (c) { | |
b = c | |
} | |
l.getSink().push(b) | |
}); | |
return l.getSource() | |
} | |
return f | |
} | |
return b.resolve(a) | |
}; | |
a.prototype._createResponseParser = function (a) { | |
return function (b) { | |
var c; | |
try { | |
c = a.parseFromStringSync(b.getBody()) | |
} catch (d) { | |
throw new k(b.getURI(), s.INTERNAL_SERVER_ERROR); | |
} | |
return b.copy(null, c) | |
} | |
}; | |
a.prototype.resolve = function (a, b, c) { | |
return this._schemaRequestFilter.match(a) ? this._processSchemaRequest(a) : this._processProtoRequest(a, c) | |
} | |
})() | |
}, | |
"node_modules/cosmos-router-js/src/services/player.js": function (b, | |
l, f, n, p, r) { | |
function a() {} | |
function q(a) { | |
if (!(this instanceof q)) return new q(a); | |
if (!a) throw new TypeError("Missing player argument for player service"); | |
h.call(this, new m({ | |
uri: "sp://player/v1/main" | |
})); | |
this._player = a | |
} | |
n = b("node_modules/cosmos-router-js/node_modules/js-common/index.js"); | |
l = b("node_modules/cosmos-router-js/node_modules/cosmos-common-js/index.js"); | |
n = n.helpers; | |
var m = b("node_modules/cosmos-router-js/src/requestfilter.js").RequestFilter, | |
h = b("node_modules/cosmos-router-js/src/resolver.js").Resolver; | |
p = l.response; | |
var g = p.Response, | |
d = p.StatusCode, | |
c = l.request.Action, | |
k = l.playerstate.PlayerState; | |
b("node_modules/cosmos-router-js/src/interface_helper.js"); | |
var s = "sp://player/v1/main"; | |
a.prototype.play = function (a) {}; | |
a.prototype.update = function (a) {}; | |
a.prototype.stop = function (a) {}; | |
a.prototype.pause = function (a) {}; | |
a.prototype.resume = function (a) {}; | |
a.prototype.next = function (a) {}; | |
a.prototype.previous = function (a) {}; | |
a.prototype.getState = function () {}; | |
a.prototype.subscribe = function () {}; | |
a.prototype.unsubscribe = function () {}; | |
n.inherit(q, h); | |
f.PlayerService = q; | |
q.prototype.resolve = function (a, b) { | |
function k(b, c) { | |
b ? f.push(new g(s, d.BAD_REQUEST)) : f.push(new g(s, d.OK, a.getHeaders(), c)) | |
} | |
var h = this._createChannel(), | |
f = h.getSink(), | |
m = a.getAction(), | |
l = a.getBody(); | |
switch (m) { | |
case c.POST: | |
this._postRequestHandler(l, b, k); | |
break; | |
case c.GET: | |
this._getRequestHandler(k); | |
break; | |
case c.SUB: | |
m = this._subRequestHandler(k); | |
f.addCloseCallback(this._subCloseRequestHandler.bind(this, m)); | |
break; | |
default: | |
f.push(new g(s, d.METHOD_NOT_ALLOWED)) | |
} | |
return h.getSource() | |
}; | |
q.prototype._subRequestHandler = function (a) { | |
return this._player.subscribe(a.bind(this)) | |
}; | |
q.prototype._subCloseRequestHandler = function (a) { | |
return this._player.unsubscribe(a) | |
}; | |
q.prototype._postRequestHandler = function (a, b, c) { | |
a = this._parseRequestBody(a); | |
switch (a.action) { | |
case "play": | |
this._player.play(a, b, c); | |
break; | |
case "update": | |
this._player.update(a, b, c); | |
break; | |
case "stop": | |
this._player.stop(a, c); | |
break; | |
case "pause": | |
this._player.pause(a, c); | |
break; | |
case "resume": | |
this._player.resume(a, c); | |
break; | |
case "skip_next": | |
this._player.next(a, | |
c); | |
break; | |
case "skip_prev": | |
this._player.previous(a, c); | |
break; | |
default: | |
c(Error("Unrecognized action")) | |
} | |
}; | |
q.prototype._getRequestHandler = function (a) { | |
var b = this; | |
this._player.getState(function (c, d) { | |
c || (d = b._parsePlayerState(d)); | |
a(c, d) | |
}) | |
}; | |
q.prototype._parsePlayerState = function (a) { | |
a instanceof k || (a = new k(a)); | |
return a.serialize() | |
}; | |
q.prototype._parseRequestBody = function (a) { | |
var b; | |
try { | |
b = JSON.parse(a) | |
} catch (c) {} | |
return b ? (new k(b)).serialize() : null | |
} | |
}, | |
"node_modules/cosmos-router-js/src/services/trackresolver.js": function (b, | |
l, f, n, p, r) { | |
function a(b) { | |
if (!(this instanceof a)) return new a(b); | |
if (!b) throw new TypeError("TrackListResolver is required."); | |
q.call(this, new g({ | |
uri: a.TRACK_RESOLVER_URI + "*" | |
}, d.HIGH)); | |
this._trackListResolver = b | |
} | |
l = b("node_modules/cosmos-router-js/node_modules/js-common/index.js"); | |
n = b("node_modules/cosmos-router-js/node_modules/cosmos-common-js/index.js"); | |
l = l.helpers; | |
var q = b("node_modules/cosmos-router-js/src/resolver.js").Resolver; | |
n = n.response; | |
var m = n.Response, | |
h = n.StatusCode; | |
b = b("node_modules/cosmos-router-js/src/requestfilter.js"); | |
var g = b.RequestFilter, | |
d = b.RequestFilterPriority; | |
l.inherit(a, q); | |
f.TrackResolverService = a; | |
a.TRACK_RESOLVER_URI = "hm://track-resolver/v1?uri="; | |
a.prototype._prepareList = function (a, b) { | |
for (var d = [], g = 0, h = b.length; g < h; g++) { | |
var f = b[g]; | |
f && f.uri && d.push({ | |
track: f.uri, | |
context: a | |
}) | |
} | |
return { | |
tracks: d | |
} | |
}; | |
a.prototype._prepareResponse = function (a, b) { | |
return new m(a, h.OK, { | |
"Content-Type": "application/json" | |
}, b) | |
}; | |
a.prototype.resolve = function (b) { | |
b = b.getURI(); | |
var d = b.replace(a.TRACK_RESOLVER_URI, ""), | |
g = { | |
type: "list", | |
uri: d | |
}, h = this._createChannel(), | |
f = h.getSink(); | |
this._trackListResolver.resolveAll(g).then(function (a) { | |
return a.toArray() | |
}).then(this._prepareList.bind(this, d)).catchError(this._prepareList.bind(this, d, [])).then(this._prepareResponse.bind(this, b)).then(f.push.bind(f)); | |
return h.getSource() | |
} | |
}, | |
"node_modules/cosmos-router-js/src/services/messages.js": function (b, l, f, n, p, r) { | |
function a(b, d) { | |
if (!(this instanceof a)) return new a(b, d); | |
if (!b || !d) throw new TypeError("Missing arguments for MessageResolver"); | |
this._sender = b; | |
this._messageRouter = | |
d; | |
q.call(this, new g({ | |
uri: c + "**" | |
})) | |
} | |
n = b("node_modules/cosmos-router-js/node_modules/js-common/index.js"); | |
l = b("node_modules/cosmos-router-js/node_modules/cosmos-common-js/index.js"); | |
n = n.helpers; | |
var q = b("node_modules/cosmos-router-js/src/resolver.js").Resolver; | |
p = l.response; | |
var m = p.Response, | |
h = p.StatusCode, | |
g = b("node_modules/cosmos-router-js/src/requestfilter.js").RequestFilter, | |
d = l.request.Action, | |
c = "sp://messages/v1/"; | |
n.inherit(a, q); | |
f.MessageResolver = a; | |
a.prototype.resolve = function (a) { | |
var b = this._createChannel(), | |
c = b.getSink(), | |
g = a.getAction(), | |
f = a.getURI(); | |
switch (g) { | |
case d.POST: | |
this._postRequestHandler(a, c); | |
break; | |
case d.SUB: | |
this._subRequestHandler(a, c); | |
break; | |
default: | |
c.push(new m(f, h.METHOD_NOT_ALLOWED, { | |
allow: d.POST + ", " + d.SUB | |
})) | |
} | |
return b.getSource() | |
}; | |
a.prototype._subRequestHandler = function (a, b) { | |
var c = a.getURI(), | |
d = this._extractTopic(c), | |
g = a.getHeaders() || {}, f = this._parseRealmsField(g.realms), | |
l = this._messageRouter.subscribe(d, f, function (a) { | |
var k = { | |
sender: this._sender, | |
realms: f.join(","), | |
topic: d | |
}; | |
b.push(new m(c, | |
h.OK, k, a)) | |
}.bind(this)); | |
b.addCloseCallback(function () { | |
this._messageRouter.unsubscribe(l) | |
}.bind(this)) | |
}; | |
a.prototype._postRequestHandler = function (a, b) { | |
var c = a.getURI(), | |
d = this._extractTopic(c), | |
g = this._parseRealmsField(a.getHeaders().realms), | |
f = a.getBody(); | |
d ? (this._messageRouter.sendMessage(d, g, f), b.push(new m(c, h.ACCEPTED, a.getHeaders()))) : b.push(new m(c, h.BAD_REQUEST)) | |
}; | |
a.prototype._extractTopic = function (a) { | |
return a.replace(c, "") | |
}; | |
a.prototype._parseRealmsField = function (a) { | |
if ("string" !== typeof a) return []; | |
a = a.replace(/\s+/g, ""); | |
return a.split(",").filter(function (a, b, c) { | |
return !!a && c.indexOf(a) === b | |
}) | |
} | |
}, | |
"node_modules/cosmos-router-js/src/cosmos.js": function (b, l, f, n, p, r) { | |
var a = b("node_modules/cosmos-router-js/node_modules/js-common/index.js"), | |
q = b("node_modules/cosmos-router-js/node_modules/cosmos-common-js/index.js"); | |
l = b("node_modules/cosmos-router-js/src/bridge.js"); | |
n = q.message; | |
p = b("node_modules/cosmos-router-js/src/pattern.js"); | |
r = q.request; | |
var m = b("node_modules/cosmos-router-js/src/requestfilter.js"), | |
q = q.response, | |
h = b("node_modules/cosmos-router-js/src/resolver.js"), | |
g = b("node_modules/cosmos-router-js/src/router.js"), | |
a = a.helpers, | |
d = b("node_modules/cosmos-router-js/src/channel.js"), | |
c = b("node_modules/cosmos-router-js/src/requesthandler.js"), | |
k = b("node_modules/cosmos-router-js/src/messagerouter.js"), | |
s = b("node_modules/cosmos-router-js/src/services/echo.js"), | |
x = b("node_modules/cosmos-router-js/src/services/hermes.js"), | |
z = b("node_modules/cosmos-router-js/src/services/http.js"), | |
t = b("node_modules/cosmos-router-js/src/services/protobuf.js"), | |
v = b("node_modules/cosmos-router-js/src/services/player.js"), | |
w = b("node_modules/cosmos-router-js/src/services/trackresolver.js"); | |
b = b("node_modules/cosmos-router-js/src/services/messages.js"); | |
f.Bridge = l.Bridge; | |
f.Message = n.Message; | |
f.Action = r.Action; | |
f.Pattern = p.Pattern; | |
f.Response = q.Response; | |
f.Request = r.Request; | |
f.RequestFilter = m.RequestFilter; | |
f.RequestFilterPriority = m.RequestFilterPriority; | |
f.Router = g.Router; | |
f.Resolver = h.Resolver; | |
f.StatusCode = q.StatusCode; | |
f.Helpers = a; | |
f.Channel = d.Channel; | |
f.RequestHandler = | |
c.RequestHandler; | |
f.MessageRouter = k.MessageRouter; | |
f.EchoService = s.EchoService; | |
f.HermesService = x.HermesService; | |
f.HTTPService = z.HTTPService; | |
f.ProtobufResolver = t.ProtobufResolver; | |
f.PlayerService = v.PlayerService; | |
f.TrackResolverService = w.TrackResolverService; | |
f.MessageResolver = b.MessageResolver | |
}, | |
"node_modules/cosmos-router-js/src/adapters/shell_player.js": function (b, l, f, n, p, r) { | |
function a(a, b, d, c) { | |
if (!(a && b && d && c)) throw new TypeError("Missing arguments for PlayerAdapter"); | |
this._player = a; | |
this._dispatcher = | |
b; | |
this._trackListResolver = d; | |
this._ItemList = c; | |
this._currentState = null; | |
this._requestSender = this._requestSenderWrapper(this._dispatcher.createRequestSender("GET", "/tracks")); | |
this._parseState = this._parseState.bind(this); | |
this._onStateChange = this._onStateChange.bind(this); | |
this._playerEvents = { | |
beforePlay: this._onStateChange, | |
play: this._onStateChange, | |
pause: this._onStateChange, | |
stop: this._onStateChange, | |
clear: this._onStateChange, | |
shuffleChanged: this._onStateChange, | |
repeatedChange: this._onStateChange, | |
positionChanged: this._onStateChange, | |
volumeChange: this._onStateChange | |
}; | |
this._token = 0; | |
this._subCallbacks = {}; | |
this._player.addEvents(this._playerEvents) | |
} | |
var q = b("node_modules/cosmos-router-js/node_modules/js-common/index.js").promise.Promise, | |
m = b("node_modules/cosmos-router-js/src/cosmos.js").Request; | |
a.prototype._requestSender = function () {}; | |
a.prototype._requestSenderWrapper = function (a) { | |
return function (b) { | |
return a({ | |
flush: !0 | |
}, { | |
uris: b | |
}).then(function (a) { | |
return a.body.result | |
}) | |
} | |
}; | |
a.prototype.getState = function (a) { | |
this._promiseToCallback(this._player.getState().then(this._parseState), | |
a) | |
}; | |
a.prototype._parseState = function (a) { | |
var b = this._currentState && this._currentState.play_origin || {}, d = {}, c = {}, k = {}; | |
c.source = b.source; | |
c.reason = b.reason; | |
c.referrer = b.referrer; | |
c.referrer_version = b.referrer_version; | |
c.referrer_vendor = b.referrer_vendor; | |
k.repeat = a.repeat; | |
k.shuffle = a.shuffle; | |
k.can_repeat = a.__rules.repeat; | |
k.can_shuffle = a.__rules.shuffle; | |
k.can_skip_prev = a.__rules.previous; | |
k.can_skip_next = a.__rules.next; | |
k.can_seek = a.__rules.seek; | |
a.context && (d.context = a.context.uri, d.index = a.index); | |
a.track && | |
(d.track = a.track.uri, d.duration = a.duration, d.position = a.position); | |
d.playing = a.playing; | |
d.loading = a.loading; | |
d.volume = a.volume; | |
Object.keys(k).length && (d.options = k); | |
Object.keys(c).length && (d.play_origin = c); | |
return d | |
}; | |
a.prototype._createTrackList = function (a, b) { | |
var d = new q, | |
c = a.tracks.slice(0), | |
k = a.next_page_url; | |
if (k) { | |
if (/spotify:user:[^:]+:(starred|(playlist:[^:]+))$/.test(k)) return this._trackListResolver.resolve({ | |
type: "list", | |
uri: k | |
}); | |
b.resolve(new m("GET", k)).consume(function (a) { | |
(a = a.getJSONBody()) && a.tracks && | |
c.push.apply(c, a.tracks.map(function (a) { | |
return a.track | |
})); | |
d.fulfill(c) | |
}) | |
} else d.fulfill(c); | |
return d.then(function (b) { | |
b = new this._ItemList.Array(b); | |
b = new this._ItemList.MetadataDecorator(b, this._requestSender); | |
b.setDescriptor(new this._ItemList.Descriptor.List(a.context)); | |
return b | |
}.bind(this)) | |
}; | |
a.prototype._preparePlayerOptions = function (a) { | |
var b = a.options, | |
d = a.play_origin; | |
this._currentState = a; | |
return { | |
index: a.index, | |
initialOffset: a.position, | |
owner: d.referrer, | |
reason: d.reason, | |
rules: { | |
skipCount: -1, | |
volume: !0, | |
seek: b.can_seek, | |
indexing: !0, | |
previous: b.can_skip_prev, | |
next: b.can_skip_next, | |
shuffle: b.can_shuffle, | |
repeat: b.can_repeat | |
} | |
} | |
}; | |
a.prototype.play = function (a, b, d) { | |
b = this._createTrackList(a, b).then(function (b) { | |
var d = this._preparePlayerOptions(a); | |
b = new this._ItemList.Context(b, d.owner); | |
return this._player.play(b, d) | |
}.bind(this)); | |
this._promiseToCallback(b, d) | |
}; | |
a.prototype.update = function (a, b, d) { | |
b = this._createTrackList(a, b).then(function (b) { | |
var d = this._preparePlayerOptions(a); | |
b = new this._ItemList.Context(b, d.owner); | |
return this._player.setContextList(b, d) | |
}.bind(this)); | |
this._promiseToCallback(b, d) | |
}; | |
a.prototype.stop = function (a, b) { | |
this._player.stop(); | |
b(null, {}) | |
}; | |
a.prototype.resume = function (a, b) { | |
this._promiseToCallback(this._player.resume(), b) | |
}; | |
a.prototype.pause = function (a, b) { | |
this._promiseToCallback(this._player.pause(), b) | |
}; | |
a.prototype.next = function (a, b) { | |
this._promiseToCallback(this._player.next(a.play_origin.reason), b) | |
}; | |
a.prototype.previous = function (a, b) { | |
this._promiseToCallback(this._player.previous(a.play_origin.reason), | |
b) | |
}; | |
a.prototype.subscribe = function (a) { | |
var b = this._token++; | |
this._subCallbacks[b] = a; | |
return b | |
}; | |
a.prototype.unsubscribe = function (a) { | |
this._subCallbacks[a] && (this._subCallbacks[a] = null, delete this._subCallbacks[a]) | |
}; | |
a.prototype._onStateChange = function (a) { | |
var b = Object.keys(this._subCallbacks); | |
b.length && this.getState(function (a, c) { | |
for (var k = 0, h = b.length; k < h; k++) this._subCallbacks[b[k]](a, c) | |
}.bind(this)) | |
}; | |
a.prototype._promiseToCallback = function (a, b) { | |
a.then(function (a) { | |
b(null, a) | |
}, b) | |
}; | |
f.PlayerAdapter = a | |
}, | |
"node_modules/cosmos-router-js/src/builder.js": function (b, | |
l, f, n, p, r) { | |
(function (a) { | |
function l(a, b) { | |
var k = new m.Router; | |
k.registerResolver(new m.ProtobufResolver); | |
k.registerResolver(new m.EchoService); | |
k.registerResolver(new m.HTTPService(a.XMLHttpRequest)); | |
k.registerResolver(new m.HermesService(a.hermes)); | |
k.registerResolver(new m.PlayerService(a.player)); | |
k.registerResolver(new m.TrackResolverService(a.trackListResolver)); | |
k.registerResolver(new m.MessageResolver(b.getId(), a.messageRouter)); | |
return k | |
} | |
a.Spotify = a.Spotify || {}; | |
var m = b("node_modules/cosmos-router-js/src/cosmos.js"), | |
h = b("node_modules/cosmos-router-js/src/adapters/shell_player.js").PlayerAdapter, | |
g = b("node_modules/cosmos-router-js/src/messagerouter.js").MessageRouter; | |
m.init = function (b, c) { | |
if (!(b && c.applicationManager && c.contextPlayer && c.dispatcher && c.ItemList)) throw new TypeError("Invalid arguments for Cosmos"); | |
if (!a.__noCosmosBridge) { | |
var k = new h(c.contextPlayer, c.dispatcher, c.trackListResolver, c.ItemList), | |
k = { | |
hermes: b.hermes, | |
player: k, | |
trackListResolver: c.trackListResolver, | |
XMLHttpRequest: XMLHttpRequest, | |
messageRouter: new g | |
}, | |
k = l.bind(this, k); | |
new m.Bridge(c.applicationManager, k) | |
} | |
}; | |
Spotify.Cosmos = m; | |
f.Cosmos = m | |
})(window) | |
}, | |
"node_modules/spotify-bridge/node_modules/spotify-deferred/node_modules/spotify-postrouter/src/postrouter.js": function (b, l, f, n, p, r) { | |
function a(a) { | |
var b = g[a.type]; | |
b && b.fn.call(this, a) | |
} | |
function q(a) { | |
var b = a.data; | |
if ("string" == typeof b) try { | |
b = JSON.parse(b) | |
} catch (d) { | |
return | |
} | |
var h = g[b.type]; | |
!h || "*" != h.origin && a.origin !== h.origin || h.fn.call(this, b, a) | |
} | |
var m = m ? m : setTimeout, | |
h = void 0; | |
"undefined" !== typeof window && (h = | |
window.location.origin || window.location.protocol + "//" + window.location.hostname); | |
var g = {}, d = !1; | |
l.exports = { | |
addMessageHandler: function (a, b, f) { | |
"undefined" === typeof window || d || (window.attachEvent && !window.addEventListener ? window.attachEvent("onmessage", q) : window.addEventListener("message", q, !1), d = !0); | |
f || (f = h); | |
if (g[a]) throw Error('Rehandling of message "' + a + '" not allowed.'); | |
g[a] = { | |
fn: b, | |
origin: f | |
} | |
}, | |
removeMessageHandler: function (a, b) { | |
return !g[a] || b && g[a].fn !== b ? !1 : (g[a] = null, !0) | |
}, | |
sendMessage: function (b, d, | |
g, f) { | |
d = d || {}; | |
d.type = b; | |
if ("undefined" === typeof window) return m(a.bind(null, d)); | |
g = g || window; | |
f || (f = h); | |
g.postMessage(JSON.stringify(d), f) | |
}, | |
WINDOW_ORIGIN: h | |
} | |
}, | |
"node_modules/spotify-bridge/node_modules/spotify-deferred/src/deferred.js": function (b, l, f, n, p, r) { | |
var a = b("node_modules/spotify-bridge/node_modules/spotify-deferred/node_modules/spotify-postrouter/src/postrouter.js"), | |
q = []; | |
a.addMessageHandler("execute_deferreds", function () { | |
var a = q.splice(0); | |
if (a.length) | |
for (var b = 0, g = a.length; b < g; b++) try { | |
a[b]() | |
} finally { | |
null | |
} | |
}); | |
l.exports = function (b) { | |
var h = !q.length; | |
q.push(b); | |
h && a.sendMessage("execute_deferreds") | |
} | |
}, | |
"node_modules/spotify-bridge/src/bridge/contextplayer.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(a, b, k, g) { | |
h.call(this); | |
this._available = this._uid = 0; | |
this._previous = {}; | |
this._incoming = {}; | |
a = this.audioManager = a.audioManager; | |
this.player = b; | |
this.logging = a.getTrackerForPlayerWithId(b.id); | |
this.alternate = k; | |
this._fade = !! g; | |
this._intercept = !1; | |
this._interceptions = this._intercepted = null; | |
this._queue = []; | |
this._history = []; | |
this.setup() | |
} | |
var f = Spotify.Link, | |
m = b("node_modules/spotify-bridge/node_modules/spotify-deferred/src/deferred.js"), | |
h = b("node_modules/spotify-eventemitter/src/eventemitter.js"), | |
g = [].slice; | |
a.prototype = new h; | |
a.prototype.constructor = a; | |
a.prototype.setup = function () { | |
var a = this.player; | |
a.bind("BEFORE_END", this.onBeforeEnded, this); | |
a.onPlay = this.onPlay.bind(this); | |
a.onPause = this.onPause.bind(this); | |
a.onTrackEnded = this.onEnded.bind(this); | |
a.onInvalidTrackUri = a.onPlaybackFailed = this.onInvalid.bind(this) | |
}; | |
a.prototype.onPlay = function () { | |
if (!this._hardStopped) { | |
this._available++; | |
this._keepPlay && this.player.resume(); | |
delete this._keepPlay; | |
this.fireEvent("play"); | |
var a = this.player.trackUri, | |
b = this._incoming[a]; | |
delete this._incoming[a]; | |
b && m(b.bind(this)) | |
} | |
}; | |
a.prototype.onPause = function () { | |
this.fireEvent("pause") | |
}; | |
a.prototype.onBeforeEnded = function () { | |
var a = this; | |
this._fade && !this._currentContext.hasNext() && (a._crossfading = !0, null != this._fadeback && this._fadeback && a.alternate.resume(), this.audioManager.crossfade(this.player.id, this.alternate.id, 800, function () { | |
a.player.pause(); | |
a._fadeback = | |
null; | |
a._crossfading = !1 | |
})) | |
}; | |
a.prototype.onEnded = function () { | |
delete this._keepPlay; | |
this.fireEvent("ended"); | |
this._playIntercepted() || this.next(!0) | |
}; | |
a.prototype.onInvalid = function (a) { | |
delete this._keepPlay; | |
var b = a.params.data, | |
k = this._incoming[b]; | |
delete this._incoming[b]; | |
k && m(k.bind(this, "unplayable")); | |
b = this.next.bind(this, !0, function (a) { | |
"no-context" === a && "forbidden" === a && "no-tracks" === a && (a = this._previous, this._currentContext = a.context, this._currentTrack = a.track, this._currentGroup = a.group) | |
}.bind(this)); | |
(12 != a.params.domain || 8 != a.params.code && 12 != a.params.code) && b() | |
}; | |
a.prototype._shuffled = !1; | |
a.prototype.setShuffle = function (a) { | |
this._shuffled = a = !! a; | |
var b = this._currentContext; | |
b && b.setShuffle(a); | |
return !0 | |
}; | |
a.prototype._repeated = !1; | |
a.prototype.setRepeat = function (a) { | |
this._repeated = a = !! a; | |
var b = this._currentContext; | |
b && b.setRepeat(a); | |
return !0 | |
}; | |
a.prototype.setVolume = function (a) { | |
if ("number" != typeof a) return !1; | |
this.audioManager.setMasterVolume(a); | |
return !0 | |
}; | |
a.prototype.getState = function (a) { | |
var b = this.player.getPlayerState(), | |
k = this._currentContext, | |
b = { | |
__uid: this._uid, | |
__index: k ? k.getIndex(!0) : null, | |
__length: k ? k.getLength(!0) : null, | |
__rules: k ? k.getRule() : {}, | |
__owner: k ? k.getOwner() : null, | |
playing: this._keepPlay ? !0 : !b.isPaused && !b.isStopped, | |
context: k ? { | |
uri: k.getId() | |
} : null, | |
index: k ? k.getPlayingIndex() : null, | |
track: this._currentTrack || { | |
uri: null | |
}, | |
position: b.position, | |
duration: b.duration || 0, | |
volume: this.audioManager.getMasterVolume(), | |
repeat: k ? k.isRepeated() : this._repeated, | |
shuffle: k ? k.isShuffled() : this._shuffled | |
}; | |
a && (b.__group = null, k && k.isContextGroup() && | |
(a = k._context, b.__group = { | |
id: a._id, | |
index: a.getContextIndex(), | |
array: a.getContextIds() | |
})); | |
return b | |
}; | |
a.prototype._currentGroup = null; | |
a.prototype._currentContext = null; | |
a.prototype._currentTrack = !1; | |
a.prototype.togglePlay = function () { | |
this.player.playpause(); | |
return !0 | |
}; | |
a.prototype.resume = function () { | |
var a = this.alternate.getPlayerState(); | |
a.isPaused || a.isStopped || (this.alternate.pause(), this.player.setVolume(this.audioManager.getMasterVolume())); | |
this.player.resume(); | |
return !0 | |
}; | |
a.prototype.pause = function () { | |
this.player.pause(); | |
return !0 | |
}; | |
a.prototype.stop = function () { | |
var a = this, | |
b = this.player; | |
this._hardStopped = !0; | |
this._firstPlay = !1; | |
!this._fade || (b.isStopped || b.isPaused) && null == this._keepPlay ? (this._crossfading = !1, this._fadeback = null, this.player.pause(), this.reset()) : (a._crossfading = !0, null != this._fadeback && this._fadeback && a.alternate.resume(), this.audioManager.crossfade(this.player.id, this.alternate.id, 800, function () { | |
a.player.pause(); | |
a.reset(); | |
a._fadeback = null; | |
a._crossfading = !1 | |
})) | |
}; | |
a.prototype.seek = function (a) { | |
if ("number" != | |
typeof a || !this._currentContext || !this._currentContext.getRule().seek) return !1; | |
this.player.seek(a); | |
return !0 | |
}; | |
a.prototype.queue = function (a) { | |
if (!a) return !1; | |
head ? this._queue.unshift(queue) : this._queue.push(queue); | |
a.resolve({ | |
track: 0, | |
context: 0 | |
}); | |
return !0 | |
}; | |
a.prototype.intercept = function () { | |
this._intercept = !0; | |
return this | |
}; | |
a.prototype.setIntercept = function (a) { | |
if (!a) return !1; | |
this._interceptions = a; | |
return !0 | |
}; | |
a.prototype._getIntercept = function () { | |
if (!this._intercept || !this._interceptions) return null; | |
this._intercept = !1; | |
var a = this._interceptions.shift(); | |
if (!a) return null; | |
var b = f.fromString(a.item), | |
a = a.metadata; | |
if (!a || !a.playable && !a.__pid) return null; | |
a.uri = b.toURI(); | |
return { | |
item: ("ad" == b.type ? f.adLink(a.__pid) : f.trackLink(a.__pid)).toURI(), | |
metadata: a, | |
context: this._interceptions | |
} | |
}; | |
a.prototype._playIntercepted = function () { | |
if (!this._intercepted) return !1; | |
var a = this._intercepted; | |
delete this._intercepted; | |
this._attemptPlay.apply(this, a); | |
return !0 | |
}; | |
a.prototype.next = function (a, b) { | |
var k = this._currentContext; | |
if (!this._available && | |
this._repeated) return this.createEndLog("endplay", k), this; | |
if (!k) return b && b.call(this, "no-context"), this; | |
var g = k.next(); | |
do | |
if (g) { | |
var h = g.item, | |
m = g.metadata; | |
if (m && (m.playable || m.__pid)) break | |
} while (g = k.next()); | |
if (!g) { | |
if (!1 === g) return b && b.call(this, "forbidden"), this; | |
this.createEndLog("endplay", k); | |
b && b.call(this, "no-tracks"); | |
return this.stop() | |
} | |
m.uri = h; | |
h = m.advertisement ? f.adLink(m.__pid).toURI() : f.trackLink(m.__pid).toURI(); | |
g = a ? "trackdone" : "nextbtn"; | |
this.fireEvent("beforeNext", [h, m, k], !0); | |
this.createEndLog(g, | |
k); | |
this.fireEvent("next", [h, m, k]); | |
this._attemptPlay(g, h, m, k); | |
b && b.call(this) | |
}; | |
a.prototype.previous = function (a, b) { | |
var k = this._currentContext; | |
if (!k) return b && b.call(this, "no-context"), this; | |
var g = k.previous(); | |
do | |
if (g) { | |
var h = g.item, | |
m = g.metadata; | |
if (m && (m.playable || m.__pid)) break | |
} while (g = k.previous()); | |
if (!g) { | |
if (!1 === g) { | |
b && b.call(this, "forbidden"); | |
return | |
} | |
this.createEndLog("endplay", k); | |
b && b.call(this, "no-tracks"); | |
return this.stop() | |
} | |
m.uri = h; | |
h = m.advertisement ? f.adLink(m.__pid).toURI() : f.trackLink(m.__pid).toURI(); | |
g = a ? "trackdone" : "backbtn"; | |
this.fireEvent("beforePrevious", [h, m, k], !0); | |
this.createEndLog(g, k); | |
this.fireEvent("previous", [h, m, k]); | |
this._attemptPlay(g, h, m, k); | |
b && b.call(this) | |
}; | |
a.prototype.play = function (a, b, k) { | |
this._hardStopped = !1; | |
this._firstPlay = !0; | |
a.setRepeat(this._repeated); | |
a.setShuffle(this._shuffled); | |
a.startFrom(b); | |
this._useDuration = b.duration; | |
a.resolve(b, this._parseContext.bind(this, a, b, k), (k || function () {}).bind(null, "metadata-error")) | |
}; | |
a.prototype._locatePlayable = function (a) { | |
for (var b = 0, k = a.getLength(!0); b < | |
k; b++) { | |
var g = a.get(b); | |
if (g && (track = g.item, metadata = g.metadata, metadata.playable || metadata.__pid)) return a._context._currentIndex = b, g | |
} | |
return null | |
}; | |
a.prototype._parseContext = function (a, b, k) { | |
var g = !1; - 1 == b.track && (g = !0); | |
var h, m = g ? this._locatePlayable(a) : a.current(); | |
if (!m) return k("no-playables"); | |
var l = function (g, h) { | |
h.uri = g; | |
var m = h.advertisement ? f.adLink(h.__pid) : f.trackLink(h.__pid); | |
this._available = a.getLength(!0); | |
this.fireEvent("beforeContextChange", [m, h, a], !0); | |
this.createEndLog(b.reason || "clickrow", | |
a); | |
this._attemptPlay(b.reason || "clickrow", m, h, a, k, b.ms, b.duration, b.pause); | |
this.fireEvent("contextChange", [m, h, a]) | |
}.bind(this), | |
g = m.item; | |
h = m.metadata; | |
if (!h || !h.playable && !h.__pid) return k("unplayable", m.item); | |
l(g, h) | |
}; | |
a.prototype._playTrigger = null; | |
a.prototype._attemptPlay = function (a, b, k, h, m, l, n, p) { | |
var w = this; | |
b instanceof f && (b = b.toURI()); | |
this.fireEvent("beforePlay", [b, k, h]); | |
if (this._intercepted) return this._intercepted = g.call(arguments), this.fireEvent("intercepted", [b, k, h]), this; | |
var u = this._getIntercept(); | |
u ? (this._intercepted = g.call(arguments), b = u.item, k = u.metadata, h = u.context) : this._incoming[b] = m; | |
this._previous = { | |
context: this._currentContext, | |
track: this._currentTrack, | |
group: this._currentGroup | |
}; | |
this._currentContext = h; | |
this._currentTrack = k; | |
this.player.pause(); | |
this._keepPlay = !p; | |
l = isNaN(l) || 0 > l ? 0 : l; | |
n = this._useDuration; | |
n = isNaN(n) || 0 >= n ? -1 : n; | |
this._available--; | |
this.player.onLoad = function () { | |
var a = this.alternate, | |
b = a.getPlayerState(); | |
this._hardStopped ? null != this._fadeback && this._fadeback && a.resume() : this._fade ? | |
(this._fadeback = null != this._fadeback ? this._fadeback : !a.isPaused && !a.isStopped, this._firstPlay ? (this._firstPlay = !1, w._crossfading = !0, this.audioManager.crossfade(this.alternate.id, this.player.id, 800, function () { | |
w._hardStopped ? a.setVolume(1) : (a.pause(), a.seek(Math.max(0, Math.floor(b.position - 2E3))), w._crossfading = !1) | |
})) : w._hardStopped ? a.setVolume(1) : (a.pause(), a.seek(Math.max(0, Math.floor(b.position - 2E3))))) : a.pause() | |
}.bind(this); | |
b = h.mapToId(k.uri, b); | |
this._playTrigger ? (clearTimeout(this._playTrigger), | |
this._playTrigger = setTimeout(function () { | |
this._uid++; | |
this.player.load(b, l, !p, -1 != n && -1 != l ? l + n : n, 1E3); | |
this.createLog(a, k.uri, h); | |
delete this._playTrigger | |
}.bind(this), 1E3)) : (this._playTrigger = 1, this._uid++, this.player.load(b, l, !p, -1 != n && -1 != l ? l + n : n, 1E3), this.createLog(a, k.uri, h)) | |
}; | |
a.prototype.createLog = function (a, b, k) { | |
var g = "", | |
h = "unknown", | |
m = k.getOwner(), | |
l = f.fromString(m); | |
if (k && "search" != l.id && "radio" != l.id) { | |
if (k = k.getId()) k = f.fromString(k), g = k.toURI(), h = k.type | |
} else if ("search" == l.id || "radio" == l.id) g = | |
m, source_end = h = l.id; | |
a = { | |
display_track: b, | |
play_context: g, | |
source_start: h, | |
reason_start: a, | |
referrer: m, | |
referrer_version: "0.1.0", | |
referrer_vendor: "com.spotify" | |
}; | |
this._started = !0; | |
this.logging = this.audioManager.getTrackerForPlayerWithId(this.player.id); | |
this.logging.setEndSongStartLog(a); | |
return a | |
}; | |
a.prototype.createEndLog = function (a, b) { | |
if (!this._started) return this; | |
var k = "unknown", | |
g = b.getOwner(), | |
g = f.fromString(g); | |
if (b && "search" != g.id && "radio" != g.id) { | |
if (g = b.getId()) f.fromString(g).toURI(), k = f.fromString(g).type | |
} else if ("search" == | |
g.id || "radio" == g.id) k = g.id; | |
k = { | |
source_end: k, | |
reason_end: a | |
}; | |
this.logging = this.audioManager.getTrackerForPlayerWithId(this.player.id); | |
this.logging.setEndSongStopLog(k); | |
return k | |
}; | |
a.prototype.reset = function () { | |
this._currentGroup = this._currentContext = this._currentTrack = this._keepPlay = null; | |
this._playTrigger && clearTimeout(this._playTrigger); | |
delete this._playTrigger; | |
this.player.stop(); | |
this.fireEvent("reset") | |
}; | |
l.exports = a | |
})() | |
}, | |
"node_modules/spotify-bridge/src/bridge/reply.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(a, | |
b) { | |
for (var d in b) b.hasOwnProperty(d) && (a[d] = b[d]); | |
return a | |
} | |
function f(a, b, d) { | |
if (!(this instanceof f)) return new f(a, b, d); | |
this.timestamp = (new Date).getTime(); | |
this.internal = !1; | |
this._id = a; | |
this._origin = b; | |
this._source = d; | |
this._payload = null; | |
this._success = !0; | |
this._sent = this._persisted = this._hasPartial = !1 | |
} | |
function m(a, b) { | |
if (!(this instanceof m)) return new m(a, b); | |
this.internal = !0; | |
this._done = a; | |
this._error = b; | |
this._payload = null; | |
this._success = !0; | |
this._sent = this._persisted = this._hasPartial = !1 | |
} | |
var h = b("node_modules/spotify-bridge/src/bridge/errors.js"), | |
g = b("node_modules/spotify-bridge/node_modules/spotify-deferred/src/deferred.js"), | |
d = b("node_modules/spotify-inheritance/inherit.js"); | |
f.prototype.persist = function () { | |
this._persisted = !0; | |
return this | |
}; | |
f.prototype.addPartial = function (b) { | |
this._sent || "object" != typeof b || (this._hasPartial ? this._payload = a(this._payload, b) : (this._payload = a({}, b), this._hasPartial = !0)) | |
}; | |
f.prototype.send = function (b) { | |
if (this._sent) return null; | |
this._sent = !0; | |
this._hasPartial && (b = a(this._payload, b)); | |
if (this._source) { | |
var d = { | |
id: this._id, | |
success: this._success, | |
payload: b | |
}; | |
b.type && (b.data && (b.event = b.type), b.receiver && (b.target = b.receiver)); | |
this._source !== window && this._source.postMessage(JSON.stringify(d), this._origin); | |
this._payload = this._source = this._origin = null | |
} | |
}; | |
f.prototype.fail = function (a, b, d) { | |
if (this._sent) return null; | |
a instanceof h && (d = a.code, b = a.message, a = a.type); | |
a = "string" == typeof a ? { | |
error: a, | |
message: b, | |
code: d | |
} : a; | |
this._success = !1; | |
return this.send(a) | |
}; | |
f.prototype.timeout = function () { | |
return this._sent || this._persisted ? !1 : this.fail(new h.Timeout("Request timed-out.")) | |
}; | |
d(m, f); | |
f.Internal = m; | |
m.prototype.send = function (b) { | |
if (this._sent) return null; | |
this._sent = !0; | |
this._hasPartial && (b = a(this._payload, b)); | |
this._success && this._done ? g(this._done.bind(this, b)) : !this._success && this._error && g(this._error.bind(this, b)) | |
}; | |
l.exports = f | |
})() | |
}, | |
"node_modules/spotify-bridge/src/bridge/responder.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(a) { | |
d.call(this); | |
for (var b in a) | |
if (a.hasOwnProperty(b)) a: { | |
var c = b, | |
g = a[b], | |
k = void 0; | |
switch (!0) { | |
case "_ready" == c: | |
!0 === g && this._setReady(); | |
break; | |
case "flushRequests" == | |
c: | |
w.push(g.bind(this)); | |
break; | |
case !!(k = c.match(/^(\*|@)(\1)?([^*@]+)$/)): | |
var h = "*" == k[1], | |
f = k[2] ? v : t, | |
c = k[3]; | |
if (c in f) throw Error('Redefinition of message handler "' + c + '".'); | |
if ("string" == typeof g) { | |
if (g = f[g]) f[c] = g; | |
else throw Error('Aliasing of undefined message handler "' + c + '".'); | |
break a | |
} | |
f[c] = { | |
bound: this, | |
fn: this._makeQueueable(g), | |
passApp: h | |
}; | |
break; | |
default: | |
this[c] = g | |
} | |
} | |
this.create && this.create(); | |
return this | |
} | |
var f = Spotify.Link, | |
m = b("node_modules/spotify-inheritance/inherit.js"), | |
h = Spotify.SimpleCache, | |
g = b("node_modules/spotify-promise/src/promise.js"), | |
d = b("node_modules/spotify-bridge/node_modules/spotify-queueable/src/queueable.js"), | |
c = b("node_modules/spotify-bridge/node_modules/spotify-deferred/src/deferred.js"), | |
k = b("node_modules/spotify-bridge/src/bridge/errortranslator.js"), | |
s = b("node_modules/spotify-bridge/src/bridge/errors.js"), | |
n = b("node_modules/spotify-bridge/src/bridge/reply.js"), | |
p = b("node_modules/spotify-bridge/src/bridge/sourceurls.js"), | |
t = {}, v = {}, w = [], | |
u = {}, A = {}, y = null; | |
m(a, d); | |
a.build = function (b) { | |
var c = null; | |
return { | |
getInstance: function () { | |
return c || | |
(c = new a(b)) | |
} | |
} | |
}; | |
a.getHandler = function (a) { | |
return t[a] || v[a] | |
}; | |
a.respondsTo = function (a) { | |
return a in t | |
}; | |
a.setPublisher = function (a) { | |
y = a; | |
return this | |
}; | |
a.block = function (a) { | |
A[a] = !0; | |
return this | |
}; | |
a.blockAll = function (a) { | |
for (var b = a.length; b--;) A[a[b]] = !0; | |
return this | |
}; | |
a.unblock = function (a) { | |
A[a] = null; | |
return this | |
}; | |
a.unblockAll = function () { | |
A = {}; | |
return this | |
}; | |
a.hasBlocked = function (a) { | |
return !!A[a] | |
}; | |
a.handleBlocked = function (a, b, c) { | |
y && y.notify("LIMITED_FEATURE_CALL", { | |
origin: a.source, | |
feature: c, | |
callback: function () {} | |
}); | |
return b.fail("restricted", | |
"Cannot perform action in this session.") | |
}; | |
a.prototype.traceOut = function (a) { | |
a = a || "Out: "; | |
return function () { | |
console.warn(a, arguments) | |
} | |
}; | |
a.prototype.traceError = function (a) { | |
a = a || "Err: "; | |
return function () { | |
console.error(a, arguments) | |
} | |
}; | |
a.flush = function () { | |
for (var a = w.length; a--;) w[a]() | |
}; | |
a.prototype._extractListURI = function (a) { | |
if ("string" == typeof a || a instanceof f) return a.toString(); | |
for (; a && "list" != a.type;) a = a.list; | |
return a && a.uri ? a.uri : null | |
}; | |
a.prototype.use = function (a) { | |
var b = 0, | |
c = [], | |
d; | |
for (d in a) this[d] = | |
a[d], c.push(a[d]), b++; | |
a = function () { | |
--b || this.start() | |
}.bind(this); | |
for (d = b; d--;) c[d].onReady(a, this); | |
return this | |
}; | |
a.prototype._createPromise = function () { | |
return new g | |
}; | |
a.prototype.store = function (a, b, c) { | |
(u[b] || (u[b] = new h(1E3))).put(a, c); | |
return this | |
}; | |
a.prototype.retrieve = function (a, b) { | |
return u[b] ? u[b].get(a) || null : null | |
}; | |
a.prototype.trigger = function (b, d, g, k) { | |
b = t[b] || v[b]; | |
if (!b) return "undefined" !== typeof k ? k({ | |
error: "not-implemented" | |
}) : null; | |
Array.isArray(d) && (d = { | |
args: d | |
}); | |
g = new n.Internal(g, k); | |
(d = b.fn.call(b.bound || {}, d, g)) && d.then && d.then(g.send.bind(g), g.fail.bind(g)); | |
c(function () { | |
a.flush() | |
}) | |
}; | |
a.prototype._request = function (a, b, c) { | |
var d = this._createPromise(); | |
a = t[a] || v[a]; | |
if (!a || !a.passApp) return d.fail(new s.NotImplemented("Message not implemented.")), d; | |
(b = a.fn.call(a.bound || {}, c, b)) && b.then ? b.catchError(k).pipe(d) : d.fulfill(b); | |
return d | |
}; | |
a.prototype.createImageSizes = function (a, b) { | |
var c = [ | |
[60, p.tiny + a], | |
[120, p.small + a], | |
[300, p.normal + a], | |
[640, p.large + a] | |
]; | |
b && (c.shift(), c.pop()); | |
return c | |
}; | |
a.prototype.createUserImageSizes = | |
function (a, b) { | |
var c = []; | |
a && c.push([50, a]); | |
b && c.push([180, b]); | |
for (var d = 0, g = c.length; d < g; d++) { | |
var k = c[d][1].match(/^spotify:image:(.+)/); | |
k && (c[d][1] = p.avatar + k[1]) | |
} | |
return c | |
}; | |
a.prototype.createSnapshot = function (a, b, c, d) { | |
var g = a[1] || 0; | |
a = a[2] || -1; | |
a = -1 == a ? b.length : a; | |
return { | |
range: { | |
offset: g, | |
length: a | |
}, | |
length: c || b.length, | |
array: b.slice(g, g + a), | |
metadata: (d || []).slice(g, g + a) | |
} | |
}; | |
a.prototype.createDimensions = function (a, b, c) { | |
a = a || 0; | |
c = c || 500; | |
b = -1 == b ? c : Math.min(b, c); | |
return { | |
start: a, | |
end: a + b - 1, | |
length: b | |
} | |
}; | |
l.exports = a | |
})() | |
}, | |
"node_modules/spotify-bridge/src/bridge/responders/activity.js": function (b, l, f, n, p, r) { | |
(function () { | |
var a = Spotify.Link, | |
f = b("node_modules/spotify-bridge/src/bridge/responder.js").build({ | |
_ready: !1, | |
_user: null, | |
init: function (a) { | |
var b = this.service = a.presence, | |
g = this; | |
a.user.getUserInfo(function (a) { | |
g._user = a.user; | |
b.onReady(g.start, g) | |
}) | |
}, | |
start: function () { | |
this._setReady() | |
}, | |
activityReply: function (b, h, g) { | |
for (var d = [], c = [], k = 0, f = g.length; k < f; k++) { | |
var l = g[k], | |
q = {}; | |
d.push(l.type); | |
q.activityType = l.type; | |
q.timestamp = 1E3 * | |
l.timestamp; | |
q.user = { | |
uri: a.profileLink(l.username).toString() | |
}; | |
q.item = { | |
uri: l.item_uri | |
}; | |
l.item_name && (q.item.name = l.item_name); | |
l.item_image && (q.item.image = l.item_image); | |
l.context_uri && (q.context = { | |
uri: l.context_uri | |
}); | |
l.message && (q.message = l.message); | |
l.referrer_uri && (q.referrer = { | |
uri: l.referrer_uri | |
}); | |
c.push(q) | |
} | |
h = this.createSnapshot(h, d, g.length, c); | |
b.send(h) | |
}, | |
handleError: function (a, b) { | |
var g, d; | |
switch (b.code) { | |
case 404: | |
g = "not-found"; | |
d = "No activity found."; | |
break; | |
default: | |
g = "transient", d = "Possible issues with the presence service." | |
} | |
return a.fail(g, | |
d) | |
}, | |
"@feed_activities_snapshot": function (b, h) { | |
var g = b.args, | |
d = this._extractListURI(g[0]), | |
d = d ? a.fromString(d).username : null; | |
"@" === d && (d = this._user); | |
this.service.getStatuses(d, this.activityReply.bind(this, h, g), this.handleError.bind(this, h)) | |
}, | |
"@feed_share_uri": function (a, b) { | |
this.service.broadcastUriShared(a.args[0], a.args[1], function () { | |
b.send({}) | |
}, this.handleError.bind(this, b)) | |
} | |
}); | |
l.exports = f | |
})() | |
}, | |
"node_modules/spotify-bridge/src/bridge/responders/ads.js": function (b, l, f, n, p, r) { | |
(function () { | |
var a = Spotify.Ads, | |
f = Spotify.Events, | |
m = b("node_modules/spotify-eventemitter/src/eventemitter.js"), | |
h = b("node_modules/spotify-bridge/src/bridge/errors.js"), | |
f = b("node_modules/spotify-bridge/src/bridge/responder.js").build({ | |
_ready: !1, | |
_events: new f, | |
_appEventTimeout: 1E4, | |
_listeners: null, | |
_isListening: null, | |
_appEventData: null, | |
_appEventCleanedAt: null, | |
init: function (a, b) { | |
this.publisher = b.publisher; | |
this.adsCore = a.adsCore; | |
this.logger = a.logging.logger; | |
this._isListening = !1; | |
this._appEventData = []; | |
this._setReady() | |
}, | |
getNumberOfApplications: function () { | |
return this._appEventData.length | |
}, | |
cleanEventData: function (a) { | |
this._lastCleanedAppEventData = 0; | |
this._cleanEventData(a) | |
}, | |
_dispatch: function (a, b) { | |
var c, k, h, f; | |
b = b || {}; | |
k = 0; | |
for (h = this._appEventData.length; k < h; k++) | |
if (c = this._appEventData[k], !b.appFrameId || c.app.isActive() && c.app.getFrame().id === b.appFrameId) f = { | |
type: a, | |
data: b | |
}, f.data.appFrameId && delete f.data.appFrameId, c.promise ? (c.promise.fulfill(f), c.promise = null, c.timestamp = Date.now()) : c.events.push(f); | |
this._cleanEventData() | |
}, | |
_adsCoreAddEventListeners: function (a) { | |
var b = this, | |
c; | |
for (c in a) a.hasOwnProperty(c) && | |
function () { | |
var k = c; | |
b.adsCore.addEventListener(a[k], function (a) { | |
b._dispatch(k, "object" === typeof a ? a.params : {}) | |
}) | |
}() | |
}, | |
_appListening: function (a) { | |
var b = this._getAppEventData(a); | |
!1 === b && (b = { | |
app: a, | |
events: [], | |
promise: null | |
}, this._appEventData.push(b)); | |
b.timestamp = Date.now(); | |
return b | |
}, | |
_cleanEventData: function (a) { | |
a = a || Date.now(); | |
if (!this._lastCleanedAppEventData || this._lastCleanedAppEventData < a - 18E4) { | |
this._lastCleanedAppEventData = a; | |
var b, c, k = []; | |
b = 0; | |
for (c = this._appEventData.length; b < c; b++) this._appEventData[b].timestamp > | |
a - 18E4 && k.push(this._appEventData[b]); | |
this._appEventData = k | |
} | |
}, | |
_getAppEventData: function (a) { | |
var b = !1, | |
c, k; | |
c = 0; | |
for (k = this._appEventData.length; c < k; c++) | |
if (this._appEventData[c].app === a) { | |
b = c; | |
break | |
} | |
return !1 === b ? !1 : this._appEventData[b] | |
}, | |
_adsCoreListen: function (a) { | |
this._isListening || (this._adsCoreAddEventListeners({ | |
ads_received: this._events.AD_RECEIVED, | |
ads_available: this._events.AD_AVAILABLE, | |
ads_not_available: this._events.AD_NOT_AVAILABLE, | |
ads_clear: this._events.AD_CLEAR, | |
ads_break_started: this._events.AD_BREAK_STARTED, | |
ads_break_ended: this._events.AD_BREAK_ENDED, | |
ads_debug: this._events.AD_DEBUG | |
}), this._isListening = !0); | |
this.adsCore.appListening(a.getFrame().id) | |
}, | |
_recordAdEvent: function (a, b, c) { | |
var k = c[1], | |
h = c[2]; | |
return this.adsCore.recordAdEvent(c[0], b, a.getFrame().id, k, h) | |
}, | |
"*ads_event_wait": function (a, b, c) { | |
b = this._createPromise(); | |
var k; | |
k = this._appListening(a); | |
k.events.length ? (c = k.events.shift(), b.fulfill(c)) : (c.persist(), k.promise = b); | |
this._adsCoreListen(a); | |
return b | |
}, | |
"*ads_register_inventory": function (b, d) { | |
var c = this._createPromise(), | |
k = d.args[0], | |
h = d.args[1], | |
f = d.args[2]; | |
if (!a.InventoryTypeById[h]) return c.fail("inventoryType not valid: " + h), c; | |
if (!b.isActive()) return c.fail("app is not active"), c; | |
for (var h = a.InventoryTypeById[h], l = new m, q = ["activate", "deactivate", "destroy"], n = function (a, b, c) { | |
b.addEvent(a, function (b) { | |
c.fireEvent(a, b) | |
}) | |
}, p = 0, u = q.length; p < u; p++) n(q[p], b, l); | |
l = { | |
bundleId: b.getAppLink().id, | |
frameId: b.getFrame().id, | |
publisher: l | |
}; | |
this.adsCore.registerInventory(k, h, l, f); | |
c.fulfill(!0); | |
return c | |
}, | |
"*ads_deregister_inventory": function (a, | |
b) { | |
var c = this._createPromise(), | |
k = b.args[0]; | |
this.adsCore.deregisterInventory(k, a.getFrame().id); | |
c.fail(new h.NotFound("The slotId was not found in registered inventory: " + k)); | |
return c | |
}, | |
"*ads_preview": function (a, b) { | |
var c = this._createPromise(); | |
this.adsCore.previewInventory(b.args[0], b.args[1], a.getFrame().id, function (a) { | |
c.fulfill(a) | |
}, function (a) { | |
c.fail(a) | |
}); | |
return c | |
}, | |
"*ads_break_in_progress": function (a, b) { | |
var c = this._createPromise(); | |
c.fulfill( !! this.adsCore.adBreakInProgress()); | |
return c | |
}, | |
"*ads_click": function (a, | |
b) { | |
var c = this._createPromise(); | |
c.fulfill(this._recordAdEvent(a, "click", b.args)); | |
return c | |
}, | |
"*ads_render": function (a, b) { | |
var c = this._createPromise(); | |
c.fulfill(this._recordAdEvent(a, "render", b.args)); | |
return c | |
}, | |
"*ads_error": function (a, b) { | |
var c = this._createPromise(); | |
c.fulfill(this._recordAdEvent(a, "error", b.args)); | |
return c | |
} | |
}); | |
l.exports = f | |
})() | |
}, | |
"node_modules/spotify-bridge/src/bridge/responders/application.js": function (b, l, f, n, p, r) { | |
(function () { | |
var a = Spotify.Link, | |
f = b("node_modules/spotify-bridge/src/bridge/errors.js"), | |
m = b("node_modules/spotify-bridge/src/bridge/responder.js").build({ | |
_ready: !1, | |
init: function (a, b) { | |
if (!b) return this; | |
this.publisher = b.publisher; | |
this._getAppUrl = b.getAppUrl; | |
this.clientLogger = a.logging.clientEvent; | |
this.logger = a.logging.logger; | |
this.setup() | |
}, | |
setup: function () { | |
this._setReady() | |
}, | |
"*application_open_uri": function (b, g) { | |
var d = this._createPromise(), | |
c; | |
try { | |
c = a.fromString(g.args[0]).toAppLink() | |
} catch (k) { | |
return d.fail(new f.InvalidURI("Not a valid application URI.")), d | |
} | |
var m = !! g.args[1]; | |
this.publisher.notify("APPLICATION_OPEN_URI", { | |
link: c, | |
origin: b.getFrame(), | |
replace: m | |
}); | |
d.fulfill(!0); | |
return d | |
}, | |
"*application_query": function (a, b) { | |
var d = this._createPromise(), | |
c = a.getId(), | |
c = { | |
uri: a.getURI(), | |
name: c, | |
identifier: c, | |
arguments: a.getArgsDecoded() | |
}; | |
d.fulfill(c); | |
return d | |
}, | |
"*application_event_wait": function (a, b) { | |
var d = this._createPromise(); | |
if (a.getData("hasEventWaitListeners")) { | |
var c = a.getData("eventWaitQueue").shift(); | |
c ? d.fulfill(c) : a.getData("eventWaitListeners").push(d) | |
} else a.setData("hasEventWaitListeners", !0), a.setData("eventWaitQueue", []), a.setData("eventWaitListeners", [d]), c = function (a, b) { | |
var c = { | |
type: a, | |
data: b | |
}, d = this.getData("eventWaitListeners").splice(0); | |
if (d.length) | |
for (var g = 0, h = d.length; g < h; g++) d[g].fulfill(c); | |
else this.getData("eventWaitQueue").push(c) | |
}, a.addEvent("argumentsChange", c.bind(a, "arguments")), a.addEvent("activate", c.bind(a, "activate")), a.addEvent("deactivate", c.bind(a, "deactivate")); | |
return d | |
}, | |
"*application_client_event": function (a, b) { | |
var d = this._createPromise(), | |
c = a.getURI(), | |
k = b.args; | |
try { | |
var m = { | |
source: c, | |
source_version: b.appVersion || | |
"0.0.0", | |
source_vendor: b.appVendor || "unknown", | |
context: (k[0] || "").toString(), | |
event: (k[1] || "").toString(), | |
event_version: (k[2] || "").toString(), | |
test_version: (k[3] || "").toString(), | |
data: JSON.stringify(k[4] || {}) | |
}; | |
this.clientLogger.log(m); | |
d.fulfill(!0) | |
} catch (l) { | |
d.fail(new f.InvalidRequest("Check your logging arguments.")) | |
} | |
return d | |
}, | |
"*application_banner_shown_event": function (a, b) { | |
var d = this._createPromise(); | |
this.logger.logBannerShown(b.args); | |
d.fulfill(!0); | |
return d | |
}, | |
"*application_set_preferred_size": function (a, | |
b) { | |
var d = this._createPromise(), | |
c = parseInt(b.args[0], 10), | |
k = parseInt(b.args[1], 10); | |
if (isNaN(c) || isNaN(k) || 0 >= c || 0 >= k) return d.fail(new f.InvalidRequest("Size arguments need to be positive integer values.")), d; | |
this.publisher.notify("APPLICATION_SET_PREFERRED_SIZE", { | |
origin: a.getFrame(), | |
width: c, | |
height: k, | |
callback: function (a, b) { | |
0 >= a || 0 >= b ? d.fail(new f.Forbidden("Cannot complete resizing request.")) : d.fulfill({ | |
width: a, | |
height: b | |
}) | |
} | |
}); | |
return d | |
}, | |
"*application_exit": function (a, b) { | |
var d = this._createPromise(), | |
c = | |
b.args[0]; | |
this.publisher.notify("APPLICATION_EXIT", { | |
origin: a.getFrame(), | |
status: c | |
}); | |
d.fulfill(!0); | |
return d | |
}, | |
"*application_set_title": function (a, b) { | |
var d = this._createPromise(), | |
c = b.args[0]; | |
c && c.replace(/^\s+|\s+$/g, "") ? document.title = c + " - Spotify" : document.title = "Spotify"; | |
d.fulfill(!0); | |
return d | |
}, | |
"*happ_metarequest": function (b, g) { | |
var d = this._createPromise(), | |
c; | |
try { | |
c = a.fromString(g.args[0]) | |
} catch (k) { | |
return d.fail(new f.InvalidRequest("The URI is not a valid Spotify URI.")), d | |
} | |
c = this._getAppUrl(c.id); | |
d.fulfill({ | |
url: c, | |
frame: c | |
}); | |
return d | |
}, | |
"*log_application_loaded": function (a, b) { | |
var d = this._createPromise(); | |
this.publisher.notify("APPLICATION_LOAD_TIME", { | |
uri: a.getURI(), | |
start: b.args[0] || "", | |
end: b.args[1] || "" | |
}); | |
d.fulfill(!0); | |
return d | |
}, | |
"*application_notify_loaded": function (a, b) { | |
var d = this._createPromise(); | |
this.publisher.notify("APPLICATION_LOAD_TIME", { | |
uri: a.getURI(), | |
complete: (new Date).getTime() | |
}); | |
d.fulfill(!0); | |
return d | |
} | |
}); | |
l.exports = m | |
})() | |
}, | |
"node_modules/spotify-bridge/src/bridge/responders/client.js": function (b, l, f, n, | |
p, r) { | |
(function () { | |
var a = b("node_modules/spotify-bridge/src/shell/extension.js").LinkHelper, | |
f = b("node_modules/spotify-bridge/src/bridge/errors.js"), | |
m = b("node_modules/spotify-bridge/src/bridge/responder.js").build({ | |
_ready: !1, | |
_broadcastListeners: [], | |
init: function (a, b) { | |
this._publisher = b.publisher; | |
this._setReady() | |
}, | |
"*client_event_wait": function (a, b) { | |
var d = this._createPromise(); | |
this._broadcastListeners.push(d); | |
return d | |
}, | |
"*client_broadcast": function (a, b) { | |
var d = this._broadcastListeners; | |
this._broadcastListeners = []; | |
for (var c = { | |
type: "broadcast", | |
message: b.args[0] | |
}, k = 0, f = d.length; k < f; k++) d[k].fulfill(c) | |
}, | |
"*client_features": function (a, b) { | |
return a.get("/features").then(function (a) { | |
return { | |
features: a.body.result | |
} | |
}) | |
}, | |
"*client_show_context_ui": function (a, b) { | |
var d = b.args, | |
c = parseInt(d[1], 10), | |
k = parseInt(d[2], 10), | |
c = isNaN(c) ? 0 : c, | |
k = isNaN(k) ? 0 : k; | |
this._publisher.notify("CLIENT_SHOW_CONTEXT_UI", { | |
origin: a.getFrame(), | |
items: d[0], | |
left: c, | |
top: k, | |
itemContext: d[3], | |
itemIndex: d[4] | |
}); | |
return !0 | |
}, | |
"*client_show_limited_feature_ui": function (a, | |
b) { | |
this._publisher.notify("LIMITED_FEATURE_CALL", { | |
origin: b.source, | |
feature: b.args[0], | |
callback: function () {} | |
}); | |
return !0 | |
}, | |
"*client_show_share_ui": function (b, g) { | |
var d = this._createPromise(), | |
c = g.args, | |
k = a.from(c[0]); | |
if (!k) return d.fail(new f.InvalidURI("URI is not valid.")), d; | |
var m = parseInt(c[2], 10), | |
c = parseInt(c[3], 10), | |
m = isNaN(m) ? 0 : m, | |
c = isNaN(c) ? 0 : c; | |
this._publisher.notify("CLIENT_SHOW_SHARE_UI", { | |
origin: g.source, | |
left: m, | |
top: c, | |
uri: k, | |
callback: function (a) { | |
a ? d.fulfill(!0) : d.fail(new f.Forbidden("Cannot show share UI.")) | |
} | |
}); | |
return d | |
}, | |
"*client_show_collection_union_remove_ui": function (a, b) { | |
var d = this._createPromise(); | |
this._publisher.notify("CLIENT_SHOW_COLLECTION_UNION_REMOVE_UI", { | |
origin: b.source, | |
uri: b.args[1], | |
callback: function (a) { | |
a ? d.fulfill(!0) : d.fail(new f.Forbidden("Cannot show collection-confirm-union-remove UI.")) | |
} | |
}); | |
return d | |
} | |
}); | |
l.exports = m | |
})() | |
}, | |
"node_modules/spotify-bridge/src/bridge/responders/facebook.js": function (b, l, f, n, p, r) { | |
(function () { | |
var a = Spotify.Link, | |
f = b("node_modules/spotify-bridge/src/bridge/responder.js").build({ | |
_ready: !1, | |
init: function (a, b) { | |
this.publisher = b.publisher; | |
this.use({ | |
facebook: a.facebook | |
}) | |
}, | |
start: function () { | |
this._setReady() | |
}, | |
"@facebook_friends_snapshot": function (b, h) { | |
"spotify:user:@" != this._extractListURI(b.args[0]) ? h.fail("Can only get the Facebook friends of the current user") : this.facebook.getFriends(function (g) { | |
var d = b.args[1] || 0, | |
c = b.args[2] || -1; | |
0 > d && (d = 0); | |
0 > c ? c = g.length - d : c > g.length && (c = g.length); | |
for (var k = [], f = [], l = d; l < d + c; l++) { | |
var q = g[l]; | |
k.push(q.facebookUid); | |
var n = null; | |
q.username && (n = a.profileLink(q.username).toString()); | |
f.push({ | |
image: q.picture, | |
name: q.name, | |
user: n | |
}) | |
} | |
h.send({ | |
range: { | |
offset: d, | |
length: c | |
}, | |
length: g.length, | |
array: k, | |
metadata: f | |
}) | |
}, h.fail.bind(h, "transient", "Cannot get Facebook friends.")) | |
}, | |
"@facebook_message": function (a, b) { | |
var g = a.args[0]; | |
if (!Array.isArray(g)) return b.fail("invalid-uids", "Invalid list of Facebook user IDs"); | |
var d = a.args[2], | |
c = a.args[1]; | |
if (!d && !c) return b.fail("invalid-args", "URL or message is required."); | |
this.publisher.notify("FB_MESSAGE", { | |
origin: a.source, | |
url: d, | |
message: c, | |
uids: g, | |
callback: function (a) { | |
return a ? | |
b.send(!0) : b.fail("error", "Could not message users on Facebook") | |
} | |
}) | |
}, | |
"@facebook_post": function (a, b) { | |
var g = a.args[1], | |
d = a.args[0]; | |
if (!g && !d) return b.fail("invalid-args", "URL or message is required."); | |
this.publisher.notify("FB_POST", { | |
origin: a.source, | |
url: g, | |
message: d, | |
callback: function (a) { | |
return a && !a.error ? b.send(!0) : b.fail("error", "Could not post to Facebook") | |
} | |
}) | |
}, | |
"@facebook_session_query": function (a, b) { | |
this.publisher.notify("FB_SESSION_QUERY", { | |
origin: a.source, | |
callback: function (a) { | |
return a && a.facebookUser ? | |
b.send(a) : b.fail("error", "Cannot load Facebook session") | |
} | |
}) | |
}, | |
"@facebook_user_metadata": function (a, b) { | |
this.publisher.notify("FB_SESSION_USER_METADATA", { | |
origin: a.source, | |
callback: function (a) { | |
return (a = "success" === a.status ? a.message : null) && a.name ? b.send(a) : b.fail("error", "Cannot load Facebook name") | |
} | |
}) | |
} | |
}); | |
l.exports = f | |
})() | |
}, | |
"node_modules/spotify-bridge/src/bridge/responders/hermes.js": function (b, l, f, n, p, r) { | |
(function () { | |
var a = b("node_modules/spotify-bridge/src/bridge/responder.js").build({ | |
_nextSubscriptionId: 1, | |
_subscriptions: {}, | |
_ready: !1, | |
hermes: null, | |
init: function (a) { | |
this.hermes = a.hermes; | |
this.use({ | |
pubsub: a.pubsub | |
}) | |
}, | |
start: function () { | |
this._setReady() | |
}, | |
resolveSchemas: function (a, b) { | |
if (!b) return a; | |
for (var h = b["static"], g = h.replace(/\/([^\/]*)$/, ""), d = [], c = 0, k = a.length; c < k; c++) { | |
var f = a[c]; | |
if (!/^\/static/.test(f)) { | |
var l = f.match(/^\$([a-z\-\_]+)(\/.*)/), | |
n = !1, | |
p, v = !1; | |
l ? (n = l[1], p = l[2]) : /^\//.exec(f) && (v = !0); | |
n && b[n] ? f = b[n] + p : (n ? f = "/" + n + p : v || (f = "/" + f), f = (n ? g : h) + f) | |
} | |
d.push(f) | |
} | |
return d | |
}, | |
onPubsubMessage: function (a, b, h, | |
g) { | |
if ((a = this._subscriptions[b]) && !(4 > h.length)) { | |
var d; | |
h = 0; | |
for (d = a.length; h < d; h++) a[h].send({ | |
type: "message", | |
frames: g | |
}); | |
delete this._subscriptions[b] | |
} | |
}, | |
"@hermes_event_wait": function (a, b) { | |
b.persist(); | |
var h = parseInt(a.args[0], 10); | |
if (isNaN(h) || 1 > h || h >= this._nextSubscriptionId) b.fail("hermes", "Invalid subscription id"); | |
else { | |
var g = this._subscriptions[h]; | |
g ? g.push(b) : this._subscriptions[h] = [b] | |
} | |
}, | |
"@hermes_load_schema_data": function (a, b) { | |
this.hermes.loadSchemaData(a.args, function (a) { | |
b.send({ | |
id: a | |
}) | |
}, b.fail.bind(b, | |
"hermes", "Failed to load schema data")) | |
}, | |
"@hermes_register_schema": function (a, b) { | |
this.hermes.loadSchemas(this.resolveSchemas(a.args, a.deps), "proto", function (a) { | |
b.send({ | |
id: a | |
}) | |
}, b.fail.bind(b, "hermes", "Failed to register schema")) | |
}, | |
"@hermes_send_request": function (a, b) { | |
var h = a.args; | |
this.hermes.send(h[0], h[1], h[3], h[2], h[4], function (a) { | |
b.send({ | |
result: a | |
}) | |
}, b.fail.bind(b, "hermes", "Hermes request failed")) | |
}, | |
"@hermes_subscribe": function (a, b) { | |
var h = this._nextSubscriptionId++, | |
g = a.args; | |
this.pubsub.subscribe(g[0], | |
g[3], g[2], g[1], b.send.bind(b, { | |
subscription_id: h | |
}), b.fail.bind(b, "hermes", "Error when trying to subscribe"), this.onPubsubMessage.bind(this, b, h), null) | |
}, | |
"@hermes_unsubscribe": function (a, b) { | |
var h = parseInt(a.args[0], 10); | |
if (isNaN(h) || 1 > h || h >= this._nextSubscriptionId) b.fail("hermes", "Invalid subscription id"); | |
else { | |
var g = this._subscriptions[h]; | |
if (g) { | |
for (var d = 0, c = g.length; d < c; d++) g[d].send({ | |
type: "close" | |
}); | |
delete this._subscriptions[h] | |
} | |
b.send() | |
} | |
} | |
}); | |
l.exports = a | |
})() | |
}, | |
"node_modules/spotify-bridge/src/bridge/responders/keyboard.js": function (b, | |
l, f, n, p, r) { | |
(function () { | |
var a = b("node_modules/spotify-bridge/src/bridge/responder.js").build({ | |
_ready: !1, | |
_modifiers: { | |
alt: 1, | |
meta: 2, | |
shift: 4, | |
ctrl: 8 | |
}, | |
_keymap: { | |
32: 16, | |
37: 32, | |
38: 64, | |
39: 128, | |
40: 256, | |
83: 512 | |
}, | |
_ignore: { | |
input: 1, | |
button: 1, | |
textarea: 1, | |
select: 1 | |
}, | |
_SEEK_WITH_KEYBOARD_MS: 15E3, | |
_bindings: {}, | |
_empty: function () {}, | |
init: function () { | |
this._setupBindings(); | |
this._setReady(); | |
window.addEventListener("keydown", this.handleOwn.bind(this, !1)); | |
window.addEventListener("keyup", this.handleOwn.bind(this, !0)) | |
}, | |
_setupBindings: function () { | |
var a = | |
this._bindings, | |
b = this._modifiers, | |
h = this._keymap; | |
a[h[32]] = "player_play_toggle"; | |
a[h[37] | b.shift] = "player_skip_to_prev"; | |
a[h[39] | b.shift] = "player_skip_to_next"; | |
a[h[37] | b.ctrl | b.shift] = "player_seek_backward"; | |
a[h[39] | b.ctrl | b.shift] = "player_seek_forward"; | |
a[h[38] | b.ctrl | b.alt] = "player_volume_up"; | |
a[h[40] | b.ctrl | b.alt] = "player_volume_down"; | |
a[h[83] | b.ctrl | b.alt] = "navigation_show_search" | |
}, | |
handleOwn: function (a, b) { | |
if (this._ignore[b.target.tagName.toLowerCase()]) return this; | |
var h = this._keymap[b.which || b.keyCode]; | |
if (!h) return this; | |
var g = this._modifiers; | |
b.altKey && (h |= g.alt); | |
b.metaKey && (h |= g.meta); | |
b.ctrlKey && (h |= g.ctrl); | |
b.shiftKey && (h |= g.shift); | |
h = this._bindings[h]; | |
if (!h) return this; | |
b.preventDefault(); | |
b.stopPropagation(); | |
g = null; | |
if ("player_seek_forward" === h || "player_seek_backward" === h) g = this._SEEK_WITH_KEYBOARD_MS; | |
if (!a) return this; | |
this.trigger(h, ["main", g], this._empty, this._empty) | |
}, | |
"@keyboard_get_bindings": function (a, b) { | |
return b.send({ | |
_modifiers: this._modifiers, | |
_keymap: this._keymap, | |
_ignore: this._ignore, | |
_bindings: this._bindings | |
}) | |
}, | |
"@keyboard_trigger_binding": function (a, b) { | |
var h = a.args[0], | |
g = null; | |
if ("player_seek_forward" === h || "player_seek_backward" === h) g = this._SEEK_WITH_KEYBOARD_MS; | |
this.trigger(h, { | |
args: ["main", g], | |
origin: a.origin | |
}, this._empty, this._empty) | |
}, | |
"@navigation_show_search": function (a, b) { | |
$("nav-search").onmousedown({ | |
preventDefault: this._empty | |
}) | |
} | |
}); | |
l.exports = a | |
})() | |
}, | |
"node_modules/spotify-bridge/src/bridge/responders/location.js": function (b, l, f, n, p, r) { | |
(function () { | |
var a = window.navigator, | |
f = b("node_modules/spotify-bridge/src/bridge/responder.js").build({ | |
_ready: !1, | |
_hasGeo: !1, | |
_current: null, | |
_error: null, | |
_listeners: [], | |
init: function () { | |
this.setup() | |
}, | |
setup: function () { | |
"geolocation" in a && (this._hasGeo = !0); | |
this._setReady() | |
}, | |
notifyListeners: function () { | |
for (var a = this._listeners.splice(0, this._listeners.length), b = this._error, g = 0, d = a.length; g < d; g++) { | |
var c = a[g]; | |
b ? c.fail(b.code, b.message) : c.send(this._current) | |
} | |
}, | |
positionFailed: function (a) { | |
var b; | |
switch (a.code) { | |
case 1: | |
a = "permission-denied"; | |
b = "The user has denied access to their location."; | |
break; | |
case 3: | |
a = "timeout"; | |
b = "The request has timed out"; | |
break; | |
default: | |
a = "transient", b = "Cannot fetch the location right now" | |
} | |
this._error = { | |
code: a, | |
message: b | |
}; | |
this._current = null; | |
this.notifyListeners() | |
}, | |
positionFetched: function (a) { | |
a = a.coords; | |
this._error = null; | |
this._current = this.fuzz({ | |
latitude: a.latitude, | |
longitude: a.longitude, | |
accuracy: a.accuracy | |
}); | |
this.notifyListeners() | |
}, | |
fuzz: function (a) { | |
return { | |
latitude: 0.01 * Math.floor(100 * a.latitude), | |
longitude: 0.01 * Math.floor(100 * a.longitude), | |
accuracy: a.accuracy | |
} | |
}, | |
"@location_query": function (b, h) { | |
var g = this._error, | |
d = this._current; | |
if (g) return h.fail(g.code, g.message); | |
if (d) return h.send(d); | |
this._listeners.push(h); | |
a.geolocation.watchPosition(this.positionFetched.bind(this), this.positionFailed.bind(this)) | |
} | |
}); | |
l.exports = f | |
})() | |
}, | |
"node_modules/spotify-bridge/src/bridge/responders/metadata.js": function (b, l, f, n, p, r) { | |
(function () { | |
var a = b("node_modules/spotify-bridge/src/shell/extension.js").LinkHelper, | |
f = b("node_modules/spotify-bridge/src/bridge/errors.js"), | |
m = b("node_modules/spotify-bridge/src/bridge/responder.js"), | |
h = b("node_modules/spotify-bridge/src/bridge/snapshothelper.js"), | |
m = m.build({ | |
_ready: !0, | |
"*artist_metadata": function (b, d) { | |
var c = this._createPromise(), | |
k = a.from(d.args[0]); | |
return k ? b.get("/artist", {}, { | |
uri: k | |
}).then(function (a) { | |
return a.body.result | |
}) : (c.fail(new f.InvalidURI("Not a valid Spotify URI.")), c) | |
}, | |
"*artist_profile": "artist_metadata", | |
"*album_metadata": function (b, d) { | |
var c = this._createPromise(), | |
k = a.from(d.args[0]); | |
return k ? b.get("/album", {}, { | |
uri: k | |
}).then(function (a) { | |
return a.body.result | |
}) : (c.fail(new f.InvalidURI("Not a valid Spotify URI.")), c) | |
}, | |
"*album_profile": "album_metadata", | |
"*track_metadata": function (b, d) { | |
var c = this._createPromise(), | |
k = a.from(d.args[0]); | |
return k ? b.get("/track", {}, { | |
uri: k | |
}).then(function (a) { | |
return a.body.result | |
}) : (c.fail(new f.InvalidURI("Not a valid Spotify URI.")), c) | |
}, | |
"**track_multi_metadata": function (a, b, c) { | |
console.trace(); | |
for (var k = b.args.length, h = {}, f = function (a, b) { | |
h[a] = b.error ? null : data; | |
k--; | |
k || c.send(h) | |
}, m = 0, l = b.args.length; m < l; m++) { | |
var q = b.args[m].toString(), | |
n = f.bind(null, q); | |
this._request("track_metadata", { | |
args: [q] | |
}, a).then(n, n) | |
} | |
}, | |
"*album_tracks_snapshot": function (a, | |
b) { | |
var c = b.args[1], | |
k = b.args[2]; | |
return a.get("/album/tracks", {}, { | |
descriptor: b.args[0] | |
}).then(h.createListSnapshotter(c, k)).then(h.formatSnapshot) | |
}, | |
"*album_disc_tracks_snapshot": function (a, b) { | |
var c = b.args[1], | |
k = b.args[2]; | |
return a.get("/album/disc/tracks", {}, { | |
descriptor: b.args[0] | |
}).then(h.createListSnapshotter(c, k)).then(h.formatSnapshot) | |
}, | |
"*artist_albums_snapshot": function (a, b) { | |
var c = b.args[1], | |
k = b.args[2]; | |
return a.get("/artist/albums", {}, { | |
descriptor: b.args[0] | |
}).then(h.createListSnapshotter(c, k)).then(h.formatMetadataSnapshot) | |
}, | |
"*artist_appearances_snapshot": function (a, b) { | |
var c = b.args[1], | |
k = b.args[2]; | |
return a.get("/artist/appearances", {}, { | |
descriptor: b.args[0] | |
}).then(h.createListSnapshotter(c, k)).then(h.formatMetadataSnapshot) | |
}, | |
"*artist_singles_snapshot": function (a, b) { | |
var c = b.args[1], | |
k = b.args[2]; | |
return a.get("/artist/singles", {}, { | |
descriptor: b.args[0] | |
}).then(h.createBaseListSnapshotter(c, k)).then(h.formatMetadataSnapshot) | |
}, | |
"*artist_top_tracks_snapshot": function (a, b) { | |
var c = b.args[1], | |
k = b.args[2]; | |
return a.get("/artist/toptracks", {}, { | |
descriptor: b.args[0] | |
}).then(h.createListSnapshotter(c, k)).then(h.formatSnapshot) | |
}, | |
"*artist_related_artists_snapshot": function (a, b) { | |
var c = b.args[1], | |
k = b.args[2]; | |
return a.get("/artist/related", {}, { | |
descriptor: b.args[0] | |
}).then(h.createListSnapshotter(c, k)).then(h.formatSnapshot) | |
} | |
}); | |
l.exports = m | |
})() | |
}, | |
"node_modules/spotify-bridge/src/bridge/responders/messaging.js": function (b, l, f, n, p, r) { | |
(function () { | |
var a = Spotify.Link, | |
f = b("node_modules/spotify-bridge/src/bridge/responder.js").build({ | |
_ready: !1, | |
init: function (a) { | |
this.use({ | |
service: a.services.inbox, | |
user: a.services.user | |
}) | |
}, | |
start: function () { | |
this._setReady() | |
}, | |
"@messaging_send": function (b, h) { | |
var g = this; | |
g.user.getUserInfo(function (d) { | |
function c() { | |
f += 1; | |
f === b.args[0].length && h.send(!0) | |
} | |
function k(a) { | |
h.fail(a, a.code, a.description) | |
} | |
var f = 0; | |
b.args[0].forEach(function (h) { | |
h = { | |
items: [{ | |
uri: b.args[2], | |
message: b.args[1] | |
}], | |
recipient: a.fromString(h).username, | |
sender: d.user | |
}; | |
g.service.addToInbox(h, c, k) | |
}) | |
}, h.fail.bind(h, "transient", "Cannot fetch session.")) | |
} | |
}); | |
l.exports = f | |
})() | |
}, | |
"node_modules/spotify-bridge/src/bridge/responders/relations.js": function (b, | |
l, f, n, p, r) { | |
(function () { | |
var a = Spotify.Link, | |
f = Spotify.Events, | |
f = b("node_modules/spotify-bridge/src/bridge/responder.js").build({ | |
_ready: !1, | |
_listeners: [], | |
_events: new f, | |
init: function (a) { | |
a = this.service = a.socialGraph; | |
a.bind(this._events.RELATIONS_SUBSCRIBE, this.addSubscriptions, this, 0); | |
a.bind(this._events.RELATIONS_UNSUBSCRIBE, this.removeSubscriptions, this, 0); | |
a.bind(this._events.RELATIONS_DISMISS, this.addDismissed, this, 0); | |
a.bind(this._events.RELATIONS_UNDISMISS, this.removeDismissed, this, 0); | |
a.bind(this._events.RELATIONS_BLOCK, | |
this.addBlocked, this, 0); | |
a.bind(this._events.RELATIONS_UNBLOCK, this.removeBlocked, this, 0); | |
a.onReady(this.start, this) | |
}, | |
start: function () { | |
this._setReady(); | |
this.service.preloadCurrentUserRelations() | |
}, | |
addSubscriptions: function (a) { | |
this.modifyRelations("add", a.params.users, "subscriptions", function (a) { | |
a.subscribed = !0; | |
return a | |
}) | |
}, | |
removeSubscriptions: function (a) { | |
this.modifyRelations("remove", a.params.users, "subscriptions", function (a) { | |
a.subscribed = !1; | |
return a | |
}) | |
}, | |
addDismissed: function (a) { | |
this.modifyRelations("add", | |
a.params.users, "dismissed", function (a) { | |
a.dismissed = !0; | |
return a | |
}) | |
}, | |
removeDismissed: function (a) { | |
this.modifyRelations("remove", a.params.users, "dismissed", function (a) { | |
a.dismissed = !1; | |
return a | |
}) | |
}, | |
addBlocked: function (a) { | |
this.modifyRelations("add", a.params.users, "blocked", function (a) { | |
a.blocked = !0; | |
return a | |
}) | |
}, | |
removeBlocked: function (a) { | |
this.modifyRelations("remove", a.params.users, "blocked", function (a) { | |
a.blocked = !1; | |
return a | |
}) | |
}, | |
modifyRelations: function (b, h, g, d) { | |
for (var c = [], k = 0, f = h.length; k < f; k++) { | |
var l = a.profileLink(h[k]), | |
q = this.retrieve(l, "parsed.metadata"); | |
q && (q = d(q), this.store(l, "parsed.metadata", q)); | |
c.push(l.toString()) | |
} | |
this.notifyListeners(b, g, c) | |
}, | |
request: function (b, h, g) { | |
var d = h.args, | |
c = this._extractListURI(h.args[0]), | |
c = c ? a.fromString(c).username : null, | |
k = h.args[1]; | |
h = h.args[2]; | |
"@" === c && (c = null); | |
this.service[b](c, h, k, this.reply.bind(this, g, d), this.handleError.bind(this, g)) | |
}, | |
modify: function (b, h, g) { | |
h = h.args; | |
for (var d = [], c = 0, k = h.length; c < k; c++) { | |
var f = a.fromString(h[c]).username; | |
"@" !== f && d.push(f) | |
} | |
this.service[b](d, this.modifyReply.bind(this, | |
g, h), this.handleError.bind(this, g)) | |
}, | |
reply: function (b, h, g) { | |
var d = [], | |
c = g[0].users; | |
g = g[0].length; | |
if (c) | |
for (var k = 0, f = c.length; k < f; k++) d.push(a.profileLink(c[k].username).toString()); | |
h = this.createSnapshot(h, d, g); | |
b.send(h) | |
}, | |
modifyReply: function (a, b, g) { | |
a.send({}) | |
}, | |
handleError: function (a, b) { | |
var g, d; | |
switch (b.code) { | |
case 404: | |
g = "not-found"; | |
d = "No relation found."; | |
break; | |
default: | |
g = "transient", d = "Possible issues with the socialgraph service." | |
} | |
return a.fail(g, d) | |
}, | |
notifyListeners: function (a, b, g) { | |
for (a = { | |
type: a, | |
receiver: b, | |
uris: g | |
}; 0 < this._listeners.length;) this._listeners.pop().send(a); | |
return this | |
}, | |
"@relations_event_wait": function (a, b) { | |
this._listeners.push(b.persist()) | |
}, | |
"@relations_subscribers_users_snapshot": function (a, b) { | |
this.request("getSubscribers", a, b) | |
}, | |
"@relations_subscriptions_users_snapshot": function (a, b) { | |
this.request("getSubscriptions", a, b) | |
}, | |
"@relations_blocked_users_snapshot": function (a, b) { | |
this.request("getBlocked", a, b) | |
}, | |
"@relations_dismissed_users_snapshot": function (a, b) { | |
this.request("getDismissed", a, b) | |
}, | |
"@relations_hidden_users_snapshot": function (a, b) { | |
this.request("getHidden", a, b) | |
}, | |
"@relations_block": function (a, b) { | |
this.modify("block", a, b) | |
}, | |
"@relations_unblock": function (a, b) { | |
this.modify("unblock", a, b) | |
}, | |
"@relations_dismiss": function (a, b) { | |
this.modify("dismiss", a, b) | |
}, | |
"@relations_undismiss": function (a, b) { | |
this.modify("undismiss", a, b) | |
}, | |
"@relations_subscribe": function (a, b) { | |
this.modify("subscribeTo", a, b) | |
}, | |
"@relations_unsubscribe": function (a, b) { | |
this.modify("unsubscribeFrom", a, b) | |
} | |
}); | |
l.exports = f | |
})() | |
}, | |
"node_modules/spotify-bridge/src/bridge/responders/runtime.js": function (b, | |
l, f, n, p, r) { | |
(function () { | |
var a = b("node_modules/spotify-bridge/src/bridge/responder.js"), | |
f = a.build({ | |
_ready: !1, | |
init: function (a, b) { | |
this.getAppUrl = b.getAppUrl; | |
this.start() | |
}, | |
start: function () { | |
this._setReady() | |
}, | |
"@core_request_lookup": function (b, h) { | |
h.send(a.respondsTo(b.args[0])) | |
}, | |
"@application_require": function (a, b) { | |
b.send("http://origin.spapps.keeto.d.spotify.net/" + a.args[0] + "/") | |
} | |
}); | |
l.exports = f | |
})() | |
}, | |
"node_modules/spotify-bridge/src/bridge/responders/search.js": function (b, l, f, n, p, r) { | |
(function () { | |
var a = b("node_modules/spotify-bridge/src/bridge/errors.js"), | |
f = b("node_modules/spotify-bridge/src/bridge/responder.js"), | |
m = b("node_modules/spotify-bridge/src/bridge/snapshothelper.js"), | |
f = f.build({ | |
_ready: !1, | |
init: function () { | |
this.start() | |
}, | |
start: function () { | |
this._setReady() | |
}, | |
_searchSnapshot: function (b, g, d) { | |
d = d.args; | |
var c = d[1], | |
k = d[2]; | |
return g.get("/search/" + b, { | |
flush: !0 | |
}, { | |
descriptor: d[0] | |
}).then(m.createListSnapshotter(c, k)).then(m.formatSnapshot).catchError(function (b) { | |
if (b.domain && 9 == b.domain && 1 == b.code) throw new a.RateLimited("Cannot perform search"); | |
throw new a.Transient("Search service issues"); | |
}) | |
}, | |
"*search_albums_snapshot": function (a, b) { | |
return this._searchSnapshot("albums", a, b) | |
}, | |
"*search_artists_snapshot": function (a, b) { | |
return this._searchSnapshot("artists", a, b) | |
}, | |
"*search_fuzzy_match": function (a, b) { | |
var d = function (a) { | |
return { | |
fuzzyMatch: a.body.match | |
} | |
}; | |
return a.get("/search/fuzzymatch", {}, { | |
query: b.args[0] | |
}).then(d, d) | |
}, | |
"*search_playlists_snapshot": function (a, b) { | |
return this._searchSnapshot("playlists", a, b) | |
}, | |
"*search_tracks_snapshot": function (a, b) { | |
return this._searchSnapshot("tracks", a, b) | |
} | |
}); | |
l.exports = | |
f | |
})() | |
}, | |
"node_modules/spotify-bridge/src/bridge/responders/suggest.js": function (b, l, f, n, p, r) { | |
(function () { | |
b("node_modules/spotify-bridge/src/bridge/sourceurls.js"); | |
var a = b("node_modules/spotify-bridge/src/bridge/errors.js"), | |
f = b("node_modules/spotify-bridge/src/bridge/responder.js").build({ | |
_ready: !0, | |
"*suggest_albums_snapshot": function (a, b) { | |
return this._handleSuggestRequest("albums", a, b) | |
}, | |
"*suggest_tracks_snapshot": function (a, b) { | |
return this._handleSuggestRequest("tracks", a, b) | |
}, | |
"*suggest_artists_snapshot": function (a, | |
b) { | |
return this._handleSuggestRequest("artists", a, b) | |
}, | |
"*suggest_playlists_snapshot": function (a, b) { | |
return this._handleSuggestRequest("playlists", a, b) | |
}, | |
_handleSuggestRequest: function (b, h, g) { | |
var d = this._extractListURI(g.args[0]), | |
c = this; | |
if (!d) throw new a.InvalidRequest("Invalid URI"); | |
d = d.toString().replace("suggest", "search"); | |
return h.get("/suggest/" + b, { | |
flush: !0 | |
}, { | |
uri: d | |
}).then(function (a) { | |
a = c._addMetadata(a.body.list); | |
return c.createSnapshot(g.args, a.array, a.total, a.metadata) | |
}).catchError(function (b) { | |
throw new a.Transient("Search service issues"); | |
}) | |
}, | |
_addMetadata: function (a) { | |
for (var b = [], g = 0; g < a.length; g++) b.push(a[g].uri); | |
return { | |
total: b.length, | |
array: b, | |
metadata: a | |
} | |
} | |
}); | |
l.exports = f | |
})() | |
}, | |
"node_modules/spotify-bridge/src/bridge/responders/toplist.js": function (b, l, f, n, p, r) { | |
(function () { | |
var a = b("node_modules/spotify-bridge/src/bridge/snapshothelper.js"), | |
f = b("node_modules/spotify-bridge/src/bridge/responder.js").build({ | |
_ready: !0, | |
"*toplist_user_snapshot": function (b, h) { | |
var g = h.args[1], | |
d = h.args[2]; | |
return b.get("/toplist/user", null, { | |
descriptor: h.args[0] | |
}).then(a.createListSnapshotter(g, | |
d)).then(a.formatSnapshot) | |
}, | |
"*toplist_user_albums_snapshot": "toplist_user_snapshot", | |
"*toplist_user_artists_snapshot": "toplist_user_snapshot", | |
"*toplist_user_tracks_snapshot": "toplist_user_snapshot", | |
"*toplist_user_playlists_snapshot": "toplist_user_snapshot", | |
"*toplist_region_snapshot": function (b, h) { | |
var g = h.args[1], | |
d = h.args[2]; | |
return b.get("/toplist/region", null, { | |
descriptor: h.args[0] | |
}).then(a.createListSnapshotter(g, d)).then(a.formatSnapshot) | |
}, | |
"*toplist_region_albums_snapshot": "toplist_region_snapshot", | |
"*toplist_region_artists_snapshot": "toplist_region_snapshot", | |
"*toplist_region_tracks_snapshot": "toplist_region_snapshot", | |
"*toplist_region_playlists_snapshot": "toplist_region_snapshot", | |
"*toplist_artist_tracks_snapshot": "artist_top_tracks_snapshot" | |
}); | |
l.exports = f | |
})() | |
}, | |
"node_modules/spotify-bridge/src/bridge/responders/user.js": function (b, l, f, n, p, r) { | |
(function () { | |
var a = b("node_modules/spotify-bridge/src/bridge/responder.js").build({ | |
_ready: !0, | |
"*session_query": function (a, b) { | |
return a.get("/session").then(function (a) { | |
a = | |
a.body.result; | |
a._username = a.user.username; | |
a._publishPlaylists = a.publishPlaylists; | |
return a | |
}) | |
}, | |
"**session_query_nocache": function (a, b) { | |
return a.get("/session").then(function (a) { | |
a = a.body.result; | |
a._username = a.user.username; | |
a._publishPlaylists = a.publishPlaylists; | |
return a | |
}) | |
}, | |
"*session_test_group": function (a, b) { | |
return a.get("/session").then(function (h) { | |
return a.get("/user/groupid", {}, { | |
username: h.body.result.user.username, | |
salt: b.args[0] | |
}) | |
}).then(function (a) { | |
return { | |
testGroup: a.body.id | |
} | |
}) | |
}, | |
"*user_set_attribute": function (a, | |
b) { | |
var h = b.args; | |
return a.update("/user/attribute", null, { | |
key: h[0], | |
value: h[1] | |
}).then(function (a) { | |
return a.body | |
}) | |
}, | |
"*session_event_wait": function (a, b) {}, | |
"*user_metadata": function (a, b) { | |
return a.get("/profile", null, { | |
uri: b.args[0] | |
}).then(function (a) { | |
return a.body.result | |
}) | |
}, | |
"*user_associated_artist": function (a, b) { | |
return a.get("/profile/associatedartist", null, { | |
uri: b.args[0] | |
}).then(function (a) { | |
return { | |
artist: a.body.result | |
} | |
}) | |
}, | |
"*artist_associated_user": function (a, b) { | |
return a.get("/profile/associateduser", null, { | |
uri: b.args[0] | |
}).then(function (a) { | |
return { | |
user: a.body.result | |
} | |
}) | |
} | |
}); | |
l.exports = a | |
})() | |
}, | |
"node_modules/spotify-bridge/src/bridge/responders/library.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(a, b, d, g) { | |
var f = null; | |
a[d] !== b[g] && (f = -1 === b.indexOf(a[d]) && d < a.length ? { | |
type: "remove", | |
uris: [a[d]], | |
index: g, | |
indices: [g] | |
} : { | |
type: "insert", | |
uris: [b[g]], | |
index: g, | |
indices: [g] | |
}); | |
return f | |
} | |
function f(b, d) { | |
for (var g = [], h = Math.max(b.length, d.length), l, m, q = 0, n = 0, u, p, y = 0; y < h; y += u) { | |
u = 1; | |
for (p = 0; l = a(b, d, y + p - q, y + p - n);) { | |
if (m) | |
if (l.type === | |
m.type) m.uris.push(l.uris[0]), m.indices.push(l.index), l = m; | |
else break; | |
"insert" === l.type ? q++ : "remove" === l.type && n++; | |
m = l; | |
p++; | |
if (Math.max(p, n) > h - y) throw Error("unsupported array: not sorted/unique."); | |
} | |
m && (u = m.uris.length, h += u, g.push(m), m = null) | |
} | |
return g | |
} | |
function m() { | |
this._listeners = [] | |
} | |
var h = b("node_modules/spotify-bridge/src/bridge/responder.js"), | |
g = Spotify.Link, | |
d = Spotify.Events; | |
m.prototype.queueEventListener = function (a) { | |
this._listeners.push(a) | |
}; | |
m.prototype.dispatch = function (a, b) { | |
for (var d = this._listeners.splice(0, | |
b || this._listeners.length), g = 0, f = d.length; g < f; g++)(0, d[g])(a) | |
}; | |
h = h.build({ | |
_ready: !1, | |
_collectionTracksDispatcherByUsername: {}, | |
_collectionAlbumsDispatcherByUsername: {}, | |
_collectionArtistsDispatcherByUsername: {}, | |
_collectionUnplayedDispatcher: new m, | |
_collectionAlbumChangesDispatcherByUri: {}, | |
_events: new d, | |
init: function (a) { | |
this.clientEventLogger = a.logging.clientEvent; | |
this.use({ | |
collectionStorageService: a.collectionStorage, | |
collectionViewService: a.collectionView, | |
collectionUnplayedService: a.collectionUnplayed, | |
userService: a.user | |
}) | |
}, | |
start: function () { | |
var a = this; | |
this.collectionUnplayedService.bind(this._events.CHANGED, function () { | |
a._collectionUnplayedDispatcher.dispatch({ | |
type: "change" | |
}) | |
}); | |
this._setReady() | |
}, | |
resolveUsername: function (a, b, d) { | |
try { | |
var f = g.fromString(a) | |
} catch (h) { | |
d("invalid-request", h); | |
return | |
} | |
f.type !== g.Type.PROFILE && (f.username ? a = g.profileLink(f.username).toURI() : d("invalid-request", "The uri did not contain a username")); | |
this.trigger("user_metadata", [a], function (a) { | |
b(a.username) | |
}, d) | |
}, | |
verifyLinkTypes: function (a, | |
b, d) { | |
for (var f = 0; f < a.length; f++) | |
if (g.fromString(a[f]).type != b) return d.fail("invalid-request", "Item of wrong type."), !1; | |
return !0 | |
}, | |
handleEventWait: function (a, b, d, g) { | |
var f = this; | |
g = g.persist(); | |
f.resolveUsername(this._extractListURI(d.args[0]), function (d) { | |
f.collectionViewService.getInstance(d, function (h) { | |
var l = a[d]; | |
l || (a[d] = l = new m, h.bind(f._events.CHANGED, function (a) { | |
if (a.params.source == b || "all" == a.params.source) a.params.inserted && a.params.inserted[b] && 0 < a.params.inserted[b].uris.length ? l.dispatch({ | |
type: "insert", | |
uris: a.params.inserted[b].uris, | |
index: a.params.inserted[b].indices[0], | |
indices: a.params.inserted[b].indices | |
}) : a.params.removed && a.params.removed[b] && 0 < a.params.removed[b].uris.length && l.dispatch({ | |
type: "remove", | |
uris: a.params.removed[b].uris, | |
index: a.params.removed[b].indices[0], | |
indices: a.params.removed[b].indices | |
}) | |
})); | |
l.queueEventListener(function (a) { | |
g.send(a) | |
}) | |
}) | |
}) | |
}, | |
"@library_artists_event_wait": function (a, b) { | |
this.handleEventWait(this._collectionArtistsDispatcherByUsername, "artists", a, b) | |
}, | |
"@library_albums_event_wait": function (a, | |
b) { | |
this.handleEventWait(this._collectionAlbumsDispatcherByUsername, "albums", a, b) | |
}, | |
"@library_tracks_event_wait": function (a, b) { | |
this.handleEventWait(this._collectionTracksDispatcherByUsername, "tracks", a, b) | |
}, | |
"@library_unplayed_event_wait": function (a, b) { | |
b = b.persist(); | |
this._collectionUnplayedDispatcher.queueEventListener(function (a) { | |
b.send(a) | |
}) | |
}, | |
handleSnapshot: function (a, b, d) { | |
var g = this, | |
f = b.args[1] || 0, | |
h = b.args[2]; | |
g.resolveUsername(this._extractListURI(b.args[0]), function (b) { | |
g.collectionViewService.getInstance(b, | |
function (b) { | |
b[a](f, h, function (a, b) { | |
d.send({ | |
range: { | |
offset: f, | |
length: a.length | |
}, | |
length: b || a.length, | |
array: a, | |
metadata: [] | |
}) | |
}, d.fail.bind(d, "transient", "Cannot snapshot collection.")) | |
}, d.fail.bind(d, "transient", "Cannot get a collection view instance.")) | |
}, d.fail.bind(d, "transient", "Unable to resolve username.")) | |
}, | |
"@library_artists_snapshot": function (a, b) { | |
this.handleSnapshot("artistsSnapshot", a, b) | |
}, | |
"@library_albums_snapshot": function (a, b) { | |
this.handleSnapshot("albumsSnapshot", a, b) | |
}, | |
"@library_tracks_snapshot": function (a, | |
b) { | |
this.handleSnapshot("tracksSnapshot", a, b) | |
}, | |
handleAppend: function (a, b, d, g, f) { | |
var h = this, | |
l = g.args.slice(1); | |
this.verifyLinkTypes(l, b, f) && h.resolveUsername(this._extractListURI(g.args[0]), function (b) { | |
h.collectionViewService.getInstance(b, function (b) { | |
b[d](l, function () { | |
f.send(!0); | |
h.clientEventLogger.log({ | |
source: a.getURI(), | |
source_version: "unkown", | |
source_vendor: "unkown", | |
event: "add-to-collection", | |
data: JSON.stringify(l) | |
}) | |
}, f.fail.bind(f, "transient", "Cannot perform operation on collection.")) | |
}, f.fail.bind(f, | |
"transient", "Cannot get a collection view instance.")) | |
}, f.fail.bind(f, "transient", "Unable to resolve username.")) | |
}, | |
"*library_albums_append": function (a, b, d) { | |
this.handleAppend(a, g.Type.ALBUM, "albumsAdd", b, d) | |
}, | |
"*library_tracks_append": function (a, b, d) { | |
this.handleAppend(a, g.Type.TRACK, "tracksAdd", b, d) | |
}, | |
handleRemove: function (a, b, d, f, h) { | |
var l = this, | |
m = f.args[2]; | |
if (g.fromString(m).type != b) return h.fail("invalid-request", "Trying to append item of wrong type."); | |
l.resolveUsername(this._extractListURI(f.args[0]), | |
function (b) { | |
l.collectionViewService.getInstance(b, function (b) { | |
b[d]([m], function () { | |
h.send(!0); | |
l.clientEventLogger.log({ | |
source: a.getURI(), | |
source_version: "unkown", | |
source_vendor: "unkown", | |
event: "remove-from-collection", | |
data: JSON.stringify([m]) | |
}) | |
}, h.fail.bind(h, "transient", "Cannot perform operation on collection.")) | |
}, h.fail.bind(h, "transient", "Cannot get a collection view instance.")) | |
}, h.fail.bind(h, "transient", "Unable to resolve username.")) | |
}, | |
"*library_albums_remove": function (a, b, d) { | |
this.handleRemove(a, | |
g.Type.ALBUM, "albumsRemove", b, d) | |
}, | |
"*library_tracks_remove": function (a, b, d) { | |
this.handleRemove(a, g.Type.TRACK, "tracksRemove", b, d) | |
}, | |
handleContains: function (a, b, d, g) { | |
var f = this, | |
h = d.args.slice(1); | |
this.verifyLinkTypes(h, a, g) && f.resolveUsername(this._extractListURI(d.args[0]), function (a) { | |
f.collectionViewService.getInstance(a, function (a) { | |
a[b](h, function (a) { | |
g.send({ | |
in_collection: a | |
}) | |
}, g.fail.bind(g, "transient", "Cannot perform operation on collection.")) | |
}, g.fail.bind(g, "transient", "Cannot get a collection view instance.")) | |
}, | |
g.fail.bind(g, "transient", "Unable to resolve username.")) | |
}, | |
"@library_tracks_contains": function (a, b) { | |
this.handleContains(g.Type.TRACK, "tracksContains", a, b) | |
}, | |
"@library_albums_contains": function (a, b) { | |
this.handleContains(g.Type.ALBUM, "albumsContains", a, b) | |
}, | |
"@library_unplayed_contains": function (a, b) { | |
var d = this, | |
f = a.args.slice(1); | |
this.verifyLinkTypes(f, g.Type.TRACK, b) && d.resolveUsername(this._extractListURI(a.args[0]), function (a) { | |
d.collectionUnplayedService.isUnplayed(a, f, function (a) { | |
b.send({ | |
in_collection: a | |
}) | |
}, | |
b.fail.bind(b, "transient", "Getting unplayed status failed.")) | |
}, b.fail.bind(b, "transient", "Unable to resolve username.")) | |
}, | |
"@library_tracks_clear": function (a, b) { | |
var d = this; | |
d.resolveUsername(this._extractListURI(a.args[0]), function (a) { | |
d.collectionViewService.getInstance(a, function (a) { | |
a.tracksClear(function () { | |
b.send(!0) | |
}, b.fail.bind(b, "transient", "Cannot perform operation on collection.")) | |
}, b.fail.bind(b, "transient", "Cannot get a collection view instance.")) | |
}, b.fail.bind(b, "transient", "Unable to resolve username.")) | |
}, | |
"@library_get_union_sources": function (a, b) { | |
var d = this, | |
g = a.args[1]; | |
d.resolveUsername(this._extractListURI(a.args[0]), function (a) { | |
d.collectionViewService.getInstance(a, function (a) { | |
if (!a.getSources) return b.fail("transient", "Not implemented yet"); | |
a.getSources(g, function (a) { | |
b.send(a) | |
}, b.fail.bind(b, "transient", "Cannot perform operation on collection.")) | |
}, b.fail.bind(b, "transient", "Cannot get a collection view instance.")) | |
}, b.fail.bind(b, "transient", "Unable to resolve username.")) | |
}, | |
"@collection_album_tracks_snapshot": function (a, | |
b) { | |
var d = g.fromString(this._extractListURI(a.args[0])); | |
if (d.type !== g.Type.COLLECTION_ALBUM) return b.fail("invalid-request", "Not a CollectionAlbum URI."); | |
this.getCollectionAlbumSnapshot(d, b.send.bind(b), b.fail.bind(b)) | |
}, | |
"@collection_missing_album_tracks_snapshot": function (a, b) { | |
var d = g.fromString(this._extractListURI(a.args[0])); | |
if (d.type !== g.Type.COLLECTION_MISSING_ALBUM) return b.fail("invalid-request", "Not a CollectionAlbum URI."); | |
this.getCollectionAlbumSnapshot(d, b.send.bind(b), b.fail.bind(b)) | |
}, | |
"@collection_album_event_wait": function (a, b) { | |
b = b.persist(); | |
var d = this, | |
h = g.fromString(this._extractListURI(a.args[0])), | |
l = g.profileLink(h.username).toURI(); | |
d.resolveUsername(l, function (a) { | |
h.username = a; | |
var c = h.toURI(), | |
g = d._collectionAlbumChangesDispatcherByUri[c]; | |
g || (d._collectionAlbumChangesDispatcherByUri[c] = g = new m, d.getCollectionAlbumSnapshot(h, function (l) { | |
d.collectionViewService.getInstance(a, function (a) { | |
var m = function (n) { | |
"tracks" != n.params.source && "all" != n.params.source || d.getCollectionAlbumSnapshot(h, | |
function (b) { | |
b = f(l.array, b.array); | |
g.dispatch(b); | |
d._collectionAlbumChangesDispatcherByUri[c] = g = null; | |
a.unbind(d._events.CHANGED, m) | |
}, b.fail.bind(b)) | |
}; | |
a.bind(d._events.CHANGED, m) | |
}) | |
}, b.fail.bind(b))); | |
g.queueEventListener(function (a) { | |
b.send(a) | |
}) | |
}) | |
}, | |
"@collection_missing_album_event_wait": "collection_album_event_wait", | |
getCollectionAlbumSnapshot: function (a, b, d) { | |
var f = a.type === g.Type.COLLECTION_ALBUM, | |
h = g.albumLink(a.id).toURI(), | |
l = g.profileLink(a.username).toURI(), | |
m = this; | |
m.trigger("album_tracks_snapshot", [h], | |
function (a) { | |
m.trigger("library_tracks_contains", [l].concat(a.array), function (d) { | |
var c = [], | |
g = []; | |
d.in_collection.forEach(function (b, d) { | |
f === b && (c.push(a.array[d]), a.metadata[d] && g.push(a.metadata[d])) | |
}); | |
b(m.createSnapshot([], c, null, g)) | |
}, d.bind(this, "transient", "Cannot check Collection containment")) | |
}, d.bind(this, "transient", "Cannot fetch album tracks")) | |
} | |
}); | |
h.diffUniqueSortedArrays = f; | |
l.exports = h | |
})() | |
}, | |
"node_modules/spotify-bridge/src/bridge/contextbase.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(a, | |
b, g) { | |
var f = 0, | |
h = b; | |
for (b = g.length + b; h < b; f++, h++) a[h] = g[f] | |
} | |
function f(a) { | |
for (var b = a.length; b;) { | |
var g = Math.floor(Math.random() * b--), | |
h = a[b]; | |
a[b] = a[g]; | |
a[g] = h | |
} | |
return a | |
} | |
function m(a, b) { | |
this._id = a; | |
this._rule = g.defaults; | |
this._currentIndex = 0; | |
this._shuffled = this._repeated = !1; | |
this._shuffledList = null; | |
this._metadata = []; | |
var k = this._list = this._origin = []; | |
if (!b) return this; | |
for (var f = 0, h = b.length; f < h; f++) f in b && b[f] && k.push(b[f]) | |
} | |
var h = b("node_modules/spotify-bridge/src/bridge/responder.js"), | |
g = { | |
defaults: { | |
skipCount: -1, | |
volume: !0, | |
seek: !0, | |
indexing: !0, | |
previous: !0, | |
next: !0, | |
shuffle: !0, | |
repeat: !0 | |
}, | |
intercept: { | |
skipcount: -1, | |
volume: !1, | |
seek: !1, | |
indexing: !0, | |
previous: !1, | |
next: !1, | |
shuffle: !1, | |
repeat: !1 | |
}, | |
radio: { | |
skipCount: -1, | |
volume: !0, | |
seek: !0, | |
indexing: !0, | |
previous: !1, | |
next: !0, | |
shuffle: !1, | |
repeat: !1 | |
}, | |
dmca: { | |
skipCount: 6, | |
volume: !0, | |
seek: !0, | |
indexing: !0, | |
previous: !1, | |
next: !0, | |
shuffle: !1, | |
repeat: !1 | |
}, | |
stream: { | |
skipcount: -1, | |
volume: !0, | |
seek: !1, | |
indexing: !0, | |
previous: !1, | |
next: !1, | |
shuffle: !1, | |
repeat: !1 | |
} | |
}; | |
m.prototype.getId = function () { | |
return this._anonymous ? null : | |
this._id | |
}; | |
m.prototype.setAnonymous = function (a) { | |
this._anonymous = !! a; | |
return this | |
}; | |
m.prototype.setRule = function (a) { | |
return (a = g[a]) ? (this._rule = a, !0) : !1 | |
}; | |
m.prototype.getRule = function (a) { | |
return this._rule | |
}; | |
m.prototype.setRepeat = function (a) { | |
return this._rule.repeat ? this._repeated = a : !1 | |
}; | |
m.prototype.isRepeated = function () { | |
return this._repeated | |
}; | |
m.prototype.setShuffle = function (a) { | |
if (!this._rule.shuffle) return !1; | |
(this._shuffled = a) ? this._shuffle() : this._unshuffle(); | |
return a | |
}; | |
m.prototype.isShuffled = function () { | |
return this._shuffled | |
}; | |
m.prototype.setExpiry = function (a) { | |
if (!a || 0 > a) return this; | |
this._time = (new Date).getTime(); | |
this._ttl = a; | |
return this | |
}; | |
m.prototype.isExpired = function () { | |
var a = this._ttl; | |
return a ? (new Date).getTime() - this._time >= a : !1 | |
}; | |
m.prototype.mapToURI = function (a, b) { | |
return b || a | |
}; | |
m.prototype.mapToId = function (a, b) { | |
return b || a | |
}; | |
m.prototype._shufflePartial = function (a) { | |
var b = this._shuffledList; | |
if (!b) return this; | |
for (var g = this._origin.length - a, h = Array(g); g--;) h[g] = a + g; | |
f(h).unshift(a, 0); | |
b.splice.apply(b, h); | |
return this | |
}; | |
m.prototype._shuffle = | |
function (a) { | |
if (void 0 != a) return this._shufflePartial(a); | |
var b = this._origin.length; | |
for (a = Array(b); b--;) a[b] = b; | |
b = a.splice(this._currentIndex, 1).pop(); | |
f(a).unshift(b); | |
this._list = this._shuffledList = a; | |
this._currentIndex = 0; | |
return this | |
}; | |
m.prototype._unshuffle = function () { | |
if (!this._shuffledList) return this; | |
this._list = this._origin; | |
this._currentIndex = this._shuffledList[this._currentIndex]; | |
return this | |
}; | |
m.prototype.get = function (a) { | |
var b = this._origin; | |
if (0 > a || a > b.length) return null; | |
this._shuffled && (a = this._shuffledList[a]); | |
b = b[a]; | |
a = this._metadata[a]; | |
return b && a ? { | |
item: b, | |
metadata: a | |
} : null | |
}; | |
m.prototype.getList = function () { | |
return this._origin | |
}; | |
m.prototype.getLength = function () { | |
return this._origin.length | |
}; | |
m.prototype.setFullLength = function (a) { | |
if ("number" != typeof a && (a = parseInt(a, 10), isNaN(a))) throw new TypeError("Cannot set possible length to a non-number"); | |
this._actualLen = a; | |
return this | |
}; | |
m.prototype.getFullLength = function () { | |
return void 0 != this._actualLen ? Math.max(this._actualLen, this.getLength()) : this.getLength() | |
}; | |
m.prototype.append = | |
function (a) { | |
if (!a) return this; | |
if (this._resolved) h.prototype.trigger("track_multi_metadata", [a], function (b) { | |
var c = this._origin.push(a) - 1; | |
this._metadata.push(b[a]); | |
this._shuffled && this._shuffle(c) | |
}.bind(this)); | |
else { | |
var b = this._origin.push(a) - 1; | |
this._shuffled && this._shuffle(b) | |
} | |
return this | |
}; | |
m.prototype.prependMany = function (a) { | |
a = Array.isArray(a) ? a : [a]; | |
this._resolved ? h.prototype.trigger("track_multi_metadata", a, function (b) { | |
this._origin.unshift.apply(this._origin, a); | |
for (var g = [], f = 0, h = a.length; f < h; f++) g[f] = | |
b[a[f]]; | |
this._metadata.unshift.apply(this._metadata, g); | |
this._shuffled && this._shuffle(0) | |
}.bind(this)) : (this._origin.unshift.apply(this._origin, a), this._shuffled && this._shuffle(0)); | |
return this | |
}; | |
m.prototype.appendWithMeta = function (a, b) { | |
if (!a || !b) return this; | |
var g = this._origin.push(a) - 1; | |
this._metadata[g] = b; | |
this._shuffled && this._shuffle(g); | |
return this | |
}; | |
m.prototype.concat = function (a) { | |
if (!a || !a.length) return this; | |
if (this._resolved) h.prototype.trigger("track_multi_metadata", a, function (b) { | |
for (var c = 0, g = a.length; c < | |
g; c++) this._origin.push(a[c]), this._metadata.push(b[a[c]]); | |
this._shuffled && this._shuffle(this._origin.length - a.length - 1) | |
}.bind(this)); | |
else { | |
for (var b = 0, g = a.length; b < g; b++) this._origin.push(a[b]); | |
this._shuffled && this._shuffle(this._origin.length - a.length - 1) | |
} | |
return this | |
}; | |
m.prototype.splice = function (b, c) { | |
if ("undefined" == typeof b || !c || !c.length) return this; | |
if (this._resolved) h.prototype.trigger("track_multi_metadata", c, function (g) { | |
for (var k = [], f = [], h = 0, l = c.length; h < l; h++) h in c && c[h] && (k.push(c[h]), f.push(g[c[h]])); | |
a(this._origin, b, c); | |
a(this._metadata, b, f); | |
this._shuffled && this._shuffle(b) | |
}.bind(this)); | |
else { | |
for (var g = [], f = 0, l = c.length; f < l; f++) f in c && c[f] && g.push(c[f]); | |
a(this._origin, b, g); | |
this._shuffled && this._shuffle(b) | |
} | |
}; | |
m.prototype.trim = function (a, b) { | |
var g = this._origin; | |
if (g[a] != b) return !1; | |
a += 1; | |
var f = g.length; | |
g.splice(a, f); | |
this._resolved && this._metadata.splice(a, f); | |
this._shuffled && this._shuffle(); | |
return !0 | |
}; | |
m.prototype.insert = function (a, b, g) { | |
if (!g) return !1; | |
"string" == typeof g && (g = [g]); | |
var f = this._origin; | |
if (f[a] != | |
b) return !1; | |
this._resolved ? h.prototype.trigger("track_multi_metadata", g, function (h) { | |
f.splice.apply(f, [a, 1, b].concat(g)); | |
for (var l = [], m = 0, q = g.length; m < q; m++) l.push(h[g[m]]); | |
this._metadata.splice.apply(this._metadata, [a + 1, 0].concat(l)) | |
}.bind(this)) : f.splice.apply(f, [a, 1, b].concat(g)); | |
return !0 | |
}; | |
m.prototype.remove = function (a, b) { | |
if (!b) return !1; | |
var g = this._origin; | |
if (g[a] != b) return !1; | |
g.splice(a, 1); | |
this._resolved && this._metadata.splice(a, 1); | |
this._shuffled && this._shuffle(); | |
return !0 | |
}; | |
m.prototype.clear = function () { | |
var a = | |
this._origin, | |
b = this._metadata; | |
a.splice(0, a.length); | |
b.splice(0, b.length); | |
return this | |
}; | |
m.prototype.hasRange = function (a, b) { | |
var g = this._origin; | |
if (0 > a || b >= g.length) return !1; | |
for (var g = g.slice(a, b), f = g.length; f--;) | |
if (!(f in g)) return !1; | |
return !0 | |
}; | |
m.prototype.slice = function (a, b) { | |
return this._origin.slice(a, b) | |
}; | |
m.prototype.indexOf = function (a) { | |
return this._list.indexOf(a) | |
}; | |
m.prototype.getIndex = function () { | |
return this._rule.indexing ? this._currentIndex : 0 | |
}; | |
m.prototype.getPlayingIndex = function () { | |
return this._shuffled ? | |
this._shuffledList[this._currentIndex] : this._currentIndex | |
}; | |
m.prototype.startFrom = function (a) { | |
var b = a.track; | |
if (this._shuffled) { | |
a = this._shuffledList; | |
if (-1 == b) { | |
do b = Math.floor(Math.random() * a.length); while (b >= a.length) | |
} | |
for (var g = a.length; g--;) | |
if (a[g] === b) { | |
b = a[0]; | |
a[0] = a[g]; | |
a[g] = b; | |
this._currentIndex = 0; | |
break | |
} | |
} else this._currentIndex = -1 == b ? 0 : b; | |
return this | |
}; | |
m.prototype.current = function () { | |
var a = this._shuffled ? this._list[this._currentIndex] : this._currentIndex; | |
return { | |
item: this._origin[a], | |
metadata: this._metadata[a] | |
} | |
}; | |
m.prototype.shift = function () { | |
var a = this._shuffled ? this._list[this._currentIndex] : this._currentIndex; | |
if (!this._origin[a]) return null; | |
var b = { | |
item: this._origin[a], | |
metadata: this._metadata[a] | |
}; | |
this._origin.splice(a, 1); | |
this._metadata.splice(a, 1); | |
this._shuffled && this._list.splice(this._currentIndex, 1); | |
return b | |
}; | |
m.prototype.hasNext = function () { | |
return this._repeated || this._currentIndex + 1 < this._origin.length | |
}; | |
m.prototype.next = function () { | |
if (!this._rule.next) return !1; | |
var a = ++this._currentIndex, | |
b = this._origin; | |
if (this._repeated) return a >= b.length && (a = this._currentIndex = 0), this._shuffled && (a = this._shuffledList[a]), { | |
item: b[a], | |
metadata: this._metadata[a] | |
}; | |
if (a < b.length) return this._shuffled && (a = this._shuffledList[a]), { | |
item: b[a], | |
metadata: this._metadata[a] | |
}; | |
this._currentIndex--; | |
return null | |
}; | |
m.prototype.hasPrevious = function () { | |
return this._repeated || 0 <= this._currentIndex - 1 | |
}; | |
m.prototype.previous = function () { | |
if (!this._rule.previous) return !1; | |
var a = --this._currentIndex, | |
b = this._origin; | |
if (this._repeated) return 0 > a && (a = | |
this._currentIndex = b.length - 1), this._shuffled && (a = this._shuffledList[a]), { | |
item: b[a], | |
metadata: this._metadata[a] | |
}; | |
if (0 <= a) return this._shuffled && (a = this._shuffledList[a]), { | |
item: b[a], | |
metadata: this._metadata[a] | |
}; | |
this._currentIndex++; | |
return null | |
}; | |
m.prototype._loader = null; | |
m.prototype.setLoader = function (a) { | |
if ("function" != typeof a) return this; | |
this._loader = a; | |
return this | |
}; | |
m.prototype._requestContents = function (a, b) { | |
return this._loader && this._origin.length != this.getFullLength() ? this._loader.call(this, this, a.track, | |
b.bind(this)) : b.call(this) | |
}; | |
m.prototype._resolved = !1; | |
m.prototype._resolvePartial = function (a, b, g, f, h) { | |
for (var l = this._metadata, m = a.length; m--;) l[a[m].idx] = h[a[m]]; | |
this._resolved = !0; | |
if (!b) return this; | |
g(this); | |
this._requestMeta(b, null, null, f) | |
}; | |
m.prototype._requestMeta = function (a, b, g, f) { | |
h.prototype.trigger("track_multi_metadata", a, this._resolvePartial.bind(this, a, b, g, f), f.bind(null)) | |
}; | |
m.prototype._resolve = function (a, b, g) { | |
b = b || function () {}; | |
g = g || function () {}; | |
if (this._resolved) return b(this); | |
a = -1 == a ? 0 : a || | |
0; | |
var f = this._origin, | |
h = this._shuffledList, | |
l = Math.max(a - 7, 0), | |
m, q, n, u = []; | |
if (this._shuffled) { | |
m = 0; | |
for (q = h.length; m < q; m++) n = new String(f[h[m]]), n.idx = h[m], h[m] == a ? (h.unshift(h.splice(m, 1).pop()), u.unshift(n)) : u.push(n); | |
l = this._currentIndex = 0 | |
} else | |
for (m = 0, q = f.length; m < q; m++) n = new String(f[m]), n.idx = m, u.push(n); | |
a = u.splice(l, 15); | |
this._requestMeta(a, u, b, g) | |
}; | |
m.prototype.resolve = function (a, b, g) { | |
this._requestContents(a, this._resolve.bind(this, a.track, b, g)) | |
}; | |
l.exports = { | |
quickShuffle: f, | |
Context: m | |
} | |
})() | |
}, | |
"node_modules/spotify-bridge/src/bridge/contextgroup.js": function (b, | |
l, f, n, p, r) { | |
(function () { | |
function a(a) { | |
this._id = a; | |
this._repeated = this._shuffled = !1; | |
this._currentContext = 0; | |
this._contexts = []; | |
this._shuffledContexts = []; | |
this._noReset = new f; | |
this._ttl = (new Date).getTime(); | |
this.setRule("defaults") | |
} | |
var f = b("node_modules/spotify-weakmap/src/weakmap.js"), | |
m = b("node_modules/spotify-bridge/src/bridge/contextbase.js").quickShuffle, | |
h = b("node_modules/spotify-bridge/src/bridge/contextbase.js").Context; | |
a.prototype.mapToId = h.prototype.mapToId; | |
a.prototype.mapToURI = h.prototype.mapToURI; | |
a.prototype.setExpiry = h.prototype.setExpiry; | |
a.prototype.isExpired = h.prototype.isExpired; | |
a.prototype.setRule = h.prototype.setRule; | |
a.prototype.getContext = function (a) { | |
a = void 0 != a ? a : this._currentContext; | |
return this._shuffled ? this._contexts[this._shuffledContexts[a]] : this._contexts[a] | |
}; | |
a.prototype.getContextIds = function () { | |
var a = [], | |
b = this._contexts, | |
c = b.length; | |
if (!c) return a; | |
for (; c--;) a[c] = b[c].getId(); | |
return a | |
}; | |
a.prototype.getRule = function (a) { | |
return this.getContext().getRule() | |
}; | |
a.prototype.setShuffle = function (a) { | |
if (!this._rule.shuffle) return !1; | |
(this._shuffled = a) ? this._shuffle() : this._unshuffle(); | |
return a | |
}; | |
a.prototype.isShuffled = function () { | |
return this._shuffled | |
}; | |
a.prototype.setRepeat = function (a) { | |
return this._rule.repeat ? this._repeated = a : !1 | |
}; | |
a.prototype.isRepeated = function () { | |
return this._repeated | |
}; | |
a.prototype.startFrom = function (a) { | |
var b = a.context; | |
if (this._shuffled) { | |
var c = this._shuffledContexts; | |
if (-1 == b) { | |
do b = Math.floor(Math.random() * c.length); while (b >= c.length) | |
} | |
for (var k = c.length; k--;) | |
if (c[k] === b) { | |
b = c[0]; | |
c[0] = c[k]; | |
c[k] = b; | |
this._currentContext = | |
0; | |
break | |
} | |
} else this._currentContext = -1 == b ? 0 : b; | |
(c = this.getContext()) && c.startFrom(a); | |
return this | |
}; | |
a.prototype._shufflePartial = function (a) { | |
var b = this._shuffledContexts; | |
if (!b) return this; | |
for (var c = this._contexts, k = c.length - a, f = Array(k); k--;) { | |
var h = c[a + k]; | |
h && h.setShuffle(!0); | |
f[k] = a + k | |
} | |
m(f).unshift(a, 0); | |
b.splice.apply(b, f) | |
}; | |
a.prototype._shuffle = function (a) { | |
if (void 0 != a) return this._shufflePartial(a); | |
var b = this._contexts.slice(0); | |
a = this._shuffledContexts = []; | |
for (var c = 0, k = b.length; c < k; c++) b[c].setShuffle(!0), | |
a.push(c); | |
b = a.splice(this._currentContext, 1).pop(); | |
m(a).unshift(b); | |
this._currentContext = 0; | |
this._noReset.clear(); | |
this._noReset.set(this.getContext(), !0); | |
return this | |
}; | |
a.prototype._unshuffle = function () { | |
this._currentContext = this._shuffledContexts[this._currentContext]; | |
for (var a = this._contexts.slice(0), b = 0, c = a.length; b < c; b++) a[b].setShuffle(!1); | |
this._noReset.clear(); | |
return this | |
}; | |
a.prototype.append = function (a) { | |
this._contexts.push(a.unwrap()); | |
this._resolved && a.resolve({ | |
track: 0, | |
context: 0 | |
}); | |
this._shuffled && | |
this._shuffle(this.length - 1); | |
return this | |
}; | |
a.prototype.concat = function (a) { | |
if (!a || !a.length) return this; | |
for (var b = 0, c = a.length; b < c; b++) this._contexts.push(a[b].unwrap()), this._resolved && a[b].resolve({ | |
track: 0, | |
context: 0 | |
}); | |
this._shuffled && this._shuffle(this._contexts.length - a.length) | |
}; | |
a.prototype.splice = function (a, b) { | |
if ("undefined" == typeof a || !b || !b.length) return this; | |
for (var c = [a, b.length], k = 0, f = b.length; k < f; k++) k in b && b[k] && (c.push(b[k].unwrap()), this._resolved && b[k].resolve({ | |
track: 0, | |
context: 0 | |
})); | |
this._contexts.splice.apply(this._origin, | |
c); | |
this._shuffled && this._shuffle(a) | |
}; | |
a.prototype.insert = function (a, b, c) { | |
if (!c) return !1; | |
var k = this._contexts; | |
b = b.unwrap(); | |
c = c.unwrap(); | |
if (k[a] != b) return !1; | |
k.splice(a, 1, b, c); | |
this._resolved && c.resolve({ | |
track: 0, | |
context: 0 | |
}); | |
return !0 | |
}; | |
a.prototype.remove = function (a, b) { | |
if (!b) return !1; | |
var c = this._contexts; | |
b = b.unwrap(); | |
if (c[a] != b) return !1; | |
c.splice(a, 1); | |
this._shuffled && this._shuffle(); | |
return !0 | |
}; | |
a.prototype.clear = function () { | |
var a = this._contexts; | |
a.splice(0, a.length); | |
return this | |
}; | |
a.prototype.slice = function (a, b) { | |
return this._contexts.slice(a, | |
b) | |
}; | |
a.prototype.get = function (a) { | |
for (var b = this._contexts, c = 0, k = b.length; c < k; c++) { | |
var f = b[c], | |
h = f.getLength(); | |
if (h < a) a -= h; | |
else return f.get(a) | |
} | |
return null | |
}; | |
a.prototype.current = function () { | |
return this.getContext().current() | |
}; | |
a.prototype.getIndex = function (a) { | |
var b = this.getContext().getIndex(); | |
if (!a) return b; | |
a = this._currentContext; | |
for (var c = this._contexts, k = 0; k != a; k++) b += c[k]._origin.length; | |
return b | |
}; | |
a.prototype.getPlayingIndex = function () { | |
return this.getContext().getPlayingIndex() | |
}; | |
a.prototype.getContextIndex = | |
function () { | |
return this._shuffled ? this._shuffledContexts[this._currentContext] : this._currentContext | |
}; | |
a.prototype.getLength = function (a) { | |
if (!a) return this.getContext().getLength(); | |
a = 0; | |
for (var b = this._contexts.length; b--;) a += this._contexts[b]._origin.length; | |
return a | |
}; | |
a.prototype.getFullLength = function () { | |
return this.getContext().getFullLength() | |
}; | |
a.prototype.getContextsLength = function () { | |
return this._contexts.length | |
}; | |
a.prototype.previous = function () { | |
if (!this._rule.previous) return !1; | |
var a = this._contexts, | |
b = | |
a.length, | |
c = null, | |
k; | |
if (this._shuffled) | |
for (var f = this._noReset; b--;) { | |
k = --this._currentContext; | |
0 > k && (k = this._currentContext = a.length - 1); | |
k = a[this._shuffledContexts[k]]; | |
if (!k) return null; | |
this._repeated && 0 == k._currentIndex && (k._currentIndex = k.getLength()); | |
f.get(k) || (k._currentIndex++, f.set(k, !0)); | |
if (c = this.getContext().previous()) break | |
} else | |
for (; b-- && !(c = this.getContext().previous());) { | |
k = --this._currentContext; | |
if (0 > k) { | |
if (!this._repeated) { | |
this._currentContext++; | |
break | |
} | |
k = this._currentContext = a.length - 1 | |
} | |
k = a[k]; | |
if (!k) return null; | |
k._currentIndex = k.getLength() | |
} | |
return c | |
}; | |
a.prototype.next = function () { | |
if (!this._rule.next) return !1; | |
var a = this._contexts, | |
b = a.length, | |
c = null, | |
k; | |
if (this._shuffled) | |
for (var f = this._noReset; b--;) { | |
k = ++this._currentContext; | |
k >= a.length && (k = this._currentContext = 0); | |
next = a[this._shuffledContexts[k]]; | |
if (!next) return null; | |
this._repeated && next._currentIndex == next.getLength() - 1 && (next._currentIndex = -1); | |
f.get(next) || (next._currentIndex--, f.set(next, !0)); | |
if (c = this.getContext().next()) break | |
} else | |
for (; b-- && !(c = this.getContext().next());) { | |
k = ++this._currentContext; | |
if (k >= a.length) { | |
if (!this._repeated) { | |
this._currentContext--; | |
break | |
} | |
k = this._currentContext = 0 | |
} | |
next = a[k]; | |
if (!next) return null; | |
next._currentIndex = -1 | |
} | |
return c | |
}; | |
a.prototype.getId = function () { | |
return this.getContext().getId() | |
}; | |
a.prototype.resolve = function (a, b, c) { | |
this.startFrom(a); | |
var k = this._contexts; | |
if (this._resolved) return b(); | |
this.getContext().resolve(a, function () { | |
this._resolved = !0; | |
b(); | |
for (var c = k.length; c--;) k[c].resolve(a) | |
}.bind(this), c) | |
}; | |
l.exports = | |
a | |
})() | |
}, | |
"node_modules/spotify-bridge/src/bridge/contextmanager.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(a) { | |
this._context = a; | |
this._owner = "" | |
} | |
function f() { | |
this.cache = new g(1E3) | |
} | |
function m(b, c, d) { | |
b = new b(c.toString()); | |
this.cache.put(c, b); | |
return (new a(b)).setExpiry(d) | |
} | |
function h(b, c, g, k) { | |
var f = this.cache.get(c.toString()); | |
if (f) | |
if (f.isExpired()) this.cache.remove(f); | |
else return (new a(f)).setExpiry(k); | |
return g ? b == d ? this.create(c, k) : this.createGroup(c, k) : null | |
} | |
var g = Spotify.SimpleCache, | |
d = b("node_modules/spotify-bridge/src/bridge/contextbase.js").Context, | |
c = b("node_modules/spotify-bridge/src/bridge/contextgroup.js"); | |
a.prototype.getOwner = function (a) { | |
return this._owner | |
}; | |
a.prototype.unwrap = function () { | |
return this._context | |
}; | |
a.prototype.setOwner = function (a) { | |
a && (this._owner = a); | |
return this | |
}; | |
a.prototype.isContext = function () { | |
return this._context instanceof d | |
}; | |
a.prototype.isContextGroup = function () { | |
return this._context instanceof c | |
}; | |
for (var k in d.prototype)(function (b) { | |
a.prototype[b] = function () { | |
var a = this._context, | |
c = a[b]; | |
if (!c) throw Error('Context object has no method "' + | |
b + '"'); | |
c = c.apply(a, arguments); | |
return c == a ? this : c | |
} | |
})(k); | |
f.prototype.create = function (a, b) { | |
return m.call(this, d, a, b) | |
}; | |
f.prototype.createGroup = function (a, b) { | |
return m.call(this, c, a, b) | |
}; | |
f.prototype.get = function (a, b, c) { | |
return h.call(this, d, a, b, c) | |
}; | |
f.prototype.getGroup = function (a, b, d) { | |
return h.call(this, c, a, b, d) | |
}; | |
f.prototype.remove = function (a) { | |
return this.cache.remove(a.toString()) | |
}; | |
l.exports = f | |
})() | |
}, | |
"node_modules/spotify-bridge/src/bridge/messages.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(b) { | |
if (!(this instanceof a)) return new a(b); | |
this._applicationManager = b; | |
this._checkTimeoutID = null; | |
this._interceptors = {}; | |
this._queuedWindows = new c; | |
this._replies = new f; | |
this._timeout = 3E4; | |
this._handleMessage = this._handleMessage.bind(this); | |
this._checkTimeout = this._checkTimeout.bind(this); | |
this._unqueueMessages = this._unqueueMessages.bind(this); | |
this.attach() | |
} | |
var f = Spotify.LinkedList, | |
m = b("node_modules/spotify-bridge/src/bridge/errors.js"), | |
h = b("node_modules/spotify-bridge/src/bridge/errortranslator.js"), | |
g = b("node_modules/spotify-bridge/src/bridge/reply.js"), | |
d = b("node_modules/spotify-bridge/src/bridge/responder.js"), | |
c = b("node_modules/spotify-weakmap/src/weakmap.js"), | |
k = b("node_modules/spotify-bridge/node_modules/spotify-deferred/src/deferred.js"); | |
a.prototype._checkTimeout = function () { | |
var a = this._timeout, | |
b = this._replies; | |
if (b.length) { | |
var c = (new Date).getTime(), | |
d = b.first; | |
do { | |
var g = d.value, | |
k = d.next; | |
if (g.timestamp) { | |
if (c - g.timestamp < a) break; | |
g.timeout(); | |
b.remove(d) | |
} | |
} while (d = k) | |
} | |
this._checkTimeoutID = setTimeout(this._checkTimeout, a) | |
}; | |
a.prototype._handleMessage = function (a) { | |
var b = | |
a.data; | |
if ("string" == typeof b) try { | |
b = JSON.parse(b) | |
} catch (c) { | |
return this | |
} | |
if (b.type && "bridge_request" == b.type) { | |
var d = b.name; | |
if (d) { | |
b.origin = a.origin; | |
var k = b.source = a.source, | |
f = this._applicationManager.getFromWindow(k); | |
f ? (a = new g(b.id, b.origin, b.source), this.trigger(d, f, b, a)) : ((b = this._queuedWindows.get(k)) || this._queuedWindows.set(k, b = []), b.push(a)) | |
} | |
} | |
}; | |
a.prototype.trigger = function (a, b, c, g) { | |
if (d.hasBlocked(a)) return d.handleBlocked(c, g, a); | |
var k = this._interceptors[a]; | |
if (!k || k(b, c, g)) { | |
k = d.getHandler(a); | |
if (!k) return g.fail(new m.NotImplemented("Message not implemented.")); | |
g.internal || (this._replies.append(new f.Node(g)), /event_wait/.test(a) && g.persist()); | |
k.passApp ? (a = k.fn.call(k.bound || {}, b, c, g)) && (a.then ? a.catchError(h).then(g.send.bind(g), g.fail.bind(g)) : g.send(a)) : k.fn.call(k.bound || {}, c, g) | |
} | |
}; | |
a.prototype._unqueueMessages = function (a) { | |
a = a.window; | |
var b = this._queuedWindows.get(a); | |
if (b && b.length) { | |
for (var b = b.splice(0), c = 0, d = b.length; c < d; c++) k(this._handleMessage.bind(this, b[c])); | |
this._queuedWindows.remove(a) | |
} | |
}; | |
a.prototype.addInterceptor = function (a, b) { | |
var c = this._interceptors; | |
if (c[a]) throw Error('Interceptor for message "' + a + '" already exists.'); | |
c[a] = b | |
}; | |
a.prototype.removeInterceptor = function (a, b) { | |
var c = this._interceptors, | |
d = c[a]; | |
return d && d == b ? (c[a] = null, !0) : !1 | |
}; | |
a.prototype.attach = function () { | |
this._checkTimeoutID = setTimeout(this._checkTimeout, this._timeout); | |
window.attachEvent && !window.addEventListener ? window.attachEvent("onmessage", this._handleMessage) : window.addEventListener("message", this._handleMessage, !1); | |
this._applicationManager.addEvent("windowAssociated", this._unqueueMessages); | |
return this | |
}; | |
a.prototype.detach = function () { | |
clearTimeout(this._checkTimeoutID); | |
window.attachEvent && !window.addEventListener ? window.detachEvent("onmessage", this._handleMessage) : window.removeEventListener("message", this._handleMessage, !1); | |
this._applicationManager.removeEvent("windowAssociated", this._unqueueMessages); | |
return this | |
}; | |
l.exports = a | |
})() | |
}, | |
"node_modules/spotify-bridge/node_modules/spotify-crypto/src/base62.js": function (b, l, f, n, p, r) { | |
function a(a, b, g) { | |
for (var f = [0], h = [1], l = 0; l < a.length; ++l) { | |
for (var m = | |
f, q = h, n = a[l], u = g, p = 0, y = 0; y < q.length; ++y) p = ~~m[y] + q[y] * n + p, m[y] = p % u, p = ~~ (p / u); | |
for (; p;) p = ~~m[y] + p, m[y] = p % u, p = ~~ (p / u), ++y; | |
m = h; | |
q = b; | |
n = g; | |
for (u = y = 0; u < m.length; ++u) y = m[u] * q + y, m[u] = y % n, y = ~~ (y / n); | |
for (; y;) m.push(y % n), y = ~~ (y / n) | |
} | |
return f | |
} | |
function q(a, b) { | |
for (var g = 0, f = []; g < a.length; ++g) f.push(b[a[g]]); | |
return f.reverse() | |
} | |
function m(a, b) { | |
for (; a.length < b;) a.push(0); | |
return a | |
} | |
var h = {}, g = {}; | |
for (b = 0; 62 > b; ++b) g["0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" [b]] = b; | |
for (b = 0; 16 > b; ++b) h["0123456789abcdef" [b]] = | |
b; | |
for (b = 0; 16 > b; ++b) h["0123456789ABCDEF" [b]] = b; | |
l.exports = { | |
fromBytes: function (b, c) { | |
var g = a(b.slice(0).reverse(), 256, 62); | |
return q(m(g, c), "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ").join("") | |
}, | |
toBytes: function (b, c) { | |
var k = a(q(b, g), 62, 256); | |
return m(k, c).reverse() | |
}, | |
toHex: function (b, c) { | |
var k = a(q(b, g), 62, 16); | |
return q(m(k, c), "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ").join("") | |
}, | |
fromHex: function (b, c) { | |
var g = a(q(b, h), 16, 62); | |
return q(m(g, c), "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ").join("") | |
} | |
} | |
}, | |
"node_modules/spotify-bridge/node_modules/spotify-crypto/src/base64.js": function (b, l, f, n, p, r) { | |
b = function () { | |
for (var a = [], b = 0; 256 > b; ++b) a[b] = 255; | |
for (b = 0; b < this.BASE64_DIGITS.length; ++b) a[this.BASE64_DIGITS.charCodeAt(b)] = b; | |
this._inverseData = String.fromCharCode.apply(String, a) | |
}; | |
b.prototype.BASE64_DIGITS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; | |
b.prototype.STRING_CHUNK_SIZE = 4096; | |
b.prototype._stringFromCharCode = function (a) { | |
if (a.length < this.STRING_CHUNK_SIZE) return String.fromCharCode.apply(String, | |
a); | |
var b = 0, | |
f = []; | |
do f.push(String.fromCharCode.apply(String, a.slice(b, b + this.STRING_CHUNK_SIZE))), b += this.STRING_CHUNK_SIZE; while (b < a.length); | |
return f.join("") | |
}; | |
b.prototype.encode = function (a) { | |
if ("undefined" !== typeof window && "undefined" !== typeof window.btoa) return window.btoa(a); | |
var b, f, h, g, d, c; | |
h = a.length; | |
f = 0; | |
for (b = ""; f < h;) { | |
g = a.charCodeAt(f++) & 255; | |
if (f == h) { | |
b += this.BASE64_DIGITS.charAt(g >> 2); | |
b += this.BASE64_DIGITS.charAt((g & 3) << 4); | |
b += "=="; | |
break | |
} | |
d = a.charCodeAt(f++); | |
if (f == h) { | |
b += this.BASE64_DIGITS.charAt(g >> | |
2); | |
b += this.BASE64_DIGITS.charAt((g & 3) << 4 | (d & 240) >> 4); | |
b += this.BASE64_DIGITS.charAt((d & 15) << 2); | |
b += "="; | |
break | |
} | |
c = a.charCodeAt(f++); | |
b += this.BASE64_DIGITS.charAt(g >> 2); | |
b += this.BASE64_DIGITS.charAt((g & 3) << 4 | (d & 240) >> 4); | |
b += this.BASE64_DIGITS.charAt((d & 15) << 2 | (c & 192) >> 6); | |
b += this.BASE64_DIGITS.charAt(c & 63) | |
} | |
return b | |
}; | |
b.prototype.decode = function (a) { | |
if ("undefined" !== typeof window && "undefined" !== typeof window.atob) return window.atob(a); | |
for (var b = [], f = a.length, h, g, d = 0;;) { | |
do h = this._inverseData.charCodeAt(a.charCodeAt(d++) & | |
255); while (255 === h && d < f); | |
do g = this._inverseData.charCodeAt(a.charCodeAt(d++) & 255); while (255 === g && d < f); | |
b.push((h << 2 | g >> 4) & 255); | |
do h = this._inverseData.charCodeAt(a.charCodeAt(d++) & 255); while (255 === h && d < f); | |
if (255 === h) break; | |
b.push((g << 4 | h >> 2) & 255); | |
do g = this._inverseData.charCodeAt(a.charCodeAt(d++) & 255); while (255 === g && d < f); | |
if (255 === g) break; | |
b.push((h << 6 | g) & 255) | |
} | |
return this._stringFromCharCode(b) | |
}; | |
b = new b; | |
l.exports = { | |
fromString: b.encode.bind(b), | |
toString: b.decode.bind(b) | |
} | |
}, | |
"node_modules/spotify-bridge/node_modules/spotify-crypto/src/hex.js": function (b, | |
l, f, n, p, r) { | |
l.exports = { | |
toString: function (a) { | |
for (var b = [], f = 0, h = a.length; f < h - 1; f += 2) b.push(String.fromCharCode(parseInt(a.substr(f, 2), 16))); | |
return b.join("") | |
}, | |
fromString: function (a) { | |
for (var b = "", f = 0, h = a.length; f < h; ++f) b += (a.charCodeAt(f) + 256).toString(16).slice(-2); | |
return b | |
} | |
} | |
}, | |
"node_modules/spotify-bridge/node_modules/spotify-crypto/src/md5.js": function (b, l, f, n, p, r) { | |
function a(a, b, d, f, h, l) { | |
a = g(g(b, a), g(f, l)); | |
return g(a << h | a >>> 32 - h, d) | |
} | |
function q(b, d, g, f, h, l, m) { | |
return a(d & g | ~d & f, b, d, h, l, m) | |
} | |
function m(b, | |
d, g, f, h, l, m) { | |
return a(d & f | g & ~f, b, d, h, l, m) | |
} | |
function h(b, d, g, f, h, l, m) { | |
return a(g ^ (d | ~f), b, d, h, l, m) | |
} | |
function g(a, b) { | |
var d = (a & 65535) + (b & 65535); | |
return (a >> 16) + (b >> 16) + (d >> 16) << 16 | d & 65535 | |
} | |
var d = 0; | |
l.exports = { | |
encode: function (b) { | |
for (var k = "", f = -1, l, n; ++f < b.length;) l = b.charCodeAt(f), n = f + 1 < b.length ? b.charCodeAt(f + 1) : 0, 55296 <= l && 56319 >= l && 56320 <= n && 57343 >= n && (l = 65536 + ((l & 1023) << 10) + (n & 1023), f++), 127 >= l ? k += String.fromCharCode(l) : 2047 >= l ? k += String.fromCharCode(192 | l >>> 6 & 31, 128 | l & 63) : 65535 >= l ? k += String.fromCharCode(224 | | |
l >>> 12 & 15, 128 | l >>> 6 & 63, 128 | l & 63) : 2097151 >= l && (k += String.fromCharCode(240 | l >>> 18 & 7, 128 | l >>> 12 & 63, 128 | l >>> 6 & 63, 128 | l & 63)); | |
b = Array(k.length >> 2); | |
f = 0; | |
for (l = b.length; f < l; f++) b[f] = 0; | |
f = 0; | |
for (l = 8 * k.length; f < l; f += 8) b[f >> 5] |= (k.charCodeAt(f / 8) & 255) << f % 32; | |
k = 8 * k.length; | |
b[k >> 5] |= 128 << k % 32; | |
b[(k + 64 >>> 9 << 4) + 14] = k; | |
k = 1732584193; | |
f = -271733879; | |
l = -1732584194; | |
n = 271733878; | |
for (var p = 0; p < b.length; p += 16) { | |
var r = k, | |
w = f, | |
u = l, | |
A = n, | |
k = q(k, f, l, n, b[p + 0], 7, -680876936); | |
n = q(n, k, f, l, b[p + 1], 12, -389564586); | |
l = q(l, n, k, f, b[p + 2], 17, 606105819); | |
f = | |
q(f, l, n, k, b[p + 3], 22, -1044525330); | |
k = q(k, f, l, n, b[p + 4], 7, -176418897); | |
n = q(n, k, f, l, b[p + 5], 12, 1200080426); | |
l = q(l, n, k, f, b[p + 6], 17, -1473231341); | |
f = q(f, l, n, k, b[p + 7], 22, -45705983); | |
k = q(k, f, l, n, b[p + 8], 7, 1770035416); | |
n = q(n, k, f, l, b[p + 9], 12, -1958414417); | |
l = q(l, n, k, f, b[p + 10], 17, -42063); | |
f = q(f, l, n, k, b[p + 11], 22, -1990404162); | |
k = q(k, f, l, n, b[p + 12], 7, 1804603682); | |
n = q(n, k, f, l, b[p + 13], 12, -40341101); | |
l = q(l, n, k, f, b[p + 14], 17, -1502002290); | |
f = q(f, l, n, k, b[p + 15], 22, 1236535329); | |
k = m(k, f, l, n, b[p + 1], 5, -165796510); | |
n = m(n, k, f, l, b[p + 6], 9, -1069501632); | |
l = m(l, n, k, f, b[p + 11], 14, 643717713); | |
f = m(f, l, n, k, b[p + 0], 20, -373897302); | |
k = m(k, f, l, n, b[p + 5], 5, -701558691); | |
n = m(n, k, f, l, b[p + 10], 9, 38016083); | |
l = m(l, n, k, f, b[p + 15], 14, -660478335); | |
f = m(f, l, n, k, b[p + 4], 20, -405537848); | |
k = m(k, f, l, n, b[p + 9], 5, 568446438); | |
n = m(n, k, f, l, b[p + 14], 9, -1019803690); | |
l = m(l, n, k, f, b[p + 3], 14, -187363961); | |
f = m(f, l, n, k, b[p + 8], 20, 1163531501); | |
k = m(k, f, l, n, b[p + 13], 5, -1444681467); | |
n = m(n, k, f, l, b[p + 2], 9, -51403784); | |
l = m(l, n, k, f, b[p + 7], 14, 1735328473); | |
f = m(f, l, n, k, b[p + 12], 20, -1926607734); | |
k = a(f ^ l ^ n, k, f, b[p + 5], 4, -378558); | |
n = a(k ^ f ^ l, n, k, b[p + 8], 11, -2022574463); | |
l = a(n ^ k ^ f, l, n, b[p + 11], 16, 1839030562); | |
f = a(l ^ n ^ k, f, l, b[p + 14], 23, -35309556); | |
k = a(f ^ l ^ n, k, f, b[p + 1], 4, -1530992060); | |
n = a(k ^ f ^ l, n, k, b[p + 4], 11, 1272893353); | |
l = a(n ^ k ^ f, l, n, b[p + 7], 16, -155497632); | |
f = a(l ^ n ^ k, f, l, b[p + 10], 23, -1094730640); | |
k = a(f ^ l ^ n, k, f, b[p + 13], 4, 681279174); | |
n = a(k ^ f ^ l, n, k, b[p + 0], 11, -358537222); | |
l = a(n ^ k ^ f, l, n, b[p + 3], 16, -722521979); | |
f = a(l ^ n ^ k, f, l, b[p + 6], 23, 76029189); | |
k = a(f ^ l ^ n, k, f, b[p + 9], 4, -640364487); | |
n = a(k ^ f ^ l, n, k, b[p + 12], 11, -421815835); | |
l = a(n ^ k ^ f, l, n, b[p + 15], 16, 530742520); | |
f = a(l ^ n ^ k, f, l, b[p + 2], 23, -995338651); | |
k = h(k, f, l, n, b[p + 0], 6, -198630844); | |
n = h(n, k, f, l, b[p + 7], 10, 1126891415); | |
l = h(l, n, k, f, b[p + 14], 15, -1416354905); | |
f = h(f, l, n, k, b[p + 5], 21, -57434055); | |
k = h(k, f, l, n, b[p + 12], 6, 1700485571); | |
n = h(n, k, f, l, b[p + 3], 10, -1894986606); | |
l = h(l, n, k, f, b[p + 10], 15, -1051523); | |
f = h(f, l, n, k, b[p + 1], 21, -2054922799); | |
k = h(k, f, l, n, b[p + 8], 6, 1873313359); | |
n = h(n, k, f, l, b[p + 15], 10, -30611744); | |
l = h(l, n, k, f, b[p + 6], 15, -1560198380); | |
f = h(f, l, n, k, b[p + 13], 21, 1309151649); | |
k = h(k, f, l, n, b[p + 4], 6, -145523070); | |
n = h(n, k, f, l, b[p + 11], 10, -1120210379); | |
l = h(l, n, k, f, b[p + 2], 15, 718787259); | |
f = h(f, l, n, k, b[p + 9], 21, -343485551); | |
k = g(k, r); | |
f = g(f, w); | |
l = g(l, u); | |
n = g(n, A) | |
} | |
b = [k, f, l, n]; | |
k = ""; | |
for (f = 0; f < 32 * b.length; f += 8) k += String.fromCharCode(b[f >> 5] >>> f % 32 & 255); | |
b = k; | |
try { | |
d | |
} catch (y) { | |
d = 0 | |
} | |
k = d ? "0123456789ABCDEF" : "0123456789abcdef"; | |
f = ""; | |
for (n = 0; n < b.length; n++) l = b.charCodeAt(n), f += k.charAt(l >>> 4 & 15) + k.charAt(l & 15); | |
return f | |
} | |
} | |
}, | |
"node_modules/spotify-bridge/node_modules/spotify-crypto/src/lut.js": function (b, l, f, n, p, r) { | |
var a = b("node_modules/spotify-bridge/node_modules/spotify-crypto/src/md5.js"), | |
q = {}; | |
l.exports = { | |
calc: function (b) { | |
var f = 0, | |
g = q[b]; | |
if (g) return g; | |
g = Array(1E4); | |
for (f = 0; f < g.length; f++) g[f] = f; | |
for (var f = a.encode(b), f = parseInt(f.substring(0, 8), 16), d = g, c = d.length - 1; 1 <= c; c--) { | |
var f = 16807 * f % 2147483647, | |
k = f % (c + 1), | |
l = d[c]; | |
d[c] = d[k]; | |
d[k] = l | |
} | |
return q[b] = g | |
} | |
} | |
}, | |
"node_modules/spotify-bridge/node_modules/spotify-crypto/index.js": function (b, l, f, n, p, r) { | |
l.exports = { | |
Base62: b("node_modules/spotify-bridge/node_modules/spotify-crypto/src/base62.js"), | |
Base64: b("node_modules/spotify-bridge/node_modules/spotify-crypto/src/base64.js"), | |
Hex: b("node_modules/spotify-bridge/node_modules/spotify-crypto/src/hex.js"), | |
md5: b("node_modules/spotify-bridge/node_modules/spotify-crypto/src/md5.js"), | |
Lut: b("node_modules/spotify-bridge/node_modules/spotify-crypto/src/lut.js") | |
} | |
}, | |
"node_modules/spotify-bridge/src/shell/reactors/abtests.js": function (b, l, f, n, p, r) { | |
(function () { | |
var a = b("node_modules/spotify-bridge/src/shell/reactor.js"), | |
f = b("node_modules/spotify-bridge/node_modules/spotify-crypto/index.js"), | |
m = b("node_modules/spotify-bridge/src/shell/dispatcher.js").ResponseStatus, | |
a = new a.Reactor({ | |
_construct: function () { | |
this._setReady() | |
}, | |
"GET /user/groupid": function (a, b) { | |
var d = a.body, | |
c = this._createPromise(), | |
k = this._createResponse(); | |
if (d.username && d.salt && "string" == typeof d.salt) { | |
var l; | |
l = d.username; | |
if ((d = d.salt) && "NTX_" == d.substring(0, 4)) d = f.Lut.calc(d), l = parseInt(f.md5.encode("spotify:test:" + l).substring(0, 8), 16), l = Math.floor(1E4 * l * Math.pow(2, -32)), l = Math.floor(d[l] / 10); | |
else { | |
var n = "spotify:test:"; | |
d && (n += d + ":"); | |
l = parseInt(f.md5.encode(n + l).substring(0, 8), 16); | |
l = Math.floor(1E3 * | |
l * Math.pow(2, -32)) | |
} | |
k.setBodyField("id", l); | |
c.fulfill(k) | |
} else k.setStatus(m.BAD_REQUEST), c.fail(k); | |
return c | |
} | |
}); | |
l.exports = a | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/entities/image.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(b, f) { | |
if (!(this instanceof a)) return new a(uri, data); | |
this.image = b; | |
this.images = f | |
} | |
var f = b("node_modules/spotify-bridge/node_modules/spotify-crypto/index.js").Hex; | |
a.create = function (b, h) { | |
h = h || ""; | |
for (var g = null, d = [], c = 0, k = b.length; c < k; c++) { | |
var l = b[c]; | |
if (l.file_id) { | |
var n = h + f.fromString(l.file_id); | |
d.push([Math.min(l.width, l.height), n]); | |
g || "default" != l.size.toLowerCase() || (g = n) | |
} | |
}!g && d.length && (g = d[0][1]); | |
d.sort(function (a, b) { | |
return a[0] - b[0] | |
}); | |
return new a(g, d) | |
}; | |
a.createSearch = function (b, f) { | |
f = f || ""; | |
for (var g = null, d = [], c = { | |
small: 120, | |
large: 640, | |
"default": 300 | |
}, k = 0, l = b.length; k < l; k++) { | |
var n = b[k]; | |
if (n.file_id) { | |
var q = f + n.file_id; | |
d.push([c[n.size.toLowerCase()], q]); | |
g || "default" != n.size.toLowerCase() || (g = q) | |
} | |
}!g && d.length && (g = d[0][1]); | |
d.sort(function (a, b) { | |
return a[0] - b[0] | |
}); | |
return new a(g, d) | |
}; | |
a.createProfile = | |
function (b, f) { | |
f = f || ""; | |
var g = null, | |
d = []; | |
b.image && d.push([50, b.image]); | |
b.imageLarge && d.push([180, b.imageLarge]); | |
for (var c = 0, k = d.length; c < k; c++) { | |
var l = d[c][1].match(/^spotify:image:(.+)/); | |
l && (d[c][1] = f + l[1]) | |
} | |
d.length && (g = d[0][1]); | |
return new a(g, d) | |
}; | |
l.exports = a | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/entities/playlist.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(b, c) { | |
if (!(this instanceof a)) return new a(b, c); | |
p.call(this, b); | |
c && this._fill(c) | |
} | |
function f(a, b) { | |
if (!(this instanceof f)) return new f(a, | |
b); | |
this.uri = a.toString(); | |
b && this._fill(b) | |
} | |
var m = b("node_modules/spotify-inheritance/inherit.js"), | |
h = Spotify.Link, | |
g = b("node_modules/spotify-promise/src/promise.js"), | |
d = b("node_modules/spotify-bridge/src/shell/lists.js"), | |
c = d.Comparators, | |
k = d.Predicates, | |
n = b("node_modules/spotify-bridge/src/shell/entities/image.js"), | |
p = b("node_modules/spotify-bridge/src/shell/entities/base.js"); | |
m(a, p); | |
a.prototype._fill = function (a) { | |
this.allows = { | |
"delete": !1, | |
editDescription: !1, | |
insertTracks: !1, | |
moveTracks: !1, | |
removeTracks: !1, | |
rename: !1 | |
}; | |
this.name = a.name; | |
this.ownerName = a.owner; | |
this.owner = { | |
uri: a.owner ? h.profileLink(a.owner).toString() : null | |
}; | |
this.collaborative = !! a.collaborative; | |
this.description = a.description || ""; | |
this.published = this.subscribed = !1; | |
if (a.picture) { | |
var b = a.picture; | |
try { | |
b = decodeURIComponent(b) | |
} catch (c) {} | |
a = n.create([{ | |
size: "default", | |
width: 300, | |
height: 300, | |
file_id: b | |
}], a.resourceUrl); | |
this.image = a.image; | |
this.images = a.images | |
} | |
}; | |
a.create = function (b, c) { | |
var d = new g; | |
try { | |
d.fulfill(new a(b, c)) | |
} catch (f) { | |
d.fail(f) | |
} | |
return d | |
}; | |
a.prototype.createComparator = | |
function (a, b) { | |
return null | |
}; | |
a.prototype.createPredicate = function (a, b, c) { | |
return null | |
}; | |
f.prototype._fill = function (a) { | |
this.creator = (this.creatorName = a.added_by) ? h.profileLink(a.added_by) : null; | |
this.addTime = a.timestamp; | |
this.track = a.track | |
}; | |
f.prototype.setTrack = function (a) { | |
this.track = a | |
}; | |
f.create = function (a, b) { | |
var c = new g; | |
try { | |
c.fulfill(new f(a, b)) | |
} catch (d) { | |
c.fail(d) | |
} | |
return c | |
}; | |
f.createComparator = function (a, b) { | |
switch (a) { | |
case "uri": | |
case "creator": | |
return "desc" == b ? c.forStringPropertyReversed(a) : c.forStringProperty(a); | |
case "addTime": | |
return "desc" == b ? c.forNumberPropertyReversed(a) : c.forNumberProperty(a); | |
default: | |
var d = Entities.Track.createComparator(a, b); | |
if (d) return function (a, b) { | |
return d(a && a.track, b && b.track) | |
} | |
} | |
return null | |
}; | |
f.createPredicate = function (a, b, c) { | |
switch (a) { | |
case "uri": | |
case "creator": | |
case "addTime": | |
return k.forPropertyOperator(a, b, c); | |
default: | |
var d = Entities.Track.createPredicate(a, b, c); | |
if (d) return function (a) { | |
return d(a && a.track) | |
} | |
} | |
return null | |
}; | |
l.exports = { | |
PlaylistData: void 0, | |
PlaylistRowData: void 0, | |
Playlist: a, | |
PlaylistRow: f | |
} | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/entities/search.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(b, d) { | |
if (!(this instanceof a)) return new a(b, d); | |
this.uri = b.toString(); | |
d && this._fill(d) | |
} | |
function f(a, b) { | |
if (!(this instanceof f)) return new f(a, b); | |
this.uri = a.toString(); | |
b && this._fill(b) | |
} | |
function m(a, b) { | |
if (!(this instanceof m)) return new m(a, b); | |
this.uri = a.toString(); | |
b && this._fill(b) | |
} | |
function h(a, b) { | |
if (!(this instanceof h)) return new h(a, b); | |
this.uri = a.toString(); | |
b && this._fill(b) | |
} | |
var g = Spotify.Link; | |
b("node_modules/spotify-promise/src/promise.js"); | |
var d = b("node_modules/spotify-bridge/src/shell/entities/image.js"); | |
a.prototype._fill = function (a) { | |
var b, f; | |
this.artistName = ""; | |
this.artists = []; | |
this.availability = a.availability; | |
this.image = void 0; | |
this.images = []; | |
this.name = a.name; | |
this.playable = a.playable; | |
this.popularity = a.popularity; | |
this.type = (a.type || "").toLowerCase(); | |
var h = a.artists, | |
l = this.artists, | |
m = []; | |
this.artistName = ""; | |
if (h && h.length) { | |
b = 0; | |
for (f = h.length; b < f; b++) { | |
var n = h[b]; | |
l.push({ | |
uri: g.artistLink(n.id).toString(), | |
name: n.name | |
}); | |
m.push(n.name) | |
} | |
this.artistName = m.join(";") | |
} | |
if (b = a.cover) a = d.createSearch(b, a.resourceUrl), this.image = a.image, this.images = a.images | |
}; | |
f.prototype._fill = function (a) { | |
this.availability = a.availability; | |
this.image = null; | |
this.images = []; | |
this.name = a.name; | |
this.playable = a.playable; | |
this.popularity = a.popularity; | |
var b = a.portrait; | |
b && (a = d.createSearch(b, a.resourceUrl), this.image = a.image, this.images = a.images) | |
}; | |
m.prototype._fill = function (a) { | |
this.image = void 0; | |
this.images = []; | |
this.name = a.name; | |
this.owner_name = | |
a.owner; | |
this.owner = { | |
uri: g.profileLink(a.owner).toString() | |
}; | |
var b = a.image; | |
if (b) { | |
var d = this.images, | |
b = b.split(":").splice(2, b.length - 1).join(""), | |
b = this.image = a.resourceUrls.normal + b; | |
d.push([300, b]); | |
if (b = a["image-large"]) b = b.split(":").splice(2, b.length - 1).join(""), d.push([640, a.resourceUrl.large + b]); | |
if (b = a["image-small"]) b = b.split(":").splice(2, b.length - 1).join(""), d.push([120, a.resourceUrl.small + b]) | |
} | |
}; | |
h.prototype._fill = function (a) { | |
this._pid = this.playableId = a.playableId; | |
this.availability = a.availability; | |
this.duration = a.length; | |
this.explicit = !! a.explicit; | |
this.local = !1; | |
this.name = a.name; | |
this.playable = a.playable; | |
this.playableURI = g.trackLink(this._pid); | |
this.popularity = a.popularity; | |
var b = a.album, | |
f = this.album = {}; | |
if (b) { | |
this.albumUri = f.uri = g.albumLink(b.id).toString(); | |
this.albumName = f.name = b.name; | |
var h = f.artists = [], | |
l = b.artists; | |
if (l && l.length) | |
for (n = 0, q = l.length; n < q; n++) { | |
var m = l[n]; | |
h.push({ | |
uri: g.artistLink(m.id).toString(), | |
name: m.name | |
}) | |
} | |
if (n = b.cover) n = d.createSearch(n, a.resourceUrl), this.image = f.image = n.image, | |
this.images = f.images = n.images | |
} | |
a = a.artist || a.artists; | |
f = this.artists = []; | |
b = []; | |
this.artistName = ""; | |
if (a && a.length) { | |
for (var n = 0, q = a.length; n < q; n++) h = a[n], f.push({ | |
uri: g.artistLink(h.id).toString(), | |
name: h.name | |
}), b.push(h.name); | |
this.artistName = b.join(";") | |
} | |
}; | |
l.exports = { | |
SearchAlbum: a, | |
SearchArtist: f, | |
SearchPlaylist: m, | |
SearchTrack: h | |
} | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/entities/track.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(b, c) { | |
if (!(this instanceof a)) return new a(b, c); | |
this.uri = b.toString(); | |
c && | |
this._fill(c) | |
} | |
function f(a) { | |
if (!(this instanceof f)) return new f(a); | |
this.uri = a.toString(); | |
this._parseData(a) | |
} | |
function m(a, b) { | |
if (!(this instanceof m)) return new m(a); | |
this.uri = a.toString(); | |
b && this._parseData(b) | |
} | |
var h = b("node_modules/spotify-inheritance/inherit.js"), | |
g = Spotify.Link, | |
d = b("node_modules/spotify-promise/src/promise.js"), | |
c = b("node_modules/spotify-bridge/src/shell/lists.js"), | |
k = c.Comparators, | |
n = c.Predicates, | |
p = b("node_modules/spotify-bridge/src/shell/entities/image.js"), | |
r = b("node_modules/spotify-bridge/node_modules/spotify-crypto/index.js").Hex; | |
a.prototype._fill = function (a) { | |
this._pid = this.playableId = a.playableId; | |
this.playableURI = g.trackLink(this._pid); | |
this.name = a.name; | |
this.disc = void 0 == a.disc_number ? a.disc_number : parseInt(a.disc_number, 10); | |
this.duration = a.duration; | |
this.local = !1; | |
this.number = void 0 == a.number ? a.number : parseInt(a.number, 10); | |
this.popularity = a.popularity; | |
this.availability = a.availability; | |
this.playable = a.playable; | |
this.image = a.image; | |
this.images = a.images; | |
this.starred = a.starred; | |
this.explicit = !! a.explicit; | |
this.advertisement = !! a.ad; | |
this.seen = !0; | |
var b = a.album, | |
c = this.album = {}; | |
b && (this.albumUri = c.uri = g.albumLink(b.id).toString(), this.albumName = c.name = b.name, b = b.cover_group && b.cover_group.image) && (b = p.create(b, a.resourceUrl), this.image = b.image, this.images = b.images); | |
var b = a.artist || a.artists, | |
c = this.artists = [], | |
d = []; | |
this.artistName = ""; | |
if (b && b.length) { | |
for (var f = 0, k = b.length; f < k; f++) { | |
var h = b[f]; | |
c.push({ | |
uri: g.artistLink(h.id).toString(), | |
name: h.name | |
}); | |
d.push(h.name) | |
} | |
this.artistName = d.join(";") | |
} | |
this.previewURI = null; | |
if ((a = a.preview) && a.length) | |
for (b = | |
0, c = a.length; b < c; b++)(d = a[b]) && "MP3_96" == d.format && (this.previewURI = g.audioFileLink("mp3", r.fromString(d.file_id))) | |
}; | |
a.create = function (b, c) { | |
var f = new d; | |
try { | |
f.fulfill(new a(b, c)) | |
} catch (g) { | |
f.fail(g) | |
} | |
return f | |
}; | |
a.createComparator = function (a, b) { | |
switch (a) { | |
case "uri": | |
case "name": | |
return "desc" != b ? k.forStringProperty(a) : k.forStringPropertyReversed(a); | |
case "disc": | |
case "duration": | |
case "number": | |
case "popularity": | |
case "seen": | |
case "starred": | |
return "desc" != b ? k.forNumberProperty(a) : k.forNumberPropertyReversed(a); | |
case "artists.name": | |
return "desc" != | |
b ? k.forStringProperty("artistName") : k.forStringPropertyReversed("artistName"); | |
case "album.name": | |
return "desc" != b ? k.forStringProperty("albumName") : k.forStringPropertyReversed("albumName") | |
} | |
return null | |
}; | |
a.createPredicate = function (a, b, c) { | |
switch (a) { | |
case "uri": | |
case "name": | |
case "disc": | |
case "duration": | |
case "number": | |
case "popularity": | |
case "seen": | |
case "starred": | |
return n.forPropertyOperator(a, b, c); | |
case "artists.name": | |
return n.forPropertyOperator("artistName", b, c); | |
case "album.name": | |
return n.forPropertyOperator("albumName", | |
b, c) | |
} | |
return null | |
}; | |
h(f, a); | |
f.prototype._parseData = function (a) { | |
var b = g.localAlbumLink(a.artist, a.album).toURI(), | |
c = g.localArtistLink(a.artist).toURI(); | |
this.name = a.track || ""; | |
this.duration = isNaN(a.duration) ? -1 : 1E3 * (a.duration || 0); | |
this.cover = ""; | |
this.local = !0; | |
this.playable = !1; | |
this.album = { | |
uri: b, | |
artists: [{ | |
uri: c, | |
name: a.artist || "" | |
}], | |
name: a.album || "" | |
}; | |
this.artists = [{ | |
uri: c, | |
name: a.artist || "" | |
}] | |
}; | |
h(m, a); | |
m.create = function (a, b) { | |
var c = new d; | |
try { | |
c.fulfill(new m(a, b)) | |
} catch (f) { | |
c.fail(f) | |
} | |
return c | |
}; | |
m.prototype._parseData = | |
function (a) { | |
for (var b in a) this[b] = a[b]; | |
this._pid = this.playableId = a.__pid; | |
this.playableURI = g.adLink(this._pid) | |
}; | |
l.exports = { | |
TrackData: void 0, | |
Track: a, | |
LocalTrack: f, | |
AdTrack: m | |
} | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/entities/album.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(b, d) { | |
if (!(this instanceof a)) return new a(b, d); | |
this.uri = b.toString(); | |
d && this._fill(d) | |
} | |
var f = Spotify.Link, | |
m = b("node_modules/spotify-promise/src/promise.js"), | |
h = b("node_modules/spotify-bridge/src/shell/entities/image.js"); | |
a.prototype._fill = | |
function (a) { | |
var b, c; | |
this.artistName = ""; | |
this.artists = []; | |
this.availability = a.availability; | |
this.copyrights = []; | |
this.date = a.date || {}; | |
this.discs = []; | |
this.image = null; | |
this.images = []; | |
this.label = a.label; | |
this.name = a.name; | |
this.playable = a.playable; | |
this.popularity = a.popularity; | |
this.type = (a.type || "").toLowerCase(); | |
var k = a.artist, | |
l = this.artists = [], | |
m = []; | |
this.artistName = ""; | |
if (k && k.length) { | |
b = 0; | |
for (c = k.length; b < c; b++) { | |
var n = k[b]; | |
l.push({ | |
uri: f.artistLink(n.id).toString(), | |
name: n.name | |
}); | |
m.push(n.name) | |
} | |
this.artistName = m.join(";") | |
} | |
if (b = | |
a.cover_group && a.cover_group.image) b = h.create(b, a.resourceUrl), this.image = b.image, this.images = b.images; | |
k = this.discs; | |
if (l = a.disc) | |
for (m = f.fromString(this.uri), b = 0, c = l.length; b < c; b++) { | |
n = l[b]; | |
m.disc = n.number; | |
for (var p = [], r = 0, w = n.track.length; r < w; r++) p.push(f.trackLink(n.track[r].id).toString()); | |
k.push({ | |
album: this.uri, | |
number: n.number, | |
trackURIs: p, | |
uri: m.toString() | |
}) | |
} | |
if (a = a.copyright) | |
for (k = this.copyrights, b = 0, c = a.length; b < c; b++) { | |
var u = a[b]; | |
k[b] = u.text.replace(/^(\([A-Z]+\))?(.*)$/, function (a, b, c) { | |
return b ? | |
a : "(" + u.type + ") " + c | |
}) | |
} | |
}; | |
a.create = function (b, d) { | |
var c = new m; | |
try { | |
c.fulfill(new a(b, d)) | |
} catch (f) { | |
c.fail(f) | |
} | |
return c | |
}; | |
a.createComparator = function (a, b) { | |
return null | |
}; | |
a.createPredicate = function (a, b, c) { | |
return null | |
}; | |
l.exports = a | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/entities/artist.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(b, d) { | |
if (!(this instanceof a)) return new a(b, d); | |
this.uri = b.toString(); | |
d && this._fill(d) | |
} | |
var f = Spotify.Link, | |
m = b("node_modules/spotify-promise/src/promise.js"), | |
h = b("node_modules/spotify-bridge/src/shell/entities/image.js"); | |
a.prototype._fill = function (a) { | |
var b, c, f, l; | |
this.name = a.name; | |
this.popularity = a.popularity; | |
this.image = null; | |
this.images = []; | |
this.genres = []; | |
this.biography = ""; | |
this.portraits = []; | |
this.years = null; | |
a.genre && (this.genres = a.genre.slice()); | |
if (f = a.portrait_group && a.portrait_group.image) f = h.create(f, a.resourceUrl), this.image = f.image, this.images = f.images; | |
if ((f = a.biography) && f.length) | |
for (l = f.length; l--;) | |
if (b = f[l], b.text && (this.biography = b.text), b.portrait_group) { | |
var m = b.portrait_group; | |
b = 0; | |
for (c = m.length; b < c; b++) { | |
var n = | |
m[b] && m[b].image; | |
n && (n = h.create(n, a.resourceUrl), n.image && this.portraits.push(n.image)) | |
} | |
} | |
if ((b = a.activity_period) && b.length) { | |
c = []; | |
f = 0; | |
for (l = b.length; f < l; f++) n = b[f], m = n.start_year || n.decade, n = n.end_year || n.decade + 9, isNaN(n) && (n = (new Date).getFullYear()), c.push({ | |
start: m, | |
end: n | |
}); | |
c.length && (this.years = { | |
from: c[0].start, | |
to: c[c.length - 1].end | |
}) | |
} | |
this.getAlbumGroups = this.getAlbumGroups.bind(this, a); | |
this.getAppearsOnGroups = this.getAppearsOnGroups.bind(this, a); | |
this.getSingleGroups = this.getSingleGroups.bind(this, | |
a); | |
this.getRelatedArtists = this.getRelatedArtists.bind(this, a); | |
this.getTopTracks = this.getTopTracks.bind(this, a) | |
}; | |
a.prototype.getAlbumGroups = function (a) { | |
var b = [], | |
c = a.album_group; | |
if (c && c.length) | |
for (var k = 0, h = c.length; k < h; k++) { | |
var l = c[k]; | |
a = []; | |
for (var m = 0, n = l.length; m < n; m++) l[m].playable && a.push({ | |
uri: f.albumLink(l[m].id).toURI() | |
}); | |
a.length && b.push({ | |
albums: a | |
}) | |
} | |
return b | |
}; | |
a.prototype.getAppearsOnGroups = function (a) { | |
var b = [], | |
c = a.appears_on_group; | |
if (c && c.length) | |
for (var k = 0, h = c.length; k < h; k++) { | |
var l = c[k]; | |
a = []; | |
for (var m = 0, n = l.length; m < n; m++) l[m].playable && a.push({ | |
uri: f.albumLink(l[m].id).toURI() | |
}); | |
a.length && b.push({ | |
albums: a | |
}) | |
} | |
return b | |
}; | |
a.prototype.getSingleGroups = function (a) { | |
var b = [], | |
c = a.single_group; | |
if (c && c.length) | |
for (var k = 0, h = c.length; k < h; k++) { | |
var l = c[k]; | |
a = []; | |
for (var m = 0, n = l.length; m < n; m++) l[m].playable && a.push({ | |
uri: f.albumLink(l[m].id).toURI() | |
}); | |
a.length && b.push({ | |
albums: a | |
}) | |
} | |
return b | |
}; | |
a.prototype.getRelatedArtists = function (a) { | |
var b = []; | |
if ((a = a.related) && a.length) | |
for (var c = 0, k = a.length; c < k; c++) b.push(f.artistLink(a[c].id).toURI()); | |
return b | |
}; | |
a.prototype.getTopTracks = function (a) { | |
var b = []; | |
if ((a = a.top_track) && a.length) | |
for (var c = 0, k = a.length; c < k; c++) b.push(f.trackLink(a[c].id).toURI()); | |
return b | |
}; | |
a.create = function (b, d) { | |
var c = new m; | |
c.fulfill(new a(b, d)); | |
return c | |
}; | |
a.createComparator = function (a, b) {}; | |
a.createPredicate = function (a, b, c) {}; | |
l.exports = a | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/entities/profile.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(b, f) { | |
if (!(this instanceof a)) return new a(b, f); | |
this.uri = b.toString(); | |
f && this._fill(f) | |
} | |
var f = b("node_modules/spotify-promise/src/promise.js"), | |
m = b("node_modules/spotify-bridge/src/shell/entities/image.js"); | |
a.prototype._fill = function (a) { | |
this.username = a.username; | |
this.name = a.full_name || a.username; | |
this.subscribed = this.currentUser = !1; | |
this.images = this.image = null; | |
this.identifier = ""; | |
if (a.image_url || a.large_image_url) a = m.createProfile({ | |
image: a.image_url, | |
imageLarge: a.large_image_url | |
}, a.resourceUrl), this.image = a.image, this.images = a.images | |
}; | |
a.create = function (b, g) { | |
var d = new f; | |
try { | |
d.fulfill(new a(b, | |
g)) | |
} catch (c) { | |
d.fail(c) | |
} | |
return d | |
}; | |
l.exports = a | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/entities.js": function (b, l, f, n, p, r) { | |
b = b("node_modules/spotify-inheritance/extend.js")({}, b("node_modules/spotify-bridge/src/shell/entities/playlist.js"), b("node_modules/spotify-bridge/src/shell/entities/search.js"), b("node_modules/spotify-bridge/src/shell/entities/track.js"), { | |
Base: b("node_modules/spotify-bridge/src/shell/entities/base.js"), | |
Album: b("node_modules/spotify-bridge/src/shell/entities/album.js"), | |
Artist: b("node_modules/spotify-bridge/src/shell/entities/artist.js"), | |
Profile: b("node_modules/spotify-bridge/src/shell/entities/profile.js"), | |
Session: b("node_modules/spotify-bridge/src/shell/entities/session.js") | |
}); | |
l.exports = b | |
}, | |
"node_modules/spotify-bridge/src/bridge/responders/playlist.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(a, b, c) { | |
this._list = null; | |
this._listeners = b; | |
this._receiver = c || null; | |
this._queue = a | |
} | |
var f = Spotify.Link, | |
m = b("node_modules/spotify-bridge/src/shell/extension.js").LinkHelper, | |
h = b("node_modules/spotify-promise/src/promise.js"), | |
g = b("node_modules/spotify-bridge/src/bridge/errors.js"), | |
d = b("node_modules/spotify-bridge/src/bridge/snapshothelper.js"), | |
c = b("node_modules/spotify-bridge/src/shell/entities.js"), | |
k = b("node_modules/spotify-bridge/src/shell/lists.js"), | |
n = k.Descriptor, | |
p = k.MutationResult, | |
r = Array.prototype.slice, | |
t = b("node_modules/spotify-bridge/src/bridge/responder.js"); | |
a.prototype.sendEvents = function (a) { | |
a = Array.isArray(a) ? a : r.call(arguments); | |
for (var b = this._listeners, c = 0, d = a.length; c < d; c++) { | |
var f = b.splice(0), | |
g = f.length; | |
if (g) | |
for (var k = 0; k < g; k++) f[k].fulfill(a[c]); | |
else { | |
b = this._queue; | |
b.push.apply(b, a.slice(c)); | |
break | |
} | |
} | |
}; | |
a.prototype.onBeforeMutate = function (a) { | |
this._list = a.toArray() | |
}; | |
a.prototype.onMutate = function (a) { | |
var b = this._receiver, | |
c = [], | |
d = this._list; | |
if (null == d) return this; | |
for (var f = 0, g = a.length; f < g; f++) { | |
var k = a[f], | |
h, l, m, n, q, p; | |
switch (k.type) { | |
case "insert": | |
h = k.begin; | |
l = k.items.length; | |
m = k.items.map(function (a) { | |
return a.uri | |
}); | |
c.push({ | |
type: "insert", | |
receiver: b, | |
data: { | |
index: h, | |
length: l, | |
array: m | |
}, | |
index: h, | |
uris: m | |
}); | |
break; | |
case "remove": | |
h = k.begin; | |
l = k.length; | |
m = []; | |
n = []; | |
q = h; | |
for (p = h + l; q < p; q++) n.push(q), | |
m.push(d[q].uri); | |
c.push({ | |
type: "remove", | |
receiver: b, | |
data: { | |
index: h, | |
length: l, | |
array: m | |
}, | |
indices: n, | |
index: h, | |
uris: m | |
}); | |
break; | |
case "move": | |
h = k.begin; | |
l = k.length; | |
m = []; | |
n = []; | |
q = h; | |
for (p = h + l; q < p; q++) n.push(q), m.push(d[q].uri); | |
c.push({ | |
type: "move", | |
receiver: b, | |
data: { | |
indexFrom: h, | |
indexTo: k.end, | |
length: l, | |
array: m | |
}, | |
indices: n, | |
indexFrom: h, | |
indexTo: k.end, | |
uris: m | |
}) | |
} | |
} | |
c.length && this.sendEvents(c); | |
this._list = null | |
}; | |
t = t.build({ | |
init: function () { | |
this._setReady() | |
}, | |
_attachLibraryObservers: function (b, c) { | |
var d = [], | |
f = [c], | |
g = new a(d, f, "playlists"), | |
k = new a(d, f, "published"); | |
h.join(b.get("/rootlist", null, { | |
descriptor: new n.List("spotify:user:@:rootlist") | |
}), b.get("/publishedrootlist", null, { | |
descriptor: new n.List("spotify:user:@:publishedrootlist") | |
})).thenSpread(function (a, c) { | |
a = a.body.list.getRootBaseList(); | |
c = c.body.list.getRootBaseList(); | |
a.observe(g); | |
c.observe(k); | |
b.addOnceEvent("destroy", function () { | |
a.unobserve(g); | |
c.unobserve(k) | |
}) | |
}); | |
b.setData("hasLibraryEventListeners", !0); | |
b.setData("libraryEventQueue", d); | |
b.setData("libraryEventListeners", f) | |
}, | |
_attachPlaylistListeners: function (b, | |
c, d) { | |
var f = []; | |
d = [d]; | |
var g = new a(f, d), | |
k = function (a) { | |
var b = { | |
type: "change", | |
data: {}, | |
uris: [], | |
receiver: null | |
}; | |
b.data[a.property] = a.newValue; | |
g.sendEvents(b) | |
}; | |
c.setData("hasPlaylistEventListeners:" + b, !0); | |
c.setData("playlistEventQueue:" + b, f); | |
c.setData("playlistEventListeners:" + b, d); | |
h.join(c.get("/playlist", null, { | |
uri: b | |
}), c.get("/playlist/tracks", null, { | |
descriptor: new n.List(b) | |
})).thenSpread(function (a, b) { | |
a = a.body.result; | |
b = b.body.list; | |
a.addEvent("change", k); | |
b.observe(g); | |
c.addOnceEvent("destroy", function () { | |
a.removeEvent("change", | |
k); | |
b.unobserve(g) | |
}) | |
}) | |
}, | |
_groupURIs: function (a) { | |
for (var b = { | |
albums: [], | |
artists: [], | |
playlists: [], | |
profiles: [], | |
tracks: [] | |
}, c = 0, d = a.length; c < d; c++) { | |
var f = m.from(a[c]); | |
if (f) switch (f.type) { | |
case "album": | |
b.albums.push(f); | |
break; | |
case "artist": | |
b.artists.push(f); | |
break; | |
case "profile": | |
b.profiles.push(f); | |
break; | |
case "playlist": | |
case "starred": | |
case "user-toplist": | |
case "user-top-tracks": | |
b.playlists.push(f); | |
break; | |
case "track": | |
b.tracks.push(f) | |
} | |
} | |
return b | |
}, | |
_rootlistInsert: function (a, b, c, d, f) { | |
return a.get("/session").then(function (a) { | |
a = | |
a.body.result; | |
if ("@" == d.username) return d.username = a.user.username, d; | |
if (d.username == a.user.username) return d; | |
throw new g.Forbidden("Cannot publish as another user."); | |
}).then(function (b) { | |
return h.join(b, a.get("/playlists", null, { | |
uris: f | |
})) | |
}).thenSpread(function (d, g) { | |
for (var k = g.body.result, l = [], m = 0, q = f.length; m < q; m++) { | |
var p = k[f[m]]; | |
p && !p[c] && l.push({ | |
uri: p.uri, | |
added_by: d.username | |
}) | |
} | |
return h.join([l, a.get("/" + b, null, { | |
descriptor: new n.List(d) | |
})]) | |
}).thenSpread(function (a, b) { | |
var c = b.body.list; | |
return a.length ? | |
c.preload().then(function () { | |
var b = c.createMutator(); | |
b.canInsert(0, a.length) == p.ALLOWED && (b.insert(0, a), b.apply()); | |
return !0 | |
}) : !0 | |
}) | |
}, | |
_rootlistRemove: function (a, b, c, d, f) { | |
return a.get("/session").then(function (a) { | |
a = a.body.result; | |
if ("@" == d.username) return d.username = a.user.username, d; | |
if (d.username == a.user.username) return d; | |
throw new g.Forbidden("Cannot publish as another user."); | |
}).then(function (b) { | |
return h.join(b, a.get("/playlists", null, { | |
uris: f | |
})) | |
}).thenSpread(function (d, g) { | |
for (var k = g.body.result, l = [], m = 0, q = f.length; m < q; m++) { | |
var p = k[f[m]]; | |
p && p[c] && l.push(p.uri) | |
} | |
return h.join([l, a.get("/" + b, null, { | |
descriptor: new n.List(d) | |
})]) | |
}).thenSpread(function (a, b) { | |
var c = new k.Filtered(b.body.list, function (b) { | |
return !(!b || -1 == a.indexOf(b.uri)) | |
}); | |
return a.length ? c.getLength().then(function (a) { | |
var b = c.createMutator(); | |
b.canRemove(0, a) == p.ALLOWED && (b.remove(0, a), b.apply()); | |
return !0 | |
}) : !0 | |
}) | |
}, | |
"*library_publish": function (a, b) { | |
var c = b.args, | |
d = m.from(c[0]), | |
c = this._groupURIs(c.slice(1)); | |
return d ? this._rootlistInsert(a, | |
"publishedrootlist", "published", d, c.playlists) : new g.InvalidRequest("Invalid user.") | |
}, | |
"*library_unpublish": function (a, b) { | |
var c = b.args, | |
d = m.from(c[0]), | |
c = this._groupURIs(c.slice(1)); | |
return d ? this._rootlistRemove(a, "publishedrootlist", "published", d, c.playlists) : new g.InvalidRequest("Invalid user.") | |
}, | |
"*library_star": function (a, b) { | |
var c = b.args.slice(1); | |
b.args = [new n.List("spotify:user:@:starred")].concat(c); | |
return this._request("playlist_tracks_append", b, a) | |
}, | |
"*library_unstar": function (a, b) { | |
var c = b.args, | |
d = m.from(c[0]), | |
f = this._groupURIs(c.slice(1)).tracks; | |
return d ? a.get("/session").then(function (a) { | |
a = a.body.result; | |
if ("@" == d.username) return d.username = a.user.username, d; | |
if (d.username == a.user.username) return d; | |
throw new g.Forbidden("Cannot publish as another user."); | |
}).then(function (b) { | |
return h.join(b, a.get("/tracks", { | |
flush: !0 | |
}, { | |
uris: f | |
})) | |
}).thenSpread(function (b, c) { | |
for (var d = c.body.result, g = [], k = 0, l = f.length; k < l; k++) { | |
var m = d[f[k]]; | |
m && m.starred && g.push(m.uri) | |
} | |
return h.join([g, a.get("/starredlist", null, { | |
descriptor: new n.List(b) | |
})]) | |
}).thenSpread(function (a, b) { | |
var c = new k.Filtered(b.body.list, function (b) { | |
return !(!b || -1 == a.indexOf(b.uri)) | |
}); | |
return a.length ? c.getLength().then(function (a) { | |
var b = c.createMutator(); | |
b.canRemove(0, a) == p.ALLOWED && (b.remove(0, a), b.apply()); | |
return !0 | |
}) : !0 | |
}) : new g.InvalidRequest("Invalid user.") | |
}, | |
"*library_subscribe": function (a, b) { | |
var c = this, | |
d = b.args, | |
f = m.from(d[0]), | |
d = this._groupURIs(d.slice(1)); | |
return f ? this._rootlistInsert(a, "rootlist", "subscribed", f, d.playlists).then(function (b) { | |
return h.join(b, | |
a.get("/session").get("body").get("result")) | |
}).thenSpread(function (d, f) { | |
return d && f.publishPlaylists ? c._request("library_publish", b, a).then(function (a) { | |
return a | |
}) : d | |
}) : new g.InvalidRequest("Invalid user.") | |
}, | |
"*library_unsubscribe": function (a, b) { | |
var c = this, | |
d = b.args, | |
f = m.from(d[0]), | |
d = this._groupURIs(d.slice(1)); | |
return f ? this._rootlistRemove(a, "rootlist", "subscribed", f, d.playlists).then(function (d) { | |
return d ? c._request("library_unpublish", b, a) : d | |
}) : new g.InvalidRequest("Invalid user.") | |
}, | |
"*library_event_wait": function (a, | |
b) { | |
var c = this._createPromise(); | |
if (a.getData("hasLibraryEventListeners")) { | |
var d = a.getData("libraryEventQueue"); | |
d.length ? c.fulfill(d.shift()) : a.getData("libraryEventListeners").push(c) | |
} else this._attachLibraryObservers(a, c); | |
return c | |
}, | |
"*library_playlists_snapshot": function (a, b) { | |
var c = b.args, | |
f = c[1], | |
g = c[2]; | |
return a.get("/rootlist", null, { | |
descriptor: c[0] | |
}).then(d.createListSnapshotter(f, g)).then(d.formatSnapshot) | |
}, | |
"*library_published_snapshot": function (a, b) { | |
var c = b.args, | |
f = c[1], | |
g = c[2]; | |
return a.get("/publishedrootlist", | |
null, { | |
descriptor: c[0] | |
}).then(d.createListSnapshotter(f, g)).then(d.formatSnapshot) | |
}, | |
"*playlist_create": function (a, b) { | |
return a.create("/playlist", null, { | |
name: b.args[0] | |
}).then(function (a) { | |
return { | |
uri: a.body.uri | |
} | |
}) | |
}, | |
"*playlist_create_temporary": function (a, b) { | |
var c = this._createPromise(), | |
d = a.getId(), | |
k = b.args[0], | |
h = f.temporaryPlaylistLink(d, encodeURIComponent(k)); | |
return a.getData(h) ? (c.fail(new g.InvalidRequest("Playlist already created.")), c) : a.create("/playlist/temporary", null, { | |
name: k, | |
uri: h.toString() | |
}).then(function (b) { | |
var c = | |
b.body.result; | |
a.setData(h, b.body.list); | |
a.setData("playlist-metadata:" + h.toString(), c); | |
return c | |
}) | |
}, | |
"*playlist_enforce_rules": function (a, b) { | |
var c = b.args, | |
d = c[0], | |
f = a.getData("ruleMap", {}); | |
f || (f = {}, a.setData("ruleMap", f)); | |
f[d] = c[1]; | |
return !0 | |
}, | |
"*playlist_event_wait": function (a, b) { | |
var c = this, | |
d = this._createPromise(); | |
a.get("/playlist/uri", null, { | |
uri: b.args[0] | |
}).then(function (b) { | |
b = b.body.result; | |
if (a.getData("hasPlaylistEventListeners:" + b)) { | |
var f = a.getData("playlistEventQueue:" + b); | |
f.length ? d.fulfill(f.shift()) : | |
a.getData("playlistEventListeners:" + b).push(d) | |
} else c._attachPlaylistListeners(b, a, d) | |
}); | |
return d | |
}, | |
"*playlist_metadata": function (a, b) { | |
return a.get("/playlist", null, { | |
uri: b.args[0] | |
}).then(function (a) { | |
return a.body.result | |
}) | |
}, | |
"*playlist_popularity": function (a, b) { | |
return a.get("/playlist/popularity", null, { | |
uri: b.args[0] | |
}).then(function (a) { | |
return { | |
popularity: a.body.result | |
} | |
}) | |
}, | |
"*playlist_profile": function (a, b) { | |
return a.get("/playlist/mosaic", {}, { | |
uri: b.args[0] | |
}).then(function (a) { | |
return a.body | |
}) | |
}, | |
"*playlist_remove_temporary": function (a, | |
b) { | |
var c = this._createPromise(), | |
d = a.getId(), | |
k = b.args[0], | |
h = f.temporaryPlaylistLink(d, encodeURIComponent(k)); | |
if (a.getData(h)) return a.remove("/playlist/temporary", null, { | |
name: k, | |
uri: h.toString() | |
}).then(function (b) { | |
a.setData(h, null); | |
a.setData("playlist-metadata:" + h.toString(), null); | |
return !0 | |
}); | |
c.fail(new g.InvalidRequest("Playlist does not exist.")); | |
return c | |
}, | |
"*playlist_restricted": function (a, b) { | |
return a.get("/playlist", null, { | |
uri: b.args[0] | |
}).then(function (a) { | |
return { | |
ownedByCurrentUser: !! a.body.result.ownedByCurrentUser | |
} | |
}) | |
}, | |
"*playlist_set_name": function (a, b) { | |
var c = b.args; | |
return a.update("/playlist", null, { | |
uri: c[0], | |
attributes: { | |
name: c[1] | |
} | |
}).then(function () { | |
return !0 | |
}) | |
}, | |
"*playlist_subscribers_snapshot": function (a, b) { | |
var c = b.args, | |
f = c[1], | |
g = c[2]; | |
return a.get("/playlist/subscribers", null, { | |
uri: c[0].uri | |
}).then(d.createListSnapshotter(f, g)).then(d.formatSnapshot) | |
}, | |
"*playlist_tracks_append": function (a, b) { | |
var d = b.args, | |
f = d[0]; | |
return a.get("/session").then(function (b) { | |
b = b.body.result; | |
for (var k = [], l = (new Date).getTime(), m = 1, n = d.length; m < | |
n; m++) { | |
var q = d[m]; | |
k.push(new c.PlaylistRow(q, { | |
added_by: b.user.username, | |
timestamp: l, | |
track: q | |
})) | |
} | |
return a.get("/playlist/tracks", null, { | |
descriptor: f | |
}).then(function (a) { | |
a = a.body.list; | |
return h.join(a, a.preload()) | |
}).thenSpread(function (a) { | |
if ((a = a.createMutator()) && a.canAdd(k.length) == p.ALLOWED) return a.add(k), a.apply(); | |
throw new g.Forbidden("Cannot add tracks to playlist."); | |
}).then(function (a) { | |
return a == p.SUCCESS | |
}) | |
}) | |
}, | |
"*playlist_tracks_clear": function (a, b) { | |
return a.get("/playlist/tracks", null, { | |
descriptor: b.args[0] | |
}).then(function (a) { | |
a = | |
a.body.list; | |
return h.join(a, a.preload()) | |
}).thenSpread(function (a) { | |
return h.join(a, a.getLength()) | |
}).thenSpread(function (a, b) { | |
var c = a.createMutator(); | |
if (c && c.canRemove(0, b) == p.ALLOWED) return c.remove(0, b), c.apply(); | |
throw new g.Forbidden("Cannot clear playlist."); | |
}).then(function (a) { | |
return a == p.SUCCESS | |
}) | |
}, | |
"*playlist_tracks_insert": function (a, b) { | |
var d = b.args, | |
f = d[0], | |
k = d[1]; | |
return a.get("/session").then(function (b) { | |
b = b.body.result; | |
for (var l = [], m = (new Date).getTime(), n = 3, q = d.length; n < q; n++) { | |
var s = d[n]; | |
l.push(new c.PlaylistRow(s, { | |
added_by: b.user.username, | |
timestamp: m, | |
track: s | |
})) | |
} | |
return a.get("/playlist/tracks", null, { | |
descriptor: f | |
}).then(function (a) { | |
a = a.body.list; | |
return h.join(a, a.preload()) | |
}).thenSpread(function (a) { | |
if ((a = a.createMutator()) && a.canInsert(k, l.length) == p.ALLOWED) return a.insert(k, l), a.apply(); | |
throw new g.Forbidden("Cannot insert into playlist."); | |
}).then(function (a) { | |
return a == p.SUCCESS | |
}) | |
}) | |
}, | |
"*playlist_tracks_move": function (a, b) { | |
var c = b.args, | |
d = c[1], | |
f = c[2], | |
k = c[3]; | |
return a.get("/playlist/tracks", null, { | |
descriptor: c[0] | |
}).then(function (a) { | |
a = | |
a.body.list; | |
return h.join(a, a.preload()) | |
}).thenSpread(function (a) { | |
if ((a = a.createMutator()) && a.canMove(d, f, k) == p.ALLOWED) return a.move(d, f, k), a.apply(); | |
throw new g.Forbidden("Cannot move tracks in playlist."); | |
}).then(function (a) { | |
return a == p.SUCCESS | |
}) | |
}, | |
"*playlist_tracks_remove": function (a, b) { | |
var c = b.args, | |
d = c[1]; | |
return a.get("/playlist/tracks", null, { | |
descriptor: c[0] | |
}).then(function (a) { | |
a = a.body.list; | |
return h.join(a, a.preload()) | |
}).thenSpread(function (a) { | |
if ((a = a.createMutator()) && a.canRemove(d, 1) == p.ALLOWED) return a.remove(d, | |
1), a.apply(); | |
throw new g.Forbidden("Cannot remove track from playlist."); | |
}).then(function (a) { | |
return a == p.SUCCESS | |
}) | |
}, | |
"*playlist_tracks_trim": function (a, b) { | |
var c = b.args, | |
d = c[1]; | |
return a.get("/playlist/tracks", null, { | |
descriptor: c[0] | |
}).then(function (a) { | |
a = a.body.list; | |
return h.join(a, a.preload()) | |
}).thenSpread(function (a) { | |
return h.join(a, a.getLength()) | |
}).thenSpread(function (a, b) { | |
var c = b - d, | |
f = a.createMutator(); | |
if (f && f.canRemove(d, c) == p.ALLOWED) return f.remove(d, c), f.apply(); | |
throw new g.Forbidden("Cannot trim playlist."); | |
}).then(function (a) { | |
return a == p.SUCCESS | |
}) | |
}, | |
"*playlist_tracks_snapshot": function (a, b) { | |
var c = b.args, | |
f = c[1], | |
g = c[2]; | |
return a.get("/playlist/tracks", null, { | |
descriptor: c[0] | |
}).then(d.createListSnapshotter(f, g)).then(d.formatTrackRowSnapshot) | |
} | |
}); | |
l.exports = t | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/sublists/album.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(b, c) { | |
if (!(this instanceof a)) return new a(b, c); | |
d.call(this, c); | |
this._uri = b.toString(); | |
this._loadLimit = 500 | |
} | |
function f(a, b) { | |
if (!(this instanceof f)) return new f(a, | |
b); | |
c.call(this, b); | |
this._uri = a.toString() | |
} | |
var m = b("node_modules/spotify-inheritance/inherit.js"), | |
h = b("node_modules/spotify-bridge/src/shell/entities.js"), | |
g = b("node_modules/spotify-bridge/src/shell/lists.js"), | |
d = g.Array, | |
c = g.Concatenated; | |
m(a, d); | |
m(f, c); | |
f.prototype.createComparator = function (a, b) { | |
return h.Track.createComparator(a, b) | |
}; | |
f.prototype.createPredicate = function (a, b, c) { | |
return h.Track.createPredicate(a, b, c) | |
}; | |
l.exports = { | |
DiscTrack: a, | |
AlbumTrack: f | |
} | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/sublists/playlist.js": function (b, | |
l, f, n, p, r) { | |
(function () { | |
function a(b, c, d) { | |
if (!(this instanceof a)) return new a(b, c, d); | |
r.call(this); | |
this._uri = b.toString(); | |
this._loadLimit = 200; | |
this._itemLoader = c; | |
this._operationApplicator = d | |
} | |
function f(b, c, d) { | |
if (!(this instanceof f)) return new f(b, c, d); | |
a.call(this, b, c, d) | |
} | |
function m(a, b, c) { | |
if (!(this instanceof m)) return new m(a, b, c); | |
f.call(this, a, b, c) | |
} | |
function h(b, c) { | |
if (!(this instanceof h)) return new h(b, c); | |
a.call(this, b, c) | |
} | |
var g = Spotify.Link, | |
d = b("node_modules/spotify-inheritance/inherit.js"), | |
c = b("node_modules/spotify-promise/src/promise.js"), | |
k = b("node_modules/spotify-bridge/src/shell/range.js"), | |
n = b("node_modules/spotify-bridge/src/shell/entities.js"), | |
p = b("node_modules/spotify-bridge/src/shell/lists.js"), | |
r = p.Base, | |
t = p.MutationResult, | |
v = p.Snapshot, | |
w = r.prototype._applyInsertMutation, | |
u = r.prototype._applyRemoveMutation, | |
A = r.prototype._applyMoveMutation; | |
d(a, r); | |
a.prototype._load = function (a) { | |
var b = this, | |
d = new c; | |
this._itemLoader(this._uri, a).then(function (c) { | |
d.fulfill({ | |
range: a, | |
items: b._createRows(c) | |
}) | |
}); | |
return d | |
}; | |
a.prototype._loadLength = function () { | |
var a = | |
this, | |
b = new c, | |
d = new k(0, this._loadLimit); | |
this._itemLoader(this._uri, d).then(function (c) { | |
c = a._length = c.length; | |
b.fulfill({ | |
length: c | |
}) | |
}, function () { | |
var c = a._length = 0; | |
b.fulfill({ | |
length: c | |
}) | |
}); | |
return b | |
}; | |
a.prototype._createRows = function (a) { | |
a = a.contents; | |
for (var b = [], c = 0, d = a.length; c < d; c++) { | |
var f = a[c]; | |
b.push({ | |
uri: f.uri.toString(), | |
addedBy: f.attributes && f.attributes.added_by || "" | |
}) | |
} | |
return b | |
}; | |
a.prototype._createMutationApplicator = function () { | |
var a = this; | |
return function (b, d) { | |
var f = new c; | |
if (a._version != b) return f.fulfill(t.EXPIRED), | |
f; | |
a.notify("onBeforeMutate", new v(a._version, a._createVersionedAccessor(), new k(0, a._length), a._length)); | |
for (var g = [], h = 0, l = d.length; h < l; h++) { | |
var m = d[h]; | |
switch (m.type) { | |
case "insert": | |
g.push(a._applyInsertMutation(m)); | |
break; | |
case "remove": | |
g.push(a._applyRemoveMutation(m)); | |
break; | |
case "move": | |
g.push(a._applyMoveMutation(m)) | |
} | |
} | |
g.length && a._operationApplicator(a._uri, g).then(function (b) { | |
a._version++; | |
a.notify("onMutate", d); | |
f.fulfill(t.SUCCESS) | |
}); | |
return f | |
} | |
}; | |
a.prototype._applyInsertMutation = function (a) { | |
w.call(this, | |
a); | |
for (var b = a.items, c = [], d = 0, f = b.length; d < f; d++) c.push({ | |
uri: b[d].uri.toString(), | |
attributes: {} | |
}); | |
return { | |
kind: "ADD", | |
add: { | |
fromIndex: a.begin, | |
items: c | |
} | |
} | |
}; | |
a.prototype._applyRemoveMutation = function (a) { | |
u.call(this, a); | |
return { | |
kind: "REM", | |
rem: { | |
fromIndex: a.begin, | |
length: a.length | |
} | |
} | |
}; | |
a.prototype._applyMoveMutation = function (a) { | |
A.call(this, a); | |
return { | |
kind: "MOV", | |
mov: { | |
fromIndex: a.begin, | |
toIndex: a.end, | |
length: a.length | |
} | |
} | |
}; | |
d(f, a); | |
f.prototype._createRows = function (a) { | |
a = a.contents; | |
for (var b = [], c = 0, d = a.length; c < d; c++) { | |
var f = a[c]; | |
b.push(new n.PlaylistRow(f.uri, f.attributes)) | |
} | |
return b | |
}; | |
f.prototype._applyInsertMutation = function (a) { | |
w.call(this, a); | |
for (var b = a.items, c = [], d = 0, f = b.length; d < f; d++) { | |
var g = b[d]; | |
c.push({ | |
uri: g.uri.toString(), | |
attributes: { | |
added_by: g.creatorName | |
} | |
}) | |
} | |
return { | |
kind: "ADD", | |
add: { | |
fromIndex: a.begin, | |
items: c | |
} | |
} | |
}; | |
f.prototype.createComparator = function (a, b) { | |
return n.PlaylistRow.createComparator(a, b) | |
}; | |
f.prototype.createPredicate = function (a, b, c) { | |
return n.PlaylistRow.createPredicate(a, b, c) | |
}; | |
d(m, f); | |
m.prototype._applyInsertMutation = | |
function (a) { | |
var b = a.items, | |
c = b.length; | |
this._list.spliceWith(a.begin, 0, b); | |
this._length += c; | |
for (a = Array(c); c--;) a[c] = b[c].uri.toString(); | |
return { | |
kind: "ADD", | |
items: a | |
} | |
}; | |
m.prototype._applyRemoveMutation = function (a) { | |
var b = a.length; | |
a = this._list.splice(a.begin, b); | |
this._length -= b; | |
for (var c = Array(b); b--;) c[b] = a[b].uri.toString(); | |
return { | |
kind: "REM", | |
items: c | |
} | |
}; | |
d(h, a); | |
h.prototype._createRows = function (a) { | |
a = a.contents; | |
for (var b = [], c = 0, d = a.length; c < d; c++) b.push({ | |
uri: g.profileLink(a[c]).toString() | |
}); | |
return b | |
}; | |
l.exports = { | |
PlaylistRoot: a, | |
PlaylistRow: f, | |
PlaylistStarred: m, | |
PlaylistSubscribers: h | |
} | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/sublists/search.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(a, b) { | |
r.call(this); | |
this._uri = a.toString(); | |
this._loadLimit = 50; | |
this._itemLoader = b; | |
this._timestamp = (new Date).getTime() | |
} | |
function f(b, c) { | |
if (!(this instanceof f)) return new f(b, c); | |
a.call(this, b, c) | |
} | |
function m(b, c) { | |
if (!(this instanceof m)) return new m(b, c); | |
a.call(this, b, c) | |
} | |
function h(b, c) { | |
if (!(this instanceof h)) return new h(b, | |
c); | |
a.call(this, b, c) | |
} | |
function g(b, c) { | |
if (!(this instanceof g)) return new g(b, c); | |
a.call(this, b, c) | |
} | |
var d = b("node_modules/spotify-inheritance/inherit.js"), | |
c = Spotify.Link, | |
k = b("node_modules/spotify-promise/src/promise.js"), | |
n = b("node_modules/spotify-bridge/src/shell/entities.js"), | |
p = b("node_modules/spotify-bridge/src/shell/range.js"), | |
r = b("node_modules/spotify-bridge/src/shell/lists.js").Base; | |
d(a, r); | |
a.create = function (a, b, c) { | |
switch (a) { | |
case "albums": | |
return new f(b, c); | |
case "artists": | |
return new m(b, c); | |
case "playlists": | |
return new h(b, | |
c); | |
case "tracks": | |
return new g(b, c); | |
default: | |
return null | |
} | |
}; | |
a.prototype._load = function (a) { | |
var b = this, | |
c = new k; | |
this._itemLoader(a).then(function (d) { | |
c.fulfill({ | |
range: a, | |
items: b._createRows(d.items) | |
}) | |
}, function (a) { | |
c.fail(a) | |
}); | |
return c | |
}; | |
a.prototype._loadLength = function () { | |
var a = this, | |
b = new k, | |
c = new p(0, this._loadLimit); | |
this._itemLoader(c).then(function (c) { | |
var d = a._length = Math.min(c.length, 1E4); | |
a._insertLoadedData({ | |
range: new p(0, Math.min(d, a._loadLimit)), | |
items: a._createRows(c.items) | |
}); | |
b.fulfill({ | |
length: d | |
}) | |
}, function () { | |
var c = | |
a._length = 0; | |
b.fulfill({ | |
length: c | |
}) | |
}); | |
return b | |
}; | |
a.prototype._createRows = function (a) { | |
return a | |
}; | |
a.prototype.isOlderThan = function (a) { | |
return (new Date).getTime() - this._timestamp >= a | |
}; | |
d(f, a); | |
f.prototype._createRows = function (a) { | |
for (var b = 0, c = a.length; b < c; b++) { | |
var d = a[b]; | |
a[b] = new n.SearchAlbum(new Spotify.Link.albumLink(d.id), d) | |
} | |
return a | |
}; | |
d(m, a); | |
m.prototype._createRows = function (a) { | |
for (var b = 0, c = a.length; b < c; b++) { | |
var d = a[b]; | |
a[b] = new n.SearchArtist(new Spotify.Link.artistLink(d.id), d) | |
} | |
return a | |
}; | |
d(h, a); | |
h.prototype._createRows = | |
function (a) { | |
for (var b = 0, d = a.length; b < d; b++) { | |
var f = a[b], | |
g = c.fromString(f.uri); | |
f.owner = g.username; | |
a[b] = new n.SearchPlaylist(g, f) | |
} | |
return a | |
}; | |
d(g, a); | |
g.prototype._createRows = function (a) { | |
for (var b = 0, c = a.length; b < c; b++) { | |
var d = a[b]; | |
a[b] = new n.SearchTrack(new Spotify.Link.trackLink(d.id), d) | |
} | |
return a | |
}; | |
l.exports = { | |
SearchTypes: { | |
ALBUMS: "albums", | |
ARTISTS: "artists", | |
PLAYLISTS: "playlists", | |
TRACKS: "tracks" | |
}, | |
Search: a, | |
SearchAlbums: f, | |
SearchArtists: m, | |
SearchPlaylists: h, | |
SearchTracks: g | |
} | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/sublists.js": function (b, | |
l, f, n, p, r) { | |
b = b("node_modules/spotify-inheritance/extend.js")({}, b("node_modules/spotify-bridge/src/shell/sublists/album.js"), b("node_modules/spotify-bridge/src/shell/sublists/playlist.js"), b("node_modules/spotify-bridge/src/shell/sublists/search.js"), b("node_modules/spotify-bridge/src/shell/sublists/toplist.js"), { | |
Context: b("node_modules/spotify-bridge/src/shell/sublists/context.js"), | |
Decorator: b("node_modules/spotify-bridge/src/shell/sublists/decorator.js"), | |
MetadataDecorator: b("node_modules/spotify-bridge/src/shell/sublists/metadatadecorator.js"), | |
PlaylistTrackDecorator: b("node_modules/spotify-bridge/src/shell/sublists/playlistdecorator.js"), | |
Mappable: b("node_modules/spotify-bridge/src/shell/sublists/mappable.js") | |
}); | |
l.exports = b | |
}, | |
"node_modules/spotify-bridge/src/shell/spirc.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(a, b, c) { | |
this._loadPosition = void 0; | |
this._contextPlayer = b; | |
this._spircService = a; | |
this._itemLoaderFn = c; | |
this._init() | |
} | |
var f = Spotify.Link, | |
m = b("node_modules/spotify-bridge/node_modules/spotify-crypto/index.js").Base62; | |
b("node_modules/spotify-bridge/src/shell/extension.js"); | |
var h = b("node_modules/spotify-bridge/src/shell/lists.js"), | |
g = b("node_modules/spotify-bridge/src/shell/sublists.js"), | |
d = b("node_modules/spotify-promise/src/promise.js"), | |
c = Spotify.Events(); | |
a.prototype._init = function () { | |
var a = this._spircService; | |
a.bind(c.NOTIFICATION, this._handleMessage.bind(this)); | |
a.subscribe(); | |
var b = this._contextPlayer; | |
this._stateChangeListener = stateChangeListener = this._handleStateChange.bind(this); | |
a.bind(c.TOKEN_LOST, function () { | |
b.removeEvent("pause", stateChangeListener) | |
}); | |
b.addEvents({ | |
play: stateChangeListener, | |
positionChanged: stateChangeListener, | |
volumeChange: stateChangeListener | |
}) | |
}; | |
a.prototype._handleMessage = function (a) { | |
var b = this._contextPlayer; | |
a = a.params.message; | |
switch (a.type) { | |
case "kMessageTypePlay": | |
b.resume(); | |
break; | |
case "kMessageTypePause": | |
b.pause(); | |
break; | |
case "kMessageTypePlayPause": | |
b.togglePlay(); | |
break; | |
case "kMessageTypePrev": | |
b.previous(a.type); | |
break; | |
case "kMessageTypeNext": | |
b.next(a.type); | |
break; | |
case "kMessageTypeVolumeDown": | |
case "kMessageTypeVolumeUp": | |
break; | |
case "kMessageTypeLoad": | |
this._handleLoad(a.state); | |
break; | |
case "kMessageTypeReplace": | |
this._handleReplace(a.state); | |
break; | |
case "kMessageTypeSeek": | |
b.seek(a.position); | |
break; | |
case "kMessageTypeVolume": | |
b.setVolume(a.volume / 65535); | |
break; | |
default: | |
console.log("This type is not supported") | |
} | |
}; | |
a.prototype._handleLoad = function (a) { | |
this._spircService.setFrameState({ | |
status: "kPlayStatusLoading" | |
}); | |
this._spircService.notify(); | |
var b = a.context_uri, | |
c = this._loadPosition = a.position_ms, | |
d = a.playing_track_index, | |
l = a.status; | |
a = a.track; | |
for (var m = [], n = 0; n < a.length; n++) m.push(f.fromByteString("track", | |
a[n].gid).toURI()); | |
a = new g.Context(new g.MetadataDecorator(new h.Array(m), this._itemLoaderFn), b); | |
a.setDescriptor(new h.Descriptor.List(b)); | |
b = { | |
index: d, | |
initialOffset: c, | |
offset: 0, | |
duration: -1, | |
pause: "kPlayStatusPause" == l, | |
reason: "spirc", | |
rules: this._contextPlayer.getRuleFor("default") | |
}; | |
this._contextPlayer.play(a, b) | |
}; | |
a.prototype._handleReplace = function (a) { | |
var b = this._contextPlayer.getContextList().getOwner(), | |
c = a.playing_track_index; | |
a = a.track; | |
for (var d = [], l = 0; l < a.length; l++) d.push(f.fromByteString("track", | |
a[l].gid).toURI()); | |
a = new g.MetadataDecorator(new h.Array(d), this._itemLoaderFn); | |
a.setDescriptor(new h.Descriptor.List(b)); | |
c = { | |
index: c + 1, | |
offset: 0, | |
duration: -1, | |
pause: !1, | |
reason: "spirc", | |
rules: this._contextPlayer.getRuleFor("default") | |
}; | |
a = new g.Context(a, b); | |
this._contextPlayer.setContextList(a, c) | |
}; | |
a.prototype._notifyStateChange = function (a) { | |
var b = this._spircService, | |
c = this; | |
d.join(this._contextPlayer.getBaseState(), a.toArray()).thenSpread(function (d, g) { | |
var h = {}; | |
h.context_uri = a.getOwner(); | |
for (var l = [], n = 0, p = | |
g.length; n < p; n++) { | |
var r = g[n].uri.split(":")[2]; | |
l.push({ | |
gid: f.trackLink(m.toHex(r)).idToByteString() | |
}) | |
} | |
h.track = l; | |
h.playing_from_fallback = !0; | |
h.playing_track_index = a.getIndex(); | |
h.position_measured_at = (new Date).getTime(); | |
h.position_ms = "undefined" === typeof c._loadPosition ? d.position : c._loadPosition; | |
c._loadPosition = void 0; | |
h.status = d.playing ? "kPlayStatusPlay" : "kPlayStatusPause"; | |
b.setFrameState(h); | |
b.notify() | |
}) | |
}; | |
a.prototype._notifyVolumeChange = function (a) { | |
var b = this._spircService; | |
b.setDeviceVolume(Math.round(65535 * | |
a)); | |
b.notify() | |
}; | |
a.prototype._handleStateChange = function (a) { | |
switch (a.type) { | |
case "play": | |
this._contextPlayer.addEvent("pause", this._stateChangeListener); | |
case "pause": | |
case "positionChanged": | |
this._notifyStateChange(a.context); | |
break; | |
case "volumeChange": | |
this._notifyVolumeChange(a.volume); | |
break; | |
default: | |
console.log("Event type not supported!") | |
} | |
}; | |
l.exports = a | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/tracklistresolver.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(b, d) { | |
if (!(this instanceof a)) return new a(b, | |
d); | |
this._dispatcher = b; | |
this._listManager = d; | |
this._resolvers = {} | |
} | |
var f = b("node_modules/spotify-bridge/src/shell/lists.js"), | |
m = b("node_modules/spotify-bridge/src/shell/sublists.js"), | |
h = f.Descriptor, | |
g = b("node_modules/spotify-bridge/src/shell/extension.js").LinkHelper, | |
d = b("node_modules/spotify-promise/src/promise.js"); | |
a.prototype._resolveSimpleList = function (a) { | |
var b = new d, | |
l = this._listManager.get(a); | |
if (l) return l.layersListType(m.PlaylistTrackDecorator) && (l = new f.Property(l, "track")), b.fulfill(l), b; | |
if (l = h.extractList(a)) l = | |
g.from(l.uri); | |
else return b.fail(Error("Invalid descriptor")), b; | |
var n = this._resolvers[l.type]; | |
if (n) return n(l, a, this._dispatcher, this._listManager); | |
b.fail(Error("Cannot create list.")); | |
return b | |
}; | |
a.prototype._filterSimpleList = function (a) { | |
if (a.layersListType(m.SearchTracks)) return a; | |
var b = new f.Filtered(a, function (a) { | |
return a && !! a.playable | |
}); | |
return b.snapshot(0, -1).then(function (a) { | |
return b | |
}) | |
}; | |
a.prototype._resolve = function (a, b) { | |
var g; | |
if ("lists" == a.type) { | |
for (var h = [], l = a.lists, m = 0, n = l.length; m < n; m++) g = | |
this._resolveSimpleList(l[m]), b && (g = g.then(this._filterSimpleList)), h.push(g); | |
return d.join(h).then(function (b) { | |
for (var d = [], g = 0, h = b.length; g < h; g++) { | |
var k = b[g]; | |
k && d.push(k) | |
} | |
b = new f.Concatenated(d); | |
b.setDescriptor(a); | |
return b | |
}) | |
} | |
g = this._resolveSimpleList(a); | |
b && (g = g.then(this._filterSimpleList)); | |
return g | |
}; | |
a.prototype.register = function (a, b) { | |
this._resolvers[a] = b; | |
return this | |
}; | |
a.prototype.resolve = function (a) { | |
return this._resolve(a, !0) | |
}; | |
a.prototype.resolveAll = function (a) { | |
return this._resolve(a, !1) | |
}; | |
l.exports = | |
a | |
})() | |
}, | |
"node_modules/spotify-bridge/src/shell/contextplayer.js": function (b, l, f, n, p, r) { | |
(function () { | |
function a(b) { | |
if (!(this instanceof a)) return new a(b); | |
this._audioManager = b; | |
this._stack = []; | |
this._players = {} | |
} | |
function f() { | |
throw new TypeError("ContextList is an interface"); | |
} | |
function m(a, b, c, d, f) { | |
if (!(this instanceof m)) return new m(a, b, c, d, f); | |
if (!b) throw new TypeError("ContextPlayer: Argument `id` cannot be undefined."); | |
if (!a) throw new TypeError("ContextPlayer: Argument `audioManager` cannot be undefined."); | |
t.call(this); | |
this._audioManager = a; | |
this._id = b; | |
this._uriProperty = f || "playableURI"; | |
this._uid = 0; | |
this._player = a.addPlayer(b + ":A"); | |
this._alternatePlayer = a.addPlayer(b + ":B"); | |
this._interceptContextList = c; | |
this._queueContextList = d; | |
this._previousPlayCall = this._currentTrack = this._currentContextOptions = this._currentContextList = null; | |
this._shuffled = this._repeated = this._fakePlayState = !1; | |
this._nextMovement = "next"; | |
this._crossfading = this._crossfade = this._stopped = !1; | |
this._crossfadeAmount = 0; | |
this._crossfadeBuffer = 1E3; | |
this._playingFromQueue = this._playingFromIntercept = !1; | |
this._initEvents(this._player); | |
this._initEvents(this._alternatePlayer) | |
} | |
function h(a, b) { | |
if (!(this instanceof h)) return new h(a, b); | |
this._audioManager = a; | |
this._hasStartLog = !1; | |
this.createStartLog = this.createStartLog.bind(this); | |
this.createEndLog = this.createEndLog.bind(this); | |
b.addEvents({ | |
beforePlay: this.createStartLog, | |
beforeNextTrack: this.createEndLog, | |
beforePreviousTrack: this.createEndLog, | |
contextEnd: this.createEndLog, | |
stopped: this.createEndLog | |
}) | |
} | |
var g = | |
b("node_modules/spotify-inheritance/inherit.js"), | |
d = b("node_modules/spotify-promise/src/promise.js"), | |
c = b("node_modules/spotify-bridge/src/shell/lists.js"), | |
k = b("node_modules/spotify-bridge/src/shell/sublists.js"), | |
n = c.Array, | |
p = k.Context, | |
r = b("node_modules/spotify-bridge/src/shell/extension.js").LinkHelper, | |
t = b("node_modules/spotify-eventemitter/src/eventemitter.js"), | |
v = { | |
CONTEXT_END: "contextEnd", | |
EMPTY: "empty", | |
FORBIDDEN: "forbidden", | |
INVALID: "invalid", | |
NO_CONTEXT: "nonContext", | |
SUCCESS: "success" | |
}, w = { | |
DEFAULT: { | |
skipCount: -1, | |
volume: !0, | |
seek: !0, | |
indexing: !0, | |
previous: !0, | |
next: !0, | |
shuffle: !0, | |
repeat: !0 | |
}, | |
INTERCEPT: { | |
skipcount: -1, | |
volume: !1, | |
seek: !1, | |
indexing: !0, | |
previous: !1, | |
next: !1, | |
shuffle: !1, | |
repeat: !1 | |
}, | |
RADIO: { | |
skipCount: -1, | |
volume: !0, | |
seek: !0, | |
indexing: !0, | |
previous: !1, | |
next: !0, | |
shuffle: !1, | |
repeat: !1 | |
}, | |
DMCA: { | |
skipCount: 6, | |
volume: !0, | |
seek: !0, | |
indexing: !0, | |
previous: !1, | |
next: !0, | |
shuffle: !1, | |
repeat: !1 | |
}, | |
STREAM: { | |
skipcount: -1, | |
volume: !0, | |
seek: !1, | |
indexing: !0, | |
previous: !1, | |
next: !1, | |
shuffle: !1, | |
repeat: !1 | |
} | |
}; | |
a.prototype.create = function (a, b) { | |
var c = this._players; | |
if (c[a]) throw new TypeError('A player with the id "' + | |
a + '" already exists.'); | |
var d = new m(this._audioManager, a, new p(new n([]), "intercept"), new p(new n([]), "queue"), b); | |
d.addEvents({ | |
trackLoaded: this._onTrackLoaded.bind(this), | |
play: this._onPlayerPlay.bind(this), | |
contextEnd: this._onContextStop.bind(this), | |
stop: this._onContextStop.bind(this) | |
}); | |
c[a] = d; | |
new h(this._audioManager, d); | |
return d | |
}; | |
a.prototype.get = function (a) { | |
return this._players[a] || null | |
}; | |
a.prototype._onTrackLoaded = function (a) { | |
var b = a.player; | |
a = this._stack; | |
if (!a.length) return this; | |
var c = a[0]; | |
if (c.player == | |
b) return this; | |
var d = this._audioManager; | |
c.player.getBaseState().then(function (a) { | |
c.state = a; | |
d.crossfade(c.player.getPlayerId(), b.getPlayerId(), 800, function () { | |
c.player.pause(); | |
b.setVolume(1) | |
}) | |
}) | |
}; | |
a.prototype._onPlayerPlay = function (a) { | |
a = a.player; | |
var b = this._stack; | |
b.length && b[0].player == a || b.unshift({ | |
player: a, | |
state: {} | |
}) | |
}; | |
a.prototype._onContextStop = function (a) { | |
a = this._stack; | |
var b = a.shift(); | |
if (a.length) { | |
var c = a[0]; | |
c.state.playing ? (c.player.resume(), this._audioManager.crossfade(b.player.getPlayerId(), c.player.getPlayerId(), | |
800, function () { | |
c.player.setVolume(1) | |
})) : c.player.setVolume(1) | |
} | |
}; | |
f.prototype.getDescriptor = function () {}; | |
f.prototype.getLength = function () {}; | |
f.prototype.getOwner = function () {}; | |
f.prototype.getIndex = function () {}; | |
f.prototype.startAt = function (a) {}; | |
f.prototype.shuffle = function () {}; | |
f.prototype.unshuffle = function () {}; | |
f.prototype.makeInfinite = function () {}; | |
f.prototype.makeFinite = function () {}; | |
f.prototype.next = function () {}; | |
f.prototype.previous = function () {}; | |
f.prototype.toArray = function () {}; | |
g(m, t); | |
m.prototype._initEvents = | |
function (a) { | |
a.bind("PLAYING", this._handlePlay.bind(this)); | |
a.bind("PAUSED", this._handlePause.bind(this)); | |
a.bind("TRACK_ENDED", this._handleEnded.bind(this)); | |
a.bind("CANNOT_PLAY_TRACK", this._handleInvalid.bind(this)); | |
a.bind("PLAYBACK_FAILED", this._handleInvalid.bind(this)); | |
a.bind("INVALID_TRACK_URI", this._handleInvalid.bind(this)); | |
a.bind("BEFORE_END", this._handleBeforeEnded.bind(this)); | |
a.bind("POSITION_CHANGED", this._handlePositionChange.bind(this)) | |
}; | |
m.prototype._handlePlay = function (a) { | |
a = "number" == typeof a.params ? | |
a.params : 0; | |
this._fakePlayState = !1; | |
this.fireEvent("play", { | |
type: "play", | |
player: this, | |
track: this._currentTrack, | |
position: a, | |
context: this._currentContextList, | |
options: this._currentContextOptions | |
}) | |
}; | |
m.prototype._handlePause = function (a) { | |
this.fireEvent("pause", { | |
type: "pause", | |
player: this, | |
track: this._currentTrack, | |
position: "number" == typeof a.params ? a.params : 0, | |
context: this._currentContextList, | |
options: this._currentContextOptions | |
}) | |
}; | |
m.prototype._handleEnded = function (a) { | |
this.fireEvent("playEnd", { | |
type: "playEnd", | |
player: this, | |
View raw
(Sorry about that, but we can’t show files that are this big right now.)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment