mqtt 5.3.6 → 5.4.0
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 +1 -1
- package/build/lib/PingTimer.d.ts +0 -2
- package/build/lib/PingTimer.js +5 -30
- package/build/lib/PingTimer.js.map +1 -1
- package/build/lib/client.js +9 -0
- package/build/lib/client.js.map +1 -1
- package/build/lib/timers.d.ts +6 -0
- package/build/lib/timers.js +35 -0
- package/build/lib/timers.js.map +1 -0
- package/build/mqtt.d.ts +2 -1
- package/build/mqtt.js +3 -1
- package/build/mqtt.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/dist/mqtt.esm.js +5 -5
- package/dist/mqtt.js +69 -37
- package/dist/mqtt.min.js +5 -5
- package/package.json +3 -3
- package/src/lib/PingTimer.ts +3 -14
- package/src/lib/client.ts +13 -0
- package/src/lib/timers.ts +15 -0
- package/src/mqtt.ts +2 -0
package/dist/mqtt.js
CHANGED
|
@@ -17247,6 +17247,27 @@ var mqtt = (() => {
|
|
|
17247
17247
|
}
|
|
17248
17248
|
});
|
|
17249
17249
|
|
|
17250
|
+
// build/lib/is-browser.js
|
|
17251
|
+
var require_is_browser = __commonJS({
|
|
17252
|
+
"build/lib/is-browser.js"(exports5) {
|
|
17253
|
+
"use strict";
|
|
17254
|
+
init_buffer2();
|
|
17255
|
+
init_process2();
|
|
17256
|
+
init_navigator();
|
|
17257
|
+
Object.defineProperty(exports5, "__esModule", { value: true });
|
|
17258
|
+
exports5.isWebWorker = void 0;
|
|
17259
|
+
var isStandardBrowserEnv = () => typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
17260
|
+
var isWebWorkerEnv = () => {
|
|
17261
|
+
var _a, _b;
|
|
17262
|
+
return Boolean(typeof self === "object" && ((_b = (_a = self === null || self === void 0 ? void 0 : self.constructor) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.includes("WorkerGlobalScope")));
|
|
17263
|
+
};
|
|
17264
|
+
var isReactNativeEnv = () => typeof navigator !== "undefined" && navigator.product === "ReactNative";
|
|
17265
|
+
var isBrowser = isStandardBrowserEnv() || isWebWorkerEnv() || isReactNativeEnv();
|
|
17266
|
+
exports5.isWebWorker = isWebWorkerEnv();
|
|
17267
|
+
exports5.default = isBrowser;
|
|
17268
|
+
}
|
|
17269
|
+
});
|
|
17270
|
+
|
|
17250
17271
|
// node_modules/fast-unique-numbers/build/es5/bundle.js
|
|
17251
17272
|
var require_bundle = __commonJS({
|
|
17252
17273
|
"node_modules/fast-unique-numbers/build/es5/bundle.js"(exports5, module) {
|
|
@@ -17408,7 +17429,8 @@ var mqtt = (() => {
|
|
|
17408
17429
|
}
|
|
17409
17430
|
});
|
|
17410
17431
|
};
|
|
17411
|
-
var setInterval2 = function setInterval3(func
|
|
17432
|
+
var setInterval2 = function setInterval3(func) {
|
|
17433
|
+
var delay = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
|
|
17412
17434
|
var timerId = fastUniqueNumbers.generateUniqueNumber(scheduledIntervalFunctions);
|
|
17413
17435
|
scheduledIntervalFunctions.set(timerId, function() {
|
|
17414
17436
|
func();
|
|
@@ -17437,7 +17459,8 @@ var mqtt = (() => {
|
|
|
17437
17459
|
});
|
|
17438
17460
|
return timerId;
|
|
17439
17461
|
};
|
|
17440
|
-
var setTimeout2 = function setTimeout3(func
|
|
17462
|
+
var setTimeout2 = function setTimeout3(func) {
|
|
17463
|
+
var delay = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
|
|
17441
17464
|
var timerId = fastUniqueNumbers.generateUniqueNumber(scheduledTimeoutFunctions);
|
|
17442
17465
|
scheduledTimeoutFunctions.set(timerId, func);
|
|
17443
17466
|
worker.postMessage({
|
|
@@ -17491,7 +17514,7 @@ var mqtt = (() => {
|
|
|
17491
17514
|
return broker;
|
|
17492
17515
|
};
|
|
17493
17516
|
};
|
|
17494
|
-
var worker = `(()=>{var e={
|
|
17517
|
+
var worker = `(()=>{var e={472:(e,t,r)=>{var o,i;void 0===(i="function"==typeof(o=function(){"use strict";var e=new Map,t=new Map,r=function(t){var r=e.get(t);if(void 0===r)throw new Error('There is no interval scheduled with the given id "'.concat(t,'".'));clearTimeout(r),e.delete(t)},o=function(e){var r=t.get(e);if(void 0===r)throw new Error('There is no timeout scheduled with the given id "'.concat(e,'".'));clearTimeout(r),t.delete(e)},i=function(e,t){var r,o=performance.now();return{expected:o+(r=e-Math.max(0,o-t)),remainingDelay:r}},n=function e(t,r,o,i){var n=performance.now();n>o?postMessage({id:null,method:"call",params:{timerId:r,timerType:i}}):t.set(r,setTimeout(e,o-n,t,r,o,i))},a=function(t,r,o){var a=i(t,o),s=a.expected,d=a.remainingDelay;e.set(r,setTimeout(n,d,e,r,s,"interval"))},s=function(e,r,o){var a=i(e,o),s=a.expected,d=a.remainingDelay;t.set(r,setTimeout(n,d,t,r,s,"timeout"))};addEventListener("message",(function(e){var t=e.data;try{if("clear"===t.method){var i=t.id,n=t.params,d=n.timerId,c=n.timerType;if("interval"===c)r(d),postMessage({error:null,id:i});else{if("timeout"!==c)throw new Error('The given type "'.concat(c,'" is not supported'));o(d),postMessage({error:null,id:i})}}else{if("set"!==t.method)throw new Error('The given method "'.concat(t.method,'" is not supported'));var u=t.params,l=u.delay,p=u.now,m=u.timerId,v=u.timerType;if("interval"===v)a(l,m,p);else{if("timeout"!==v)throw new Error('The given type "'.concat(v,'" is not supported'));s(l,m,p)}}}catch(e){postMessage({error:{message:e.message},id:t.id,result:null})}}))})?o.call(t,r,t,e):o)||(e.exports=i)}},t={};function r(o){var i=t[o];if(void 0!==i)return i.exports;var n=t[o]={exports:{}};return e[o](n,n.exports,r),n.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";r(472)})()})();`;
|
|
17495
17518
|
var loadOrReturnBroker = createLoadOrReturnBroker(workerTimersBroker.load, worker);
|
|
17496
17519
|
var clearInterval2 = function clearInterval3(timerId) {
|
|
17497
17520
|
return loadOrReturnBroker().clearInterval(timerId);
|
|
@@ -17499,11 +17522,13 @@ var mqtt = (() => {
|
|
|
17499
17522
|
var clearTimeout2 = function clearTimeout3(timerId) {
|
|
17500
17523
|
return loadOrReturnBroker().clearTimeout(timerId);
|
|
17501
17524
|
};
|
|
17502
|
-
var setInterval2 = function setInterval3(
|
|
17503
|
-
|
|
17525
|
+
var setInterval2 = function setInterval3() {
|
|
17526
|
+
var _loadOrReturnBroker;
|
|
17527
|
+
return (_loadOrReturnBroker = loadOrReturnBroker()).setInterval.apply(_loadOrReturnBroker, arguments);
|
|
17504
17528
|
};
|
|
17505
|
-
var setTimeout$1 = function setTimeout2(
|
|
17506
|
-
|
|
17529
|
+
var setTimeout$1 = function setTimeout2() {
|
|
17530
|
+
var _loadOrReturnBroker2;
|
|
17531
|
+
return (_loadOrReturnBroker2 = loadOrReturnBroker()).setTimeout.apply(_loadOrReturnBroker2, arguments);
|
|
17507
17532
|
};
|
|
17508
17533
|
exports6.clearInterval = clearInterval2;
|
|
17509
17534
|
exports6.clearTimeout = clearTimeout2;
|
|
@@ -17513,30 +17538,9 @@ var mqtt = (() => {
|
|
|
17513
17538
|
}
|
|
17514
17539
|
});
|
|
17515
17540
|
|
|
17516
|
-
// build/lib/
|
|
17517
|
-
var
|
|
17518
|
-
"build/lib/
|
|
17519
|
-
"use strict";
|
|
17520
|
-
init_buffer2();
|
|
17521
|
-
init_process2();
|
|
17522
|
-
init_navigator();
|
|
17523
|
-
Object.defineProperty(exports5, "__esModule", { value: true });
|
|
17524
|
-
exports5.isWebWorker = void 0;
|
|
17525
|
-
var isStandardBrowserEnv = () => typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
17526
|
-
var isWebWorkerEnv = () => {
|
|
17527
|
-
var _a, _b;
|
|
17528
|
-
return Boolean(typeof self === "object" && ((_b = (_a = self === null || self === void 0 ? void 0 : self.constructor) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.includes("WorkerGlobalScope")));
|
|
17529
|
-
};
|
|
17530
|
-
var isReactNativeEnv = () => typeof navigator !== "undefined" && navigator.product === "ReactNative";
|
|
17531
|
-
var isBrowser = isStandardBrowserEnv() || isWebWorkerEnv() || isReactNativeEnv();
|
|
17532
|
-
exports5.isWebWorker = isWebWorkerEnv();
|
|
17533
|
-
exports5.default = isBrowser;
|
|
17534
|
-
}
|
|
17535
|
-
});
|
|
17536
|
-
|
|
17537
|
-
// build/lib/PingTimer.js
|
|
17538
|
-
var require_PingTimer = __commonJS({
|
|
17539
|
-
"build/lib/PingTimer.js"(exports5) {
|
|
17541
|
+
// build/lib/timers.js
|
|
17542
|
+
var require_timers = __commonJS({
|
|
17543
|
+
"build/lib/timers.js"(exports5) {
|
|
17540
17544
|
"use strict";
|
|
17541
17545
|
init_buffer2();
|
|
17542
17546
|
init_process2();
|
|
@@ -17574,25 +17578,43 @@ var mqtt = (() => {
|
|
|
17574
17578
|
return result;
|
|
17575
17579
|
};
|
|
17576
17580
|
Object.defineProperty(exports5, "__esModule", { value: true });
|
|
17577
|
-
var worker_timers_1 = require_bundle3();
|
|
17578
17581
|
var is_browser_1 = __importStar(require_is_browser());
|
|
17582
|
+
var worker_timers_1 = require_bundle3();
|
|
17583
|
+
var timers = {
|
|
17584
|
+
set: is_browser_1.default && !is_browser_1.isWebWorker ? worker_timers_1.setTimeout : (func, time) => setTimeout(func, time),
|
|
17585
|
+
clear: is_browser_1.default && !is_browser_1.isWebWorker ? worker_timers_1.clearTimeout : (timer) => clearTimeout(timer)
|
|
17586
|
+
};
|
|
17587
|
+
exports5.default = timers;
|
|
17588
|
+
}
|
|
17589
|
+
});
|
|
17590
|
+
|
|
17591
|
+
// build/lib/PingTimer.js
|
|
17592
|
+
var require_PingTimer = __commonJS({
|
|
17593
|
+
"build/lib/PingTimer.js"(exports5) {
|
|
17594
|
+
"use strict";
|
|
17595
|
+
init_buffer2();
|
|
17596
|
+
init_process2();
|
|
17597
|
+
init_navigator();
|
|
17598
|
+
var __importDefault = exports5 && exports5.__importDefault || function(mod) {
|
|
17599
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
17600
|
+
};
|
|
17601
|
+
Object.defineProperty(exports5, "__esModule", { value: true });
|
|
17602
|
+
var timers_1 = __importDefault(require_timers());
|
|
17579
17603
|
var PingTimer = class {
|
|
17580
17604
|
constructor(keepalive, checkPing) {
|
|
17581
|
-
this._setTimeout = is_browser_1.default && !is_browser_1.isWebWorker ? worker_timers_1.setTimeout : (func, time) => setTimeout(func, time);
|
|
17582
|
-
this._clearTimeout = is_browser_1.default && !is_browser_1.isWebWorker ? worker_timers_1.clearTimeout : (timer) => clearTimeout(timer);
|
|
17583
17605
|
this.keepalive = keepalive * 1e3;
|
|
17584
17606
|
this.checkPing = checkPing;
|
|
17585
17607
|
this.reschedule();
|
|
17586
17608
|
}
|
|
17587
17609
|
clear() {
|
|
17588
17610
|
if (this.timer) {
|
|
17589
|
-
|
|
17611
|
+
timers_1.default.clear(this.timer);
|
|
17590
17612
|
this.timer = null;
|
|
17591
17613
|
}
|
|
17592
17614
|
}
|
|
17593
17615
|
reschedule() {
|
|
17594
17616
|
this.clear();
|
|
17595
|
-
this.timer =
|
|
17617
|
+
this.timer = timers_1.default.set(() => {
|
|
17596
17618
|
this.checkPing();
|
|
17597
17619
|
if (this.timer) {
|
|
17598
17620
|
this.reschedule();
|
|
@@ -17659,6 +17681,7 @@ var mqtt = (() => {
|
|
|
17659
17681
|
var shared_1 = require_shared();
|
|
17660
17682
|
var TypedEmitter_1 = require_TypedEmitter();
|
|
17661
17683
|
var PingTimer_1 = __importDefault(require_PingTimer());
|
|
17684
|
+
var is_browser_1 = __importStar(require_is_browser());
|
|
17662
17685
|
var setImmediate = globalThis.setImmediate || ((...args) => {
|
|
17663
17686
|
const callback = args.shift();
|
|
17664
17687
|
(0, shared_1.nextTick)(() => {
|
|
@@ -17692,6 +17715,12 @@ var mqtt = (() => {
|
|
|
17692
17715
|
}
|
|
17693
17716
|
this.log = this.options.log || (0, debug_1.default)("mqttjs:client");
|
|
17694
17717
|
this.noop = this._noop.bind(this);
|
|
17718
|
+
this.log("MqttClient :: version:", "5.4.0");
|
|
17719
|
+
if (is_browser_1.isWebWorker) {
|
|
17720
|
+
this.log("MqttClient :: environment", "webworker");
|
|
17721
|
+
} else {
|
|
17722
|
+
this.log("MqttClient :: environment", is_browser_1.default ? "browser" : "node");
|
|
17723
|
+
}
|
|
17695
17724
|
this.log("MqttClient :: options.protocol", options.protocol);
|
|
17696
17725
|
this.log("MqttClient :: options.protocolVersion", options.protocolVersion);
|
|
17697
17726
|
this.log("MqttClient :: options.username", options.username);
|
|
@@ -18591,6 +18620,7 @@ var mqtt = (() => {
|
|
|
18591
18620
|
this.pingResp = false;
|
|
18592
18621
|
this._sendPacket({ cmd: "pingreq" });
|
|
18593
18622
|
} else {
|
|
18623
|
+
this.emit("error", new Error("Keepalive timeout"));
|
|
18594
18624
|
this.log("_checkPing :: calling _cleanUp with force true");
|
|
18595
18625
|
this._cleanUp(true);
|
|
18596
18626
|
}
|
|
@@ -21458,7 +21488,7 @@ var mqtt = (() => {
|
|
|
21458
21488
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|
21459
21489
|
};
|
|
21460
21490
|
Object.defineProperty(exports5, "__esModule", { value: true });
|
|
21461
|
-
exports5.ReasonCodes = exports5.UniqueMessageIdProvider = exports5.DefaultMessageIdProvider = exports5.Store = exports5.MqttClient = exports5.connectAsync = exports5.connect = exports5.Client = void 0;
|
|
21491
|
+
exports5.ReasonCodes = exports5.PingTimer = exports5.UniqueMessageIdProvider = exports5.DefaultMessageIdProvider = exports5.Store = exports5.MqttClient = exports5.connectAsync = exports5.connect = exports5.Client = void 0;
|
|
21462
21492
|
var client_1 = __importDefault(require_client());
|
|
21463
21493
|
exports5.MqttClient = client_1.default;
|
|
21464
21494
|
var default_message_id_provider_1 = __importDefault(require_default_message_id_provider());
|
|
@@ -21472,6 +21502,8 @@ var mqtt = (() => {
|
|
|
21472
21502
|
Object.defineProperty(exports5, "connectAsync", { enumerable: true, get: function() {
|
|
21473
21503
|
return connect_1.connectAsync;
|
|
21474
21504
|
} });
|
|
21505
|
+
var PingTimer_1 = __importDefault(require_PingTimer());
|
|
21506
|
+
exports5.PingTimer = PingTimer_1.default;
|
|
21475
21507
|
exports5.Client = client_1.default;
|
|
21476
21508
|
__exportStar(require_client(), exports5);
|
|
21477
21509
|
__exportStar(require_shared(), exports5);
|