mqtt 5.12.1 → 5.13.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 +2 -0
- package/build/lib/client.d.ts +1 -0
- package/build/lib/client.js +44 -19
- package/build/lib/client.js.map +1 -1
- package/build/lib/shared.d.ts +5 -1
- package/build/lib/shared.js +10 -1
- package/build/lib/shared.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/dist/mqtt.esm.js +5 -5
- package/dist/mqtt.js +51 -20
- package/dist/mqtt.min.js +5 -5
- package/package.json +1 -1
- package/src/lib/client.ts +67 -20
- package/src/lib/shared.ts +14 -1
package/dist/mqtt.js
CHANGED
|
@@ -11812,7 +11812,7 @@ var mqtt = (() => {
|
|
|
11812
11812
|
// package-json:../../package.json
|
|
11813
11813
|
var require_package = __commonJS({
|
|
11814
11814
|
"package-json:../../package.json"(exports5, module) {
|
|
11815
|
-
module.exports = { version: "5.
|
|
11815
|
+
module.exports = { version: "5.13.1" };
|
|
11816
11816
|
}
|
|
11817
11817
|
});
|
|
11818
11818
|
|
|
@@ -11824,7 +11824,7 @@ var mqtt = (() => {
|
|
|
11824
11824
|
init_buffer2();
|
|
11825
11825
|
init_process2();
|
|
11826
11826
|
Object.defineProperty(exports5, "__esModule", { value: true });
|
|
11827
|
-
exports5.MQTTJS_VERSION = exports5.nextTick = exports5.ErrorWithReasonCode = void 0;
|
|
11827
|
+
exports5.MQTTJS_VERSION = exports5.nextTick = exports5.ErrorWithSubackPacket = exports5.ErrorWithReasonCode = void 0;
|
|
11828
11828
|
exports5.applyMixin = applyMixin;
|
|
11829
11829
|
var ErrorWithReasonCode = class _ErrorWithReasonCode extends Error {
|
|
11830
11830
|
constructor(message, code) {
|
|
@@ -11835,6 +11835,15 @@ var mqtt = (() => {
|
|
|
11835
11835
|
}
|
|
11836
11836
|
};
|
|
11837
11837
|
exports5.ErrorWithReasonCode = ErrorWithReasonCode;
|
|
11838
|
+
var ErrorWithSubackPacket = class _ErrorWithSubackPacket extends Error {
|
|
11839
|
+
constructor(message, packet) {
|
|
11840
|
+
super(message);
|
|
11841
|
+
this.packet = packet;
|
|
11842
|
+
Object.setPrototypeOf(this, _ErrorWithSubackPacket.prototype);
|
|
11843
|
+
Object.getPrototypeOf(this).name = "ErrorWithSubackPacket";
|
|
11844
|
+
}
|
|
11845
|
+
};
|
|
11846
|
+
exports5.ErrorWithSubackPacket = ErrorWithSubackPacket;
|
|
11838
11847
|
function applyMixin(target, mixin, includeConstructor = false) {
|
|
11839
11848
|
var _a;
|
|
11840
11849
|
const inheritanceChain = [mixin];
|
|
@@ -16990,6 +16999,7 @@ var mqtt = (() => {
|
|
|
16990
16999
|
connectTimeout: 30 * 1e3,
|
|
16991
17000
|
clean: true,
|
|
16992
17001
|
resubscribe: true,
|
|
17002
|
+
subscribeBatchSize: null,
|
|
16993
17003
|
writeCache: true,
|
|
16994
17004
|
timerVariant: "auto"
|
|
16995
17005
|
};
|
|
@@ -17377,15 +17387,10 @@ var mqtt = (() => {
|
|
|
17377
17387
|
callback(null, []);
|
|
17378
17388
|
return this;
|
|
17379
17389
|
}
|
|
17380
|
-
const
|
|
17381
|
-
const messageId = this._nextId();
|
|
17382
|
-
if (messageId === null) {
|
|
17383
|
-
this.log("No messageId left");
|
|
17384
|
-
return false;
|
|
17385
|
-
}
|
|
17390
|
+
const subscribeChunkedSubs = (chunkedSubs, messageId) => {
|
|
17386
17391
|
const packet = {
|
|
17387
17392
|
cmd: "subscribe",
|
|
17388
|
-
subscriptions:
|
|
17393
|
+
subscriptions: chunkedSubs,
|
|
17389
17394
|
messageId
|
|
17390
17395
|
};
|
|
17391
17396
|
if (properties) {
|
|
@@ -17394,7 +17399,7 @@ var mqtt = (() => {
|
|
|
17394
17399
|
if (this.options.resubscribe) {
|
|
17395
17400
|
this.log("subscribe :: resubscribe true");
|
|
17396
17401
|
const topics = [];
|
|
17397
|
-
|
|
17402
|
+
chunkedSubs.forEach((sub) => {
|
|
17398
17403
|
if (this.options.reconnectPeriod > 0) {
|
|
17399
17404
|
const topic = { qos: sub.qos };
|
|
17400
17405
|
if (version2 === 5) {
|
|
@@ -17409,20 +17414,46 @@ var mqtt = (() => {
|
|
|
17409
17414
|
});
|
|
17410
17415
|
this.messageIdToTopic[packet.messageId] = topics;
|
|
17411
17416
|
}
|
|
17412
|
-
|
|
17413
|
-
|
|
17414
|
-
|
|
17415
|
-
|
|
17416
|
-
|
|
17417
|
-
|
|
17418
|
-
|
|
17417
|
+
const promise = new Promise((resolve2, reject) => {
|
|
17418
|
+
this.outgoing[packet.messageId] = {
|
|
17419
|
+
volatile: true,
|
|
17420
|
+
cb(err, packet2) {
|
|
17421
|
+
if (!err) {
|
|
17422
|
+
const { granted } = packet2;
|
|
17423
|
+
for (let grantedI = 0; grantedI < granted.length; grantedI += 1) {
|
|
17424
|
+
chunkedSubs[grantedI].qos = granted[grantedI];
|
|
17425
|
+
}
|
|
17426
|
+
}
|
|
17427
|
+
if (!err) {
|
|
17428
|
+
resolve2(packet2);
|
|
17429
|
+
} else {
|
|
17430
|
+
reject(new shared_1.ErrorWithSubackPacket(err.message, packet2));
|
|
17419
17431
|
}
|
|
17420
17432
|
}
|
|
17421
|
-
|
|
17422
|
-
|
|
17423
|
-
};
|
|
17433
|
+
};
|
|
17434
|
+
});
|
|
17424
17435
|
this.log("subscribe :: call _sendPacket");
|
|
17425
17436
|
this._sendPacket(packet);
|
|
17437
|
+
return promise;
|
|
17438
|
+
};
|
|
17439
|
+
const subscribeProc = () => {
|
|
17440
|
+
var _a;
|
|
17441
|
+
const batchSize = (_a = this.options.subscribeBatchSize) !== null && _a !== void 0 ? _a : subs.length;
|
|
17442
|
+
const subscribePromises = [];
|
|
17443
|
+
for (let i5 = 0; i5 < subs.length; i5 += batchSize) {
|
|
17444
|
+
const chunkedSubs = subs.slice(i5, i5 + batchSize);
|
|
17445
|
+
const messageId = this._nextId();
|
|
17446
|
+
if (messageId === null) {
|
|
17447
|
+
this.log("No messageId left");
|
|
17448
|
+
return false;
|
|
17449
|
+
}
|
|
17450
|
+
subscribePromises.push(subscribeChunkedSubs(chunkedSubs, messageId));
|
|
17451
|
+
}
|
|
17452
|
+
Promise.all(subscribePromises).then((packets) => {
|
|
17453
|
+
callback(null, subs, packets.at(-1));
|
|
17454
|
+
}).catch((err) => {
|
|
17455
|
+
callback(err, subs, err.packet);
|
|
17456
|
+
});
|
|
17426
17457
|
return true;
|
|
17427
17458
|
};
|
|
17428
17459
|
if (this._storeProcessing || this._storeProcessingQueue.length > 0 || !subscribeProc()) {
|