@react-native-ohos/react-native-tcp-socket 6.2.1-rc.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.
Files changed (60) hide show
  1. package/LICENSE +21 -0
  2. package/README.OpenSource +11 -0
  3. package/README.md +13 -0
  4. package/harmony/tcp_socket/Index.ets +9 -0
  5. package/harmony/tcp_socket/build-profile.json5 +31 -0
  6. package/harmony/tcp_socket/consumer-rules.txt +0 -0
  7. package/harmony/tcp_socket/hvigorfile.ts +6 -0
  8. package/harmony/tcp_socket/obfuscation-rules.txt +23 -0
  9. package/harmony/tcp_socket/oh-package.json5 +11 -0
  10. package/harmony/tcp_socket/src/main/cpp/CMakeLists.txt +10 -0
  11. package/harmony/tcp_socket/src/main/cpp/TcpSocketPackage.h +26 -0
  12. package/harmony/tcp_socket/src/main/cpp/generated/RNOH/generated/BaseReactNativeTcpSocketPackage.h +65 -0
  13. package/harmony/tcp_socket/src/main/cpp/generated/RNOH/generated/turbo_modules/TcpSocketModule.cpp +28 -0
  14. package/harmony/tcp_socket/src/main/cpp/generated/RNOH/generated/turbo_modules/TcpSocketModule.h +16 -0
  15. package/harmony/tcp_socket/src/main/cpp/generated/react/renderer/components/react_native_tcp_socket/ComponentDescriptors.h +22 -0
  16. package/harmony/tcp_socket/src/main/cpp/generated/react/renderer/components/react_native_tcp_socket/EventEmitters.cpp +18 -0
  17. package/harmony/tcp_socket/src/main/cpp/generated/react/renderer/components/react_native_tcp_socket/EventEmitters.h +19 -0
  18. package/harmony/tcp_socket/src/main/cpp/generated/react/renderer/components/react_native_tcp_socket/Props.cpp +21 -0
  19. package/harmony/tcp_socket/src/main/cpp/generated/react/renderer/components/react_native_tcp_socket/Props.h +20 -0
  20. package/harmony/tcp_socket/src/main/cpp/generated/react/renderer/components/react_native_tcp_socket/ShadowNodes.cpp +19 -0
  21. package/harmony/tcp_socket/src/main/cpp/generated/react/renderer/components/react_native_tcp_socket/ShadowNodes.h +25 -0
  22. package/harmony/tcp_socket/src/main/cpp/generated/react/renderer/components/react_native_tcp_socket/States.cpp +18 -0
  23. package/harmony/tcp_socket/src/main/cpp/generated/react/renderer/components/react_native_tcp_socket/States.h +23 -0
  24. package/harmony/tcp_socket/src/main/ets/Logger.ts +46 -0
  25. package/harmony/tcp_socket/src/main/ets/TcpEventListener.ts +121 -0
  26. package/harmony/tcp_socket/src/main/ets/TcpSocket.ts +17 -0
  27. package/harmony/tcp_socket/src/main/ets/TcpSocketClient.ts +444 -0
  28. package/harmony/tcp_socket/src/main/ets/TcpSocketPackage.ets +27 -0
  29. package/harmony/tcp_socket/src/main/ets/TcpSocketServer.ts +151 -0
  30. package/harmony/tcp_socket/src/main/ets/TcpSocketTurboModule.ts +224 -0
  31. package/harmony/tcp_socket/src/main/ets/generated/components/ts.ts +5 -0
  32. package/harmony/tcp_socket/src/main/ets/generated/index.ets +5 -0
  33. package/harmony/tcp_socket/src/main/ets/generated/ts.ts +6 -0
  34. package/harmony/tcp_socket/src/main/ets/generated/turboModules/TcpSocketModule.ts +38 -0
  35. package/harmony/tcp_socket/src/main/ets/generated/turboModules/ts.ts +5 -0
  36. package/harmony/tcp_socket/src/main/module.json5 +11 -0
  37. package/harmony/tcp_socket/src/main/resources/base/element/string.json +8 -0
  38. package/harmony/tcp_socket/src/main/resources/en_US/element/string.json +8 -0
  39. package/harmony/tcp_socket/src/main/resources/zh_CN/element/string.json +8 -0
  40. package/harmony/tcp_socket/src/ohosTest/ets/test/Ability.test.ets +35 -0
  41. package/harmony/tcp_socket/src/ohosTest/ets/test/List.test.ets +5 -0
  42. package/harmony/tcp_socket/src/ohosTest/module.json5 +13 -0
  43. package/harmony/tcp_socket/src/test/List.test.ets +5 -0
  44. package/harmony/tcp_socket/src/test/LocalUnit.test.ets +33 -0
  45. package/harmony/tcp_socket/ts.ets +7 -0
  46. package/harmony/tcp_socket.har +0 -0
  47. package/lib/types/Globals.d.ts +2 -0
  48. package/lib/types/Server.d.ts +114 -0
  49. package/lib/types/Socket.d.ts +272 -0
  50. package/lib/types/TLSServer.d.ts +28 -0
  51. package/lib/types/TLSSocket.d.ts +50 -0
  52. package/lib/types/index.d.ts +62 -0
  53. package/package.json +90 -0
  54. package/src/Globals.js +12 -0
  55. package/src/Server.js +185 -0
  56. package/src/Socket.js +513 -0
  57. package/src/TLSServer.js +70 -0
  58. package/src/TLSSocket.js +93 -0
  59. package/src/TcpSocketModule.ts +40 -0
  60. package/src/index.js +131 -0
