ljs-tools 0.3.13 → 0.3.15
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/index.css +1 -1
- package/index.js +119 -62
- package/index.umd.cjs +5 -5
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -352,6 +352,10 @@ function formatTime(time, pattern) {
|
|
|
352
352
|
});
|
|
353
353
|
}
|
|
354
354
|
function customizedDate(time, pattern, span = 0) {
|
|
355
|
+
if (span === 0) {
|
|
356
|
+
let t = new Date(time).getTime();
|
|
357
|
+
return formatTime(t, pattern);
|
|
358
|
+
}
|
|
355
359
|
if (pattern === "{y}-{m}-{d}") {
|
|
356
360
|
let t = new Date(time).getTime();
|
|
357
361
|
t = t + 3600 * 1e3 * 24 * span;
|
|
@@ -623,20 +627,20 @@ function pickerOptions(dateType = "3", span = 0, dateTypeKeyValue = ["1", "2", "
|
|
|
623
627
|
return time.getTime() > oneTimeDisabledDate;
|
|
624
628
|
};
|
|
625
629
|
}
|
|
626
|
-
let trendsDisabledDate = 0;
|
|
630
|
+
let trendsDisabledDate$1 = 0;
|
|
627
631
|
function pickerOptionsDynamic(day = 30, times) {
|
|
628
632
|
if (times) {
|
|
629
|
-
trendsDisabledDate = LJSdate.formatTime(times[0], "{y}-{m}-{d}");
|
|
633
|
+
trendsDisabledDate$1 = LJSdate.formatTime(times[0], "{y}-{m}-{d}");
|
|
630
634
|
} else {
|
|
631
|
-
trendsDisabledDate = 0;
|
|
635
|
+
trendsDisabledDate$1 = 0;
|
|
632
636
|
}
|
|
633
637
|
const stepTime = 3600 * 1e3 * 24 * day;
|
|
634
638
|
return (time) => {
|
|
635
|
-
if (trendsDisabledDate === 0) {
|
|
636
|
-
return time.getTime() > Date.now() || time.getTime() < trendsDisabledDate;
|
|
639
|
+
if (trendsDisabledDate$1 === 0) {
|
|
640
|
+
return time.getTime() > Date.now() || time.getTime() < trendsDisabledDate$1;
|
|
637
641
|
} else {
|
|
638
|
-
const max = new Date(trendsDisabledDate).getTime() + stepTime - 3600 * 1e3 * 24;
|
|
639
|
-
const min = new Date(trendsDisabledDate).getTime() - stepTime;
|
|
642
|
+
const max = new Date(trendsDisabledDate$1).getTime() + stepTime - 3600 * 1e3 * 24;
|
|
643
|
+
const min = new Date(trendsDisabledDate$1).getTime() - stepTime;
|
|
640
644
|
if (max >= Date.now()) {
|
|
641
645
|
return time.getTime() > Date.now() || time.getTime() < min;
|
|
642
646
|
} else {
|
|
@@ -13262,7 +13266,36 @@ const index = {
|
|
|
13262
13266
|
type: Boolean,
|
|
13263
13267
|
default: true
|
|
13264
13268
|
},
|
|
13265
|
-
|
|
13269
|
+
disabledDate_start: {
|
|
13270
|
+
type: Function,
|
|
13271
|
+
default: () => {
|
|
13272
|
+
}
|
|
13273
|
+
},
|
|
13274
|
+
disabledDate_end: {
|
|
13275
|
+
type: Function,
|
|
13276
|
+
default: () => {
|
|
13277
|
+
}
|
|
13278
|
+
},
|
|
13279
|
+
// 开始日期事件。同 el-date-picker 事件 change
|
|
13280
|
+
change_start: {
|
|
13281
|
+
type: Function,
|
|
13282
|
+
default: (val) => {
|
|
13283
|
+
}
|
|
13284
|
+
},
|
|
13285
|
+
// 结束日期事件。同 el-date-picker 事件 change
|
|
13286
|
+
change_end: {
|
|
13287
|
+
type: Function,
|
|
13288
|
+
default: (val) => {
|
|
13289
|
+
}
|
|
13290
|
+
},
|
|
13291
|
+
// 开始日期事件。同 el-date-picker 事件 visible-change
|
|
13292
|
+
visibleChange_start: {
|
|
13293
|
+
type: Function,
|
|
13294
|
+
default: () => {
|
|
13295
|
+
}
|
|
13296
|
+
},
|
|
13297
|
+
// 结束日期事件。同 el-date-picker 事件 visible-change
|
|
13298
|
+
visibleChange_end: {
|
|
13266
13299
|
type: Function,
|
|
13267
13300
|
default: () => {
|
|
13268
13301
|
}
|
|
@@ -13335,12 +13368,34 @@ const index = {
|
|
|
13335
13368
|
this.opts.valueFormat = "YYYY";
|
|
13336
13369
|
break;
|
|
13337
13370
|
}
|
|
13371
|
+
},
|
|
13372
|
+
// let trendsDisabledDate = 0; // 根据点击的第一个日期,控制日期区间是否可选
|
|
13373
|
+
pickerOptionsDynamic(day = 30, times) {
|
|
13374
|
+
if (times) {
|
|
13375
|
+
trendsDisabledDate = D.formatTime(times[0], "{y}-{m}-{d}");
|
|
13376
|
+
} else {
|
|
13377
|
+
trendsDisabledDate = 0;
|
|
13378
|
+
}
|
|
13379
|
+
const stepTime = 3600 * 1e3 * 24 * day;
|
|
13380
|
+
return (time) => {
|
|
13381
|
+
if (trendsDisabledDate === 0) {
|
|
13382
|
+
return time.getTime() > Date.now() || time.getTime() < trendsDisabledDate;
|
|
13383
|
+
} else {
|
|
13384
|
+
const max = new Date(trendsDisabledDate).getTime() + stepTime - 3600 * 1e3 * 24;
|
|
13385
|
+
const min = new Date(trendsDisabledDate).getTime() - stepTime;
|
|
13386
|
+
if (max >= Date.now()) {
|
|
13387
|
+
return time.getTime() > Date.now() || time.getTime() < min;
|
|
13388
|
+
} else {
|
|
13389
|
+
return time.getTime() > max || time.getTime() < min;
|
|
13390
|
+
}
|
|
13391
|
+
}
|
|
13392
|
+
};
|
|
13338
13393
|
}
|
|
13339
13394
|
}
|
|
13340
13395
|
};
|
|
13341
|
-
const
|
|
13396
|
+
const index_vue_vue_type_style_index_0_scoped_2bc58730_lang = "";
|
|
13342
13397
|
const _sfc_main$2 = index;
|
|
13343
|
-
const _withScopeId$1 = (n) => (pushScopeId("data-v-
|
|
13398
|
+
const _withScopeId$1 = (n) => (pushScopeId("data-v-2bc58730"), n = n(), popScopeId(), n);
|
|
13344
13399
|
const _hoisted_1$2 = /* @__PURE__ */ _withScopeId$1(() => /* @__PURE__ */ createElementVNode("span", { class: "and" }, "~", -1));
|
|
13345
13400
|
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
13346
13401
|
const _component_el_date_picker = resolveComponent("el-date-picker");
|
|
@@ -13361,13 +13416,14 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
13361
13416
|
placeholder: "开始日期",
|
|
13362
13417
|
editable: false,
|
|
13363
13418
|
clearable: _ctx.clearable,
|
|
13364
|
-
"disabled-date": _ctx.
|
|
13365
|
-
onChange: _ctx.dateChange
|
|
13366
|
-
|
|
13419
|
+
"disabled-date": _ctx.disabledDate_start,
|
|
13420
|
+
onChange: _cache[1] || (_cache[1] = ($event) => (_ctx.change_start($event), _ctx.dateChange())),
|
|
13421
|
+
onVisibleChange: _cache[2] || (_cache[2] = ($event) => _ctx.visibleChange_start($event))
|
|
13422
|
+
}, null, 8, ["modelValue", "style", "value-format", "type", "clearable", "disabled-date"]),
|
|
13367
13423
|
_hoisted_1$2,
|
|
13368
13424
|
createVNode(_component_el_date_picker, {
|
|
13369
13425
|
modelValue: _ctx.opts.endDate,
|
|
13370
|
-
"onUpdate:modelValue": _cache[
|
|
13426
|
+
"onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => _ctx.opts.endDate = $event),
|
|
13371
13427
|
style: normalizeStyle({
|
|
13372
13428
|
width: `${_ctx.dateType === "year" ? 100 : _ctx.dateType === "month" ? 120 : _ctx.dateType === "date" ? 140 : _ctx.dateType === "datetime" ? 200 : 200}px !important`
|
|
13373
13429
|
}),
|
|
@@ -13376,14 +13432,15 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
13376
13432
|
placeholder: "结束日期",
|
|
13377
13433
|
editable: false,
|
|
13378
13434
|
clearable: _ctx.clearable,
|
|
13379
|
-
"disabled-date": _ctx.
|
|
13380
|
-
onChange: _ctx.dateChange
|
|
13381
|
-
|
|
13435
|
+
"disabled-date": _ctx.disabledDate_end,
|
|
13436
|
+
onChange: _cache[4] || (_cache[4] = ($event) => (_ctx.change_end($event), _ctx.dateChange())),
|
|
13437
|
+
onVisibleChange: _cache[5] || (_cache[5] = ($event) => _ctx.visibleChange_end($event))
|
|
13438
|
+
}, null, 8, ["modelValue", "style", "value-format", "type", "clearable", "disabled-date"])
|
|
13382
13439
|
]),
|
|
13383
13440
|
_: 1
|
|
13384
13441
|
}, 8, ["label"]);
|
|
13385
13442
|
}
|
|
13386
|
-
const DateRange = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2], ["__scopeId", "data-v-
|
|
13443
|
+
const DateRange = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2], ["__scopeId", "data-v-2bc58730"]]);
|
|
13387
13444
|
const index_vue_vue_type_style_index_0_scoped_f2de2f23_lang = "";
|
|
13388
13445
|
const _sfc_main$1 = {
|
|
13389
13446
|
name: "DictTag",
|
|
@@ -20247,7 +20304,7 @@ var wd = M((AP, bd) => {
|
|
|
20247
20304
|
_();
|
|
20248
20305
|
v();
|
|
20249
20306
|
m();
|
|
20250
|
-
var vm = ld(), { EventEmitter: Em } = (ir(), Z(rr)), yd = fd(), V = jo(),
|
|
20307
|
+
var vm = ld(), { EventEmitter: Em } = (ir(), Z(rr)), yd = fd(), V = jo(), D2 = ot()("mqtt-packet:parser"), Fo = class t extends Em {
|
|
20251
20308
|
constructor() {
|
|
20252
20309
|
super(), this.parser = this.constructor.parser;
|
|
20253
20310
|
}
|
|
@@ -20255,25 +20312,25 @@ var wd = M((AP, bd) => {
|
|
|
20255
20312
|
return this instanceof t ? (this.settings = e || {}, this._states = ["_parseHeader", "_parseLength", "_parsePayload", "_newPacket"], this._resetState(), this) : new t().parser(e);
|
|
20256
20313
|
}
|
|
20257
20314
|
_resetState() {
|
|
20258
|
-
|
|
20315
|
+
D2("_resetState: resetting packet, error, _list, and _stateCounter"), this.packet = new yd(), this.error = null, this._list = vm(), this._stateCounter = 0;
|
|
20259
20316
|
}
|
|
20260
20317
|
parse(e) {
|
|
20261
|
-
for (this.error && this._resetState(), this._list.append(e),
|
|
20262
|
-
this._stateCounter++,
|
|
20263
|
-
return
|
|
20318
|
+
for (this.error && this._resetState(), this._list.append(e), D2("parse: current state: %s", this._states[this._stateCounter]); (this.packet.length !== -1 || this._list.length > 0) && this[this._states[this._stateCounter]]() && !this.error; )
|
|
20319
|
+
this._stateCounter++, D2("parse: state complete. _stateCounter is now: %d", this._stateCounter), D2("parse: packet.length: %d, buffer list length: %d", this.packet.length, this._list.length), this._stateCounter >= this._states.length && (this._stateCounter = 0);
|
|
20320
|
+
return D2("parse: exited while loop. packet: %d, buffer list length: %d", this.packet.length, this._list.length), this._list.length;
|
|
20264
20321
|
}
|
|
20265
20322
|
_parseHeader() {
|
|
20266
20323
|
let e = this._list.readUInt8(0), r = e >> V.CMD_SHIFT;
|
|
20267
20324
|
this.packet.cmd = V.types[r];
|
|
20268
20325
|
let i = e & 15, n = V.requiredHeaderFlags[r];
|
|
20269
|
-
return n != null && i !== n ? this._emitError(new Error(V.requiredHeaderFlagsErrors[r])) : (this.packet.retain = (e & V.RETAIN_MASK) !== 0, this.packet.qos = e >> V.QOS_SHIFT & V.QOS_MASK, this.packet.qos > 2 ? this._emitError(new Error("Packet must not have both QoS bits set to 1")) : (this.packet.dup = (e & V.DUP_MASK) !== 0,
|
|
20326
|
+
return n != null && i !== n ? this._emitError(new Error(V.requiredHeaderFlagsErrors[r])) : (this.packet.retain = (e & V.RETAIN_MASK) !== 0, this.packet.qos = e >> V.QOS_SHIFT & V.QOS_MASK, this.packet.qos > 2 ? this._emitError(new Error("Packet must not have both QoS bits set to 1")) : (this.packet.dup = (e & V.DUP_MASK) !== 0, D2("_parseHeader: packet: %o", this.packet), this._list.consume(1), true));
|
|
20270
20327
|
}
|
|
20271
20328
|
_parseLength() {
|
|
20272
20329
|
let e = this._parseVarByteNum(true);
|
|
20273
|
-
return e && (this.packet.length = e.value, this._list.consume(e.bytes)),
|
|
20330
|
+
return e && (this.packet.length = e.value, this._list.consume(e.bytes)), D2("_parseLength %d", e.value), !!e;
|
|
20274
20331
|
}
|
|
20275
20332
|
_parsePayload() {
|
|
20276
|
-
|
|
20333
|
+
D2("_parsePayload: payload %O", this._list);
|
|
20277
20334
|
let e = false;
|
|
20278
20335
|
if (this.packet.length === 0 || this._list.length >= this.packet.length) {
|
|
20279
20336
|
switch (this._pos = 0, this.packet.cmd) {
|
|
@@ -20318,10 +20375,10 @@ var wd = M((AP, bd) => {
|
|
|
20318
20375
|
}
|
|
20319
20376
|
e = true;
|
|
20320
20377
|
}
|
|
20321
|
-
return
|
|
20378
|
+
return D2("_parsePayload complete result: %s", e), e;
|
|
20322
20379
|
}
|
|
20323
20380
|
_parseConnect() {
|
|
20324
|
-
|
|
20381
|
+
D2("_parseConnect");
|
|
20325
20382
|
let e, r, i, n, o = {}, s = this.packet, a = this._parseString();
|
|
20326
20383
|
if (a === null)
|
|
20327
20384
|
return this._emitError(new Error("Cannot parse protocolId"));
|
|
@@ -20354,31 +20411,31 @@ var wd = M((AP, bd) => {
|
|
|
20354
20411
|
let h2 = this._parseString();
|
|
20355
20412
|
if (h2 === null)
|
|
20356
20413
|
return this._emitError(new Error("Packet too short"));
|
|
20357
|
-
if (s.clientId = h2,
|
|
20414
|
+
if (s.clientId = h2, D2("_parseConnect: packet.clientId: %s", s.clientId), o.will) {
|
|
20358
20415
|
if (s.protocolVersion === 5) {
|
|
20359
20416
|
let d = this._parseProperties();
|
|
20360
20417
|
Object.getOwnPropertyNames(d).length && (s.will.properties = d);
|
|
20361
20418
|
}
|
|
20362
20419
|
if (e = this._parseString(), e === null)
|
|
20363
20420
|
return this._emitError(new Error("Cannot parse will topic"));
|
|
20364
|
-
if (s.will.topic = e,
|
|
20421
|
+
if (s.will.topic = e, D2("_parseConnect: packet.will.topic: %s", s.will.topic), r = this._parseBuffer(), r === null)
|
|
20365
20422
|
return this._emitError(new Error("Cannot parse will payload"));
|
|
20366
|
-
s.will.payload = r,
|
|
20423
|
+
s.will.payload = r, D2("_parseConnect: packet.will.paylaod: %s", s.will.payload);
|
|
20367
20424
|
}
|
|
20368
20425
|
if (o.username) {
|
|
20369
20426
|
if (n = this._parseString(), n === null)
|
|
20370
20427
|
return this._emitError(new Error("Cannot parse username"));
|
|
20371
|
-
s.username = n,
|
|
20428
|
+
s.username = n, D2("_parseConnect: packet.username: %s", s.username);
|
|
20372
20429
|
}
|
|
20373
20430
|
if (o.password) {
|
|
20374
20431
|
if (i = this._parseBuffer(), i === null)
|
|
20375
20432
|
return this._emitError(new Error("Cannot parse password"));
|
|
20376
20433
|
s.password = i;
|
|
20377
20434
|
}
|
|
20378
|
-
return this.settings = s,
|
|
20435
|
+
return this.settings = s, D2("_parseConnect: complete"), s;
|
|
20379
20436
|
}
|
|
20380
20437
|
_parseConnack() {
|
|
20381
|
-
|
|
20438
|
+
D2("_parseConnack");
|
|
20382
20439
|
let e = this.packet;
|
|
20383
20440
|
if (this._list.length < 1)
|
|
20384
20441
|
return null;
|
|
@@ -20398,10 +20455,10 @@ var wd = M((AP, bd) => {
|
|
|
20398
20455
|
let i = this._parseProperties();
|
|
20399
20456
|
Object.getOwnPropertyNames(i).length && (e.properties = i);
|
|
20400
20457
|
}
|
|
20401
|
-
|
|
20458
|
+
D2("_parseConnack: complete");
|
|
20402
20459
|
}
|
|
20403
20460
|
_parsePublish() {
|
|
20404
|
-
|
|
20461
|
+
D2("_parsePublish");
|
|
20405
20462
|
let e = this.packet;
|
|
20406
20463
|
if (e.topic = this._parseString(), e.topic === null)
|
|
20407
20464
|
return this._emitError(new Error("Cannot parse topic"));
|
|
@@ -20410,11 +20467,11 @@ var wd = M((AP, bd) => {
|
|
|
20410
20467
|
let r = this._parseProperties();
|
|
20411
20468
|
Object.getOwnPropertyNames(r).length && (e.properties = r);
|
|
20412
20469
|
}
|
|
20413
|
-
e.payload = this._list.slice(this._pos, e.length),
|
|
20470
|
+
e.payload = this._list.slice(this._pos, e.length), D2("_parsePublish: payload from buffer list: %o", e.payload);
|
|
20414
20471
|
}
|
|
20415
20472
|
}
|
|
20416
20473
|
_parseSubscribe() {
|
|
20417
|
-
|
|
20474
|
+
D2("_parseSubscribe");
|
|
20418
20475
|
let e = this.packet, r, i, n, o, s, a, u;
|
|
20419
20476
|
if (e.subscriptions = [], !!this._parseMessageId()) {
|
|
20420
20477
|
if (this.settings.protocolVersion === 5) {
|
|
@@ -20437,12 +20494,12 @@ var wd = M((AP, bd) => {
|
|
|
20437
20494
|
return this._emitError(new Error("Invalid subscribe QoS, must be <= 2"));
|
|
20438
20495
|
if (a = (i >> V.SUBSCRIBE_OPTIONS_NL_SHIFT & V.SUBSCRIBE_OPTIONS_NL_MASK) !== 0, s = (i >> V.SUBSCRIBE_OPTIONS_RAP_SHIFT & V.SUBSCRIBE_OPTIONS_RAP_MASK) !== 0, o = i >> V.SUBSCRIBE_OPTIONS_RH_SHIFT & V.SUBSCRIBE_OPTIONS_RH_MASK, o > 2)
|
|
20439
20496
|
return this._emitError(new Error("Invalid retain handling, must be <= 2"));
|
|
20440
|
-
u = { topic: r, qos: n }, this.settings.protocolVersion === 5 ? (u.nl = a, u.rap = s, u.rh = o) : this.settings.bridgeMode && (u.rh = 0, u.rap = true, u.nl = true),
|
|
20497
|
+
u = { topic: r, qos: n }, this.settings.protocolVersion === 5 ? (u.nl = a, u.rap = s, u.rh = o) : this.settings.bridgeMode && (u.rh = 0, u.rap = true, u.nl = true), D2("_parseSubscribe: push subscription `%s` to subscription", u), e.subscriptions.push(u);
|
|
20441
20498
|
}
|
|
20442
20499
|
}
|
|
20443
20500
|
}
|
|
20444
20501
|
_parseSuback() {
|
|
20445
|
-
|
|
20502
|
+
D2("_parseSuback");
|
|
20446
20503
|
let e = this.packet;
|
|
20447
20504
|
if (this.packet.granted = [], !!this._parseMessageId()) {
|
|
20448
20505
|
if (this.settings.protocolVersion === 5) {
|
|
@@ -20463,7 +20520,7 @@ var wd = M((AP, bd) => {
|
|
|
20463
20520
|
}
|
|
20464
20521
|
}
|
|
20465
20522
|
_parseUnsubscribe() {
|
|
20466
|
-
|
|
20523
|
+
D2("_parseUnsubscribe");
|
|
20467
20524
|
let e = this.packet;
|
|
20468
20525
|
if (e.unsubscriptions = [], !!this._parseMessageId()) {
|
|
20469
20526
|
if (this.settings.protocolVersion === 5) {
|
|
@@ -20476,12 +20533,12 @@ var wd = M((AP, bd) => {
|
|
|
20476
20533
|
let r = this._parseString();
|
|
20477
20534
|
if (r === null)
|
|
20478
20535
|
return this._emitError(new Error("Cannot parse topic"));
|
|
20479
|
-
|
|
20536
|
+
D2("_parseUnsubscribe: push topic `%s` to unsubscriptions", r), e.unsubscriptions.push(r);
|
|
20480
20537
|
}
|
|
20481
20538
|
}
|
|
20482
20539
|
}
|
|
20483
20540
|
_parseUnsuback() {
|
|
20484
|
-
|
|
20541
|
+
D2("_parseUnsuback");
|
|
20485
20542
|
let e = this.packet;
|
|
20486
20543
|
if (!this._parseMessageId())
|
|
20487
20544
|
return this._emitError(new Error("Cannot parse messageId"));
|
|
@@ -20500,7 +20557,7 @@ var wd = M((AP, bd) => {
|
|
|
20500
20557
|
}
|
|
20501
20558
|
}
|
|
20502
20559
|
_parseConfirmation() {
|
|
20503
|
-
|
|
20560
|
+
D2("_parseConfirmation: packet.cmd: `%s`", this.packet.cmd);
|
|
20504
20561
|
let e = this.packet;
|
|
20505
20562
|
if (this._parseMessageId(), this.settings.protocolVersion === 5) {
|
|
20506
20563
|
if (e.length > 2) {
|
|
@@ -20516,7 +20573,7 @@ var wd = M((AP, bd) => {
|
|
|
20516
20573
|
return this._emitError(new Error("Invalid " + this.packet.cmd + " reason code"));
|
|
20517
20574
|
break;
|
|
20518
20575
|
}
|
|
20519
|
-
|
|
20576
|
+
D2("_parseConfirmation: packet.reasonCode `%d`", e.reasonCode);
|
|
20520
20577
|
} else
|
|
20521
20578
|
e.reasonCode = 0;
|
|
20522
20579
|
if (e.length > 3) {
|
|
@@ -20528,58 +20585,58 @@ var wd = M((AP, bd) => {
|
|
|
20528
20585
|
}
|
|
20529
20586
|
_parseDisconnect() {
|
|
20530
20587
|
let e = this.packet;
|
|
20531
|
-
if (
|
|
20588
|
+
if (D2("_parseDisconnect"), this.settings.protocolVersion === 5) {
|
|
20532
20589
|
this._list.length > 0 ? (e.reasonCode = this._parseByte(), V.MQTT5_DISCONNECT_CODES[e.reasonCode] || this._emitError(new Error("Invalid disconnect reason code"))) : e.reasonCode = 0;
|
|
20533
20590
|
let r = this._parseProperties();
|
|
20534
20591
|
Object.getOwnPropertyNames(r).length && (e.properties = r);
|
|
20535
20592
|
}
|
|
20536
|
-
return
|
|
20593
|
+
return D2("_parseDisconnect result: true"), true;
|
|
20537
20594
|
}
|
|
20538
20595
|
_parseAuth() {
|
|
20539
|
-
|
|
20596
|
+
D2("_parseAuth");
|
|
20540
20597
|
let e = this.packet;
|
|
20541
20598
|
if (this.settings.protocolVersion !== 5)
|
|
20542
20599
|
return this._emitError(new Error("Not supported auth packet for this version MQTT"));
|
|
20543
20600
|
if (e.reasonCode = this._parseByte(), !V.MQTT5_AUTH_CODES[e.reasonCode])
|
|
20544
20601
|
return this._emitError(new Error("Invalid auth reason code"));
|
|
20545
20602
|
let r = this._parseProperties();
|
|
20546
|
-
return Object.getOwnPropertyNames(r).length && (e.properties = r),
|
|
20603
|
+
return Object.getOwnPropertyNames(r).length && (e.properties = r), D2("_parseAuth: result: true"), true;
|
|
20547
20604
|
}
|
|
20548
20605
|
_parseMessageId() {
|
|
20549
20606
|
let e = this.packet;
|
|
20550
|
-
return e.messageId = this._parseNum(), e.messageId === null ? (this._emitError(new Error("Cannot parse messageId")), false) : (
|
|
20607
|
+
return e.messageId = this._parseNum(), e.messageId === null ? (this._emitError(new Error("Cannot parse messageId")), false) : (D2("_parseMessageId: packet.messageId %d", e.messageId), true);
|
|
20551
20608
|
}
|
|
20552
20609
|
_parseString(e) {
|
|
20553
20610
|
let r = this._parseNum(), i = r + this._pos;
|
|
20554
20611
|
if (r === -1 || i > this._list.length || i > this.packet.length)
|
|
20555
20612
|
return null;
|
|
20556
20613
|
let n = this._list.toString("utf8", this._pos, i);
|
|
20557
|
-
return this._pos += r,
|
|
20614
|
+
return this._pos += r, D2("_parseString: result: %s", n), n;
|
|
20558
20615
|
}
|
|
20559
20616
|
_parseStringPair() {
|
|
20560
|
-
return
|
|
20617
|
+
return D2("_parseStringPair"), { name: this._parseString(), value: this._parseString() };
|
|
20561
20618
|
}
|
|
20562
20619
|
_parseBuffer() {
|
|
20563
20620
|
let e = this._parseNum(), r = e + this._pos;
|
|
20564
20621
|
if (e === -1 || r > this._list.length || r > this.packet.length)
|
|
20565
20622
|
return null;
|
|
20566
20623
|
let i = this._list.slice(this._pos, r);
|
|
20567
|
-
return this._pos += e,
|
|
20624
|
+
return this._pos += e, D2("_parseBuffer: result: %o", i), i;
|
|
20568
20625
|
}
|
|
20569
20626
|
_parseNum() {
|
|
20570
20627
|
if (this._list.length - this._pos < 2)
|
|
20571
20628
|
return -1;
|
|
20572
20629
|
let e = this._list.readUInt16BE(this._pos);
|
|
20573
|
-
return this._pos += 2,
|
|
20630
|
+
return this._pos += 2, D2("_parseNum: result: %s", e), e;
|
|
20574
20631
|
}
|
|
20575
20632
|
_parse4ByteNum() {
|
|
20576
20633
|
if (this._list.length - this._pos < 4)
|
|
20577
20634
|
return -1;
|
|
20578
20635
|
let e = this._list.readUInt32BE(this._pos);
|
|
20579
|
-
return this._pos += 4,
|
|
20636
|
+
return this._pos += 4, D2("_parse4ByteNum: result: %s", e), e;
|
|
20580
20637
|
}
|
|
20581
20638
|
_parseVarByteNum(e) {
|
|
20582
|
-
|
|
20639
|
+
D2("_parseVarByteNum");
|
|
20583
20640
|
let r = 4, i = 0, n = 1, o = 0, s = false, a, u = this._pos ? this._pos : 0;
|
|
20584
20641
|
for (; i < r && u + i < this._list.length; ) {
|
|
20585
20642
|
if (a = this._list.readUInt8(u + i++), o += n * (a & V.VARBYTEINT_MASK), n *= 128, !(a & V.VARBYTEINT_FIN_MASK)) {
|
|
@@ -20589,14 +20646,14 @@ var wd = M((AP, bd) => {
|
|
|
20589
20646
|
if (this._list.length <= i)
|
|
20590
20647
|
break;
|
|
20591
20648
|
}
|
|
20592
|
-
return !s && i === r && this._list.length >= i && this._emitError(new Error("Invalid variable byte integer")), u && (this._pos += i), s ? e ? s = { bytes: i, value: o } : s = o : s = false,
|
|
20649
|
+
return !s && i === r && this._list.length >= i && this._emitError(new Error("Invalid variable byte integer")), u && (this._pos += i), s ? e ? s = { bytes: i, value: o } : s = o : s = false, D2("_parseVarByteNum: result: %o", s), s;
|
|
20593
20650
|
}
|
|
20594
20651
|
_parseByte() {
|
|
20595
20652
|
let e;
|
|
20596
|
-
return this._pos < this._list.length && (e = this._list.readUInt8(this._pos), this._pos++),
|
|
20653
|
+
return this._pos < this._list.length && (e = this._list.readUInt8(this._pos), this._pos++), D2("_parseByte: result: %o", e), e;
|
|
20597
20654
|
}
|
|
20598
20655
|
_parseByType(e) {
|
|
20599
|
-
switch (
|
|
20656
|
+
switch (D2("_parseByType: type: %s", e), e) {
|
|
20600
20657
|
case "byte":
|
|
20601
20658
|
return this._parseByte() !== 0;
|
|
20602
20659
|
case "int8":
|
|
@@ -20616,7 +20673,7 @@ var wd = M((AP, bd) => {
|
|
|
20616
20673
|
}
|
|
20617
20674
|
}
|
|
20618
20675
|
_parseProperties() {
|
|
20619
|
-
|
|
20676
|
+
D2("_parseProperties");
|
|
20620
20677
|
let e = this._parseVarByteNum(), i = this._pos + e, n = {};
|
|
20621
20678
|
for (; this._pos < i; ) {
|
|
20622
20679
|
let o = this._parseByte();
|
|
@@ -20644,10 +20701,10 @@ var wd = M((AP, bd) => {
|
|
|
20644
20701
|
return n;
|
|
20645
20702
|
}
|
|
20646
20703
|
_newPacket() {
|
|
20647
|
-
return
|
|
20704
|
+
return D2("_newPacket"), this.packet && (this._list.consume(this.packet.length), D2("_newPacket: parser emit packet: packet.cmd: %s, packet.payload: %s, packet.length: %d", this.packet.cmd, this.packet.payload, this.packet.length), this.emit("packet", this.packet)), D2("_newPacket: new packet"), this.packet = new yd(), this._pos = 0, true;
|
|
20648
20705
|
}
|
|
20649
20706
|
_emitError(e) {
|
|
20650
|
-
|
|
20707
|
+
D2("_emitError", e), this.error = e, this.emit("error", e);
|
|
20651
20708
|
}
|
|
20652
20709
|
};
|
|
20653
20710
|
bd.exports = Fo;
|