mqtt-json-rpc 1.3.7 → 2.1.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 +25 -25
- package/dst/mqtt-json-rpc.cjs.js +5930 -0
- package/dst/mqtt-json-rpc.d.ts +33 -0
- package/dst/mqtt-json-rpc.esm.js +5931 -0
- package/dst/mqtt-json-rpc.js +287 -0
- package/dst/mqtt-json-rpc.umd.js +10 -0
- package/etc/eslint.mts +129 -0
- package/etc/stx.conf +29 -0
- package/etc/tsc.json +27 -0
- package/etc/tsc.tsbuildinfo +1 -0
- package/etc/vite.mts +45 -0
- package/package.json +45 -26
- package/sample/package.json +9 -10
- package/sample/sample.js +20 -26
- package/sample/sample.ts +34 -0
- package/sample/tsc.json +26 -0
- package/sample/tsc.tsbuildinfo +1 -0
- package/sample/vite.mjs +36 -0
- package/src/mqtt-json-rpc.ts +337 -0
- package/eslint.yaml +0 -66
- package/mqtt-json-rpc.js +0 -299
- package/sample/Gruntfile.js +0 -33
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { MqttClient } from "mqtt";
|
|
2
|
+
export type TopicRequestMake = (method: string) => string;
|
|
3
|
+
export type TopicResponseMake = (method: string, clientId: string) => string;
|
|
4
|
+
export type TopicRequestMatch = (topic: string) => RegExpMatchArray | null;
|
|
5
|
+
export type TopicResponseMatch = (topic: string) => RegExpMatchArray | null;
|
|
6
|
+
export interface APIOptions {
|
|
7
|
+
clientId: string;
|
|
8
|
+
encoding: "json" | "cbor" | "msgpack";
|
|
9
|
+
timeout: number;
|
|
10
|
+
topicRequestMake: TopicRequestMake;
|
|
11
|
+
topicResponseMake: TopicResponseMake;
|
|
12
|
+
topicRequestMatch: TopicRequestMatch;
|
|
13
|
+
topicResponseMatch: TopicResponseMatch;
|
|
14
|
+
}
|
|
15
|
+
export default class API {
|
|
16
|
+
private mqtt;
|
|
17
|
+
private options;
|
|
18
|
+
private encodr;
|
|
19
|
+
private registry;
|
|
20
|
+
private requests;
|
|
21
|
+
private subscriptions;
|
|
22
|
+
constructor(mqtt: MqttClient, options?: Partial<APIOptions>);
|
|
23
|
+
registered(method: string): boolean;
|
|
24
|
+
register<C extends ((...params: any[]) => any)>(method: string, callback: C): Promise<void>;
|
|
25
|
+
unregister(method: string): Promise<void>;
|
|
26
|
+
private _onServerMessage;
|
|
27
|
+
notify<P extends any[]>(method: string, ...params: P): void;
|
|
28
|
+
call<C extends ((...params: any[]) => any)>(method: string, ...params: Parameters<C>): Promise<ReturnType<C>>;
|
|
29
|
+
private _onClientMessage;
|
|
30
|
+
private _responseSubscribe;
|
|
31
|
+
private _responseUnsubscribe;
|
|
32
|
+
private _buildError;
|
|
33
|
+
}
|