beam-interactive-node2
Version:
A NodeJS and Browser compatible client for mixer.com's interactive 2 Protocol
1,507 lines (1,370 loc) • 356 kB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["interactive"] = factory();
else
root["interactive"] = factory();
})(this, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // identity function for calling harmony imports with the correct context
/******/ __webpack_require__.i = function(value) { return value; };
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 38);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports) {
var g;
// This works in non-strict mode
g = (function() {
return this;
})();
try {
// This works if eval is allowed (see CSP)
g = g || Function("return this")() || (1,eval)("this");
} catch(e) {
// This works if the window reference is available
if(typeof window === "object")
g = window;
}
// g can still be undefined, but nothing to do about it...
// We return undefined, instead of nothing here, so it's
// easier to handle this case. if(!global) { ...}
module.exports = g;
/***/ }),
/* 1 */
/***/ (function(module, exports) {
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
function EventEmitter() {
this._events = this._events || {};
this._maxListeners = this._maxListeners || undefined;
}
module.exports = EventEmitter;
// Backwards-compat with node 0.10.x
EventEmitter.EventEmitter = EventEmitter;
EventEmitter.prototype._events = undefined;
EventEmitter.prototype._maxListeners = undefined;
// By default EventEmitters will print a warning if more than 10 listeners are
// added to it. This is a useful default which helps finding memory leaks.
EventEmitter.defaultMaxListeners = 10;
// Obviously not all Emitters should be limited to 10. This function allows
// that to be increased. Set to zero for unlimited.
EventEmitter.prototype.setMaxListeners = function(n) {
if (!isNumber(n) || n < 0 || isNaN(n))
throw TypeError('n must be a positive number');
this._maxListeners = n;
return this;
};
EventEmitter.prototype.emit = function(type) {
var er, handler, len, args, i, listeners;
if (!this._events)
this._events = {};
// If there is no 'error' event listener then throw.
if (type === 'error') {
if (!this._events.error ||
(isObject(this._events.error) && !this._events.error.length)) {
er = arguments[1];
if (er instanceof Error) {
throw er; // Unhandled 'error' event
} else {
// At least give some kind of context to the user
var err = new Error('Uncaught, unspecified "error" event. (' + er + ')');
err.context = er;
throw err;
}
}
}
handler = this._events[type];
if (isUndefined(handler))
return false;
if (isFunction(handler)) {
switch (arguments.length) {
// fast cases
case 1:
handler.call(this);
break;
case 2:
handler.call(this, arguments[1]);
break;
case 3:
handler.call(this, arguments[1], arguments[2]);
break;
// slower
default:
args = Array.prototype.slice.call(arguments, 1);
handler.apply(this, args);
}
} else if (isObject(handler)) {
args = Array.prototype.slice.call(arguments, 1);
listeners = handler.slice();
len = listeners.length;
for (i = 0; i < len; i++)
listeners[i].apply(this, args);
}
return true;
};
EventEmitter.prototype.addListener = function(type, listener) {
var m;
if (!isFunction(listener))
throw TypeError('listener must be a function');
if (!this._events)
this._events = {};
// To avoid recursion in the case that type === "newListener"! Before
// adding it to the listeners, first emit "newListener".
if (this._events.newListener)
this.emit('newListener', type,
isFunction(listener.listener) ?
listener.listener : listener);
if (!this._events[type])
// Optimize the case of one listener. Don't need the extra array object.
this._events[type] = listener;
else if (isObject(this._events[type]))
// If we've already got an array, just append.
this._events[type].push(listener);
else
// Adding the second element, need to change to array.
this._events[type] = [this._events[type], listener];
// Check for listener leak
if (isObject(this._events[type]) && !this._events[type].warned) {
if (!isUndefined(this._maxListeners)) {
m = this._maxListeners;
} else {
m = EventEmitter.defaultMaxListeners;
}
if (m && m > 0 && this._events[type].length > m) {
this._events[type].warned = true;
console.error('(node) warning: possible EventEmitter memory ' +
'leak detected. %d listeners added. ' +
'Use emitter.setMaxListeners() to increase limit.',
this._events[type].length);
if (typeof console.trace === 'function') {
// not supported in IE 10
console.trace();
}
}
}
return this;
};
EventEmitter.prototype.on = EventEmitter.prototype.addListener;
EventEmitter.prototype.once = function(type, listener) {
if (!isFunction(listener))
throw TypeError('listener must be a function');
var fired = false;
function g() {
this.removeListener(type, g);
if (!fired) {
fired = true;
listener.apply(this, arguments);
}
}
g.listener = listener;
this.on(type, g);
return this;
};
// emits a 'removeListener' event iff the listener was removed
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;
list = this._events[type];
length = list.length;
position = -1;
if (list === listener ||
(isFunction(list.listener) && list.listener === listener)) {
delete this._events[type];
if (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 (position < 0)
return this;
if (list.length === 1) {
list.length = 0;
delete this._events[type];
} else {
list.splice(position, 1);
}
if (this._events.removeListener)
this.emit('removeListener', type, listener);
}
return this;
};
EventEmitter.prototype.removeAllListeners = function(type) {
var key, listeners;
if (!this._events)
return this;
// not listening for removeListener, no need to emit
if (!this._events.removeListener) {
if (arguments.length === 0)
this._events = {};
else if (this._events[type])
delete this._events[type];
return this;
}
// emit removeListener for all listeners on all events
if (arguments.length === 0) {
for (key in this._events) {
if (key === 'removeListener') continue;
this.removeAllListeners(key);
}
this.removeAllListeners('removeListener');
this._events = {};
return this;
}
listeners = this._events[type];
if (isFunction(listeners)) {
this.removeListener(type, listeners);
} else if (listeners) {
// LIFO order
while (listeners.length)
this.removeListener(type, listeners[listeners.length - 1]);
}
delete this._events[type];
return this;
};
EventEmitter.prototype.listeners = function(type) {
var ret;
if (!this._events || !this._events[type])
ret = [];
else if (isFunction(this._events[type]))
ret = [this._events[type]];
else
ret = this._events[type].slice();
return ret;
};
EventEmitter.prototype.listenerCount = function(type) {
if (this._events) {
var evlistener = this._events[type];
if (isFunction(evlistener))
return 1;
else if (evlistener)
return evlistener.length;
}
return 0;
};
EventEmitter.listenerCount = function(emitter, type) {
return emitter.listenerCount(type);
};
function isFunction(arg) {
return typeof arg === 'function';
}
function isNumber(arg) {
return typeof arg === 'number';
}
function isObject(arg) {
return typeof arg === 'object' && arg !== null;
}
function isUndefined(arg) {
return arg === void 0;
}
/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var BaseError = /** @class */ (function (_super) {
__extends(BaseError, _super);
function BaseError(message) {
var _this = _super.call(this) || this;
_this.message = message;
if (Error.captureStackTrace) {
// chrome etc.
Error.captureStackTrace(_this, _this.constructor);
return _this;
}
var stack = new Error().stack.split('\n'); // removes useless stack frame
stack.splice(1, 1);
_this.stack = stack.join('\n');
return _this;
}
BaseError.setProto = function (error) {
if (Object.setPrototypeOf) {
Object.setPrototypeOf(error, this.prototype);
return;
}
error.__proto__ = this.prototype; // Super emergency fallback
};
return BaseError;
}(Error));
exports.BaseError = BaseError;
/**
* Cancelled errors are thrown when the packet is cancelled by the client before
* a reply was received.
*/
var CancelledError = /** @class */ (function (_super) {
__extends(CancelledError, _super);
function CancelledError() {
var _this = _super.call(this, 'Packet was cancelled or socket was closed before a reply was received.') || this;
CancelledError.setProto(_this);
return _this;
}
return CancelledError;
}(BaseError));
exports.CancelledError = CancelledError;
/**
* HTTPError is used when a request does not respond successfully.
*/
var HTTPError = /** @class */ (function (_super) {
__extends(HTTPError, _super);
function HTTPError(code, message, res) {
var _this = _super.call(this, message) || this;
_this.code = code;
_this.res = res;
HTTPError.setProto(_this);
return _this;
}
HTTPError.prototype.cause = function () {
return this.res;
};
return HTTPError;
}(BaseError));
exports.HTTPError = HTTPError;
/**
* This error is thrown when you try to perform an action which is not supported by an
* instantiated [Client]{@link Client}.
*/
var PermissionDeniedError = /** @class */ (function (_super) {
__extends(PermissionDeniedError, _super);
function PermissionDeniedError(operation, source) {
var _this = _super.call(this, "You don't have permission to " + operation + " from " + source + "!") || this;
PermissionDeniedError.setProto(_this);
return _this;
}
return PermissionDeniedError;
}(BaseError));
exports.PermissionDeniedError = PermissionDeniedError;
/**
* TimeoutErrors occur when a reply is not received from the server after a defined
* wait period.
*/
var TimeoutError = /** @class */ (function (_super) {
__extends(TimeoutError, _super);
function TimeoutError(message) {
var _this = _super.call(this, message) || this;
TimeoutError.setProto(_this);
return _this;
}
return TimeoutError;
}(BaseError));
exports.TimeoutError = TimeoutError;
/**
* MessageParseError indicates that a message received is invalid JSON.
*/
var MessageParseError = /** @class */ (function (_super) {
__extends(MessageParseError, _super);
function MessageParseError(message) {
var _this = _super.call(this, message) || this;
MessageParseError.setProto(_this);
return _this;
}
return MessageParseError;
}(BaseError));
exports.MessageParseError = MessageParseError;
/**
* NoInteractiveServersAvailable indicates that a request to retrieve
* available interactive servers failed and that none can be located.
*/
var NoInteractiveServersAvailable = /** @class */ (function (_super) {
__extends(NoInteractiveServersAvailable, _super);
function NoInteractiveServersAvailable(message) {
var _this = _super.call(this, message) || this;
NoInteractiveServersAvailable.setProto(_this);
return _this;
}
return NoInteractiveServersAvailable;
}(BaseError));
exports.NoInteractiveServersAvailable = NoInteractiveServersAvailable;
var InteractiveError;
(function (InteractiveError) {
var Base = /** @class */ (function (_super) {
__extends(Base, _super);
function Base(message, code) {
var _this = _super.call(this, message) || this;
_this.code = code;
Base.setProto(_this);
return _this;
}
return Base;
}(BaseError));
InteractiveError.Base = Base;
InteractiveError.errors = {};
InteractiveError.startOfRange = 4000;
function fromSocketMessage(error) {
if (InteractiveError.errors[error.code]) {
var err = new InteractiveError.errors[error.code](error.message, error.code);
err.path = error.path;
return err;
}
return new Base(error.message, error.code);
}
InteractiveError.fromSocketMessage = fromSocketMessage;
var CloseUnknown = /** @class */ (function (_super) {
__extends(CloseUnknown, _super);
function CloseUnknown(message) {
var _this = _super.call(this, message, 1011) || this;
CloseUnknown.setProto(_this);
return _this;
}
return CloseUnknown;
}(Base));
InteractiveError.CloseUnknown = CloseUnknown;
InteractiveError.errors[1011] = CloseUnknown;
var CloseRestarting = /** @class */ (function (_super) {
__extends(CloseRestarting, _super);
function CloseRestarting(message) {
var _this = _super.call(this, message, 1012) || this;
CloseRestarting.setProto(_this);
return _this;
}
return CloseRestarting;
}(Base));
InteractiveError.CloseRestarting = CloseRestarting;
InteractiveError.errors[1012] = CloseRestarting;
/**
* Indicates that a message received at the server is invalid JSON.
*/
var InvalidPayload = /** @class */ (function (_super) {
__extends(InvalidPayload, _super);
function InvalidPayload(message) {
var _this = _super.call(this, message, 4000) || this;
InvalidPayload.setProto(_this);
return _this;
}
return InvalidPayload;
}(Base));
InteractiveError.InvalidPayload = InvalidPayload;
InteractiveError.errors[4000] = InvalidPayload;
/**
* Indicates that the server was unable to decompress a frame
* sent from the client.
*/
var PayloadDecompression = /** @class */ (function (_super) {
__extends(PayloadDecompression, _super);
function PayloadDecompression(message) {
var _this = _super.call(this, message, 4001) || this;
PayloadDecompression.setProto(_this);
return _this;
}
return PayloadDecompression;
}(Base));
InteractiveError.PayloadDecompression = PayloadDecompression;
InteractiveError.errors[4001] = PayloadDecompression;
/**
* Indicates that the server did not recognize the type of packet sent to it.
*/
var UnknownPacketType = /** @class */ (function (_super) {
__extends(UnknownPacketType, _super);
function UnknownPacketType(message) {
var _this = _super.call(this, message, 4002) || this;
UnknownPacketType.setProto(_this);
return _this;
}
return UnknownPacketType;
}(Base));
InteractiveError.UnknownPacketType = UnknownPacketType;
InteractiveError.errors[4002] = UnknownPacketType;
/**
* Indicates that the server did not recognize the method name sent to it.
*/
var UnknownMethodName = /** @class */ (function (_super) {
__extends(UnknownMethodName, _super);
function UnknownMethodName(message) {
var _this = _super.call(this, message, 4003) || this;
UnknownMethodName.setProto(_this);
return _this;
}
return UnknownMethodName;
}(Base));
InteractiveError.UnknownMethodName = UnknownMethodName;
InteractiveError.errors[4003] = UnknownMethodName;
/**
* Indicates that the server was unable to parse the method's arguments.
*/
var InvalidMethodArguments = /** @class */ (function (_super) {
__extends(InvalidMethodArguments, _super);
function InvalidMethodArguments(message) {
var _this = _super.call(this, message, 4004) || this;
InvalidMethodArguments.setProto(_this);
return _this;
}
return InvalidMethodArguments;
}(Base));
InteractiveError.InvalidMethodArguments = InvalidMethodArguments;
InteractiveError.errors[4004] = InvalidMethodArguments;
/**
* Indicates that an invalid transactionId was specified in a `capture` method.
*/
var InvalidTransactionId = /** @class */ (function (_super) {
__extends(InvalidTransactionId, _super);
function InvalidTransactionId(message) {
var _this = _super.call(this, message, 4006) || this;
InvalidTransactionId.setProto(_this);
return _this;
}
return InvalidTransactionId;
}(Base));
InteractiveError.InvalidTransactionId = InvalidTransactionId;
InteractiveError.errors[4006] = InvalidTransactionId;
/**
* Indicates that a transaction failed to capture because the participant does not have enough sparks.
*/
var NotEnoughSparks = /** @class */ (function (_super) {
__extends(NotEnoughSparks, _super);
function NotEnoughSparks(message) {
var _this = _super.call(this, message, 4007) || this;
NotEnoughSparks.setProto(_this);
return _this;
}
return NotEnoughSparks;
}(Base));
InteractiveError.NotEnoughSparks = NotEnoughSparks;
InteractiveError.errors[4007] = NotEnoughSparks;
/**
* Indicates that an operation was attempted on a Group that the server does not know about.
*/
var UnknownGroup = /** @class */ (function (_super) {
__extends(UnknownGroup, _super);
function UnknownGroup(message) {
var _this = _super.call(this, message, 4008) || this;
UnknownGroup.setProto(_this);
return _this;
}
return UnknownGroup;
}(Base));
InteractiveError.UnknownGroup = UnknownGroup;
InteractiveError.errors[4008] = UnknownGroup;
/**
* Indicates that the group you're trying to create already exists.
*/
var GroupAlreadyExists = /** @class */ (function (_super) {
__extends(GroupAlreadyExists, _super);
function GroupAlreadyExists(message) {
var _this = _super.call(this, message, 4009) || this;
GroupAlreadyExists.setProto(_this);
return _this;
}
return GroupAlreadyExists;
}(Base));
InteractiveError.GroupAlreadyExists = GroupAlreadyExists;
InteractiveError.errors[4009] = GroupAlreadyExists;
/**
* Indicates that a scene that you're trying to operate on is not known by the server.
*/
var UnknownSceneId = /** @class */ (function (_super) {
__extends(UnknownSceneId, _super);
function UnknownSceneId(message) {
var _this = _super.call(this, message, 4010) || this;
UnknownSceneId.setProto(_this);
return _this;
}
return UnknownSceneId;
}(Base));
InteractiveError.UnknownSceneId = UnknownSceneId;
InteractiveError.errors[4010] = UnknownSceneId;
/**
* Indicates that the scene you're trying to create already exists.
*/
var SceneAlreadyExists = /** @class */ (function (_super) {
__extends(SceneAlreadyExists, _super);
function SceneAlreadyExists(message) {
var _this = _super.call(this, message, 4011) || this;
SceneAlreadyExists.setProto(_this);
return _this;
}
return SceneAlreadyExists;
}(Base));
InteractiveError.SceneAlreadyExists = SceneAlreadyExists;
InteractiveError.errors[4011] = SceneAlreadyExists;
/**
* Indicates that you're trying to perform an operation on a control
* that is not known by the server.
*/
var UnknownControlId = /** @class */ (function (_super) {
__extends(UnknownControlId, _super);
function UnknownControlId(message) {
var _this = _super.call(this, message, 4012) || this;
UnknownControlId.setProto(_this);
return _this;
}
return UnknownControlId;
}(Base));
InteractiveError.UnknownControlId = UnknownControlId;
InteractiveError.errors[4012] = UnknownControlId;
/**
* Indicates that the control you're trying to create already exists.
*/
var ControlAlreadyExists = /** @class */ (function (_super) {
__extends(ControlAlreadyExists, _super);
function ControlAlreadyExists(message) {
var _this = _super.call(this, message, 4013) || this;
ControlAlreadyExists.setProto(_this);
return _this;
}
return ControlAlreadyExists;
}(Base));
InteractiveError.ControlAlreadyExists = ControlAlreadyExists;
InteractiveError.errors[4013] = ControlAlreadyExists;
/**
* Indicates that you're trying to create a control whose type is not
* recognized by the server.
*/
var UnknownControlType = /** @class */ (function (_super) {
__extends(UnknownControlType, _super);
function UnknownControlType(message) {
var _this = _super.call(this, message, 4014) || this;
UnknownControlType.setProto(_this);
return _this;
}
return UnknownControlType;
}(Base));
InteractiveError.UnknownControlType = UnknownControlType;
InteractiveError.errors[4014] = UnknownControlType;
/**
* Indicates that you're trying to perform an operation on a Participant
* that the server is not aware of.
*/
var UnknownParticipant = /** @class */ (function (_super) {
__extends(UnknownParticipant, _super);
function UnknownParticipant(message) {
var _this = _super.call(this, message, 4015) || this;
UnknownParticipant.setProto(_this);
return _this;
}
return UnknownParticipant;
}(Base));
InteractiveError.UnknownParticipant = UnknownParticipant;
InteractiveError.errors[4015] = UnknownParticipant;
/**
* Sent in a Close frame when the interactive session is ending.
*/
var SessionClosing = /** @class */ (function (_super) {
__extends(SessionClosing, _super);
function SessionClosing(message) {
var _this = _super.call(this, message, 4016) || this;
SessionClosing.setProto(_this);
return _this;
}
return SessionClosing;
}(Base));
InteractiveError.SessionClosing = SessionClosing;
InteractiveError.errors[4016] = SessionClosing;
/**
* Sent in a close frame when the GameClient exceeds memory usage limits on the server.
*/
var OutOfMemory = /** @class */ (function (_super) {
__extends(OutOfMemory, _super);
function OutOfMemory(message) {
var _this = _super.call(this, message, 4017) || this;
OutOfMemory.setProto(_this);
return _this;
}
return OutOfMemory;
}(Base));
InteractiveError.OutOfMemory = OutOfMemory;
InteractiveError.errors[4017] = OutOfMemory;
/**
* Thrown when an attempt is made to delete a default resource such as a Scene or Group.
*/
var CannotDeleteDefault = /** @class */ (function (_super) {
__extends(CannotDeleteDefault, _super);
function CannotDeleteDefault(message) {
var _this = _super.call(this, message, 4018) || this;
CannotDeleteDefault.setProto(_this);
return _this;
}
return CannotDeleteDefault;
}(Base));
InteractiveError.CannotDeleteDefault = CannotDeleteDefault;
InteractiveError.errors[4018] = CannotDeleteDefault;
/**
* CannotAuthenticate occurs when the server fails to authenticate the client.
* This is usually caused by the provided Authentication details be invalid or missing.
*/
var CannotAuthenticate = /** @class */ (function (_super) {
__extends(CannotAuthenticate, _super);
function CannotAuthenticate(message) {
var _this = _super.call(this, message, 4019) || this;
CannotAuthenticate.setProto(_this);
return _this;
}
return CannotAuthenticate;
}(Base));
InteractiveError.CannotAuthenticate = CannotAuthenticate;
InteractiveError.errors[4019] = CannotAuthenticate;
/**
* NoInteractiveVersion occurs when the server is unable to validate your Interactive
* Project Version ID. This can occur if your project version id is invalid or missing,
* or if you do not have access to this version.
*/
var NoInteractiveVersion = /** @class */ (function (_super) {
__extends(NoInteractiveVersion, _super);
function NoInteractiveVersion(message) {
var _this = _super.call(this, message, 4020) || this;
NoInteractiveVersion.setProto(_this);
return _this;
}
return NoInteractiveVersion;
}(Base));
InteractiveError.NoInteractiveVersion = NoInteractiveVersion;
InteractiveError.errors[4020] = NoInteractiveVersion;
/**
* SessionConflict occurs when the server detects a conflicting connection from the client.
* This can occur if the requested channel is already interactive or as a participant if
* you're already connected to a channel.
*/
var SessionConflict = /** @class */ (function (_super) {
__extends(SessionConflict, _super);
function SessionConflict(message) {
var _this = _super.call(this, message, 4021) || this;
SessionConflict.setProto(_this);
return _this;
}
return SessionConflict;
}(Base));
InteractiveError.SessionConflict = SessionConflict;
InteractiveError.errors[4021] = SessionConflict;
/**
* ChannelNotInteractive occurs when you try to connect to a channel that is not interactive.
*/
var ChannelNotInteractive = /** @class */ (function (_super) {
__extends(ChannelNotInteractive, _super);
function ChannelNotInteractive(message) {
var _this = _super.call(this, message, 4022) || this;
ChannelNotInteractive.setProto(_this);
return _this;
}
return ChannelNotInteractive;
}(Base));
InteractiveError.ChannelNotInteractive = ChannelNotInteractive;
InteractiveError.errors[4022] = ChannelNotInteractive;
/**
* Indicates input sent from a participant is invalid.
*/
var BadUserInput = /** @class */ (function (_super) {
__extends(BadUserInput, _super);
function BadUserInput(message) {
var _this = _super.call(this, message, 4999) || this;
BadUserInput.setProto(_this);
return _this;
}
return BadUserInput;
}(Base));
InteractiveError.BadUserInput = BadUserInput;
InteractiveError.errors[4999] = BadUserInput;
})(InteractiveError = exports.InteractiveError || (exports.InteractiveError = {}));
/***/ }),
/* 3 */
/***/ (function(module, exports) {
if (typeof Object.create === 'function') {
// implementation from standard node.js 'util' module
module.exports = function inherits(ctor, superCtor) {
ctor.super_ = superCtor
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: false,
writable: true,
configurable: true
}
});
};
} else {
// old school shim for old browsers
module.exports = function inherits(ctor, superCtor) {
ctor.super_ = superCtor
var TempCtor = function () {}
TempCtor.prototype = superCtor.prototype
ctor.prototype = new TempCtor()
ctor.prototype.constructor = ctor
}
}
/***/ }),
/* 4 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
var events_1 = __webpack_require__(1);
var merge_1 = __webpack_require__(10);
/**
* Control is used a base class for all other controls within an interactive session.
* It contains shared logic which all types of controls can utilize.
*/
var Control = /** @class */ (function (_super) {
__extends(Control, _super);
function Control(control) {
var _this = _super.call(this) || this;
merge_1.merge(_this, control);
return _this;
}
/**
* Sets the scene this control belongs to.
*/
Control.prototype.setScene = function (scene) {
this.scene = scene;
};
/**
* Sets the client instance this control can use to execute methods.
*/
Control.prototype.setClient = function (client) {
this.client = client;
};
/**
* Called by client when it receives an input event for this control from the server.
*/
Control.prototype.receiveInput = function (inputEvent, participant) {
this.emit(inputEvent.input.event, inputEvent, participant);
};
Control.prototype.sendInput = function (input) {
// We add this on behalf of the controls so that they don't have to worry about the
// Protocol side too much
input.controlID = this.controlID;
return this.client.giveInput(input);
};
/**
* Disables this control, preventing participant interaction.
*/
Control.prototype.disable = function () {
return this.updateAttribute('disabled', true);
};
/**
* Enables this control, allowing participant interaction.
*/
Control.prototype.enable = function () {
return this.updateAttribute('disabled', false);
};
Control.prototype.updateAttribute = function (attribute, value) {
var packet = {};
packet.controlID = this.controlID;
packet[attribute] = value;
return this.client.updateControls({
sceneID: this.scene.sceneID,
controls: [packet],
});
};
/**
* Merges in values from the server in response to an update operation from the server.
*/
Control.prototype.onUpdate = function (controlData) {
merge_1.merge(this, controlData);
this.emit('updated', this);
};
/**
* Update this control on the server.
*/
Control.prototype.update = function (controlUpdate) {
var changedData = __assign({}, controlUpdate, { controlID: this.controlID });
return this.client.updateControls({
sceneID: this.scene.sceneID,
controls: [changedData],
});
};
Control.prototype.destroy = function () {
this.emit('deleted', this);
};
return Control;
}(events_1.EventEmitter));
exports.Control = Control;
/***/ }),
/* 5 */
/***/ (function(module, exports) {
// shim for using process in browser
var process = module.exports = {};
// cached from whatever global is present so that test runners that stub it
// don't break things. But we need to wrap it in a try catch in case it is
// wrapped in strict mode code which doesn't define any globals. It's inside a
// function because try/catches deoptimize in certain engines.
var cachedSetTimeout;
var cachedClearTimeout;
function defaultSetTimout() {
throw new Error('setTimeout has not been defined');
}
function defaultClearTimeout () {
throw new Error('clearTimeout has not been defined');
}
(function () {
try {
if (typeof setTimeout === 'function') {
cachedSetTimeout = setTimeout;
} else {
cachedSetTimeout = defaultSetTimout;
}
} catch (e) {
cachedSetTimeout = defaultSetTimout;
}
try {
if (typeof clearTimeout === 'function') {
cachedClearTimeout = clearTimeout;
} else {
cachedClearTimeout = defaultClearTimeout;
}
} catch (e) {
cachedClearTimeout = defaultClearTimeout;
}
} ())
function runTimeout(fun) {
if (cachedSetTimeout === setTimeout) {
//normal enviroments in sane situations
return setTimeout(fun, 0);
}
// if setTimeout wasn't available but was latter defined
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
cachedSetTimeout = setTimeout;
return setTimeout(fun, 0);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedSetTimeout(fun, 0);
} catch(e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedSetTimeout.call(null, fun, 0);
} catch(e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
return cachedSetTimeout.call(this, fun, 0);
}
}
}
function runClearTimeout(marker) {
if (cachedClearTimeout === clearTimeout) {
//normal enviroments in sane situations
return clearTimeout(marker);
}
// if clearTimeout wasn't available but was latter defined
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
cachedClearTimeout = clearTimeout;
return clearTimeout(marker);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedClearTimeout(marker);
} catch (e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedClearTimeout.call(null, marker);
} catch (e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
return cachedClearTimeout.call(this, marker);
}
}
}
var queue = [];
var draining = false;
var currentQueue;
var queueIndex = -1;
function cleanUpNextTick() {
if (!draining || !currentQueue) {
return;
}
draining = false;
if (currentQueue.length) {
queue = currentQueue.concat(queue);
} else {
queueIndex = -1;
}
if (queue.length) {
drainQueue();
}
}
function drainQueue() {
if (draining) {
return;
}
var timeout = runTimeout(cleanUpNextTick);
draining = true;
var len = queue.length;
while(len) {
currentQueue = queue;
queue = [];
while (++queueIndex < len) {
if (currentQueue) {
currentQueue[queueIndex].run();
}
}
queueIndex = -1;
len = queue.length;
}
currentQueue = null;
draining = false;
runClearTimeout(timeout);
}
process.nextTick = function (fun) {
var args = new Array(arguments.length - 1);
if (arguments.length > 1) {
for (var i = 1; i < arguments.length; i++) {
args[i - 1] = arguments[i];
}
}
queue.push(new Item(fun, args));
if (queue.length === 1 && !draining) {
runTimeout(drainQueue);
}
};
// v8 likes predictible objects
function Item(fun, array) {
this.fun = fun;
this.array = array;
}
Item.prototype.run = function () {
this.fun.apply(null, this.array);
};
process.title = 'browser';
process.browser = true;
process.env = {};
process.argv = [];
process.version = ''; // empty string to avoid regexp issues
process.versions = {};
function noop() {}
process.on = noop;
process.addListener = noop;
process.once = noop;
process.off = noop;
process.removeListener = noop;
process.removeAllListeners = noop;
process.emit = noop;
process.prependListener = noop;
process.prependOnceListener = noop;
process.listeners = function (name) { return [] }
process.binding = function (name) {
throw new Error('process.binding is not supported');
};
process.cwd = function () { return '/' };
process.chdir = function (dir) {
throw new Error('process.chdir is not supported');
};
process.umask = function() { return 0; };
/***/ }),
/* 6 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
// a duplex stream is just a stream that is both readable and writable.
// Since JS doesn't have multiple prototypal inheritance, this class
// prototypally inherits from Readable, and then parasitically from
// Writable.
/*<replacement>*/
var pna = __webpack_require__(11);
/*</replacement>*/
/*<replacement>*/
var objectKeys = Object.keys || function (obj) {
var keys = [];
for (var key in obj) {
keys.push(key);
}return keys;
};
/*</replacement>*/
module.exports = Duplex;
/*<replacement>*/
var util = __webpack_require__(8);
util.inherits = __webpack_require__(3);
/*</replacement>*/
var Readable = __webpack_require__(22);
var Writable = __webpack_require__(24);
util.inherits(Duplex, Readable);
{
// avoid scope creep, the keys array can then be collected
var keys = objectKeys(Writable.prototype);
for (var v = 0; v < keys.length; v++) {
var method = keys[v];
if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
}
}
function Duplex(options) {
if (!(this instanceof Duplex)) return new Duplex(options);
Readable.call(this, options);
Writable.call(this, options);
if (options && options.readable === false) this.readable = false;
if (options && options.writable === false) this.writable = false;
this.allowHalfOpen = true;
if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
this.once('end', onend);
}
Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
// making it explicit this property is not enumerable
// because otherwise some prototype manipulation in
// userland will fail
enumerable: false,
get: function () {
return this._writableState.highWaterMark;
}
});
// the no-half-open enforcer
function onend() {
// if we allow half-open state, or if the writable side ended,
// then we're ok.
if (this.allowHalfOpen || this._writableState.ended) return;
// no more data can be written.
// But allow more writes to happen in this tick.
pna.nextTick(onEndNT, this);
}
function onEndNT(self) {
self.end();
}
Object.defineProperty(Duplex.prototype, 'destroyed', {
get: function () {
if (this._readableState === undefined || this._writableState === undefined) {
return false;
}
return this._readableState.destroyed && this._writableState.destroyed;
},
set: function (value) {
// we ignore the value if the stream
// has not been initialized yet
if (this._readableState === undefined || this._writableState === undefined) {
return;
}
// backward compatibility, the user is explicitly
// managing destroyed
this._readableState.destroyed = value;
this._writableState.destroyed = value;
}
});
Duplex.prototype._destroy = function (err, cb) {
this.push(null);
this.end();
pna.nextTick(cb, err);
};
/***/ }),
/* 7 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(global) {/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
* @license MIT
*/
/* eslint-disable no-proto */
var base64 = __webpack_require__(47)
var ieee754 = __webpack_require__(51)
var isArray = __webpack_require__(21)
exports.Buffer = Buffer
exports.SlowBuffer = SlowBuffer
exports.INSPECT_MAX_BYTES = 50
/**
* If `Buffer.TYPED_ARRAY_SUPPORT`:
* === true Use Uint8Array implementation (fastest)
* === false Use Object implementation (most compatible, even IE6)
*
* Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
* Opera 11.6+, iOS 4.2+.
*
* Due to various browser bugs, sometimes the Object implementation will be used even
* when the browser supports typed arrays.
*
* Note:
*
* - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
* See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
*
* - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
*
* - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
* incorrect length in some situations.
* We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
* get the Object implementation, which is slower but behaves correctly.
*/
Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
? global.TYPED_ARRAY_SUPPORT
: typedArraySupport()
/*
* Export kMaxLength after typed array support is determined.
*/
exports.kMaxLength = kMaxLength()
function typedArraySupport () {
try {
var arr = new Uint8Array(1)
arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
return arr.foo() === 42 && // typed array instances can be augmented
typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
} catch (e) {
return false
}
}
function kMaxLength () {
return Buffer.TYPED_ARRAY_SUPPORT
? 0x7fffffff
: 0x3fffffff
}
function createBuffer (that, length) {
if (kMaxLength() < length) {
throw new RangeError('Invalid typed array length')
}
if (Buffer.TYPED_ARRAY_SUPPORT) {
// Return an augmented `Uint8Array` instance, for best performance
that = new Uint8Array(length)
that.__proto__ = Buffer.prototype
} else {
// Fallback: Return an object instance of the Buffer class
if (that === null) {
that = new Buffer(length)
}
that.length = length
}
return that
}
/**
* The Buffer constructor returns instances of `Uint8Array` that have their
* prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
* `Uint8Array`, so the returned instances will have all the node `Buffer` methods
* and the `Uint8Array` methods. Square bracket notation works as expected -- it
* returns a single octet.
*
* The `Uint8Array` prototype remains unmodified.
*/
function Buffer (arg, encodingOrOffset, length) {
if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
return new Buffer(arg, encodingOrOffset, length)
}
// Common case.
if (typeof arg === 'number') {
if (typeof encodingOrOffset === 'string') {
throw new Error(
'If encoding is specified then the first argument must be a string'
)
}
return allocUnsafe(this, arg)
}
return from(this, arg, encodingOrOffset, length)
}
Buffer.poolSize = 8192 // no