u8-mqtt 0.3.1 → 0.3.2-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 +2 -2
- package/cjs/index.cjs +33 -9
- package/cjs/index.cjs.map +1 -1
- package/cjs/v4.cjs +33 -9
- package/cjs/v4.cjs.map +1 -1
- package/cjs/v5.cjs +33 -9
- package/cjs/v5.cjs.map +1 -1
- package/code/core.jsy +41 -15
- package/code/{index.mjs → index.js} +1 -1
- package/code/{v4.mjs → v4.js} +1 -1
- package/code/{v5.mjs → v5.js} +1 -1
- package/code/version.js +1 -0
- package/esm/deno/index.js +38 -15
- package/esm/deno/index.js.map +1 -1
- package/esm/deno/v4.js +38 -15
- package/esm/deno/v4.js.map +1 -1
- package/esm/deno/v5.js +38 -15
- package/esm/deno/v5.js.map +1 -1
- package/esm/node/index.js +32 -8
- package/esm/node/index.js.map +1 -1
- package/esm/node/index.mjs +32 -8
- package/esm/node/index.mjs.map +1 -1
- package/esm/node/v4.js +32 -8
- package/esm/node/v4.js.map +1 -1
- package/esm/node/v4.mjs +32 -8
- package/esm/node/v4.mjs.map +1 -1
- package/esm/node/v5.js +32 -8
- package/esm/node/v5.js.map +1 -1
- package/esm/node/v5.mjs +32 -8
- package/esm/node/v5.mjs.map +1 -1
- package/esm/web/index.js +27 -4
- package/esm/web/index.js.map +1 -1
- package/esm/web/index.min.js +1 -1
- package/esm/web/index.min.js.br +0 -0
- package/esm/web/index.min.js.gz +0 -0
- package/esm/web/v4.js +27 -4
- package/esm/web/v4.js.map +1 -1
- package/esm/web/v4.min.js +1 -1
- package/esm/web/v4.min.js.br +0 -0
- package/esm/web/v4.min.js.gz +0 -0
- package/esm/web/v5.js +27 -4
- package/esm/web/v5.js.map +1 -1
- package/esm/web/v5.min.js +1 -1
- package/esm/web/v5.min.js.br +0 -0
- package/esm/web/v5.min.js.gz +0 -0
- package/package.json +5 -5
package/code/core.jsy
CHANGED
|
@@ -3,6 +3,7 @@ import { MQTTBase } from './base.jsy'
|
|
|
3
3
|
|
|
4
4
|
#IF PLAT_NODEJS
|
|
5
5
|
import {connect as tcp_connect} from 'node:net'
|
|
6
|
+
import {connect as tls_connect} from 'node:tls'
|
|
6
7
|
|
|
7
8
|
const pkt_api = {
|
|
8
9
|
utf8(u8) { return new TextDecoder('utf-8').decode(u8 || this.payload ) },
|
|
@@ -27,7 +28,7 @@ export class MQTTCore extends MQTTBase ::
|
|
|
27
28
|
return this
|
|
28
29
|
|
|
29
30
|
//log_conn(evt, arg, err_arg) ::
|
|
30
|
-
//console.info @ '[[u8-mqtt log: %s]]', evt, arg, err_arg
|
|
31
|
+
// console.info @ '[[u8-mqtt log: %s]]', evt, arg, err_arg
|
|
31
32
|
|
|
32
33
|
on_live(client, is_reconnect) ::
|
|
33
34
|
if is_reconnect ::
|
|
@@ -69,30 +70,55 @@ export class MQTTCore extends MQTTBase ::
|
|
|
69
70
|
return this
|
|
70
71
|
|
|
71
72
|
|
|
73
|
+
|
|
72
74
|
#IF PLAT_DENO
|
|
73
|
-
with_tcp(
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
with_tcp(...opt) ::
|
|
76
|
+
opt = this._conn_opt(opt)
|
|
77
|
+
opt.transport = 'tcp'
|
|
78
|
+
return this._use_conn @=>
|
|
79
|
+
this.with_deno_iter @
|
|
80
|
+
Deno.connect(opt)
|
|
76
81
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
82
|
+
with_tls(...opt) ::
|
|
83
|
+
opt = this._conn_opt(opt)
|
|
84
|
+
return this._use_conn @=>
|
|
85
|
+
this.with_deno_iter @
|
|
86
|
+
Deno.connectTls(opt)
|
|
80
87
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
88
|
+
with_deno_iter(conn) ::
|
|
89
|
+
return this.with_async_iter @
|
|
90
|
+
conn.then(Deno.iter),
|
|
91
|
+
async u8_pkt =>
|
|
92
|
+
(await conn).write(u8_pkt)
|
|
84
93
|
|
|
85
|
-
|
|
94
|
+
_conn_opt([a0, a1, a2]) ::
|
|
95
|
+
// (port, hostname, options) or (url, options)
|
|
96
|
+
if Number.isFinite(a0) ::
|
|
97
|
+
return {...a2, port: a0, hostname: a1}
|
|
86
98
|
|
|
99
|
+
a0 = new URL(a0)
|
|
100
|
+
return {...a1, port: a0.port, hostname: a0.hostname}
|
|
87
101
|
|
|
88
102
|
#IF PLAT_NODEJS
|
|
89
|
-
with_tcp(
|
|
90
|
-
|
|
91
|
-
|
|
103
|
+
with_tcp(...opt) ::
|
|
104
|
+
opt = this._conn_opt(opt)
|
|
105
|
+
console.log @: opt
|
|
106
|
+
return this._use_conn @=>
|
|
107
|
+
this.with_stream @
|
|
108
|
+
tcp_connect(opt)
|
|
92
109
|
|
|
110
|
+
with_tls(...opt) ::
|
|
111
|
+
opt = this._conn_opt(opt)
|
|
93
112
|
return this._use_conn @=>
|
|
94
113
|
this.with_stream @
|
|
95
|
-
|
|
114
|
+
tls_connect(opt)
|
|
115
|
+
|
|
116
|
+
_conn_opt([a0, a1, a2]) ::
|
|
117
|
+
// (port, hostname, options) or (url, options)
|
|
118
|
+
if Number.isFinite(a0) ::
|
|
119
|
+
return {...a2, port: a0, host: a1}
|
|
120
|
+
a0 = new URL(a0)
|
|
121
|
+
return {...a1, port: a0.port, host: a0.hostname}
|
|
96
122
|
|
|
97
123
|
|
|
98
124
|
with_stream(read_stream, write_stream) ::
|
package/code/{v4.mjs → v4.js}
RENAMED
package/code/{v5.mjs → v5.js}
RENAMED
package/code/version.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const version = 'GITREPO'
|
package/esm/deno/index.js
CHANGED
|
@@ -867,8 +867,6 @@ function mqtt_pkt_ctx(mqtt_level, opts, pkt_ctx) {
|
|
|
867
867
|
}
|
|
868
868
|
}
|
|
869
869
|
|
|
870
|
-
Object.freeze({ao_done: true});
|
|
871
|
-
|
|
872
870
|
function ao_defer_ctx(as_res = (...args) => args) {
|
|
873
871
|
let y,n,_pset = (a,b) => { y=a, n=b; };
|
|
874
872
|
return p =>(
|
|
@@ -1448,7 +1446,7 @@ class MQTTCore extends MQTTBase {
|
|
|
1448
1446
|
return this}
|
|
1449
1447
|
|
|
1450
1448
|
//log_conn(evt, arg, err_arg) ::
|
|
1451
|
-
//console.info @ '[[u8-mqtt log: %s]]', evt, arg, err_arg
|
|
1449
|
+
// console.info @ '[[u8-mqtt log: %s]]', evt, arg, err_arg
|
|
1452
1450
|
|
|
1453
1451
|
on_live(client, is_reconnect) {
|
|
1454
1452
|
if (is_reconnect) {
|
|
@@ -1490,23 +1488,48 @@ class MQTTCore extends MQTTBase {
|
|
|
1490
1488
|
return this}
|
|
1491
1489
|
|
|
1492
1490
|
|
|
1491
|
+
|
|
1492
|
+
|
|
1493
|
+
with_tcp(...opt) {
|
|
1494
|
+
opt = this._conn_opt(opt);
|
|
1495
|
+
opt.transport = 'tcp';
|
|
1496
|
+
return this._use_conn (() =>
|
|
1497
|
+
this.with_deno_iter(
|
|
1498
|
+
Deno.connect(opt)) ) }
|
|
1499
|
+
|
|
1500
|
+
with_tls(...opt) {
|
|
1501
|
+
opt = this._conn_opt(opt);
|
|
1502
|
+
return this._use_conn (() =>
|
|
1503
|
+
this.with_deno_iter(
|
|
1504
|
+
Deno.connectTls(opt)) ) }
|
|
1505
|
+
|
|
1506
|
+
with_deno_iter(conn) {
|
|
1507
|
+
return this.with_async_iter(
|
|
1508
|
+
conn.then(Deno.iter),
|
|
1509
|
+
async u8_pkt =>
|
|
1510
|
+
(await conn).write(u8_pkt)) }
|
|
1511
|
+
|
|
1512
|
+
_conn_opt([a0, a1, a2]) {
|
|
1513
|
+
// (port, hostname, options) or (url, options)
|
|
1514
|
+
if (Number.isFinite(a0)) {
|
|
1515
|
+
return {...a2, port: a0, hostname: a1}}
|
|
1516
|
+
|
|
1517
|
+
a0 = new URL(a0);
|
|
1518
|
+
return {...a1, port: a0.port, hostname: a0.hostname}}
|
|
1519
|
+
|
|
1493
1520
|
|
|
1494
|
-
with_tcp(port, hostname) {
|
|
1495
|
-
if (!Number.isFinite(port)) {
|
|
1496
|
-
({port, hostname} = new URL(port));}
|
|
1497
1521
|
|
|
1498
|
-
return this._use_conn (() => {
|
|
1499
|
-
let conn = Deno.connect({
|
|
1500
|
-
port, hostname, transport: 'tcp'});
|
|
1501
1522
|
|
|
1502
|
-
this.with_async_iter(
|
|
1503
|
-
conn.then(Deno.iter,)
|
|
1504
|
-
, async u8_pkt => (await conn).write(u8_pkt));
|
|
1505
1523
|
|
|
1506
|
-
return this}) }
|
|
1507
1524
|
|
|
1508
1525
|
|
|
1509
|
-
|
|
1526
|
+
|
|
1527
|
+
|
|
1528
|
+
|
|
1529
|
+
|
|
1530
|
+
|
|
1531
|
+
|
|
1532
|
+
|
|
1510
1533
|
|
|
1511
1534
|
|
|
1512
1535
|
|
|
@@ -1559,7 +1582,7 @@ class MQTTCore extends MQTTBase {
|
|
|
1559
1582
|
|
|
1560
1583
|
return this} }
|
|
1561
1584
|
|
|
1562
|
-
|
|
1585
|
+
const version = '0.3.2-0';
|
|
1563
1586
|
|
|
1564
1587
|
const MQTTClient_v4 = /* #__PURE__ */
|
|
1565
1588
|
MQTTCore.mqtt_ctx(4, mqtt_opts_v5);
|