mqtt 5.5.5 → 5.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.
- package/build/lib/connect/tcp.js.map +1 -1
- package/build/lib/connect/ws.js +1 -3
- package/build/lib/connect/ws.js.map +1 -1
- package/build/lib/handlers/index.js +1 -1
- package/build/lib/handlers/index.js.map +1 -1
- package/build/lib/is-browser.js +12 -1
- package/build/lib/is-browser.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/dist/mqtt.esm.js +3 -3
- package/dist/mqtt.js +15 -6
- package/dist/mqtt.min.js +3 -3
- package/package.json +1 -1
- package/src/lib/connect/tcp.ts +0 -1
- package/src/lib/connect/ws.ts +5 -3
- package/src/lib/handlers/index.ts +1 -1
- package/src/lib/is-browser.ts +25 -2
package/package.json
CHANGED
package/src/lib/connect/tcp.ts
CHANGED
package/src/lib/connect/ws.ts
CHANGED
|
@@ -28,9 +28,7 @@ function buildUrl(opts: IClientOptions, client: MqttClient) {
|
|
|
28
28
|
|
|
29
29
|
function setDefaultOpts(opts: IClientOptions) {
|
|
30
30
|
const options = opts
|
|
31
|
-
|
|
32
|
-
options.hostname = 'localhost'
|
|
33
|
-
}
|
|
31
|
+
|
|
34
32
|
if (!opts.port) {
|
|
35
33
|
if (opts.protocol === 'wss') {
|
|
36
34
|
options.port = 443
|
|
@@ -38,6 +36,7 @@ function setDefaultOpts(opts: IClientOptions) {
|
|
|
38
36
|
options.port = 80
|
|
39
37
|
}
|
|
40
38
|
}
|
|
39
|
+
|
|
41
40
|
if (!opts.path) {
|
|
42
41
|
options.path = '/'
|
|
43
42
|
}
|
|
@@ -141,6 +140,9 @@ function createBrowserWebSocket(client: MqttClient, opts: IClientOptions) {
|
|
|
141
140
|
const streamBuilder: StreamBuilder = (client, opts) => {
|
|
142
141
|
debug('streamBuilder')
|
|
143
142
|
const options = setDefaultOpts(opts)
|
|
143
|
+
|
|
144
|
+
options.hostname = options.hostname || options.host || 'localhost'
|
|
145
|
+
|
|
144
146
|
const url = buildUrl(options, client)
|
|
145
147
|
const socket = createWebSocket(client, url, options)
|
|
146
148
|
const webSocketStream = Ws.createWebSocketStream(
|
|
@@ -26,7 +26,7 @@ const handle: PacketHandler = (client, packet, done) => {
|
|
|
26
26
|
client.pingResp = Date.now()
|
|
27
27
|
|
|
28
28
|
// do not shift on pingresp otherwise we would skip the pingreq sending
|
|
29
|
-
if (packet.cmd
|
|
29
|
+
if (!['pingresp', 'publish'].includes(packet.cmd)) {
|
|
30
30
|
client['_shiftPingInterval']()
|
|
31
31
|
}
|
|
32
32
|
|
package/src/lib/is-browser.ts
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
|
-
const isStandardBrowserEnv = () =>
|
|
2
|
-
|
|
1
|
+
const isStandardBrowserEnv = () => {
|
|
2
|
+
// window is only defined when it is a browser
|
|
3
|
+
if (typeof window !== 'undefined') {
|
|
4
|
+
// Is the process an electron application
|
|
5
|
+
// check if we are in electron `renderer`
|
|
6
|
+
const electronRenderCheck =
|
|
7
|
+
navigator?.userAgent?.toLowerCase().indexOf(' electron/') > -1
|
|
8
|
+
if (electronRenderCheck && process?.versions) {
|
|
9
|
+
const electronMainCheck = Object.prototype.hasOwnProperty.call(
|
|
10
|
+
process.versions,
|
|
11
|
+
'electron',
|
|
12
|
+
)
|
|
13
|
+
// Both electron checks are only true if the following webPreferences are set in the main electron BrowserWindow()
|
|
14
|
+
// webPreferences: {
|
|
15
|
+
// sandbox: false,
|
|
16
|
+
// nodeIntegration: true
|
|
17
|
+
// contextIsolation: false
|
|
18
|
+
// }
|
|
19
|
+
return !electronMainCheck
|
|
20
|
+
}
|
|
21
|
+
return typeof window.document !== 'undefined'
|
|
22
|
+
}
|
|
23
|
+
// return false if nothing is detected
|
|
24
|
+
return false
|
|
25
|
+
}
|
|
3
26
|
|
|
4
27
|
const isWebWorkerEnv = () =>
|
|
5
28
|
Boolean(
|