File tree Expand file tree Collapse file tree 3 files changed +15
-4
lines changed Expand file tree Collapse file tree 3 files changed +15
-4
lines changed Original file line number Diff line number Diff line change 2
2
3
3
const MqttClient = require ( '../client' )
4
4
const Store = require ( '../store' )
5
+ const IS_BROWSER = require ( '../is-browser' ) . IS_BROWSER
5
6
const url = require ( 'url' )
6
7
const xtend = require ( 'xtend' )
7
8
const debug = require ( 'debug' ) ( 'mqttjs' )
8
9
9
10
const protocols = { }
10
11
11
- // eslint-disable-next-line camelcase
12
- if ( ( typeof process !== 'undefined' && process . title !== 'browser' ) || typeof __webpack_require__ !== 'function' ) {
12
+ if ( ! IS_BROWSER ) {
13
13
protocols . mqtt = require ( './tcp' )
14
14
protocols . tcp = require ( './tcp' )
15
15
protocols . ssl = require ( './tls' )
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ const WS = require('ws')
5
5
const debug = require ( 'debug' ) ( 'mqttjs:ws' )
6
6
const duplexify = require ( 'duplexify' )
7
7
const Transform = require ( 'readable-stream' ) . Transform
8
+ const IS_BROWSER = require ( '../is-browser' ) . IS_BROWSER
8
9
9
10
const WSS_OPTIONS = [
10
11
'rejectUnauthorized' ,
@@ -14,8 +15,7 @@ const WSS_OPTIONS = [
14
15
'pfx' ,
15
16
'passphrase'
16
17
]
17
- // eslint-disable-next-line camelcase
18
- const IS_BROWSER = ( typeof process !== 'undefined' && process . title === 'browser' ) || typeof __webpack_require__ === 'function'
18
+
19
19
function buildUrl ( opts , client ) {
20
20
let url = opts . protocol + '://' + opts . hostname + ':' + opts . port + opts . path
21
21
if ( typeof ( opts . transformWsUrl ) === 'function' ) {
Original file line number Diff line number Diff line change
1
+ const legacyIsBrowser =
2
+ ( typeof process !== 'undefined' && process . title === 'browser' ) ||
3
+ // eslint-disable-next-line camelcase
4
+ typeof __webpack_require__ === 'function'
5
+
6
+ const isBrowser =
7
+ typeof window !== 'undefined' && typeof document !== 'undefined'
8
+
9
+ module . exports = {
10
+ IS_BROWSER : isBrowser || legacyIsBrowser
11
+ }
You can’t perform that action at this time.
0 commit comments