uws-react-native 0.0.9 → 0.0.10
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 +27 -7
- package/cpp/UwsReactNativeModule.h +77 -0
- package/cpp/app/TemplatedAppObject.h +28 -0
- package/cpp/app/WebSocketBehaviorImpl.h +48 -0
- package/cpp/app/WebSocketObject.h +64 -0
- package/lib/commonjs/_internal/native-modules/NativeUwsReactNative.js.map +1 -1
- package/lib/commonjs/modules/CompressOptions.js +89 -101
- package/lib/commonjs/modules/CompressOptions.js.map +1 -1
- package/lib/commonjs/types/WebSocketBehavior.js +6 -0
- package/lib/commonjs/types/WebSocketBehavior.js.map +1 -0
- package/lib/module/_internal/native-modules/NativeUwsReactNative.js.map +1 -1
- package/lib/module/modules/CompressOptions.js +85 -101
- package/lib/module/modules/CompressOptions.js.map +1 -1
- package/lib/module/types/WebSocketBehavior.js +4 -0
- package/lib/module/types/WebSocketBehavior.js.map +1 -0
- package/lib/typescript/commonjs/_internal/native-modules/NativeUwsReactNative.d.ts +76 -0
- package/lib/typescript/commonjs/_internal/native-modules/NativeUwsReactNative.d.ts.map +1 -1
- package/lib/typescript/commonjs/modules/CompressOptions.d.ts +81 -0
- package/lib/typescript/commonjs/modules/CompressOptions.d.ts.map +1 -1
- package/lib/typescript/commonjs/types/WebSocket.d.ts +42 -43
- package/lib/typescript/commonjs/types/WebSocket.d.ts.map +1 -1
- package/lib/typescript/commonjs/types/WebSocketBehavior.d.ts +101 -0
- package/lib/typescript/commonjs/types/WebSocketBehavior.d.ts.map +1 -0
- package/lib/typescript/module/_internal/native-modules/NativeUwsReactNative.d.ts +76 -0
- package/lib/typescript/module/_internal/native-modules/NativeUwsReactNative.d.ts.map +1 -1
- package/lib/typescript/module/modules/CompressOptions.d.ts +81 -0
- package/lib/typescript/module/modules/CompressOptions.d.ts.map +1 -1
- package/lib/typescript/module/types/WebSocket.d.ts +42 -43
- package/lib/typescript/module/types/WebSocket.d.ts.map +1 -1
- package/lib/typescript/module/types/WebSocketBehavior.d.ts +101 -0
- package/lib/typescript/module/types/WebSocketBehavior.d.ts.map +1 -0
- package/lib/typescript/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/_internal/native-modules/NativeUwsReactNative.ts +95 -0
- package/src/modules/CompressOptions.ts +101 -101
- package/src/types/TemplatedApp.ts +3 -3
- package/src/types/WebSocket.ts +59 -60
- package/src/types/WebSocketBehavior.ts +161 -0
- package/src/types/index.ts +1 -1
- package/lib/commonjs/types/WebSocketBehaviour.js +0 -139
- package/lib/commonjs/types/WebSocketBehaviour.js.map +0 -1
- package/lib/module/types/WebSocketBehaviour.js +0 -139
- package/lib/module/types/WebSocketBehaviour.js.map +0 -1
- package/lib/typescript/commonjs/types/WebSocketBehaviour.d.ts +0 -1
- package/lib/typescript/commonjs/types/WebSocketBehaviour.d.ts.map +0 -1
- package/lib/typescript/module/types/WebSocketBehaviour.d.ts +0 -1
- package/lib/typescript/module/types/WebSocketBehaviour.d.ts.map +0 -1
- package/src/types/WebSocketBehaviour.ts +0 -137
package/README.md
CHANGED
|
@@ -5,11 +5,22 @@ The port of [**uWebSockets**](https://github.com/uNetworking/uWebSockets) librar
|
|
|
5
5
|
- **uWebSockets** is simple, secure & standards compliant web server for the most demanding of applications. See [**uWebSockets**](https://github.com/uNetworking/uWebSockets) for more information
|
|
6
6
|
- **uws-react-native** is library that allows you to easily use **uWebSockets** in your React Native through new architecture with JSI to the native C++
|
|
7
7
|
|
|
8
|
-
> ⚠️
|
|
8
|
+
> ⚠️ WebSocket server is not implemented yet
|
|
9
|
+
|
|
10
|
+
- [Installation](#installation)
|
|
11
|
+
- [From NPM Registry](#from-npm-registry)
|
|
12
|
+
- [From GitHub Packages](#from-github-packages)
|
|
13
|
+
- [Usage](#usage)
|
|
14
|
+
- [Compatibility](#compatibility)
|
|
15
|
+
- [Platform](#platform)
|
|
16
|
+
- [Unsupported APIs](#unsupported-apis)
|
|
17
|
+
- [New APIs](#new-apis)
|
|
18
|
+
- [Contributing](#contributing)
|
|
19
|
+
- [Development & Research](#development--research)
|
|
9
20
|
|
|
10
21
|
## Installation
|
|
11
22
|
|
|
12
|
-
We provide two registry homes where this library lives which can be used for your project. You can use either it
|
|
23
|
+
We provide two registry homes where this library lives which can be used for your project. You can use either it is from NPM registry or GitHub Packages. It has absolutely **no external JavaScript dependencies**
|
|
13
24
|
|
|
14
25
|
### From NPM Registry
|
|
15
26
|
|
|
@@ -68,7 +79,7 @@ pnpm install @rakadoank/uws-react-native
|
|
|
68
79
|
Since uws-react-native is a port of uWebSockets library for JavaScript, this library is really similar of how to use the [uWebSockets](https://github.com/uNetworking/uWebSockets) in C++, or the [uWebSockets.js](https://github.com/uNetworking/uWebSockets.js) for Node.js.
|
|
69
80
|
You can refer to the [uWebSockets.js](https://github.com/uNetworking/uWebSockets.js) example.
|
|
70
81
|
|
|
71
|
-
This repository does also contain the [example](https://github.com/RakaDoank/uws-react-native/blob/main/
|
|
82
|
+
This repository does also contain the [server example](https://github.com/RakaDoank/uws-react-native/blob/main/examples/app/src/screens/home/_use-server.ts). You can also refer to it, but it is currently for library development playground rather than proper example.
|
|
72
83
|
|
|
73
84
|
## Compatibility
|
|
74
85
|
|
|
@@ -94,6 +105,11 @@ There are some new APIs in uws-react-native. The most reason is because of the d
|
|
|
94
105
|
|
|
95
106
|
---
|
|
96
107
|
|
|
108
|
+
## Contributing
|
|
109
|
+
|
|
110
|
+
Thank you for your support to this project.
|
|
111
|
+
See [Contributing](https://github.com/RakaDoank/uws-react-native?tab=contributing-ov-file#contributing) for more information to help you get started with your contributions.
|
|
112
|
+
|
|
97
113
|
## Development & Research
|
|
98
114
|
|
|
99
115
|
uws-react-native is still in heavy development and research. All the uWebSockets instances are not fully implemented yet.
|
|
@@ -106,11 +122,11 @@ We are embracing the main chaos of supporting uWebSockets in React Native archit
|
|
|
106
122
|
|
|
107
123
|
Intentionally, we make the uWebSockets will runs in another thread, therefore we have to make sure the communication safety between uWebSockets runner thread to the JS thread and vice versa. In theory, we can make uWebSockets runs in the main thread, but the app will be unusable, and then force closing the app is the only way to stop the server.
|
|
108
124
|
|
|
109
|
-
Yet, we only use one dedicated thread per uWebSockets
|
|
125
|
+
Yet, we only use one dedicated thread per uWebSockets runner. I am in my own research to find better way to improve this by maximizing it to the hardware concurrency limit. Basically, if you run the `App` with two instance or more in JavaScript side, and with the same port listening number, you actually run the uWebSockets in multiple thread, but the JavaScript is still in single thread. It is single thread by default in React Native, we have no control of it.
|
|
110
126
|
|
|
111
127
|
We have another issue because of the uWebSockets runs in another thread. From the JSI C++ side, we have to assume any JavaScript functions as a callback especially the route method handler are asynchronous. We cannot make a sync call to the JavaScript function from an arbitrary thread to the JavaScript thread, and due to the asynchronous call, it makes the JavaScript call to the uWebSockets instances is late.
|
|
112
128
|
|
|
113
|
-
There some topics
|
|
129
|
+
There some topics regarding the threading
|
|
114
130
|
|
|
115
131
|
#### Predefined Instances
|
|
116
132
|
|
|
@@ -126,6 +142,10 @@ For the `onData` and `onDataV2`, we have predefined it with a single `onDataV2`
|
|
|
126
142
|
|
|
127
143
|
#### About Worker Thread
|
|
128
144
|
|
|
129
|
-
In theory, we can create another JavaScript runtime with [react-native-worklets](https://docs.swmansion.com/react-native-worklets/) and tie with our uWebSockets runner. It would solve a lot of late communication problem between uWebSockets runner and JavaScript thread that we embrace right now, but it also introduces new major issue, which is
|
|
145
|
+
In theory, we can create another JavaScript runtime with [react-native-worklets](https://docs.swmansion.com/react-native-worklets/) and tie with our uWebSockets runner. It would solve a lot of late communication problem between uWebSockets runner and JavaScript thread that we embrace right now, but it also introduces new major issue, which is making other native libraries unavailable.
|
|
146
|
+
|
|
147
|
+
Think of this sample case, you want to use `uws-react-native` server for a simple CRUD with a local database in an app. You probably know SQLite can be used in Android, iOS, macOS, even Windows app, with your own adapter or a known library that support SQLite integration in React Native such as [op-sqlite](https://github.com/OP-Engineering/op-sqlite), and [Expo SQLite](https://docs.expo.dev/versions/latest/sdk/sqlite). If you want to use that known library, this case would not works at all, because [op-sqlite](https://github.com/OP-Engineering/op-sqlite) and/or [Expo SQLite](https://docs.expo.dev/versions/latest/sdk/sqlite) is tied to the default JavaScript runtime. Even, you cannot use any React Native native libraries in arbitrary JavaScript thread that has created by [react-native-worklets](https://docs.swmansion.com/react-native-worklets/) if the library you want to use is using the default JavaScript runtime. If you really want to achieve the goal of this case, you have to create your own library for the SQLite database by yourself and tie-up with the JavaScript runtime. Probably, in the future we would still provide that worker thread with [react-native-worklets](https://docs.swmansion.com/react-native-worklets/).
|
|
148
|
+
|
|
149
|
+
##### Possibility Fixes
|
|
130
150
|
|
|
131
|
-
|
|
151
|
+
If the native library you want to use is using [react-native-nitro-modules](https://github.com/mrousavy/nitro), you can use the library in arbitrary JavaScript thread that created by [react-native-worklets](https://docs.swmansion.com/react-native-worklets/), because the [Nitro itself is fully runtime-agnostic](https://nitro.margelo.com/docs/guides/worklets). In short, our uWebSockets runner can run in truly multiple threads approach by making your JavaScript thread also run in multiple threads with [react-native-worklets](https://docs.swmansion.com/react-native-worklets/).
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
#include <UwsReactNativeSpecsJSI.h>
|
|
4
4
|
#include "app/TemplatedAppObject.h"
|
|
5
|
+
#include "uWebSockets/PerMessageDeflate.h"
|
|
5
6
|
|
|
6
7
|
namespace facebook::react {
|
|
7
8
|
|
|
@@ -25,6 +26,82 @@ public:
|
|
|
25
26
|
double id
|
|
26
27
|
/*facebook::jsi::Object socket*/);
|
|
27
28
|
|
|
29
|
+
double DISABLED(facebook::jsi::Runtime &rt) {
|
|
30
|
+
return uWS::DISABLED;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
double SHARED_COMPRESSOR(facebook::jsi::Runtime &rt) {
|
|
34
|
+
return uWS::SHARED_COMPRESSOR;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
double SHARED_DECOMPRESSOR(facebook::jsi::Runtime &rt) {
|
|
38
|
+
return uWS::SHARED_DECOMPRESSOR;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
double DEDICATED_COMPRESSOR_3KB(facebook::jsi::Runtime &rt) {
|
|
42
|
+
return uWS::DEDICATED_COMPRESSOR_3KB;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
double DEDICATED_COMPRESSOR_4KB(facebook::jsi::Runtime &rt) {
|
|
46
|
+
return uWS::DEDICATED_COMPRESSOR_4KB;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
double DEDICATED_COMPRESSOR_8KB(facebook::jsi::Runtime &rt) {
|
|
50
|
+
return uWS::DEDICATED_COMPRESSOR_8KB;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
double DEDICATED_COMPRESSOR_16KB(facebook::jsi::Runtime &rt) {
|
|
54
|
+
return uWS::DEDICATED_COMPRESSOR_16KB;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
double DEDICATED_COMPRESSOR_32KB(facebook::jsi::Runtime &rt) {
|
|
58
|
+
return uWS::DEDICATED_COMPRESSOR_32KB;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
double DEDICATED_COMPRESSOR_64KB(facebook::jsi::Runtime &rt) {
|
|
62
|
+
return uWS::DEDICATED_COMPRESSOR_64KB;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
double DEDICATED_COMPRESSOR_128KB(facebook::jsi::Runtime &rt) {
|
|
66
|
+
return uWS::DEDICATED_COMPRESSOR_128KB;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
double DEDICATED_COMPRESSOR_256KB(facebook::jsi::Runtime &rt) {
|
|
70
|
+
return uWS::DEDICATED_COMPRESSOR_256KB;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
double DEDICATED_DECOMPRESSOR_32KB(facebook::jsi::Runtime &rt) {
|
|
74
|
+
return uWS::DEDICATED_DECOMPRESSOR_32KB;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
double DEDICATED_DECOMPRESSOR_16KB(facebook::jsi::Runtime &rt) {
|
|
78
|
+
return uWS::DEDICATED_DECOMPRESSOR_16KB;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
double DEDICATED_DECOMPRESSOR_8KB(facebook::jsi::Runtime &rt) {
|
|
82
|
+
return uWS::DEDICATED_DECOMPRESSOR_8KB;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
double DEDICATED_DECOMPRESSOR_4KB(facebook::jsi::Runtime &rt) {
|
|
86
|
+
return uWS::DEDICATED_DECOMPRESSOR_4KB;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
double DEDICATED_DECOMPRESSOR_2KB(facebook::jsi::Runtime &rt) {
|
|
90
|
+
return uWS::DEDICATED_DECOMPRESSOR_2KB;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
double DEDICATED_DECOMPRESSOR_1KB(facebook::jsi::Runtime &rt) {
|
|
94
|
+
return uWS::DEDICATED_DECOMPRESSOR_1KB;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
double DEDICATED_DECOMPRESSOR_512B(facebook::jsi::Runtime &rt) {
|
|
98
|
+
return uWS::DEDICATED_DECOMPRESSOR_512B;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
double DEDICATED_DECOMPRESSOR(facebook::jsi::Runtime &rt) {
|
|
102
|
+
return uWS::DEDICATED_DECOMPRESSOR;
|
|
103
|
+
}
|
|
104
|
+
|
|
28
105
|
};
|
|
29
106
|
|
|
30
107
|
}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
#include "HttpResponseObject.h"
|
|
9
9
|
#include "HttpResponseObjectProvider.h"
|
|
10
10
|
#include "RecognizedString.h"
|
|
11
|
+
#include "WebSocketBehaviorImpl.h"
|
|
11
12
|
#include "uWebSockets/App.h"
|
|
12
13
|
|
|
13
14
|
namespace uws_react_native {
|
|
@@ -369,6 +370,33 @@ public:
|
|
|
369
370
|
compress);
|
|
370
371
|
}));
|
|
371
372
|
|
|
373
|
+
// TODO `WebSocketObject` and `WebSocketBehaviorImpl` are not properly implemented yet
|
|
374
|
+
// this->setProperty(rt,
|
|
375
|
+
// "ws",
|
|
376
|
+
// facebook::jsi::Function::createFromHostFunction(rt,
|
|
377
|
+
// facebook::jsi::PropNameID::forUtf8(rt, "ws"),
|
|
378
|
+
// 2,
|
|
379
|
+
// [&appRunner, &jsInvoker](facebook::jsi::Runtime &rt_1,
|
|
380
|
+
// const facebook::jsi::Value &thisValue,
|
|
381
|
+
// const facebook::jsi::Value *arguments,
|
|
382
|
+
// size_t count) -> facebook::jsi::Value {
|
|
383
|
+
//#ifdef REACT_NATIVE_DEBUG
|
|
384
|
+
// if(!arguments) {
|
|
385
|
+
// throw facebook::jsi::JSError(rt_1, "Expected pattern and WebSocketBehaviour argument");
|
|
386
|
+
// }
|
|
387
|
+
// if(!arguments[1].isObject()) {
|
|
388
|
+
// throw facebook::jsi::JSError(rt_1, "Expected a WebSocketBehaviour object in the second argument");
|
|
389
|
+
// }
|
|
390
|
+
//#endif
|
|
391
|
+
//
|
|
392
|
+
// auto pattern = RecognizedString(rt_1, arguments[0]).getString();
|
|
393
|
+
// auto behavior = WebSocketBehaviorImpl(rt_1, jsInvoker, arguments[1].asObject(rt_1));
|
|
394
|
+
//
|
|
395
|
+
// appRunner.app.ws(pattern, std::move(behavior));
|
|
396
|
+
//
|
|
397
|
+
// return {rt_1, thisValue};
|
|
398
|
+
// }));
|
|
399
|
+
|
|
372
400
|
// +++++ ROUTER +++++
|
|
373
401
|
|
|
374
402
|
this->setProperty(rt,
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <jsi/jsi.h>
|
|
5
|
+
#include "WebSocketObject.h"
|
|
6
|
+
#include "jsi/Buffer.h"
|
|
7
|
+
#include "uWebSockets/App.h"
|
|
8
|
+
|
|
9
|
+
namespace uws_react_native {
|
|
10
|
+
|
|
11
|
+
struct WebSocketBehaviorImpl : uWS::App::WebSocketBehavior<facebook::jsi::Value> {
|
|
12
|
+
|
|
13
|
+
public:
|
|
14
|
+
WebSocketBehaviorImpl(facebook::jsi::Runtime &rt,
|
|
15
|
+
std::shared_ptr<facebook::react::CallInvoker> &jsInvoker,
|
|
16
|
+
facebook::jsi::Object &&object) {
|
|
17
|
+
|
|
18
|
+
// AppRunner thread
|
|
19
|
+
{
|
|
20
|
+
auto prop = object.getProperty(rt, "close");
|
|
21
|
+
#ifdef REACT_NATIVE_DEBUG
|
|
22
|
+
if(!prop.isObject()) {
|
|
23
|
+
throw facebook::jsi::JSError(rt, "The \"close\" property must be a function");
|
|
24
|
+
}
|
|
25
|
+
#endif
|
|
26
|
+
|
|
27
|
+
auto obj = prop.asObject(rt);
|
|
28
|
+
|
|
29
|
+
#ifdef REACT_NATIVE_DEBUG
|
|
30
|
+
if(!obj.isFunction(rt)) {
|
|
31
|
+
throw facebook::jsi::JSError(rt, "The \"close\" property must be a function");
|
|
32
|
+
}
|
|
33
|
+
#endif
|
|
34
|
+
|
|
35
|
+
this->close = [fn = facebook::react::AsyncCallback(rt, std::move(obj).asFunction(rt), jsInvoker)](auto *ws, int code, std::string_view message) {
|
|
36
|
+
fn.call([sharedWs = std::make_shared<uWS::WebSocket<false, true, facebook::jsi::Object>>(*ws), code, message](facebook::jsi::Runtime &rt_1, facebook::jsi::Function &cb) {
|
|
37
|
+
cb.call(rt_1,
|
|
38
|
+
WebSocketObject(rt_1, sharedWs),
|
|
39
|
+
code,
|
|
40
|
+
facebook::jsi::ArrayBuffer(rt_1,
|
|
41
|
+
std::make_shared<StringViewMutableBuffer>(message)));
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <jsi/jsi.h>
|
|
5
|
+
#include "uWebSockets/App.h"
|
|
6
|
+
|
|
7
|
+
namespace uws_react_native {
|
|
8
|
+
|
|
9
|
+
/// Only use this in the JavaScript thread
|
|
10
|
+
struct WebSocketObject : public facebook::jsi::Object {
|
|
11
|
+
|
|
12
|
+
public:
|
|
13
|
+
WebSocketObject(facebook::jsi::Runtime &rt,
|
|
14
|
+
const std::shared_ptr<uWS::WebSocket<false, true, facebook::jsi::Object>> &ws) : facebook::jsi::Object(rt) {
|
|
15
|
+
this->setProperty(rt,
|
|
16
|
+
"close",
|
|
17
|
+
facebook::jsi::Function::createFromHostFunction(rt,
|
|
18
|
+
facebook::jsi::PropNameID::forUtf8(rt, "close"),
|
|
19
|
+
0,
|
|
20
|
+
[ws](facebook::jsi::Runtime &rt_1,
|
|
21
|
+
const facebook::jsi::Value &thisValue,
|
|
22
|
+
const facebook::jsi::Value *arguments,
|
|
23
|
+
size_t count) -> facebook::jsi::Value {
|
|
24
|
+
ws->close();
|
|
25
|
+
return {rt_1, thisValue};
|
|
26
|
+
}));
|
|
27
|
+
|
|
28
|
+
this->setProperty(rt,
|
|
29
|
+
"cork",
|
|
30
|
+
facebook::jsi::Function::createFromHostFunction(rt,
|
|
31
|
+
facebook::jsi::PropNameID::forUtf8(rt, "cork"),
|
|
32
|
+
1,
|
|
33
|
+
[ws](facebook::jsi::Runtime &rt_1,
|
|
34
|
+
const facebook::jsi::Value &thisValue,
|
|
35
|
+
const facebook::jsi::Value *arguments,
|
|
36
|
+
size_t count) -> facebook::jsi::Value {
|
|
37
|
+
#ifdef REACT_NATIVE_DEBUG
|
|
38
|
+
if(!arguments) {
|
|
39
|
+
throw facebook::jsi::JSError(rt_1, "Expected a function from the first argument");
|
|
40
|
+
}
|
|
41
|
+
if(!arguments[0].isObject()) {
|
|
42
|
+
throw facebook::jsi::JSError(rt_1, "Expected a function from the first argument");
|
|
43
|
+
}
|
|
44
|
+
#endif
|
|
45
|
+
|
|
46
|
+
auto obj = arguments[0].asObject(rt_1);
|
|
47
|
+
|
|
48
|
+
#ifdef REACT_NATIVE_DEBUG
|
|
49
|
+
if(!obj.isFunction(rt_1)) {
|
|
50
|
+
throw facebook::jsi::JSError(rt_1, "Expected a function from the first argument");
|
|
51
|
+
}
|
|
52
|
+
#endif
|
|
53
|
+
|
|
54
|
+
ws->cork([&rt_1, callback = std::move(obj).asFunction(rt_1)] {
|
|
55
|
+
callback.call(rt_1);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
return {rt_1, thisValue};
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../../../src","sources":["_internal/native-modules/NativeUwsReactNative.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAMA;AACA;AACA;AAFA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../../../src","sources":["_internal/native-modules/NativeUwsReactNative.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAMA;AACA;AACA;AAFA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GA8HeC,gCAAmB,CAACC,YAAY,CAC9C,gBACD,CAAC","ignoreList":[]}
|
|
@@ -1,103 +1,91 @@
|
|
|
1
|
-
// import NativeReactNativeEcho from "../_internal/native-modules/NativeUwsReactNative"
|
|
2
|
-
|
|
3
|
-
// /**
|
|
4
|
-
// * WebSocket compression options. Combine any compressor with any decompressor using bitwise OR.
|
|
5
|
-
// */
|
|
6
|
-
// export enum CompressOptions {
|
|
7
|
-
// /**
|
|
8
|
-
// * No compression (always a good idea if you operate using an efficient binary protocol)
|
|
9
|
-
// */
|
|
10
|
-
// DISABLED = -1,
|
|
11
|
-
|
|
12
|
-
// /**
|
|
13
|
-
// * Zero memory overhead compression.
|
|
14
|
-
// */
|
|
15
|
-
// SHARED_COMPRESSOR = -1,
|
|
16
|
-
|
|
17
|
-
// /**
|
|
18
|
-
// * Zero memory overhead decompression.
|
|
19
|
-
// */
|
|
20
|
-
// SHARED_DECOMPRESSOR = -1,
|
|
21
|
-
|
|
22
|
-
// /**
|
|
23
|
-
// * Sliding dedicated compress window, requires 3KB of memory per socket
|
|
24
|
-
// */
|
|
25
|
-
// DEDICATED_COMPRESSOR_3KB = -1,
|
|
26
|
-
|
|
27
|
-
// /**
|
|
28
|
-
// * Sliding dedicated compress window, requires 4KB of memory per socket
|
|
29
|
-
// */
|
|
30
|
-
// DEDICATED_COMPRESSOR_4KB = -1,
|
|
31
|
-
|
|
32
|
-
// /**
|
|
33
|
-
// * Sliding dedicated compress window, requires 8KB of memory per socket
|
|
34
|
-
// */
|
|
35
|
-
// DEDICATED_COMPRESSOR_8KB = -1,
|
|
36
|
-
|
|
37
|
-
// /**
|
|
38
|
-
// * Sliding dedicated compress window, requires 16KB of memory per socket
|
|
39
|
-
// */
|
|
40
|
-
// DEDICATED_COMPRESSOR_16KB = -1,
|
|
41
|
-
|
|
42
|
-
// /**
|
|
43
|
-
// * Sliding dedicated compress window, requires 32KB of memory per socket
|
|
44
|
-
// */
|
|
45
|
-
// DEDICATED_COMPRESSOR_32KB = -1,
|
|
46
|
-
|
|
47
|
-
// /**
|
|
48
|
-
// * Sliding dedicated compress window, requires 64KB of memory per socket
|
|
49
|
-
// */
|
|
50
|
-
// DEDICATED_COMPRESSOR_64KB = -1,
|
|
51
|
-
|
|
52
|
-
// /**
|
|
53
|
-
// * Sliding dedicated compress window, requires 128KB of memory per socket
|
|
54
|
-
// */
|
|
55
|
-
// DEDICATED_COMPRESSOR_128KB = -1,
|
|
56
|
-
|
|
57
|
-
// /**
|
|
58
|
-
// * Sliding dedicated compress window, requires 256KB of memory per socket
|
|
59
|
-
// */
|
|
60
|
-
// DEDICATED_COMPRESSOR_256KB = -1,
|
|
61
|
-
|
|
62
|
-
// /**
|
|
63
|
-
// * Sliding dedicated decompress window, requires 32KB of memory per socket (plus about 23KB)
|
|
64
|
-
// */
|
|
65
|
-
// DEDICATED_DECOMPRESSOR_32KB = -1,
|
|
66
|
-
|
|
67
|
-
// /**
|
|
68
|
-
// * Sliding dedicated decompress window, requires 16KB of memory per socket (plus about 23KB)
|
|
69
|
-
// */
|
|
70
|
-
// DEDICATED_DECOMPRESSOR_16KB = -1,
|
|
71
|
-
|
|
72
|
-
// /**
|
|
73
|
-
// * Sliding dedicated decompress window, requires 8KB of memory per socket (plus about 23KB)
|
|
74
|
-
// */
|
|
75
|
-
// DEDICATED_DECOMPRESSOR_8KB = -1,
|
|
76
|
-
|
|
77
|
-
// /**
|
|
78
|
-
// * Sliding dedicated decompress window, requires 4KB of memory per socket (plus about 23KB)
|
|
79
|
-
// */
|
|
80
|
-
// DEDICATED_DECOMPRESSOR_4KB = -1,
|
|
81
|
-
|
|
82
|
-
// /**
|
|
83
|
-
// * Sliding dedicated decompress window, requires 2KB of memory per socket (plus about 23KB)
|
|
84
|
-
// */
|
|
85
|
-
// DEDICATED_DECOMPRESSOR_2KB = -1,
|
|
86
|
-
|
|
87
|
-
// /**
|
|
88
|
-
// * Sliding dedicated decompress window, requires 1KB of memory per socket (plus about 23KB)
|
|
89
|
-
// */
|
|
90
|
-
// DEDICATED_DECOMPRESSOR_1KB = -1,
|
|
91
|
-
|
|
92
|
-
// /**
|
|
93
|
-
// * Sliding dedicated decompress window, requires 512B of memory per socket (plus about 23KB)
|
|
94
|
-
// */
|
|
95
|
-
// DEDICATED_DECOMPRESSOR_512B = -1,
|
|
96
|
-
|
|
97
|
-
// /**
|
|
98
|
-
// * Sliding dedicated decompress window, requires 32KB of memory per socket (plus about 23KB)
|
|
99
|
-
// */
|
|
100
|
-
// DEDICATED_DECOMPRESSOR = -1,
|
|
101
|
-
// }
|
|
102
1
|
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.CompressOptions = void 0;
|
|
7
|
+
var _NativeUwsReactNative = _interopRequireDefault(require("../_internal/native-modules/NativeUwsReactNative.js"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
/**
|
|
10
|
+
* WebSocket compression options. Combine any compressor with any decompressor using bitwise OR.
|
|
11
|
+
*/
|
|
12
|
+
let CompressOptions = exports.CompressOptions = function (CompressOptions) {
|
|
13
|
+
/**
|
|
14
|
+
* No compression (always a good idea if you operate using an efficient binary protocol)
|
|
15
|
+
*/
|
|
16
|
+
CompressOptions[CompressOptions["DISABLED"] = _NativeUwsReactNative.default.DISABLED()] = "DISABLED";
|
|
17
|
+
/**
|
|
18
|
+
* Zero memory overhead compression.
|
|
19
|
+
*/
|
|
20
|
+
CompressOptions[CompressOptions["SHARED_COMPRESSOR"] = _NativeUwsReactNative.default.SHARED_COMPRESSOR()] = "SHARED_COMPRESSOR";
|
|
21
|
+
/**
|
|
22
|
+
* Zero memory overhead decompression.
|
|
23
|
+
*/
|
|
24
|
+
CompressOptions[CompressOptions["SHARED_DECOMPRESSOR"] = _NativeUwsReactNative.default.SHARED_DECOMPRESSOR()] = "SHARED_DECOMPRESSOR";
|
|
25
|
+
/**
|
|
26
|
+
* Sliding dedicated compress window, requires 3KB of memory per socket
|
|
27
|
+
*/
|
|
28
|
+
CompressOptions[CompressOptions["DEDICATED_COMPRESSOR_3KB"] = _NativeUwsReactNative.default.DEDICATED_COMPRESSOR_3KB()] = "DEDICATED_COMPRESSOR_3KB";
|
|
29
|
+
/**
|
|
30
|
+
* Sliding dedicated compress window, requires 4KB of memory per socket
|
|
31
|
+
*/
|
|
32
|
+
CompressOptions[CompressOptions["DEDICATED_COMPRESSOR_4KB"] = _NativeUwsReactNative.default.DEDICATED_COMPRESSOR_4KB()] = "DEDICATED_COMPRESSOR_4KB";
|
|
33
|
+
/**
|
|
34
|
+
* Sliding dedicated compress window, requires 8KB of memory per socket
|
|
35
|
+
*/
|
|
36
|
+
CompressOptions[CompressOptions["DEDICATED_COMPRESSOR_8KB"] = _NativeUwsReactNative.default.DEDICATED_COMPRESSOR_8KB()] = "DEDICATED_COMPRESSOR_8KB";
|
|
37
|
+
/**
|
|
38
|
+
* Sliding dedicated compress window, requires 16KB of memory per socket
|
|
39
|
+
*/
|
|
40
|
+
CompressOptions[CompressOptions["DEDICATED_COMPRESSOR_16KB"] = _NativeUwsReactNative.default.DEDICATED_COMPRESSOR_16KB()] = "DEDICATED_COMPRESSOR_16KB";
|
|
41
|
+
/**
|
|
42
|
+
* Sliding dedicated compress window, requires 32KB of memory per socket
|
|
43
|
+
*/
|
|
44
|
+
CompressOptions[CompressOptions["DEDICATED_COMPRESSOR_32KB"] = _NativeUwsReactNative.default.DEDICATED_COMPRESSOR_32KB()] = "DEDICATED_COMPRESSOR_32KB";
|
|
45
|
+
/**
|
|
46
|
+
* Sliding dedicated compress window, requires 64KB of memory per socket
|
|
47
|
+
*/
|
|
48
|
+
CompressOptions[CompressOptions["DEDICATED_COMPRESSOR_64KB"] = _NativeUwsReactNative.default.DEDICATED_COMPRESSOR_64KB()] = "DEDICATED_COMPRESSOR_64KB";
|
|
49
|
+
/**
|
|
50
|
+
* Sliding dedicated compress window, requires 128KB of memory per socket
|
|
51
|
+
*/
|
|
52
|
+
CompressOptions[CompressOptions["DEDICATED_COMPRESSOR_128KB"] = _NativeUwsReactNative.default.DEDICATED_COMPRESSOR_128KB()] = "DEDICATED_COMPRESSOR_128KB";
|
|
53
|
+
/**
|
|
54
|
+
* Sliding dedicated compress window, requires 256KB of memory per socket
|
|
55
|
+
*/
|
|
56
|
+
CompressOptions[CompressOptions["DEDICATED_COMPRESSOR_256KB"] = _NativeUwsReactNative.default.DEDICATED_COMPRESSOR_256KB()] = "DEDICATED_COMPRESSOR_256KB";
|
|
57
|
+
/**
|
|
58
|
+
* Sliding dedicated decompress window, requires 32KB of memory per socket (plus about 23KB)
|
|
59
|
+
*/
|
|
60
|
+
CompressOptions[CompressOptions["DEDICATED_DECOMPRESSOR_32KB"] = _NativeUwsReactNative.default.DEDICATED_DECOMPRESSOR_32KB()] = "DEDICATED_DECOMPRESSOR_32KB";
|
|
61
|
+
/**
|
|
62
|
+
* Sliding dedicated decompress window, requires 16KB of memory per socket (plus about 23KB)
|
|
63
|
+
*/
|
|
64
|
+
CompressOptions[CompressOptions["DEDICATED_DECOMPRESSOR_16KB"] = _NativeUwsReactNative.default.DEDICATED_DECOMPRESSOR_16KB()] = "DEDICATED_DECOMPRESSOR_16KB";
|
|
65
|
+
/**
|
|
66
|
+
* Sliding dedicated decompress window, requires 8KB of memory per socket (plus about 23KB)
|
|
67
|
+
*/
|
|
68
|
+
CompressOptions[CompressOptions["DEDICATED_DECOMPRESSOR_8KB"] = _NativeUwsReactNative.default.DEDICATED_DECOMPRESSOR_8KB()] = "DEDICATED_DECOMPRESSOR_8KB";
|
|
69
|
+
/**
|
|
70
|
+
* Sliding dedicated decompress window, requires 4KB of memory per socket (plus about 23KB)
|
|
71
|
+
*/
|
|
72
|
+
CompressOptions[CompressOptions["DEDICATED_DECOMPRESSOR_4KB"] = _NativeUwsReactNative.default.DEDICATED_DECOMPRESSOR_4KB()] = "DEDICATED_DECOMPRESSOR_4KB";
|
|
73
|
+
/**
|
|
74
|
+
* Sliding dedicated decompress window, requires 2KB of memory per socket (plus about 23KB)
|
|
75
|
+
*/
|
|
76
|
+
CompressOptions[CompressOptions["DEDICATED_DECOMPRESSOR_2KB"] = _NativeUwsReactNative.default.DEDICATED_DECOMPRESSOR_2KB()] = "DEDICATED_DECOMPRESSOR_2KB";
|
|
77
|
+
/**
|
|
78
|
+
* Sliding dedicated decompress window, requires 1KB of memory per socket (plus about 23KB)
|
|
79
|
+
*/
|
|
80
|
+
CompressOptions[CompressOptions["DEDICATED_DECOMPRESSOR_1KB"] = _NativeUwsReactNative.default.DEDICATED_DECOMPRESSOR_1KB()] = "DEDICATED_DECOMPRESSOR_1KB";
|
|
81
|
+
/**
|
|
82
|
+
* Sliding dedicated decompress window, requires 512B of memory per socket (plus about 23KB)
|
|
83
|
+
*/
|
|
84
|
+
CompressOptions[CompressOptions["DEDICATED_DECOMPRESSOR_512B"] = _NativeUwsReactNative.default.DEDICATED_DECOMPRESSOR_512B()] = "DEDICATED_DECOMPRESSOR_512B";
|
|
85
|
+
/**
|
|
86
|
+
* Sliding dedicated decompress window, requires 32KB of memory per socket (plus about 23KB)
|
|
87
|
+
*/
|
|
88
|
+
CompressOptions[CompressOptions["DEDICATED_DECOMPRESSOR"] = _NativeUwsReactNative.default.DEDICATED_DECOMPRESSOR()] = "DEDICATED_DECOMPRESSOR";
|
|
89
|
+
return CompressOptions;
|
|
90
|
+
}({});
|
|
103
91
|
//# sourceMappingURL=CompressOptions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["modules/CompressOptions.ts"],"mappings":"AAAA
|
|
1
|
+
{"version":3,"names":["_NativeUwsReactNative","_interopRequireDefault","require","e","__esModule","default","CompressOptions","exports","NativeUwsReactNative","DISABLED","SHARED_COMPRESSOR","SHARED_DECOMPRESSOR","DEDICATED_COMPRESSOR_3KB","DEDICATED_COMPRESSOR_4KB","DEDICATED_COMPRESSOR_8KB","DEDICATED_COMPRESSOR_16KB","DEDICATED_COMPRESSOR_32KB","DEDICATED_COMPRESSOR_64KB","DEDICATED_COMPRESSOR_128KB","DEDICATED_COMPRESSOR_256KB","DEDICATED_DECOMPRESSOR_32KB","DEDICATED_DECOMPRESSOR_16KB","DEDICATED_DECOMPRESSOR_8KB","DEDICATED_DECOMPRESSOR_4KB","DEDICATED_DECOMPRESSOR_2KB","DEDICATED_DECOMPRESSOR_1KB","DEDICATED_DECOMPRESSOR_512B","DEDICATED_DECOMPRESSOR"],"sourceRoot":"../../../src","sources":["modules/CompressOptions.ts"],"mappings":";;;;;;AAAA,IAAAA,qBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAmF,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEnF;AACA;AACA;AAFA,IAGYG,eAAe,GAAAC,OAAA,CAAAD,eAAA,aAAfA,eAAe;EAC1B;AACD;AACA;EAHYA,eAAe,CAAfA,eAAe,eAIXE,6BAAoB,CAACC,QAAQ,CAAC,CAAC;EAE9C;AACD;AACA;EARYH,eAAe,CAAfA,eAAe,wBASJE,6BAAoB,CAACE,iBAAiB,CAAC,CAAC;EAE9D;AACD;AACA;EAbYJ,eAAe,CAAfA,eAAe,0BAcFE,6BAAoB,CAACG,mBAAmB,CAAC,CAAC;EAElE;AACD;AACA;EAlBYL,eAAe,CAAfA,eAAe,+BAmBCE,6BAAoB,CAACI,wBAAwB,CAAC,CAAC;EAE1E;AACD;AACA;EAvBYN,eAAe,CAAfA,eAAe,+BAwBCE,6BAAoB,CAACK,wBAAwB,CAAC,CAAC;EAE1E;AACD;AACA;EA5BYP,eAAe,CAAfA,eAAe,+BA6BCE,6BAAoB,CAACM,wBAAwB,CAAC,CAAC;EAE1E;AACD;AACA;EAjCYR,eAAe,CAAfA,eAAe,gCAkCEE,6BAAoB,CAACO,yBAAyB,CAAC,CAAC;EAE5E;AACD;AACA;EAtCYT,eAAe,CAAfA,eAAe,gCAuCEE,6BAAoB,CAACQ,yBAAyB,CAAC,CAAC;EAE5E;AACD;AACA;EA3CYV,eAAe,CAAfA,eAAe,gCA4CEE,6BAAoB,CAACS,yBAAyB,CAAC,CAAC;EAE5E;AACD;AACA;EAhDYX,eAAe,CAAfA,eAAe,iCAiDGE,6BAAoB,CAACU,0BAA0B,CAAC,CAAC;EAE9E;AACD;AACA;EArDYZ,eAAe,CAAfA,eAAe,iCAsDGE,6BAAoB,CAACW,0BAA0B,CAAC,CAAC;EAE9E;AACD;AACA;EA1DYb,eAAe,CAAfA,eAAe,kCA2DIE,6BAAoB,CAACY,2BAA2B,CAAC,CAAC;EAEhF;AACD;AACA;EA/DYd,eAAe,CAAfA,eAAe,kCAgEIE,6BAAoB,CAACa,2BAA2B,CAAC,CAAC;EAEhF;AACD;AACA;EApEYf,eAAe,CAAfA,eAAe,iCAqEGE,6BAAoB,CAACc,0BAA0B,CAAC,CAAC;EAE9E;AACD;AACA;EAzEYhB,eAAe,CAAfA,eAAe,iCA0EGE,6BAAoB,CAACe,0BAA0B,CAAC,CAAC;EAE9E;AACD;AACA;EA9EYjB,eAAe,CAAfA,eAAe,iCA+EGE,6BAAoB,CAACgB,0BAA0B,CAAC,CAAC;EAE9E;AACD;AACA;EAnFYlB,eAAe,CAAfA,eAAe,iCAoFGE,6BAAoB,CAACiB,0BAA0B,CAAC,CAAC;EAE9E;AACD;AACA;EAxFYnB,eAAe,CAAfA,eAAe,kCAyFIE,6BAAoB,CAACkB,2BAA2B,CAAC,CAAC;EAEhF;AACD;AACA;EA7FYpB,eAAe,CAAfA,eAAe,6BA8FAE,6BAAoB,CAACmB,sBAAsB,CAAC,CAAC;EAAA,OA9F5DrB,eAAe;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/WebSocketBehavior.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../../../src","sources":["_internal/native-modules/NativeUwsReactNative.ts"],"mappings":";;AAAA,SACCA,mBAAmB,QAGb,cAAc;;AAErB;AACA;AACA;;
|
|
1
|
+
{"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../../../src","sources":["_internal/native-modules/NativeUwsReactNative.ts"],"mappings":";;AAAA,SACCA,mBAAmB,QAGb,cAAc;;AAErB;AACA;AACA;;AA4HA,eAAeA,mBAAmB,CAACC,YAAY,CAC9C,gBACD,CAAC","ignoreList":[]}
|