@@ -0,0 +1,272 @@
1
+ /**
2
+ * @typedef {"ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex"} BufferEncoding
3
+ *
4
+ * @typedef {import('react-native').NativeEventEmitter} NativeEventEmitter
5
+ *
6
+ * @typedef {{address: string, family: string, port: number}} AddressInfo
7
+ *
8
+ * @typedef {{localAddress: string, localPort: number, remoteAddress: string, remotePort: number, remoteFamily: string}} NativeConnectionInfo
9
+ *
10
+ * @typedef {{
11
+ * port: number;
12
+ * host?: string;
13
+ * localAddress?: string,
14
+ * localPort?: number,
15
+ * interface?: 'wifi' | 'cellular' | 'ethernet',
16
+ * reuseAddress?: boolean,
17
+ * tls?: boolean,
18
+ * tlsCheckValidity?: boolean,
19
+ * tlsCert?: any,
20
+ * }} ConnectionOptions
21
+ *
22
+ * @typedef {object} ReadableEvents
23
+ * @property {() => void} pause
24
+ * @property {() => void} resume
25
+ *
26
+ * @typedef {object} SocketEvents
27
+ * @property {(had_error: boolean) => void} close
28
+ * @property {() => void} connect
29
+ * @property {(data: Buffer | string) => void} data
30
+ * @property {() => void} drain
31
+ * @property {(err: Error) => void} error
32
+ * @property {() => void} timeout
33
+ * @property {() => void} secureConnect
34
+ *
35
+ * @extends {EventEmitter<SocketEvents & ReadableEvents, any>}
36
+ */
37
+ export default class Socket extends EventEmitter<SocketEvents & ReadableEvents, any> {
38
+ /** @package */
39
+ _id: number;
40
+ /** @private */
41
+ private _eventEmitter;
42
+ /** @type {EventEmitter<'written', any>} @private */
43
+ private _msgEvtEmitter;
44
+ /** @type {number} @private */
45
+ private _timeoutMsecs;
46
+ /** @type {number | undefined} @private */
47
+ private _timeout;
48
+ /** @private */
49
+ private _encoding;
50
+ /** @private */
51
+ private _msgId;
52
+ /** @private */
53
+ private _lastRcvMsgId;
54
+ /** @private */
55
+ private _lastSentMsgId;
56
+ /** @private */
57
+ private _paused;
58
+ /** @private */
59
+ private _resuming;
60
+ /** @private */
61
+ private _writeBufferSize;
62
+ /** @private */
63
+ private _bytesRead;
64
+ /** @private */
65
+ private _bytesWritten;
66
+ /** @private */
67
+ private _connecting;
68
+ /** @private */
69
+ private _pending;
70
+ /** @private */
71
+ private _destroyed;
72
+ /** @type {'opening' | 'open' | 'readOnly' | 'writeOnly'} @private */
73
+ private _readyState;
74
+ /** @type {{ id: number; data: string; }[]} @private */
75
+ private _pausedDataEvents;
76
+ readableHighWaterMark: number;
77
+ writableHighWaterMark: number;
78
+ writableNeedDrain: boolean;
79
+ localAddress: string | undefined;
80
+ localPort: number | undefined;
81
+ remoteAddress: string | undefined;
82
+ remotePort: number | undefined;
83
+ remoteFamily: string | undefined;
84
+ get readyState(): "opening" | "open" | "readOnly" | "writeOnly";
85
+ get destroyed(): boolean;
86
+ get pending(): boolean;
87
+ get connecting(): boolean;
88
+ get bytesWritten(): number;
89
+ get bytesRead(): number;
90
+ get timeout(): number | undefined;
91
+ /**
92
+ * @package
93
+ * @param {number} id
94
+ */
95
+ _setId(id: number): void;
96
+ /**
97
+ * @package
98
+ * @param {NativeConnectionInfo} connectionInfo
99
+ */
100
+ _setConnected(connectionInfo: NativeConnectionInfo): void;
101
+ /**
102
+ * @param {ConnectionOptions} options
103
+ * @param {() => void} [callback]
104
+ */
105
+ connect(options: ConnectionOptions, callback?: (() => void) | undefined): Socket;
106
+ /**
107
+ * Sets the socket to timeout after `timeout` milliseconds of inactivity on the socket. By default `TcpSocket` do not have a timeout.
108
+ *
109
+ * When an idle timeout is triggered the socket will receive a `'timeout'` event but the connection will not be severed.
110
+ * The user must manually call `socket.end()` or `socket.destroy()` to end the connection.
111
+ *
112
+ * If `timeout` is 0, then the existing idle timeout is disabled.
113
+ *
114
+ * The optional `callback` parameter will be added as a one-time listener for the `'timeout'` event.
115
+ *
116
+ * @param {number} timeout
117
+ * @param {() => void} [callback]
118
+ */
119
+ setTimeout(timeout: number, callback?: (() => void) | undefined): Socket;
120
+ /**
121
+ * @private
122
+ * @param {number} [timeout]
123
+ */
124
+ private _activateTimer;
125
+ /**
126
+ * @private
127
+ */
128
+ private _clearTimeout;
129
+ /**
130
+ * Set the encoding for the socket as a Readable Stream. By default, no encoding is assigned and stream data will be returned as `Buffer` objects.
131
+ * Setting an encoding causes the stream data to be returned as strings of the specified encoding rather than as Buffer objects.
132
+ *
133
+ * For instance, calling `socket.setEncoding('utf8')` will cause the output data to be interpreted as UTF-8 data, and passed as strings.
134
+ * Calling `socket.setEncoding('hex')` will cause the data to be encoded in hexadecimal string format.
135
+ *
136
+ * @param {BufferEncoding} [encoding]
137
+ */
138
+ setEncoding(encoding?: "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex" | undefined): Socket;
139
+ /**
140
+ * Enable/disable the use of Nagle's algorithm. When a TCP connection is created, it will have Nagle's algorithm enabled.
141
+ *
142
+ * Nagle's algorithm delays data before it is sent via the network. It attempts to optimize throughput at the expense of latency.
143
+ *
144
+ * Passing `true` for `noDelay` or not passing an argument will disable Nagle's algorithm for the socket. Passing false for noDelay will enable Nagle's algorithm.
145
+ *
146
+ * @param {boolean} noDelay Default: `true`
147
+ */
148
+ setNoDelay(noDelay?: boolean): Socket;
149
+ /**
150
+ * Enable/disable keep-alive functionality, and optionally set the initial delay before the first keepalive probe is sent on an idle socket.
151
+ *
152
+ * `initialDelay` is ignored.
153
+ *
154
+ * @param {boolean} enable Default: `false`
155
+ * @param {number} initialDelay ***IGNORED**. Default: `0`
156
+ */
157
+ setKeepAlive(enable?: boolean, initialDelay?: number): Socket;
158
+ /**
159
+ * Returns the bound `address`, the address `family` name and `port` of the socket as reported
160
+ * by the operating system: `{ port: 12346, family: 'IPv4', address: '127.0.0.1' }`.
161
+ *
162
+ * @returns {AddressInfo | {}}
163
+ */
164
+ address(): AddressInfo | {};
165
+ /**
166
+ * Half-closes the socket. i.e., it sends a FIN packet. It is possible the server will still send some data.
167
+ *
168
+ * @param {string | Buffer | Uint8Array} [data]
169
+ * @param {BufferEncoding} [encoding]
170
+ */
171
+ end(data?: string | Buffer | Uint8Array | undefined, encoding?: "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex" | undefined): Socket;
172
+ /**
173
+ * Ensures that no more I/O activity happens on this socket. Destroys the stream and closes the connection.
174
+ */
175
+ destroy(): Socket;
176
+ /**
177
+ * Sends data on the socket. The second parameter specifies the encoding in the case of a string — it defaults to UTF8 encoding.
178
+ *
179
+ * Returns `true` if the entire data was flushed successfully to the kernel buffer. Returns `false` if all or part of the data
180
+ * was queued in user memory. `'drain'` will be emitted when the buffer is again free.
181
+ *
182
+ * The optional callback parameter will be executed when the data is finally written out, which may not be immediately.
183
+ *
184
+ * @param {string | Buffer | Uint8Array} buffer
185
+ * @param {BufferEncoding} [encoding]
186
+ * @param {(err?: Error) => void} [cb]
187
+ *
188
+ * @return {boolean}
189
+ */
190
+ write(buffer: string | Buffer | Uint8Array, encoding?: "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex" | undefined, cb?: ((err?: Error | undefined) => void) | undefined): boolean;
191
+ /**
192
+ * Pauses the reading of data. That is, `'data'` events will not be emitted. Useful to throttle back an upload.
193
+ */
194
+ pause(): void;
195
+ /**
196
+ * Resumes reading after a call to `socket.pause()`.
197
+ */
198
+ resume(): void;
199
+ ref(): void;
200
+ unref(): void;
201
+ /**
202
+ * @private
203
+ */
204
+ private _recoverDataEventsAfterPause;
205
+ /**
206
+ * @private
207
+ */
208
+ private _onDeviceDataEvt;
209
+ /**
210
+ * @private
211
+ */
212
+ private _registerEvents;
213
+ _dataListener: import("react-native").EmitterSubscription | undefined;
214
+ _errorListener: import("react-native").EmitterSubscription | undefined;
215
+ _closeListener: import("react-native").EmitterSubscription | undefined;
216
+ _connectListener: import("react-native").EmitterSubscription | undefined;
217
+ _writtenListener: import("react-native").EmitterSubscription | undefined;
218
+ /**
219
+ * @package
220
+ */
221
+ _unregisterEvents(): void;
222
+ /**
223
+ * @private
224
+ * @param {string | Buffer | Uint8Array} buffer
225
+ * @param {BufferEncoding} [encoding]
226
+ */
227
+ private _generateSendBuffer;
228
+ /**
229
+ * @private
230
+ */
231
+ private _setDisconnected;
232
+ }
233
+ export type BufferEncoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex";
234
+ export type NativeEventEmitter = import("react-native").NativeEventEmitter;
235
+ export type AddressInfo = {
236
+ address: string;
237
+ family: string;
238
+ port: number;
239
+ };
240
+ export type NativeConnectionInfo = {
241
+ localAddress: string;
242
+ localPort: number;
243
+ remoteAddress: string;
244
+ remotePort: number;
245
+ remoteFamily: string;
246
+ };
247
+ export type ConnectionOptions = {
248
+ port: number;
249
+ host?: string | undefined;
250
+ localAddress?: string | undefined;
251
+ localPort?: number | undefined;
252
+ interface?: "wifi" | "cellular" | "ethernet" | undefined;
253
+ reuseAddress?: boolean | undefined;
254
+ tls?: boolean | undefined;
255
+ tlsCheckValidity?: boolean | undefined;
256
+ tlsCert?: any;
257
+ };
258
+ export type ReadableEvents = {
259
+ pause: () => void;
260
+ resume: () => void;
261
+ };
262
+ export type SocketEvents = {
263
+ close: (had_error: boolean) => void;
264
+ connect: () => void;
265
+ data: (data: Buffer | string) => void;
266
+ drain: () => void;
267
+ error: (err: Error) => void;
268
+ timeout: () => void;
269
+ secureConnect: () => void;
270
+ };
271
+ import EventEmitter from "eventemitter3";
272
+ import { Buffer } from "buffer";
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @typedef {object} TLSServerOptions
3
+ * @property {any} keystore
4
+ *
5
+ * @extends {Server}
6
+ */
7
+ export default class TLSServer extends Server {
8
+ /**
9
+ * @param {(socket: TLSSocket) => void} [secureConnectionListener] Automatically set as a listener for the `'secureConnection'` event.
10
+ */
11
+ constructor(secureConnectionListener?: ((socket: TLSSocket) => void) | undefined);
12
+ /**
13
+ * @param {TLSServerOptions} options TLS server options
14
+ */
15
+ setSecureContext(options: TLSServerOptions): void;
16
+ /** @private */
17
+ private _options;
18
+ /**
19
+ * @private
20
+ */
21
+ private _registerTLSEvents;
22
+ _secureConnectionListener: import("react-native").EmitterSubscription | undefined;
23
+ }
24
+ export type TLSServerOptions = {
25
+ keystore: any;
26
+ };
27
+ import Server from "./Server";
28
+ import TLSSocket from "./TLSSocket";
@@ -0,0 +1,50 @@
1
+ /**
2
+ * @typedef {object} TLSSocketOptions
3
+ * @property {any} [ca]
4
+ * @property {any} [key]
5
+ * @property {any} [cert]
6
+ * @property {string} [androidKeyStore]
7
+ * @property {string} [certAlias]
8
+ * @property {string} [keyAlias]
9
+ * @property {string[]} [resolvedKeys]
10
+ *
11
+ * @extends {Socket}
12
+ */
13
+ export default class TLSSocket extends Socket {
14
+ /**
15
+ * @private
16
+ * Resolves the asset source if necessary and registers the resolved key.
17
+ * @param {TLSSocketOptions} options The options object containing the source to be resolved.
18
+ * @param {'ca' | 'key' | 'cert'} key The key name being resolved.
19
+ */
20
+ private static resolveAssetIfNeeded;
21
+ /**
22
+ * @param {Socket} socket Any instance of `Socket`.
23
+ * @param {TLSSocketOptions} [options] Options for the TLS socket.
24
+ */
25
+ constructor(socket: Socket, options?: TLSSocketOptions | undefined);
26
+ /** @private */
27
+ private _options;
28
+ /** @private */
29
+ private _socket;
30
+ /**
31
+ * @private
32
+ */
33
+ private _initialize;
34
+ /**
35
+ * @private
36
+ */
37
+ private _startTLS;
38
+ getCertificate(): any;
39
+ getPeerCertificate(): any;
40
+ }
41
+ export type TLSSocketOptions = {
42
+ ca?: any;
43
+ key?: any;
44
+ cert?: any;
45
+ androidKeyStore?: string | undefined;
46
+ certAlias?: string | undefined;
47
+ keyAlias?: string | undefined;
48
+ resolvedKeys?: string[] | undefined;
49
+ };
50
+ import Socket from "./Socket";
@@ -0,0 +1,62 @@
1
+ declare namespace _default {
2
+ export { createConnection as connect };
3
+ export { createServer };
4
+ export { createConnection };
5
+ export { createTLSServer };
6
+ export { connectTLS };
7
+ export { isIP };
8
+ export { isIPv4 };
9
+ export { isIPv6 };
10
+ export { Server };
11
+ export { Socket };
12
+ export { TLSServer };
13
+ export { TLSSocket };
14
+ }
15
+ export default _default;
16
+ /**
17
+ * @param {import('./Socket').ConnectionOptions} options
18
+ * @param {() => void} callback
19
+ * @returns {Socket}
20
+ */
21
+ declare function createConnection(options: import('./Socket').ConnectionOptions, callback: () => void): Socket;
22
+ /**
23
+ * @param {(socket: Socket) => void} connectionListener
24
+ * @returns {Server}
25
+ */
26
+ declare function createServer(connectionListener: (socket: Socket) => void): Server;
27
+ /**
28
+ * @param {import('./TLSServer').TLSServerOptions} options
29
+ * @param {(socket: TLSSocket) => void} connectionListener
30
+ * @returns {TLSServer}
31
+ */
32
+ declare function createTLSServer(options: import('./TLSServer').TLSServerOptions, connectionListener: (socket: TLSSocket) => void): TLSServer;
33
+ /**
34
+ * The `callback` function, if specified, will be added as a listener for the `'secureConnect'` event.
35
+ *
36
+ * @param {import('./TLSSocket').TLSSocketOptions & import('./Socket').ConnectionOptions} options
37
+ * @param {() => void} [callback]
38
+ * @returns {TLSSocket}
39
+ */
40
+ declare function connectTLS(options: import('./TLSSocket').TLSSocketOptions & import('./Socket').ConnectionOptions, callback?: (() => void) | undefined): TLSSocket;
41
+ /**
42
+ * Tests if input is an IP address. Returns `0` for invalid strings, returns `4` for IP version 4 addresses, and returns `6` for IP version 6 addresses.
43
+ *
44
+ * @param {string} input
45
+ */
46
+ declare function isIP(input: string): 0 | 4 | 6;
47
+ /**
48
+ * Returns `true` if input is a version 4 IP address, otherwise returns `false`.
49
+ *
50
+ * @param {string} input
51
+ */
52
+ declare function isIPv4(input: string): boolean;
53
+ /**
54
+ * Returns `true` if input is a version 6 IP address, otherwise returns `false`.
55
+ *
56
+ * @param {string} input
57
+ */
58
+ declare function isIPv6(input: string): boolean;
59
+ import Server from "./Server";
60
+ import Socket from "./Socket";
61
+ import TLSServer from "./TLSServer";
62
+ import TLSSocket from "./TLSSocket";
package/package.json ADDED
@@ -0,0 +1,90 @@
1
+ {
2
+ "name": "@react-native-ohos/react-native-tcp-socket",
3
+ "title": "React Native Tcp Socket",
4
+ "version": "6.2.1-rc.1",
5
+ "description": "React Native TCP socket API for HarmonyOS with SSL/TLS support",
6
+ "main": "src/index.js",
7
+ "types": "lib/types/index.d.ts",
8
+ "scripts": {
9
+ "ci": "yarn install --frozen-lockfile && yarn lint && yarn declaration:build && yarn checkjs && yarn test",
10
+ "lint": "eslint .",
11
+ "checkjs": "tsc && tsc -p ./__tests__/tsconfig.json",
12
+ "test": "jest ./__tests__",
13
+ "declaration:build": "tsc -p ./declaration.tsconfig.json",
14
+ "prepublishOnly": "yarn declaration:build && yarn checkjs",
15
+ "codegen-lib": "react-native codegen-lib-harmony --no-safety-check --npm-package-name react-native-tcp-socket --cpp-output-path ./harmony/tcp_socket/src/main/cpp/generated --ets-output-path ./harmony/tcp_socket/src/main/ets/generated --turbo-modules-spec-paths ./src --arkts-components-spec-paths ./src"
16
+ },
17
+ "files": [
18
+ "/src",
19
+ "/lib",
20
+ "/harmony"
21
+ ],
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://gitcode.com/openharmony-sig/rntpc_react-native-tcp-socket.git",
25
+ "baseUrl": "https://gitcode.com/openharmony-sig/rntpc_react-native-tcp-socket"
26
+ },
27
+ "keywords": [
28
+ "react-native",
29
+ "harmony",
30
+ "tcp-socket",
31
+ "tls",
32
+ "ssl",
33
+ "tcp-server",
34
+ "tcp-client",
35
+ "tcp",
36
+ "react-native-library"
37
+ ],
38
+ "harmony": {
39
+ "alias": "react-native-tcp-socket",
40
+ "autolinking": {
41
+ "etsPackageClassName":"TcpSocketPackage",
42
+ "cppPackageClassName":"TcpSocketPackage",
43
+ "cmakeLibraryTargetName": "rnoh_tcp_socket",
44
+ "ohPackageName": "@react-native-ohos/react-native-tcp-socket"
45
+ }
46
+ },
47
+ "funding": {
48
+ "type": "individual",
49
+ "url": "https://github.com/sponsors/Rapsssito"
50
+ },
51
+ "author": {
52
+ "name": "Rapsssito",
53
+ "email": "contact@rodrigomartin.dev"
54
+ },
55
+ "license": "MIT",
56
+ "licenseFilename": "LICENSE",
57
+ "readmeFilename": "README.md",
58
+ "peerDependencies": {
59
+ "react-native": ">=0.60.0"
60
+ },
61
+ "devDependencies": {
62
+ "@babel/core": "^7.7.7",
63
+ "@semantic-release/changelog": "^5.0.0",
64
+ "@semantic-release/git": "^9.0.0",
65
+ "@semantic-release/github": "^7.0.0",
66
+ "@semantic-release/npm": "^7.0.0",
67
+ "@types/eventemitter3": "^2.0.2",
68
+ "@types/jest": "^25.1.3",
69
+ "@types/react-native": "^0.61.17",
70
+ "babel-eslint": "^10.1.0",
71
+ "babel-jest": "^24.9.0",
72
+ "eslint": "^6.8.0",
73
+ "eslint-config-prettier": "^6.5.0",
74
+ "eslint-plugin-jest": "^23.6.0",
75
+ "eslint-plugin-jsdoc": "^21.0.0",
76
+ "eslint-plugin-prettier": "^3.1.1",
77
+ "jest": "^26.6.3",
78
+ "metro-react-native-babel-preset": "^0.58.0",
79
+ "prettier": "^1.18.2",
80
+ "react": "16.9.0",
81
+ "react-native": "0.60.5",
82
+ "semantic-release": "^17.0.1",
83
+ "typescript": "^4.1.3"
84
+ },
85
+ "dependencies": {
86
+ "buffer": "^5.4.3",
87
+ "eventemitter3": "^4.0.7",
88
+ "react-native-tcp-socket": "6.2.0"
89
+ }
90
+ }
package/src/Globals.js ADDED
@@ -0,0 +1,12 @@
1
+ import { DeviceEventEmitter } from 'react-native';
2
+
3
+
4
+ let instanceNumber = 0;
5
+
6
+ function getNextId() {
7
+ return instanceNumber++;
8
+ }
9
+
10
+ const nativeEventEmitter = DeviceEventEmitter;
11
+
12
+ export { nativeEventEmitter, getNextId };