mqtt 5.3.0 → 5.3.1

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mqtt",
3
3
  "description": "A library for the MQTT protocol",
4
- "version": "5.3.0",
4
+ "version": "5.3.1",
5
5
  "contributors": [
6
6
  "Adam Rudd <adamvrr@gmail.com>",
7
7
  "Matteo Collina <matteo.collina@gmail.com> (https://github.com/mcollina)",
@@ -1,11 +1,18 @@
1
- const isBrowser =
2
- (typeof window !== 'undefined' && typeof window.document !== 'undefined') ||
3
- // eslint-disable-next-line no-restricted-globals
4
- (typeof self === 'object' &&
5
- // eslint-disable-next-line no-restricted-globals
6
- self.constructor &&
1
+ const isStandardBrowserEnv = () =>
2
+ typeof window !== 'undefined' && typeof window.document !== 'undefined'
3
+
4
+ const isWebWorkerEnv = () =>
5
+ Boolean(
7
6
  // eslint-disable-next-line no-restricted-globals
8
- self.constructor.name === 'DedicatedWorkerGlobalScope') || // is web worker
9
- (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') // while navigator.product is deprecated
7
+ typeof self === 'object' &&
8
+ // eslint-disable-next-line no-restricted-globals
9
+ self?.constructor?.name?.includes('WorkerGlobalScope'),
10
+ )
11
+
12
+ const isReactNativeEnv = () =>
13
+ typeof navigator !== 'undefined' && navigator.product === 'ReactNative'
14
+
15
+ const isBrowser =
16
+ isStandardBrowserEnv() || isWebWorkerEnv() || isReactNativeEnv()
10
17
 
11
18
  export default isBrowser
package/src/lib/shared.ts CHANGED
@@ -10,7 +10,8 @@ export type GenericCallback<T> = (error?: Error, result?: T) => void
10
10
  export type VoidCallback = () => void
11
11
 
12
12
  export type IStream = Duplex & {
13
- socket?: WebSocket
13
+ /** only set on browsers, it's a [WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) */
14
+ socket?: any
14
15
  }
15
16
 
16
17
  export type StreamBuilder = (