0% found this document useful (0 votes)
6K views13 pages

Js

The document defines functions and classes for a module that provides search and discovery capabilities. It includes classes for Services, Applications, Channels, and a Search class. Functions are defined to get services locally or by URI, search for services, and define event emitter functionality.

Uploaded by

Max Mustermann
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6K views13 pages

Js

The document defines functions and classes for a module that provides search and discovery capabilities. It includes classes for Services, Applications, Channels, and a Search class. Functions are defined to get services locally or by URI, search for services, and define event emitter functionality.

Uploaded by

Max Mustermann
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 13

var msf = function(modules) {

function __webpack_require__(moduleId) {
if (installedModules[moduleId]) return installedModules[moduleId].exports;
var module = installedModules[moduleId] = {
exports: {},
id: moduleId,
loaded: !1
};
return modules[moduleId].call(module.exports, module, module.exports,
__webpack_require__), module.loaded = !0, module.exports
}
var installedModules = {};
return __webpack_require__.m = modules, __webpack_require__.c =
installedModules, __webpack_require__.p = "", __webpack_require__(0)
}([function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_RESULT__, msf = __webpack_require__(1);
msf.version = "{{version}}", __WEBPACK_AMD_DEFINE_RESULT__ = function() {
return msf
}.call(exports, __webpack_require__, exports, module), !(void 0 !==
__WEBPACK_AMD_DEFINE_RESULT__ && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)),
module.exports = msf
}, function(module, exports, __webpack_require__) {
"use strict";
var util = __webpack_require__(5),
Service = (__webpack_require__(2), __webpack_require__(3)),
Search = __webpack_require__(4),
search = null;
module.exports.logger = util.logger, module.exports.search = function(callback)
{
return search || (search = new Search), callback && (search.once("found",
function(services) {
callback(null, services)
}), setTimeout(function() {
search.start()
}, 0)), search
}, module.exports.local = function(callback) {
Service.getLocal(callback)
}, module.exports.remote = function(uri, callback) {
Service.getByURI(uri, callback)
}
}, function(module) {
"use strict";

function EventEmitter() {
this._events = this._events || {}, this._maxListeners = this._maxListeners
|| void 0
}

function isFunction(arg) {
return "function" == typeof arg
}

function isNumber(arg) {
return "number" == typeof arg
}

function isObject(arg) {
return "object" == typeof arg && null !== arg
}
function isUndefined(arg) {
return void 0 === arg
}
module.exports = EventEmitter, EventEmitter.EventEmitter = EventEmitter,
EventEmitter.prototype._disabledEvents = {}, EventEmitter.prototype._events = void
0, EventEmitter.prototype._maxListeners = void 0, EventEmitter.defaultMaxListeners
= 10, EventEmitter.prototype.setMaxListeners = function(n) {
if (!isNumber(n) || 0 > n || isNaN(n)) throw TypeError("n must be a
positive number");
return this._maxListeners = n, this
}, EventEmitter.prototype.emit = function(type) {
var er, handler, len, args, i, listeners;
if (this._events || (this._events = {}), this._disabledEvents[type]) return
!1;
if ("error" === type && (!this._events.error ||
isObject(this._events.error) && !this._events.error.length)) {
if (er = arguments[1], er instanceof Error) throw er;
throw TypeError('Uncaught, unspecified "error" event.')
}
if (handler = this._events[type], isUndefined(handler)) return !1;
if (isFunction(handler)) switch (arguments.length) {
case 1:
handler.call(this);
break;
case 2:
handler.call(this, arguments[1]);
break;
case 3:
handler.call(this, arguments[1], arguments[2]);
break;
default:
for (len = arguments.length, args = new Array(len - 1), i = 1; len
> i; i++) args[i - 1] = arguments[i];
handler.apply(this, args)
} else if (isObject(handler)) {
for (len = arguments.length, args = new Array(len - 1), i = 1; len > i;
i++) args[i - 1] = arguments[i];
for (listeners = handler.slice(), len = listeners.length, i = 0; len >
i; i++) {
var r = listeners[i].apply(this, args);
if ("stopEvent" === r) break
}
}
return !0
}, EventEmitter.prototype.addListener = function(type, listener) {
var m;
if (!isFunction(listener)) throw TypeError("listener must be a function");
if (this._events || (this._events = {}), this._events.newListener &&
this.emit("newListener", type, isFunction(listener.listener) ? listener.listener :
listener), this._events[type] ? isObject(this._events[type]) ?
this._events[type].push(listener) : this._events[type] = [this._events[type],
listener] : this._events[type] = listener, isObject(this._events[type]) && !
this._events[type].warned) {
var m;
m = isUndefined(this._maxListeners) ?
EventEmitter.defaultMaxListeners : this._maxListeners, m && m > 0 &&
this._events[type].length > m && (this._events[type].warned = !0,
console.error("(node) warning: possible EventEmitter memory leak detected. %d
listeners added. Use emitter.setMaxListeners() to increase limit.",
this._events[type].length), "function" == typeof console.trace && console.trace())
}
return this
}, EventEmitter.prototype.on = function() {
EventEmitter.prototype.addListener.apply(this, arguments)
}, EventEmitter.prototype.once = function(type, listener) {
function g() {
this.removeListener(type, g), fired || (fired = !0,
listener.apply(this, arguments))
}
if (!isFunction(listener)) throw TypeError("listener must be a function");
var fired = !1;
return g.listener = listener, this.on(type, g), this
}, EventEmitter.prototype.removeListener = function(type, listener) {
var list, position, length, i;
if (!isFunction(listener)) throw TypeError("listener must be a function");
if (!this._events || !this._events[type]) return this;
if (list = this._events[type], length = list.length, position = -1, list
=== listener || isFunction(list.listener) && list.listener === listener) delete
this._events[type], this._events.removeListener && this.emit("removeListener",
type, listener);
else if (isObject(list)) {
for (i = length; i-- > 0;)
if (list[i] === listener || list[i].listener && list[i].listener
=== listener) {
position = i;
break
}
if (0 > position) return this;
1 === list.length ? (list.length = 0, delete this._events[type]) :
list.splice(position, 1), this._events.removeListener &&
this.emit("removeListener", type, listener)
}
return this
}, EventEmitter.prototype.off = function() {
EventEmitter.prototype.removeListener.apply(this, arguments)
}, EventEmitter.prototype.removeAllListeners = function(type) {
var key, listeners;
if (!this._events) return this;
if (!this._events.removeListener) return 0 === arguments.length ?
this._events = {} : this._events[type] && delete this._events[type], this;
if (0 === arguments.length) {
for (key in this._events) "removeListener" !== key &&
this.removeAllListeners(key);
return this.removeAllListeners("removeListener"), this._events = {},
this
}
if (listeners = this._events[type], isFunction(listeners))
this.removeListener(type, listeners);
else
for (; listeners.length;) this.removeListener(type,
listeners[listeners.length - 1]);
return delete this._events[type], this
}, EventEmitter.prototype.listeners = function(type) {
var ret;
return ret = this._events && this._events[type] ?
isFunction(this._events[type]) ? [this._events[type]] :
this._events[type].slice() : []
}, EventEmitter.prototype.disableEvent = function(type) {
type && "string" == typeof type && (this._disabledEvents[type] = !0)
}, EventEmitter.prototype.enableEvent = function(type) {
type && "string" == typeof type && delete this._disabledEvents[type]
}, EventEmitter.listenerCount = function(emitter, type) {
var ret;
return ret = emitter._events && emitter._events[type] ?
isFunction(emitter._events[type]) ? 1 : emitter._events[type].length : 0
}
}, function(module, exports, __webpack_require__) {
"use strict";

function Service(description) {
this.id = description.id, this.name = description.name, this.version =
description.version, this.type = description.type, this.uri = description.uri,
this.device = description.device, props.readOnly(this, ["id", "name", "version",
"type", "uri", "device"])
}
var util = __webpack_require__(5),
props = util.props,
Application = __webpack_require__(6),
Channel = __webpack_require__(7);
Service.prototype.application = function(id, channelUri) {
return new Application(this, id, channelUri)
}, Service.prototype.channel = function(uri) {
return new Channel(this, uri)
}, Service.getLocal = function(callback) {
Service.getByURI("http://127.0.0.1:8001/api/v2/", callback)
}, Service.getByURI = function(uri, callback) {
var oReq = new XMLHttpRequest;
oReq.timeout = 5e3, oReq.ontimeout = function() {
callback()
}, oReq.onload = function() {
if (200 === this.status) try {
var result = JSON.parse(this.responseText);
callback(null, new Service(result))
} catch (e) {
callback(e)
} else callback()
}, oReq.open("get", uri, !0), oReq.send()
}, module.exports = Service
}, function(module, exports, __webpack_require__) {
"use strict";

function Search() {
Search.super_.call(this), this.discoveryFrame = null, this.status =
Search.STATUS_STOPPED;
var self = this,
frame = document.createElement("iframe");
frame.setAttribute("width", "1"), frame.setAttribute("height", "1"),
frame.style.display = "none", frame.src =
"http://multiscreen.samsung.com/discoveryservice/v2/discover",
document.body.appendChild(frame), this.windowMessageListener = function(event) {
if (event.source === frame.contentWindow)
if (event.data && "discovery.ready" === event.data.event)
self.discoveryFrame = event.source, self.onSearchReady();
else if (event.data && "discovery.result" === event.data.event) {
for (var results = [], Service = __webpack_require__(3), i = 0; i <
event.data.result.length; i++) results.push(new Service(event.data.result[i]));
self.onSearchResult(results)
} else event.data && "discovery.error" === event.data.event &&
(self.onSearchError(event.data.error), this.status = Search.STATUS_STOPPED)
}, window.addEventListener("message", this.windowMessageListener),
props["private"](this, ["discoveryFrame", "windowMessageListener"])
}
var util = __webpack_require__(5),
props = util.props,
EventEmitter = __webpack_require__(2);
util.inherits(Search, EventEmitter), Search.STATUS_STOPPED = "stopped",
Search.STATUS_STARTED = "started", Search.prototype.start = function() {
if (this.status === Search.STATUS_STOPPED) {
if (this.discoveryFrame) this.discoveryFrame.postMessage({
method: "discovery.search"
}, "*");
else {
var self = this;
this.once("ready", function() {
self.discoveryFrame.postMessage({
method: "discovery.search"
}, "*")
})
}
this.onSearchStart()
} else console.warn("a previous search is already in progress")
}, Search.prototype.stop = function() {
this.onSearchStop()
}, Search.prototype.onSearchReady = function() {
this.emit("ready")
}, Search.prototype.onSearchResult = function(results) {
this.status !== Search.STATUS_STOPPED && this.emit("found", results),
this.status = Search.STATUS_STOPPED
}, Search.prototype.onSearchError = function(error) {
this.emit("error", error), this.status = Search.STATUS_STOPPED
}, Search.prototype.onSearchStart = function() {
this.status = Search.STATUS_STARTED, this.emit("start", this)
}, Search.prototype.onSearchStop = function() {
this.status = Search.STATUS_STOPPED, this.emit("stop", this)
}, module.exports = Search
}, function(module, exports, __webpack_require__) {
module.exports = {
logger: __webpack_require__(8),
url: __webpack_require__(9),
inherits: __webpack_require__(10),
props: __webpack_require__(11),
types: __webpack_require__(12),
queryString: __webpack_require__(13)
}
}, function(module, exports, __webpack_require__) {
"use strict";

function Application(service, id, channelURI) {


if (!types.isObject(service)) throw new TypeError("service must be of type
Service");
if (!types.isString(id)) throw new TypeError("id must be a valid string");
if (!types.isString(channelURI)) throw new TypeError("channelId must be a
valid string");
this.type = id.match(/(file:\/\/|http(s)?:\/\/)/gim) ? TYPE_WEB_APP :
TYPE_APP, Application.super_.call(this, service, channelURI), this.id = id,
this.service = service, this.on("clientDisconnect", function(client) {
client.isHost && this.disconnect()
}.bind(this)), this.disableEvent("connect"), props.readOnly(this, "id"),
props["private"](this, "type", "service")
}
var util = __webpack_require__(5),
logger = util.logger,
types = util.types,
props = util.props,
Channel = __webpack_require__(7),
TYPE_APP = "applications",
TYPE_WEB_APP = "webapplication";
util.inherits(Application, Channel), Application.prototype.connect =
function(attributes, callback) {
if (!types.isObject(attributes)) throw new TypeError("attributes must be a
valid object");
if (!types.isFunction(callback)) throw new TypeError("callback must be a
valid function");
this.start(function(err) {
return err ? callback(err) : void Channel.prototype.connect.call(this,
attributes, function(err, client) {
if (err) return callback(err);
this.connected = !1;
var readyHandler = function() {
this.connected = !0, callback &&
(logger.debug("application.connect->callback", null, client), callback(null,
client)), logger.debug('application.emit("connect")', client),
this.enableEvent("connect"), this.emit("connect", client),
this.disableEvent("connect")
}.bind(this);
this.once("ready", readyHandler)
}.bind(this))
}.bind(this))
}, Application.prototype.disconnect = function(exitOnRemote, callback) {
if (types.isFunction(exitOnRemote) && (callback = exitOnRemote,
exitOnRemote = !0), types.isUndefined(exitOnRemote) && (exitOnRemote = !0),
exitOnRemote && this.clients.length <= 2) {
var stopCallback = function() {
Channel.prototype.disconnect.call(this, callback)
}.bind(this);
"webapplication" === this.type ? this.invoke("ms.webapplication.stop",
{
url: this.id
}, stopCallback) : this.invoke("ms.application.stop", {
id: this.id
}, stopCallback)
} else Channel.prototype.disconnect.call(this, callback)
}, Application.prototype.install = function(callback) {
if (this.type === TYPE_WEB_APP) return callback(new Error("web application
cannot be installed"));
var e, req = new XMLHttpRequest;
req.timeout = 1e4, req.ontimeout = function() {
e = new Error("Request Timeout"), e.code = 408, callback(e)
}, req.onload = function() {
200 === this.status ? callback(null, !0) : (e = new
Error(this.statusText), e.code = this.status, callback(e))
}, req.open("get", this.service.uri + "applications/" + this.id, !0),
req.send()
}, Application.prototype.start = function(callback) {
var e, req = new XMLHttpRequest;
req.timeout = 1e4, req.ontimeout = function() {
e = new Error("Request Timeout"), e.code = 408, callback(e)
}, req.onload = function() {
200 === this.status ? callback(null, !0) : (e = new
Error(this.statusText), e.code = this.status, callback(e))
}, this.type === TYPE_WEB_APP ? (req.open("post", this.service.uri +
"webapplication/", !0), req.setRequestHeader("Content-Type",
"application/json;charset=UTF-8"), req.send(JSON.stringify({
url: this.id
}))) : (req.open("post", this.service.uri + "applications/" + this.id, !0),
req.setRequestHeader("Content-Type", "application/json;charset=UTF-8"),
req.send(JSON.stringify({})))
}, module.exports = Application
}, function(module, exports, __webpack_require__) {
"use strict";

function Channel(service, uri) {


if (logger.debug("new Channel", arguments), !types.isObject(service)) throw
new TypeError("service must be of type Service");
if (!types.isString(uri)) throw new TypeError("uri must be a valid
string");
Channel.super_.call(this);
var self = this,
oServiceUrl = util.url.parse(service.uri);
this.connected = !1, this.clientId = null, this.connection = null,
this.resultHandlers = {}, this.connectionUrl = "ws://" + oServiceUrl.host +
oServiceUrl.pathname + "channels/" + uri, this.pingTimeout = null,
this.pingInterval = null, this.clients = new ClientList(this),
Object.defineProperty(this, "isConnected", {
get: function() {
return self.connected
}
}), Object.defineProperty(this, "connectionTimeout", {
set: function(timeout) {
logger.debug("updating connection timeout ", timeout),
self.pingTimeout = timeout > 0 ? timeout : 0, this.isConnected &&
self.startHealthCheck()
},
get: function() {
return self.pingTimeout
}
}), this.on("connect", this.startHealthCheck), this.on("disconnect",
this.stopHealthCheck), props.readOnly(this, ["clients"]), props["private"](this,
["connected", "clientId", "connection", "resultHandlers", "connectionUrl",
"connectCallback", "pingInterval", "pingTimeout", "lastPingReceived"])
}
var util = __webpack_require__(5),
logger = util.logger,
types = util.types,
props = util.props,
EventEmitter = __webpack_require__(2),
Client = __webpack_require__(14),
ClientList = __webpack_require__(15),
EVENT_HEALTH_CHECK = "__ping";
util.inherits(Channel, EventEmitter), Channel.prototype.connect =
function(attributes, callback) {
if (logger.debug("channel.connect", arguments), this.isConnected) return
console.warn("Channel is already connected.");
if (types.isFunction(attributes) && !callback ? (callback = attributes,
attributes = {}) : attributes = attributes || {}, !types.isObject(attributes))
throw new TypeError("attributes must be a valid object");
if (callback && !types.isFunction(callback)) throw new TypeError("callback
must be a valid function");
this.connectCallback = callback;
var u = this.connectionUrl + "?" + util.queryString.stringify(attributes);
this.connection && (this.connection.onopen = null, this.connection.onerror
= null, this.connection.onclose = null, this.connection.onmessage = null),
this.connection = new WebSocket(u), this.connection.binaryType = "arraybuffer",
this.connection.onopen = this._onSocketOpen.bind(this), this.connection.onerror =
this._onSocketError.bind(this), this.connection.onclose =
this._onSocketClose.bind(this), this.connection.onmessage =
this._onSocketMessage.bind(this)
}, Channel.prototype.disconnect = function(callback) {
logger.debug("channel.disconnect", arguments), this.isConnected ||
console.warn("channel is already disconnected"), this.connection.close();
var self = this;
setTimeout(function() {
callback && callback(null, self)
}, 0)
}, Channel.prototype.publish = function(event, message, target, payload) {
if (logger.silly("channel.publish", arguments), !this.isConnected) return
console.warn("Channel is not connected.");
if (target = target || "broadcast", message = message || null, !
types.isString(event)) throw new TypeError("event must be a valid string");
if (!types.isString(target) && !types.isArray(target)) throw new
TypeError("targets must be a valid string or array");
this.invoke("ms.channel.emit", {
event: event,
data: message,
to: target
}, null, !0, payload)
}, Channel.packMessage = function(oMsg, payload) {
logger.debug("channel.packMessage", arguments);
var msg = JSON.stringify(oMsg),
msgByteLength = new Blob([msg]).size,
hBuff = new ArrayBuffer(2),
hView = new DataView(hBuff);
return hView.setUint16(0, msgByteLength), new Blob([hBuff, msg, payload])
}, Channel.unpackMessage = function(buffer) {
logger.debug("channel.unpackMessage", arguments);
for (var json = "", view = new DataView(buffer), msgByteLen =
view.getUint16(0), i = 0; msgByteLen > i; i++) json +=
String.fromCharCode(view.getUint8(i + 2));
var payload = buffer.slice(2 + msgByteLen),
message = JSON.parse(json);
return {
payload: payload,
message: message
}
}, Channel.prototype.invoke = function(method, params, callback,
isNotification, payload) {
if (logger.debug("channel.invoke", arguments), !types.isString(method))
throw new TypeError("method must be a valid string");
params = params || {};
var msg = {
method: method,
params: params
};
callback && !isNotification && (msg.id = Date.now(),
this.resultHandlers[msg.id] = callback), msg = payload ? Channel.packMessage(msg,
payload) : JSON.stringify(msg), this.connection.send(msg)
}, Channel.prototype._onConnect = function(data) {
logger.silly("channel._onConnect"), this.connected = !0, this.clientId =
data.id, data.clients.forEach(function(clientInfo) {
var client = new Client(clientInfo.id, clientInfo.attributes,
clientInfo.isHost);
this.clients.push(client)
}, this), this.connectCallback && (logger.debug("channel.connect-
>callback", this.clients.me), this.connectCallback(null, this.clients.me),
this.connectCallback = null), logger.debug('channel.emit("connect")',
this.clients.me), this.emit("connect", this.clients.me)
}, Channel.prototype._onDisconnect = function() {
if (logger.silly("channel._onDisconnect"), this.connected) {
var client = this.clients.me;
this.clients.clear(), logger.debug('channel.emit("disconnect")',
client), this.emit("disconnect", client)
}
this.connected = !1
}, Channel.prototype._onClientConnect = function(data) {
logger.silly("channel._onClientConnect");
var client = new Client(data.id, data.attributes, data.isHost);
this.clients.push(client), logger.debug('channel.emit("clientConnect")',
client), this.emit("clientConnect", client)
}, Channel.prototype._onClientDisconnect = function(data) {
logger.silly("channel._onClientDisconnect");
var client = this.clients.getById(data.id);
client ? this.clients.remove(client) : (logger.warn("client " + data.id + "
could not be found, so it was not removed from the client list"), client = new
Client(data.id, data.attributes, data.isHost)),
logger.debug('channel.emit("clientDisconnect")', client),
this.emit("clientDisconnect", client)
}, Channel.prototype._onReady = function() {
logger.debug('channel.emit("ready")'), this.emit("ready")
}, Channel.prototype._onUserEvent = function(msg) {
var client = this.clients.getById(msg.from),
event = msg.event,
data = msg.data,
payload = msg.payload;
logger.debug('channel.emit("' + event + '")', data, client, payload),
this.emit(event, data, client, payload)
}, Channel.prototype._onSocketOpen = function() {
logger.silly("channel._onSocketOpen")
}, Channel.prototype._onSocketClose = function() {
logger.silly("channel._onSocketClose"), this._onDisconnect()
}, Channel.prototype._onSocketError = function(e) {
logger.silly("channel._onSocketError", e), this.emit("error", new
Error("WebSocket error"))
}, Channel.prototype._onSocketMessage = function(msg) {
logger.silly("channel._onSocketMessage", msg);
try {
if ("string" == typeof msg.data) msg = JSON.parse(msg.data);
else {
var unpacked = Channel.unpackMessage(msg.data);
msg = unpacked.message, msg.payload = unpacked.payload
}
} catch (e) {
return void logger.warn("unable to parse message", msg)
}
if (msg.id && (msg.result || msg.error)) {
if (!this.resultHandlers[msg.id]) return void logger.warn("unable to
find result handler for result message ", msg);
this.resultHandlers[msg.id](msg.error, msg.result)
} else if (msg.event) switch (msg.event) {
case "ms.channel.connect":
this._onConnect(msg.data);
break;
case "ms.channel.clientConnect":
this._onClientConnect(msg.data);
break;
case "ms.channel.clientDisconnect":
this._onClientDisconnect(msg.data);
break;
case "ms.channel.ready":
this._onReady(msg.data);
break;
default:
this._onUserEvent(msg)
} else logger.warn("unrecognized message type", msg)
}, Channel.prototype.startHealthCheck = function() {
if (this.stopHealthCheck(), this.pingTimeout > 0) {
var lastReceivedPing = null;
this.on(EVENT_HEALTH_CHECK, function(sent) {
lastReceivedPing = Date.now(), logger.debug("ping trip : ",
lastReceivedPing - sent), logger.debug("updated last ping time : ",
lastReceivedPing)
});
var checkAndPing = function() {
var now = Date.now();
lastReceivedPing || (lastReceivedPing = now), now -
lastReceivedPing < this.pingTimeout ? (logger.debug("sending ping"),
this.publish(EVENT_HEALTH_CHECK, now, this.clients.me.id)) : (logger.debug("ping
timed, out closing connection"), this.stopHealthCheck(), this.connection &&
(this.connection.close(), this._onDisconnect()))
}.bind(this);
this.pingInterval = setInterval(checkAndPing, this.pingTimeout)
}
}, Channel.prototype.stopHealthCheck = function() {
clearInterval(this.pingInterval),
this.removeAllListeners(EVENT_HEALTH_CHECK)
}, module.exports = Channel
}, function(module) {
"use strict";

function createLevel(level) {
return function() {
var args = Array.prototype.slice.call(arguments);
args.unshift(level), logger.log.apply(logger, args)
}
}
for (var levels = ["error", "warn", "info", "verbose", "debug", "silly"],
logger = {
level: "disabled",
log: function(level) {
if ("disabled" !== logger.level && levels.indexOf(level) <=
levels.indexOf(logger.level)) {
var args = Array.prototype.slice.call(arguments, 1);
args.unshift("[MSF:" + level.toUpperCase() + "]"),
console[level] ? console[level].apply(console, args) : console.log.apply(console,
args)
}
}
}, i = 0; i < levels.length; i++) {
var level = levels[i];
logger[level] = createLevel(level)
}
module.exports = logger
}, function(module, exports, __webpack_require__) {
"use strict";
var queryString = __webpack_require__(13),
url = {
isValid: function(u) {
var pattern = /^(?:([A-Za-z]+):)?(\/{0,3})([0-9.\-A-Za-z]+)(?::
(\d+))?(?:\/([^?#]*))?(?:\?([^#]*))?(?:#(.*))?$/;
return u.match(pattern) ? !0 : !1
},
parse: function(u) {
var oUrl = {},
parser = document.createElement("a");
return parser.href = u, oUrl.href = parser.href, oUrl.protocol =
parser.protocol, oUrl.hostname = parser.hostname, oUrl.port = parser.port,
oUrl.pathname = parser.pathname, oUrl.search = parser.search, oUrl.hash =
parser.hash, oUrl.host = parser.host, oUrl.queryString =
queryString.parse(parser.search), oUrl
}
};
module.exports = url
}, function(module) {
"use strict";
module.exports = "function" == typeof Object.create ? function(ctor, superCtor)
{
ctor.super_ = superCtor, ctor.prototype =
Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: !1,
writable: !0,
configurable: !0
}
})
} : function(ctor, superCtor) {
ctor.super_ = superCtor;
var TempCtor = function() {};
TempCtor.prototype = superCtor.prototype, ctor.prototype = new TempCtor,
ctor.prototype.constructor = ctor
}
}, function(module) {
"use strict";

function createDescriptor(e, c, w, v) {
return {
enumerable: e,
configurable: c,
writable: w,
value: v
}
}
module.exports = {
readOnly: function(obj, key) {
Array.isArray(key) ? key.forEach(function(k) {
Object.defineProperty(obj, k, createDescriptor(!0, !0, !1, obj[k]))
}) : Object.defineProperty(obj, key, createDescriptor(!0, !0, !1,
obj[key]))
},
"private": function(obj, key) {
Array.isArray(key) ? key.forEach(function(k) {
Object.defineProperty(obj, k, createDescriptor(!1, !0, !0, obj[k]))
}) : Object.defineProperty(obj, key, createDescriptor(!1, !0, !0,
obj[key]))
}
}
}, function(module) {
"use strict";
module.exports = {
isString: function(obj) {
return "string" == typeof obj
},
isNull: function(obj) {
return null === obj
},
isBoolean: function(obj) {
return "boolean" == typeof obj
},
isNumber: function(obj) {
return "number" == typeof obj
},
isObject: function(obj) {
return obj === Object(obj)
},
isArray: function(obj) {
return obj.constructor === Array
},
isFunction: function(obj) {
return "function" == typeof obj
},
isUndefined: function(obj) {
return "undefined" == typeof obj
}
}
}, function(module) {
"use strict";
/*!
query-string
Parse and stringify URL query strings
https://github.com/sindresorhus/query-string
by Sindre Sorhus
MIT License
*/
var queryString = {};
queryString.parse = function(str) {
return "string" != typeof str ? {} : (str = str.trim().replace(/^(\?|#)/,
""), str ? str.trim().split("&").reduce(function(ret, param) {
var parts = param.replace(/\+/g, " ").split("="),
key = parts[0],
val = parts[1];
return key = decodeURIComponent(key), val = void 0 === val ? null :
decodeURIComponent(val), ret.hasOwnProperty(key) ? Array.isArray(ret[key]) ?
ret[key].push(val) : ret[key] = [ret[key], val] : ret[key] = val, ret
}, {}) : {})
}, queryString.stringify = function(obj) {
return obj ? Object.keys(obj).map(function(key) {
var val = obj[key];
return Array.isArray(val) ? val.map(function(val2) {
return encodeURIComponent(key) + "=" + encodeURIComponent(val2)
}).join("&") : encodeURIComponent(key) + "=" + encodeURIComponent(val)
}).join("&") : ""
}, module.exports = queryString
}, function(module, exports, __webpack_require__) {
"use strict";

function Client(id, attributes, isHost, connectTime) {


if (!types.isString(id)) throw new TypeError("id must be a valid string");
if (attributes && !types.isObject(attributes)) throw new
TypeError("attributes must be a valid object");
this.id = id, this.attributes = attributes || {}, this.isHost = isHost,
this.connectTime = connectTime || Date.now(), Object.freeze(this.attributes),
Object.freeze(this)
}
var util = __webpack_require__(5),
types = util.types;
module.exports = Client
}, function(module, exports, __webpack_require__) {
"use strict";

function ClientList(channel) {
if (!types.isObject(channel)) throw new TypeError("channel must be of type
Channel");
this.channel = channel, ClientList.super_.call(this)
}
var util = __webpack_require__(5),
types = util.types;
util.inherits(ClientList, Array), Object.defineProperty(ClientList.prototype,
"me", {
get: function() {
return this.getById(this.channel.clientId)
}
}), ClientList.prototype.clear = function() {
this.length = 0
}, ClientList.prototype.remove = function(item) {
var i = this.indexOf(item);
return -1 !== i ? (this.splice(i, 1), item) : null
}, ClientList.prototype.getById = function(id) {
if (!types.isString(id) && !types.isNumber(id)) throw new TypeError("id
must be a valid string or number");
for (var i = 0; i < this.length; i++)
if (this[i].id === id) return this[i];
return null
}, module.exports = ClientList
}]);
//# sourceMappingURL=msf-2.0.21.min.js.map

You might also like