@ray-js/wechat-mqtt 0.0.1-beta-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/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@ray-js/wechat-mqtt",
3
+ "version": "0.0.1-beta-1",
4
+ "publishConfig": {
5
+ "access": "public",
6
+ "registry": "https://registry.npmjs.org"
7
+ },
8
+ "module": "./index.esm.js",
9
+ "main": "./index.js",
10
+ "type": "module",
11
+ "types": "./src/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./src/index.d.ts",
15
+ "import": "./index.esm.js",
16
+ "require": "./index.js"
17
+ }
18
+ },
19
+ "dependencies": {
20
+ "mqtt": "4.1.0",
21
+ "js-md5": "0.7.3",
22
+ "@ray-js/wechat-tycrypto": "0.0.1",
23
+ "@ray-js/wechat-event": "0.0.1",
24
+ "@ray-js/wechat-request": "0.0.1",
25
+ "@ray-js/wechat-helper": "0.0.1",
26
+ "js-base64": "3.7.2"
27
+ },
28
+ "peerDependencies": {}
29
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,38 @@
1
+ export interface ConnectOptions {
2
+ clientId: string;
3
+ username: string;
4
+ password: string;
5
+ subscribeTopics: string;
6
+ keepalive: number;
7
+ url: string;
8
+ }
9
+ export interface MessageData {
10
+ topic: string;
11
+ payload: {
12
+ data: {
13
+ bizCode?: string;
14
+ devId: string;
15
+ status?: Record<string, any>;
16
+ bizData?: Record<string, any>;
17
+ };
18
+ protocol: number;
19
+ pv: string;
20
+ };
21
+ }
22
+ export declare type MQTTEventType = 'connect' | 'message' | 'packetsend' | 'packetreceive' | 'error' | 'close' | 'offline' | 'disconnect' | 'end';
23
+ /**
24
+ * 连接 mqtt
25
+ */
26
+ declare const connect: (needReopen?: boolean) => Promise<void>;
27
+ /**
28
+ * 销毁连接
29
+ * @param client
30
+ */
31
+ declare const destroy: () => void;
32
+ /**
33
+ * 消息监听
34
+ * @param cb
35
+ */
36
+ declare const onMessage: (cb: (data: MessageData) => void) => void;
37
+ declare const offMessage: (cb: (data: MessageData) => void) => void;
38
+ export { onMessage, offMessage, destroy, connect };