@mr_chick/vue_laravel_echo
Version:
A wrapper (and more) for the laravel-echo package
161 lines (142 loc) • 42.9 kB
JavaScript
module.exports =
/******/ (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;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // 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 = "./index.js");
/******/ })
/************************************************************************/
/******/ ({
/***/ "../node_modules/laravel-echo/dist/echo.js":
/*!*************************************************!*\
!*** ../node_modules/laravel-echo/dist/echo.js ***!
\*************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
eval("var asyncGenerator = function () {\n function AwaitValue(value) {\n this.value = value;\n }\n\n function AsyncGenerator(gen) {\n var front, back;\n\n function send(key, arg) {\n return new Promise(function (resolve, reject) {\n var request = {\n key: key,\n arg: arg,\n resolve: resolve,\n reject: reject,\n next: null\n };\n\n if (back) {\n back = back.next = request;\n } else {\n front = back = request;\n resume(key, arg);\n }\n });\n }\n\n function resume(key, arg) {\n try {\n var result = gen[key](arg);\n var value = result.value;\n\n if (value instanceof AwaitValue) {\n Promise.resolve(value.value).then(function (arg) {\n resume(\"next\", arg);\n }, function (arg) {\n resume(\"throw\", arg);\n });\n } else {\n settle(result.done ? \"return\" : \"normal\", result.value);\n }\n } catch (err) {\n settle(\"throw\", err);\n }\n }\n\n function settle(type, value) {\n switch (type) {\n case \"return\":\n front.resolve({\n value: value,\n done: true\n });\n break;\n\n case \"throw\":\n front.reject(value);\n break;\n\n default:\n front.resolve({\n value: value,\n done: false\n });\n break;\n }\n\n front = front.next;\n\n if (front) {\n resume(front.key, front.arg);\n } else {\n back = null;\n }\n }\n\n this._invoke = send;\n\n if (typeof gen.return !== \"function\") {\n this.return = undefined;\n }\n }\n\n if (typeof Symbol === \"function\" && Symbol.asyncIterator) {\n AsyncGenerator.prototype[Symbol.asyncIterator] = function () {\n return this;\n };\n }\n\n AsyncGenerator.prototype.next = function (arg) {\n return this._invoke(\"next\", arg);\n };\n\n AsyncGenerator.prototype.throw = function (arg) {\n return this._invoke(\"throw\", arg);\n };\n\n AsyncGenerator.prototype.return = function (arg) {\n return this._invoke(\"return\", arg);\n };\n\n return {\n wrap: function (fn) {\n return function () {\n return new AsyncGenerator(fn.apply(this, arguments));\n };\n },\n await: function (value) {\n return new AwaitValue(value);\n }\n };\n}();\n\nvar classCallCheck = function (instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n};\n\nvar createClass = function () {\n function defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n Object.defineProperty(target, descriptor.key, descriptor);\n }\n }\n\n return function (Constructor, protoProps, staticProps) {\n if (protoProps) defineProperties(Constructor.prototype, protoProps);\n if (staticProps) defineProperties(Constructor, staticProps);\n return Constructor;\n };\n}();\n\nvar _extends = Object.assign || function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n\n return target;\n};\n\nvar inherits = function (subClass, superClass) {\n if (typeof superClass !== \"function\" && superClass !== null) {\n throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass);\n }\n\n subClass.prototype = Object.create(superClass && superClass.prototype, {\n constructor: {\n value: subClass,\n enumerable: false,\n writable: true,\n configurable: true\n }\n });\n if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;\n};\n\nvar possibleConstructorReturn = function (self, call) {\n if (!self) {\n throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n }\n\n return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self;\n};\n\nvar Connector = function () {\n function Connector(options) {\n classCallCheck(this, Connector);\n\n this._defaultOptions = {\n auth: {\n headers: {}\n },\n authEndpoint: '/broadcasting/auth',\n broadcaster: 'pusher',\n csrfToken: null,\n host: null,\n key: null,\n namespace: 'App.Events'\n };\n this.setOptions(options);\n this.connect();\n }\n\n createClass(Connector, [{\n key: 'setOptions',\n value: function setOptions(options) {\n this.options = _extends(this._defaultOptions, options);\n if (this.csrfToken()) {\n this.options.auth.headers['X-CSRF-TOKEN'] = this.csrfToken();\n }\n return options;\n }\n }, {\n key: 'csrfToken',\n value: function csrfToken() {\n var selector = void 0;\n if (typeof window !== 'undefined' && window['Laravel'] && window['Laravel'].csrfToken) {\n return window['Laravel'].csrfToken;\n } else if (this.options.csrfToken) {\n return this.options.csrfToken;\n } else if (typeof document !== 'undefined' && (selector = document.querySelector('meta[name=\"csrf-token\"]'))) {\n return selector.getAttribute('content');\n }\n return null;\n }\n }]);\n return Connector;\n}();\n\nvar Channel = function () {\n function Channel() {\n classCallCheck(this, Channel);\n }\n\n createClass(Channel, [{\n key: 'notification',\n value: function notification(callback) {\n return this.listen('.Illuminate\\\\Notifications\\\\Events\\\\BroadcastNotificationCreated', callback);\n }\n }, {\n key: 'listenForWhisper',\n value: function listenForWhisper(event, callback) {\n return this.listen('.client-' + event, callback);\n }\n }]);\n return Channel;\n}();\n\nvar EventFormatter = function () {\n function EventFormatter(namespace) {\n classCallCheck(this, EventFormatter);\n\n this.setNamespace(namespace);\n }\n\n createClass(EventFormatter, [{\n key: 'format',\n value: function format(event) {\n if (event.charAt(0) === '.' || event.charAt(0) === '\\\\') {\n return event.substr(1);\n } else if (this.namespace) {\n event = this.namespace + '.' + event;\n }\n return event.replace(/\\./g, '\\\\');\n }\n }, {\n key: 'setNamespace',\n value: function setNamespace(value) {\n this.namespace = value;\n }\n }]);\n return EventFormatter;\n}();\n\nvar PusherChannel = function (_Channel) {\n inherits(PusherChannel, _Channel);\n\n function PusherChannel(pusher, name, options) {\n classCallCheck(this, PusherChannel);\n\n var _this = possibleConstructorReturn(this, (PusherChannel.__proto__ || Object.getPrototypeOf(PusherChannel)).call(this));\n\n _this.name = name;\n _this.pusher = pusher;\n _this.options = options;\n _this.eventFormatter = new EventFormatter(_this.options.namespace);\n _this.subscribe();\n return _this;\n }\n\n createClass(PusherChannel, [{\n key: 'subscribe',\n value: function subscribe() {\n this.subscription = this.pusher.subscribe(this.name);\n }\n }, {\n key: 'unsubscribe',\n value: function unsubscribe() {\n this.pusher.unsubscribe(this.name);\n }\n }, {\n key: 'listen',\n value: function listen(event, callback) {\n this.on(this.eventFormatter.format(event), callback);\n return this;\n }\n }, {\n key: 'stopListening',\n value: function stopListening(event) {\n this.subscription.unbind(this.eventFormatter.format(event));\n return this;\n }\n }, {\n key: 'on',\n value: function on(event, callback) {\n this.subscription.bind(event, callback);\n return this;\n }\n }]);\n return PusherChannel;\n}(Channel);\n\nvar PusherPrivateChannel = function (_PusherChannel) {\n inherits(PusherPrivateChannel, _PusherChannel);\n\n function PusherPrivateChannel() {\n classCallCheck(this, PusherPrivateChannel);\n return possibleConstructorReturn(this, (PusherPrivateChannel.__proto__ || Object.getPrototypeOf(PusherPrivateChannel)).apply(this, arguments));\n }\n\n createClass(PusherPrivateChannel, [{\n key: 'whisper',\n value: function whisper(eventName, data) {\n this.pusher.channels.channels[this.name].trigger('client-' + eventName, data);\n return this;\n }\n }]);\n return PusherPrivateChannel;\n}(PusherChannel);\n\nvar PusherPresenceChannel = function (_PusherChannel) {\n inherits(PusherPresenceChannel, _PusherChannel);\n\n function PusherPresenceChannel() {\n classCallCheck(this, PusherPresenceChannel);\n return possibleConstructorReturn(this, (PusherPresenceChannel.__proto__ || Object.getPrototypeOf(PusherPresenceChannel)).apply(this, arguments));\n }\n\n createClass(PusherPresenceChannel, [{\n key: 'here',\n value: function here(callback) {\n this.on('pusher:subscription_succeeded', function (data) {\n callback(Object.keys(data.members).map(function (k) {\n return data.members[k];\n }));\n });\n return this;\n }\n }, {\n key: 'joining',\n value: function joining(callback) {\n this.on('pusher:member_added', function (member) {\n callback(member.info);\n });\n return this;\n }\n }, {\n key: 'leaving',\n value: function leaving(callback) {\n this.on('pusher:member_removed', function (member) {\n callback(member.info);\n });\n return this;\n }\n }, {\n key: 'whisper',\n value: function whisper(eventName, data) {\n this.pusher.channels.channels[this.name].trigger('client-' + eventName, data);\n return this;\n }\n }]);\n return PusherPresenceChannel;\n}(PusherChannel);\n\nvar SocketIoChannel = function (_Channel) {\n inherits(SocketIoChannel, _Channel);\n\n function SocketIoChannel(socket, name, options) {\n classCallCheck(this, SocketIoChannel);\n\n var _this = possibleConstructorReturn(this, (SocketIoChannel.__proto__ || Object.getPrototypeOf(SocketIoChannel)).call(this));\n\n _this.events = {};\n _this.name = name;\n _this.socket = socket;\n _this.options = options;\n _this.eventFormatter = new EventFormatter(_this.options.namespace);\n _this.subscribe();\n _this.configureReconnector();\n return _this;\n }\n\n createClass(SocketIoChannel, [{\n key: 'subscribe',\n value: function subscribe() {\n this.socket.emit('subscribe', {\n channel: this.name,\n auth: this.options.auth || {}\n });\n }\n }, {\n key: 'unsubscribe',\n value: function unsubscribe() {\n this.unbind();\n this.socket.emit('unsubscribe', {\n channel: this.name,\n auth: this.options.auth || {}\n });\n }\n }, {\n key: 'listen',\n value: function listen(event, callback) {\n this.on(this.eventFormatter.format(event), callback);\n return this;\n }\n }, {\n key: 'on',\n value: function on(event, callback) {\n var _this2 = this;\n\n var listener = function listener(channel, data) {\n if (_this2.name == channel) {\n callback(data);\n }\n };\n this.socket.on(event, listener);\n this.bind(event, listener);\n }\n }, {\n key: 'configureReconnector',\n value: function configureReconnector() {\n var _this3 = this;\n\n var listener = function listener() {\n _this3.subscribe();\n };\n this.socket.on('reconnect', listener);\n this.bind('reconnect', listener);\n }\n }, {\n key: 'bind',\n value: function bind(event, callback) {\n this.events[event] = this.events[event] || [];\n this.events[event].push(callback);\n }\n }, {\n key: 'unbind',\n value: function unbind() {\n var _this4 = this;\n\n Object.keys(this.events).forEach(function (event) {\n _this4.events[event].forEach(function (callback) {\n _this4.socket.removeListener(event, callback);\n });\n delete _this4.events[event];\n });\n }\n }]);\n return SocketIoChannel;\n}(Channel);\n\nvar SocketIoPrivateChannel = function (_SocketIoChannel) {\n inherits(SocketIoPrivateChannel, _SocketIoChannel);\n\n function SocketIoPrivateChannel() {\n classCallCheck(this, SocketIoPrivateChannel);\n return possibleConstructorReturn(this, (SocketIoPrivateChannel.__proto__ || Object.getPrototypeOf(SocketIoPrivateChannel)).apply(this, arguments));\n }\n\n createClass(SocketIoPrivateChannel, [{\n key: 'whisper',\n value: function whisper(eventName, data) {\n this.socket.emit('client event', {\n channel: this.name,\n event: 'client-' + eventName,\n data: data\n });\n return this;\n }\n }]);\n return SocketIoPrivateChannel;\n}(SocketIoChannel);\n\nvar SocketIoPresenceChannel = function (_SocketIoPrivateChann) {\n inherits(SocketIoPresenceChannel, _SocketIoPrivateChann);\n\n function SocketIoPresenceChannel() {\n classCallCheck(this, SocketIoPresenceChannel);\n return possibleConstructorReturn(this, (SocketIoPresenceChannel.__proto__ || Object.getPrototypeOf(SocketIoPresenceChannel)).apply(this, arguments));\n }\n\n createClass(SocketIoPresenceChannel, [{\n key: 'here',\n value: function here(callback) {\n this.on('presence:subscribed', function (members) {\n callback(members.map(function (m) {\n return m.user_info;\n }));\n });\n return this;\n }\n }, {\n key: 'joining',\n value: function joining(callback) {\n this.on('presence:joining', function (member) {\n return callback(member.user_info);\n });\n return this;\n }\n }, {\n key: 'leaving',\n value: function leaving(callback) {\n this.on('presence:leaving', function (member) {\n return callback(member.user_info);\n });\n return this;\n }\n }]);\n return SocketIoPresenceChannel;\n}(SocketIoPrivateChannel);\n\nvar NullChannel = function (_Channel) {\n inherits(NullChannel, _Channel);\n\n function NullChannel() {\n classCallCheck(this, NullChannel);\n return possibleConstructorReturn(this, (NullChannel.__proto__ || Object.getPrototypeOf(NullChannel)).apply(this, arguments));\n }\n\n createClass(NullChannel, [{\n key: 'subscribe',\n value: function subscribe() {}\n }, {\n key: 'unsubscribe',\n value: function unsubscribe() {}\n }, {\n key: 'listen',\n value: function listen(event, callback) {\n return this;\n }\n }, {\n key: 'stopListening',\n value: function stopListening(event) {\n return this;\n }\n }, {\n key: 'on',\n value: function on(event, callback) {\n return this;\n }\n }]);\n return NullChannel;\n}(Channel);\n\nvar NullPrivateChannel = function (_NullChannel) {\n inherits(NullPrivateChannel, _NullChannel);\n\n function NullPrivateChannel() {\n classCallCheck(this, NullPrivateChannel);\n return possibleConstructorReturn(this, (NullPrivateChannel.__proto__ || Object.getPrototypeOf(NullPrivateChannel)).apply(this, arguments));\n }\n\n createClass(NullPrivateChannel, [{\n key: 'whisper',\n value: function whisper(eventName, data) {\n return this;\n }\n }]);\n return NullPrivateChannel;\n}(NullChannel);\n\nvar NullPresenceChannel = function (_NullChannel) {\n inherits(NullPresenceChannel, _NullChannel);\n\n function NullPresenceChannel() {\n classCallCheck(this, NullPresenceChannel);\n return possibleConstructorReturn(this, (NullPresenceChannel.__proto__ || Object.getPrototypeOf(NullPresenceChannel)).apply(this, arguments));\n }\n\n createClass(NullPresenceChannel, [{\n key: 'here',\n value: function here(callback) {\n return this;\n }\n }, {\n key: 'joining',\n value: function joining(callback) {\n return this;\n }\n }, {\n key: 'leaving',\n value: function leaving(callback) {\n return this;\n }\n }, {\n key: 'whisper',\n value: function whisper(eventName, data) {\n return this;\n }\n }]);\n return NullPresenceChannel;\n}(NullChannel);\n\nvar PusherConnector = function (_Connector) {\n inherits(PusherConnector, _Connector);\n\n function PusherConnector() {\n var _ref;\n\n classCallCheck(this, PusherConnector);\n\n for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n var _this = possibleConstructorReturn(this, (_ref = PusherConnector.__proto__ || Object.getPrototypeOf(PusherConnector)).call.apply(_ref, [this].concat(args)));\n\n _this.channels = {};\n return _this;\n }\n\n createClass(PusherConnector, [{\n key: 'connect',\n value: function connect() {\n this.pusher = new Pusher(this.options.key, this.options);\n }\n }, {\n key: 'listen',\n value: function listen(name, event, callback) {\n return this.channel(name).listen(event, callback);\n }\n }, {\n key: 'channel',\n value: function channel(name) {\n if (!this.channels[name]) {\n this.channels[name] = new PusherChannel(this.pusher, name, this.options);\n }\n return this.channels[name];\n }\n }, {\n key: 'privateChannel',\n value: function privateChannel(name) {\n if (!this.channels['private-' + name]) {\n this.channels['private-' + name] = new PusherPrivateChannel(this.pusher, 'private-' + name, this.options);\n }\n return this.channels['private-' + name];\n }\n }, {\n key: 'presenceChannel',\n value: function presenceChannel(name) {\n if (!this.channels['presence-' + name]) {\n this.channels['presence-' + name] = new PusherPresenceChannel(this.pusher, 'presence-' + name, this.options);\n }\n return this.channels['presence-' + name];\n }\n }, {\n key: 'leave',\n value: function leave(name) {\n var _this2 = this;\n\n var channels = [name, 'private-' + name, 'presence-' + name];\n channels.forEach(function (name, index) {\n if (_this2.channels[name]) {\n _this2.channels[name].unsubscribe();\n delete _this2.channels[name];\n }\n });\n }\n }, {\n key: 'socketId',\n value: function socketId() {\n return this.pusher.connection.socket_id;\n }\n }, {\n key: 'disconnect',\n value: function disconnect() {\n this.pusher.disconnect();\n }\n }]);\n return PusherConnector;\n}(Connector);\n\nvar SocketIoConnector = function (_Connector) {\n inherits(SocketIoConnector, _Connector);\n\n function SocketIoConnector() {\n var _ref;\n\n classCallCheck(this, SocketIoConnector);\n\n for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n var _this = possibleConstructorReturn(this, (_ref = SocketIoConnector.__proto__ || Object.getPrototypeOf(SocketIoConnector)).call.apply(_ref, [this].concat(args)));\n\n _this.channels = {};\n return _this;\n }\n\n createClass(SocketIoConnector, [{\n key: 'connect',\n value: function connect() {\n var io = this.getSocketIO();\n this.socket = io(this.options.host, this.options);\n return this.socket;\n }\n }, {\n key: 'getSocketIO',\n value: function getSocketIO() {\n if (typeof io !== 'undefined') {\n return io;\n }\n if (this.options.client !== 'undefined') {\n return this.options.client;\n }\n throw new Error('Socket.io client not found. Should be globally available or passed via options.client');\n }\n }, {\n key: 'listen',\n value: function listen(name, event, callback) {\n return this.channel(name).listen(event, callback);\n }\n }, {\n key: 'channel',\n value: function channel(name) {\n if (!this.channels[name]) {\n this.channels[name] = new SocketIoChannel(this.socket, name, this.options);\n }\n return this.channels[name];\n }\n }, {\n key: 'privateChannel',\n value: function privateChannel(name) {\n if (!this.channels['private-' + name]) {\n this.channels['private-' + name] = new SocketIoPrivateChannel(this.socket, 'private-' + name, this.options);\n }\n return this.channels['private-' + name];\n }\n }, {\n key: 'presenceChannel',\n value: function presenceChannel(name) {\n if (!this.channels['presence-' + name]) {\n this.channels['presence-' + name] = new SocketIoPresenceChannel(this.socket, 'presence-' + name, this.options);\n }\n return this.channels['presence-' + name];\n }\n }, {\n key: 'leave',\n value: function leave(name) {\n var _this2 = this;\n\n var channels = [name, 'private-' + name, 'presence-' + name];\n channels.forEach(function (name) {\n if (_this2.channels[name]) {\n _this2.channels[name].unsubscribe();\n delete _this2.channels[name];\n }\n });\n }\n }, {\n key: 'socketId',\n value: function socketId() {\n return this.socket.id;\n }\n }, {\n key: 'disconnect',\n value: function disconnect() {\n this.socket.disconnect();\n }\n }]);\n return SocketIoConnector;\n}(Connector);\n\nvar NullConnector = function (_Connector) {\n inherits(NullConnector, _Connector);\n\n function NullConnector() {\n var _ref;\n\n classCallCheck(this, NullConnector);\n\n for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n var _this = possibleConstructorReturn(this, (_ref = NullConnector.__proto__ || Object.getPrototypeOf(NullConnector)).call.apply(_ref, [this].concat(args)));\n\n _this.channels = {};\n return _this;\n }\n\n createClass(NullConnector, [{\n key: 'connect',\n value: function connect() {}\n }, {\n key: 'listen',\n value: function listen(name, event, callback) {\n return new NullChannel();\n }\n }, {\n key: 'channel',\n value: function channel(name) {\n return new NullChannel();\n }\n }, {\n key: 'privateChannel',\n value: function privateChannel(name) {\n return new NullPrivateChannel();\n }\n }, {\n key: 'presenceChannel',\n value: function presenceChannel(name) {\n return new NullPresenceChannel();\n }\n }, {\n key: 'leave',\n value: function leave(name) {}\n }, {\n key: 'socketId',\n value: function socketId() {\n return 'fake-socket-id';\n }\n }, {\n key: 'disconnect',\n value: function disconnect() {}\n }]);\n return NullConnector;\n}(Connector);\n\nvar Echo = function () {\n function Echo(options) {\n classCallCheck(this, Echo);\n\n this.options = options;\n if (typeof Vue === 'function' && Vue.http) {\n this.registerVueRequestInterceptor();\n }\n if (typeof axios === 'function') {\n this.registerAxiosRequestInterceptor();\n }\n if (typeof jQuery === 'function') {\n this.registerjQueryAjaxSetup();\n }\n if (this.options.broadcaster == 'pusher') {\n this.connector = new PusherConnector(this.options);\n } else if (this.options.broadcaster == 'socket.io') {\n this.connector = new SocketIoConnector(this.options);\n } else if (this.options.broadcaster == 'null') {\n this.connector = new NullConnector(this.options);\n }\n }\n\n createClass(Echo, [{\n key: 'registerVueRequestInterceptor',\n value: function registerVueRequestInterceptor() {\n var _this = this;\n\n Vue.http.interceptors.push(function (request, next) {\n if (_this.socketId()) {\n request.headers.set('X-Socket-ID', _this.socketId());\n }\n next();\n });\n }\n }, {\n key: 'registerAxiosRequestInterceptor',\n value: function registerAxiosRequestInterceptor() {\n var _this2 = this;\n\n axios.interceptors.request.use(function (config) {\n if (_this2.socketId()) {\n config.headers['X-Socket-Id'] = _this2.socketId();\n }\n return config;\n });\n }\n }, {\n key: 'registerjQueryAjaxSetup',\n value: function registerjQueryAjaxSetup() {\n var _this3 = this;\n\n if (typeof jQuery.ajax != 'undefined') {\n jQuery.ajaxSetup({\n beforeSend: function beforeSend(xhr) {\n if (_this3.socketId()) {\n xhr.setRequestHeader('X-Socket-Id', _this3.socketId());\n }\n }\n });\n }\n }\n }, {\n key: 'listen',\n value: function listen(channel, event, callback) {\n return this.connector.listen(channel, event, callback);\n }\n }, {\n key: 'channel',\n value: function channel(_channel) {\n return this.connector.channel(_channel);\n }\n }, {\n key: 'private',\n value: function _private(channel) {\n return this.connector.privateChannel(channel);\n }\n }, {\n key: 'join',\n value: function join(channel) {\n return this.connector.presenceChannel(channel);\n }\n }, {\n key: 'leave',\n value: function leave(channel) {\n this.connector.leave(channel);\n }\n }, {\n key: 'socketId',\n value: function socketId() {\n return this.connector.socketId();\n }\n }, {\n key: 'disconnect',\n value: function disconnect() {\n this.connector.disconnect();\n }\n }]);\n return Echo;\n}();\n\nmodule.exports = Echo;\n\n//# sourceURL=webpack://vue_laravel_echo/../node_modules/laravel-echo/dist/echo.js?");
/***/ }),
/***/ "./index.js":
/*!******************!*\
!*** ./index.js ***!
\******************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar _laravelEcho = _interopRequireDefault(__webpack_require__(/*! laravel-echo */ \"../node_modules/laravel-echo/dist/echo.js\"));\n\nvar _store = _interopRequireDefault(__webpack_require__(/*! ./store/ */ \"./store/index.js\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); }\n\nfunction _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nvar vue_laravel_echo =\n/*#__PURE__*/\nfunction () {\n function VLE(echo) {\n _classCallCheck(this, VLE);\n\n this.rawEcho = echo;\n this.debug = false;\n this.options = {\n 'host': '',\n 'auth': null,\n 'broadcaster': {},\n 'pusher_key': null\n };\n } // /**\n // * Install function\n // */\n\n\n _createClass(VLE, [{\n key: \"install\",\n value: function install(Vue, settings) {\n // settings should be an object\n if (_typeof(settings) !== \"object\") {// throw error\n }\n\n this.initialize(settings);\n Vue.prototype.$echo = this;\n } // /**\n // * Initializing echo\n // */\n\n }, {\n key: \"initialize\",\n value: function initialize(settings) {\n // set debugger\n if (settings.debug && typeof settings.debug === \"boolean\") this.debug = settings.debug;\n this.showDebug(\"initializing!\"); // set broadcaster\n\n if (settings.broadcaster && _typeof(settings.broadcaster) === \"object\") {\n this.options.broadcaster.name = settings.broadcaster.name; // this.options.broadcaster.object = settings.broadcaster.object\n }\n\n this.showDebug(\"Broadcaster set to \", this.options.broadcaster.name); // set host\n\n if (settings.host && typeof settings.host === \"string\") {\n this.options.host = settings.host;\n }\n\n this.showDebug(\"Host set to \", this.options.host); // set auth headers\n\n if (settings.auth && _typeof(settings.auth) === 'object' && settings.auth.headers && _typeof(settings.auth.headers) === \"object\") {\n var _arr = Object.entries(settings.auth.headers);\n\n for (var _i = 0; _i < _arr.length; _i++) {\n var _arr$_i = _slicedToArray(_arr[_i], 2),\n header = _arr$_i[0],\n value = _arr$_i[1];\n\n this.addAuthHeader(header, value);\n this.showDebug(\"Auth header set to \", header + value);\n }\n } // set the store\n\n\n if (settings.store && _typeof(settings.store) === 'object') {\n this.store = settings.store;\n this.showDebug('echo store', _store.default);\n this.store.registerModule(['echo'], _store.default);\n }\n\n this.showDebug('Store is set to ', this.store);\n var options = {\n broadcaster: this.options.broadcaster.name,\n host: this.options.host\n };\n if (this.options.auth) options.auth = this.options.auth;\n this.echo = new this.rawEcho(options);\n this.showDebug(\"echo set to \", this.echo);\n }\n /**\n * private\n */\n\n }, {\n key: \"private\",\n value: function _private(channel) {\n this.showDebug(\"Joining private channel \" + channel);\n var response = this.echo.private(channel);\n this.store.dispatch('echo/addChannel', channel);\n return response;\n }\n /**\n * public \n */\n\n }, {\n key: \"public\",\n value: function _public(channel) {\n return this.echo.channel(channel);\n }\n }, {\n key: \"channel\",\n value: function channel(_channel) {\n this.showDebug(\"Joining public channel \" + _channel);\n var response = this.echo.private(_channel);\n this.store.dispatch('echo/addChannel', _channel);\n return response;\n }\n /** \n * leave a channel\n */\n\n }, {\n key: \"leave\",\n value: function leave(channel) {\n this.showDebug(\"Leaving channel \" + channel);\n var response = this.echo.leave(channel);\n this.showDebug(response);\n return response;\n }\n /**\n * Add auth header\n */\n\n }, {\n key: \"addAuthHeader\",\n value: function addAuthHeader(header, value) {\n if (!this.options.auth) this.options.auth = {};\n if (!this.options.auth.headers) this.options.auth.headers = {};\n this.options.auth.headers[header] = value;\n }\n }, {\n key: \"addAuthToken\",\n value: function addAuthToken(token) {\n // check if object is set\n if (this.echo.connector._defaultOptions.auth) {\n this.echo.connector._defaultOptions.auth.headers['Authorization'] = 'Bearer ' + token;\n }\n\n this.showDebug('settings auth token to ', token);\n }\n /**\n * List channels\n */\n\n }, {\n key: \"channels\",\n value: function channels() {\n return Object.getOwnPropertyNames(this.echo.connector.channels);\n }\n /**\n * Status\n */\n\n }, {\n key: \"isConnected\",\n value: function isConnected() {\n return this.echo.connector.socket.connected;\n }\n /** \n * Debug\n */\n\n }, {\n key: \"showDebug\",\n value: function showDebug(string) {\n var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;\n if (this.debug) console.log(string, data);\n }\n }]);\n\n return VLE;\n}();\n\nvar _default = new vue_laravel_echo(_laravelEcho.default, _store.default);\n\nexports.default = _default;\n\n//# sourceURL=webpack://vue_laravel_echo/./index.js?");
/***/ }),
/***/ "./store/actions.js":
/*!**************************!*\
!*** ./store/actions.js ***!
\**************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar addChannel = function addChannel(_ref, channel) {\n var commit = _ref.commit;\n commit('ADD_CHANNEL', channel);\n};\n\nvar _default = {\n addChannel: addChannel\n};\nexports.default = _default;\n\n//# sourceURL=webpack://vue_laravel_echo/./store/actions.js?");
/***/ }),
/***/ "./store/getters.js":
/*!**************************!*\
!*** ./store/getters.js ***!
\**************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
eval("\n\n//# sourceURL=webpack://vue_laravel_echo/./store/getters.js?");
/***/ }),
/***/ "./store/index.js":
/*!************************!*\
!*** ./store/index.js ***!
\************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar _actions = _interopRequireDefault(__webpack_require__(/*! ./actions */ \"./store/actions.js\"));\n\nvar _getters = _interopRequireDefault(__webpack_require__(/*! ./getters */ \"./store/getters.js\"));\n\nvar _mutations = _interopRequireDefault(__webpack_require__(/*! ./mutations */ \"./store/mutations.js\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar state = {\n 'channels': {}\n};\nvar _default = {\n namespaced: true,\n state: state,\n getters: _getters.default,\n actions: _actions.default,\n mutations: _mutations.default\n};\nexports.default = _default;\n\n//# sourceURL=webpack://vue_laravel_echo/./store/index.js?");
/***/ }),
/***/ "./store/mutations.js":
/*!****************************!*\
!*** ./store/mutations.js ***!
\****************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar ADD_CHANNEL = function ADD_CHANNEL(state, channel) {\n console.log('mutationg store to add channel ' + channel);\n state.channels[channel] = {};\n};\n\nvar _default = {\n ADD_CHANNEL: ADD_CHANNEL\n};\nexports.default = _default;\n\n//# sourceURL=webpack://vue_laravel_echo/./store/mutations.js?");
/***/ })
/******/ });