pusher-js 8.1.0 → 8.3.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.
Files changed (27) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/node/pusher.js +24 -18
  3. package/dist/node/pusher.js.map +1 -1
  4. package/dist/react-native/pusher.js +2 -2
  5. package/dist/react-native/pusher.js.map +1 -1
  6. package/dist/web/pusher-with-encryption.js +24 -18
  7. package/dist/web/pusher-with-encryption.js.map +1 -1
  8. package/dist/web/pusher-with-encryption.min.js +2 -2
  9. package/dist/web/pusher-with-encryption.min.js.map +1 -1
  10. package/dist/web/pusher.js +24 -18
  11. package/dist/web/pusher.js.map +1 -1
  12. package/dist/web/pusher.min.js +2 -2
  13. package/dist/web/pusher.min.js.map +1 -1
  14. package/dist/worker/pusher-with-encryption.worker.js +24 -18
  15. package/dist/worker/pusher-with-encryption.worker.js.map +1 -1
  16. package/dist/worker/pusher-with-encryption.worker.min.js +2 -2
  17. package/dist/worker/pusher-with-encryption.worker.min.js.map +1 -1
  18. package/dist/worker/pusher.worker.js +24 -18
  19. package/dist/worker/pusher.worker.js.map +1 -1
  20. package/dist/worker/pusher.worker.min.js +2 -2
  21. package/dist/worker/pusher.worker.min.js.map +1 -1
  22. package/package.json +1 -1
  23. package/spec/javascripts/unit/core/strategies/{cached_strategy_spec.js → websocket_prioritized_cached_strategy_spec.js} +56 -14
  24. package/src/core/strategies/{cached_strategy.ts → websocket_prioritized_cached_strategy.ts} +25 -16
  25. package/src/runtimes/isomorphic/default_strategy.ts +3 -4
  26. package/src/runtimes/web/default_strategy.ts +3 -4
  27. package/types/src/core/strategies/{cached_strategy.d.ts → websocket_prioritized_cached_strategy.d.ts} +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 8.3.0
4
+
5
+ - [CHANGED] Update cached re-connect strategy to prioritize WebSocket
6
+
7
+ ## 8.2.0
8
+
9
+ - [CHANGED] Remove WebSocket retry limit.
10
+
3
11
  ## 8.1.0
4
12
 
5
13
  - [CHANGED] Move @types dependencies to devDependencies
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Pusher JavaScript Library v8.1.0
2
+ * Pusher JavaScript Library v8.3.0
3
3
  * https://pusher.com/
4
4
  *
5
5
  * Copyright 2020, Pusher
@@ -7499,7 +7499,7 @@ function safeJSONStringify(source) {
7499
7499
 
7500
7500
  // CONCATENATED MODULE: ./src/core/defaults.ts
7501
7501
  var Defaults = {
7502
- VERSION: "8.1.0",
7502
+ VERSION: "8.3.0",
7503
7503
  PROTOCOL: 7,
7504
7504
  wsPort: 80,
7505
7505
  wssPort: 443,
@@ -9224,12 +9224,12 @@ function abortRunner(runner) {
9224
9224
  }
9225
9225
  }
9226
9226
 
9227
- // CONCATENATED MODULE: ./src/core/strategies/cached_strategy.ts
9227
+ // CONCATENATED MODULE: ./src/core/strategies/websocket_prioritized_cached_strategy.ts
9228
9228
 
9229
9229
 
9230
9230
 
9231
9231
 
9232
- class cached_strategy_CachedStrategy {
9232
+ class websocket_prioritized_cached_strategy_WebSocketPrioritizedCachedStrategy {
9233
9233
  constructor(strategy, transports, options) {
9234
9234
  this.strategy = strategy;
9235
9235
  this.transports = transports;
@@ -9243,19 +9243,25 @@ class cached_strategy_CachedStrategy {
9243
9243
  connect(minPriority, callback) {
9244
9244
  var usingTLS = this.usingTLS;
9245
9245
  var info = fetchTransportCache(usingTLS);
9246
+ var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;
9246
9247
  var strategies = [this.strategy];
9247
9248
  if (info && info.timestamp + this.ttl >= util.now()) {
9248
9249
  var transport = this.transports[info.transport];
9249
9250
  if (transport) {
9250
- this.timeline.info({
9251
- cached: true,
9252
- transport: info.transport,
9253
- latency: info.latency
9254
- });
9255
- strategies.push(new sequential_strategy_SequentialStrategy([transport], {
9256
- timeout: info.latency * 2 + 1000,
9257
- failFast: true
9258
- }));
9251
+ if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {
9252
+ this.timeline.info({
9253
+ cached: true,
9254
+ transport: info.transport,
9255
+ latency: info.latency
9256
+ });
9257
+ strategies.push(new sequential_strategy_SequentialStrategy([transport], {
9258
+ timeout: info.latency * 2 + 1000,
9259
+ failFast: true
9260
+ }));
9261
+ }
9262
+ else {
9263
+ cacheSkipCount++;
9264
+ }
9259
9265
  }
9260
9266
  }
9261
9267
  var startTimestamp = util.now();
@@ -9273,7 +9279,7 @@ class cached_strategy_CachedStrategy {
9273
9279
  }
9274
9280
  }
9275
9281
  else {
9276
- storeTransportCache(usingTLS, handshake.transport.name, util.now() - startTimestamp);
9282
+ storeTransportCache(usingTLS, handshake.transport.name, util.now() - startTimestamp, cacheSkipCount);
9277
9283
  callback(null, handshake);
9278
9284
  }
9279
9285
  });
@@ -9308,14 +9314,15 @@ function fetchTransportCache(usingTLS) {
9308
9314
  }
9309
9315
  return null;
9310
9316
  }
9311
- function storeTransportCache(usingTLS, transport, latency) {
9317
+ function storeTransportCache(usingTLS, transport, latency, cacheSkipCount) {
9312
9318
  var storage = node_runtime.getLocalStorage();
9313
9319
  if (storage) {
9314
9320
  try {
9315
9321
  storage[getTransportCacheKey(usingTLS)] = safeJSONStringify({
9316
9322
  timestamp: util.now(),
9317
9323
  transport: transport,
9318
- latency: latency
9324
+ latency: latency,
9325
+ cacheSkipCount: cacheSkipCount
9319
9326
  });
9320
9327
  }
9321
9328
  catch (e) {
@@ -9442,7 +9449,6 @@ var getDefaultStrategy = function (config, baseOptions, defineTransport) {
9442
9449
  timeoutLimit: 60000
9443
9450
  };
9444
9451
  var ws_manager = new transport_manager_TransportManager({
9445
- lives: 2,
9446
9452
  minPingDelay: 10000,
9447
9453
  maxPingDelay: config.activityTimeout
9448
9454
  });
@@ -9479,7 +9485,7 @@ var getDefaultStrategy = function (config, baseOptions, defineTransport) {
9479
9485
  new delayed_strategy_DelayedStrategy(http_loop, { delay: 5000 })
9480
9486
  ]);
9481
9487
  }
9482
- return new cached_strategy_CachedStrategy(new FirstConnectedStrategy(new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)), definedTransports, {
9488
+ return new websocket_prioritized_cached_strategy_WebSocketPrioritizedCachedStrategy(new FirstConnectedStrategy(new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)), definedTransports, {
9483
9489
  ttl: 1800000,
9484
9490
  timeline: baseOptions.timeline,
9485
9491
  useTLS: baseOptions.useTLS