ljs-tools 0.3.14 → 0.3.16
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 +115 -62
- package/index.umd.cjs +5 -5
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -627,20 +627,20 @@ function pickerOptions(dateType = "3", span = 0, dateTypeKeyValue = ["1", "2", "
|
|
|
627
627
|
return time.getTime() > oneTimeDisabledDate;
|
|
628
628
|
};
|
|
629
629
|
}
|
|
630
|
-
let trendsDisabledDate = 0;
|
|
630
|
+
let trendsDisabledDate$1 = 0;
|
|
631
631
|
function pickerOptionsDynamic(day = 30, times) {
|
|
632
632
|
if (times) {
|
|
633
|
-
trendsDisabledDate = LJSdate.formatTime(times[0], "{y}-{m}-{d}");
|
|
633
|
+
trendsDisabledDate$1 = LJSdate.formatTime(times[0], "{y}-{m}-{d}");
|
|
634
634
|
} else {
|
|
635
|
-
trendsDisabledDate = 0;
|
|
635
|
+
trendsDisabledDate$1 = 0;
|
|
636
636
|
}
|
|
637
637
|
const stepTime = 3600 * 1e3 * 24 * day;
|
|
638
638
|
return (time) => {
|
|
639
|
-
if (trendsDisabledDate === 0) {
|
|
640
|
-
return time.getTime() > Date.now() || time.getTime() < trendsDisabledDate;
|
|
639
|
+
if (trendsDisabledDate$1 === 0) {
|
|
640
|
+
return time.getTime() > Date.now() || time.getTime() < trendsDisabledDate$1;
|
|
641
641
|
} else {
|
|
642
|
-
const max = new Date(trendsDisabledDate).getTime() + stepTime - 3600 * 1e3 * 24;
|
|
643
|
-
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;
|
|
644
644
|
if (max >= Date.now()) {
|
|
645
645
|
return time.getTime() > Date.now() || time.getTime() < min;
|
|
646
646
|
} else {
|
|
@@ -13266,7 +13266,36 @@ const index = {
|
|
|
13266
13266
|
type: Boolean,
|
|
13267
13267
|
default: true
|
|
13268
13268
|
},
|
|
13269
|
-
|
|
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: {
|
|
13270
13299
|
type: Function,
|
|
13271
13300
|
default: () => {
|
|
13272
13301
|
}
|
|
@@ -13339,12 +13368,34 @@ const index = {
|
|
|
13339
13368
|
this.opts.valueFormat = "YYYY";
|
|
13340
13369
|
break;
|
|
13341
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
|
+
};
|
|
13342
13393
|
}
|
|
13343
13394
|
}
|
|
13344
13395
|
};
|
|
13345
|
-
const
|
|
13396
|
+
const index_vue_vue_type_style_index_0_scoped_2bc58730_lang = "";
|
|
13346
13397
|
const _sfc_main$2 = index;
|
|
13347
|
-
const _withScopeId$1 = (n) => (pushScopeId("data-v-
|
|
13398
|
+
const _withScopeId$1 = (n) => (pushScopeId("data-v-2bc58730"), n = n(), popScopeId(), n);
|
|
13348
13399
|
const _hoisted_1$2 = /* @__PURE__ */ _withScopeId$1(() => /* @__PURE__ */ createElementVNode("span", { class: "and" }, "~", -1));
|
|
13349
13400
|
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
13350
13401
|
const _component_el_date_picker = resolveComponent("el-date-picker");
|
|
@@ -13365,13 +13416,14 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
13365
13416
|
placeholder: "开始日期",
|
|
13366
13417
|
editable: false,
|
|
13367
13418
|
clearable: _ctx.clearable,
|
|
13368
|
-
"disabled-date": _ctx.
|
|
13369
|
-
onChange: _ctx.dateChange
|
|
13370
|
-
|
|
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"]),
|
|
13371
13423
|
_hoisted_1$2,
|
|
13372
13424
|
createVNode(_component_el_date_picker, {
|
|
13373
13425
|
modelValue: _ctx.opts.endDate,
|
|
13374
|
-
"onUpdate:modelValue": _cache[
|
|
13426
|
+
"onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => _ctx.opts.endDate = $event),
|
|
13375
13427
|
style: normalizeStyle({
|
|
13376
13428
|
width: `${_ctx.dateType === "year" ? 100 : _ctx.dateType === "month" ? 120 : _ctx.dateType === "date" ? 140 : _ctx.dateType === "datetime" ? 200 : 200}px !important`
|
|
13377
13429
|
}),
|
|
@@ -13380,14 +13432,15 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
13380
13432
|
placeholder: "结束日期",
|
|
13381
13433
|
editable: false,
|
|
13382
13434
|
clearable: _ctx.clearable,
|
|
13383
|
-
"disabled-date": _ctx.
|
|
13384
|
-
onChange: _ctx.dateChange
|
|
13385
|
-
|
|
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"])
|
|
13386
13439
|
]),
|
|
13387
13440
|
_: 1
|
|
13388
13441
|
}, 8, ["label"]);
|
|
13389
13442
|
}
|
|
13390
|
-
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"]]);
|
|
13391
13444
|
const index_vue_vue_type_style_index_0_scoped_f2de2f23_lang = "";
|
|
13392
13445
|
const _sfc_main$1 = {
|
|
13393
13446
|
name: "DictTag",
|
|
@@ -20251,7 +20304,7 @@ var wd = M((AP, bd) => {
|
|
|
20251
20304
|
_();
|
|
20252
20305
|
v();
|
|
20253
20306
|
m();
|
|
20254
|
-
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 {
|
|
20255
20308
|
constructor() {
|
|
20256
20309
|
super(), this.parser = this.constructor.parser;
|
|
20257
20310
|
}
|
|
@@ -20259,25 +20312,25 @@ var wd = M((AP, bd) => {
|
|
|
20259
20312
|
return this instanceof t ? (this.settings = e || {}, this._states = ["_parseHeader", "_parseLength", "_parsePayload", "_newPacket"], this._resetState(), this) : new t().parser(e);
|
|
20260
20313
|
}
|
|
20261
20314
|
_resetState() {
|
|
20262
|
-
|
|
20315
|
+
D2("_resetState: resetting packet, error, _list, and _stateCounter"), this.packet = new yd(), this.error = null, this._list = vm(), this._stateCounter = 0;
|
|
20263
20316
|
}
|
|
20264
20317
|
parse(e) {
|
|
20265
|
-
for (this.error && this._resetState(), this._list.append(e),
|
|
20266
|
-
this._stateCounter++,
|
|
20267
|
-
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;
|
|
20268
20321
|
}
|
|
20269
20322
|
_parseHeader() {
|
|
20270
20323
|
let e = this._list.readUInt8(0), r = e >> V.CMD_SHIFT;
|
|
20271
20324
|
this.packet.cmd = V.types[r];
|
|
20272
20325
|
let i = e & 15, n = V.requiredHeaderFlags[r];
|
|
20273
|
-
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));
|
|
20274
20327
|
}
|
|
20275
20328
|
_parseLength() {
|
|
20276
20329
|
let e = this._parseVarByteNum(true);
|
|
20277
|
-
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;
|
|
20278
20331
|
}
|
|
20279
20332
|
_parsePayload() {
|
|
20280
|
-
|
|
20333
|
+
D2("_parsePayload: payload %O", this._list);
|
|
20281
20334
|
let e = false;
|
|
20282
20335
|
if (this.packet.length === 0 || this._list.length >= this.packet.length) {
|
|
20283
20336
|
switch (this._pos = 0, this.packet.cmd) {
|
|
@@ -20322,10 +20375,10 @@ var wd = M((AP, bd) => {
|
|
|
20322
20375
|
}
|
|
20323
20376
|
e = true;
|
|
20324
20377
|
}
|
|
20325
|
-
return
|
|
20378
|
+
return D2("_parsePayload complete result: %s", e), e;
|
|
20326
20379
|
}
|
|
20327
20380
|
_parseConnect() {
|
|
20328
|
-
|
|
20381
|
+
D2("_parseConnect");
|
|
20329
20382
|
let e, r, i, n, o = {}, s = this.packet, a = this._parseString();
|
|
20330
20383
|
if (a === null)
|
|
20331
20384
|
return this._emitError(new Error("Cannot parse protocolId"));
|
|
@@ -20358,31 +20411,31 @@ var wd = M((AP, bd) => {
|
|
|
20358
20411
|
let h2 = this._parseString();
|
|
20359
20412
|
if (h2 === null)
|
|
20360
20413
|
return this._emitError(new Error("Packet too short"));
|
|
20361
|
-
if (s.clientId = h2,
|
|
20414
|
+
if (s.clientId = h2, D2("_parseConnect: packet.clientId: %s", s.clientId), o.will) {
|
|
20362
20415
|
if (s.protocolVersion === 5) {
|
|
20363
20416
|
let d = this._parseProperties();
|
|
20364
20417
|
Object.getOwnPropertyNames(d).length && (s.will.properties = d);
|
|
20365
20418
|
}
|
|
20366
20419
|
if (e = this._parseString(), e === null)
|
|
20367
20420
|
return this._emitError(new Error("Cannot parse will topic"));
|
|
20368
|
-
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)
|
|
20369
20422
|
return this._emitError(new Error("Cannot parse will payload"));
|
|
20370
|
-
s.will.payload = r,
|
|
20423
|
+
s.will.payload = r, D2("_parseConnect: packet.will.paylaod: %s", s.will.payload);
|
|
20371
20424
|
}
|
|
20372
20425
|
if (o.username) {
|
|
20373
20426
|
if (n = this._parseString(), n === null)
|
|
20374
20427
|
return this._emitError(new Error("Cannot parse username"));
|
|
20375
|
-
s.username = n,
|
|
20428
|
+
s.username = n, D2("_parseConnect: packet.username: %s", s.username);
|
|
20376
20429
|
}
|
|
20377
20430
|
if (o.password) {
|
|
20378
20431
|
if (i = this._parseBuffer(), i === null)
|
|
20379
20432
|
return this._emitError(new Error("Cannot parse password"));
|
|
20380
20433
|
s.password = i;
|
|
20381
20434
|
}
|
|
20382
|
-
return this.settings = s,
|
|
20435
|
+
return this.settings = s, D2("_parseConnect: complete"), s;
|
|
20383
20436
|
}
|
|
20384
20437
|
_parseConnack() {
|
|
20385
|
-
|
|
20438
|
+
D2("_parseConnack");
|
|
20386
20439
|
let e = this.packet;
|
|
20387
20440
|
if (this._list.length < 1)
|
|
20388
20441
|
return null;
|
|
@@ -20402,10 +20455,10 @@ var wd = M((AP, bd) => {
|
|
|
20402
20455
|
let i = this._parseProperties();
|
|
20403
20456
|
Object.getOwnPropertyNames(i).length && (e.properties = i);
|
|
20404
20457
|
}
|
|
20405
|
-
|
|
20458
|
+
D2("_parseConnack: complete");
|
|
20406
20459
|
}
|
|
20407
20460
|
_parsePublish() {
|
|
20408
|
-
|
|
20461
|
+
D2("_parsePublish");
|
|
20409
20462
|
let e = this.packet;
|
|
20410
20463
|
if (e.topic = this._parseString(), e.topic === null)
|
|
20411
20464
|
return this._emitError(new Error("Cannot parse topic"));
|
|
@@ -20414,11 +20467,11 @@ var wd = M((AP, bd) => {
|
|
|
20414
20467
|
let r = this._parseProperties();
|
|
20415
20468
|
Object.getOwnPropertyNames(r).length && (e.properties = r);
|
|
20416
20469
|
}
|
|
20417
|
-
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);
|
|
20418
20471
|
}
|
|
20419
20472
|
}
|
|
20420
20473
|
_parseSubscribe() {
|
|
20421
|
-
|
|
20474
|
+
D2("_parseSubscribe");
|
|
20422
20475
|
let e = this.packet, r, i, n, o, s, a, u;
|
|
20423
20476
|
if (e.subscriptions = [], !!this._parseMessageId()) {
|
|
20424
20477
|
if (this.settings.protocolVersion === 5) {
|
|
@@ -20441,12 +20494,12 @@ var wd = M((AP, bd) => {
|
|
|
20441
20494
|
return this._emitError(new Error("Invalid subscribe QoS, must be <= 2"));
|
|
20442
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)
|
|
20443
20496
|
return this._emitError(new Error("Invalid retain handling, must be <= 2"));
|
|
20444
|
-
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);
|
|
20445
20498
|
}
|
|
20446
20499
|
}
|
|
20447
20500
|
}
|
|
20448
20501
|
_parseSuback() {
|
|
20449
|
-
|
|
20502
|
+
D2("_parseSuback");
|
|
20450
20503
|
let e = this.packet;
|
|
20451
20504
|
if (this.packet.granted = [], !!this._parseMessageId()) {
|
|
20452
20505
|
if (this.settings.protocolVersion === 5) {
|
|
@@ -20467,7 +20520,7 @@ var wd = M((AP, bd) => {
|
|
|
20467
20520
|
}
|
|
20468
20521
|
}
|
|
20469
20522
|
_parseUnsubscribe() {
|
|
20470
|
-
|
|
20523
|
+
D2("_parseUnsubscribe");
|
|
20471
20524
|
let e = this.packet;
|
|
20472
20525
|
if (e.unsubscriptions = [], !!this._parseMessageId()) {
|
|
20473
20526
|
if (this.settings.protocolVersion === 5) {
|
|
@@ -20480,12 +20533,12 @@ var wd = M((AP, bd) => {
|
|
|
20480
20533
|
let r = this._parseString();
|
|
20481
20534
|
if (r === null)
|
|
20482
20535
|
return this._emitError(new Error("Cannot parse topic"));
|
|
20483
|
-
|
|
20536
|
+
D2("_parseUnsubscribe: push topic `%s` to unsubscriptions", r), e.unsubscriptions.push(r);
|
|
20484
20537
|
}
|
|
20485
20538
|
}
|
|
20486
20539
|
}
|
|
20487
20540
|
_parseUnsuback() {
|
|
20488
|
-
|
|
20541
|
+
D2("_parseUnsuback");
|
|
20489
20542
|
let e = this.packet;
|
|
20490
20543
|
if (!this._parseMessageId())
|
|
20491
20544
|
return this._emitError(new Error("Cannot parse messageId"));
|
|
@@ -20504,7 +20557,7 @@ var wd = M((AP, bd) => {
|
|
|
20504
20557
|
}
|
|
20505
20558
|
}
|
|
20506
20559
|
_parseConfirmation() {
|
|
20507
|
-
|
|
20560
|
+
D2("_parseConfirmation: packet.cmd: `%s`", this.packet.cmd);
|
|
20508
20561
|
let e = this.packet;
|
|
20509
20562
|
if (this._parseMessageId(), this.settings.protocolVersion === 5) {
|
|
20510
20563
|
if (e.length > 2) {
|
|
@@ -20520,7 +20573,7 @@ var wd = M((AP, bd) => {
|
|
|
20520
20573
|
return this._emitError(new Error("Invalid " + this.packet.cmd + " reason code"));
|
|
20521
20574
|
break;
|
|
20522
20575
|
}
|
|
20523
|
-
|
|
20576
|
+
D2("_parseConfirmation: packet.reasonCode `%d`", e.reasonCode);
|
|
20524
20577
|
} else
|
|
20525
20578
|
e.reasonCode = 0;
|
|
20526
20579
|
if (e.length > 3) {
|
|
@@ -20532,58 +20585,58 @@ var wd = M((AP, bd) => {
|
|
|
20532
20585
|
}
|
|
20533
20586
|
_parseDisconnect() {
|
|
20534
20587
|
let e = this.packet;
|
|
20535
|
-
if (
|
|
20588
|
+
if (D2("_parseDisconnect"), this.settings.protocolVersion === 5) {
|
|
20536
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;
|
|
20537
20590
|
let r = this._parseProperties();
|
|
20538
20591
|
Object.getOwnPropertyNames(r).length && (e.properties = r);
|
|
20539
20592
|
}
|
|
20540
|
-
return
|
|
20593
|
+
return D2("_parseDisconnect result: true"), true;
|
|
20541
20594
|
}
|
|
20542
20595
|
_parseAuth() {
|
|
20543
|
-
|
|
20596
|
+
D2("_parseAuth");
|
|
20544
20597
|
let e = this.packet;
|
|
20545
20598
|
if (this.settings.protocolVersion !== 5)
|
|
20546
20599
|
return this._emitError(new Error("Not supported auth packet for this version MQTT"));
|
|
20547
20600
|
if (e.reasonCode = this._parseByte(), !V.MQTT5_AUTH_CODES[e.reasonCode])
|
|
20548
20601
|
return this._emitError(new Error("Invalid auth reason code"));
|
|
20549
20602
|
let r = this._parseProperties();
|
|
20550
|
-
return Object.getOwnPropertyNames(r).length && (e.properties = r),
|
|
20603
|
+
return Object.getOwnPropertyNames(r).length && (e.properties = r), D2("_parseAuth: result: true"), true;
|
|
20551
20604
|
}
|
|
20552
20605
|
_parseMessageId() {
|
|
20553
20606
|
let e = this.packet;
|
|
20554
|
-
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);
|
|
20555
20608
|
}
|
|
20556
20609
|
_parseString(e) {
|
|
20557
20610
|
let r = this._parseNum(), i = r + this._pos;
|
|
20558
20611
|
if (r === -1 || i > this._list.length || i > this.packet.length)
|
|
20559
20612
|
return null;
|
|
20560
20613
|
let n = this._list.toString("utf8", this._pos, i);
|
|
20561
|
-
return this._pos += r,
|
|
20614
|
+
return this._pos += r, D2("_parseString: result: %s", n), n;
|
|
20562
20615
|
}
|
|
20563
20616
|
_parseStringPair() {
|
|
20564
|
-
return
|
|
20617
|
+
return D2("_parseStringPair"), { name: this._parseString(), value: this._parseString() };
|
|
20565
20618
|
}
|
|
20566
20619
|
_parseBuffer() {
|
|
20567
20620
|
let e = this._parseNum(), r = e + this._pos;
|
|
20568
20621
|
if (e === -1 || r > this._list.length || r > this.packet.length)
|
|
20569
20622
|
return null;
|
|
20570
20623
|
let i = this._list.slice(this._pos, r);
|
|
20571
|
-
return this._pos += e,
|
|
20624
|
+
return this._pos += e, D2("_parseBuffer: result: %o", i), i;
|
|
20572
20625
|
}
|
|
20573
20626
|
_parseNum() {
|
|
20574
20627
|
if (this._list.length - this._pos < 2)
|
|
20575
20628
|
return -1;
|
|
20576
20629
|
let e = this._list.readUInt16BE(this._pos);
|
|
20577
|
-
return this._pos += 2,
|
|
20630
|
+
return this._pos += 2, D2("_parseNum: result: %s", e), e;
|
|
20578
20631
|
}
|
|
20579
20632
|
_parse4ByteNum() {
|
|
20580
20633
|
if (this._list.length - this._pos < 4)
|
|
20581
20634
|
return -1;
|
|
20582
20635
|
let e = this._list.readUInt32BE(this._pos);
|
|
20583
|
-
return this._pos += 4,
|
|
20636
|
+
return this._pos += 4, D2("_parse4ByteNum: result: %s", e), e;
|
|
20584
20637
|
}
|
|
20585
20638
|
_parseVarByteNum(e) {
|
|
20586
|
-
|
|
20639
|
+
D2("_parseVarByteNum");
|
|
20587
20640
|
let r = 4, i = 0, n = 1, o = 0, s = false, a, u = this._pos ? this._pos : 0;
|
|
20588
20641
|
for (; i < r && u + i < this._list.length; ) {
|
|
20589
20642
|
if (a = this._list.readUInt8(u + i++), o += n * (a & V.VARBYTEINT_MASK), n *= 128, !(a & V.VARBYTEINT_FIN_MASK)) {
|
|
@@ -20593,14 +20646,14 @@ var wd = M((AP, bd) => {
|
|
|
20593
20646
|
if (this._list.length <= i)
|
|
20594
20647
|
break;
|
|
20595
20648
|
}
|
|
20596
|
-
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;
|
|
20597
20650
|
}
|
|
20598
20651
|
_parseByte() {
|
|
20599
20652
|
let e;
|
|
20600
|
-
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;
|
|
20601
20654
|
}
|
|
20602
20655
|
_parseByType(e) {
|
|
20603
|
-
switch (
|
|
20656
|
+
switch (D2("_parseByType: type: %s", e), e) {
|
|
20604
20657
|
case "byte":
|
|
20605
20658
|
return this._parseByte() !== 0;
|
|
20606
20659
|
case "int8":
|
|
@@ -20620,7 +20673,7 @@ var wd = M((AP, bd) => {
|
|
|
20620
20673
|
}
|
|
20621
20674
|
}
|
|
20622
20675
|
_parseProperties() {
|
|
20623
|
-
|
|
20676
|
+
D2("_parseProperties");
|
|
20624
20677
|
let e = this._parseVarByteNum(), i = this._pos + e, n = {};
|
|
20625
20678
|
for (; this._pos < i; ) {
|
|
20626
20679
|
let o = this._parseByte();
|
|
@@ -20648,10 +20701,10 @@ var wd = M((AP, bd) => {
|
|
|
20648
20701
|
return n;
|
|
20649
20702
|
}
|
|
20650
20703
|
_newPacket() {
|
|
20651
|
-
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;
|
|
20652
20705
|
}
|
|
20653
20706
|
_emitError(e) {
|
|
20654
|
-
|
|
20707
|
+
D2("_emitError", e), this.error = e, this.emit("error", e);
|
|
20655
20708
|
}
|
|
20656
20709
|
};
|
|
20657
20710
|
bd.exports = Fo;
|