mqtt 5.7.3 → 5.8.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/README.md +8 -1
- package/build/lib/KeepaliveManager.d.ts +2 -1
- package/build/lib/KeepaliveManager.js +6 -1
- package/build/lib/KeepaliveManager.js.map +1 -1
- package/build/lib/client.d.ts +3 -2
- package/build/lib/client.js +12 -2
- package/build/lib/client.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 +5 -1
- package/build/lib/is-browser.js.map +1 -1
- package/build/mqtt.d.ts +1 -0
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/dist/mqtt.esm.js +5 -5
- package/dist/mqtt.js +15 -6
- package/dist/mqtt.min.js +5 -5
- package/package.json +1 -1
- package/src/lib/KeepaliveManager.ts +7 -2
- package/src/lib/client.ts +17 -3
- package/src/lib/handlers/index.ts +1 -1
- package/src/lib/is-browser.ts +7 -1
- package/src/mqtt.ts +1 -0
package/package.json
CHANGED
|
@@ -33,9 +33,14 @@ export default class KeepaliveManager {
|
|
|
33
33
|
return this._keepalive
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
constructor(client: MqttClient, variant: TimerVariant) {
|
|
36
|
+
constructor(client: MqttClient, variant: TimerVariant | Timer) {
|
|
37
37
|
this.client = client
|
|
38
|
-
this.timer =
|
|
38
|
+
this.timer =
|
|
39
|
+
typeof variant === 'object' &&
|
|
40
|
+
'set' in variant &&
|
|
41
|
+
'clear' in variant
|
|
42
|
+
? variant
|
|
43
|
+
: getTimer(variant)
|
|
39
44
|
this.setKeepalive(client.options.keepalive)
|
|
40
45
|
}
|
|
41
46
|
|
package/src/lib/client.ts
CHANGED
|
@@ -41,6 +41,7 @@ import TopicAliasSend from './topic-alias-send'
|
|
|
41
41
|
import { TypedEventEmitter } from './TypedEmitter'
|
|
42
42
|
import KeepaliveManager from './KeepaliveManager'
|
|
43
43
|
import isBrowser, { isWebWorker } from './is-browser'
|
|
44
|
+
import { Timer } from './get-timer'
|
|
44
45
|
|
|
45
46
|
const setImmediate =
|
|
46
47
|
globalThis.setImmediate ||
|
|
@@ -278,8 +279,9 @@ export interface IClientOptions extends ISecureClientOptions {
|
|
|
278
279
|
properties?: IConnectPacket['properties']
|
|
279
280
|
/**
|
|
280
281
|
* @description 'auto', set to 'native' or 'worker' if you're having issues with 'auto' detection
|
|
282
|
+
* or pass a custom timer object
|
|
281
283
|
*/
|
|
282
|
-
timerVariant?: TimerVariant
|
|
284
|
+
timerVariant?: TimerVariant | Timer
|
|
283
285
|
}
|
|
284
286
|
|
|
285
287
|
export interface IClientPublishOptions {
|
|
@@ -730,6 +732,13 @@ export default class MqttClient extends TypedEventEmitter<MqttClientEventCallbac
|
|
|
730
732
|
this.log('connect :: calling method to clear reconnect')
|
|
731
733
|
this._clearReconnect()
|
|
732
734
|
|
|
735
|
+
if (this.disconnected && !this.reconnecting) {
|
|
736
|
+
this.incomingStore = this.options.incomingStore || new Store()
|
|
737
|
+
this.outgoingStore = this.options.outgoingStore || new Store()
|
|
738
|
+
this.disconnecting = false
|
|
739
|
+
this.disconnected = false
|
|
740
|
+
}
|
|
741
|
+
|
|
733
742
|
this.log(
|
|
734
743
|
'connect :: using streamBuilder provided to client to create stream',
|
|
735
744
|
)
|
|
@@ -1457,6 +1466,11 @@ export default class MqttClient extends TypedEventEmitter<MqttClientEventCallbac
|
|
|
1457
1466
|
})
|
|
1458
1467
|
if (this._deferredReconnect) {
|
|
1459
1468
|
this._deferredReconnect()
|
|
1469
|
+
} else if (
|
|
1470
|
+
this.options.reconnectPeriod === 0 ||
|
|
1471
|
+
this.options.manualConnect
|
|
1472
|
+
) {
|
|
1473
|
+
this.disconnecting = false
|
|
1460
1474
|
}
|
|
1461
1475
|
}
|
|
1462
1476
|
|
|
@@ -2095,11 +2109,11 @@ export default class MqttClient extends TypedEventEmitter<MqttClientEventCallbac
|
|
|
2095
2109
|
/**
|
|
2096
2110
|
* Reschedule the ping interval
|
|
2097
2111
|
*/
|
|
2098
|
-
public reschedulePing() {
|
|
2112
|
+
public reschedulePing(force = false) {
|
|
2099
2113
|
if (
|
|
2100
2114
|
this.keepaliveManager &&
|
|
2101
2115
|
this.options.keepalive &&
|
|
2102
|
-
this.options.reschedulePings
|
|
2116
|
+
(force || this.options.reschedulePings)
|
|
2103
2117
|
) {
|
|
2104
2118
|
this._reschedulePing()
|
|
2105
2119
|
}
|
package/src/lib/is-browser.ts
CHANGED
|
@@ -25,6 +25,9 @@ const isStandardBrowserEnv = () => {
|
|
|
25
25
|
return false
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
const isTxikijsEnv = () =>
|
|
29
|
+
typeof navigator !== 'undefined' && navigator.userAgent === 'txiki.js'
|
|
30
|
+
|
|
28
31
|
const isWebWorkerEnv = () =>
|
|
29
32
|
Boolean(
|
|
30
33
|
// eslint-disable-next-line no-restricted-globals
|
|
@@ -37,7 +40,10 @@ const isReactNativeEnv = () =>
|
|
|
37
40
|
typeof navigator !== 'undefined' && navigator.product === 'ReactNative'
|
|
38
41
|
|
|
39
42
|
const isBrowser =
|
|
40
|
-
isStandardBrowserEnv() ||
|
|
43
|
+
isStandardBrowserEnv() ||
|
|
44
|
+
isWebWorkerEnv() ||
|
|
45
|
+
isReactNativeEnv() ||
|
|
46
|
+
isTxikijsEnv()
|
|
41
47
|
|
|
42
48
|
export const isWebWorker = isWebWorkerEnv()
|
|
43
49
|
|
package/src/mqtt.ts
CHANGED