laravel-echo
Advanced tools
Comparing version 1.3.2 to 1.3.3
@@ -208,3 +208,3 @@ var asyncGenerator = function () { | ||
var selector = void 0; | ||
if (window && window['Laravel'] && window['Laravel'].csrfToken) { | ||
if (typeof window !== 'undefined' && window['Laravel'] && window['Laravel'].csrfToken) { | ||
return window['Laravel'].csrfToken; | ||
@@ -624,2 +624,3 @@ } else if (this.options.csrfToken) { | ||
value: function connect() { | ||
var io = this.getSocketIO(); | ||
this.socket = io(this.options.host, this.options); | ||
@@ -629,2 +630,13 @@ return this.socket; | ||
}, { | ||
key: 'getSocketIO', | ||
value: function getSocketIO() { | ||
if (typeof io !== 'undefined') { | ||
return io; | ||
} | ||
if (this.options.client !== 'undefined') { | ||
return this.options.client; | ||
} | ||
throw new Error('Socket.io client not found. Should be globally available or passed via options.client'); | ||
} | ||
}, { | ||
key: 'listen', | ||
@@ -631,0 +643,0 @@ value: function listen(name, event, callback) { |
{ | ||
"name": "laravel-echo", | ||
"version": "1.3.2", | ||
"version": "1.3.3", | ||
"description": "Laravel Echo library for beautiful Pusher and Socket.IO integration", | ||
@@ -23,4 +23,8 @@ "main": "dist/echo.js", | ||
"homepage": "https://github.com/laravel/echo", | ||
"engines": { | ||
"node": ">6.0.*" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@types/node": "^6.0.85", | ||
"babel-plugin-transform-object-assign": "^6.8.0", | ||
@@ -32,5 +36,4 @@ "babel-preset-es2015-rollup": "^3.0.0", | ||
"rollup-plugin-babel": "^2.4.0", | ||
"rollup-plugin-typescript": "^0.7.5", | ||
"typings": "^1.0.4" | ||
"rollup-plugin-typescript": "^0.7.5" | ||
} | ||
} |
@@ -64,3 +64,3 @@ import { Channel, PresenceChannel } from './../channel'; | ||
if (window && window['Laravel'] && window['Laravel'].csrfToken) { | ||
if (typeof window !== 'undefined' && window['Laravel'] && window['Laravel'].csrfToken) { | ||
return window['Laravel'].csrfToken; | ||
@@ -67,0 +67,0 @@ } else if (this.options.csrfToken) { |
@@ -28,2 +28,4 @@ import { Connector } from './connector'; | ||
connect(): void { | ||
let io = this.getSocketIO(); | ||
this.socket = io(this.options.host, this.options); | ||
@@ -35,2 +37,19 @@ | ||
/** | ||
* Get socket.io module from global scope or options. | ||
* | ||
* @type {object} | ||
*/ | ||
getSocketIO(): any { | ||
if (typeof io !== 'undefined') { | ||
return io; | ||
} | ||
if (this.options.client !== 'undefined') { | ||
return this.options.client; | ||
} | ||
throw new Error('Socket.io client not found. Should be globally available or passed via options.client'); | ||
} | ||
/** | ||
* Listen for an event on a channel instance. | ||
@@ -37,0 +56,0 @@ * |
@@ -1,3 +0,1 @@ | ||
/// <reference path="globals/node/index.d.ts" /> | ||
declare let Pusher: any; | ||
@@ -7,2 +5,2 @@ declare let io: any; | ||
declare let axios: any; | ||
declare let jQuery: any; | ||
declare let jQuery: any; |
54423
26
1741