@folklore/socket 0.4.18 → 0.4.20

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.
package/dist/cjs.js CHANGED
@@ -6,11 +6,11 @@ var createDebug = require('debug');
6
6
  var invariant = require('invariant');
7
7
  var isFunction = require('lodash/isFunction');
8
8
  var EventEmitter = require('wolfy87-eventemitter');
9
+ var isString = require('lodash/isString');
9
10
  var isArray = require('lodash/isArray');
10
11
  var React = require('react');
11
12
  var PropTypes = require('prop-types');
12
13
  var jsxRuntime = require('react/jsx-runtime');
13
- var isString = require('lodash/isString');
14
14
 
15
15
  const debug$3 = createDebug('folklore:socket:pubnub');
16
16
  class PubNubSocket extends EventEmitter {
@@ -336,7 +336,7 @@ class SocketIOSocket extends EventEmitter {
336
336
  }
337
337
 
338
338
  const debug$1 = createDebug('folklore:socket:pusher');
339
- class PusherSocker extends EventEmitter {
339
+ class PusherSocket extends EventEmitter {
340
340
  constructor(opts) {
341
341
  super();
342
342
  this.options = {
@@ -404,7 +404,7 @@ class PusherSocker extends EventEmitter {
404
404
  loadPusher.then(() => this.createPusher()).then(() => this.onReady());
405
405
  }
406
406
  loadPusher() {
407
- debug$1('Load PusherJs');
407
+ debug$1('Load Pusher');
408
408
  return import('pusher-js').then(_ref => {
409
409
  let {
410
410
  default: Pusher
@@ -416,6 +416,7 @@ class PusherSocker extends EventEmitter {
416
416
  if (this.destroyed) {
417
417
  return;
418
418
  }
419
+ debug$1('Create Pusher appKey: %s', this.options.appKey);
419
420
  const {
420
421
  Pusher
421
422
  } = this;
@@ -442,7 +443,7 @@ class PusherSocker extends EventEmitter {
442
443
  debug$1('Skipping start: Already starting.');
443
444
  return;
444
445
  }
445
- if (this.io === null) {
446
+ if (this.pusher === null) {
446
447
  debug$1('Socket.io not ready.');
447
448
  this.shouldStart = true;
448
449
  return;
@@ -506,7 +507,7 @@ class PusherSocker extends EventEmitter {
506
507
  var SocketAdapters = {
507
508
  PubNub: PubNubSocket,
508
509
  SocketIO: SocketIOSocket,
509
- Pusher: PusherSocker
510
+ Pusher: PusherSocket
510
511
  };
511
512
 
512
513
  const normalize = str => str.replace(/[^a-z0-9]+/gi, '').toLowerCase();
@@ -668,7 +669,7 @@ class Socket extends EventEmitter {
668
669
  channels,
669
670
  ...adapterOptions
670
671
  } = this.options;
671
- const SocketAdapter = Socket.getAdapter(adapterKey);
672
+ const SocketAdapter = isString(adapterKey) ? Socket.getAdapter(adapterKey) : adapterKey;
672
673
  this.adapter = new SocketAdapter(adapterOptions);
673
674
  const methods = ['start', 'stop', 'destroy', 'updateChannels', 'send'];
674
675
  methods.forEach(method => {
package/dist/es.js CHANGED
@@ -2,11 +2,11 @@ import createDebug from 'debug';
2
2
  import invariant from 'invariant';
3
3
  import isFunction from 'lodash/isFunction';
4
4
  import EventEmitter from 'wolfy87-eventemitter';
5
+ import isString from 'lodash/isString';
5
6
  import isArray from 'lodash/isArray';
6
7
  import React, { useMemo, useState, useRef, useCallback, useEffect, useContext } from 'react';
7
8
  import PropTypes from 'prop-types';
8
9
  import { jsx } from 'react/jsx-runtime';
9
- import isString from 'lodash/isString';
10
10
 
11
11
  const debug$3 = createDebug('folklore:socket:pubnub');
12
12
  class PubNubSocket extends EventEmitter {
@@ -332,7 +332,7 @@ class SocketIOSocket extends EventEmitter {
332
332
  }
333
333
 
334
334
  const debug$1 = createDebug('folklore:socket:pusher');
335
- class PusherSocker extends EventEmitter {
335
+ class PusherSocket extends EventEmitter {
336
336
  constructor(opts) {
337
337
  super();
338
338
  this.options = {
@@ -400,7 +400,7 @@ class PusherSocker extends EventEmitter {
400
400
  loadPusher.then(() => this.createPusher()).then(() => this.onReady());
401
401
  }
402
402
  loadPusher() {
403
- debug$1('Load PusherJs');
403
+ debug$1('Load Pusher');
404
404
  return import('pusher-js').then(_ref => {
405
405
  let {
406
406
  default: Pusher
@@ -412,6 +412,7 @@ class PusherSocker extends EventEmitter {
412
412
  if (this.destroyed) {
413
413
  return;
414
414
  }
415
+ debug$1('Create Pusher appKey: %s', this.options.appKey);
415
416
  const {
416
417
  Pusher
417
418
  } = this;
@@ -438,7 +439,7 @@ class PusherSocker extends EventEmitter {
438
439
  debug$1('Skipping start: Already starting.');
439
440
  return;
440
441
  }
441
- if (this.io === null) {
442
+ if (this.pusher === null) {
442
443
  debug$1('Socket.io not ready.');
443
444
  this.shouldStart = true;
444
445
  return;
@@ -502,7 +503,7 @@ class PusherSocker extends EventEmitter {
502
503
  var SocketAdapters = {
503
504
  PubNub: PubNubSocket,
504
505
  SocketIO: SocketIOSocket,
505
- Pusher: PusherSocker
506
+ Pusher: PusherSocket
506
507
  };
507
508
 
508
509
  const normalize = str => str.replace(/[^a-z0-9]+/gi, '').toLowerCase();
@@ -664,7 +665,7 @@ class Socket extends EventEmitter {
664
665
  channels,
665
666
  ...adapterOptions
666
667
  } = this.options;
667
- const SocketAdapter = Socket.getAdapter(adapterKey);
668
+ const SocketAdapter = isString(adapterKey) ? Socket.getAdapter(adapterKey) : adapterKey;
668
669
  this.adapter = new SocketAdapter(adapterOptions);
669
670
  const methods = ['start', 'stop', 'destroy', 'updateChannels', 'send'];
670
671
  methods.forEach(method => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@folklore/socket",
3
- "version": "0.4.18",
3
+ "version": "0.4.20",
4
4
  "description": "Socket utilities",
5
5
  "keywords": [
6
6
  "javascript",
@@ -56,5 +56,5 @@
56
56
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
57
57
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
58
58
  },
59
- "gitHead": "49ada31fdf59837a0cc47b0db69d9929515ae9aa"
59
+ "gitHead": "fdba71c923f438864575b8e7e7bac4178e8184f5"
60
60
  }