react-native-tcp-windows 0.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/LICENSE +20 -0
- package/README.md +145 -0
- package/lib/commonjs/ReactNativeTcpWindows.js +9 -0
- package/lib/commonjs/ReactNativeTcpWindows.js.map +1 -0
- package/lib/commonjs/index.js +124 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/module/ReactNativeTcpWindows.js +5 -0
- package/lib/module/ReactNativeTcpWindows.js.map +1 -0
- package/lib/module/index.js +104 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/ReactNativeTcpWindows.d.ts +13 -0
- package/lib/typescript/commonjs/src/ReactNativeTcpWindows.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/__tests__/index.test.d.ts +1 -0
- package/lib/typescript/commonjs/src/__tests__/index.test.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +80 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/ReactNativeTcpWindows.d.ts +13 -0
- package/lib/typescript/module/src/ReactNativeTcpWindows.d.ts.map +1 -0
- package/lib/typescript/module/src/__tests__/index.test.d.ts +1 -0
- package/lib/typescript/module/src/__tests__/index.test.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +80 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/package.json +204 -0
- package/react-native.config.js +12 -0
- package/src/ReactNativeTcpWindows.ts +14 -0
- package/src/__tests__/index.test.tsx +1 -0
- package/src/index.tsx +124 -0
- package/windows/ExperimentalFeatures.props +33 -0
- package/windows/ReactNativeTcpWindows/ReactNativeTcpWindows.cpp +206 -0
- package/windows/ReactNativeTcpWindows/ReactNativeTcpWindows.def +3 -0
- package/windows/ReactNativeTcpWindows/ReactNativeTcpWindows.h +83 -0
- package/windows/ReactNativeTcpWindows/ReactNativeTcpWindows.rc +0 -0
- package/windows/ReactNativeTcpWindows/ReactNativeTcpWindows.vcxproj +146 -0
- package/windows/ReactNativeTcpWindows/ReactNativeTcpWindows.vcxproj.filters +44 -0
- package/windows/ReactNativeTcpWindows/ReactPackageProvider.cpp +20 -0
- package/windows/ReactNativeTcpWindows/ReactPackageProvider.h +24 -0
- package/windows/ReactNativeTcpWindows/ReactPackageProvider.idl +9 -0
- package/windows/ReactNativeTcpWindows/TcpSocket.cpp +565 -0
- package/windows/ReactNativeTcpWindows/TcpSocket.h +69 -0
- package/windows/ReactNativeTcpWindows/codegen/.clang-format +2 -0
- package/windows/ReactNativeTcpWindows/codegen/NativeReactNativeTcpWindowsSpec.g.h +71 -0
- package/windows/ReactNativeTcpWindows/packages.lock.json +60 -0
- package/windows/ReactNativeTcpWindows/pch.cpp +1 -0
- package/windows/ReactNativeTcpWindows/pch.h +30 -0
- package/windows/ReactNativeTcpWindows/resource.h +5 -0
- package/windows/ReactNativeTcpWindows/targetver.h +8 -0
- package/windows/ReactNativeTcpWindows.sln +43 -0
package/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2025 Kyle Grande
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
6
|
+
in the Software without restriction, including without limitation the rights
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
9
|
+
furnished to do so, subject to the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
12
|
+
copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
+
SOFTWARE.
|
package/README.md
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
# react-native-tcp-windows
|
2
|
+
|
3
|
+
TCP sockets communication for React Native Windows (RNW).
|
4
|
+
|
5
|
+
---
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
```sh
|
10
|
+
npm install react-native-tcp-windows
|
11
|
+
````
|
12
|
+
|
13
|
+
---
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
```tsx
|
18
|
+
import React, { useEffect, useState } from 'react';
|
19
|
+
import {
|
20
|
+
connectToServer,
|
21
|
+
closeConnection,
|
22
|
+
writeString,
|
23
|
+
bytesToString,
|
24
|
+
eventEmitter,
|
25
|
+
TCP_SOCKET_EVENTS,
|
26
|
+
type DataReceivedEvent,
|
27
|
+
} from 'react-native-tcp-windows';
|
28
|
+
|
29
|
+
const SERVER_ADDRESS = '127.0.0.1';
|
30
|
+
const SERVER_PORT = 5000;
|
31
|
+
|
32
|
+
export default function App() {
|
33
|
+
const [log, setLog] = useState<string[]>([]);
|
34
|
+
|
35
|
+
useEffect(() => {
|
36
|
+
const connect = async () => {
|
37
|
+
try {
|
38
|
+
const msg = await connectToServer(SERVER_ADDRESS, SERVER_PORT);
|
39
|
+
appendLog(`✅ Connected: ${msg}`);
|
40
|
+
} catch (error: any) {
|
41
|
+
appendLog(`❌ Connection failed: ${error.message || error}`);
|
42
|
+
}
|
43
|
+
};
|
44
|
+
|
45
|
+
connect();
|
46
|
+
|
47
|
+
const subscription = eventEmitter.addListener(
|
48
|
+
TCP_SOCKET_EVENTS.DATA_RECEIVED,
|
49
|
+
(event: DataReceivedEvent) => {
|
50
|
+
const text = bytesToString(event.data);
|
51
|
+
appendLog(`📥 Received: ${text}`);
|
52
|
+
}
|
53
|
+
);
|
54
|
+
|
55
|
+
return () => {
|
56
|
+
subscription.remove();
|
57
|
+
closeConnection().then(() => appendLog('🔌 Connection closed'));
|
58
|
+
};
|
59
|
+
}, []);
|
60
|
+
|
61
|
+
const appendLog = (message: string) => {
|
62
|
+
setLog((logs) => [...logs, message]);
|
63
|
+
};
|
64
|
+
|
65
|
+
const sendMessage = async (message: string) => {
|
66
|
+
const success = await writeString(message);
|
67
|
+
if (success) appendLog(`📤 Sent: ${message}`);
|
68
|
+
else appendLog(`⚠️ Failed to send message`);
|
69
|
+
};
|
70
|
+
|
71
|
+
return (
|
72
|
+
// Your UI components here
|
73
|
+
);
|
74
|
+
}
|
75
|
+
```
|
76
|
+
|
77
|
+
---
|
78
|
+
|
79
|
+
## API
|
80
|
+
|
81
|
+
| Function | Description | Returns |
|
82
|
+
| --------------------- | ------------------------------------------------- | ------------------ |
|
83
|
+
| `connectToServer` | Connect as a TCP client to a server | `Promise<string>` |
|
84
|
+
| `startServer` | Start a TCP server listening on a port | `Promise<string>` |
|
85
|
+
| `closeConnection` | Close current client or server connection | `Promise<string>` |
|
86
|
+
| `write` | Send raw bytes (number array) | `Promise<boolean>` |
|
87
|
+
| `writeString` | Send UTF-8 string data | `Promise<boolean>` |
|
88
|
+
| `writeJson` | Send JSON data as UTF-8 string | `Promise<boolean>` |
|
89
|
+
| `getConnectionStatus` | Get connection status | `Promise<boolean>` |
|
90
|
+
| `bytesToString` | Convert received byte array to string | `string` |
|
91
|
+
| `bytesToJson` | Convert received byte array to parsed JSON object | `any` |
|
92
|
+
|
93
|
+
---
|
94
|
+
|
95
|
+
## Events
|
96
|
+
|
97
|
+
You can listen to socket events via the exported `eventEmitter`:
|
98
|
+
|
99
|
+
| Event Name | Event Data Type | Description |
|
100
|
+
| --------------------------------------------- | ------------------------------ | ------------------------------------ |
|
101
|
+
| `TCP_SOCKET_EVENTS.DATA_RECEIVED` | `DataReceivedEvent` | Fired when data is received |
|
102
|
+
| `TCP_SOCKET_EVENTS.CLIENT_CONNECTED` | `ClientConnectedEvent` | Fired when a client connects |
|
103
|
+
| `TCP_SOCKET_EVENTS.CLIENT_DISCONNECTED` | `ClientDisconnectedEvent` | Fired when a client disconnects |
|
104
|
+
| `TCP_SOCKET_EVENTS.CONNECTION_STATUS_CHANGED` | `ConnectionStatusChangedEvent` | Fired when connection status changes |
|
105
|
+
|
106
|
+
---
|
107
|
+
|
108
|
+
## Types
|
109
|
+
|
110
|
+
```ts
|
111
|
+
export interface DataReceivedEvent {
|
112
|
+
data: number[];
|
113
|
+
}
|
114
|
+
|
115
|
+
export interface ClientConnectedEvent {
|
116
|
+
clientAddress: string;
|
117
|
+
}
|
118
|
+
|
119
|
+
export interface ClientDisconnectedEvent {
|
120
|
+
clientAddress: string;
|
121
|
+
}
|
122
|
+
|
123
|
+
export interface ConnectionStatusChangedEvent {
|
124
|
+
connected: boolean;
|
125
|
+
message: string;
|
126
|
+
}
|
127
|
+
```
|
128
|
+
|
129
|
+
---
|
130
|
+
|
131
|
+
## Contributing
|
132
|
+
|
133
|
+
See the [CONTRIBUTING.md](CONTRIBUTING.md) for contribution guidelines.
|
134
|
+
|
135
|
+
---
|
136
|
+
|
137
|
+
## License
|
138
|
+
|
139
|
+
MIT
|
140
|
+
|
141
|
+
---
|
142
|
+
|
143
|
+
Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
|
144
|
+
|
145
|
+
---
|
@@ -0,0 +1,9 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
var _reactNative = require("react-native");
|
8
|
+
var _default = exports.default = _reactNative.TurboModuleRegistry.getEnforcing('ReactNativeTcpWindows');
|
9
|
+
//# sourceMappingURL=ReactNativeTcpWindows.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"..\\..\\src","sources":["ReactNativeTcpWindows.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAAmD,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAYpCC,gCAAmB,CAACC,YAAY,CAAO,uBAAuB,CAAC","ignoreList":[]}
|
@@ -0,0 +1,124 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.TCP_SOCKET_EVENTS = void 0;
|
7
|
+
Object.defineProperty(exports, "TcpSocketWindows", {
|
8
|
+
enumerable: true,
|
9
|
+
get: function () {
|
10
|
+
return _ReactNativeTcpWindows.default;
|
11
|
+
}
|
12
|
+
});
|
13
|
+
exports.bytesToJson = bytesToJson;
|
14
|
+
exports.bytesToString = bytesToString;
|
15
|
+
exports.closeConnection = closeConnection;
|
16
|
+
exports.connectToServer = connectToServer;
|
17
|
+
exports.eventEmitter = void 0;
|
18
|
+
exports.getConnectionStatus = getConnectionStatus;
|
19
|
+
exports.startServer = startServer;
|
20
|
+
exports.write = write;
|
21
|
+
exports.writeJson = writeJson;
|
22
|
+
exports.writeString = writeString;
|
23
|
+
var _reactNative = require("react-native");
|
24
|
+
var _ReactNativeTcpWindows = _interopRequireDefault(require("./ReactNativeTcpWindows.js"));
|
25
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
26
|
+
const eventEmitter = exports.eventEmitter = new _reactNative.NativeEventEmitter(_ReactNativeTcpWindows.default);
|
27
|
+
// Event types for better type safety
|
28
|
+
const TCP_SOCKET_EVENTS = exports.TCP_SOCKET_EVENTS = {
|
29
|
+
DATA_RECEIVED: 'TcpSocketDataReceived',
|
30
|
+
CLIENT_CONNECTED: 'TcpSocketClientConnected',
|
31
|
+
CLIENT_DISCONNECTED: 'TcpSocketClientDisconnected',
|
32
|
+
CONNECTION_STATUS_CHANGED: 'TcpSocketConnectionStatusChanged'
|
33
|
+
};
|
34
|
+
|
35
|
+
// Event data interfaces
|
36
|
+
|
37
|
+
/**
|
38
|
+
* Connect to a TCP server as a client
|
39
|
+
* @param address Server IP address (e.g., "192.168.1.100")
|
40
|
+
* @param port Server port number
|
41
|
+
* @returns Promise that resolves with success message
|
42
|
+
*/
|
43
|
+
function connectToServer(address, port) {
|
44
|
+
return _ReactNativeTcpWindows.default.connectToServer(address, port);
|
45
|
+
}
|
46
|
+
|
47
|
+
/**
|
48
|
+
* Start a TCP server to accept client connections
|
49
|
+
* @param port Port number to listen on
|
50
|
+
* @returns Promise that resolves with success message
|
51
|
+
*/
|
52
|
+
function startServer(port) {
|
53
|
+
return _ReactNativeTcpWindows.default.startServer(port);
|
54
|
+
}
|
55
|
+
|
56
|
+
/**
|
57
|
+
* Close the current connection (client or server)
|
58
|
+
* @returns Promise that resolves with success message
|
59
|
+
*/
|
60
|
+
function closeConnection() {
|
61
|
+
return _ReactNativeTcpWindows.default.closeConnection();
|
62
|
+
}
|
63
|
+
|
64
|
+
/**
|
65
|
+
* Write data to the TCP connection
|
66
|
+
* For clients: sends to the connected server
|
67
|
+
* For servers: sends to all connected clients
|
68
|
+
* @param data Array of bytes to send (0-255)
|
69
|
+
* @returns Promise that resolves with success status
|
70
|
+
*/
|
71
|
+
function write(data) {
|
72
|
+
return _ReactNativeTcpWindows.default.write(data);
|
73
|
+
}
|
74
|
+
|
75
|
+
/**
|
76
|
+
* Get the current connection status
|
77
|
+
* @returns Promise that resolves with connection status object
|
78
|
+
*/
|
79
|
+
function getConnectionStatus() {
|
80
|
+
return _ReactNativeTcpWindows.default.getConnectionStatus();
|
81
|
+
}
|
82
|
+
|
83
|
+
/**
|
84
|
+
* Write a string as UTF-8 bytes
|
85
|
+
* @param text String to send
|
86
|
+
* @returns Promise that resolves with success status
|
87
|
+
*/
|
88
|
+
function writeString(text) {
|
89
|
+
const encoder = new TextEncoder();
|
90
|
+
const bytes = Array.from(encoder.encode(text));
|
91
|
+
return write(bytes);
|
92
|
+
}
|
93
|
+
|
94
|
+
/**
|
95
|
+
* Write JSON data as UTF-8 bytes
|
96
|
+
* @param data Object to serialize and send
|
97
|
+
* @returns Promise that resolves with success status
|
98
|
+
*/
|
99
|
+
function writeJson(data) {
|
100
|
+
const jsonString = JSON.stringify(data);
|
101
|
+
return writeString(jsonString);
|
102
|
+
}
|
103
|
+
|
104
|
+
/**
|
105
|
+
* Convenience function to convert received byte array to string
|
106
|
+
* @param data Byte array from DataReceivedEvent
|
107
|
+
* @returns Decoded UTF-8 string
|
108
|
+
*/
|
109
|
+
function bytesToString(data) {
|
110
|
+
const uint8Array = new Uint8Array(data);
|
111
|
+
const decoder = new TextDecoder();
|
112
|
+
return decoder.decode(uint8Array);
|
113
|
+
}
|
114
|
+
|
115
|
+
/**
|
116
|
+
* Convenience function to convert received byte array to JSON
|
117
|
+
* @param data Byte array from DataReceivedEvent
|
118
|
+
* @returns Parsed JSON object
|
119
|
+
*/
|
120
|
+
function bytesToJson(data) {
|
121
|
+
const jsonString = bytesToString(data);
|
122
|
+
return JSON.parse(jsonString);
|
123
|
+
}
|
124
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_ReactNativeTcpWindows","_interopRequireDefault","e","__esModule","default","eventEmitter","exports","NativeEventEmitter","TcpSocketWindows","TCP_SOCKET_EVENTS","DATA_RECEIVED","CLIENT_CONNECTED","CLIENT_DISCONNECTED","CONNECTION_STATUS_CHANGED","connectToServer","address","port","startServer","closeConnection","write","data","getConnectionStatus","writeString","text","encoder","TextEncoder","bytes","Array","from","encode","writeJson","jsonString","JSON","stringify","bytesToString","uint8Array","Uint8Array","decoder","TextDecoder","decode","bytesToJson","parse"],"sourceRoot":"..\\..\\src","sources":["index.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAuD,SAAAE,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEhD,MAAMG,YAAY,GAAAC,OAAA,CAAAD,YAAA,GAAG,IAAIE,+BAAkB,CAACC,8BAAgB,CAAC;AAEpE;AACO,MAAMC,iBAAiB,GAAAH,OAAA,CAAAG,iBAAA,GAAG;EAC/BC,aAAa,EAAE,uBAAuB;EACtCC,gBAAgB,EAAE,0BAA0B;EAC5CC,mBAAmB,EAAE,6BAA6B;EAClDC,yBAAyB,EAAE;AAC7B,CAAU;;AAKV;;AAkBA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,eAAeA,CAC7BC,OAAe,EACfC,IAAY,EACK;EACjB,OAAOR,8BAAgB,CAACM,eAAe,CAACC,OAAO,EAAEC,IAAI,CAAC;AACxD;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,WAAWA,CAACD,IAAY,EAAmB;EACzD,OAAOR,8BAAgB,CAACS,WAAW,CAACD,IAAI,CAAC;AAC3C;;AAEA;AACA;AACA;AACA;AACO,SAASE,eAAeA,CAAA,EAAoB;EACjD,OAAOV,8BAAgB,CAACU,eAAe,CAAC,CAAC;AAC3C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,KAAKA,CAACC,IAAc,EAAoB;EACtD,OAAOZ,8BAAgB,CAACW,KAAK,CAACC,IAAI,CAAC;AACrC;;AAEA;AACA;AACA;AACA;AACO,SAASC,mBAAmBA,CAAA,EAAqB;EACtD,OAAOb,8BAAgB,CAACa,mBAAmB,CAAC,CAAC;AAC/C;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,WAAWA,CAACC,IAAY,EAAoB;EAC1D,MAAMC,OAAO,GAAG,IAAIC,WAAW,CAAC,CAAC;EACjC,MAAMC,KAAK,GAAGC,KAAK,CAACC,IAAI,CAACJ,OAAO,CAACK,MAAM,CAACN,IAAI,CAAC,CAAC;EAC9C,OAAOJ,KAAK,CAACO,KAAK,CAAC;AACrB;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASI,SAASA,CAACV,IAAS,EAAoB;EACrD,MAAMW,UAAU,GAAGC,IAAI,CAACC,SAAS,CAACb,IAAI,CAAC;EACvC,OAAOE,WAAW,CAACS,UAAU,CAAC;AAChC;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASG,aAAaA,CAACd,IAAc,EAAU;EACpD,MAAMe,UAAU,GAAG,IAAIC,UAAU,CAAChB,IAAI,CAAC;EACvC,MAAMiB,OAAO,GAAG,IAAIC,WAAW,CAAC,CAAC;EACjC,OAAOD,OAAO,CAACE,MAAM,CAACJ,UAAU,CAAC;AACnC;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASK,WAAWA,CAACpB,IAAc,EAAO;EAC/C,MAAMW,UAAU,GAAGG,aAAa,CAACd,IAAI,CAAC;EACtC,OAAOY,IAAI,CAACS,KAAK,CAACV,UAAU,CAAC;AAC/B","ignoreList":[]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"type":"commonjs"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"..\\..\\src","sources":["ReactNativeTcpWindows.ts"],"mappings":";;AACA,SAASA,mBAAmB,QAAQ,cAAc;AAYlD,eAAeA,mBAAmB,CAACC,YAAY,CAAO,uBAAuB,CAAC","ignoreList":[]}
|
@@ -0,0 +1,104 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
import { NativeEventEmitter } from 'react-native';
|
4
|
+
import TcpSocketWindows from "./ReactNativeTcpWindows.js";
|
5
|
+
export const eventEmitter = new NativeEventEmitter(TcpSocketWindows);
|
6
|
+
export { TcpSocketWindows };
|
7
|
+
// Event types for better type safety
|
8
|
+
export const TCP_SOCKET_EVENTS = {
|
9
|
+
DATA_RECEIVED: 'TcpSocketDataReceived',
|
10
|
+
CLIENT_CONNECTED: 'TcpSocketClientConnected',
|
11
|
+
CLIENT_DISCONNECTED: 'TcpSocketClientDisconnected',
|
12
|
+
CONNECTION_STATUS_CHANGED: 'TcpSocketConnectionStatusChanged'
|
13
|
+
};
|
14
|
+
|
15
|
+
// Event data interfaces
|
16
|
+
|
17
|
+
/**
|
18
|
+
* Connect to a TCP server as a client
|
19
|
+
* @param address Server IP address (e.g., "192.168.1.100")
|
20
|
+
* @param port Server port number
|
21
|
+
* @returns Promise that resolves with success message
|
22
|
+
*/
|
23
|
+
export function connectToServer(address, port) {
|
24
|
+
return TcpSocketWindows.connectToServer(address, port);
|
25
|
+
}
|
26
|
+
|
27
|
+
/**
|
28
|
+
* Start a TCP server to accept client connections
|
29
|
+
* @param port Port number to listen on
|
30
|
+
* @returns Promise that resolves with success message
|
31
|
+
*/
|
32
|
+
export function startServer(port) {
|
33
|
+
return TcpSocketWindows.startServer(port);
|
34
|
+
}
|
35
|
+
|
36
|
+
/**
|
37
|
+
* Close the current connection (client or server)
|
38
|
+
* @returns Promise that resolves with success message
|
39
|
+
*/
|
40
|
+
export function closeConnection() {
|
41
|
+
return TcpSocketWindows.closeConnection();
|
42
|
+
}
|
43
|
+
|
44
|
+
/**
|
45
|
+
* Write data to the TCP connection
|
46
|
+
* For clients: sends to the connected server
|
47
|
+
* For servers: sends to all connected clients
|
48
|
+
* @param data Array of bytes to send (0-255)
|
49
|
+
* @returns Promise that resolves with success status
|
50
|
+
*/
|
51
|
+
export function write(data) {
|
52
|
+
return TcpSocketWindows.write(data);
|
53
|
+
}
|
54
|
+
|
55
|
+
/**
|
56
|
+
* Get the current connection status
|
57
|
+
* @returns Promise that resolves with connection status object
|
58
|
+
*/
|
59
|
+
export function getConnectionStatus() {
|
60
|
+
return TcpSocketWindows.getConnectionStatus();
|
61
|
+
}
|
62
|
+
|
63
|
+
/**
|
64
|
+
* Write a string as UTF-8 bytes
|
65
|
+
* @param text String to send
|
66
|
+
* @returns Promise that resolves with success status
|
67
|
+
*/
|
68
|
+
export function writeString(text) {
|
69
|
+
const encoder = new TextEncoder();
|
70
|
+
const bytes = Array.from(encoder.encode(text));
|
71
|
+
return write(bytes);
|
72
|
+
}
|
73
|
+
|
74
|
+
/**
|
75
|
+
* Write JSON data as UTF-8 bytes
|
76
|
+
* @param data Object to serialize and send
|
77
|
+
* @returns Promise that resolves with success status
|
78
|
+
*/
|
79
|
+
export function writeJson(data) {
|
80
|
+
const jsonString = JSON.stringify(data);
|
81
|
+
return writeString(jsonString);
|
82
|
+
}
|
83
|
+
|
84
|
+
/**
|
85
|
+
* Convenience function to convert received byte array to string
|
86
|
+
* @param data Byte array from DataReceivedEvent
|
87
|
+
* @returns Decoded UTF-8 string
|
88
|
+
*/
|
89
|
+
export function bytesToString(data) {
|
90
|
+
const uint8Array = new Uint8Array(data);
|
91
|
+
const decoder = new TextDecoder();
|
92
|
+
return decoder.decode(uint8Array);
|
93
|
+
}
|
94
|
+
|
95
|
+
/**
|
96
|
+
* Convenience function to convert received byte array to JSON
|
97
|
+
* @param data Byte array from DataReceivedEvent
|
98
|
+
* @returns Parsed JSON object
|
99
|
+
*/
|
100
|
+
export function bytesToJson(data) {
|
101
|
+
const jsonString = bytesToString(data);
|
102
|
+
return JSON.parse(jsonString);
|
103
|
+
}
|
104
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["NativeEventEmitter","TcpSocketWindows","eventEmitter","TCP_SOCKET_EVENTS","DATA_RECEIVED","CLIENT_CONNECTED","CLIENT_DISCONNECTED","CONNECTION_STATUS_CHANGED","connectToServer","address","port","startServer","closeConnection","write","data","getConnectionStatus","writeString","text","encoder","TextEncoder","bytes","Array","from","encode","writeJson","jsonString","JSON","stringify","bytesToString","uint8Array","Uint8Array","decoder","TextDecoder","decode","bytesToJson","parse"],"sourceRoot":"..\\..\\src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,kBAAkB,QAAQ,cAAc;AACjD,OAAOC,gBAAgB,MAAM,4BAAyB;AAEtD,OAAO,MAAMC,YAAY,GAAG,IAAIF,kBAAkB,CAACC,gBAAgB,CAAC;AACpE,SAASA,gBAAgB;AACzB;AACA,OAAO,MAAME,iBAAiB,GAAG;EAC/BC,aAAa,EAAE,uBAAuB;EACtCC,gBAAgB,EAAE,0BAA0B;EAC5CC,mBAAmB,EAAE,6BAA6B;EAClDC,yBAAyB,EAAE;AAC7B,CAAU;;AAKV;;AAkBA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAC7BC,OAAe,EACfC,IAAY,EACK;EACjB,OAAOT,gBAAgB,CAACO,eAAe,CAACC,OAAO,EAAEC,IAAI,CAAC;AACxD;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,WAAWA,CAACD,IAAY,EAAmB;EACzD,OAAOT,gBAAgB,CAACU,WAAW,CAACD,IAAI,CAAC;AAC3C;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASE,eAAeA,CAAA,EAAoB;EACjD,OAAOX,gBAAgB,CAACW,eAAe,CAAC,CAAC;AAC3C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,KAAKA,CAACC,IAAc,EAAoB;EACtD,OAAOb,gBAAgB,CAACY,KAAK,CAACC,IAAI,CAAC;AACrC;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CAAA,EAAqB;EACtD,OAAOd,gBAAgB,CAACc,mBAAmB,CAAC,CAAC;AAC/C;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,WAAWA,CAACC,IAAY,EAAoB;EAC1D,MAAMC,OAAO,GAAG,IAAIC,WAAW,CAAC,CAAC;EACjC,MAAMC,KAAK,GAAGC,KAAK,CAACC,IAAI,CAACJ,OAAO,CAACK,MAAM,CAACN,IAAI,CAAC,CAAC;EAC9C,OAAOJ,KAAK,CAACO,KAAK,CAAC;AACrB;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASI,SAASA,CAACV,IAAS,EAAoB;EACrD,MAAMW,UAAU,GAAGC,IAAI,CAACC,SAAS,CAACb,IAAI,CAAC;EACvC,OAAOE,WAAW,CAACS,UAAU,CAAC;AAChC;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASG,aAAaA,CAACd,IAAc,EAAU;EACpD,MAAMe,UAAU,GAAG,IAAIC,UAAU,CAAChB,IAAI,CAAC;EACvC,MAAMiB,OAAO,GAAG,IAAIC,WAAW,CAAC,CAAC;EACjC,OAAOD,OAAO,CAACE,MAAM,CAACJ,UAAU,CAAC;AACnC;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASK,WAAWA,CAACpB,IAAc,EAAO;EAC/C,MAAMW,UAAU,GAAGG,aAAa,CAACd,IAAI,CAAC;EACtC,OAAOY,IAAI,CAACS,KAAK,CAACV,UAAU,CAAC;AAC/B","ignoreList":[]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"type":"module"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"type":"commonjs"}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
2
|
+
export interface Spec extends TurboModule {
|
3
|
+
connectToServer(address: string, port: number): Promise<string>;
|
4
|
+
startServer(port: number): Promise<string>;
|
5
|
+
closeConnection(): Promise<string>;
|
6
|
+
write(data: Array<number>): Promise<boolean>;
|
7
|
+
getConnectionStatus(): Promise<boolean>;
|
8
|
+
addListener(eventType: string): void;
|
9
|
+
removeListeners(count: number): void;
|
10
|
+
}
|
11
|
+
declare const _default: Spec;
|
12
|
+
export default _default;
|
13
|
+
//# sourceMappingURL=ReactNativeTcpWindows.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ReactNativeTcpWindows.d.ts","sourceRoot":"","sources":["../../../../src/ReactNativeTcpWindows.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAChE,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC3C,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACnC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7C,mBAAmB,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IACxC,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtC;;AAED,wBAA+E"}
|
@@ -0,0 +1 @@
|
|
1
|
+
//# sourceMappingURL=index.test.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../../../src/__tests__/index.test.tsx"],"names":[],"mappings":""}
|
@@ -0,0 +1,80 @@
|
|
1
|
+
import { NativeEventEmitter } from 'react-native';
|
2
|
+
import TcpSocketWindows from './ReactNativeTcpWindows';
|
3
|
+
export declare const eventEmitter: NativeEventEmitter;
|
4
|
+
export { TcpSocketWindows };
|
5
|
+
export declare const TCP_SOCKET_EVENTS: {
|
6
|
+
readonly DATA_RECEIVED: "TcpSocketDataReceived";
|
7
|
+
readonly CLIENT_CONNECTED: "TcpSocketClientConnected";
|
8
|
+
readonly CLIENT_DISCONNECTED: "TcpSocketClientDisconnected";
|
9
|
+
readonly CONNECTION_STATUS_CHANGED: "TcpSocketConnectionStatusChanged";
|
10
|
+
};
|
11
|
+
export type TcpSocketEvent = (typeof TCP_SOCKET_EVENTS)[keyof typeof TCP_SOCKET_EVENTS];
|
12
|
+
export interface DataReceivedEvent {
|
13
|
+
data: number[];
|
14
|
+
}
|
15
|
+
export interface ClientConnectedEvent {
|
16
|
+
clientAddress: string;
|
17
|
+
}
|
18
|
+
export interface ClientDisconnectedEvent {
|
19
|
+
clientAddress: string;
|
20
|
+
}
|
21
|
+
export interface ConnectionStatusChangedEvent {
|
22
|
+
connected: boolean;
|
23
|
+
message: string;
|
24
|
+
}
|
25
|
+
/**
|
26
|
+
* Connect to a TCP server as a client
|
27
|
+
* @param address Server IP address (e.g., "192.168.1.100")
|
28
|
+
* @param port Server port number
|
29
|
+
* @returns Promise that resolves with success message
|
30
|
+
*/
|
31
|
+
export declare function connectToServer(address: string, port: number): Promise<string>;
|
32
|
+
/**
|
33
|
+
* Start a TCP server to accept client connections
|
34
|
+
* @param port Port number to listen on
|
35
|
+
* @returns Promise that resolves with success message
|
36
|
+
*/
|
37
|
+
export declare function startServer(port: number): Promise<string>;
|
38
|
+
/**
|
39
|
+
* Close the current connection (client or server)
|
40
|
+
* @returns Promise that resolves with success message
|
41
|
+
*/
|
42
|
+
export declare function closeConnection(): Promise<string>;
|
43
|
+
/**
|
44
|
+
* Write data to the TCP connection
|
45
|
+
* For clients: sends to the connected server
|
46
|
+
* For servers: sends to all connected clients
|
47
|
+
* @param data Array of bytes to send (0-255)
|
48
|
+
* @returns Promise that resolves with success status
|
49
|
+
*/
|
50
|
+
export declare function write(data: number[]): Promise<boolean>;
|
51
|
+
/**
|
52
|
+
* Get the current connection status
|
53
|
+
* @returns Promise that resolves with connection status object
|
54
|
+
*/
|
55
|
+
export declare function getConnectionStatus(): Promise<boolean>;
|
56
|
+
/**
|
57
|
+
* Write a string as UTF-8 bytes
|
58
|
+
* @param text String to send
|
59
|
+
* @returns Promise that resolves with success status
|
60
|
+
*/
|
61
|
+
export declare function writeString(text: string): Promise<boolean>;
|
62
|
+
/**
|
63
|
+
* Write JSON data as UTF-8 bytes
|
64
|
+
* @param data Object to serialize and send
|
65
|
+
* @returns Promise that resolves with success status
|
66
|
+
*/
|
67
|
+
export declare function writeJson(data: any): Promise<boolean>;
|
68
|
+
/**
|
69
|
+
* Convenience function to convert received byte array to string
|
70
|
+
* @param data Byte array from DataReceivedEvent
|
71
|
+
* @returns Decoded UTF-8 string
|
72
|
+
*/
|
73
|
+
export declare function bytesToString(data: number[]): string;
|
74
|
+
/**
|
75
|
+
* Convenience function to convert received byte array to JSON
|
76
|
+
* @param data Byte array from DataReceivedEvent
|
77
|
+
* @returns Parsed JSON object
|
78
|
+
*/
|
79
|
+
export declare function bytesToJson(data: number[]): any;
|
80
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,gBAAgB,MAAM,yBAAyB,CAAC;AAEvD,eAAO,MAAM,YAAY,oBAA2C,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAE5B,eAAO,MAAM,iBAAiB;;;;;CAKpB,CAAC;AAEX,MAAM,MAAM,cAAc,GACxB,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAC;AAG7D,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,uBAAuB;IACtC,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,4BAA4B;IAC3C,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,CAAC,CAEjB;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAEzD;AAED;;;GAGG;AACH,wBAAgB,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC,CAEjD;AAED;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAEtD;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAAC,OAAO,CAAC,CAEtD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAI1D;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,CAGrD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAIpD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,GAAG,CAG/C"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"type":"module"}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
2
|
+
export interface Spec extends TurboModule {
|
3
|
+
connectToServer(address: string, port: number): Promise<string>;
|
4
|
+
startServer(port: number): Promise<string>;
|
5
|
+
closeConnection(): Promise<string>;
|
6
|
+
write(data: Array<number>): Promise<boolean>;
|
7
|
+
getConnectionStatus(): Promise<boolean>;
|
8
|
+
addListener(eventType: string): void;
|
9
|
+
removeListeners(count: number): void;
|
10
|
+
}
|
11
|
+
declare const _default: Spec;
|
12
|
+
export default _default;
|
13
|
+
//# sourceMappingURL=ReactNativeTcpWindows.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ReactNativeTcpWindows.d.ts","sourceRoot":"","sources":["../../../../src/ReactNativeTcpWindows.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAChE,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC3C,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACnC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7C,mBAAmB,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IACxC,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtC;;AAED,wBAA+E"}
|
@@ -0,0 +1 @@
|
|
1
|
+
//# sourceMappingURL=index.test.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../../../src/__tests__/index.test.tsx"],"names":[],"mappings":""}
|
@@ -0,0 +1,80 @@
|
|
1
|
+
import { NativeEventEmitter } from 'react-native';
|
2
|
+
import TcpSocketWindows from './ReactNativeTcpWindows';
|
3
|
+
export declare const eventEmitter: NativeEventEmitter;
|
4
|
+
export { TcpSocketWindows };
|
5
|
+
export declare const TCP_SOCKET_EVENTS: {
|
6
|
+
readonly DATA_RECEIVED: "TcpSocketDataReceived";
|
7
|
+
readonly CLIENT_CONNECTED: "TcpSocketClientConnected";
|
8
|
+
readonly CLIENT_DISCONNECTED: "TcpSocketClientDisconnected";
|
9
|
+
readonly CONNECTION_STATUS_CHANGED: "TcpSocketConnectionStatusChanged";
|
10
|
+
};
|
11
|
+
export type TcpSocketEvent = (typeof TCP_SOCKET_EVENTS)[keyof typeof TCP_SOCKET_EVENTS];
|
12
|
+
export interface DataReceivedEvent {
|
13
|
+
data: number[];
|
14
|
+
}
|
15
|
+
export interface ClientConnectedEvent {
|
16
|
+
clientAddress: string;
|
17
|
+
}
|
18
|
+
export interface ClientDisconnectedEvent {
|
19
|
+
clientAddress: string;
|
20
|
+
}
|
21
|
+
export interface ConnectionStatusChangedEvent {
|
22
|
+
connected: boolean;
|
23
|
+
message: string;
|
24
|
+
}
|
25
|
+
/**
|
26
|
+
* Connect to a TCP server as a client
|
27
|
+
* @param address Server IP address (e.g., "192.168.1.100")
|
28
|
+
* @param port Server port number
|
29
|
+
* @returns Promise that resolves with success message
|
30
|
+
*/
|
31
|
+
export declare function connectToServer(address: string, port: number): Promise<string>;
|
32
|
+
/**
|
33
|
+
* Start a TCP server to accept client connections
|
34
|
+
* @param port Port number to listen on
|
35
|
+
* @returns Promise that resolves with success message
|
36
|
+
*/
|
37
|
+
export declare function startServer(port: number): Promise<string>;
|
38
|
+
/**
|
39
|
+
* Close the current connection (client or server)
|
40
|
+
* @returns Promise that resolves with success message
|
41
|
+
*/
|
42
|
+
export declare function closeConnection(): Promise<string>;
|
43
|
+
/**
|
44
|
+
* Write data to the TCP connection
|
45
|
+
* For clients: sends to the connected server
|
46
|
+
* For servers: sends to all connected clients
|
47
|
+
* @param data Array of bytes to send (0-255)
|
48
|
+
* @returns Promise that resolves with success status
|
49
|
+
*/
|
50
|
+
export declare function write(data: number[]): Promise<boolean>;
|
51
|
+
/**
|
52
|
+
* Get the current connection status
|
53
|
+
* @returns Promise that resolves with connection status object
|
54
|
+
*/
|
55
|
+
export declare function getConnectionStatus(): Promise<boolean>;
|
56
|
+
/**
|
57
|
+
* Write a string as UTF-8 bytes
|
58
|
+
* @param text String to send
|
59
|
+
* @returns Promise that resolves with success status
|
60
|
+
*/
|
61
|
+
export declare function writeString(text: string): Promise<boolean>;
|
62
|
+
/**
|
63
|
+
* Write JSON data as UTF-8 bytes
|
64
|
+
* @param data Object to serialize and send
|
65
|
+
* @returns Promise that resolves with success status
|
66
|
+
*/
|
67
|
+
export declare function writeJson(data: any): Promise<boolean>;
|
68
|
+
/**
|
69
|
+
* Convenience function to convert received byte array to string
|
70
|
+
* @param data Byte array from DataReceivedEvent
|
71
|
+
* @returns Decoded UTF-8 string
|
72
|
+
*/
|
73
|
+
export declare function bytesToString(data: number[]): string;
|
74
|
+
/**
|
75
|
+
* Convenience function to convert received byte array to JSON
|
76
|
+
* @param data Byte array from DataReceivedEvent
|
77
|
+
* @returns Parsed JSON object
|
78
|
+
*/
|
79
|
+
export declare function bytesToJson(data: number[]): any;
|
80
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,gBAAgB,MAAM,yBAAyB,CAAC;AAEvD,eAAO,MAAM,YAAY,oBAA2C,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAE5B,eAAO,MAAM,iBAAiB;;;;;CAKpB,CAAC;AAEX,MAAM,MAAM,cAAc,GACxB,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAC;AAG7D,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,uBAAuB;IACtC,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,4BAA4B;IAC3C,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,CAAC,CAEjB;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAEzD;AAED;;;GAGG;AACH,wBAAgB,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC,CAEjD;AAED;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAEtD;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAAC,OAAO,CAAC,CAEtD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAI1D;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,CAGrD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAIpD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,GAAG,CAG/C"}
|