uws-react-native 0.0.10 → 0.1.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +108 -3
- package/cpp/UwsReactNativeModule.cpp +4 -0
- package/cpp/app/HttpResponseObject.h +116 -40
- package/cpp/app/RecognizedString.h +20 -14
- package/cpp/app/TemplatedAppObject.h +61 -36
- package/cpp/app/WebSocketBehaviorImpl.h +269 -11
- package/cpp/app/WebSocketObject.h +354 -16
- package/cpp/app/WebSocketUserData.h +227 -0
- package/lib/commonjs/modules/WebSocketSendStatus.js +22 -0
- package/lib/commonjs/modules/WebSocketSendStatus.js.map +1 -0
- package/lib/commonjs/modules/index.js +22 -0
- package/lib/commonjs/modules/index.js.map +1 -1
- package/lib/commonjs/types/WebSocketUserData.js +2 -0
- package/lib/commonjs/types/WebSocketUserData.js.map +1 -0
- package/lib/module/modules/WebSocketSendStatus.js +18 -0
- package/lib/module/modules/WebSocketSendStatus.js.map +1 -0
- package/lib/module/modules/index.js +2 -1
- package/lib/module/modules/index.js.map +1 -1
- package/lib/module/types/WebSocketUserData.js +2 -0
- package/lib/module/types/WebSocketUserData.js.map +1 -0
- package/lib/typescript/commonjs/modules/WebSocketSendStatus.d.ts +15 -0
- package/lib/typescript/commonjs/modules/WebSocketSendStatus.d.ts.map +1 -0
- package/lib/typescript/commonjs/modules/index.d.ts +2 -0
- package/lib/typescript/commonjs/modules/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/types/HttpResponse.d.ts +39 -4
- package/lib/typescript/commonjs/types/HttpResponse.d.ts.map +1 -1
- package/lib/typescript/commonjs/types/HttpRouterOptions.d.ts +1 -1
- package/lib/typescript/commonjs/types/TemplatedApp.d.ts +5 -0
- package/lib/typescript/commonjs/types/TemplatedApp.d.ts.map +1 -1
- package/lib/typescript/commonjs/types/WebSocket.d.ts +18 -8
- package/lib/typescript/commonjs/types/WebSocket.d.ts.map +1 -1
- package/lib/typescript/commonjs/types/WebSocketBehavior.d.ts +9 -9
- package/lib/typescript/commonjs/types/WebSocketBehavior.d.ts.map +1 -1
- package/lib/typescript/commonjs/types/WebSocketUserData.d.ts +9 -0
- package/lib/typescript/commonjs/types/WebSocketUserData.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/index.d.ts +3 -0
- package/lib/typescript/commonjs/types/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/types/us_socket_context_t.d.ts +2 -3
- package/lib/typescript/commonjs/types/us_socket_context_t.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +2 -2
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/modules/App.d.ts +1 -1
- package/lib/typescript/module/modules/App.d.ts.map +1 -1
- package/lib/typescript/module/modules/WebSocketSendStatus.d.ts +15 -0
- package/lib/typescript/module/modules/WebSocketSendStatus.d.ts.map +1 -0
- package/lib/typescript/module/modules/getParts.d.ts +1 -1
- package/lib/typescript/module/modules/getParts.d.ts.map +1 -1
- package/lib/typescript/module/modules/index.d.ts +7 -5
- package/lib/typescript/module/modules/index.d.ts.map +1 -1
- package/lib/typescript/module/types/HttpRequest.d.ts +1 -1
- package/lib/typescript/module/types/HttpRequest.d.ts.map +1 -1
- package/lib/typescript/module/types/HttpResponse.d.ts +40 -5
- package/lib/typescript/module/types/HttpResponse.d.ts.map +1 -1
- package/lib/typescript/module/types/HttpRouterOptions.d.ts +1 -1
- package/lib/typescript/module/types/TemplatedApp.d.ts +10 -5
- package/lib/typescript/module/types/TemplatedApp.d.ts.map +1 -1
- package/lib/typescript/module/types/WebSocket.d.ts +19 -9
- package/lib/typescript/module/types/WebSocket.d.ts.map +1 -1
- package/lib/typescript/module/types/WebSocketBehavior.d.ts +14 -14
- package/lib/typescript/module/types/WebSocketBehavior.d.ts.map +1 -1
- package/lib/typescript/module/types/WebSocketUserData.d.ts +9 -0
- package/lib/typescript/module/types/WebSocketUserData.d.ts.map +1 -0
- package/lib/typescript/module/types/index.d.ts +8 -5
- package/lib/typescript/module/types/index.d.ts.map +1 -1
- package/lib/typescript/module/types/us_socket_context_t.d.ts +2 -3
- package/lib/typescript/module/types/us_socket_context_t.d.ts.map +1 -1
- package/lib/typescript/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -3
- package/src/modules/WebSocketSendStatus.ts +14 -0
- package/src/modules/index.ts +2 -1
- package/src/types/HttpResponse.ts +50 -33
- package/src/types/HttpRouterOptions.ts +1 -1
- package/src/types/TemplatedApp.ts +10 -10
- package/src/types/WebSocket.ts +24 -8
- package/src/types/WebSocketBehavior.ts +9 -9
- package/src/types/WebSocketUserData.ts +28 -0
- package/src/types/index.ts +3 -2
- package/src/types/us_socket_context_t.ts +2 -3
|
@@ -21,14 +21,14 @@ import type {
|
|
|
21
21
|
/**
|
|
22
22
|
* A structure holding settings and handlers for a WebSocket URL route handler.
|
|
23
23
|
*/
|
|
24
|
-
export interface WebSocketBehavior<UserData> {
|
|
24
|
+
export interface WebSocketBehavior/* <UserData extends object> */ {
|
|
25
25
|
/**
|
|
26
26
|
* Handler for close event, no matter if error, timeout or graceful close.
|
|
27
27
|
* You may not use WebSocket after this event.
|
|
28
28
|
* Do not send on this WebSocket from within here, it is closed.
|
|
29
29
|
*/
|
|
30
30
|
close?: (
|
|
31
|
-
ws: WebSocket
|
|
31
|
+
ws: WebSocket,
|
|
32
32
|
code: number,
|
|
33
33
|
message: ArrayBuffer,
|
|
34
34
|
) => void,
|
|
@@ -51,7 +51,7 @@ export interface WebSocketBehavior<UserData> {
|
|
|
51
51
|
* Use this to guide / drive your backpressure throttling.
|
|
52
52
|
*/
|
|
53
53
|
drain?: (
|
|
54
|
-
ws: WebSocket
|
|
54
|
+
ws: WebSocket,
|
|
55
55
|
) => void,
|
|
56
56
|
|
|
57
57
|
/**
|
|
@@ -62,7 +62,7 @@ export interface WebSocketBehavior<UserData> {
|
|
|
62
62
|
* (until first await or return) and will be neutered.
|
|
63
63
|
*/
|
|
64
64
|
dropped?: (
|
|
65
|
-
ws: WebSocket
|
|
65
|
+
ws: WebSocket,
|
|
66
66
|
message: ArrayBuffer,
|
|
67
67
|
isBinary: boolean,
|
|
68
68
|
) => void | Promise<void>,
|
|
@@ -105,7 +105,7 @@ export interface WebSocketBehavior<UserData> {
|
|
|
105
105
|
* Given ArrayBuffer is valid during the lifetime of this callback (until first await or return) and will be neutered.
|
|
106
106
|
*/
|
|
107
107
|
message?: (
|
|
108
|
-
ws: WebSocket
|
|
108
|
+
ws: WebSocket,
|
|
109
109
|
message: ArrayBuffer,
|
|
110
110
|
isBinary: boolean,
|
|
111
111
|
) => void | Promise<void>,
|
|
@@ -115,7 +115,7 @@ export interface WebSocketBehavior<UserData> {
|
|
|
115
115
|
* WebSocket is valid from open to close, no errors.
|
|
116
116
|
*/
|
|
117
117
|
open?: (
|
|
118
|
-
ws: WebSocket
|
|
118
|
+
ws: WebSocket,
|
|
119
119
|
) => void | Promise<void>,
|
|
120
120
|
|
|
121
121
|
/**
|
|
@@ -123,7 +123,7 @@ export interface WebSocketBehavior<UserData> {
|
|
|
123
123
|
* You do not need to handle this, pong messages are automatically sent as per the standard.
|
|
124
124
|
*/
|
|
125
125
|
ping?: (
|
|
126
|
-
ws: WebSocket
|
|
126
|
+
ws: WebSocket,
|
|
127
127
|
message: ArrayBuffer,
|
|
128
128
|
) => void,
|
|
129
129
|
|
|
@@ -131,7 +131,7 @@ export interface WebSocketBehavior<UserData> {
|
|
|
131
131
|
* Handler for received pong control message.
|
|
132
132
|
*/
|
|
133
133
|
pong?: (
|
|
134
|
-
ws: WebSocket
|
|
134
|
+
ws: WebSocket,
|
|
135
135
|
message: ArrayBuffer,
|
|
136
136
|
) => void,
|
|
137
137
|
|
|
@@ -144,7 +144,7 @@ export interface WebSocketBehavior<UserData> {
|
|
|
144
144
|
* Handler for subscription changes.
|
|
145
145
|
*/
|
|
146
146
|
subscription?: (
|
|
147
|
-
ws: WebSocket
|
|
147
|
+
ws: WebSocket,
|
|
148
148
|
topic: ArrayBuffer,
|
|
149
149
|
newCount: number,
|
|
150
150
|
oldCount: number,
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface WebSocketUserData {
|
|
2
|
+
getBoolean(
|
|
3
|
+
key: string,
|
|
4
|
+
): boolean | undefined,
|
|
5
|
+
|
|
6
|
+
setBoolean(
|
|
7
|
+
key: string,
|
|
8
|
+
value: boolean,
|
|
9
|
+
): void,
|
|
10
|
+
|
|
11
|
+
getNumber(
|
|
12
|
+
key: string,
|
|
13
|
+
): number | undefined,
|
|
14
|
+
|
|
15
|
+
setNumber(
|
|
16
|
+
key: string,
|
|
17
|
+
value: number,
|
|
18
|
+
): void,
|
|
19
|
+
|
|
20
|
+
getString(
|
|
21
|
+
key: string,
|
|
22
|
+
): string | undefined,
|
|
23
|
+
|
|
24
|
+
setString(
|
|
25
|
+
key: string,
|
|
26
|
+
value: number,
|
|
27
|
+
): void,
|
|
28
|
+
}
|
package/src/types/index.ts
CHANGED
|
@@ -5,8 +5,9 @@ export type * from "./HttpResponse"
|
|
|
5
5
|
export type * from "./MultipartField"
|
|
6
6
|
export type * from "./RecognizedString"
|
|
7
7
|
export type * from "./TemplatedApp"
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
export type * from "./WebSocket"
|
|
9
|
+
export type * from "./WebSocketBehavior"
|
|
10
|
+
export type * from "./WebSocketUserData"
|
|
10
11
|
// export type * from "./us_listen_socket"
|
|
11
12
|
// export type * from "./us_socket"
|
|
12
13
|
// export type * from "./us_socket_context_t"
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Native type representing a raw uSockets struct us_socket_context_t.
|
|
3
|
-
*
|
|
3
|
+
* This is not intended to be modified from JavaScript.
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
6
|
-
}
|
|
5
|
+
export type us_socket_context_t = unknown
|