@cnhongwei/react-native-mqtt 0.0.0-stage → 0.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/LICENSE +20 -0
- package/README.md +169 -2
- package/README.zh-CN.md +100 -0
- package/ReactNativeMqtt.podspec +28 -0
- package/THIRD_PARTY_NOTICES.md +17 -0
- package/android/build.gradle +70 -0
- package/android/consumer-rules.pro +10 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/cnhongwei/reactnativemqtt/MqttOptionsParser.kt +176 -0
- package/android/src/main/java/com/cnhongwei/reactnativemqtt/MqttSession.kt +1006 -0
- package/android/src/main/java/com/cnhongwei/reactnativemqtt/PahoLogger.java +44 -0
- package/android/src/main/java/com/cnhongwei/reactnativemqtt/PahoMqttTransport.kt +399 -0
- package/android/src/main/java/com/cnhongwei/reactnativemqtt/ReactNativeMqttModule.kt +619 -0
- package/android/src/main/java/com/cnhongwei/reactnativemqtt/ReactNativeMqttPackage.kt +31 -0
- package/ios/ReactNativeMqtt.h +15 -0
- package/ios/ReactNativeMqtt.mm +1184 -0
- package/ios/ReactNativeMqttCocoaTransport.swift +782 -0
- package/ios/ReactNativeMqttConnAckProbe.swift +87 -0
- package/ios/ReactNativeMqttSession.swift +420 -0
- package/lib/module/NativeReactNativeMqtt.js +5 -0
- package/lib/module/NativeReactNativeMqtt.js.map +1 -0
- package/lib/module/client.js +555 -0
- package/lib/module/client.js.map +1 -0
- package/lib/module/errors.js +20 -0
- package/lib/module/errors.js.map +1 -0
- package/lib/module/helpers.js +116 -0
- package/lib/module/helpers.js.map +1 -0
- package/lib/module/index.js +8 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/validation.js +306 -0
- package/lib/module/validation.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/NativeReactNativeMqtt.d.ts +154 -0
- package/lib/typescript/src/NativeReactNativeMqtt.d.ts.map +1 -0
- package/lib/typescript/src/client.d.ts +3 -0
- package/lib/typescript/src/client.d.ts.map +1 -0
- package/lib/typescript/src/errors.d.ts +18 -0
- package/lib/typescript/src/errors.d.ts.map +1 -0
- package/lib/typescript/src/helpers.d.ts +5 -0
- package/lib/typescript/src/helpers.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +9 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +161 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/lib/typescript/src/validation.d.ts +13 -0
- package/lib/typescript/src/validation.d.ts.map +1 -0
- package/package.json +188 -4
- package/react-native.config.js +1 -0
- package/src/NativeReactNativeMqtt.ts +173 -0
- package/src/client.ts +859 -0
- package/src/errors.ts +51 -0
- package/src/helpers.ts +151 -0
- package/src/index.ts +30 -0
- package/src/types.ts +184 -0
- package/src/validation.ts +735 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { type CodegenTypes, type TurboModule } from 'react-native';
|
|
2
|
+
export type WireUserProperty = {
|
|
3
|
+
key: string;
|
|
4
|
+
value: string;
|
|
5
|
+
};
|
|
6
|
+
export type WireCapabilities = {
|
|
7
|
+
wireVersion: number;
|
|
8
|
+
platform: string;
|
|
9
|
+
protocolVersions: number[];
|
|
10
|
+
transports: string[];
|
|
11
|
+
supportsSessionPresent: boolean;
|
|
12
|
+
supportsDuplicateUserProperties: boolean;
|
|
13
|
+
};
|
|
14
|
+
export type WireSessionOptions = {
|
|
15
|
+
host: string;
|
|
16
|
+
port: number;
|
|
17
|
+
protocolVersion?: number;
|
|
18
|
+
transport?: string;
|
|
19
|
+
path?: string;
|
|
20
|
+
clientId?: string;
|
|
21
|
+
username?: string;
|
|
22
|
+
password?: string;
|
|
23
|
+
keepAliveSeconds?: number;
|
|
24
|
+
connectTimeoutMs?: number;
|
|
25
|
+
operationTimeoutMs?: number;
|
|
26
|
+
disconnectTimeoutMs?: number;
|
|
27
|
+
reconnectEnabled?: boolean;
|
|
28
|
+
reconnectInitialDelayMs?: number;
|
|
29
|
+
reconnectMaxDelayMs?: number;
|
|
30
|
+
reconnectJitterRatio?: number;
|
|
31
|
+
tlsCaBase64?: string;
|
|
32
|
+
tlsP12Base64?: string;
|
|
33
|
+
tlsP12Password?: string;
|
|
34
|
+
tlsInsecure?: boolean;
|
|
35
|
+
tlsAllowInvalidHostnameForTesting?: boolean;
|
|
36
|
+
willTopic?: string;
|
|
37
|
+
willPayloadBase64?: string;
|
|
38
|
+
willQos?: number;
|
|
39
|
+
willRetained?: boolean;
|
|
40
|
+
cleanSession?: boolean;
|
|
41
|
+
cleanStart?: boolean;
|
|
42
|
+
sessionExpiryIntervalSeconds?: number;
|
|
43
|
+
receiveMaximum?: number;
|
|
44
|
+
userProperties?: WireUserProperty[];
|
|
45
|
+
maxQueuedMessages?: number;
|
|
46
|
+
maxQueuedBytes?: number;
|
|
47
|
+
maxMessageBytes?: number;
|
|
48
|
+
batchMaxMessages?: number;
|
|
49
|
+
batchMaxBytes?: number;
|
|
50
|
+
batchAckTimeoutMs?: number;
|
|
51
|
+
overflowPolicy?: string;
|
|
52
|
+
};
|
|
53
|
+
export type WireSubscribeOptions = {
|
|
54
|
+
qos?: number;
|
|
55
|
+
noLocal?: boolean;
|
|
56
|
+
retainAsPublished?: boolean;
|
|
57
|
+
retainHandling?: number;
|
|
58
|
+
};
|
|
59
|
+
export type WirePublishRequest = {
|
|
60
|
+
topic: string;
|
|
61
|
+
payloadBase64: string;
|
|
62
|
+
qos?: number;
|
|
63
|
+
retained?: boolean;
|
|
64
|
+
userProperties?: WireUserProperty[];
|
|
65
|
+
contentType?: string;
|
|
66
|
+
responseTopic?: string;
|
|
67
|
+
correlationDataBase64?: string;
|
|
68
|
+
messageExpiryIntervalSeconds?: number;
|
|
69
|
+
payloadFormatIndicator?: number;
|
|
70
|
+
};
|
|
71
|
+
export type WireConnAck = {
|
|
72
|
+
sessionPresent: boolean;
|
|
73
|
+
assignedClientId?: string;
|
|
74
|
+
reasonCode?: number;
|
|
75
|
+
reasonString?: string;
|
|
76
|
+
userProperties?: WireUserProperty[];
|
|
77
|
+
};
|
|
78
|
+
export type WireSnapshot = {
|
|
79
|
+
instanceId: string;
|
|
80
|
+
revision: number;
|
|
81
|
+
generation: number;
|
|
82
|
+
state: string;
|
|
83
|
+
lastConnAck: WireConnAck | null;
|
|
84
|
+
subscriptionsRevision: number;
|
|
85
|
+
subscriptionsStatus: string;
|
|
86
|
+
deliveryStatus: string;
|
|
87
|
+
};
|
|
88
|
+
export type WireMessage = {
|
|
89
|
+
instanceId: string;
|
|
90
|
+
generation: number;
|
|
91
|
+
topic: string;
|
|
92
|
+
payloadBase64: string;
|
|
93
|
+
qos: number;
|
|
94
|
+
retained: boolean;
|
|
95
|
+
userProperties?: WireUserProperty[];
|
|
96
|
+
contentType?: string;
|
|
97
|
+
responseTopic?: string;
|
|
98
|
+
correlationDataBase64?: string;
|
|
99
|
+
messageExpiryIntervalSeconds?: number;
|
|
100
|
+
payloadFormatIndicator?: number;
|
|
101
|
+
};
|
|
102
|
+
export type WireBatch = {
|
|
103
|
+
instanceId: string;
|
|
104
|
+
streamEpoch: number;
|
|
105
|
+
batchId: number;
|
|
106
|
+
messages: WireMessage[];
|
|
107
|
+
};
|
|
108
|
+
export type WireDiagnostic = {
|
|
109
|
+
instanceId: string;
|
|
110
|
+
generation: number;
|
|
111
|
+
code: string;
|
|
112
|
+
message: string;
|
|
113
|
+
operation?: string;
|
|
114
|
+
reasonCode?: number;
|
|
115
|
+
reasonString?: string;
|
|
116
|
+
metrics?: {
|
|
117
|
+
queuedMessages: number;
|
|
118
|
+
queuedBytes: number;
|
|
119
|
+
pendingOperations: number;
|
|
120
|
+
droppedMessages: number;
|
|
121
|
+
reconnectAttempts: number;
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
export type WireSubscriptionResult = {
|
|
125
|
+
generation: number;
|
|
126
|
+
intentRevision: number;
|
|
127
|
+
grantedQos: number;
|
|
128
|
+
reasonCode?: number;
|
|
129
|
+
};
|
|
130
|
+
export type WireIntentResult = {
|
|
131
|
+
intentRevision: number;
|
|
132
|
+
};
|
|
133
|
+
export interface Spec extends TurboModule {
|
|
134
|
+
getCapabilities(): Promise<WireCapabilities>;
|
|
135
|
+
openSession(instanceId: string, options: WireSessionOptions): Promise<WireSnapshot>;
|
|
136
|
+
connect(instanceId: string): Promise<{
|
|
137
|
+
snapshot: WireSnapshot;
|
|
138
|
+
ack: WireConnAck;
|
|
139
|
+
}>;
|
|
140
|
+
disconnect(instanceId: string): Promise<WireSnapshot>;
|
|
141
|
+
close(instanceId: string): Promise<WireSnapshot>;
|
|
142
|
+
getSnapshot(instanceId: string): Promise<WireSnapshot>;
|
|
143
|
+
setSubscription(instanceId: string, filter: string, options: WireSubscribeOptions, intentRevision: number): Promise<WireSubscriptionResult>;
|
|
144
|
+
removeSubscription(instanceId: string, filter: string, intentRevision: number): Promise<WireIntentResult>;
|
|
145
|
+
awaitSubscriptions(instanceId: string, generation: number, desiredRevision: number): Promise<WireSnapshot>;
|
|
146
|
+
publish(instanceId: string, request: WirePublishRequest): Promise<void>;
|
|
147
|
+
ackMessageBatch(instanceId: string, streamEpoch: number, batchId: number): Promise<void>;
|
|
148
|
+
readonly onSessionSnapshot: CodegenTypes.EventEmitter<WireSnapshot>;
|
|
149
|
+
readonly onMessageBatch: CodegenTypes.EventEmitter<WireBatch>;
|
|
150
|
+
readonly onDiagnostic: CodegenTypes.EventEmitter<WireDiagnostic>;
|
|
151
|
+
}
|
|
152
|
+
declare const _default: Spec | null | undefined;
|
|
153
|
+
export default _default;
|
|
154
|
+
//# sourceMappingURL=NativeReactNativeMqtt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NativeReactNativeMqtt.d.ts","sourceRoot":"","sources":["../../../src/NativeReactNativeMqtt.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,YAA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ACrB,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACnC,kBAAkB,CAChB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC7B,kBAAkB,CAChB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,YAAY,CAAC,CAAC;IACzB,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxE,eAAe,CACb,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,QAAQ,CAAC,iBAAiB,EAAE,YAAY,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;IACpE,QAAQ,CAAC,cAAc,EAAE,YAAY,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IAC9D,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;CAClE;;AAED,wBAAgE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/client.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAMV,UAAU,EACV,WAAW,EAIZ,MAAM,YAAS,CAAC;AAiKjB,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,GAAG,UAAU,CAoqB/D"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type MqttErrorCode = 'ERR_INVALID_OPTIONS' | 'ERR_INVALID_PAYLOAD' | 'ERR_NATIVE_UNAVAILABLE' | 'ERR_CONTRACT_MISMATCH' | 'ERR_NOT_CONNECTED' | 'ERR_DISPOSED' | 'ERR_OPERATION_IN_PROGRESS' | 'ERR_OPERATION_SUPERSEDED' | 'ERR_CONNECT_TIMEOUT' | 'ERR_OPERATION_TIMEOUT' | 'ERR_CONNECTION_REFUSED' | 'ERR_CONNECTION_LOST' | 'ERR_SUBSCRIPTION_CONFLICT' | 'ERR_SUBSCRIBE_FAILED' | 'ERR_UNSUBSCRIBE_FAILED' | 'ERR_PUBLISH_FAILED' | 'ERR_TLS' | 'ERR_CLEANUP_FAILED' | 'ERR_UNKNOWN';
|
|
2
|
+
export declare class MqttError extends Error {
|
|
3
|
+
readonly code: MqttErrorCode;
|
|
4
|
+
readonly operation?: string;
|
|
5
|
+
readonly generation?: number;
|
|
6
|
+
readonly reasonCode?: number;
|
|
7
|
+
readonly reasonString?: string;
|
|
8
|
+
readonly outcome?: 'not-sent' | 'rejected' | 'unknown';
|
|
9
|
+
constructor(code: MqttErrorCode, message: string, details?: {
|
|
10
|
+
operation?: string;
|
|
11
|
+
generation?: number;
|
|
12
|
+
reasonCode?: number;
|
|
13
|
+
reasonString?: string;
|
|
14
|
+
outcome?: 'not-sent' | 'rejected' | 'unknown';
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
export declare function invalidOptions(message: string): MqttError;
|
|
18
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GACrB,qBAAqB,GACrB,qBAAqB,GACrB,wBAAwB,GACxB,uBAAuB,GACvB,mBAAmB,GACnB,cAAc,GACd,2BAA2B,GAC3B,0BAA0B,GAC1B,qBAAqB,GACrB,uBAAuB,GACvB,wBAAwB,GACxB,qBAAqB,GACrB,2BAA2B,GAC3B,sBAAsB,GACtB,wBAAwB,GACxB,oBAAoB,GACpB,SAAS,GACT,oBAAoB,GACpB,aAAa,CAAC;AAClB,qBAAa,SAAU,SAAQ,KAAK;IAClC,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,OAAO,CAAC,EAAE,UAAU,GAAG,UAAU,GAAG,SAAS,CAAC;gBAErD,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;QACP,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,OAAO,CAAC,EAAE,UAAU,GAAG,UAAU,GAAG,SAAS,CAAC;KAC1C;CAWT;AACD,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAEzD"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function encodeUtf8(text: string): Uint8Array;
|
|
2
|
+
export declare function decodeUtf8(bytes: Uint8Array): string;
|
|
3
|
+
export declare function encodeBase64(bytes: Uint8Array): string;
|
|
4
|
+
export declare function decodeBase64(text: string): Uint8Array;
|
|
5
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/helpers.ts"],"names":[],"mappings":"AAuBA,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAInD;AACD,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAyEpD;AAGD,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAatD;AACD,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAgCrD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type { Spec as NativeReactNativeMqttSpec } from './NativeReactNativeMqtt.js';
|
|
2
|
+
export { MqttError } from './errors.js';
|
|
3
|
+
export type { MqttErrorCode } from './errors.js';
|
|
4
|
+
export { createMqttClient } from './client.js';
|
|
5
|
+
export { decodeBase64, decodeUtf8, encodeBase64, encodeUtf8 } from './helpers.js';
|
|
6
|
+
export type { ConnAck, ConnectionState, DeliveryOptions, Diagnostic, Listener, Message, Mqtt4Options, Mqtt5Options, MqttClient, MqttOptions, PublishOptions, QoS, ReconnectOptions, SessionSnapshot, SubscribeOptions, Subscription, TlsOptions, Transport, UserProperty, WillOptions, } from './types.js';
|
|
7
|
+
export declare const packageName: "@cnhongwei/react-native-mqtt";
|
|
8
|
+
export declare const packageVersion: "0.1.0";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,IAAI,IAAI,yBAAyB,EAAE,MAAM,4BAAyB,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,MAAM,aAAU,CAAC;AACrC,YAAY,EAAE,aAAa,EAAE,MAAM,aAAU,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAU,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,cAAW,CAAC;AAC/E,YAAY,EACV,OAAO,EACP,eAAe,EACf,eAAe,EACf,UAAU,EACV,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,WAAW,EACX,cAAc,EACd,GAAG,EACH,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,UAAU,EACV,SAAS,EACT,YAAY,EACZ,WAAW,GACZ,MAAM,YAAS,CAAC;AAEjB,eAAO,MAAM,WAAW,EAAG,8BAAuC,CAAC;AACnE,eAAO,MAAM,cAAc,EAAG,OAAgB,CAAC"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
export type QoS = 0 | 1 | 2;
|
|
2
|
+
export type Transport = 'tcp' | 'tls' | 'ws' | 'wss';
|
|
3
|
+
export type ConnectionState = 'idle' | 'connecting' | 'connected' | 'reconnecting' | 'disconnecting' | 'disconnected' | 'closed';
|
|
4
|
+
export type UserProperty = {
|
|
5
|
+
key: string;
|
|
6
|
+
value: string;
|
|
7
|
+
};
|
|
8
|
+
export type TlsOptions = {
|
|
9
|
+
caBase64?: string;
|
|
10
|
+
p12Base64?: string;
|
|
11
|
+
p12Password?: string;
|
|
12
|
+
insecure?: boolean;
|
|
13
|
+
allowInvalidHostnameForTesting?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export type ReconnectOptions = {
|
|
16
|
+
enabled?: boolean;
|
|
17
|
+
initialDelayMs?: number;
|
|
18
|
+
maxDelayMs?: number;
|
|
19
|
+
jitterRatio?: number;
|
|
20
|
+
};
|
|
21
|
+
export type DeliveryOptions = {
|
|
22
|
+
maxQueuedMessages?: number;
|
|
23
|
+
maxQueuedBytes?: number;
|
|
24
|
+
maxMessageBytes?: number;
|
|
25
|
+
batchMaxMessages?: number;
|
|
26
|
+
batchMaxBytes?: number;
|
|
27
|
+
batchAckTimeoutMs?: number;
|
|
28
|
+
overflowPolicy?: 'disconnect' | 'drop-newest';
|
|
29
|
+
};
|
|
30
|
+
export type WillOptions = {
|
|
31
|
+
topic: string;
|
|
32
|
+
payloadBase64: string;
|
|
33
|
+
qos?: QoS;
|
|
34
|
+
retained?: boolean;
|
|
35
|
+
};
|
|
36
|
+
export type CommonMqttOptions = {
|
|
37
|
+
host: string;
|
|
38
|
+
port: number;
|
|
39
|
+
transport?: Transport;
|
|
40
|
+
path?: string;
|
|
41
|
+
clientId?: string;
|
|
42
|
+
username?: string;
|
|
43
|
+
password?: string;
|
|
44
|
+
keepAliveSeconds?: number;
|
|
45
|
+
connectTimeoutMs?: number;
|
|
46
|
+
operationTimeoutMs?: number;
|
|
47
|
+
disconnectTimeoutMs?: number;
|
|
48
|
+
reconnect?: ReconnectOptions;
|
|
49
|
+
tls?: TlsOptions;
|
|
50
|
+
will?: WillOptions;
|
|
51
|
+
delivery?: DeliveryOptions;
|
|
52
|
+
};
|
|
53
|
+
export type Mqtt4Options = CommonMqttOptions & {
|
|
54
|
+
/** MQTT 3.1.1 (default). MQTT 3.1 / protocol level 3 is unsupported. */
|
|
55
|
+
protocolVersion?: 4;
|
|
56
|
+
cleanSession?: boolean;
|
|
57
|
+
cleanStart?: never;
|
|
58
|
+
sessionExpiryIntervalSeconds?: never;
|
|
59
|
+
receiveMaximum?: never;
|
|
60
|
+
userProperties?: never;
|
|
61
|
+
};
|
|
62
|
+
export type Mqtt5Options = CommonMqttOptions & {
|
|
63
|
+
/** MQTT 5.0. Only protocol levels 4 and 5 are supported on Android/iOS. */
|
|
64
|
+
protocolVersion: 5;
|
|
65
|
+
cleanSession?: never;
|
|
66
|
+
cleanStart?: boolean;
|
|
67
|
+
sessionExpiryIntervalSeconds?: number;
|
|
68
|
+
receiveMaximum?: number;
|
|
69
|
+
userProperties?: UserProperty[];
|
|
70
|
+
};
|
|
71
|
+
export type MqttOptions = Mqtt4Options | Mqtt5Options;
|
|
72
|
+
export type SubscribeOptions = {
|
|
73
|
+
qos?: QoS;
|
|
74
|
+
noLocal?: boolean;
|
|
75
|
+
retainAsPublished?: boolean;
|
|
76
|
+
retainHandling?: 0 | 1 | 2;
|
|
77
|
+
};
|
|
78
|
+
export type PublishOptions = {
|
|
79
|
+
qos?: QoS;
|
|
80
|
+
retained?: boolean;
|
|
81
|
+
userProperties?: UserProperty[];
|
|
82
|
+
contentType?: string;
|
|
83
|
+
responseTopic?: string;
|
|
84
|
+
correlationDataBase64?: string;
|
|
85
|
+
messageExpiryIntervalSeconds?: number;
|
|
86
|
+
payloadFormatIndicator?: 0 | 1;
|
|
87
|
+
};
|
|
88
|
+
export type ConnAck = {
|
|
89
|
+
sessionPresent: boolean;
|
|
90
|
+
assignedClientId?: string;
|
|
91
|
+
reasonCode?: number;
|
|
92
|
+
reasonString?: string;
|
|
93
|
+
userProperties?: UserProperty[];
|
|
94
|
+
};
|
|
95
|
+
export type SessionSnapshot = {
|
|
96
|
+
instanceId: string;
|
|
97
|
+
revision: number;
|
|
98
|
+
generation: number;
|
|
99
|
+
state: ConnectionState;
|
|
100
|
+
lastConnAck: ConnAck | null;
|
|
101
|
+
subscriptionsRevision: number;
|
|
102
|
+
subscriptionsStatus: 'pending' | 'ready' | 'failed';
|
|
103
|
+
deliveryStatus: 'active' | 'stalled' | 'closed';
|
|
104
|
+
};
|
|
105
|
+
export type Message = {
|
|
106
|
+
instanceId: string;
|
|
107
|
+
generation: number;
|
|
108
|
+
topic: string;
|
|
109
|
+
bytes: Uint8Array;
|
|
110
|
+
qos: QoS;
|
|
111
|
+
retained: boolean;
|
|
112
|
+
userProperties?: UserProperty[];
|
|
113
|
+
contentType?: string;
|
|
114
|
+
responseTopic?: string;
|
|
115
|
+
correlationData?: Uint8Array;
|
|
116
|
+
messageExpiryIntervalSeconds?: number;
|
|
117
|
+
payloadFormatIndicator?: 0 | 1;
|
|
118
|
+
};
|
|
119
|
+
export type Diagnostic = {
|
|
120
|
+
instanceId: string;
|
|
121
|
+
generation: number;
|
|
122
|
+
code: 'SUBSCRIPTION_SYNC_FAILED' | 'DELIVERY_STALLED' | 'QUEUE_OVERFLOW' | 'LISTENER_ERROR' | 'INSECURE_TLS';
|
|
123
|
+
message: string;
|
|
124
|
+
operation?: string;
|
|
125
|
+
reasonCode?: number;
|
|
126
|
+
reasonString?: string;
|
|
127
|
+
metrics?: {
|
|
128
|
+
queuedMessages: number;
|
|
129
|
+
queuedBytes: number;
|
|
130
|
+
pendingOperations: number;
|
|
131
|
+
droppedMessages: number;
|
|
132
|
+
reconnectAttempts: number;
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
export type Listener = {
|
|
136
|
+
remove(): void;
|
|
137
|
+
};
|
|
138
|
+
export type Subscription = {
|
|
139
|
+
readonly topicFilter: string;
|
|
140
|
+
readonly qos: QoS;
|
|
141
|
+
unsubscribe(): Promise<void>;
|
|
142
|
+
};
|
|
143
|
+
export type MqttClient = {
|
|
144
|
+
readonly instanceId: string;
|
|
145
|
+
readonly clientId: string;
|
|
146
|
+
readonly state: ConnectionState;
|
|
147
|
+
connect(): Promise<ConnAck>;
|
|
148
|
+
disconnect(): Promise<void>;
|
|
149
|
+
dispose(): Promise<void>;
|
|
150
|
+
ready(): Promise<void>;
|
|
151
|
+
getSnapshot(): Promise<SessionSnapshot>;
|
|
152
|
+
subscribe(topicFilter: string, options?: SubscribeOptions): Promise<Subscription>;
|
|
153
|
+
publishText(topic: string, text: string, options?: PublishOptions): Promise<void>;
|
|
154
|
+
publishBytes(topic: string, bytes: Uint8Array, options?: PublishOptions): Promise<void>;
|
|
155
|
+
publishBase64(topic: string, base64: string, options?: PublishOptions): Promise<void>;
|
|
156
|
+
onStateChange(listener: (snapshot: SessionSnapshot) => void): Listener;
|
|
157
|
+
onMessage(listener: (message: Message) => void): Listener;
|
|
158
|
+
onDiagnostic(listener: (diagnostic: Diagnostic) => void): Listener;
|
|
159
|
+
readonly [Symbol.asyncDispose]?: () => Promise<void>;
|
|
160
|
+
};
|
|
161
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC5B,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,CAAC;AACrD,MAAM,MAAM,eAAe,GACvB,MAAM,GACN,YAAY,GACZ,WAAW,GACX,cAAc,GACd,eAAe,GACf,cAAc,GACd,QAAQ,CAAC;AACb,MAAM,MAAM,YAAY,GAAG;IAAE,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AAC,IAAI,CAAC,CAAC;IACvB,WAAW,IAAI,OAAO,CAAC,eAAe,CAAC,CAAC;IACxC,SAAS,CACP,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,YAAY,CAAC,CAAC;IACzB,WAAW,CACT,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,YAAY,CACV,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,UAAU,EACjB,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,aAAa,CACX,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,aAAa,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,IAAI,GAAG,QAAQ,CAAC;IACvE,SAAS,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,GAAG,QAAQ,CAAC;IAC1D,YAAY,CAAC,QAAQ,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,GAAG,QAAQ,CAAC;IACnE,QAAQ,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACtD,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { encodeBase64 } from './helpers.js';
|
|
2
|
+
import type { MqttOptions, PublishOptions, SubscribeOptions } from './types.js';
|
|
3
|
+
import type { WirePublishRequest, WireSessionOptions, WireSubscribeOptions } from './NativeReactNativeMqtt.js';
|
|
4
|
+
export declare function normalizeOptions(input: MqttOptions): MqttOptions;
|
|
5
|
+
export declare function validateTopicName(topic: string): void;
|
|
6
|
+
export declare function validateTopicFilter(filter: string): void;
|
|
7
|
+
export declare function normalizeSubscribeOptions(input: SubscribeOptions | undefined, protocolVersion?: 4 | 5): SubscribeOptions;
|
|
8
|
+
export declare function normalizePublishOptions(input: PublishOptions | undefined, protocolVersion?: 4 | 5): PublishOptions;
|
|
9
|
+
export declare function toWireSessionOptions(options: MqttOptions): WireSessionOptions;
|
|
10
|
+
export declare function toWireSubscribeOptions(options: SubscribeOptions | undefined): WireSubscribeOptions;
|
|
11
|
+
export declare function toWirePublishRequest(topic: string, payloadBase64: string, options: PublishOptions | undefined, protocolVersion?: 4 | 5): WirePublishRequest;
|
|
12
|
+
export { encodeBase64 };
|
|
13
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../src/validation.ts"],"names":[],"mappings":"AACA,OAAO,EAA4B,YAAY,EAAc,MAAM,cAAW,CAAC;AAC/E,OAAO,KAAK,EAGV,WAAW,EACX,cAAc,EAEd,gBAAgB,EAKjB,MAAM,YAAS,CAAC;AACjB,OAAO,KAAK,EACV,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EAErB,MAAM,4BAAyB,CAAC;AAuYjC,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,GAAG,WAAW,CA+DhE;AACD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAUrD;AACD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAiBxD;AACD,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,gBAAgB,GAAG,SAAS,EACnC,eAAe,GAAE,CAAC,GAAG,CAAK,GACzB,gBAAgB,CA+ClB;AACD,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,cAAc,GAAG,SAAS,EACjC,eAAe,GAAE,CAAC,GAAG,CAAK,GACzB,cAAc,CAoFhB;AACD,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,WAAW,GAAG,kBAAkB,CAoD7E;AAID,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,gBAAgB,GAAG,SAAS,GACpC,oBAAoB,CAQtB;AACD,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,EACb,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,cAAc,GAAG,SAAS,EACnC,eAAe,GAAE,CAAC,GAAG,CAAK,GACzB,kBAAkB,CAmBpB;AACD,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,190 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cnhongwei/react-native-mqtt",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Native MQTT 3.1.1 and 5 client for React Native on Android and iOS",
|
|
5
|
+
"main": "./lib/module/index.js",
|
|
6
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"source": "./src/index.ts",
|
|
10
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
11
|
+
"default": "./lib/module/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"src",
|
|
17
|
+
"lib",
|
|
18
|
+
"android",
|
|
19
|
+
"ios",
|
|
20
|
+
"*.podspec",
|
|
21
|
+
"react-native.config.js",
|
|
22
|
+
"LICENSE",
|
|
23
|
+
"THIRD_PARTY_NOTICES.md",
|
|
24
|
+
"README.md",
|
|
25
|
+
"README.zh-CN.md",
|
|
26
|
+
"!ios/build",
|
|
27
|
+
"!android/build",
|
|
28
|
+
"!android/**/build",
|
|
29
|
+
"!build",
|
|
30
|
+
"!build/**",
|
|
31
|
+
"!openspec",
|
|
32
|
+
"!openspec/**",
|
|
33
|
+
"!android/gradle",
|
|
34
|
+
"!android/gradlew",
|
|
35
|
+
"!android/gradlew.bat",
|
|
36
|
+
"!android/local.properties",
|
|
37
|
+
"!android/src/test",
|
|
38
|
+
"!android/src/test/**",
|
|
39
|
+
"!android/src/androidTest",
|
|
40
|
+
"!android/src/androidTest/**",
|
|
41
|
+
"!ios/Tests",
|
|
42
|
+
"!ios/Tests/**",
|
|
43
|
+
"!test",
|
|
44
|
+
"!test/**",
|
|
45
|
+
"!examples",
|
|
46
|
+
"!examples/**",
|
|
47
|
+
"!**/__tests__",
|
|
48
|
+
"!**/__fixtures__",
|
|
49
|
+
"!**/__mocks__",
|
|
50
|
+
"!**/.*"
|
|
51
|
+
],
|
|
52
|
+
"scripts": {
|
|
53
|
+
"example": "yarn workspace @cnhongwei/react-native-mqtt-example",
|
|
54
|
+
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
|
55
|
+
"build": "bob build",
|
|
56
|
+
"prepare": "bob build",
|
|
57
|
+
"typecheck": "tsc --noEmit",
|
|
58
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
59
|
+
"test": "jest --runInBand",
|
|
60
|
+
"codegen": "node scripts/codegen.mjs",
|
|
61
|
+
"test:android": "yarn workspace @cnhongwei/react-native-mqtt-example build:android",
|
|
62
|
+
"test:ios": "yarn workspace @cnhongwei/react-native-mqtt-example build:ios",
|
|
63
|
+
"test:ios:scenarios": "swift test --package-path ios/Tests",
|
|
64
|
+
"test:ios:public-matrix": "node scripts/ios-public-matrix.mjs",
|
|
65
|
+
"test:swift-session": "node scripts/swift-session-smoke.mjs",
|
|
66
|
+
"build:android": "yarn workspace @cnhongwei/react-native-mqtt-example android",
|
|
67
|
+
"build:ios": "yarn workspace @cnhongwei/react-native-mqtt-example ios",
|
|
68
|
+
"test:integration": "node scripts/integration.mjs",
|
|
69
|
+
"test:scenarios": "node scripts/scenario-primitives-smoke.mjs",
|
|
70
|
+
"test:examples": "node scripts/example-surface-smoke.mjs",
|
|
71
|
+
"test:diagnostics": "node scripts/diagnostic-safety-smoke.mjs",
|
|
72
|
+
"test:delivery-benchmark": "node scripts/delivery-benchmark.mjs",
|
|
73
|
+
"test:capabilities": "node scripts/backend-capability-smoke.mjs",
|
|
74
|
+
"test:desugaring": "node scripts/desugaring-smoke.mjs",
|
|
75
|
+
"test:manifest": "node scripts/manifest-audit.mjs",
|
|
76
|
+
"test:expo": "node scripts/expo.mjs",
|
|
77
|
+
"test:consumer": "node scripts/consumer-smoke.mjs",
|
|
78
|
+
"test:consumer-runtime": "node scripts/consumer-runtime-smoke.mjs",
|
|
79
|
+
"test:package": "node scripts/package-smoke.mjs",
|
|
80
|
+
"verify": "node scripts/verify.mjs"
|
|
81
|
+
},
|
|
82
|
+
"keywords": [
|
|
83
|
+
"react-native",
|
|
84
|
+
"ios",
|
|
85
|
+
"android"
|
|
86
|
+
],
|
|
87
|
+
"author": "cnhongwei",
|
|
88
|
+
"license": "MIT",
|
|
89
|
+
"homepage": "https://github.com/cnhongwei/react-native-mqtt#readme",
|
|
90
|
+
"repository": {
|
|
91
|
+
"type": "git",
|
|
92
|
+
"url": "git+https://github.com/cnhongwei/react-native-mqtt.git"
|
|
93
|
+
},
|
|
94
|
+
"bugs": {
|
|
95
|
+
"url": "https://github.com/cnhongwei/react-native-mqtt/issues"
|
|
96
|
+
},
|
|
97
|
+
"publishConfig": {
|
|
98
|
+
"access": "public",
|
|
99
|
+
"registry": "https://registry.npmjs.org/"
|
|
100
|
+
},
|
|
101
|
+
"devDependencies": {
|
|
102
|
+
"@eslint/compat": "^2.1.0",
|
|
103
|
+
"@eslint/eslintrc": "^3.3.6",
|
|
104
|
+
"@eslint/js": "^9.39.5",
|
|
105
|
+
"@jest/globals": "^29.7.0",
|
|
106
|
+
"@react-native-community/cli": "20.1.0",
|
|
107
|
+
"@react-native/babel-preset": "0.86.2",
|
|
108
|
+
"@react-native/eslint-config": "0.86.2",
|
|
109
|
+
"@react-native/jest-preset": "0.86.2",
|
|
110
|
+
"@types/jest": "29.5.14",
|
|
111
|
+
"@types/react": "^19.2.0",
|
|
112
|
+
"del-cli": "^7.0.0",
|
|
113
|
+
"eslint": "8.57.1",
|
|
114
|
+
"eslint-config-prettier": "^10.1.8",
|
|
115
|
+
"eslint-plugin-ft-flow": "^3.0.11",
|
|
116
|
+
"eslint-plugin-prettier": "^5.5.6",
|
|
117
|
+
"jest": "^29.7.0",
|
|
118
|
+
"prettier": "^3.9.6",
|
|
119
|
+
"react": "19.2.3",
|
|
120
|
+
"react-native": "0.86.2",
|
|
121
|
+
"react-native-builder-bob": "0.43.0",
|
|
122
|
+
"turbo": "^2.10.8",
|
|
123
|
+
"typescript": "^6.0.3"
|
|
124
|
+
},
|
|
125
|
+
"peerDependencies": {
|
|
126
|
+
"react": ">=19.2.3",
|
|
127
|
+
"react-native": ">=0.86.2"
|
|
128
|
+
},
|
|
129
|
+
"workspaces": [
|
|
130
|
+
"example",
|
|
131
|
+
"examples/expo"
|
|
132
|
+
],
|
|
133
|
+
"packageManager": "yarn@4.11.0",
|
|
134
|
+
"react-native-builder-bob": {
|
|
135
|
+
"source": "src",
|
|
136
|
+
"output": "lib",
|
|
137
|
+
"targets": [
|
|
138
|
+
[
|
|
139
|
+
"module",
|
|
140
|
+
{
|
|
141
|
+
"esm": true
|
|
142
|
+
}
|
|
143
|
+
],
|
|
144
|
+
[
|
|
145
|
+
"typescript",
|
|
146
|
+
{
|
|
147
|
+
"project": "tsconfig.build.json"
|
|
148
|
+
}
|
|
149
|
+
]
|
|
150
|
+
]
|
|
151
|
+
},
|
|
152
|
+
"codegenConfig": {
|
|
153
|
+
"name": "ReactNativeMqttSpec",
|
|
154
|
+
"type": "modules",
|
|
155
|
+
"jsSrcsDir": "src",
|
|
156
|
+
"android": {
|
|
157
|
+
"javaPackageName": "com.cnhongwei.reactnativemqtt"
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
"prettier": {
|
|
161
|
+
"quoteProps": "consistent",
|
|
162
|
+
"singleQuote": true,
|
|
163
|
+
"tabWidth": 2,
|
|
164
|
+
"trailingComma": "es5",
|
|
165
|
+
"useTabs": false
|
|
166
|
+
},
|
|
167
|
+
"jest": {
|
|
168
|
+
"preset": "@react-native/jest-preset",
|
|
169
|
+
"testEnvironmentOptions": {
|
|
170
|
+
"customExportConditions": [
|
|
171
|
+
"require",
|
|
172
|
+
"react-native",
|
|
173
|
+
"<%- project.sourceCondition -%>"
|
|
174
|
+
]
|
|
175
|
+
},
|
|
176
|
+
"modulePathIgnorePatterns": [
|
|
177
|
+
"<rootDir>/example/node_modules",
|
|
178
|
+
"<rootDir>/lib/"
|
|
179
|
+
]
|
|
180
|
+
},
|
|
181
|
+
"create-react-native-library": {
|
|
182
|
+
"type": "turbo-module",
|
|
183
|
+
"languages": "kotlin-objc",
|
|
184
|
+
"tools": [
|
|
185
|
+
"eslint",
|
|
186
|
+
"jest"
|
|
187
|
+
],
|
|
188
|
+
"version": "0.63.1"
|
|
189
|
+
}
|
|
190
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = {};
|