@jcbuisson/express-x-client 1.5.5 → 1.5.6

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.mjs +3 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jcbuisson/express-x-client",
3
- "version": "1.5.5",
3
+ "version": "1.5.6",
4
4
  "type": "module",
5
5
  "description": "Client library for ExpressX framework",
6
6
  "main": "src/index.mjs",
package/src/index.mjs CHANGED
@@ -19,12 +19,12 @@ export default function expressXClient(socket, options={}) {
19
19
  }
20
20
 
21
21
  function _getCnxId() {
22
- if (typeof window !== 'undefined') return sessionStorage.getItem('expressx-cnx-id')
22
+ if (typeof sessionStorage !== 'undefined') return sessionStorage.getItem('expressx-cnx-id')
23
23
  return nodeCnxId
24
24
  }
25
25
 
26
26
  function _setCnxId(id) {
27
- if (typeof window !== 'undefined') {
27
+ if (typeof sessionStorage !== 'undefined') {
28
28
  sessionStorage.setItem('expressx-cnx-id', id)
29
29
  } else {
30
30
  nodeCnxId = id
@@ -79,7 +79,7 @@ export default function expressXClient(socket, options={}) {
79
79
  })
80
80
 
81
81
  // disconnection due to a page reload
82
- if (typeof window !== 'undefined') {
82
+ if (typeof window !== 'undefined' && 'addEventListener' in window) {
83
83
  window.addEventListener('unload', () => {
84
84
  const id = _getCnxId()
85
85
  if (id > 0) {