pusher-js 8.0.2 → 8.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Pusher JavaScript Library v8.0.2
2
+ * Pusher JavaScript Library v8.2.0
3
3
  * https://pusher.com/
4
4
  *
5
5
  * Copyright 2020, Pusher
@@ -2963,14 +2963,17 @@ module.exports = __webpack_require__(5).default;
2963
2963
  // ESM COMPAT FLAG
2964
2964
  __webpack_require__.r(__webpack_exports__);
2965
2965
 
2966
+ // EXPORTS
2967
+ __webpack_require__.d(__webpack_exports__, "default", function() { return /* binding */ pusher_with_encryption_PusherWithEncryption; });
2968
+
2966
2969
  // CONCATENATED MODULE: ./src/runtimes/web/dom/script_receiver_factory.ts
2967
- var ScriptReceiverFactory = (function () {
2968
- function ScriptReceiverFactory(prefix, name) {
2970
+ class ScriptReceiverFactory {
2971
+ constructor(prefix, name) {
2969
2972
  this.lastId = 0;
2970
2973
  this.prefix = prefix;
2971
2974
  this.name = name;
2972
2975
  }
2973
- ScriptReceiverFactory.prototype.create = function (callback) {
2976
+ create(callback) {
2974
2977
  this.lastId++;
2975
2978
  var number = this.lastId;
2976
2979
  var id = this.prefix + number;
@@ -2984,18 +2987,16 @@ var ScriptReceiverFactory = (function () {
2984
2987
  };
2985
2988
  this[number] = callbackWrapper;
2986
2989
  return { number: number, id: id, name: name, callback: callbackWrapper };
2987
- };
2988
- ScriptReceiverFactory.prototype.remove = function (receiver) {
2990
+ }
2991
+ remove(receiver) {
2989
2992
  delete this[receiver.number];
2990
- };
2991
- return ScriptReceiverFactory;
2992
- }());
2993
-
2993
+ }
2994
+ }
2994
2995
  var ScriptReceivers = new ScriptReceiverFactory('_pusher_script_', 'Pusher.ScriptReceivers');
2995
2996
 
2996
2997
  // CONCATENATED MODULE: ./src/core/defaults.ts
2997
2998
  var Defaults = {
2998
- VERSION: "8.0.2",
2999
+ VERSION: "8.2.0",
2999
3000
  PROTOCOL: 7,
3000
3001
  wsPort: 80,
3001
3002
  wssPort: 443,
@@ -3027,13 +3028,13 @@ var Defaults = {
3027
3028
  // CONCATENATED MODULE: ./src/runtimes/web/dom/dependency_loader.ts
3028
3029
 
3029
3030
 
3030
- var dependency_loader_DependencyLoader = (function () {
3031
- function DependencyLoader(options) {
3031
+ class dependency_loader_DependencyLoader {
3032
+ constructor(options) {
3032
3033
  this.options = options;
3033
3034
  this.receivers = options.receivers || ScriptReceivers;
3034
3035
  this.loading = {};
3035
3036
  }
3036
- DependencyLoader.prototype.load = function (name, options, callback) {
3037
+ load(name, options, callback) {
3037
3038
  var self = this;
3038
3039
  if (self.loading[name] && self.loading[name].length > 0) {
3039
3040
  self.loading[name].push(callback);
@@ -3058,8 +3059,8 @@ var dependency_loader_DependencyLoader = (function () {
3058
3059
  });
3059
3060
  request.send(receiver);
3060
3061
  }
3061
- };
3062
- DependencyLoader.prototype.getRoot = function (options) {
3062
+ }
3063
+ getRoot(options) {
3063
3064
  var cdn;
3064
3065
  var protocol = runtime.getDocument().location.protocol;
3065
3066
  if ((options && options.useTLS) || protocol === 'https:') {
@@ -3069,20 +3070,18 @@ var dependency_loader_DependencyLoader = (function () {
3069
3070
  cdn = this.options.cdn_http;
3070
3071
  }
3071
3072
  return cdn.replace(/\/*$/, '') + '/' + this.options.version;
3072
- };
3073
- DependencyLoader.prototype.getPath = function (name, options) {
3073
+ }
3074
+ getPath(name, options) {
3074
3075
  return this.getRoot(options) + '/' + name + this.options.suffix + '.js';
3075
- };
3076
- return DependencyLoader;
3077
- }());
3078
- /* harmony default export */ var dependency_loader = (dependency_loader_DependencyLoader);
3076
+ }
3077
+ }
3079
3078
 
3080
3079
  // CONCATENATED MODULE: ./src/runtimes/web/dom/dependencies.ts
3081
3080
 
3082
3081
 
3083
3082
 
3084
3083
  var DependenciesReceivers = new ScriptReceiverFactory('_pusher_dependencies', 'Pusher.DependenciesReceivers');
3085
- var Dependencies = new dependency_loader({
3084
+ var Dependencies = new dependency_loader_DependencyLoader({
3086
3085
  cdn_http: defaults.cdn_http,
3087
3086
  cdn_https: defaults.cdn_https,
3088
3087
  version: defaults.VERSION,
@@ -3091,7 +3090,7 @@ var Dependencies = new dependency_loader({
3091
3090
  });
3092
3091
 
3093
3092
  // CONCATENATED MODULE: ./src/core/utils/url_store.ts
3094
- var urlStore = {
3093
+ const urlStore = {
3095
3094
  baseUrl: 'https://pusher.com',
3096
3095
  urls: {
3097
3096
  authenticationEndpoint: {
@@ -3111,12 +3110,12 @@ var urlStore = {
3111
3110
  }
3112
3111
  }
3113
3112
  };
3114
- var buildLogSuffix = function (key) {
3115
- var urlPrefix = 'See:';
3116
- var urlObj = urlStore.urls[key];
3113
+ const buildLogSuffix = function (key) {
3114
+ const urlPrefix = 'See:';
3115
+ const urlObj = urlStore.urls[key];
3117
3116
  if (!urlObj)
3118
3117
  return '';
3119
- var url;
3118
+ let url;
3120
3119
  if (urlObj.fullUrl) {
3121
3120
  url = urlObj.fullUrl;
3122
3121
  }
@@ -3125,9 +3124,9 @@ var buildLogSuffix = function (key) {
3125
3124
  }
3126
3125
  if (!url)
3127
3126
  return '';
3128
- return urlPrefix + " " + url;
3127
+ return `${urlPrefix} ${url}`;
3129
3128
  };
3130
- /* harmony default export */ var url_store = ({ buildLogSuffix: buildLogSuffix });
3129
+ /* harmony default export */ var url_store = ({ buildLogSuffix });
3131
3130
 
3132
3131
  // CONCATENATED MODULE: ./src/core/auth/options.ts
3133
3132
  var AuthRequestType;
@@ -3137,134 +3136,76 @@ var AuthRequestType;
3137
3136
  })(AuthRequestType || (AuthRequestType = {}));
3138
3137
 
3139
3138
  // CONCATENATED MODULE: ./src/core/errors.ts
3140
- var __extends = (undefined && undefined.__extends) || (function () {
3141
- var extendStatics = function (d, b) {
3142
- extendStatics = Object.setPrototypeOf ||
3143
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
3144
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
3145
- return extendStatics(d, b);
3146
- };
3147
- return function (d, b) {
3148
- extendStatics(d, b);
3149
- function __() { this.constructor = d; }
3150
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
3151
- };
3152
- })();
3153
- var BadEventName = (function (_super) {
3154
- __extends(BadEventName, _super);
3155
- function BadEventName(msg) {
3156
- var _newTarget = this.constructor;
3157
- var _this = _super.call(this, msg) || this;
3158
- Object.setPrototypeOf(_this, _newTarget.prototype);
3159
- return _this;
3160
- }
3161
- return BadEventName;
3162
- }(Error));
3163
-
3164
- var BadChannelName = (function (_super) {
3165
- __extends(BadChannelName, _super);
3166
- function BadChannelName(msg) {
3167
- var _newTarget = this.constructor;
3168
- var _this = _super.call(this, msg) || this;
3169
- Object.setPrototypeOf(_this, _newTarget.prototype);
3170
- return _this;
3171
- }
3172
- return BadChannelName;
3173
- }(Error));
3174
-
3175
- var RequestTimedOut = (function (_super) {
3176
- __extends(RequestTimedOut, _super);
3177
- function RequestTimedOut(msg) {
3178
- var _newTarget = this.constructor;
3179
- var _this = _super.call(this, msg) || this;
3180
- Object.setPrototypeOf(_this, _newTarget.prototype);
3181
- return _this;
3182
- }
3183
- return RequestTimedOut;
3184
- }(Error));
3185
-
3186
- var TransportPriorityTooLow = (function (_super) {
3187
- __extends(TransportPriorityTooLow, _super);
3188
- function TransportPriorityTooLow(msg) {
3189
- var _newTarget = this.constructor;
3190
- var _this = _super.call(this, msg) || this;
3191
- Object.setPrototypeOf(_this, _newTarget.prototype);
3192
- return _this;
3193
- }
3194
- return TransportPriorityTooLow;
3195
- }(Error));
3196
-
3197
- var TransportClosed = (function (_super) {
3198
- __extends(TransportClosed, _super);
3199
- function TransportClosed(msg) {
3200
- var _newTarget = this.constructor;
3201
- var _this = _super.call(this, msg) || this;
3202
- Object.setPrototypeOf(_this, _newTarget.prototype);
3203
- return _this;
3204
- }
3205
- return TransportClosed;
3206
- }(Error));
3207
-
3208
- var UnsupportedFeature = (function (_super) {
3209
- __extends(UnsupportedFeature, _super);
3210
- function UnsupportedFeature(msg) {
3211
- var _newTarget = this.constructor;
3212
- var _this = _super.call(this, msg) || this;
3213
- Object.setPrototypeOf(_this, _newTarget.prototype);
3214
- return _this;
3215
- }
3216
- return UnsupportedFeature;
3217
- }(Error));
3218
-
3219
- var UnsupportedTransport = (function (_super) {
3220
- __extends(UnsupportedTransport, _super);
3221
- function UnsupportedTransport(msg) {
3222
- var _newTarget = this.constructor;
3223
- var _this = _super.call(this, msg) || this;
3224
- Object.setPrototypeOf(_this, _newTarget.prototype);
3225
- return _this;
3226
- }
3227
- return UnsupportedTransport;
3228
- }(Error));
3229
-
3230
- var UnsupportedStrategy = (function (_super) {
3231
- __extends(UnsupportedStrategy, _super);
3232
- function UnsupportedStrategy(msg) {
3233
- var _newTarget = this.constructor;
3234
- var _this = _super.call(this, msg) || this;
3235
- Object.setPrototypeOf(_this, _newTarget.prototype);
3236
- return _this;
3237
- }
3238
- return UnsupportedStrategy;
3239
- }(Error));
3240
-
3241
- var HTTPAuthError = (function (_super) {
3242
- __extends(HTTPAuthError, _super);
3243
- function HTTPAuthError(status, msg) {
3244
- var _newTarget = this.constructor;
3245
- var _this = _super.call(this, msg) || this;
3246
- _this.status = status;
3247
- Object.setPrototypeOf(_this, _newTarget.prototype);
3248
- return _this;
3249
- }
3250
- return HTTPAuthError;
3251
- }(Error));
3252
-
3139
+ class BadEventName extends Error {
3140
+ constructor(msg) {
3141
+ super(msg);
3142
+ Object.setPrototypeOf(this, new.target.prototype);
3143
+ }
3144
+ }
3145
+ class BadChannelName extends Error {
3146
+ constructor(msg) {
3147
+ super(msg);
3148
+ Object.setPrototypeOf(this, new.target.prototype);
3149
+ }
3150
+ }
3151
+ class RequestTimedOut extends Error {
3152
+ constructor(msg) {
3153
+ super(msg);
3154
+ Object.setPrototypeOf(this, new.target.prototype);
3155
+ }
3156
+ }
3157
+ class TransportPriorityTooLow extends Error {
3158
+ constructor(msg) {
3159
+ super(msg);
3160
+ Object.setPrototypeOf(this, new.target.prototype);
3161
+ }
3162
+ }
3163
+ class TransportClosed extends Error {
3164
+ constructor(msg) {
3165
+ super(msg);
3166
+ Object.setPrototypeOf(this, new.target.prototype);
3167
+ }
3168
+ }
3169
+ class UnsupportedFeature extends Error {
3170
+ constructor(msg) {
3171
+ super(msg);
3172
+ Object.setPrototypeOf(this, new.target.prototype);
3173
+ }
3174
+ }
3175
+ class UnsupportedTransport extends Error {
3176
+ constructor(msg) {
3177
+ super(msg);
3178
+ Object.setPrototypeOf(this, new.target.prototype);
3179
+ }
3180
+ }
3181
+ class UnsupportedStrategy extends Error {
3182
+ constructor(msg) {
3183
+ super(msg);
3184
+ Object.setPrototypeOf(this, new.target.prototype);
3185
+ }
3186
+ }
3187
+ class HTTPAuthError extends Error {
3188
+ constructor(status, msg) {
3189
+ super(msg);
3190
+ this.status = status;
3191
+ Object.setPrototypeOf(this, new.target.prototype);
3192
+ }
3193
+ }
3253
3194
 
3254
3195
  // CONCATENATED MODULE: ./src/runtimes/isomorphic/auth/xhr_auth.ts
3255
3196
 
3256
3197
 
3257
3198
 
3258
3199
 
3259
- var ajax = function (context, query, authOptions, authRequestType, callback) {
3260
- var xhr = runtime.createXHR();
3200
+ const ajax = function (context, query, authOptions, authRequestType, callback) {
3201
+ const xhr = runtime.createXHR();
3261
3202
  xhr.open('POST', authOptions.endpoint, true);
3262
3203
  xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
3263
3204
  for (var headerName in authOptions.headers) {
3264
3205
  xhr.setRequestHeader(headerName, authOptions.headers[headerName]);
3265
3206
  }
3266
3207
  if (authOptions.headersProvider != null) {
3267
- var dynamicHeaders = authOptions.headersProvider();
3208
+ let dynamicHeaders = authOptions.headersProvider();
3268
3209
  for (var headerName in dynamicHeaders) {
3269
3210
  xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);
3270
3211
  }
@@ -3272,31 +3213,31 @@ var ajax = function (context, query, authOptions, authRequestType, callback) {
3272
3213
  xhr.onreadystatechange = function () {
3273
3214
  if (xhr.readyState === 4) {
3274
3215
  if (xhr.status === 200) {
3275
- var data = void 0;
3276
- var parsed = false;
3216
+ let data;
3217
+ let parsed = false;
3277
3218
  try {
3278
3219
  data = JSON.parse(xhr.responseText);
3279
3220
  parsed = true;
3280
3221
  }
3281
3222
  catch (e) {
3282
- callback(new HTTPAuthError(200, "JSON returned from " + authRequestType.toString() + " endpoint was invalid, yet status code was 200. Data was: " + xhr.responseText), null);
3223
+ callback(new HTTPAuthError(200, `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${xhr.responseText}`), null);
3283
3224
  }
3284
3225
  if (parsed) {
3285
3226
  callback(null, data);
3286
3227
  }
3287
3228
  }
3288
3229
  else {
3289
- var suffix = '';
3230
+ let suffix = '';
3290
3231
  switch (authRequestType) {
3291
3232
  case AuthRequestType.UserAuthentication:
3292
3233
  suffix = url_store.buildLogSuffix('authenticationEndpoint');
3293
3234
  break;
3294
3235
  case AuthRequestType.ChannelAuthorization:
3295
- suffix = "Clients must be authorized to join private or presence channels. " + url_store.buildLogSuffix('authorizationEndpoint');
3236
+ suffix = `Clients must be authorized to join private or presence channels. ${url_store.buildLogSuffix('authorizationEndpoint')}`;
3296
3237
  break;
3297
3238
  }
3298
- callback(new HTTPAuthError(xhr.status, "Unable to retrieve auth string from " + authRequestType.toString() + " endpoint - " +
3299
- ("received status: " + xhr.status + " from " + authOptions.endpoint + ". " + suffix)), null);
3239
+ callback(new HTTPAuthError(xhr.status, `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +
3240
+ `received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`), null);
3300
3241
  }
3301
3242
  }
3302
3243
  };
@@ -3347,43 +3288,28 @@ var btoa = window.btoa ||
3347
3288
  };
3348
3289
 
3349
3290
  // CONCATENATED MODULE: ./src/core/utils/timers/abstract_timer.ts
3350
- var Timer = (function () {
3351
- function Timer(set, clear, delay, callback) {
3352
- var _this = this;
3291
+ class Timer {
3292
+ constructor(set, clear, delay, callback) {
3353
3293
  this.clear = clear;
3354
- this.timer = set(function () {
3355
- if (_this.timer) {
3356
- _this.timer = callback(_this.timer);
3294
+ this.timer = set(() => {
3295
+ if (this.timer) {
3296
+ this.timer = callback(this.timer);
3357
3297
  }
3358
3298
  }, delay);
3359
3299
  }
3360
- Timer.prototype.isRunning = function () {
3300
+ isRunning() {
3361
3301
  return this.timer !== null;
3362
- };
3363
- Timer.prototype.ensureAborted = function () {
3302
+ }
3303
+ ensureAborted() {
3364
3304
  if (this.timer) {
3365
3305
  this.clear(this.timer);
3366
3306
  this.timer = null;
3367
3307
  }
3368
- };
3369
- return Timer;
3370
- }());
3308
+ }
3309
+ }
3371
3310
  /* harmony default export */ var abstract_timer = (Timer);
3372
3311
 
3373
3312
  // CONCATENATED MODULE: ./src/core/utils/timers/index.ts
3374
- var timers_extends = (undefined && undefined.__extends) || (function () {
3375
- var extendStatics = function (d, b) {
3376
- extendStatics = Object.setPrototypeOf ||
3377
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
3378
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
3379
- return extendStatics(d, b);
3380
- };
3381
- return function (d, b) {
3382
- extendStatics(d, b);
3383
- function __() { this.constructor = d; }
3384
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
3385
- };
3386
- })();
3387
3313
 
3388
3314
  function timers_clearTimeout(timer) {
3389
3315
  window.clearTimeout(timer);
@@ -3391,33 +3317,27 @@ function timers_clearTimeout(timer) {
3391
3317
  function timers_clearInterval(timer) {
3392
3318
  window.clearInterval(timer);
3393
3319
  }
3394
- var OneOffTimer = (function (_super) {
3395
- timers_extends(OneOffTimer, _super);
3396
- function OneOffTimer(delay, callback) {
3397
- return _super.call(this, setTimeout, timers_clearTimeout, delay, function (timer) {
3320
+ class timers_OneOffTimer extends abstract_timer {
3321
+ constructor(delay, callback) {
3322
+ super(setTimeout, timers_clearTimeout, delay, function (timer) {
3398
3323
  callback();
3399
3324
  return null;
3400
- }) || this;
3325
+ });
3401
3326
  }
3402
- return OneOffTimer;
3403
- }(abstract_timer));
3404
-
3405
- var PeriodicTimer = (function (_super) {
3406
- timers_extends(PeriodicTimer, _super);
3407
- function PeriodicTimer(delay, callback) {
3408
- return _super.call(this, setInterval, timers_clearInterval, delay, function (timer) {
3327
+ }
3328
+ class timers_PeriodicTimer extends abstract_timer {
3329
+ constructor(delay, callback) {
3330
+ super(setInterval, timers_clearInterval, delay, function (timer) {
3409
3331
  callback();
3410
3332
  return timer;
3411
- }) || this;
3333
+ });
3412
3334
  }
3413
- return PeriodicTimer;
3414
- }(abstract_timer));
3415
-
3335
+ }
3416
3336
 
3417
3337
  // CONCATENATED MODULE: ./src/core/util.ts
3418
3338
 
3419
3339
  var Util = {
3420
- now: function () {
3340
+ now() {
3421
3341
  if (Date.now) {
3422
3342
  return Date.now();
3423
3343
  }
@@ -3425,14 +3345,10 @@ var Util = {
3425
3345
  return new Date().valueOf();
3426
3346
  }
3427
3347
  },
3428
- defer: function (callback) {
3429
- return new OneOffTimer(0, callback);
3348
+ defer(callback) {
3349
+ return new timers_OneOffTimer(0, callback);
3430
3350
  },
3431
- method: function (name) {
3432
- var args = [];
3433
- for (var _i = 1; _i < arguments.length; _i++) {
3434
- args[_i - 1] = arguments[_i];
3435
- }
3351
+ method(name, ...args) {
3436
3352
  var boundArguments = Array.prototype.slice.call(arguments, 1);
3437
3353
  return function (object) {
3438
3354
  return object[name].apply(object, boundArguments.concat(arguments));
@@ -3444,11 +3360,7 @@ var Util = {
3444
3360
  // CONCATENATED MODULE: ./src/core/utils/collections.ts
3445
3361
 
3446
3362
 
3447
- function extend(target) {
3448
- var sources = [];
3449
- for (var _i = 1; _i < arguments.length; _i++) {
3450
- sources[_i - 1] = arguments[_i];
3451
- }
3363
+ function extend(target, ...sources) {
3452
3364
  for (var i = 0; i < sources.length; i++) {
3453
3365
  var extensions = sources[i];
3454
3366
  for (var property in extensions) {
@@ -3642,67 +3554,50 @@ function safeJSONStringify(source) {
3642
3554
  // CONCATENATED MODULE: ./src/core/logger.ts
3643
3555
 
3644
3556
 
3645
- var logger_Logger = (function () {
3646
- function Logger() {
3647
- this.globalLog = function (message) {
3557
+ class logger_Logger {
3558
+ constructor() {
3559
+ this.globalLog = (message) => {
3648
3560
  if (window.console && window.console.log) {
3649
3561
  window.console.log(message);
3650
3562
  }
3651
3563
  };
3652
3564
  }
3653
- Logger.prototype.debug = function () {
3654
- var args = [];
3655
- for (var _i = 0; _i < arguments.length; _i++) {
3656
- args[_i] = arguments[_i];
3657
- }
3565
+ debug(...args) {
3658
3566
  this.log(this.globalLog, args);
3659
- };
3660
- Logger.prototype.warn = function () {
3661
- var args = [];
3662
- for (var _i = 0; _i < arguments.length; _i++) {
3663
- args[_i] = arguments[_i];
3664
- }
3567
+ }
3568
+ warn(...args) {
3665
3569
  this.log(this.globalLogWarn, args);
3666
- };
3667
- Logger.prototype.error = function () {
3668
- var args = [];
3669
- for (var _i = 0; _i < arguments.length; _i++) {
3670
- args[_i] = arguments[_i];
3671
- }
3570
+ }
3571
+ error(...args) {
3672
3572
  this.log(this.globalLogError, args);
3673
- };
3674
- Logger.prototype.globalLogWarn = function (message) {
3573
+ }
3574
+ globalLogWarn(message) {
3675
3575
  if (window.console && window.console.warn) {
3676
3576
  window.console.warn(message);
3677
3577
  }
3678
3578
  else {
3679
3579
  this.globalLog(message);
3680
3580
  }
3681
- };
3682
- Logger.prototype.globalLogError = function (message) {
3581
+ }
3582
+ globalLogError(message) {
3683
3583
  if (window.console && window.console.error) {
3684
3584
  window.console.error(message);
3685
3585
  }
3686
3586
  else {
3687
3587
  this.globalLogWarn(message);
3688
3588
  }
3689
- };
3690
- Logger.prototype.log = function (defaultLoggingFunction) {
3691
- var args = [];
3692
- for (var _i = 1; _i < arguments.length; _i++) {
3693
- args[_i - 1] = arguments[_i];
3694
- }
3589
+ }
3590
+ log(defaultLoggingFunction, ...args) {
3695
3591
  var message = stringify.apply(this, arguments);
3696
3592
  if (core_pusher.log) {
3697
3593
  core_pusher.log(message);
3698
3594
  }
3699
3595
  else if (core_pusher.logToConsole) {
3700
- var log = defaultLoggingFunction.bind(this);
3596
+ const log = defaultLoggingFunction.bind(this);
3701
3597
  log(message);
3702
3598
  }
3703
- };
3704
- return Logger;
3705
- }());
3599
+ }
3600
+ }
3706
3601
  /* harmony default export */ var logger = (new logger_Logger());
3707
3602
 
3708
3603
  // CONCATENATED MODULE: ./src/runtimes/web/auth/jsonp_auth.ts
@@ -3710,7 +3605,7 @@ var logger_Logger = (function () {
3710
3605
  var jsonp = function (context, query, authOptions, authRequestType, callback) {
3711
3606
  if (authOptions.headers !== undefined ||
3712
3607
  authOptions.headersProvider != null) {
3713
- logger.warn("To send headers with the " + authRequestType.toString() + " request, you must use AJAX, rather than JSONP.");
3608
+ logger.warn(`To send headers with the ${authRequestType.toString()} request, you must use AJAX, rather than JSONP.`);
3714
3609
  }
3715
3610
  var callbackName = context.nextAuthCallbackID.toString();
3716
3611
  context.nextAuthCallbackID++;
@@ -3732,11 +3627,11 @@ var jsonp = function (context, query, authOptions, authRequestType, callback) {
3732
3627
  /* harmony default export */ var jsonp_auth = (jsonp);
3733
3628
 
3734
3629
  // CONCATENATED MODULE: ./src/runtimes/web/dom/script_request.ts
3735
- var ScriptRequest = (function () {
3736
- function ScriptRequest(src) {
3630
+ class ScriptRequest {
3631
+ constructor(src) {
3737
3632
  this.src = src;
3738
3633
  }
3739
- ScriptRequest.prototype.send = function (receiver) {
3634
+ send(receiver) {
3740
3635
  var self = this;
3741
3636
  var errorString = 'Error loading ' + self.src;
3742
3637
  self.script = document.createElement('script');
@@ -3776,8 +3671,8 @@ var ScriptRequest = (function () {
3776
3671
  if (self.errorScript) {
3777
3672
  head.insertBefore(self.errorScript, self.script.nextSibling);
3778
3673
  }
3779
- };
3780
- ScriptRequest.prototype.cleanup = function () {
3674
+ }
3675
+ cleanup() {
3781
3676
  if (this.script) {
3782
3677
  this.script.onload = this.script.onerror = null;
3783
3678
  this.script.onreadystatechange = null;
@@ -3790,20 +3685,18 @@ var ScriptRequest = (function () {
3790
3685
  }
3791
3686
  this.script = null;
3792
3687
  this.errorScript = null;
3793
- };
3794
- return ScriptRequest;
3795
- }());
3796
- /* harmony default export */ var script_request = (ScriptRequest);
3688
+ }
3689
+ }
3797
3690
 
3798
3691
  // CONCATENATED MODULE: ./src/runtimes/web/dom/jsonp_request.ts
3799
3692
 
3800
3693
 
3801
- var jsonp_request_JSONPRequest = (function () {
3802
- function JSONPRequest(url, data) {
3694
+ class jsonp_request_JSONPRequest {
3695
+ constructor(url, data) {
3803
3696
  this.url = url;
3804
3697
  this.data = data;
3805
3698
  }
3806
- JSONPRequest.prototype.send = function (receiver) {
3699
+ send(receiver) {
3807
3700
  if (this.request) {
3808
3701
  return;
3809
3702
  }
@@ -3811,15 +3704,13 @@ var jsonp_request_JSONPRequest = (function () {
3811
3704
  var url = this.url + '/' + receiver.number + '?' + query;
3812
3705
  this.request = runtime.createScriptRequest(url);
3813
3706
  this.request.send(receiver);
3814
- };
3815
- JSONPRequest.prototype.cleanup = function () {
3707
+ }
3708
+ cleanup() {
3816
3709
  if (this.request) {
3817
3710
  this.request.cleanup();
3818
3711
  }
3819
- };
3820
- return JSONPRequest;
3821
- }());
3822
- /* harmony default export */ var jsonp_request = (jsonp_request_JSONPRequest);
3712
+ }
3713
+ }
3823
3714
 
3824
3715
  // CONCATENATED MODULE: ./src/runtimes/web/timeline/jsonp_timeline.ts
3825
3716
 
@@ -3844,7 +3735,7 @@ var getAgent = function (sender, useTLS) {
3844
3735
  };
3845
3736
  var jsonp_timeline_jsonp = {
3846
3737
  name: 'jsonp',
3847
- getAgent: getAgent
3738
+ getAgent
3848
3739
  };
3849
3740
  /* harmony default export */ var jsonp_timeline = (jsonp_timeline_jsonp);
3850
3741
 
@@ -3888,14 +3779,14 @@ var sockjs = {
3888
3779
 
3889
3780
  // CONCATENATED MODULE: ./src/core/events/callback_registry.ts
3890
3781
 
3891
- var callback_registry_CallbackRegistry = (function () {
3892
- function CallbackRegistry() {
3782
+ class callback_registry_CallbackRegistry {
3783
+ constructor() {
3893
3784
  this._callbacks = {};
3894
3785
  }
3895
- CallbackRegistry.prototype.get = function (name) {
3786
+ get(name) {
3896
3787
  return this._callbacks[prefix(name)];
3897
- };
3898
- CallbackRegistry.prototype.add = function (name, callback, context) {
3788
+ }
3789
+ add(name, callback, context) {
3899
3790
  var prefixedEventName = prefix(name);
3900
3791
  this._callbacks[prefixedEventName] =
3901
3792
  this._callbacks[prefixedEventName] || [];
@@ -3903,8 +3794,8 @@ var callback_registry_CallbackRegistry = (function () {
3903
3794
  fn: callback,
3904
3795
  context: context
3905
3796
  });
3906
- };
3907
- CallbackRegistry.prototype.remove = function (name, callback, context) {
3797
+ }
3798
+ remove(name, callback, context) {
3908
3799
  if (!name && !callback && !context) {
3909
3800
  this._callbacks = {};
3910
3801
  return;
@@ -3916,8 +3807,8 @@ var callback_registry_CallbackRegistry = (function () {
3916
3807
  else {
3917
3808
  this.removeAllCallbacks(names);
3918
3809
  }
3919
- };
3920
- CallbackRegistry.prototype.removeCallback = function (names, callback, context) {
3810
+ }
3811
+ removeCallback(names, callback, context) {
3921
3812
  apply(names, function (name) {
3922
3813
  this._callbacks[name] = filter(this._callbacks[name] || [], function (binding) {
3923
3814
  return ((callback && callback !== binding.fn) ||
@@ -3927,15 +3818,13 @@ var callback_registry_CallbackRegistry = (function () {
3927
3818
  delete this._callbacks[name];
3928
3819
  }
3929
3820
  }, this);
3930
- };
3931
- CallbackRegistry.prototype.removeAllCallbacks = function (names) {
3821
+ }
3822
+ removeAllCallbacks(names) {
3932
3823
  apply(names, function (name) {
3933
3824
  delete this._callbacks[name];
3934
3825
  }, this);
3935
- };
3936
- return CallbackRegistry;
3937
- }());
3938
- /* harmony default export */ var callback_registry = (callback_registry_CallbackRegistry);
3826
+ }
3827
+ }
3939
3828
  function prefix(name) {
3940
3829
  return '_' + name;
3941
3830
  }
@@ -3943,38 +3832,38 @@ function prefix(name) {
3943
3832
  // CONCATENATED MODULE: ./src/core/events/dispatcher.ts
3944
3833
 
3945
3834
 
3946
- var dispatcher_Dispatcher = (function () {
3947
- function Dispatcher(failThrough) {
3948
- this.callbacks = new callback_registry();
3835
+ class dispatcher_Dispatcher {
3836
+ constructor(failThrough) {
3837
+ this.callbacks = new callback_registry_CallbackRegistry();
3949
3838
  this.global_callbacks = [];
3950
3839
  this.failThrough = failThrough;
3951
3840
  }
3952
- Dispatcher.prototype.bind = function (eventName, callback, context) {
3841
+ bind(eventName, callback, context) {
3953
3842
  this.callbacks.add(eventName, callback, context);
3954
3843
  return this;
3955
- };
3956
- Dispatcher.prototype.bind_global = function (callback) {
3844
+ }
3845
+ bind_global(callback) {
3957
3846
  this.global_callbacks.push(callback);
3958
3847
  return this;
3959
- };
3960
- Dispatcher.prototype.unbind = function (eventName, callback, context) {
3848
+ }
3849
+ unbind(eventName, callback, context) {
3961
3850
  this.callbacks.remove(eventName, callback, context);
3962
3851
  return this;
3963
- };
3964
- Dispatcher.prototype.unbind_global = function (callback) {
3852
+ }
3853
+ unbind_global(callback) {
3965
3854
  if (!callback) {
3966
3855
  this.global_callbacks = [];
3967
3856
  return this;
3968
3857
  }
3969
- this.global_callbacks = filter(this.global_callbacks || [], function (c) { return c !== callback; });
3858
+ this.global_callbacks = filter(this.global_callbacks || [], c => c !== callback);
3970
3859
  return this;
3971
- };
3972
- Dispatcher.prototype.unbind_all = function () {
3860
+ }
3861
+ unbind_all() {
3973
3862
  this.unbind();
3974
3863
  this.unbind_global();
3975
3864
  return this;
3976
- };
3977
- Dispatcher.prototype.emit = function (eventName, data, metadata) {
3865
+ }
3866
+ emit(eventName, data, metadata) {
3978
3867
  for (var i = 0; i < this.global_callbacks.length; i++) {
3979
3868
  this.global_callbacks[i](eventName, data);
3980
3869
  }
@@ -3995,54 +3884,36 @@ var dispatcher_Dispatcher = (function () {
3995
3884
  this.failThrough(eventName, data);
3996
3885
  }
3997
3886
  return this;
3998
- };
3999
- return Dispatcher;
4000
- }());
4001
- /* harmony default export */ var dispatcher = (dispatcher_Dispatcher);
3887
+ }
3888
+ }
4002
3889
 
4003
3890
  // CONCATENATED MODULE: ./src/core/transports/transport_connection.ts
4004
- var transport_connection_extends = (undefined && undefined.__extends) || (function () {
4005
- var extendStatics = function (d, b) {
4006
- extendStatics = Object.setPrototypeOf ||
4007
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
4008
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
4009
- return extendStatics(d, b);
4010
- };
4011
- return function (d, b) {
4012
- extendStatics(d, b);
4013
- function __() { this.constructor = d; }
4014
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
4015
- };
4016
- })();
4017
3891
 
4018
3892
 
4019
3893
 
4020
3894
 
4021
3895
 
4022
- var transport_connection_TransportConnection = (function (_super) {
4023
- transport_connection_extends(TransportConnection, _super);
4024
- function TransportConnection(hooks, name, priority, key, options) {
4025
- var _this = _super.call(this) || this;
4026
- _this.initialize = runtime.transportConnectionInitializer;
4027
- _this.hooks = hooks;
4028
- _this.name = name;
4029
- _this.priority = priority;
4030
- _this.key = key;
4031
- _this.options = options;
4032
- _this.state = 'new';
4033
- _this.timeline = options.timeline;
4034
- _this.activityTimeout = options.activityTimeout;
4035
- _this.id = _this.timeline.generateUniqueID();
4036
- return _this;
3896
+ class transport_connection_TransportConnection extends dispatcher_Dispatcher {
3897
+ constructor(hooks, name, priority, key, options) {
3898
+ super();
3899
+ this.initialize = runtime.transportConnectionInitializer;
3900
+ this.hooks = hooks;
3901
+ this.name = name;
3902
+ this.priority = priority;
3903
+ this.key = key;
3904
+ this.options = options;
3905
+ this.state = 'new';
3906
+ this.timeline = options.timeline;
3907
+ this.activityTimeout = options.activityTimeout;
3908
+ this.id = this.timeline.generateUniqueID();
4037
3909
  }
4038
- TransportConnection.prototype.handlesActivityChecks = function () {
3910
+ handlesActivityChecks() {
4039
3911
  return Boolean(this.hooks.handlesActivityChecks);
4040
- };
4041
- TransportConnection.prototype.supportsPing = function () {
3912
+ }
3913
+ supportsPing() {
4042
3914
  return Boolean(this.hooks.supportsPing);
4043
- };
4044
- TransportConnection.prototype.connect = function () {
4045
- var _this = this;
3915
+ }
3916
+ connect() {
4046
3917
  if (this.socket || this.state !== 'initialized') {
4047
3918
  return false;
4048
3919
  }
@@ -4051,18 +3922,18 @@ var transport_connection_TransportConnection = (function (_super) {
4051
3922
  this.socket = this.hooks.getSocket(url, this.options);
4052
3923
  }
4053
3924
  catch (e) {
4054
- util.defer(function () {
4055
- _this.onError(e);
4056
- _this.changeState('closed');
3925
+ util.defer(() => {
3926
+ this.onError(e);
3927
+ this.changeState('closed');
4057
3928
  });
4058
3929
  return false;
4059
3930
  }
4060
3931
  this.bindListeners();
4061
- logger.debug('Connecting', { transport: this.name, url: url });
3932
+ logger.debug('Connecting', { transport: this.name, url });
4062
3933
  this.changeState('connecting');
4063
3934
  return true;
4064
- };
4065
- TransportConnection.prototype.close = function () {
3935
+ }
3936
+ close() {
4066
3937
  if (this.socket) {
4067
3938
  this.socket.close();
4068
3939
  return true;
@@ -4070,13 +3941,12 @@ var transport_connection_TransportConnection = (function (_super) {
4070
3941
  else {
4071
3942
  return false;
4072
3943
  }
4073
- };
4074
- TransportConnection.prototype.send = function (data) {
4075
- var _this = this;
3944
+ }
3945
+ send(data) {
4076
3946
  if (this.state === 'open') {
4077
- util.defer(function () {
4078
- if (_this.socket) {
4079
- _this.socket.send(data);
3947
+ util.defer(() => {
3948
+ if (this.socket) {
3949
+ this.socket.send(data);
4080
3950
  }
4081
3951
  });
4082
3952
  return true;
@@ -4084,24 +3954,24 @@ var transport_connection_TransportConnection = (function (_super) {
4084
3954
  else {
4085
3955
  return false;
4086
3956
  }
4087
- };
4088
- TransportConnection.prototype.ping = function () {
3957
+ }
3958
+ ping() {
4089
3959
  if (this.state === 'open' && this.supportsPing()) {
4090
3960
  this.socket.ping();
4091
3961
  }
4092
- };
4093
- TransportConnection.prototype.onOpen = function () {
3962
+ }
3963
+ onOpen() {
4094
3964
  if (this.hooks.beforeOpen) {
4095
3965
  this.hooks.beforeOpen(this.socket, this.hooks.urls.getPath(this.key, this.options));
4096
3966
  }
4097
3967
  this.changeState('open');
4098
3968
  this.socket.onopen = undefined;
4099
- };
4100
- TransportConnection.prototype.onError = function (error) {
3969
+ }
3970
+ onError(error) {
4101
3971
  this.emit('error', { type: 'WebSocketError', error: error });
4102
3972
  this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));
4103
- };
4104
- TransportConnection.prototype.onClose = function (closeEvent) {
3973
+ }
3974
+ onClose(closeEvent) {
4105
3975
  if (closeEvent) {
4106
3976
  this.changeState('closed', {
4107
3977
  code: closeEvent.code,
@@ -4114,34 +3984,33 @@ var transport_connection_TransportConnection = (function (_super) {
4114
3984
  }
4115
3985
  this.unbindListeners();
4116
3986
  this.socket = undefined;
4117
- };
4118
- TransportConnection.prototype.onMessage = function (message) {
3987
+ }
3988
+ onMessage(message) {
4119
3989
  this.emit('message', message);
4120
- };
4121
- TransportConnection.prototype.onActivity = function () {
3990
+ }
3991
+ onActivity() {
4122
3992
  this.emit('activity');
4123
- };
4124
- TransportConnection.prototype.bindListeners = function () {
4125
- var _this = this;
4126
- this.socket.onopen = function () {
4127
- _this.onOpen();
3993
+ }
3994
+ bindListeners() {
3995
+ this.socket.onopen = () => {
3996
+ this.onOpen();
4128
3997
  };
4129
- this.socket.onerror = function (error) {
4130
- _this.onError(error);
3998
+ this.socket.onerror = error => {
3999
+ this.onError(error);
4131
4000
  };
4132
- this.socket.onclose = function (closeEvent) {
4133
- _this.onClose(closeEvent);
4001
+ this.socket.onclose = closeEvent => {
4002
+ this.onClose(closeEvent);
4134
4003
  };
4135
- this.socket.onmessage = function (message) {
4136
- _this.onMessage(message);
4004
+ this.socket.onmessage = message => {
4005
+ this.onMessage(message);
4137
4006
  };
4138
4007
  if (this.supportsPing()) {
4139
- this.socket.onactivity = function () {
4140
- _this.onActivity();
4008
+ this.socket.onactivity = () => {
4009
+ this.onActivity();
4141
4010
  };
4142
4011
  }
4143
- };
4144
- TransportConnection.prototype.unbindListeners = function () {
4012
+ }
4013
+ unbindListeners() {
4145
4014
  if (this.socket) {
4146
4015
  this.socket.onopen = undefined;
4147
4016
  this.socket.onerror = undefined;
@@ -4151,44 +4020,40 @@ var transport_connection_TransportConnection = (function (_super) {
4151
4020
  this.socket.onactivity = undefined;
4152
4021
  }
4153
4022
  }
4154
- };
4155
- TransportConnection.prototype.changeState = function (state, params) {
4023
+ }
4024
+ changeState(state, params) {
4156
4025
  this.state = state;
4157
4026
  this.timeline.info(this.buildTimelineMessage({
4158
4027
  state: state,
4159
4028
  params: params
4160
4029
  }));
4161
4030
  this.emit(state, params);
4162
- };
4163
- TransportConnection.prototype.buildTimelineMessage = function (message) {
4031
+ }
4032
+ buildTimelineMessage(message) {
4164
4033
  return extend({ cid: this.id }, message);
4165
- };
4166
- return TransportConnection;
4167
- }(dispatcher));
4168
- /* harmony default export */ var transport_connection = (transport_connection_TransportConnection);
4034
+ }
4035
+ }
4169
4036
 
4170
4037
  // CONCATENATED MODULE: ./src/core/transports/transport.ts
4171
4038
 
4172
- var transport_Transport = (function () {
4173
- function Transport(hooks) {
4039
+ class transport_Transport {
4040
+ constructor(hooks) {
4174
4041
  this.hooks = hooks;
4175
4042
  }
4176
- Transport.prototype.isSupported = function (environment) {
4043
+ isSupported(environment) {
4177
4044
  return this.hooks.isSupported(environment);
4178
- };
4179
- Transport.prototype.createConnection = function (name, priority, key, options) {
4180
- return new transport_connection(this.hooks, name, priority, key, options);
4181
- };
4182
- return Transport;
4183
- }());
4184
- /* harmony default export */ var transports_transport = (transport_Transport);
4045
+ }
4046
+ createConnection(name, priority, key, options) {
4047
+ return new transport_connection_TransportConnection(this.hooks, name, priority, key, options);
4048
+ }
4049
+ }
4185
4050
 
4186
4051
  // CONCATENATED MODULE: ./src/runtimes/isomorphic/transports/transports.ts
4187
4052
 
4188
4053
 
4189
4054
 
4190
4055
 
4191
- var WSTransport = new transports_transport({
4056
+ var WSTransport = new transport_Transport({
4192
4057
  urls: ws,
4193
4058
  handlesActivityChecks: false,
4194
4059
  supportsPing: false,
@@ -4225,8 +4090,8 @@ var xhrConfiguration = {
4225
4090
  return runtime.isXHRSupported();
4226
4091
  }
4227
4092
  };
4228
- var XHRStreamingTransport = new transports_transport((extend({}, streamingConfiguration, xhrConfiguration)));
4229
- var XHRPollingTransport = new transports_transport(extend({}, pollingConfiguration, xhrConfiguration));
4093
+ var XHRStreamingTransport = new transport_Transport((extend({}, streamingConfiguration, xhrConfiguration)));
4094
+ var XHRPollingTransport = new transport_Transport(extend({}, pollingConfiguration, xhrConfiguration));
4230
4095
  var Transports = {
4231
4096
  ws: WSTransport,
4232
4097
  xhr_streaming: XHRStreamingTransport,
@@ -4241,7 +4106,7 @@ var Transports = {
4241
4106
 
4242
4107
 
4243
4108
 
4244
- var SockJSTransport = new transports_transport({
4109
+ var SockJSTransport = new transport_Transport({
4245
4110
  file: 'sockjs',
4246
4111
  urls: sockjs,
4247
4112
  handlesActivityChecks: true,
@@ -4272,33 +4137,19 @@ var xdrConfiguration = {
4272
4137
  return yes;
4273
4138
  }
4274
4139
  };
4275
- var XDRStreamingTransport = new transports_transport((extend({}, streamingConfiguration, xdrConfiguration)));
4276
- var XDRPollingTransport = new transports_transport(extend({}, pollingConfiguration, xdrConfiguration));
4140
+ var XDRStreamingTransport = new transport_Transport((extend({}, streamingConfiguration, xdrConfiguration)));
4141
+ var XDRPollingTransport = new transport_Transport(extend({}, pollingConfiguration, xdrConfiguration));
4277
4142
  transports.xdr_streaming = XDRStreamingTransport;
4278
4143
  transports.xdr_polling = XDRPollingTransport;
4279
4144
  transports.sockjs = SockJSTransport;
4280
4145
  /* harmony default export */ var transports_transports = (transports);
4281
4146
 
4282
4147
  // CONCATENATED MODULE: ./src/runtimes/web/net_info.ts
4283
- var net_info_extends = (undefined && undefined.__extends) || (function () {
4284
- var extendStatics = function (d, b) {
4285
- extendStatics = Object.setPrototypeOf ||
4286
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
4287
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
4288
- return extendStatics(d, b);
4289
- };
4290
- return function (d, b) {
4291
- extendStatics(d, b);
4292
- function __() { this.constructor = d; }
4293
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
4294
- };
4295
- })();
4296
4148
 
4297
- var NetInfo = (function (_super) {
4298
- net_info_extends(NetInfo, _super);
4299
- function NetInfo() {
4300
- var _this = _super.call(this) || this;
4301
- var self = _this;
4149
+ class net_info_NetInfo extends dispatcher_Dispatcher {
4150
+ constructor() {
4151
+ super();
4152
+ var self = this;
4302
4153
  if (window.addEventListener !== undefined) {
4303
4154
  window.addEventListener('online', function () {
4304
4155
  self.emit('online');
@@ -4307,34 +4158,30 @@ var NetInfo = (function (_super) {
4307
4158
  self.emit('offline');
4308
4159
  }, false);
4309
4160
  }
4310
- return _this;
4311
4161
  }
4312
- NetInfo.prototype.isOnline = function () {
4162
+ isOnline() {
4313
4163
  if (window.navigator.onLine === undefined) {
4314
4164
  return true;
4315
4165
  }
4316
4166
  else {
4317
4167
  return window.navigator.onLine;
4318
4168
  }
4319
- };
4320
- return NetInfo;
4321
- }(dispatcher));
4322
-
4323
- var net_info_Network = new NetInfo();
4169
+ }
4170
+ }
4171
+ var net_info_Network = new net_info_NetInfo();
4324
4172
 
4325
4173
  // CONCATENATED MODULE: ./src/core/transports/assistant_to_the_transport_manager.ts
4326
4174
 
4327
4175
 
4328
- var assistant_to_the_transport_manager_AssistantToTheTransportManager = (function () {
4329
- function AssistantToTheTransportManager(manager, transport, options) {
4176
+ class assistant_to_the_transport_manager_AssistantToTheTransportManager {
4177
+ constructor(manager, transport, options) {
4330
4178
  this.manager = manager;
4331
4179
  this.transport = transport;
4332
4180
  this.minPingDelay = options.minPingDelay;
4333
4181
  this.maxPingDelay = options.maxPingDelay;
4334
4182
  this.pingDelay = undefined;
4335
4183
  }
4336
- AssistantToTheTransportManager.prototype.createConnection = function (name, priority, key, options) {
4337
- var _this = this;
4184
+ createConnection(name, priority, key, options) {
4338
4185
  options = extend({}, options, {
4339
4186
  activityTimeout: this.pingDelay
4340
4187
  });
@@ -4345,31 +4192,29 @@ var assistant_to_the_transport_manager_AssistantToTheTransportManager = (functio
4345
4192
  connection.bind('closed', onClosed);
4346
4193
  openTimestamp = util.now();
4347
4194
  };
4348
- var onClosed = function (closeEvent) {
4195
+ var onClosed = closeEvent => {
4349
4196
  connection.unbind('closed', onClosed);
4350
4197
  if (closeEvent.code === 1002 || closeEvent.code === 1003) {
4351
- _this.manager.reportDeath();
4198
+ this.manager.reportDeath();
4352
4199
  }
4353
4200
  else if (!closeEvent.wasClean && openTimestamp) {
4354
4201
  var lifespan = util.now() - openTimestamp;
4355
- if (lifespan < 2 * _this.maxPingDelay) {
4356
- _this.manager.reportDeath();
4357
- _this.pingDelay = Math.max(lifespan / 2, _this.minPingDelay);
4202
+ if (lifespan < 2 * this.maxPingDelay) {
4203
+ this.manager.reportDeath();
4204
+ this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);
4358
4205
  }
4359
4206
  }
4360
4207
  };
4361
4208
  connection.bind('open', onOpen);
4362
4209
  return connection;
4363
- };
4364
- AssistantToTheTransportManager.prototype.isSupported = function (environment) {
4210
+ }
4211
+ isSupported(environment) {
4365
4212
  return this.manager.isAlive() && this.transport.isSupported(environment);
4366
- };
4367
- return AssistantToTheTransportManager;
4368
- }());
4369
- /* harmony default export */ var assistant_to_the_transport_manager = (assistant_to_the_transport_manager_AssistantToTheTransportManager);
4213
+ }
4214
+ }
4370
4215
 
4371
4216
  // CONCATENATED MODULE: ./src/core/connection/protocol/protocol.ts
4372
- var Protocol = {
4217
+ const Protocol = {
4373
4218
  decodeMessage: function (messageEvent) {
4374
4219
  try {
4375
4220
  var messageData = JSON.parse(messageEvent.data);
@@ -4462,68 +4307,52 @@ var Protocol = {
4462
4307
  /* harmony default export */ var protocol_protocol = (Protocol);
4463
4308
 
4464
4309
  // CONCATENATED MODULE: ./src/core/connection/connection.ts
4465
- var connection_extends = (undefined && undefined.__extends) || (function () {
4466
- var extendStatics = function (d, b) {
4467
- extendStatics = Object.setPrototypeOf ||
4468
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
4469
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
4470
- return extendStatics(d, b);
4471
- };
4472
- return function (d, b) {
4473
- extendStatics(d, b);
4474
- function __() { this.constructor = d; }
4475
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
4476
- };
4477
- })();
4478
4310
 
4479
4311
 
4480
4312
 
4481
4313
 
4482
- var connection_Connection = (function (_super) {
4483
- connection_extends(Connection, _super);
4484
- function Connection(id, transport) {
4485
- var _this = _super.call(this) || this;
4486
- _this.id = id;
4487
- _this.transport = transport;
4488
- _this.activityTimeout = transport.activityTimeout;
4489
- _this.bindListeners();
4490
- return _this;
4314
+ class connection_Connection extends dispatcher_Dispatcher {
4315
+ constructor(id, transport) {
4316
+ super();
4317
+ this.id = id;
4318
+ this.transport = transport;
4319
+ this.activityTimeout = transport.activityTimeout;
4320
+ this.bindListeners();
4491
4321
  }
4492
- Connection.prototype.handlesActivityChecks = function () {
4322
+ handlesActivityChecks() {
4493
4323
  return this.transport.handlesActivityChecks();
4494
- };
4495
- Connection.prototype.send = function (data) {
4324
+ }
4325
+ send(data) {
4496
4326
  return this.transport.send(data);
4497
- };
4498
- Connection.prototype.send_event = function (name, data, channel) {
4327
+ }
4328
+ send_event(name, data, channel) {
4499
4329
  var event = { event: name, data: data };
4500
4330
  if (channel) {
4501
4331
  event.channel = channel;
4502
4332
  }
4503
4333
  logger.debug('Event sent', event);
4504
4334
  return this.send(protocol_protocol.encodeMessage(event));
4505
- };
4506
- Connection.prototype.ping = function () {
4335
+ }
4336
+ ping() {
4507
4337
  if (this.transport.supportsPing()) {
4508
4338
  this.transport.ping();
4509
4339
  }
4510
4340
  else {
4511
4341
  this.send_event('pusher:ping', {});
4512
4342
  }
4513
- };
4514
- Connection.prototype.close = function () {
4343
+ }
4344
+ close() {
4515
4345
  this.transport.close();
4516
- };
4517
- Connection.prototype.bindListeners = function () {
4518
- var _this = this;
4346
+ }
4347
+ bindListeners() {
4519
4348
  var listeners = {
4520
- message: function (messageEvent) {
4349
+ message: (messageEvent) => {
4521
4350
  var pusherEvent;
4522
4351
  try {
4523
4352
  pusherEvent = protocol_protocol.decodeMessage(messageEvent);
4524
4353
  }
4525
4354
  catch (e) {
4526
- _this.emit('error', {
4355
+ this.emit('error', {
4527
4356
  type: 'MessageParseError',
4528
4357
  error: e,
4529
4358
  data: messageEvent.data
@@ -4533,46 +4362,46 @@ var connection_Connection = (function (_super) {
4533
4362
  logger.debug('Event recd', pusherEvent);
4534
4363
  switch (pusherEvent.event) {
4535
4364
  case 'pusher:error':
4536
- _this.emit('error', {
4365
+ this.emit('error', {
4537
4366
  type: 'PusherError',
4538
4367
  data: pusherEvent.data
4539
4368
  });
4540
4369
  break;
4541
4370
  case 'pusher:ping':
4542
- _this.emit('ping');
4371
+ this.emit('ping');
4543
4372
  break;
4544
4373
  case 'pusher:pong':
4545
- _this.emit('pong');
4374
+ this.emit('pong');
4546
4375
  break;
4547
4376
  }
4548
- _this.emit('message', pusherEvent);
4377
+ this.emit('message', pusherEvent);
4549
4378
  }
4550
4379
  },
4551
- activity: function () {
4552
- _this.emit('activity');
4380
+ activity: () => {
4381
+ this.emit('activity');
4553
4382
  },
4554
- error: function (error) {
4555
- _this.emit('error', error);
4383
+ error: error => {
4384
+ this.emit('error', error);
4556
4385
  },
4557
- closed: function (closeEvent) {
4386
+ closed: closeEvent => {
4558
4387
  unbindListeners();
4559
4388
  if (closeEvent && closeEvent.code) {
4560
- _this.handleCloseEvent(closeEvent);
4389
+ this.handleCloseEvent(closeEvent);
4561
4390
  }
4562
- _this.transport = null;
4563
- _this.emit('closed');
4391
+ this.transport = null;
4392
+ this.emit('closed');
4564
4393
  }
4565
4394
  };
4566
- var unbindListeners = function () {
4567
- objectApply(listeners, function (listener, event) {
4568
- _this.transport.unbind(event, listener);
4395
+ var unbindListeners = () => {
4396
+ objectApply(listeners, (listener, event) => {
4397
+ this.transport.unbind(event, listener);
4569
4398
  });
4570
4399
  };
4571
- objectApply(listeners, function (listener, event) {
4572
- _this.transport.bind(event, listener);
4400
+ objectApply(listeners, (listener, event) => {
4401
+ this.transport.bind(event, listener);
4573
4402
  });
4574
- };
4575
- Connection.prototype.handleCloseEvent = function (closeEvent) {
4403
+ }
4404
+ handleCloseEvent(closeEvent) {
4576
4405
  var action = protocol_protocol.getCloseAction(closeEvent);
4577
4406
  var error = protocol_protocol.getCloseError(closeEvent);
4578
4407
  if (error) {
@@ -4581,136 +4410,114 @@ var connection_Connection = (function (_super) {
4581
4410
  if (action) {
4582
4411
  this.emit(action, { action: action, error: error });
4583
4412
  }
4584
- };
4585
- return Connection;
4586
- }(dispatcher));
4587
- /* harmony default export */ var connection_connection = (connection_Connection);
4413
+ }
4414
+ }
4588
4415
 
4589
4416
  // CONCATENATED MODULE: ./src/core/connection/handshake/index.ts
4590
4417
 
4591
4418
 
4592
4419
 
4593
- var handshake_Handshake = (function () {
4594
- function Handshake(transport, callback) {
4420
+ class handshake_Handshake {
4421
+ constructor(transport, callback) {
4595
4422
  this.transport = transport;
4596
4423
  this.callback = callback;
4597
4424
  this.bindListeners();
4598
4425
  }
4599
- Handshake.prototype.close = function () {
4426
+ close() {
4600
4427
  this.unbindListeners();
4601
4428
  this.transport.close();
4602
- };
4603
- Handshake.prototype.bindListeners = function () {
4604
- var _this = this;
4605
- this.onMessage = function (m) {
4606
- _this.unbindListeners();
4429
+ }
4430
+ bindListeners() {
4431
+ this.onMessage = m => {
4432
+ this.unbindListeners();
4607
4433
  var result;
4608
4434
  try {
4609
4435
  result = protocol_protocol.processHandshake(m);
4610
4436
  }
4611
4437
  catch (e) {
4612
- _this.finish('error', { error: e });
4613
- _this.transport.close();
4438
+ this.finish('error', { error: e });
4439
+ this.transport.close();
4614
4440
  return;
4615
4441
  }
4616
4442
  if (result.action === 'connected') {
4617
- _this.finish('connected', {
4618
- connection: new connection_connection(result.id, _this.transport),
4443
+ this.finish('connected', {
4444
+ connection: new connection_Connection(result.id, this.transport),
4619
4445
  activityTimeout: result.activityTimeout
4620
4446
  });
4621
4447
  }
4622
4448
  else {
4623
- _this.finish(result.action, { error: result.error });
4624
- _this.transport.close();
4449
+ this.finish(result.action, { error: result.error });
4450
+ this.transport.close();
4625
4451
  }
4626
4452
  };
4627
- this.onClosed = function (closeEvent) {
4628
- _this.unbindListeners();
4453
+ this.onClosed = closeEvent => {
4454
+ this.unbindListeners();
4629
4455
  var action = protocol_protocol.getCloseAction(closeEvent) || 'backoff';
4630
4456
  var error = protocol_protocol.getCloseError(closeEvent);
4631
- _this.finish(action, { error: error });
4457
+ this.finish(action, { error: error });
4632
4458
  };
4633
4459
  this.transport.bind('message', this.onMessage);
4634
4460
  this.transport.bind('closed', this.onClosed);
4635
- };
4636
- Handshake.prototype.unbindListeners = function () {
4461
+ }
4462
+ unbindListeners() {
4637
4463
  this.transport.unbind('message', this.onMessage);
4638
4464
  this.transport.unbind('closed', this.onClosed);
4639
- };
4640
- Handshake.prototype.finish = function (action, params) {
4465
+ }
4466
+ finish(action, params) {
4641
4467
  this.callback(extend({ transport: this.transport, action: action }, params));
4642
- };
4643
- return Handshake;
4644
- }());
4645
- /* harmony default export */ var connection_handshake = (handshake_Handshake);
4468
+ }
4469
+ }
4646
4470
 
4647
4471
  // CONCATENATED MODULE: ./src/core/timeline/timeline_sender.ts
4648
4472
 
4649
- var timeline_sender_TimelineSender = (function () {
4650
- function TimelineSender(timeline, options) {
4473
+ class timeline_sender_TimelineSender {
4474
+ constructor(timeline, options) {
4651
4475
  this.timeline = timeline;
4652
4476
  this.options = options || {};
4653
4477
  }
4654
- TimelineSender.prototype.send = function (useTLS, callback) {
4478
+ send(useTLS, callback) {
4655
4479
  if (this.timeline.isEmpty()) {
4656
4480
  return;
4657
4481
  }
4658
4482
  this.timeline.send(runtime.TimelineTransport.getAgent(this, useTLS), callback);
4659
- };
4660
- return TimelineSender;
4661
- }());
4662
- /* harmony default export */ var timeline_sender = (timeline_sender_TimelineSender);
4483
+ }
4484
+ }
4663
4485
 
4664
4486
  // CONCATENATED MODULE: ./src/core/channels/channel.ts
4665
- var channel_extends = (undefined && undefined.__extends) || (function () {
4666
- var extendStatics = function (d, b) {
4667
- extendStatics = Object.setPrototypeOf ||
4668
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
4669
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
4670
- return extendStatics(d, b);
4671
- };
4672
- return function (d, b) {
4673
- extendStatics(d, b);
4674
- function __() { this.constructor = d; }
4675
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
4676
- };
4677
- })();
4678
4487
 
4679
4488
 
4680
4489
 
4681
4490
 
4682
4491
 
4683
- var channel_Channel = (function (_super) {
4684
- channel_extends(Channel, _super);
4685
- function Channel(name, pusher) {
4686
- var _this = _super.call(this, function (event, data) {
4492
+ class channel_Channel extends dispatcher_Dispatcher {
4493
+ constructor(name, pusher) {
4494
+ super(function (event, data) {
4687
4495
  logger.debug('No callbacks on ' + name + ' for ' + event);
4688
- }) || this;
4689
- _this.name = name;
4690
- _this.pusher = pusher;
4691
- _this.subscribed = false;
4692
- _this.subscriptionPending = false;
4693
- _this.subscriptionCancelled = false;
4694
- return _this;
4695
- }
4696
- Channel.prototype.authorize = function (socketId, callback) {
4496
+ });
4497
+ this.name = name;
4498
+ this.pusher = pusher;
4499
+ this.subscribed = false;
4500
+ this.subscriptionPending = false;
4501
+ this.subscriptionCancelled = false;
4502
+ }
4503
+ authorize(socketId, callback) {
4697
4504
  return callback(null, { auth: '' });
4698
- };
4699
- Channel.prototype.trigger = function (event, data) {
4505
+ }
4506
+ trigger(event, data) {
4700
4507
  if (event.indexOf('client-') !== 0) {
4701
4508
  throw new BadEventName("Event '" + event + "' does not start with 'client-'");
4702
4509
  }
4703
4510
  if (!this.subscribed) {
4704
4511
  var suffix = url_store.buildLogSuffix('triggeringClientEvents');
4705
- logger.warn("Client event triggered before channel 'subscription_succeeded' event . " + suffix);
4512
+ logger.warn(`Client event triggered before channel 'subscription_succeeded' event . ${suffix}`);
4706
4513
  }
4707
4514
  return this.pusher.send_event(event, data, this.name);
4708
- };
4709
- Channel.prototype.disconnect = function () {
4515
+ }
4516
+ disconnect() {
4710
4517
  this.subscribed = false;
4711
4518
  this.subscriptionPending = false;
4712
- };
4713
- Channel.prototype.handleEvent = function (event) {
4519
+ }
4520
+ handleEvent(event) {
4714
4521
  var eventName = event.event;
4715
4522
  var data = event.data;
4716
4523
  if (eventName === 'pusher_internal:subscription_succeeded') {
@@ -4723,8 +4530,8 @@ var channel_Channel = (function (_super) {
4723
4530
  var metadata = {};
4724
4531
  this.emit(eventName, data, metadata);
4725
4532
  }
4726
- };
4727
- Channel.prototype.handleSubscriptionSucceededEvent = function (event) {
4533
+ }
4534
+ handleSubscriptionSucceededEvent(event) {
4728
4535
  this.subscriptionPending = false;
4729
4536
  this.subscribed = true;
4730
4537
  if (this.subscriptionCancelled) {
@@ -4733,91 +4540,69 @@ var channel_Channel = (function (_super) {
4733
4540
  else {
4734
4541
  this.emit('pusher:subscription_succeeded', event.data);
4735
4542
  }
4736
- };
4737
- Channel.prototype.handleSubscriptionCountEvent = function (event) {
4543
+ }
4544
+ handleSubscriptionCountEvent(event) {
4738
4545
  if (event.data.subscription_count) {
4739
4546
  this.subscriptionCount = event.data.subscription_count;
4740
4547
  }
4741
4548
  this.emit('pusher:subscription_count', event.data);
4742
- };
4743
- Channel.prototype.subscribe = function () {
4744
- var _this = this;
4549
+ }
4550
+ subscribe() {
4745
4551
  if (this.subscribed) {
4746
4552
  return;
4747
4553
  }
4748
4554
  this.subscriptionPending = true;
4749
4555
  this.subscriptionCancelled = false;
4750
- this.authorize(this.pusher.connection.socket_id, function (error, data) {
4556
+ this.authorize(this.pusher.connection.socket_id, (error, data) => {
4751
4557
  if (error) {
4752
- _this.subscriptionPending = false;
4558
+ this.subscriptionPending = false;
4753
4559
  logger.error(error.toString());
4754
- _this.emit('pusher:subscription_error', Object.assign({}, {
4560
+ this.emit('pusher:subscription_error', Object.assign({}, {
4755
4561
  type: 'AuthError',
4756
4562
  error: error.message
4757
4563
  }, error instanceof HTTPAuthError ? { status: error.status } : {}));
4758
4564
  }
4759
4565
  else {
4760
- _this.pusher.send_event('pusher:subscribe', {
4566
+ this.pusher.send_event('pusher:subscribe', {
4761
4567
  auth: data.auth,
4762
4568
  channel_data: data.channel_data,
4763
- channel: _this.name
4569
+ channel: this.name
4764
4570
  });
4765
4571
  }
4766
4572
  });
4767
- };
4768
- Channel.prototype.unsubscribe = function () {
4573
+ }
4574
+ unsubscribe() {
4769
4575
  this.subscribed = false;
4770
4576
  this.pusher.send_event('pusher:unsubscribe', {
4771
4577
  channel: this.name
4772
4578
  });
4773
- };
4774
- Channel.prototype.cancelSubscription = function () {
4579
+ }
4580
+ cancelSubscription() {
4775
4581
  this.subscriptionCancelled = true;
4776
- };
4777
- Channel.prototype.reinstateSubscription = function () {
4582
+ }
4583
+ reinstateSubscription() {
4778
4584
  this.subscriptionCancelled = false;
4779
- };
4780
- return Channel;
4781
- }(dispatcher));
4782
- /* harmony default export */ var channels_channel = (channel_Channel);
4585
+ }
4586
+ }
4783
4587
 
4784
4588
  // CONCATENATED MODULE: ./src/core/channels/private_channel.ts
4785
- var private_channel_extends = (undefined && undefined.__extends) || (function () {
4786
- var extendStatics = function (d, b) {
4787
- extendStatics = Object.setPrototypeOf ||
4788
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
4789
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
4790
- return extendStatics(d, b);
4791
- };
4792
- return function (d, b) {
4793
- extendStatics(d, b);
4794
- function __() { this.constructor = d; }
4795
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
4796
- };
4797
- })();
4798
4589
 
4799
- var PrivateChannel = (function (_super) {
4800
- private_channel_extends(PrivateChannel, _super);
4801
- function PrivateChannel() {
4802
- return _super !== null && _super.apply(this, arguments) || this;
4803
- }
4804
- PrivateChannel.prototype.authorize = function (socketId, callback) {
4590
+ class private_channel_PrivateChannel extends channel_Channel {
4591
+ authorize(socketId, callback) {
4805
4592
  return this.pusher.config.channelAuthorizer({
4806
4593
  channelName: this.name,
4807
4594
  socketId: socketId
4808
4595
  }, callback);
4809
- };
4810
- return PrivateChannel;
4811
- }(channels_channel));
4812
- /* harmony default export */ var private_channel = (PrivateChannel);
4596
+ }
4597
+ }
4813
4598
 
4814
4599
  // CONCATENATED MODULE: ./src/core/channels/members.ts
4815
4600
 
4816
- var members_Members = (function () {
4817
- function Members() {
4601
+ class members_Members {
4602
+ constructor() {
4818
4603
  this.reset();
4819
4604
  }
4820
- Members.prototype.get = function (id) {
4605
+ get(id) {
4821
4606
  if (Object.prototype.hasOwnProperty.call(this.members, id)) {
4822
4607
  return {
4823
4608
  id: id,
@@ -4827,60 +4612,44 @@ var members_Members = (function () {
4827
4612
  else {
4828
4613
  return null;
4829
4614
  }
4830
- };
4831
- Members.prototype.each = function (callback) {
4832
- var _this = this;
4833
- objectApply(this.members, function (member, id) {
4834
- callback(_this.get(id));
4615
+ }
4616
+ each(callback) {
4617
+ objectApply(this.members, (member, id) => {
4618
+ callback(this.get(id));
4835
4619
  });
4836
- };
4837
- Members.prototype.setMyID = function (id) {
4620
+ }
4621
+ setMyID(id) {
4838
4622
  this.myID = id;
4839
- };
4840
- Members.prototype.onSubscription = function (subscriptionData) {
4623
+ }
4624
+ onSubscription(subscriptionData) {
4841
4625
  this.members = subscriptionData.presence.hash;
4842
4626
  this.count = subscriptionData.presence.count;
4843
4627
  this.me = this.get(this.myID);
4844
- };
4845
- Members.prototype.addMember = function (memberData) {
4628
+ }
4629
+ addMember(memberData) {
4846
4630
  if (this.get(memberData.user_id) === null) {
4847
4631
  this.count++;
4848
4632
  }
4849
4633
  this.members[memberData.user_id] = memberData.user_info;
4850
4634
  return this.get(memberData.user_id);
4851
- };
4852
- Members.prototype.removeMember = function (memberData) {
4635
+ }
4636
+ removeMember(memberData) {
4853
4637
  var member = this.get(memberData.user_id);
4854
4638
  if (member) {
4855
4639
  delete this.members[memberData.user_id];
4856
4640
  this.count--;
4857
4641
  }
4858
4642
  return member;
4859
- };
4860
- Members.prototype.reset = function () {
4643
+ }
4644
+ reset() {
4861
4645
  this.members = {};
4862
4646
  this.count = 0;
4863
4647
  this.myID = null;
4864
4648
  this.me = null;
4865
- };
4866
- return Members;
4867
- }());
4868
- /* harmony default export */ var members = (members_Members);
4649
+ }
4650
+ }
4869
4651
 
4870
4652
  // CONCATENATED MODULE: ./src/core/channels/presence_channel.ts
4871
- var presence_channel_extends = (undefined && undefined.__extends) || (function () {
4872
- var extendStatics = function (d, b) {
4873
- extendStatics = Object.setPrototypeOf ||
4874
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
4875
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
4876
- return extendStatics(d, b);
4877
- };
4878
- return function (d, b) {
4879
- extendStatics(d, b);
4880
- function __() { this.constructor = d; }
4881
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
4882
- };
4883
- })();
4884
4653
  var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
4885
4654
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4886
4655
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -4890,80 +4659,42 @@ var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argume
4890
4659
  step((generator = generator.apply(thisArg, _arguments || [])).next());
4891
4660
  });
4892
4661
  };
4893
- var __generator = (undefined && undefined.__generator) || function (thisArg, body) {
4894
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
4895
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
4896
- function verb(n) { return function (v) { return step([n, v]); }; }
4897
- function step(op) {
4898
- if (f) throw new TypeError("Generator is already executing.");
4899
- while (_) try {
4900
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
4901
- if (y = 0, t) op = [op[0] & 2, t.value];
4902
- switch (op[0]) {
4903
- case 0: case 1: t = op; break;
4904
- case 4: _.label++; return { value: op[1], done: false };
4905
- case 5: _.label++; y = op[1]; op = [0]; continue;
4906
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
4907
- default:
4908
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
4909
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
4910
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
4911
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
4912
- if (t[2]) _.ops.pop();
4913
- _.trys.pop(); continue;
4914
- }
4915
- op = body.call(thisArg, _);
4916
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
4917
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
4918
- }
4919
- };
4920
4662
 
4921
4663
 
4922
4664
 
4923
4665
 
4924
- var presence_channel_PresenceChannel = (function (_super) {
4925
- presence_channel_extends(PresenceChannel, _super);
4926
- function PresenceChannel(name, pusher) {
4927
- var _this = _super.call(this, name, pusher) || this;
4928
- _this.members = new members();
4929
- return _this;
4930
- }
4931
- PresenceChannel.prototype.authorize = function (socketId, callback) {
4932
- var _this = this;
4933
- _super.prototype.authorize.call(this, socketId, function (error, authData) { return __awaiter(_this, void 0, void 0, function () {
4934
- var channelData, suffix;
4935
- return __generator(this, function (_a) {
4936
- switch (_a.label) {
4937
- case 0:
4938
- if (!!error) return [3, 3];
4939
- authData = authData;
4940
- if (!(authData.channel_data != null)) return [3, 1];
4941
- channelData = JSON.parse(authData.channel_data);
4942
- this.members.setMyID(channelData.user_id);
4943
- return [3, 3];
4944
- case 1: return [4, this.pusher.user.signinDonePromise];
4945
- case 2:
4946
- _a.sent();
4947
- if (this.pusher.user.user_data != null) {
4948
- this.members.setMyID(this.pusher.user.user_data.id);
4949
- }
4950
- else {
4951
- suffix = url_store.buildLogSuffix('authorizationEndpoint');
4952
- logger.error("Invalid auth response for channel '" + this.name + "', " +
4953
- ("expected 'channel_data' field. " + suffix + ", ") +
4954
- "or the user should be signed in.");
4955
- callback('Invalid auth response');
4956
- return [2];
4957
- }
4958
- _a.label = 3;
4959
- case 3:
4960
- callback(error, authData);
4961
- return [2];
4666
+ class presence_channel_PresenceChannel extends private_channel_PrivateChannel {
4667
+ constructor(name, pusher) {
4668
+ super(name, pusher);
4669
+ this.members = new members_Members();
4670
+ }
4671
+ authorize(socketId, callback) {
4672
+ super.authorize(socketId, (error, authData) => __awaiter(this, void 0, void 0, function* () {
4673
+ if (!error) {
4674
+ authData = authData;
4675
+ if (authData.channel_data != null) {
4676
+ var channelData = JSON.parse(authData.channel_data);
4677
+ this.members.setMyID(channelData.user_id);
4962
4678
  }
4963
- });
4964
- }); });
4965
- };
4966
- PresenceChannel.prototype.handleEvent = function (event) {
4679
+ else {
4680
+ yield this.pusher.user.signinDonePromise;
4681
+ if (this.pusher.user.user_data != null) {
4682
+ this.members.setMyID(this.pusher.user.user_data.id);
4683
+ }
4684
+ else {
4685
+ let suffix = url_store.buildLogSuffix('authorizationEndpoint');
4686
+ logger.error(`Invalid auth response for channel '${this.name}', ` +
4687
+ `expected 'channel_data' field. ${suffix}, ` +
4688
+ `or the user should be signed in.`);
4689
+ callback('Invalid auth response');
4690
+ return;
4691
+ }
4692
+ }
4693
+ }
4694
+ callback(error, authData);
4695
+ }));
4696
+ }
4697
+ handleEvent(event) {
4967
4698
  var eventName = event.event;
4968
4699
  if (eventName.indexOf('pusher_internal:') === 0) {
4969
4700
  this.handleInternalEvent(event);
@@ -4976,8 +4707,8 @@ var presence_channel_PresenceChannel = (function (_super) {
4976
4707
  }
4977
4708
  this.emit(eventName, data, metadata);
4978
4709
  }
4979
- };
4980
- PresenceChannel.prototype.handleInternalEvent = function (event) {
4710
+ }
4711
+ handleInternalEvent(event) {
4981
4712
  var eventName = event.event;
4982
4713
  var data = event.data;
4983
4714
  switch (eventName) {
@@ -4998,8 +4729,8 @@ var presence_channel_PresenceChannel = (function (_super) {
4998
4729
  }
4999
4730
  break;
5000
4731
  }
5001
- };
5002
- PresenceChannel.prototype.handleSubscriptionSucceededEvent = function (event) {
4732
+ }
4733
+ handleSubscriptionSucceededEvent(event) {
5003
4734
  this.subscriptionPending = false;
5004
4735
  this.subscribed = true;
5005
4736
  if (this.subscriptionCancelled) {
@@ -5009,14 +4740,12 @@ var presence_channel_PresenceChannel = (function (_super) {
5009
4740
  this.members.onSubscription(event.data);
5010
4741
  this.emit('pusher:subscription_succeeded', this.members);
5011
4742
  }
5012
- };
5013
- PresenceChannel.prototype.disconnect = function () {
4743
+ }
4744
+ disconnect() {
5014
4745
  this.members.reset();
5015
- _super.prototype.disconnect.call(this);
5016
- };
5017
- return PresenceChannel;
5018
- }(private_channel));
5019
- /* harmony default export */ var presence_channel = (presence_channel_PresenceChannel);
4746
+ super.disconnect();
4747
+ }
4748
+ }
5020
4749
 
5021
4750
  // EXTERNAL MODULE: ./node_modules/@stablelib/utf8/lib/utf8.js
5022
4751
  var utf8 = __webpack_require__(1);
@@ -5025,64 +4754,47 @@ var utf8 = __webpack_require__(1);
5025
4754
  var base64 = __webpack_require__(0);
5026
4755
 
5027
4756
  // CONCATENATED MODULE: ./src/core/channels/encrypted_channel.ts
5028
- var encrypted_channel_extends = (undefined && undefined.__extends) || (function () {
5029
- var extendStatics = function (d, b) {
5030
- extendStatics = Object.setPrototypeOf ||
5031
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5032
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
5033
- return extendStatics(d, b);
5034
- };
5035
- return function (d, b) {
5036
- extendStatics(d, b);
5037
- function __() { this.constructor = d; }
5038
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
5039
- };
5040
- })();
5041
4757
 
5042
4758
 
5043
4759
 
5044
4760
 
5045
4761
 
5046
- var encrypted_channel_EncryptedChannel = (function (_super) {
5047
- encrypted_channel_extends(EncryptedChannel, _super);
5048
- function EncryptedChannel(name, pusher, nacl) {
5049
- var _this = _super.call(this, name, pusher) || this;
5050
- _this.key = null;
5051
- _this.nacl = nacl;
5052
- return _this;
4762
+ class encrypted_channel_EncryptedChannel extends private_channel_PrivateChannel {
4763
+ constructor(name, pusher, nacl) {
4764
+ super(name, pusher);
4765
+ this.key = null;
4766
+ this.nacl = nacl;
5053
4767
  }
5054
- EncryptedChannel.prototype.authorize = function (socketId, callback) {
5055
- var _this = this;
5056
- _super.prototype.authorize.call(this, socketId, function (error, authData) {
4768
+ authorize(socketId, callback) {
4769
+ super.authorize(socketId, (error, authData) => {
5057
4770
  if (error) {
5058
4771
  callback(error, authData);
5059
4772
  return;
5060
4773
  }
5061
- var sharedSecret = authData['shared_secret'];
4774
+ let sharedSecret = authData['shared_secret'];
5062
4775
  if (!sharedSecret) {
5063
- callback(new Error("No shared_secret key in auth payload for encrypted channel: " + _this.name), null);
4776
+ callback(new Error(`No shared_secret key in auth payload for encrypted channel: ${this.name}`), null);
5064
4777
  return;
5065
4778
  }
5066
- _this.key = Object(base64["decode"])(sharedSecret);
4779
+ this.key = Object(base64["decode"])(sharedSecret);
5067
4780
  delete authData['shared_secret'];
5068
4781
  callback(null, authData);
5069
4782
  });
5070
- };
5071
- EncryptedChannel.prototype.trigger = function (event, data) {
4783
+ }
4784
+ trigger(event, data) {
5072
4785
  throw new UnsupportedFeature('Client events are not currently supported for encrypted channels');
5073
- };
5074
- EncryptedChannel.prototype.handleEvent = function (event) {
4786
+ }
4787
+ handleEvent(event) {
5075
4788
  var eventName = event.event;
5076
4789
  var data = event.data;
5077
4790
  if (eventName.indexOf('pusher_internal:') === 0 ||
5078
4791
  eventName.indexOf('pusher:') === 0) {
5079
- _super.prototype.handleEvent.call(this, event);
4792
+ super.handleEvent(event);
5080
4793
  return;
5081
4794
  }
5082
4795
  this.handleEncryptedEvent(eventName, data);
5083
- };
5084
- EncryptedChannel.prototype.handleEncryptedEvent = function (event, data) {
5085
- var _this = this;
4796
+ }
4797
+ handleEncryptedEvent(event, data) {
5086
4798
  if (!this.key) {
5087
4799
  logger.debug('Received encrypted event before key has been retrieved from the authEndpoint');
5088
4800
  return;
@@ -5092,98 +4804,81 @@ var encrypted_channel_EncryptedChannel = (function (_super) {
5092
4804
  data);
5093
4805
  return;
5094
4806
  }
5095
- var cipherText = Object(base64["decode"])(data.ciphertext);
4807
+ let cipherText = Object(base64["decode"])(data.ciphertext);
5096
4808
  if (cipherText.length < this.nacl.secretbox.overheadLength) {
5097
- logger.error("Expected encrypted event ciphertext length to be " + this.nacl.secretbox.overheadLength + ", got: " + cipherText.length);
4809
+ logger.error(`Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`);
5098
4810
  return;
5099
4811
  }
5100
- var nonce = Object(base64["decode"])(data.nonce);
4812
+ let nonce = Object(base64["decode"])(data.nonce);
5101
4813
  if (nonce.length < this.nacl.secretbox.nonceLength) {
5102
- logger.error("Expected encrypted event nonce length to be " + this.nacl.secretbox.nonceLength + ", got: " + nonce.length);
4814
+ logger.error(`Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`);
5103
4815
  return;
5104
4816
  }
5105
- var bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);
4817
+ let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);
5106
4818
  if (bytes === null) {
5107
4819
  logger.debug('Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...');
5108
- this.authorize(this.pusher.connection.socket_id, function (error, authData) {
4820
+ this.authorize(this.pusher.connection.socket_id, (error, authData) => {
5109
4821
  if (error) {
5110
- logger.error("Failed to make a request to the authEndpoint: " + authData + ". Unable to fetch new key, so dropping encrypted event");
4822
+ logger.error(`Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`);
5111
4823
  return;
5112
4824
  }
5113
- bytes = _this.nacl.secretbox.open(cipherText, nonce, _this.key);
4825
+ bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);
5114
4826
  if (bytes === null) {
5115
- logger.error("Failed to decrypt event with new key. Dropping encrypted event");
4827
+ logger.error(`Failed to decrypt event with new key. Dropping encrypted event`);
5116
4828
  return;
5117
4829
  }
5118
- _this.emit(event, _this.getDataToEmit(bytes));
4830
+ this.emit(event, this.getDataToEmit(bytes));
5119
4831
  return;
5120
4832
  });
5121
4833
  return;
5122
4834
  }
5123
4835
  this.emit(event, this.getDataToEmit(bytes));
5124
- };
5125
- EncryptedChannel.prototype.getDataToEmit = function (bytes) {
5126
- var raw = Object(utf8["decode"])(bytes);
4836
+ }
4837
+ getDataToEmit(bytes) {
4838
+ let raw = Object(utf8["decode"])(bytes);
5127
4839
  try {
5128
4840
  return JSON.parse(raw);
5129
4841
  }
5130
4842
  catch (_a) {
5131
4843
  return raw;
5132
4844
  }
5133
- };
5134
- return EncryptedChannel;
5135
- }(private_channel));
5136
- /* harmony default export */ var encrypted_channel = (encrypted_channel_EncryptedChannel);
4845
+ }
4846
+ }
5137
4847
 
5138
4848
  // CONCATENATED MODULE: ./src/core/connection/connection_manager.ts
5139
- var connection_manager_extends = (undefined && undefined.__extends) || (function () {
5140
- var extendStatics = function (d, b) {
5141
- extendStatics = Object.setPrototypeOf ||
5142
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5143
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
5144
- return extendStatics(d, b);
5145
- };
5146
- return function (d, b) {
5147
- extendStatics(d, b);
5148
- function __() { this.constructor = d; }
5149
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
5150
- };
5151
- })();
5152
4849
 
5153
4850
 
5154
4851
 
5155
4852
 
5156
4853
 
5157
- var connection_manager_ConnectionManager = (function (_super) {
5158
- connection_manager_extends(ConnectionManager, _super);
5159
- function ConnectionManager(key, options) {
5160
- var _this = _super.call(this) || this;
5161
- _this.state = 'initialized';
5162
- _this.connection = null;
5163
- _this.key = key;
5164
- _this.options = options;
5165
- _this.timeline = _this.options.timeline;
5166
- _this.usingTLS = _this.options.useTLS;
5167
- _this.errorCallbacks = _this.buildErrorCallbacks();
5168
- _this.connectionCallbacks = _this.buildConnectionCallbacks(_this.errorCallbacks);
5169
- _this.handshakeCallbacks = _this.buildHandshakeCallbacks(_this.errorCallbacks);
4854
+ class connection_manager_ConnectionManager extends dispatcher_Dispatcher {
4855
+ constructor(key, options) {
4856
+ super();
4857
+ this.state = 'initialized';
4858
+ this.connection = null;
4859
+ this.key = key;
4860
+ this.options = options;
4861
+ this.timeline = this.options.timeline;
4862
+ this.usingTLS = this.options.useTLS;
4863
+ this.errorCallbacks = this.buildErrorCallbacks();
4864
+ this.connectionCallbacks = this.buildConnectionCallbacks(this.errorCallbacks);
4865
+ this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);
5170
4866
  var Network = runtime.getNetwork();
5171
- Network.bind('online', function () {
5172
- _this.timeline.info({ netinfo: 'online' });
5173
- if (_this.state === 'connecting' || _this.state === 'unavailable') {
5174
- _this.retryIn(0);
4867
+ Network.bind('online', () => {
4868
+ this.timeline.info({ netinfo: 'online' });
4869
+ if (this.state === 'connecting' || this.state === 'unavailable') {
4870
+ this.retryIn(0);
5175
4871
  }
5176
4872
  });
5177
- Network.bind('offline', function () {
5178
- _this.timeline.info({ netinfo: 'offline' });
5179
- if (_this.connection) {
5180
- _this.sendActivityCheck();
4873
+ Network.bind('offline', () => {
4874
+ this.timeline.info({ netinfo: 'offline' });
4875
+ if (this.connection) {
4876
+ this.sendActivityCheck();
5181
4877
  }
5182
4878
  });
5183
- _this.updateStrategy();
5184
- return _this;
4879
+ this.updateStrategy();
5185
4880
  }
5186
- ConnectionManager.prototype.connect = function () {
4881
+ connect() {
5187
4882
  if (this.connection || this.runner) {
5188
4883
  return;
5189
4884
  }
@@ -5194,59 +4889,58 @@ var connection_manager_ConnectionManager = (function (_super) {
5194
4889
  this.updateState('connecting');
5195
4890
  this.startConnecting();
5196
4891
  this.setUnavailableTimer();
5197
- };
5198
- ConnectionManager.prototype.send = function (data) {
4892
+ }
4893
+ send(data) {
5199
4894
  if (this.connection) {
5200
4895
  return this.connection.send(data);
5201
4896
  }
5202
4897
  else {
5203
4898
  return false;
5204
4899
  }
5205
- };
5206
- ConnectionManager.prototype.send_event = function (name, data, channel) {
4900
+ }
4901
+ send_event(name, data, channel) {
5207
4902
  if (this.connection) {
5208
4903
  return this.connection.send_event(name, data, channel);
5209
4904
  }
5210
4905
  else {
5211
4906
  return false;
5212
4907
  }
5213
- };
5214
- ConnectionManager.prototype.disconnect = function () {
4908
+ }
4909
+ disconnect() {
5215
4910
  this.disconnectInternally();
5216
4911
  this.updateState('disconnected');
5217
- };
5218
- ConnectionManager.prototype.isUsingTLS = function () {
4912
+ }
4913
+ isUsingTLS() {
5219
4914
  return this.usingTLS;
5220
- };
5221
- ConnectionManager.prototype.startConnecting = function () {
5222
- var _this = this;
5223
- var callback = function (error, handshake) {
4915
+ }
4916
+ startConnecting() {
4917
+ var callback = (error, handshake) => {
5224
4918
  if (error) {
5225
- _this.runner = _this.strategy.connect(0, callback);
4919
+ this.runner = this.strategy.connect(0, callback);
5226
4920
  }
5227
4921
  else {
5228
4922
  if (handshake.action === 'error') {
5229
- _this.emit('error', {
4923
+ this.emit('error', {
5230
4924
  type: 'HandshakeError',
5231
4925
  error: handshake.error
5232
4926
  });
5233
- _this.timeline.error({ handshakeError: handshake.error });
4927
+ this.timeline.error({ handshakeError: handshake.error });
5234
4928
  }
5235
4929
  else {
5236
- _this.abortConnecting();
5237
- _this.handshakeCallbacks[handshake.action](handshake);
4930
+ this.abortConnecting();
4931
+ this.handshakeCallbacks[handshake.action](handshake);
5238
4932
  }
5239
4933
  }
5240
4934
  };
5241
4935
  this.runner = this.strategy.connect(0, callback);
5242
- };
5243
- ConnectionManager.prototype.abortConnecting = function () {
4936
+ }
4937
+ abortConnecting() {
5244
4938
  if (this.runner) {
5245
4939
  this.runner.abort();
5246
4940
  this.runner = null;
5247
4941
  }
5248
- };
5249
- ConnectionManager.prototype.disconnectInternally = function () {
4942
+ }
4943
+ disconnectInternally() {
5250
4944
  this.abortConnecting();
5251
4945
  this.clearRetryTimer();
5252
4946
  this.clearUnavailableTimer();
@@ -5254,136 +4948,129 @@ var connection_manager_ConnectionManager = (function (_super) {
5254
4948
  var connection = this.abandonConnection();
5255
4949
  connection.close();
5256
4950
  }
5257
- };
5258
- ConnectionManager.prototype.updateStrategy = function () {
4951
+ }
4952
+ updateStrategy() {
5259
4953
  this.strategy = this.options.getStrategy({
5260
4954
  key: this.key,
5261
4955
  timeline: this.timeline,
5262
4956
  useTLS: this.usingTLS
5263
4957
  });
5264
- };
5265
- ConnectionManager.prototype.retryIn = function (delay) {
5266
- var _this = this;
4958
+ }
4959
+ retryIn(delay) {
5267
4960
  this.timeline.info({ action: 'retry', delay: delay });
5268
4961
  if (delay > 0) {
5269
4962
  this.emit('connecting_in', Math.round(delay / 1000));
5270
4963
  }
5271
- this.retryTimer = new OneOffTimer(delay || 0, function () {
5272
- _this.disconnectInternally();
5273
- _this.connect();
4964
+ this.retryTimer = new timers_OneOffTimer(delay || 0, () => {
4965
+ this.disconnectInternally();
4966
+ this.connect();
5274
4967
  });
5275
- };
5276
- ConnectionManager.prototype.clearRetryTimer = function () {
4968
+ }
4969
+ clearRetryTimer() {
5277
4970
  if (this.retryTimer) {
5278
4971
  this.retryTimer.ensureAborted();
5279
4972
  this.retryTimer = null;
5280
4973
  }
5281
- };
5282
- ConnectionManager.prototype.setUnavailableTimer = function () {
5283
- var _this = this;
5284
- this.unavailableTimer = new OneOffTimer(this.options.unavailableTimeout, function () {
5285
- _this.updateState('unavailable');
4974
+ }
4975
+ setUnavailableTimer() {
4976
+ this.unavailableTimer = new timers_OneOffTimer(this.options.unavailableTimeout, () => {
4977
+ this.updateState('unavailable');
5286
4978
  });
5287
- };
5288
- ConnectionManager.prototype.clearUnavailableTimer = function () {
4979
+ }
4980
+ clearUnavailableTimer() {
5289
4981
  if (this.unavailableTimer) {
5290
4982
  this.unavailableTimer.ensureAborted();
5291
4983
  }
5292
- };
5293
- ConnectionManager.prototype.sendActivityCheck = function () {
5294
- var _this = this;
4984
+ }
4985
+ sendActivityCheck() {
5295
4986
  this.stopActivityCheck();
5296
4987
  this.connection.ping();
5297
- this.activityTimer = new OneOffTimer(this.options.pongTimeout, function () {
5298
- _this.timeline.error({ pong_timed_out: _this.options.pongTimeout });
5299
- _this.retryIn(0);
4988
+ this.activityTimer = new timers_OneOffTimer(this.options.pongTimeout, () => {
4989
+ this.timeline.error({ pong_timed_out: this.options.pongTimeout });
4990
+ this.retryIn(0);
5300
4991
  });
5301
- };
5302
- ConnectionManager.prototype.resetActivityCheck = function () {
5303
- var _this = this;
4992
+ }
4993
+ resetActivityCheck() {
5304
4994
  this.stopActivityCheck();
5305
4995
  if (this.connection && !this.connection.handlesActivityChecks()) {
5306
- this.activityTimer = new OneOffTimer(this.activityTimeout, function () {
5307
- _this.sendActivityCheck();
4996
+ this.activityTimer = new timers_OneOffTimer(this.activityTimeout, () => {
4997
+ this.sendActivityCheck();
5308
4998
  });
5309
4999
  }
5310
- };
5311
- ConnectionManager.prototype.stopActivityCheck = function () {
5000
+ }
5001
+ stopActivityCheck() {
5312
5002
  if (this.activityTimer) {
5313
5003
  this.activityTimer.ensureAborted();
5314
5004
  }
5315
- };
5316
- ConnectionManager.prototype.buildConnectionCallbacks = function (errorCallbacks) {
5317
- var _this = this;
5005
+ }
5006
+ buildConnectionCallbacks(errorCallbacks) {
5318
5007
  return extend({}, errorCallbacks, {
5319
- message: function (message) {
5320
- _this.resetActivityCheck();
5321
- _this.emit('message', message);
5008
+ message: message => {
5009
+ this.resetActivityCheck();
5010
+ this.emit('message', message);
5322
5011
  },
5323
- ping: function () {
5324
- _this.send_event('pusher:pong', {});
5012
+ ping: () => {
5013
+ this.send_event('pusher:pong', {});
5325
5014
  },
5326
- activity: function () {
5327
- _this.resetActivityCheck();
5015
+ activity: () => {
5016
+ this.resetActivityCheck();
5328
5017
  },
5329
- error: function (error) {
5330
- _this.emit('error', error);
5018
+ error: error => {
5019
+ this.emit('error', error);
5331
5020
  },
5332
- closed: function () {
5333
- _this.abandonConnection();
5334
- if (_this.shouldRetry()) {
5335
- _this.retryIn(1000);
5021
+ closed: () => {
5022
+ this.abandonConnection();
5023
+ if (this.shouldRetry()) {
5024
+ this.retryIn(1000);
5336
5025
  }
5337
5026
  }
5338
5027
  });
5339
- };
5340
- ConnectionManager.prototype.buildHandshakeCallbacks = function (errorCallbacks) {
5341
- var _this = this;
5028
+ }
5029
+ buildHandshakeCallbacks(errorCallbacks) {
5342
5030
  return extend({}, errorCallbacks, {
5343
- connected: function (handshake) {
5344
- _this.activityTimeout = Math.min(_this.options.activityTimeout, handshake.activityTimeout, handshake.connection.activityTimeout || Infinity);
5345
- _this.clearUnavailableTimer();
5346
- _this.setConnection(handshake.connection);
5347
- _this.socket_id = _this.connection.id;
5348
- _this.updateState('connected', { socket_id: _this.socket_id });
5031
+ connected: (handshake) => {
5032
+ this.activityTimeout = Math.min(this.options.activityTimeout, handshake.activityTimeout, handshake.connection.activityTimeout || Infinity);
5033
+ this.clearUnavailableTimer();
5034
+ this.setConnection(handshake.connection);
5035
+ this.socket_id = this.connection.id;
5036
+ this.updateState('connected', { socket_id: this.socket_id });
5349
5037
  }
5350
5038
  });
5351
- };
5352
- ConnectionManager.prototype.buildErrorCallbacks = function () {
5353
- var _this = this;
5354
- var withErrorEmitted = function (callback) {
5355
- return function (result) {
5039
+ }
5040
+ buildErrorCallbacks() {
5041
+ let withErrorEmitted = callback => {
5042
+ return (result) => {
5356
5043
  if (result.error) {
5357
- _this.emit('error', { type: 'WebSocketError', error: result.error });
5044
+ this.emit('error', { type: 'WebSocketError', error: result.error });
5358
5045
  }
5359
5046
  callback(result);
5360
5047
  };
5361
5048
  };
5362
5049
  return {
5363
- tls_only: withErrorEmitted(function () {
5364
- _this.usingTLS = true;
5365
- _this.updateStrategy();
5366
- _this.retryIn(0);
5050
+ tls_only: withErrorEmitted(() => {
5051
+ this.usingTLS = true;
5052
+ this.updateStrategy();
5053
+ this.retryIn(0);
5367
5054
  }),
5368
- refused: withErrorEmitted(function () {
5369
- _this.disconnect();
5055
+ refused: withErrorEmitted(() => {
5056
+ this.disconnect();
5370
5057
  }),
5371
- backoff: withErrorEmitted(function () {
5372
- _this.retryIn(1000);
5058
+ backoff: withErrorEmitted(() => {
5059
+ this.retryIn(1000);
5373
5060
  }),
5374
- retry: withErrorEmitted(function () {
5375
- _this.retryIn(0);
5061
+ retry: withErrorEmitted(() => {
5062
+ this.retryIn(0);
5376
5063
  })
5377
5064
  };
5378
- };
5379
- ConnectionManager.prototype.setConnection = function (connection) {
5065
+ }
5066
+ setConnection(connection) {
5380
5067
  this.connection = connection;
5381
5068
  for (var event in this.connectionCallbacks) {
5382
5069
  this.connection.bind(event, this.connectionCallbacks[event]);
5383
5070
  }
5384
5071
  this.resetActivityCheck();
5385
- };
5386
- ConnectionManager.prototype.abandonConnection = function () {
5072
+ }
5073
+ abandonConnection() {
5387
5074
  if (!this.connection) {
5388
5075
  return;
5389
5076
  }
@@ -5394,8 +5081,8 @@ var connection_manager_ConnectionManager = (function (_super) {
5394
5081
  var connection = this.connection;
5395
5082
  this.connection = null;
5396
5083
  return connection;
5397
- };
5398
- ConnectionManager.prototype.updateState = function (newState, data) {
5084
+ }
5085
+ updateState(newState, data) {
5399
5086
  var previousState = this.state;
5400
5087
  this.state = newState;
5401
5088
  if (previousState !== newState) {
@@ -5408,56 +5095,52 @@ var connection_manager_ConnectionManager = (function (_super) {
5408
5095
  this.emit('state_change', { previous: previousState, current: newState });
5409
5096
  this.emit(newState, data);
5410
5097
  }
5411
- };
5412
- ConnectionManager.prototype.shouldRetry = function () {
5098
+ }
5099
+ shouldRetry() {
5413
5100
  return this.state === 'connecting' || this.state === 'connected';
5414
- };
5415
- return ConnectionManager;
5416
- }(dispatcher));
5417
- /* harmony default export */ var connection_manager = (connection_manager_ConnectionManager);
5101
+ }
5102
+ }
5418
5103
 
5419
5104
  // CONCATENATED MODULE: ./src/core/channels/channels.ts
5420
5105
 
5421
5106
 
5422
5107
 
5423
5108
 
5424
- var channels_Channels = (function () {
5425
- function Channels() {
5109
+ class channels_Channels {
5110
+ constructor() {
5426
5111
  this.channels = {};
5427
5112
  }
5428
- Channels.prototype.add = function (name, pusher) {
5113
+ add(name, pusher) {
5429
5114
  if (!this.channels[name]) {
5430
5115
  this.channels[name] = createChannel(name, pusher);
5431
5116
  }
5432
5117
  return this.channels[name];
5433
- };
5434
- Channels.prototype.all = function () {
5118
+ }
5119
+ all() {
5435
5120
  return values(this.channels);
5436
- };
5437
- Channels.prototype.find = function (name) {
5121
+ }
5122
+ find(name) {
5438
5123
  return this.channels[name];
5439
- };
5440
- Channels.prototype.remove = function (name) {
5124
+ }
5125
+ remove(name) {
5441
5126
  var channel = this.channels[name];
5442
5127
  delete this.channels[name];
5443
5128
  return channel;
5444
- };
5445
- Channels.prototype.disconnect = function () {
5129
+ }
5130
+ disconnect() {
5446
5131
  objectApply(this.channels, function (channel) {
5447
5132
  channel.disconnect();
5448
5133
  });
5449
- };
5450
- return Channels;
5451
- }());
5452
- /* harmony default export */ var channels = (channels_Channels);
5134
+ }
5135
+ }
5453
5136
  function createChannel(name, pusher) {
5454
5137
  if (name.indexOf('private-encrypted-') === 0) {
5455
5138
  if (pusher.config.nacl) {
5456
5139
  return factory.createEncryptedChannel(name, pusher, pusher.config.nacl);
5457
5140
  }
5458
- var errMsg = 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';
5459
- var suffix = url_store.buildLogSuffix('encryptedChannelSupport');
5460
- throw new UnsupportedFeature(errMsg + ". " + suffix);
5141
+ let errMsg = 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';
5142
+ let suffix = url_store.buildLogSuffix('encryptedChannelSupport');
5143
+ throw new UnsupportedFeature(`${errMsg}. ${suffix}`);
5461
5144
  }
5462
5145
  else if (name.indexOf('private-') === 0) {
5463
5146
  return factory.createPrivateChannel(name, pusher);
@@ -5484,97 +5167,94 @@ function createChannel(name, pusher) {
5484
5167
 
5485
5168
 
5486
5169
  var Factory = {
5487
- createChannels: function () {
5488
- return new channels();
5170
+ createChannels() {
5171
+ return new channels_Channels();
5489
5172
  },
5490
- createConnectionManager: function (key, options) {
5491
- return new connection_manager(key, options);
5173
+ createConnectionManager(key, options) {
5174
+ return new connection_manager_ConnectionManager(key, options);
5492
5175
  },
5493
- createChannel: function (name, pusher) {
5494
- return new channels_channel(name, pusher);
5176
+ createChannel(name, pusher) {
5177
+ return new channel_Channel(name, pusher);
5495
5178
  },
5496
- createPrivateChannel: function (name, pusher) {
5497
- return new private_channel(name, pusher);
5179
+ createPrivateChannel(name, pusher) {
5180
+ return new private_channel_PrivateChannel(name, pusher);
5498
5181
  },
5499
- createPresenceChannel: function (name, pusher) {
5500
- return new presence_channel(name, pusher);
5182
+ createPresenceChannel(name, pusher) {
5183
+ return new presence_channel_PresenceChannel(name, pusher);
5501
5184
  },
5502
- createEncryptedChannel: function (name, pusher, nacl) {
5503
- return new encrypted_channel(name, pusher, nacl);
5185
+ createEncryptedChannel(name, pusher, nacl) {
5186
+ return new encrypted_channel_EncryptedChannel(name, pusher, nacl);
5504
5187
  },
5505
- createTimelineSender: function (timeline, options) {
5506
- return new timeline_sender(timeline, options);
5188
+ createTimelineSender(timeline, options) {
5189
+ return new timeline_sender_TimelineSender(timeline, options);
5507
5190
  },
5508
- createHandshake: function (transport, callback) {
5509
- return new connection_handshake(transport, callback);
5191
+ createHandshake(transport, callback) {
5192
+ return new handshake_Handshake(transport, callback);
5510
5193
  },
5511
- createAssistantToTheTransportManager: function (manager, transport, options) {
5512
- return new assistant_to_the_transport_manager(manager, transport, options);
5194
+ createAssistantToTheTransportManager(manager, transport, options) {
5195
+ return new assistant_to_the_transport_manager_AssistantToTheTransportManager(manager, transport, options);
5513
5196
  }
5514
5197
  };
5515
5198
  /* harmony default export */ var factory = (Factory);
5516
5199
 
5517
5200
  // CONCATENATED MODULE: ./src/core/transports/transport_manager.ts
5518
5201
 
5519
- var transport_manager_TransportManager = (function () {
5520
- function TransportManager(options) {
5202
+ class transport_manager_TransportManager {
5203
+ constructor(options) {
5521
5204
  this.options = options || {};
5522
5205
  this.livesLeft = this.options.lives || Infinity;
5523
5206
  }
5524
- TransportManager.prototype.getAssistant = function (transport) {
5207
+ getAssistant(transport) {
5525
5208
  return factory.createAssistantToTheTransportManager(this, transport, {
5526
5209
  minPingDelay: this.options.minPingDelay,
5527
5210
  maxPingDelay: this.options.maxPingDelay
5528
5211
  });
5529
- };
5530
- TransportManager.prototype.isAlive = function () {
5212
+ }
5213
+ isAlive() {
5531
5214
  return this.livesLeft > 0;
5532
- };
5533
- TransportManager.prototype.reportDeath = function () {
5215
+ }
5216
+ reportDeath() {
5534
5217
  this.livesLeft -= 1;
5535
- };
5536
- return TransportManager;
5537
- }());
5538
- /* harmony default export */ var transport_manager = (transport_manager_TransportManager);
5218
+ }
5219
+ }
5539
5220
 
5540
5221
  // CONCATENATED MODULE: ./src/core/strategies/sequential_strategy.ts
5541
5222
 
5542
5223
 
5543
5224
 
5544
- var sequential_strategy_SequentialStrategy = (function () {
5545
- function SequentialStrategy(strategies, options) {
5225
+ class sequential_strategy_SequentialStrategy {
5226
+ constructor(strategies, options) {
5546
5227
  this.strategies = strategies;
5547
5228
  this.loop = Boolean(options.loop);
5548
5229
  this.failFast = Boolean(options.failFast);
5549
5230
  this.timeout = options.timeout;
5550
5231
  this.timeoutLimit = options.timeoutLimit;
5551
5232
  }
5552
- SequentialStrategy.prototype.isSupported = function () {
5233
+ isSupported() {
5553
5234
  return any(this.strategies, util.method('isSupported'));
5554
- };
5555
- SequentialStrategy.prototype.connect = function (minPriority, callback) {
5556
- var _this = this;
5235
+ }
5236
+ connect(minPriority, callback) {
5557
5237
  var strategies = this.strategies;
5558
5238
  var current = 0;
5559
5239
  var timeout = this.timeout;
5560
5240
  var runner = null;
5561
- var tryNextStrategy = function (error, handshake) {
5241
+ var tryNextStrategy = (error, handshake) => {
5562
5242
  if (handshake) {
5563
5243
  callback(null, handshake);
5564
5244
  }
5565
5245
  else {
5566
5246
  current = current + 1;
5567
- if (_this.loop) {
5247
+ if (this.loop) {
5568
5248
  current = current % strategies.length;
5569
5249
  }
5570
5250
  if (current < strategies.length) {
5571
5251
  if (timeout) {
5572
5252
  timeout = timeout * 2;
5573
- if (_this.timeoutLimit) {
5574
- timeout = Math.min(timeout, _this.timeoutLimit);
5253
+ if (this.timeoutLimit) {
5254
+ timeout = Math.min(timeout, this.timeoutLimit);
5575
5255
  }
5576
5256
  }
5577
- runner = _this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: _this.failFast }, tryNextStrategy);
5257
+ runner = this.tryStrategy(strategies[current], minPriority, { timeout, failFast: this.failFast }, tryNextStrategy);
5578
5258
  }
5579
5259
  else {
5580
5260
  callback(true);
@@ -5593,12 +5273,12 @@ var sequential_strategy_SequentialStrategy = (function () {
5593
5273
  }
5594
5274
  }
5595
5275
  };
5596
- };
5597
- SequentialStrategy.prototype.tryStrategy = function (strategy, minPriority, options, callback) {
5276
+ }
5277
+ tryStrategy(strategy, minPriority, options, callback) {
5598
5278
  var timer = null;
5599
5279
  var runner = null;
5600
5280
  if (options.timeout > 0) {
5601
- timer = new OneOffTimer(options.timeout, function () {
5281
+ timer = new timers_OneOffTimer(options.timeout, function () {
5602
5282
  runner.abort();
5603
5283
  callback(true);
5604
5284
  });
@@ -5623,22 +5303,20 @@ var sequential_strategy_SequentialStrategy = (function () {
5623
5303
  runner.forceMinPriority(p);
5624
5304
  }
5625
5305
  };
5626
- };
5627
- return SequentialStrategy;
5628
- }());
5629
- /* harmony default export */ var sequential_strategy = (sequential_strategy_SequentialStrategy);
5306
+ }
5307
+ }
5630
5308
 
5631
5309
  // CONCATENATED MODULE: ./src/core/strategies/best_connected_ever_strategy.ts
5632
5310
 
5633
5311
 
5634
- var best_connected_ever_strategy_BestConnectedEverStrategy = (function () {
5635
- function BestConnectedEverStrategy(strategies) {
5312
+ class best_connected_ever_strategy_BestConnectedEverStrategy {
5313
+ constructor(strategies) {
5636
5314
  this.strategies = strategies;
5637
5315
  }
5638
- BestConnectedEverStrategy.prototype.isSupported = function () {
5316
+ isSupported() {
5639
5317
  return any(this.strategies, util.method('isSupported'));
5640
- };
5641
- BestConnectedEverStrategy.prototype.connect = function (minPriority, callback) {
5318
+ }
5319
+ connect(minPriority, callback) {
5642
5320
  return connect(this.strategies, minPriority, function (i, runners) {
5643
5321
  return function (error, handshake) {
5644
5322
  runners[i].error = error;
@@ -5654,10 +5332,8 @@ var best_connected_ever_strategy_BestConnectedEverStrategy = (function () {
5654
5332
  callback(null, handshake);
5655
5333
  };
5656
5334
  });
5657
- };
5658
- return BestConnectedEverStrategy;
5659
- }());
5660
- /* harmony default export */ var best_connected_ever_strategy = (best_connected_ever_strategy_BestConnectedEverStrategy);
5335
+ }
5336
+ }
5661
5337
  function connect(strategies, minPriority, callbackBuilder) {
5662
5338
  var runners = map(strategies, function (strategy, i, _, rs) {
5663
5339
  return strategy.connect(minPriority, callbackBuilder(i, rs));
@@ -5690,18 +5366,18 @@ function abortRunner(runner) {
5690
5366
 
5691
5367
 
5692
5368
 
5693
- var cached_strategy_CachedStrategy = (function () {
5694
- function CachedStrategy(strategy, transports, options) {
5369
+ class cached_strategy_CachedStrategy {
5370
+ constructor(strategy, transports, options) {
5695
5371
  this.strategy = strategy;
5696
5372
  this.transports = transports;
5697
5373
  this.ttl = options.ttl || 1800 * 1000;
5698
5374
  this.usingTLS = options.useTLS;
5699
5375
  this.timeline = options.timeline;
5700
5376
  }
5701
- CachedStrategy.prototype.isSupported = function () {
5377
+ isSupported() {
5702
5378
  return this.strategy.isSupported();
5703
- };
5704
- CachedStrategy.prototype.connect = function (minPriority, callback) {
5379
+ }
5380
+ connect(minPriority, callback) {
5705
5381
  var usingTLS = this.usingTLS;
5706
5382
  var info = fetchTransportCache(usingTLS);
5707
5383
  var strategies = [this.strategy];
@@ -5713,7 +5389,7 @@ var cached_strategy_CachedStrategy = (function () {
5713
5389
  transport: info.transport,
5714
5390
  latency: info.latency
5715
5391
  });
5716
- strategies.push(new sequential_strategy([transport], {
5392
+ strategies.push(new sequential_strategy_SequentialStrategy([transport], {
5717
5393
  timeout: info.latency * 2 + 1000,
5718
5394
  failFast: true
5719
5395
  }));
@@ -5749,10 +5425,8 @@ var cached_strategy_CachedStrategy = (function () {
5749
5425
  }
5750
5426
  }
5751
5427
  };
5752
- };
5753
- return CachedStrategy;
5754
- }());
5755
- /* harmony default export */ var cached_strategy = (cached_strategy_CachedStrategy);
5428
+ }
5429
+ }
5756
5430
  function getTransportCacheKey(usingTLS) {
5757
5431
  return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');
5758
5432
  }
@@ -5798,19 +5472,18 @@ function flushTransportCache(usingTLS) {
5798
5472
 
5799
5473
  // CONCATENATED MODULE: ./src/core/strategies/delayed_strategy.ts
5800
5474
 
5801
- var delayed_strategy_DelayedStrategy = (function () {
5802
- function DelayedStrategy(strategy, _a) {
5803
- var number = _a.delay;
5475
+ class delayed_strategy_DelayedStrategy {
5476
+ constructor(strategy, { delay: number }) {
5804
5477
  this.strategy = strategy;
5805
5478
  this.options = { delay: number };
5806
5479
  }
5807
- DelayedStrategy.prototype.isSupported = function () {
5480
+ isSupported() {
5808
5481
  return this.strategy.isSupported();
5809
- };
5810
- DelayedStrategy.prototype.connect = function (minPriority, callback) {
5482
+ }
5483
+ connect(minPriority, callback) {
5811
5484
  var strategy = this.strategy;
5812
5485
  var runner;
5813
- var timer = new OneOffTimer(this.options.delay, function () {
5486
+ var timer = new timers_OneOffTimer(this.options.delay, function () {
5814
5487
  runner = strategy.connect(minPriority, callback);
5815
5488
  });
5816
5489
  return {
@@ -5827,39 +5500,35 @@ var delayed_strategy_DelayedStrategy = (function () {
5827
5500
  }
5828
5501
  }
5829
5502
  };
5830
- };
5831
- return DelayedStrategy;
5832
- }());
5833
- /* harmony default export */ var delayed_strategy = (delayed_strategy_DelayedStrategy);
5503
+ }
5504
+ }
5834
5505
 
5835
5506
  // CONCATENATED MODULE: ./src/core/strategies/if_strategy.ts
5836
- var IfStrategy = (function () {
5837
- function IfStrategy(test, trueBranch, falseBranch) {
5507
+ class IfStrategy {
5508
+ constructor(test, trueBranch, falseBranch) {
5838
5509
  this.test = test;
5839
5510
  this.trueBranch = trueBranch;
5840
5511
  this.falseBranch = falseBranch;
5841
5512
  }
5842
- IfStrategy.prototype.isSupported = function () {
5513
+ isSupported() {
5843
5514
  var branch = this.test() ? this.trueBranch : this.falseBranch;
5844
5515
  return branch.isSupported();
5845
- };
5846
- IfStrategy.prototype.connect = function (minPriority, callback) {
5516
+ }
5517
+ connect(minPriority, callback) {
5847
5518
  var branch = this.test() ? this.trueBranch : this.falseBranch;
5848
5519
  return branch.connect(minPriority, callback);
5849
- };
5850
- return IfStrategy;
5851
- }());
5852
- /* harmony default export */ var if_strategy = (IfStrategy);
5520
+ }
5521
+ }
5853
5522
 
5854
5523
  // CONCATENATED MODULE: ./src/core/strategies/first_connected_strategy.ts
5855
- var FirstConnectedStrategy = (function () {
5856
- function FirstConnectedStrategy(strategy) {
5524
+ class FirstConnectedStrategy {
5525
+ constructor(strategy) {
5857
5526
  this.strategy = strategy;
5858
5527
  }
5859
- FirstConnectedStrategy.prototype.isSupported = function () {
5528
+ isSupported() {
5860
5529
  return this.strategy.isSupported();
5861
- };
5862
- FirstConnectedStrategy.prototype.connect = function (minPriority, callback) {
5530
+ }
5531
+ connect(minPriority, callback) {
5863
5532
  var runner = this.strategy.connect(minPriority, function (error, handshake) {
5864
5533
  if (handshake) {
5865
5534
  runner.abort();
@@ -5867,10 +5536,8 @@ var FirstConnectedStrategy = (function () {
5867
5536
  callback(error, handshake);
5868
5537
  });
5869
5538
  return runner;
5870
- };
5871
- return FirstConnectedStrategy;
5872
- }());
5873
- /* harmony default export */ var first_connected_strategy = (FirstConnectedStrategy);
5539
+ }
5540
+ }
5874
5541
 
5875
5542
  // CONCATENATED MODULE: ./src/runtimes/web/default_strategy.ts
5876
5543
 
@@ -5910,12 +5577,11 @@ var getDefaultStrategy = function (config, baseOptions, defineTransport) {
5910
5577
  timeout: 15000,
5911
5578
  timeoutLimit: 60000
5912
5579
  };
5913
- var ws_manager = new transport_manager({
5914
- lives: 2,
5580
+ var ws_manager = new transport_manager_TransportManager({
5915
5581
  minPingDelay: 10000,
5916
5582
  maxPingDelay: config.activityTimeout
5917
5583
  });
5918
- var streaming_manager = new transport_manager({
5584
+ var streaming_manager = new transport_manager_TransportManager({
5919
5585
  lives: 2,
5920
5586
  minPingDelay: 10000,
5921
5587
  maxPingDelay: config.activityTimeout
@@ -5927,37 +5593,37 @@ var getDefaultStrategy = function (config, baseOptions, defineTransport) {
5927
5593
  var xdr_streaming_transport = defineTransportStrategy('xdr_streaming', 'xdr_streaming', 1, sockjs_options, streaming_manager);
5928
5594
  var xhr_polling_transport = defineTransportStrategy('xhr_polling', 'xhr_polling', 1, sockjs_options);
5929
5595
  var xdr_polling_transport = defineTransportStrategy('xdr_polling', 'xdr_polling', 1, sockjs_options);
5930
- var ws_loop = new sequential_strategy([ws_transport], timeouts);
5931
- var wss_loop = new sequential_strategy([wss_transport], timeouts);
5932
- var sockjs_loop = new sequential_strategy([sockjs_transport], timeouts);
5933
- var streaming_loop = new sequential_strategy([
5934
- new if_strategy(testSupportsStrategy(xhr_streaming_transport), xhr_streaming_transport, xdr_streaming_transport)
5596
+ var ws_loop = new sequential_strategy_SequentialStrategy([ws_transport], timeouts);
5597
+ var wss_loop = new sequential_strategy_SequentialStrategy([wss_transport], timeouts);
5598
+ var sockjs_loop = new sequential_strategy_SequentialStrategy([sockjs_transport], timeouts);
5599
+ var streaming_loop = new sequential_strategy_SequentialStrategy([
5600
+ new IfStrategy(testSupportsStrategy(xhr_streaming_transport), xhr_streaming_transport, xdr_streaming_transport)
5935
5601
  ], timeouts);
5936
- var polling_loop = new sequential_strategy([
5937
- new if_strategy(testSupportsStrategy(xhr_polling_transport), xhr_polling_transport, xdr_polling_transport)
5602
+ var polling_loop = new sequential_strategy_SequentialStrategy([
5603
+ new IfStrategy(testSupportsStrategy(xhr_polling_transport), xhr_polling_transport, xdr_polling_transport)
5938
5604
  ], timeouts);
5939
- var http_loop = new sequential_strategy([
5940
- new if_strategy(testSupportsStrategy(streaming_loop), new best_connected_ever_strategy([
5605
+ var http_loop = new sequential_strategy_SequentialStrategy([
5606
+ new IfStrategy(testSupportsStrategy(streaming_loop), new best_connected_ever_strategy_BestConnectedEverStrategy([
5941
5607
  streaming_loop,
5942
- new delayed_strategy(polling_loop, { delay: 4000 })
5608
+ new delayed_strategy_DelayedStrategy(polling_loop, { delay: 4000 })
5943
5609
  ]), polling_loop)
5944
5610
  ], timeouts);
5945
- var http_fallback_loop = new if_strategy(testSupportsStrategy(http_loop), http_loop, sockjs_loop);
5611
+ var http_fallback_loop = new IfStrategy(testSupportsStrategy(http_loop), http_loop, sockjs_loop);
5946
5612
  var wsStrategy;
5947
5613
  if (baseOptions.useTLS) {
5948
- wsStrategy = new best_connected_ever_strategy([
5614
+ wsStrategy = new best_connected_ever_strategy_BestConnectedEverStrategy([
5949
5615
  ws_loop,
5950
- new delayed_strategy(http_fallback_loop, { delay: 2000 })
5616
+ new delayed_strategy_DelayedStrategy(http_fallback_loop, { delay: 2000 })
5951
5617
  ]);
5952
5618
  }
5953
5619
  else {
5954
- wsStrategy = new best_connected_ever_strategy([
5620
+ wsStrategy = new best_connected_ever_strategy_BestConnectedEverStrategy([
5955
5621
  ws_loop,
5956
- new delayed_strategy(wss_loop, { delay: 2000 }),
5957
- new delayed_strategy(http_fallback_loop, { delay: 5000 })
5622
+ new delayed_strategy_DelayedStrategy(wss_loop, { delay: 2000 }),
5623
+ new delayed_strategy_DelayedStrategy(http_fallback_loop, { delay: 5000 })
5958
5624
  ]);
5959
5625
  }
5960
- return new cached_strategy(new first_connected_strategy(new if_strategy(testSupportsStrategy(ws_transport), wsStrategy, http_fallback_loop)), definedTransports, {
5626
+ return new cached_strategy_CachedStrategy(new FirstConnectedStrategy(new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_fallback_loop)), definedTransports, {
5961
5627
  ttl: 1800000,
5962
5628
  timeline: baseOptions.timeline,
5963
5629
  useTLS: baseOptions.useTLS
@@ -6031,37 +5697,21 @@ var http_xdomain_request_hooks = {
6031
5697
  /* harmony default export */ var http_xdomain_request = (http_xdomain_request_hooks);
6032
5698
 
6033
5699
  // CONCATENATED MODULE: ./src/core/http/http_request.ts
6034
- var http_request_extends = (undefined && undefined.__extends) || (function () {
6035
- var extendStatics = function (d, b) {
6036
- extendStatics = Object.setPrototypeOf ||
6037
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6038
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6039
- return extendStatics(d, b);
6040
- };
6041
- return function (d, b) {
6042
- extendStatics(d, b);
6043
- function __() { this.constructor = d; }
6044
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6045
- };
6046
- })();
6047
5700
 
6048
5701
 
6049
- var MAX_BUFFER_LENGTH = 256 * 1024;
6050
- var http_request_HTTPRequest = (function (_super) {
6051
- http_request_extends(HTTPRequest, _super);
6052
- function HTTPRequest(hooks, method, url) {
6053
- var _this = _super.call(this) || this;
6054
- _this.hooks = hooks;
6055
- _this.method = method;
6056
- _this.url = url;
6057
- return _this;
5702
+ const MAX_BUFFER_LENGTH = 256 * 1024;
5703
+ class http_request_HTTPRequest extends dispatcher_Dispatcher {
5704
+ constructor(hooks, method, url) {
5705
+ super();
5706
+ this.hooks = hooks;
5707
+ this.method = method;
5708
+ this.url = url;
6058
5709
  }
6059
- HTTPRequest.prototype.start = function (payload) {
6060
- var _this = this;
5710
+ start(payload) {
6061
5711
  this.position = 0;
6062
5712
  this.xhr = this.hooks.getRequest(this);
6063
- this.unloader = function () {
6064
- _this.close();
5713
+ this.unloader = () => {
5714
+ this.close();
6065
5715
  };
6066
5716
  runtime.addUnloadListener(this.unloader);
6067
5717
  this.xhr.open(this.method, this.url, true);
@@ -6069,8 +5719,8 @@ var http_request_HTTPRequest = (function (_super) {
6069
5719
  this.xhr.setRequestHeader('Content-Type', 'application/json');
6070
5720
  }
6071
5721
  this.xhr.send(payload);
6072
- };
6073
- HTTPRequest.prototype.close = function () {
5722
+ }
5723
+ close() {
6074
5724
  if (this.unloader) {
6075
5725
  runtime.removeUnloadListener(this.unloader);
6076
5726
  this.unloader = null;
@@ -6079,8 +5729,8 @@ var http_request_HTTPRequest = (function (_super) {
6079
5729
  this.hooks.abortRequest(this.xhr);
6080
5730
  this.xhr = null;
6081
5731
  }
6082
- };
6083
- HTTPRequest.prototype.onChunk = function (status, data) {
5732
+ }
5733
+ onChunk(status, data) {
6084
5734
  while (true) {
6085
5735
  var chunk = this.advanceBuffer(data);
6086
5736
  if (chunk) {
@@ -6093,8 +5743,8 @@ var http_request_HTTPRequest = (function (_super) {
6093
5743
  if (this.isBufferTooLong(data)) {
6094
5744
  this.emit('buffer_too_long');
6095
5745
  }
6096
- };
6097
- HTTPRequest.prototype.advanceBuffer = function (buffer) {
5746
+ }
5747
+ advanceBuffer(buffer) {
6098
5748
  var unreadData = buffer.slice(this.position);
6099
5749
  var endOfLinePosition = unreadData.indexOf('\n');
6100
5750
  if (endOfLinePosition !== -1) {
@@ -6104,13 +5754,11 @@ var http_request_HTTPRequest = (function (_super) {
6104
5754
  else {
6105
5755
  return null;
6106
5756
  }
6107
- };
6108
- HTTPRequest.prototype.isBufferTooLong = function (buffer) {
5757
+ }
5758
+ isBufferTooLong(buffer) {
6109
5759
  return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;
6110
- };
6111
- return HTTPRequest;
6112
- }(dispatcher));
6113
- /* harmony default export */ var http_request = (http_request_HTTPRequest);
5760
+ }
5761
+ }
6114
5762
 
6115
5763
  // CONCATENATED MODULE: ./src/core/http/state.ts
6116
5764
  var State;
@@ -6126,24 +5774,24 @@ var State;
6126
5774
 
6127
5775
 
6128
5776
  var autoIncrement = 1;
6129
- var http_socket_HTTPSocket = (function () {
6130
- function HTTPSocket(hooks, url) {
5777
+ class http_socket_HTTPSocket {
5778
+ constructor(hooks, url) {
6131
5779
  this.hooks = hooks;
6132
5780
  this.session = randomNumber(1000) + '/' + randomString(8);
6133
5781
  this.location = getLocation(url);
6134
5782
  this.readyState = state.CONNECTING;
6135
5783
  this.openStream();
6136
5784
  }
6137
- HTTPSocket.prototype.send = function (payload) {
5785
+ send(payload) {
6138
5786
  return this.sendRaw(JSON.stringify([payload]));
6139
- };
6140
- HTTPSocket.prototype.ping = function () {
5787
+ }
5788
+ ping() {
6141
5789
  this.hooks.sendHeartbeat(this);
6142
- };
6143
- HTTPSocket.prototype.close = function (code, reason) {
5790
+ }
5791
+ close(code, reason) {
6144
5792
  this.onClose(code, reason, true);
6145
- };
6146
- HTTPSocket.prototype.sendRaw = function (payload) {
5793
+ }
5794
+ sendRaw(payload) {
6147
5795
  if (this.readyState === state.OPEN) {
6148
5796
  try {
6149
5797
  runtime.createSocketRequest('POST', getUniqueURL(getSendURL(this.location, this.session))).start(payload);
@@ -6156,12 +5804,12 @@ var http_socket_HTTPSocket = (function () {
6156
5804
  else {
6157
5805
  return false;
6158
5806
  }
6159
- };
6160
- HTTPSocket.prototype.reconnect = function () {
5807
+ }
5808
+ reconnect() {
6161
5809
  this.closeStream();
6162
5810
  this.openStream();
6163
- };
6164
- HTTPSocket.prototype.onClose = function (code, reason, wasClean) {
5811
+ }
5812
+ onClose(code, reason, wasClean) {
6165
5813
  this.closeStream();
6166
5814
  this.readyState = state.CLOSED;
6167
5815
  if (this.onclose) {
@@ -6171,8 +5819,8 @@ var http_socket_HTTPSocket = (function () {
6171
5819
  wasClean: wasClean
6172
5820
  });
6173
5821
  }
6174
- };
6175
- HTTPSocket.prototype.onChunk = function (chunk) {
5822
+ }
5823
+ onChunk(chunk) {
6176
5824
  if (chunk.status !== 200) {
6177
5825
  return;
6178
5826
  }
@@ -6204,8 +5852,8 @@ var http_socket_HTTPSocket = (function () {
6204
5852
  this.onClose(payload[0], payload[1], true);
6205
5853
  break;
6206
5854
  }
6207
- };
6208
- HTTPSocket.prototype.onOpen = function (options) {
5855
+ }
5856
+ onOpen(options) {
6209
5857
  if (this.readyState === state.CONNECTING) {
6210
5858
  if (options && options.hostname) {
6211
5859
  this.location.base = replaceHost(this.location.base, options.hostname);
@@ -6218,53 +5866,51 @@ var http_socket_HTTPSocket = (function () {
6218
5866
  else {
6219
5867
  this.onClose(1006, 'Server lost session', true);
6220
5868
  }
6221
- };
6222
- HTTPSocket.prototype.onEvent = function (event) {
5869
+ }
5870
+ onEvent(event) {
6223
5871
  if (this.readyState === state.OPEN && this.onmessage) {
6224
5872
  this.onmessage({ data: event });
6225
5873
  }
6226
- };
6227
- HTTPSocket.prototype.onActivity = function () {
5874
+ }
5875
+ onActivity() {
6228
5876
  if (this.onactivity) {
6229
5877
  this.onactivity();
6230
5878
  }
6231
- };
6232
- HTTPSocket.prototype.onError = function (error) {
5879
+ }
5880
+ onError(error) {
6233
5881
  if (this.onerror) {
6234
5882
  this.onerror(error);
6235
5883
  }
6236
- };
6237
- HTTPSocket.prototype.openStream = function () {
6238
- var _this = this;
5884
+ }
5885
+ openStream() {
6239
5886
  this.stream = runtime.createSocketRequest('POST', getUniqueURL(this.hooks.getReceiveURL(this.location, this.session)));
6240
- this.stream.bind('chunk', function (chunk) {
6241
- _this.onChunk(chunk);
5887
+ this.stream.bind('chunk', chunk => {
5888
+ this.onChunk(chunk);
6242
5889
  });
6243
- this.stream.bind('finished', function (status) {
6244
- _this.hooks.onFinished(_this, status);
5890
+ this.stream.bind('finished', status => {
5891
+ this.hooks.onFinished(this, status);
6245
5892
  });
6246
- this.stream.bind('buffer_too_long', function () {
6247
- _this.reconnect();
5893
+ this.stream.bind('buffer_too_long', () => {
5894
+ this.reconnect();
6248
5895
  });
6249
5896
  try {
6250
5897
  this.stream.start();
6251
5898
  }
6252
5899
  catch (error) {
6253
- util.defer(function () {
6254
- _this.onError(error);
6255
- _this.onClose(1006, 'Could not start streaming', false);
5900
+ util.defer(() => {
5901
+ this.onError(error);
5902
+ this.onClose(1006, 'Could not start streaming', false);
6256
5903
  });
6257
5904
  }
6258
- };
6259
- HTTPSocket.prototype.closeStream = function () {
5905
+ }
5906
+ closeStream() {
6260
5907
  if (this.stream) {
6261
5908
  this.stream.unbind_all();
6262
5909
  this.stream.close();
6263
5910
  this.stream = null;
6264
5911
  }
6265
- };
6266
- return HTTPSocket;
6267
- }());
5912
+ }
5913
+ }
6268
5914
  function getLocation(url) {
6269
5915
  var parts = /([^\?]*)\/*(\??.*)/.exec(url);
6270
5916
  return {
@@ -6371,20 +6017,20 @@ var http_xhr_request_hooks = {
6371
6017
 
6372
6018
 
6373
6019
  var HTTP = {
6374
- createStreamingSocket: function (url) {
6020
+ createStreamingSocket(url) {
6375
6021
  return this.createSocket(http_streaming_socket, url);
6376
6022
  },
6377
- createPollingSocket: function (url) {
6023
+ createPollingSocket(url) {
6378
6024
  return this.createSocket(http_polling_socket, url);
6379
6025
  },
6380
- createSocket: function (hooks, url) {
6026
+ createSocket(hooks, url) {
6381
6027
  return new http_socket(hooks, url);
6382
6028
  },
6383
- createXHR: function (method, url) {
6029
+ createXHR(method, url) {
6384
6030
  return this.createRequest(http_xhr_request, method, url);
6385
6031
  },
6386
- createRequest: function (hooks, method, url) {
6387
- return new http_request(hooks, method, url);
6032
+ createRequest(hooks, method, url) {
6033
+ return new http_request_HTTPRequest(hooks, method, url);
6388
6034
  }
6389
6035
  };
6390
6036
  /* harmony default export */ var http_http = (HTTP);
@@ -6420,17 +6066,16 @@ var Runtime = {
6420
6066
  transportConnectionInitializer: transport_connection_initializer,
6421
6067
  HTTPFactory: web_http_http,
6422
6068
  TimelineTransport: jsonp_timeline,
6423
- getXHRAPI: function () {
6069
+ getXHRAPI() {
6424
6070
  return window.XMLHttpRequest;
6425
6071
  },
6426
- getWebSocketAPI: function () {
6072
+ getWebSocketAPI() {
6427
6073
  return window.WebSocket || window.MozWebSocket;
6428
6074
  },
6429
- setup: function (PusherClass) {
6430
- var _this = this;
6075
+ setup(PusherClass) {
6431
6076
  window.Pusher = PusherClass;
6432
- var initializeOnDocumentBody = function () {
6433
- _this.onDocumentBody(PusherClass.ready);
6077
+ var initializeOnDocumentBody = () => {
6078
+ this.onDocumentBody(PusherClass.ready);
6434
6079
  };
6435
6080
  if (!window.JSON) {
6436
6081
  Dependencies.load('json2', {}, initializeOnDocumentBody);
@@ -6439,33 +6084,32 @@ var Runtime = {
6439
6084
  initializeOnDocumentBody();
6440
6085
  }
6441
6086
  },
6442
- getDocument: function () {
6087
+ getDocument() {
6443
6088
  return document;
6444
6089
  },
6445
- getProtocol: function () {
6090
+ getProtocol() {
6446
6091
  return this.getDocument().location.protocol;
6447
6092
  },
6448
- getAuthorizers: function () {
6093
+ getAuthorizers() {
6449
6094
  return { ajax: xhr_auth, jsonp: jsonp_auth };
6450
6095
  },
6451
- onDocumentBody: function (callback) {
6452
- var _this = this;
6096
+ onDocumentBody(callback) {
6453
6097
  if (document.body) {
6454
6098
  callback();
6455
6099
  }
6456
6100
  else {
6457
- setTimeout(function () {
6458
- _this.onDocumentBody(callback);
6101
+ setTimeout(() => {
6102
+ this.onDocumentBody(callback);
6459
6103
  }, 0);
6460
6104
  }
6461
6105
  },
6462
- createJSONPRequest: function (url, data) {
6463
- return new jsonp_request(url, data);
6106
+ createJSONPRequest(url, data) {
6107
+ return new jsonp_request_JSONPRequest(url, data);
6464
6108
  },
6465
- createScriptRequest: function (src) {
6466
- return new script_request(src);
6109
+ createScriptRequest(src) {
6110
+ return new ScriptRequest(src);
6467
6111
  },
6468
- getLocalStorage: function () {
6112
+ getLocalStorage() {
6469
6113
  try {
6470
6114
  return window.localStorage;
6471
6115
  }
@@ -6473,7 +6117,7 @@ var Runtime = {
6473
6117
  return undefined;
6474
6118
  }
6475
6119
  },
6476
- createXHR: function () {
6120
+ createXHR() {
6477
6121
  if (this.getXHRAPI()) {
6478
6122
  return this.createXMLHttpRequest();
6479
6123
  }
@@ -6481,21 +6125,21 @@ var Runtime = {
6481
6125
  return this.createMicrosoftXHR();
6482
6126
  }
6483
6127
  },
6484
- createXMLHttpRequest: function () {
6128
+ createXMLHttpRequest() {
6485
6129
  var Constructor = this.getXHRAPI();
6486
6130
  return new Constructor();
6487
6131
  },
6488
- createMicrosoftXHR: function () {
6132
+ createMicrosoftXHR() {
6489
6133
  return new ActiveXObject('Microsoft.XMLHTTP');
6490
6134
  },
6491
- getNetwork: function () {
6135
+ getNetwork() {
6492
6136
  return net_info_Network;
6493
6137
  },
6494
- createWebSocket: function (url) {
6138
+ createWebSocket(url) {
6495
6139
  var Constructor = this.getWebSocketAPI();
6496
6140
  return new Constructor(url);
6497
6141
  },
6498
- createSocketRequest: function (method, url) {
6142
+ createSocketRequest(method, url) {
6499
6143
  if (this.isXHRSupported()) {
6500
6144
  return this.HTTPFactory.createXHR(method, url);
6501
6145
  }
@@ -6506,16 +6150,16 @@ var Runtime = {
6506
6150
  throw 'Cross-origin HTTP requests are not supported';
6507
6151
  }
6508
6152
  },
6509
- isXHRSupported: function () {
6153
+ isXHRSupported() {
6510
6154
  var Constructor = this.getXHRAPI();
6511
6155
  return (Boolean(Constructor) && new Constructor().withCredentials !== undefined);
6512
6156
  },
6513
- isXDRSupported: function (useTLS) {
6157
+ isXDRSupported(useTLS) {
6514
6158
  var protocol = useTLS ? 'https:' : 'http:';
6515
6159
  var documentProtocol = this.getProtocol();
6516
6160
  return (Boolean(window['XDomainRequest']) && documentProtocol === protocol);
6517
6161
  },
6518
- addUnloadListener: function (listener) {
6162
+ addUnloadListener(listener) {
6519
6163
  if (window.addEventListener !== undefined) {
6520
6164
  window.addEventListener('unload', listener, false);
6521
6165
  }
@@ -6523,7 +6167,7 @@ var Runtime = {
6523
6167
  window.attachEvent('onunload', listener);
6524
6168
  }
6525
6169
  },
6526
- removeUnloadListener: function (listener) {
6170
+ removeUnloadListener(listener) {
6527
6171
  if (window.addEventListener !== undefined) {
6528
6172
  window.removeEventListener('unload', listener, false);
6529
6173
  }
@@ -6531,10 +6175,10 @@ var Runtime = {
6531
6175
  window.detachEvent('onunload', listener);
6532
6176
  }
6533
6177
  },
6534
- randomInt: function (max) {
6535
- var random = function () {
6536
- var crypto = window.crypto || window['msCrypto'];
6537
- var random = crypto.getRandomValues(new Uint32Array(1))[0];
6178
+ randomInt(max) {
6179
+ const random = function () {
6180
+ const crypto = window.crypto || window['msCrypto'];
6181
+ const random = crypto.getRandomValues(new Uint32Array(1))[0];
6538
6182
  return random / Math.pow(2, 32);
6539
6183
  };
6540
6184
  return Math.floor(random() * max);
@@ -6555,8 +6199,8 @@ var TimelineLevel;
6555
6199
 
6556
6200
 
6557
6201
 
6558
- var timeline_Timeline = (function () {
6559
- function Timeline(key, session, options) {
6202
+ class timeline_Timeline {
6203
+ constructor(key, session, options) {
6560
6204
  this.key = key;
6561
6205
  this.session = session;
6562
6206
  this.events = [];
@@ -6564,28 +6208,27 @@ var timeline_Timeline = (function () {
6564
6208
  this.sent = 0;
6565
6209
  this.uniqueID = 0;
6566
6210
  }
6567
- Timeline.prototype.log = function (level, event) {
6211
+ log(level, event) {
6568
6212
  if (level <= this.options.level) {
6569
6213
  this.events.push(extend({}, event, { timestamp: util.now() }));
6570
6214
  if (this.options.limit && this.events.length > this.options.limit) {
6571
6215
  this.events.shift();
6572
6216
  }
6573
6217
  }
6574
- };
6575
- Timeline.prototype.error = function (event) {
6218
+ }
6219
+ error(event) {
6576
6220
  this.log(timeline_level.ERROR, event);
6577
- };
6578
- Timeline.prototype.info = function (event) {
6221
+ }
6222
+ info(event) {
6579
6223
  this.log(timeline_level.INFO, event);
6580
- };
6581
- Timeline.prototype.debug = function (event) {
6224
+ }
6225
+ debug(event) {
6582
6226
  this.log(timeline_level.DEBUG, event);
6583
- };
6584
- Timeline.prototype.isEmpty = function () {
6227
+ }
6228
+ isEmpty() {
6585
6229
  return this.events.length === 0;
6586
- };
6587
- Timeline.prototype.send = function (sendfn, callback) {
6588
- var _this = this;
6230
+ }
6231
+ send(sendfn, callback) {
6589
6232
  var data = extend({
6590
6233
  session: this.session,
6591
6234
  bundle: this.sent + 1,
@@ -6597,43 +6240,40 @@ var timeline_Timeline = (function () {
6597
6240
  timeline: this.events
6598
6241
  }, this.options.params);
6599
6242
  this.events = [];
6600
- sendfn(data, function (error, result) {
6243
+ sendfn(data, (error, result) => {
6601
6244
  if (!error) {
6602
- _this.sent++;
6245
+ this.sent++;
6603
6246
  }
6604
6247
  if (callback) {
6605
6248
  callback(error, result);
6606
6249
  }
6607
6250
  });
6608
6251
  return true;
6609
- };
6610
- Timeline.prototype.generateUniqueID = function () {
6252
+ }
6253
+ generateUniqueID() {
6611
6254
  this.uniqueID++;
6612
6255
  return this.uniqueID;
6613
- };
6614
- return Timeline;
6615
- }());
6616
- /* harmony default export */ var timeline_timeline = (timeline_Timeline);
6256
+ }
6257
+ }
6617
6258
 
6618
6259
  // CONCATENATED MODULE: ./src/core/strategies/transport_strategy.ts
6619
6260
 
6620
6261
 
6621
6262
 
6622
6263
 
6623
- var transport_strategy_TransportStrategy = (function () {
6624
- function TransportStrategy(name, priority, transport, options) {
6264
+ class transport_strategy_TransportStrategy {
6265
+ constructor(name, priority, transport, options) {
6625
6266
  this.name = name;
6626
6267
  this.priority = priority;
6627
6268
  this.transport = transport;
6628
6269
  this.options = options || {};
6629
6270
  }
6630
- TransportStrategy.prototype.isSupported = function () {
6271
+ isSupported() {
6631
6272
  return this.transport.isSupported({
6632
6273
  useTLS: this.options.useTLS
6633
6274
  });
6634
- };
6635
- TransportStrategy.prototype.connect = function (minPriority, callback) {
6636
- var _this = this;
6275
+ }
6276
+ connect(minPriority, callback) {
6637
6277
  if (!this.isSupported()) {
6638
6278
  return failAttempt(new UnsupportedStrategy(), callback);
6639
6279
  }
@@ -6676,7 +6316,7 @@ var transport_strategy_TransportStrategy = (function () {
6676
6316
  transport.bind('closed', onClosed);
6677
6317
  transport.initialize();
6678
6318
  return {
6679
- abort: function () {
6319
+ abort: () => {
6680
6320
  if (connected) {
6681
6321
  return;
6682
6322
  }
@@ -6688,11 +6328,11 @@ var transport_strategy_TransportStrategy = (function () {
6688
6328
  transport.close();
6689
6329
  }
6690
6330
  },
6691
- forceMinPriority: function (p) {
6331
+ forceMinPriority: p => {
6692
6332
  if (connected) {
6693
6333
  return;
6694
6334
  }
6695
- if (_this.priority < p) {
6335
+ if (this.priority < p) {
6696
6336
  if (handshake) {
6697
6337
  handshake.close();
6698
6338
  }
@@ -6702,10 +6342,8 @@ var transport_strategy_TransportStrategy = (function () {
6702
6342
  }
6703
6343
  }
6704
6344
  };
6705
- };
6706
- return TransportStrategy;
6707
- }());
6708
- /* harmony default export */ var transport_strategy = (transport_strategy_TransportStrategy);
6345
+ }
6346
+ }
6709
6347
  function failAttempt(error, callback) {
6710
6348
  util.defer(function () {
6711
6349
  callback(error);
@@ -6722,7 +6360,7 @@ function failAttempt(error, callback) {
6722
6360
 
6723
6361
 
6724
6362
 
6725
- var strategy_builder_Transports = runtime.Transports;
6363
+ const { Transports: strategy_builder_Transports } = runtime;
6726
6364
  var strategy_builder_defineTransport = function (config, name, type, priority, options, manager) {
6727
6365
  var transportClass = strategy_builder_Transports[type];
6728
6366
  if (!transportClass) {
@@ -6735,7 +6373,7 @@ var strategy_builder_defineTransport = function (config, name, type, priority, o
6735
6373
  var transport;
6736
6374
  if (enabled) {
6737
6375
  options = Object.assign({ ignoreNullOrigin: config.ignoreNullOrigin }, options);
6738
- transport = new transport_strategy(name, priority, manager ? manager.getAssistant(transportClass) : transportClass, options);
6376
+ transport = new transport_strategy_TransportStrategy(name, priority, manager ? manager.getAssistant(transportClass) : transportClass, options);
6739
6377
  }
6740
6378
  else {
6741
6379
  transport = strategy_builder_UnsupportedStrategy;
@@ -6776,7 +6414,7 @@ function validateOptions(options) {
6776
6414
  // CONCATENATED MODULE: ./src/core/auth/user_authenticator.ts
6777
6415
 
6778
6416
 
6779
- var composeChannelQuery = function (params, authOptions) {
6417
+ const composeChannelQuery = (params, authOptions) => {
6780
6418
  var query = 'socket_id=' + encodeURIComponent(params.socketId);
6781
6419
  for (var key in authOptions.params) {
6782
6420
  query +=
@@ -6786,7 +6424,7 @@ var composeChannelQuery = function (params, authOptions) {
6786
6424
  encodeURIComponent(authOptions.params[key]);
6787
6425
  }
6788
6426
  if (authOptions.paramsProvider != null) {
6789
- var dynamicParams = authOptions.paramsProvider();
6427
+ let dynamicParams = authOptions.paramsProvider();
6790
6428
  for (var key in dynamicParams) {
6791
6429
  query +=
6792
6430
  '&' +
@@ -6797,12 +6435,12 @@ var composeChannelQuery = function (params, authOptions) {
6797
6435
  }
6798
6436
  return query;
6799
6437
  };
6800
- var UserAuthenticator = function (authOptions) {
6438
+ const UserAuthenticator = (authOptions) => {
6801
6439
  if (typeof runtime.getAuthorizers()[authOptions.transport] === 'undefined') {
6802
- throw "'" + authOptions.transport + "' is not a recognized auth transport";
6440
+ throw `'${authOptions.transport}' is not a recognized auth transport`;
6803
6441
  }
6804
- return function (params, callback) {
6805
- var query = composeChannelQuery(params, authOptions);
6442
+ return (params, callback) => {
6443
+ const query = composeChannelQuery(params, authOptions);
6806
6444
  runtime.getAuthorizers()[authOptions.transport](runtime, query, authOptions, AuthRequestType.UserAuthentication, callback);
6807
6445
  };
6808
6446
  };
@@ -6811,7 +6449,7 @@ var UserAuthenticator = function (authOptions) {
6811
6449
  // CONCATENATED MODULE: ./src/core/auth/channel_authorizer.ts
6812
6450
 
6813
6451
 
6814
- var channel_authorizer_composeChannelQuery = function (params, authOptions) {
6452
+ const channel_authorizer_composeChannelQuery = (params, authOptions) => {
6815
6453
  var query = 'socket_id=' + encodeURIComponent(params.socketId);
6816
6454
  query += '&channel_name=' + encodeURIComponent(params.channelName);
6817
6455
  for (var key in authOptions.params) {
@@ -6822,7 +6460,7 @@ var channel_authorizer_composeChannelQuery = function (params, authOptions) {
6822
6460
  encodeURIComponent(authOptions.params[key]);
6823
6461
  }
6824
6462
  if (authOptions.paramsProvider != null) {
6825
- var dynamicParams = authOptions.paramsProvider();
6463
+ let dynamicParams = authOptions.paramsProvider();
6826
6464
  for (var key in dynamicParams) {
6827
6465
  query +=
6828
6466
  '&' +
@@ -6833,20 +6471,20 @@ var channel_authorizer_composeChannelQuery = function (params, authOptions) {
6833
6471
  }
6834
6472
  return query;
6835
6473
  };
6836
- var ChannelAuthorizer = function (authOptions) {
6474
+ const ChannelAuthorizer = (authOptions) => {
6837
6475
  if (typeof runtime.getAuthorizers()[authOptions.transport] === 'undefined') {
6838
- throw "'" + authOptions.transport + "' is not a recognized auth transport";
6476
+ throw `'${authOptions.transport}' is not a recognized auth transport`;
6839
6477
  }
6840
- return function (params, callback) {
6841
- var query = channel_authorizer_composeChannelQuery(params, authOptions);
6478
+ return (params, callback) => {
6479
+ const query = channel_authorizer_composeChannelQuery(params, authOptions);
6842
6480
  runtime.getAuthorizers()[authOptions.transport](runtime, query, authOptions, AuthRequestType.ChannelAuthorization, callback);
6843
6481
  };
6844
6482
  };
6845
6483
  /* harmony default export */ var channel_authorizer = (ChannelAuthorizer);
6846
6484
 
6847
6485
  // CONCATENATED MODULE: ./src/core/auth/deprecated_channel_authorizer.ts
6848
- var ChannelAuthorizerProxy = function (pusher, authOptions, channelAuthorizerGenerator) {
6849
- var deprecatedAuthorizerOptions = {
6486
+ const ChannelAuthorizerProxy = (pusher, authOptions, channelAuthorizerGenerator) => {
6487
+ const deprecatedAuthorizerOptions = {
6850
6488
  authTransport: authOptions.transport,
6851
6489
  authEndpoint: authOptions.endpoint,
6852
6490
  auth: {
@@ -6854,32 +6492,21 @@ var ChannelAuthorizerProxy = function (pusher, authOptions, channelAuthorizerGen
6854
6492
  headers: authOptions.headers
6855
6493
  }
6856
6494
  };
6857
- return function (params, callback) {
6858
- var channel = pusher.channel(params.channelName);
6859
- var channelAuthorizer = channelAuthorizerGenerator(channel, deprecatedAuthorizerOptions);
6495
+ return (params, callback) => {
6496
+ const channel = pusher.channel(params.channelName);
6497
+ const channelAuthorizer = channelAuthorizerGenerator(channel, deprecatedAuthorizerOptions);
6860
6498
  channelAuthorizer.authorize(params.socketId, callback);
6861
6499
  };
6862
6500
  };
6863
6501
 
6864
6502
  // CONCATENATED MODULE: ./src/core/config.ts
6865
- var __assign = (undefined && undefined.__assign) || function () {
6866
- __assign = Object.assign || function(t) {
6867
- for (var s, i = 1, n = arguments.length; i < n; i++) {
6868
- s = arguments[i];
6869
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6870
- t[p] = s[p];
6871
- }
6872
- return t;
6873
- };
6874
- return __assign.apply(this, arguments);
6875
- };
6876
6503
 
6877
6504
 
6878
6505
 
6879
6506
 
6880
6507
 
6881
6508
  function getConfig(opts, pusher) {
6882
- var config = {
6509
+ let config = {
6883
6510
  activityTimeout: opts.activityTimeout || defaults.activityTimeout,
6884
6511
  cluster: opts.cluster,
6885
6512
  httpPath: opts.httpPath || defaults.httpPath,
@@ -6916,7 +6543,7 @@ function getHttpHost(opts) {
6916
6543
  return opts.httpHost;
6917
6544
  }
6918
6545
  if (opts.cluster) {
6919
- return "sockjs-" + opts.cluster + ".pusher.com";
6546
+ return `sockjs-${opts.cluster}.pusher.com`;
6920
6547
  }
6921
6548
  return defaults.httpHost;
6922
6549
  }
@@ -6927,7 +6554,7 @@ function getWebsocketHost(opts) {
6927
6554
  return getWebsocketHostFromCluster(opts.cluster);
6928
6555
  }
6929
6556
  function getWebsocketHostFromCluster(cluster) {
6930
- return "ws-" + cluster + ".pusher.com";
6557
+ return `ws-${cluster}.pusher.com`;
6931
6558
  }
6932
6559
  function shouldUseTLS(opts) {
6933
6560
  if (runtime.getProtocol() === 'https:') {
@@ -6948,7 +6575,7 @@ function getEnableStatsConfig(opts) {
6948
6575
  return false;
6949
6576
  }
6950
6577
  function buildUserAuthenticator(opts) {
6951
- var userAuthentication = __assign(__assign({}, defaults.userAuthentication), opts.userAuthentication);
6578
+ const userAuthentication = Object.assign(Object.assign({}, defaults.userAuthentication), opts.userAuthentication);
6952
6579
  if ('customHandler' in userAuthentication &&
6953
6580
  userAuthentication['customHandler'] != null) {
6954
6581
  return userAuthentication['customHandler'];
@@ -6956,9 +6583,9 @@ function buildUserAuthenticator(opts) {
6956
6583
  return user_authenticator(userAuthentication);
6957
6584
  }
6958
6585
  function buildChannelAuth(opts, pusher) {
6959
- var channelAuthorization;
6586
+ let channelAuthorization;
6960
6587
  if ('channelAuthorization' in opts) {
6961
- channelAuthorization = __assign(__assign({}, defaults.channelAuthorization), opts.channelAuthorization);
6588
+ channelAuthorization = Object.assign(Object.assign({}, defaults.channelAuthorization), opts.channelAuthorization);
6962
6589
  }
6963
6590
  else {
6964
6591
  channelAuthorization = {
@@ -6977,7 +6604,7 @@ function buildChannelAuth(opts, pusher) {
6977
6604
  return channelAuthorization;
6978
6605
  }
6979
6606
  function buildChannelAuthorizer(opts, pusher) {
6980
- var channelAuthorization = buildChannelAuth(opts, pusher);
6607
+ const channelAuthorization = buildChannelAuth(opts, pusher);
6981
6608
  if ('customHandler' in channelAuthorization &&
6982
6609
  channelAuthorization['customHandler'] != null) {
6983
6610
  return channelAuthorization['customHandler'];
@@ -6986,134 +6613,99 @@ function buildChannelAuthorizer(opts, pusher) {
6986
6613
  }
6987
6614
 
6988
6615
  // CONCATENATED MODULE: ./src/core/watchlist.ts
6989
- var watchlist_extends = (undefined && undefined.__extends) || (function () {
6990
- var extendStatics = function (d, b) {
6991
- extendStatics = Object.setPrototypeOf ||
6992
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6993
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6994
- return extendStatics(d, b);
6995
- };
6996
- return function (d, b) {
6997
- extendStatics(d, b);
6998
- function __() { this.constructor = d; }
6999
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7000
- };
7001
- })();
7002
6616
 
7003
6617
 
7004
- var watchlist_WatchlistFacade = (function (_super) {
7005
- watchlist_extends(WatchlistFacade, _super);
7006
- function WatchlistFacade(pusher) {
7007
- var _this = _super.call(this, function (eventName, data) {
7008
- logger.debug("No callbacks on watchlist events for " + eventName);
7009
- }) || this;
7010
- _this.pusher = pusher;
7011
- _this.bindWatchlistInternalEvent();
7012
- return _this;
7013
- }
7014
- WatchlistFacade.prototype.handleEvent = function (pusherEvent) {
7015
- var _this = this;
7016
- pusherEvent.data.events.forEach(function (watchlistEvent) {
7017
- _this.emit(watchlistEvent.name, watchlistEvent);
6618
+ class watchlist_WatchlistFacade extends dispatcher_Dispatcher {
6619
+ constructor(pusher) {
6620
+ super(function (eventName, data) {
6621
+ logger.debug(`No callbacks on watchlist events for ${eventName}`);
7018
6622
  });
7019
- };
7020
- WatchlistFacade.prototype.bindWatchlistInternalEvent = function () {
7021
- var _this = this;
7022
- this.pusher.connection.bind('message', function (pusherEvent) {
6623
+ this.pusher = pusher;
6624
+ this.bindWatchlistInternalEvent();
6625
+ }
6626
+ handleEvent(pusherEvent) {
6627
+ pusherEvent.data.events.forEach(watchlistEvent => {
6628
+ this.emit(watchlistEvent.name, watchlistEvent);
6629
+ });
6630
+ }
6631
+ bindWatchlistInternalEvent() {
6632
+ this.pusher.connection.bind('message', pusherEvent => {
7023
6633
  var eventName = pusherEvent.event;
7024
6634
  if (eventName === 'pusher_internal:watchlist_events') {
7025
- _this.handleEvent(pusherEvent);
6635
+ this.handleEvent(pusherEvent);
7026
6636
  }
7027
6637
  });
7028
- };
7029
- return WatchlistFacade;
7030
- }(dispatcher));
7031
- /* harmony default export */ var watchlist = (watchlist_WatchlistFacade);
6638
+ }
6639
+ }
7032
6640
 
7033
6641
  // CONCATENATED MODULE: ./src/core/utils/flat_promise.ts
7034
6642
  function flatPromise() {
7035
- var resolve, reject;
7036
- var promise = new Promise(function (res, rej) {
6643
+ let resolve, reject;
6644
+ const promise = new Promise((res, rej) => {
7037
6645
  resolve = res;
7038
6646
  reject = rej;
7039
6647
  });
7040
- return { promise: promise, resolve: resolve, reject: reject };
6648
+ return { promise, resolve, reject };
7041
6649
  }
7042
6650
  /* harmony default export */ var flat_promise = (flatPromise);
7043
6651
 
7044
6652
  // CONCATENATED MODULE: ./src/core/user.ts
7045
- var user_extends = (undefined && undefined.__extends) || (function () {
7046
- var extendStatics = function (d, b) {
7047
- extendStatics = Object.setPrototypeOf ||
7048
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
7049
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7050
- return extendStatics(d, b);
7051
- };
7052
- return function (d, b) {
7053
- extendStatics(d, b);
7054
- function __() { this.constructor = d; }
7055
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7056
- };
7057
- })();
7058
6653
 
7059
6654
 
7060
6655
 
7061
6656
 
7062
6657
 
7063
- var user_UserFacade = (function (_super) {
7064
- user_extends(UserFacade, _super);
7065
- function UserFacade(pusher) {
7066
- var _this = _super.call(this, function (eventName, data) {
6658
+ class user_UserFacade extends dispatcher_Dispatcher {
6659
+ constructor(pusher) {
6660
+ super(function (eventName, data) {
7067
6661
  logger.debug('No callbacks on user for ' + eventName);
7068
- }) || this;
7069
- _this.signin_requested = false;
7070
- _this.user_data = null;
7071
- _this.serverToUserChannel = null;
7072
- _this.signinDonePromise = null;
7073
- _this._signinDoneResolve = null;
7074
- _this._onAuthorize = function (err, authData) {
6662
+ });
6663
+ this.signin_requested = false;
6664
+ this.user_data = null;
6665
+ this.serverToUserChannel = null;
6666
+ this.signinDonePromise = null;
6667
+ this._signinDoneResolve = null;
6668
+ this._onAuthorize = (err, authData) => {
7075
6669
  if (err) {
7076
- logger.warn("Error during signin: " + err);
7077
- _this._cleanup();
6670
+ logger.warn(`Error during signin: ${err}`);
6671
+ this._cleanup();
7078
6672
  return;
7079
6673
  }
7080
- _this.pusher.send_event('pusher:signin', {
6674
+ this.pusher.send_event('pusher:signin', {
7081
6675
  auth: authData.auth,
7082
6676
  user_data: authData.user_data
7083
6677
  });
7084
6678
  };
7085
- _this.pusher = pusher;
7086
- _this.pusher.connection.bind('state_change', function (_a) {
7087
- var previous = _a.previous, current = _a.current;
6679
+ this.pusher = pusher;
6680
+ this.pusher.connection.bind('state_change', ({ previous, current }) => {
7088
6681
  if (previous !== 'connected' && current === 'connected') {
7089
- _this._signin();
6682
+ this._signin();
7090
6683
  }
7091
6684
  if (previous === 'connected' && current !== 'connected') {
7092
- _this._cleanup();
7093
- _this._newSigninPromiseIfNeeded();
6685
+ this._cleanup();
6686
+ this._newSigninPromiseIfNeeded();
7094
6687
  }
7095
6688
  });
7096
- _this.watchlist = new watchlist(pusher);
7097
- _this.pusher.connection.bind('message', function (event) {
6689
+ this.watchlist = new watchlist_WatchlistFacade(pusher);
6690
+ this.pusher.connection.bind('message', event => {
7098
6691
  var eventName = event.event;
7099
6692
  if (eventName === 'pusher:signin_success') {
7100
- _this._onSigninSuccess(event.data);
6693
+ this._onSigninSuccess(event.data);
7101
6694
  }
7102
- if (_this.serverToUserChannel &&
7103
- _this.serverToUserChannel.name === event.channel) {
7104
- _this.serverToUserChannel.handleEvent(event);
6695
+ if (this.serverToUserChannel &&
6696
+ this.serverToUserChannel.name === event.channel) {
6697
+ this.serverToUserChannel.handleEvent(event);
7105
6698
  }
7106
6699
  });
7107
- return _this;
7108
6700
  }
7109
- UserFacade.prototype.signin = function () {
6701
+ signin() {
7110
6702
  if (this.signin_requested) {
7111
6703
  return;
7112
6704
  }
7113
6705
  this.signin_requested = true;
7114
6706
  this._signin();
7115
- };
7116
- UserFacade.prototype._signin = function () {
6707
+ }
6708
+ _signin() {
7117
6709
  if (!this.signin_requested) {
7118
6710
  return;
7119
6711
  }
@@ -7124,46 +6716,45 @@ var user_UserFacade = (function (_super) {
7124
6716
  this.pusher.config.userAuthenticator({
7125
6717
  socketId: this.pusher.connection.socket_id
7126
6718
  }, this._onAuthorize);
7127
- };
7128
- UserFacade.prototype._onSigninSuccess = function (data) {
6719
+ }
6720
+ _onSigninSuccess(data) {
7129
6721
  try {
7130
6722
  this.user_data = JSON.parse(data.user_data);
7131
6723
  }
7132
6724
  catch (e) {
7133
- logger.error("Failed parsing user data after signin: " + data.user_data);
6725
+ logger.error(`Failed parsing user data after signin: ${data.user_data}`);
7134
6726
  this._cleanup();
7135
6727
  return;
7136
6728
  }
7137
6729
  if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {
7138
- logger.error("user_data doesn't contain an id. user_data: " + this.user_data);
6730
+ logger.error(`user_data doesn't contain an id. user_data: ${this.user_data}`);
7139
6731
  this._cleanup();
7140
6732
  return;
7141
6733
  }
7142
6734
  this._signinDoneResolve();
7143
6735
  this._subscribeChannels();
7144
- };
7145
- UserFacade.prototype._subscribeChannels = function () {
7146
- var _this = this;
7147
- var ensure_subscribed = function (channel) {
6736
+ }
6737
+ _subscribeChannels() {
6738
+ const ensure_subscribed = channel => {
7148
6739
  if (channel.subscriptionPending && channel.subscriptionCancelled) {
7149
6740
  channel.reinstateSubscription();
7150
6741
  }
7151
6742
  else if (!channel.subscriptionPending &&
7152
- _this.pusher.connection.state === 'connected') {
6743
+ this.pusher.connection.state === 'connected') {
7153
6744
  channel.subscribe();
7154
6745
  }
7155
6746
  };
7156
- this.serverToUserChannel = new channels_channel("#server-to-user-" + this.user_data.id, this.pusher);
7157
- this.serverToUserChannel.bind_global(function (eventName, data) {
6747
+ this.serverToUserChannel = new channel_Channel(`#server-to-user-${this.user_data.id}`, this.pusher);
6748
+ this.serverToUserChannel.bind_global((eventName, data) => {
7158
6749
  if (eventName.indexOf('pusher_internal:') === 0 ||
7159
6750
  eventName.indexOf('pusher:') === 0) {
7160
6751
  return;
7161
6752
  }
7162
- _this.emit(eventName, data);
6753
+ this.emit(eventName, data);
7163
6754
  });
7164
6755
  ensure_subscribed(this.serverToUserChannel);
7165
- };
7166
- UserFacade.prototype._cleanup = function () {
6756
+ }
6757
+ _cleanup() {
7167
6758
  this.user_data = null;
7168
6759
  if (this.serverToUserChannel) {
7169
6760
  this.serverToUserChannel.unbind_all();
@@ -7173,26 +6764,24 @@ var user_UserFacade = (function (_super) {
7173
6764
  if (this.signin_requested) {
7174
6765
  this._signinDoneResolve();
7175
6766
  }
7176
- };
7177
- UserFacade.prototype._newSigninPromiseIfNeeded = function () {
6767
+ }
6768
+ _newSigninPromiseIfNeeded() {
7178
6769
  if (!this.signin_requested) {
7179
6770
  return;
7180
6771
  }
7181
6772
  if (this.signinDonePromise && !this.signinDonePromise.done) {
7182
6773
  return;
7183
6774
  }
7184
- var _a = flat_promise(), promise = _a.promise, resolve = _a.resolve, _ = _a.reject;
6775
+ const { promise, resolve, reject: _ } = flat_promise();
7185
6776
  promise.done = false;
7186
- var setDone = function () {
6777
+ const setDone = () => {
7187
6778
  promise.done = true;
7188
6779
  };
7189
- promise.then(setDone)["catch"](setDone);
6780
+ promise.then(setDone).catch(setDone);
7190
6781
  this.signinDonePromise = promise;
7191
6782
  this._signinDoneResolve = resolve;
7192
- };
7193
- return UserFacade;
7194
- }(dispatcher));
7195
- /* harmony default export */ var user = (user_UserFacade);
6783
+ }
6784
+ }
7196
6785
 
7197
6786
  // CONCATENATED MODULE: ./src/core/pusher.ts
7198
6787
 
@@ -7208,19 +6797,29 @@ var user_UserFacade = (function (_super) {
7208
6797
 
7209
6798
 
7210
6799
 
7211
- var pusher_Pusher = (function () {
7212
- function Pusher(app_key, options) {
7213
- var _this = this;
6800
+ class pusher_Pusher {
6801
+ static ready() {
6802
+ pusher_Pusher.isReady = true;
6803
+ for (var i = 0, l = pusher_Pusher.instances.length; i < l; i++) {
6804
+ pusher_Pusher.instances[i].connect();
6805
+ }
6806
+ }
6807
+ static getClientFeatures() {
6808
+ return keys(filterObject({ ws: runtime.Transports.ws }, function (t) {
6809
+ return t.isSupported({});
6810
+ }));
6811
+ }
6812
+ constructor(app_key, options) {
7214
6813
  checkAppKey(app_key);
7215
6814
  validateOptions(options);
7216
6815
  this.key = app_key;
7217
6816
  this.config = getConfig(options, this);
7218
6817
  this.channels = factory.createChannels();
7219
- this.global_emitter = new dispatcher();
6818
+ this.global_emitter = new dispatcher_Dispatcher();
7220
6819
  this.sessionID = runtime.randomInt(1000000000);
7221
- this.timeline = new timeline_timeline(this.key, this.sessionID, {
6820
+ this.timeline = new timeline_Timeline(this.key, this.sessionID, {
7222
6821
  cluster: this.config.cluster,
7223
- features: Pusher.getClientFeatures(),
6822
+ features: pusher_Pusher.getClientFeatures(),
7224
6823
  params: this.config.timelineParams || {},
7225
6824
  limit: 50,
7226
6825
  level: timeline_level.INFO,
@@ -7232,8 +6831,8 @@ var pusher_Pusher = (function () {
7232
6831
  path: '/timeline/v2/' + runtime.TimelineTransport.name
7233
6832
  });
7234
6833
  }
7235
- var getStrategy = function (options) {
7236
- return runtime.getDefaultStrategy(_this.config, options, strategy_builder_defineTransport);
6834
+ var getStrategy = (options) => {
6835
+ return runtime.getDefaultStrategy(this.config, options, strategy_builder_defineTransport);
7237
6836
  };
7238
6837
  this.connection = factory.createConnectionManager(this.key, {
7239
6838
  getStrategy: getStrategy,
@@ -7243,106 +6842,95 @@ var pusher_Pusher = (function () {
7243
6842
  unavailableTimeout: this.config.unavailableTimeout,
7244
6843
  useTLS: Boolean(this.config.useTLS)
7245
6844
  });
7246
- this.connection.bind('connected', function () {
7247
- _this.subscribeAll();
7248
- if (_this.timelineSender) {
7249
- _this.timelineSender.send(_this.connection.isUsingTLS());
6845
+ this.connection.bind('connected', () => {
6846
+ this.subscribeAll();
6847
+ if (this.timelineSender) {
6848
+ this.timelineSender.send(this.connection.isUsingTLS());
7250
6849
  }
7251
6850
  });
7252
- this.connection.bind('message', function (event) {
6851
+ this.connection.bind('message', event => {
7253
6852
  var eventName = event.event;
7254
6853
  var internal = eventName.indexOf('pusher_internal:') === 0;
7255
6854
  if (event.channel) {
7256
- var channel = _this.channel(event.channel);
6855
+ var channel = this.channel(event.channel);
7257
6856
  if (channel) {
7258
6857
  channel.handleEvent(event);
7259
6858
  }
7260
6859
  }
7261
6860
  if (!internal) {
7262
- _this.global_emitter.emit(event.event, event.data);
6861
+ this.global_emitter.emit(event.event, event.data);
7263
6862
  }
7264
6863
  });
7265
- this.connection.bind('connecting', function () {
7266
- _this.channels.disconnect();
6864
+ this.connection.bind('connecting', () => {
6865
+ this.channels.disconnect();
7267
6866
  });
7268
- this.connection.bind('disconnected', function () {
7269
- _this.channels.disconnect();
6867
+ this.connection.bind('disconnected', () => {
6868
+ this.channels.disconnect();
7270
6869
  });
7271
- this.connection.bind('error', function (err) {
6870
+ this.connection.bind('error', err => {
7272
6871
  logger.warn(err);
7273
6872
  });
7274
- Pusher.instances.push(this);
7275
- this.timeline.info({ instances: Pusher.instances.length });
7276
- this.user = new user(this);
7277
- if (Pusher.isReady) {
6873
+ pusher_Pusher.instances.push(this);
6874
+ this.timeline.info({ instances: pusher_Pusher.instances.length });
6875
+ this.user = new user_UserFacade(this);
6876
+ if (pusher_Pusher.isReady) {
7278
6877
  this.connect();
7279
6878
  }
7280
6879
  }
7281
- Pusher.ready = function () {
7282
- Pusher.isReady = true;
7283
- for (var i = 0, l = Pusher.instances.length; i < l; i++) {
7284
- Pusher.instances[i].connect();
7285
- }
7286
- };
7287
- Pusher.getClientFeatures = function () {
7288
- return keys(filterObject({ ws: runtime.Transports.ws }, function (t) {
7289
- return t.isSupported({});
7290
- }));
7291
- };
7292
- Pusher.prototype.channel = function (name) {
6880
+ channel(name) {
7293
6881
  return this.channels.find(name);
7294
- };
7295
- Pusher.prototype.allChannels = function () {
6882
+ }
6883
+ allChannels() {
7296
6884
  return this.channels.all();
7297
- };
7298
- Pusher.prototype.connect = function () {
6885
+ }
6886
+ connect() {
7299
6887
  this.connection.connect();
7300
6888
  if (this.timelineSender) {
7301
6889
  if (!this.timelineSenderTimer) {
7302
6890
  var usingTLS = this.connection.isUsingTLS();
7303
6891
  var timelineSender = this.timelineSender;
7304
- this.timelineSenderTimer = new PeriodicTimer(60000, function () {
6892
+ this.timelineSenderTimer = new timers_PeriodicTimer(60000, function () {
7305
6893
  timelineSender.send(usingTLS);
7306
6894
  });
7307
6895
  }
7308
6896
  }
7309
- };
7310
- Pusher.prototype.disconnect = function () {
6897
+ }
6898
+ disconnect() {
7311
6899
  this.connection.disconnect();
7312
6900
  if (this.timelineSenderTimer) {
7313
6901
  this.timelineSenderTimer.ensureAborted();
7314
6902
  this.timelineSenderTimer = null;
7315
6903
  }
7316
- };
7317
- Pusher.prototype.bind = function (event_name, callback, context) {
6904
+ }
6905
+ bind(event_name, callback, context) {
7318
6906
  this.global_emitter.bind(event_name, callback, context);
7319
6907
  return this;
7320
- };
7321
- Pusher.prototype.unbind = function (event_name, callback, context) {
6908
+ }
6909
+ unbind(event_name, callback, context) {
7322
6910
  this.global_emitter.unbind(event_name, callback, context);
7323
6911
  return this;
7324
- };
7325
- Pusher.prototype.bind_global = function (callback) {
6912
+ }
6913
+ bind_global(callback) {
7326
6914
  this.global_emitter.bind_global(callback);
7327
6915
  return this;
7328
- };
7329
- Pusher.prototype.unbind_global = function (callback) {
6916
+ }
6917
+ unbind_global(callback) {
7330
6918
  this.global_emitter.unbind_global(callback);
7331
6919
  return this;
7332
- };
7333
- Pusher.prototype.unbind_all = function (callback) {
6920
+ }
6921
+ unbind_all(callback) {
7334
6922
  this.global_emitter.unbind_all();
7335
6923
  return this;
7336
- };
7337
- Pusher.prototype.subscribeAll = function () {
6924
+ }
6925
+ subscribeAll() {
7338
6926
  var channelName;
7339
6927
  for (channelName in this.channels.channels) {
7340
6928
  if (this.channels.channels.hasOwnProperty(channelName)) {
7341
6929
  this.subscribe(channelName);
7342
6930
  }
7343
6931
  }
7344
- };
7345
- Pusher.prototype.subscribe = function (channel_name) {
6932
+ }
6933
+ subscribe(channel_name) {
7346
6934
  var channel = this.channels.add(channel_name, this);
7347
6935
  if (channel.subscriptionPending && channel.subscriptionCancelled) {
7348
6936
  channel.reinstateSubscription();
@@ -7352,8 +6940,8 @@ var pusher_Pusher = (function () {
7352
6940
  channel.subscribe();
7353
6941
  }
7354
6942
  return channel;
7355
- };
7356
- Pusher.prototype.unsubscribe = function (channel_name) {
6943
+ }
6944
+ unsubscribe(channel_name) {
7357
6945
  var channel = this.channels.find(channel_name);
7358
6946
  if (channel && channel.subscriptionPending) {
7359
6947
  channel.cancelSubscription();
@@ -7364,25 +6952,24 @@ var pusher_Pusher = (function () {
7364
6952
  channel.unsubscribe();
7365
6953
  }
7366
6954
  }
7367
- };
7368
- Pusher.prototype.send_event = function (event_name, data, channel) {
6955
+ }
6956
+ send_event(event_name, data, channel) {
7369
6957
  return this.connection.send_event(event_name, data, channel);
7370
- };
7371
- Pusher.prototype.shouldUseTLS = function () {
6958
+ }
6959
+ shouldUseTLS() {
7372
6960
  return this.config.useTLS;
7373
- };
7374
- Pusher.prototype.signin = function () {
6961
+ }
6962
+ signin() {
7375
6963
  this.user.signin();
7376
- };
7377
- Pusher.instances = [];
7378
- Pusher.isReady = false;
7379
- Pusher.logToConsole = false;
7380
- Pusher.Runtime = runtime;
7381
- Pusher.ScriptReceivers = runtime.ScriptReceivers;
7382
- Pusher.DependenciesReceivers = runtime.DependenciesReceivers;
7383
- Pusher.auth_callbacks = runtime.auth_callbacks;
7384
- return Pusher;
7385
- }());
6964
+ }
6965
+ }
6966
+ pusher_Pusher.instances = [];
6967
+ pusher_Pusher.isReady = false;
6968
+ pusher_Pusher.logToConsole = false;
6969
+ pusher_Pusher.Runtime = runtime;
6970
+ pusher_Pusher.ScriptReceivers = runtime.ScriptReceivers;
6971
+ pusher_Pusher.DependenciesReceivers = runtime.DependenciesReceivers;
6972
+ pusher_Pusher.auth_callbacks = runtime.auth_callbacks;
7386
6973
  /* harmony default export */ var core_pusher = (pusher_Pusher);
7387
6974
  function checkAppKey(key) {
7388
6975
  if (key === null || key === undefined) {
@@ -7395,36 +6982,18 @@ runtime.setup(pusher_Pusher);
7395
6982
  var nacl_fast = __webpack_require__(2);
7396
6983
 
7397
6984
  // CONCATENATED MODULE: ./src/core/pusher-with-encryption.ts
7398
- var pusher_with_encryption_extends = (undefined && undefined.__extends) || (function () {
7399
- var extendStatics = function (d, b) {
7400
- extendStatics = Object.setPrototypeOf ||
7401
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
7402
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7403
- return extendStatics(d, b);
7404
- };
7405
- return function (d, b) {
7406
- extendStatics(d, b);
7407
- function __() { this.constructor = d; }
7408
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7409
- };
7410
- })();
7411
6985
 
7412
6986
 
7413
6987
 
7414
- var pusher_with_encryption_PusherWithEncryption = (function (_super) {
7415
- pusher_with_encryption_extends(PusherWithEncryption, _super);
7416
- function PusherWithEncryption(app_key, options) {
7417
- var _this = this;
7418
- core_pusher.logToConsole = PusherWithEncryption.logToConsole;
7419
- core_pusher.log = PusherWithEncryption.log;
6988
+ class pusher_with_encryption_PusherWithEncryption extends core_pusher {
6989
+ constructor(app_key, options) {
6990
+ core_pusher.logToConsole = pusher_with_encryption_PusherWithEncryption.logToConsole;
6991
+ core_pusher.log = pusher_with_encryption_PusherWithEncryption.log;
7420
6992
  validateOptions(options);
7421
6993
  options.nacl = nacl_fast;
7422
- _this = _super.call(this, app_key, options) || this;
7423
- return _this;
6994
+ super(app_key, options);
7424
6995
  }
7425
- return PusherWithEncryption;
7426
- }(core_pusher));
7427
- /* harmony default export */ var pusher_with_encryption = __webpack_exports__["default"] = (pusher_with_encryption_PusherWithEncryption);
6996
+ }
7428
6997
 
7429
6998
 
7430
6999
  /***/ })