uws-react-native 0.0.1-alpha.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/LICENSE +201 -0
- package/README.md +84 -0
- package/UwsReactNative.podspec +71 -0
- package/android/build.gradle.kts +138 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/id/sufeni/oss/uwsreactnative/UwsReactNativePackage.kt +18 -0
- package/apple/OnLoad.mm +17 -0
- package/cpp/CMakeLists.txt +154 -0
- package/cpp/UwsReactNativeModule.cpp +191 -0
- package/cpp/UwsReactNativeModule.h +30 -0
- package/cpp/app/AppHost.h +37 -0
- package/cpp/app/AppRunner.h +88 -0
- package/cpp/app/CMakeLists.txt +39 -0
- package/cpp/app/HttpRequestObject.h +173 -0
- package/cpp/app/HttpResponseObject.h +623 -0
- package/cpp/app/RecognizedString.h +71 -0
- package/cpp/app/TemplatedAppObject.h +472 -0
- package/cpp/bridging/ArrayBuffer.h +150 -0
- package/cpp/bridging/CMakeLists.txt +34 -0
- package/cpp/jsi/Buffer.h +91 -0
- package/cpp/jsi/CMakeLists.txt +34 -0
- package/cpp/uSockets/bsd.c +767 -0
- package/cpp/uSockets/context.c +524 -0
- package/cpp/uSockets/crypto/openssl.c +858 -0
- package/cpp/uSockets/crypto/sni_tree.cpp +218 -0
- package/cpp/uSockets/eventing/asio.cpp +475 -0
- package/cpp/uSockets/eventing/epoll_kqueue.c +458 -0
- package/cpp/uSockets/eventing/gcd.c +278 -0
- package/cpp/uSockets/eventing/libuv.c +305 -0
- package/cpp/uSockets/internal/eventing/asio.h +45 -0
- package/cpp/uSockets/internal/eventing/epoll_kqueue.h +67 -0
- package/cpp/uSockets/internal/eventing/gcd.h +40 -0
- package/cpp/uSockets/internal/eventing/libuv.h +45 -0
- package/cpp/uSockets/internal/internal.h +224 -0
- package/cpp/uSockets/internal/loop_data.h +38 -0
- package/cpp/uSockets/internal/networking/bsd.h +109 -0
- package/cpp/uSockets/io_uring/internal.h +98 -0
- package/cpp/uSockets/io_uring/io_context.c +302 -0
- package/cpp/uSockets/io_uring/io_loop.c +422 -0
- package/cpp/uSockets/io_uring/io_socket.c +139 -0
- package/cpp/uSockets/libusockets.h +350 -0
- package/cpp/uSockets/loop.c +396 -0
- package/cpp/uSockets/quic.c +1071 -0
- package/cpp/uSockets/quic.h +68 -0
- package/cpp/uSockets/socket.c +231 -0
- package/cpp/uSockets/udp.c +151 -0
- package/cpp/uWebSockets/uWebSockets/App.h +676 -0
- package/cpp/uWebSockets/uWebSockets/AsyncSocket.h +376 -0
- package/cpp/uWebSockets/uWebSockets/AsyncSocketData.h +94 -0
- package/cpp/uWebSockets/uWebSockets/BloomFilter.h +83 -0
- package/cpp/uWebSockets/uWebSockets/CachingApp.h +115 -0
- package/cpp/uWebSockets/uWebSockets/ChunkedEncoding.h +237 -0
- package/cpp/uWebSockets/uWebSockets/ClientApp.h +36 -0
- package/cpp/uWebSockets/uWebSockets/Http3App.h +140 -0
- package/cpp/uWebSockets/uWebSockets/Http3Context.h +157 -0
- package/cpp/uWebSockets/uWebSockets/Http3ContextData.h +21 -0
- package/cpp/uWebSockets/uWebSockets/Http3Request.h +22 -0
- package/cpp/uWebSockets/uWebSockets/Http3Response.h +120 -0
- package/cpp/uWebSockets/uWebSockets/Http3ResponseData.h +25 -0
- package/cpp/uWebSockets/uWebSockets/HttpContext.h +521 -0
- package/cpp/uWebSockets/uWebSockets/HttpContextData.h +60 -0
- package/cpp/uWebSockets/uWebSockets/HttpErrors.h +53 -0
- package/cpp/uWebSockets/uWebSockets/HttpParser.h +747 -0
- package/cpp/uWebSockets/uWebSockets/HttpResponse.h +605 -0
- package/cpp/uWebSockets/uWebSockets/HttpResponseData.h +123 -0
- package/cpp/uWebSockets/uWebSockets/HttpRouter.h +384 -0
- package/cpp/uWebSockets/uWebSockets/LocalCluster.h +64 -0
- package/cpp/uWebSockets/uWebSockets/Loop.h +238 -0
- package/cpp/uWebSockets/uWebSockets/LoopData.h +113 -0
- package/cpp/uWebSockets/uWebSockets/MessageParser.h +64 -0
- package/cpp/uWebSockets/uWebSockets/MoveOnlyFunction.h +389 -0
- package/cpp/uWebSockets/uWebSockets/Multipart.h +231 -0
- package/cpp/uWebSockets/uWebSockets/PerMessageDeflate.h +303 -0
- package/cpp/uWebSockets/uWebSockets/ProxyParser.h +187 -0
- package/cpp/uWebSockets/uWebSockets/QueryParser.h +120 -0
- package/cpp/uWebSockets/uWebSockets/TopicTree.h +364 -0
- package/cpp/uWebSockets/uWebSockets/Utilities.h +66 -0
- package/cpp/uWebSockets/uWebSockets/WebSocket.h +407 -0
- package/cpp/uWebSockets/uWebSockets/WebSocketContext.h +436 -0
- package/cpp/uWebSockets/uWebSockets/WebSocketContextData.h +109 -0
- package/cpp/uWebSockets/uWebSockets/WebSocketData.h +86 -0
- package/cpp/uWebSockets/uWebSockets/WebSocketExtensions.h +256 -0
- package/cpp/uWebSockets/uWebSockets/WebSocketHandshake.h +145 -0
- package/cpp/uWebSockets/uWebSockets/WebSocketProtocol.h +525 -0
- package/lib/commonjs/_internal/native-modules/NativeReactNativeUws.js +12 -0
- package/lib/commonjs/_internal/native-modules/NativeReactNativeUws.js.map +1 -0
- package/lib/commonjs/index.js +28 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/modules/App.js +17 -0
- package/lib/commonjs/modules/App.js.map +1 -0
- package/lib/commonjs/modules/CompressOptions.js +103 -0
- package/lib/commonjs/modules/CompressOptions.js.map +1 -0
- package/lib/commonjs/modules/EnvironmentVariables.js +17 -0
- package/lib/commonjs/modules/EnvironmentVariables.js.map +1 -0
- package/lib/commonjs/modules/ListenOptions.js +12 -0
- package/lib/commonjs/modules/ListenOptions.js.map +1 -0
- package/lib/commonjs/modules/SSLApp.js +15 -0
- package/lib/commonjs/modules/SSLApp.js.map +1 -0
- package/lib/commonjs/modules/getParts.js +28 -0
- package/lib/commonjs/modules/getParts.js.map +1 -0
- package/lib/commonjs/modules/index.js +61 -0
- package/lib/commonjs/modules/index.js.map +1 -0
- package/lib/commonjs/modules/us_listen_socket_close.js +21 -0
- package/lib/commonjs/modules/us_listen_socket_close.js.map +1 -0
- package/lib/commonjs/modules/us_socket_local_port.js +22 -0
- package/lib/commonjs/modules/us_socket_local_port.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/types/AppDescriptor.js +2 -0
- package/lib/commonjs/types/AppDescriptor.js.map +1 -0
- package/lib/commonjs/types/AppOptions.js +2 -0
- package/lib/commonjs/types/AppOptions.js.map +1 -0
- package/lib/commonjs/types/HttpRequest.js +6 -0
- package/lib/commonjs/types/HttpRequest.js.map +1 -0
- package/lib/commonjs/types/HttpResponse.js +6 -0
- package/lib/commonjs/types/HttpResponse.js.map +1 -0
- package/lib/commonjs/types/HttpRouterOptions.js +2 -0
- package/lib/commonjs/types/HttpRouterOptions.js.map +1 -0
- package/lib/commonjs/types/MultipartField.js +2 -0
- package/lib/commonjs/types/MultipartField.js.map +1 -0
- package/lib/commonjs/types/RecognizedString.js +2 -0
- package/lib/commonjs/types/RecognizedString.js.map +1 -0
- package/lib/commonjs/types/TemplatedApp.js +6 -0
- package/lib/commonjs/types/TemplatedApp.js.map +1 -0
- package/lib/commonjs/types/WebSocket.js +6 -0
- package/lib/commonjs/types/WebSocket.js.map +1 -0
- package/lib/commonjs/types/WebSocketBehaviour.js +139 -0
- package/lib/commonjs/types/WebSocketBehaviour.js.map +1 -0
- package/lib/commonjs/types/index.js +2 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/commonjs/types/us_listen_socket.js +2 -0
- package/lib/commonjs/types/us_listen_socket.js.map +1 -0
- package/lib/commonjs/types/us_socket.js +2 -0
- package/lib/commonjs/types/us_socket.js.map +1 -0
- package/lib/commonjs/types/us_socket_context_t.js +2 -0
- package/lib/commonjs/types/us_socket_context_t.js.map +1 -0
- package/lib/module/_internal/native-modules/NativeReactNativeUws.js +10 -0
- package/lib/module/_internal/native-modules/NativeReactNativeUws.js.map +1 -0
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/modules/App.js +12 -0
- package/lib/module/modules/App.js.map +1 -0
- package/lib/module/modules/CompressOptions.js +103 -0
- package/lib/module/modules/CompressOptions.js.map +1 -0
- package/lib/module/modules/EnvironmentVariables.js +13 -0
- package/lib/module/modules/EnvironmentVariables.js.map +1 -0
- package/lib/module/modules/ListenOptions.js +8 -0
- package/lib/module/modules/ListenOptions.js.map +1 -0
- package/lib/module/modules/SSLApp.js +15 -0
- package/lib/module/modules/SSLApp.js.map +1 -0
- package/lib/module/modules/getParts.js +23 -0
- package/lib/module/modules/getParts.js.map +1 -0
- package/lib/module/modules/index.js +11 -0
- package/lib/module/modules/index.js.map +1 -0
- package/lib/module/modules/us_listen_socket_close.js +17 -0
- package/lib/module/modules/us_listen_socket_close.js.map +1 -0
- package/lib/module/modules/us_socket_local_port.js +18 -0
- package/lib/module/modules/us_socket_local_port.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types/AppDescriptor.js +2 -0
- package/lib/module/types/AppDescriptor.js.map +1 -0
- package/lib/module/types/AppOptions.js +2 -0
- package/lib/module/types/AppOptions.js.map +1 -0
- package/lib/module/types/HttpRequest.js +4 -0
- package/lib/module/types/HttpRequest.js.map +1 -0
- package/lib/module/types/HttpResponse.js +4 -0
- package/lib/module/types/HttpResponse.js.map +1 -0
- package/lib/module/types/HttpRouterOptions.js +2 -0
- package/lib/module/types/HttpRouterOptions.js.map +1 -0
- package/lib/module/types/MultipartField.js +2 -0
- package/lib/module/types/MultipartField.js.map +1 -0
- package/lib/module/types/RecognizedString.js +2 -0
- package/lib/module/types/RecognizedString.js.map +1 -0
- package/lib/module/types/TemplatedApp.js +4 -0
- package/lib/module/types/TemplatedApp.js.map +1 -0
- package/lib/module/types/WebSocket.js +4 -0
- package/lib/module/types/WebSocket.js.map +1 -0
- package/lib/module/types/WebSocketBehaviour.js +139 -0
- package/lib/module/types/WebSocketBehaviour.js.map +1 -0
- package/lib/module/types/index.js +2 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/types/us_listen_socket.js +2 -0
- package/lib/module/types/us_listen_socket.js.map +1 -0
- package/lib/module/types/us_socket.js +2 -0
- package/lib/module/types/us_socket.js.map +1 -0
- package/lib/module/types/us_socket_context_t.js +2 -0
- package/lib/module/types/us_socket_context_t.js.map +1 -0
- package/lib/typescript/commonjs/_internal/native-modules/NativeReactNativeUws.d.ts +22 -0
- package/lib/typescript/commonjs/_internal/native-modules/NativeReactNativeUws.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +3 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/modules/App.d.ts +7 -0
- package/lib/typescript/commonjs/modules/App.d.ts.map +1 -0
- package/lib/typescript/commonjs/modules/CompressOptions.d.ts +1 -0
- package/lib/typescript/commonjs/modules/CompressOptions.d.ts.map +1 -0
- package/lib/typescript/commonjs/modules/EnvironmentVariables.d.ts +16 -0
- package/lib/typescript/commonjs/modules/EnvironmentVariables.d.ts.map +1 -0
- package/lib/typescript/commonjs/modules/ListenOptions.d.ts +5 -0
- package/lib/typescript/commonjs/modules/ListenOptions.d.ts.map +1 -0
- package/lib/typescript/commonjs/modules/SSLApp.d.ts +1 -0
- package/lib/typescript/commonjs/modules/SSLApp.d.ts.map +1 -0
- package/lib/typescript/commonjs/modules/getParts.d.ts +6 -0
- package/lib/typescript/commonjs/modules/getParts.d.ts.map +1 -0
- package/lib/typescript/commonjs/modules/index.d.ts +6 -0
- package/lib/typescript/commonjs/modules/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/modules/us_listen_socket_close.d.ts +5 -0
- package/lib/typescript/commonjs/modules/us_listen_socket_close.d.ts.map +1 -0
- package/lib/typescript/commonjs/modules/us_socket_local_port.d.ts +5 -0
- package/lib/typescript/commonjs/modules/us_socket_local_port.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/types/AppDescriptor.d.ts +8 -0
- package/lib/typescript/commonjs/types/AppDescriptor.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/AppOptions.d.ts +17 -0
- package/lib/typescript/commonjs/types/AppOptions.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/HttpRequest.d.ts +54 -0
- package/lib/typescript/commonjs/types/HttpRequest.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/HttpResponse.d.ts +169 -0
- package/lib/typescript/commonjs/types/HttpResponse.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/HttpRouterOptions.d.ts +24 -0
- package/lib/typescript/commonjs/types/HttpRouterOptions.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/MultipartField.d.ts +7 -0
- package/lib/typescript/commonjs/types/MultipartField.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/RecognizedString.d.ts +10 -0
- package/lib/typescript/commonjs/types/RecognizedString.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/TemplatedApp.d.ts +108 -0
- package/lib/typescript/commonjs/types/TemplatedApp.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/WebSocket.d.ts +96 -0
- package/lib/typescript/commonjs/types/WebSocket.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/WebSocketBehaviour.d.ts +1 -0
- package/lib/typescript/commonjs/types/WebSocketBehaviour.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/index.d.ts +6 -0
- package/lib/typescript/commonjs/types/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/us_listen_socket.d.ts +7 -0
- package/lib/typescript/commonjs/types/us_listen_socket.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/us_socket.d.ts +7 -0
- package/lib/typescript/commonjs/types/us_socket.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/us_socket_context_t.d.ts +7 -0
- package/lib/typescript/commonjs/types/us_socket_context_t.d.ts.map +1 -0
- package/lib/typescript/module/_internal/native-modules/NativeReactNativeUws.d.ts +22 -0
- package/lib/typescript/module/_internal/native-modules/NativeReactNativeUws.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +3 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/modules/App.d.ts +7 -0
- package/lib/typescript/module/modules/App.d.ts.map +1 -0
- package/lib/typescript/module/modules/CompressOptions.d.ts +1 -0
- package/lib/typescript/module/modules/CompressOptions.d.ts.map +1 -0
- package/lib/typescript/module/modules/EnvironmentVariables.d.ts +16 -0
- package/lib/typescript/module/modules/EnvironmentVariables.d.ts.map +1 -0
- package/lib/typescript/module/modules/ListenOptions.d.ts +5 -0
- package/lib/typescript/module/modules/ListenOptions.d.ts.map +1 -0
- package/lib/typescript/module/modules/SSLApp.d.ts +1 -0
- package/lib/typescript/module/modules/SSLApp.d.ts.map +1 -0
- package/lib/typescript/module/modules/getParts.d.ts +6 -0
- package/lib/typescript/module/modules/getParts.d.ts.map +1 -0
- package/lib/typescript/module/modules/index.d.ts +6 -0
- package/lib/typescript/module/modules/index.d.ts.map +1 -0
- package/lib/typescript/module/modules/us_listen_socket_close.d.ts +5 -0
- package/lib/typescript/module/modules/us_listen_socket_close.d.ts.map +1 -0
- package/lib/typescript/module/modules/us_socket_local_port.d.ts +5 -0
- package/lib/typescript/module/modules/us_socket_local_port.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/types/AppDescriptor.d.ts +8 -0
- package/lib/typescript/module/types/AppDescriptor.d.ts.map +1 -0
- package/lib/typescript/module/types/AppOptions.d.ts +17 -0
- package/lib/typescript/module/types/AppOptions.d.ts.map +1 -0
- package/lib/typescript/module/types/HttpRequest.d.ts +54 -0
- package/lib/typescript/module/types/HttpRequest.d.ts.map +1 -0
- package/lib/typescript/module/types/HttpResponse.d.ts +169 -0
- package/lib/typescript/module/types/HttpResponse.d.ts.map +1 -0
- package/lib/typescript/module/types/HttpRouterOptions.d.ts +24 -0
- package/lib/typescript/module/types/HttpRouterOptions.d.ts.map +1 -0
- package/lib/typescript/module/types/MultipartField.d.ts +7 -0
- package/lib/typescript/module/types/MultipartField.d.ts.map +1 -0
- package/lib/typescript/module/types/RecognizedString.d.ts +10 -0
- package/lib/typescript/module/types/RecognizedString.d.ts.map +1 -0
- package/lib/typescript/module/types/TemplatedApp.d.ts +108 -0
- package/lib/typescript/module/types/TemplatedApp.d.ts.map +1 -0
- package/lib/typescript/module/types/WebSocket.d.ts +96 -0
- package/lib/typescript/module/types/WebSocket.d.ts.map +1 -0
- package/lib/typescript/module/types/WebSocketBehaviour.d.ts +1 -0
- package/lib/typescript/module/types/WebSocketBehaviour.d.ts.map +1 -0
- package/lib/typescript/module/types/index.d.ts +6 -0
- package/lib/typescript/module/types/index.d.ts.map +1 -0
- package/lib/typescript/module/types/us_listen_socket.d.ts +7 -0
- package/lib/typescript/module/types/us_listen_socket.d.ts.map +1 -0
- package/lib/typescript/module/types/us_socket.d.ts +7 -0
- package/lib/typescript/module/types/us_socket.d.ts.map +1 -0
- package/lib/typescript/module/types/us_socket_context_t.d.ts +7 -0
- package/lib/typescript/module/types/us_socket_context_t.d.ts.map +1 -0
- package/lib/typescript/tsconfig.tsbuildinfo +1 -0
- package/package.json +62 -0
- package/src/_internal/native-modules/NativeUwsReactNative.ts +40 -0
- package/src/index.ts +2 -0
- package/src/modules/App.ts +14 -0
- package/src/modules/CompressOptions.ts +101 -0
- package/src/modules/EnvironmentVariables.ts +16 -0
- package/src/modules/ListenOptions.ts +4 -0
- package/src/modules/SSLApp.ts +13 -0
- package/src/modules/getParts.ts +29 -0
- package/src/modules/index.ts +8 -0
- package/src/modules/us_listen_socket_close.ts +15 -0
- package/src/modules/us_socket_local_port.ts +16 -0
- package/src/types/AppDescriptor.ts +7 -0
- package/src/types/AppOptions.ts +22 -0
- package/src/types/HttpRequest.ts +74 -0
- package/src/types/HttpResponse.ts +309 -0
- package/src/types/HttpRouterOptions.ts +24 -0
- package/src/types/MultipartField.ts +6 -0
- package/src/types/RecognizedString.ts +11 -0
- package/src/types/TemplatedApp.ts +285 -0
- package/src/types/WebSocket.ts +147 -0
- package/src/types/WebSocketBehaviour.ts +137 -0
- package/src/types/index.ts +12 -0
- package/src/types/us_listen_socket.ts +6 -0
- package/src/types/us_socket.ts +6 -0
- package/src/types/us_socket_context_t.ts +6 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <functional>
|
|
4
|
+
#include <jsi/jsi.h>
|
|
5
|
+
#include <string_view>
|
|
6
|
+
#include <type_traits>
|
|
7
|
+
#include <utility>
|
|
8
|
+
|
|
9
|
+
namespace uws_react_native {
|
|
10
|
+
|
|
11
|
+
/// Inspired from the uWebSockets.js NativeString
|
|
12
|
+
/// but, we don't do the arena allocator magic here.
|
|
13
|
+
/// TBH, I have no knowledge about it.
|
|
14
|
+
class RecognizedString {
|
|
15
|
+
|
|
16
|
+
private:
|
|
17
|
+
char *data;
|
|
18
|
+
size_t length;
|
|
19
|
+
|
|
20
|
+
bool valid = false;
|
|
21
|
+
|
|
22
|
+
public:
|
|
23
|
+
RecognizedString(facebook::jsi::Runtime &rt,
|
|
24
|
+
const facebook::jsi::Value &value,
|
|
25
|
+
std::optional<bool> withCheck = true) {
|
|
26
|
+
if(value.isString()) {
|
|
27
|
+
std::function<void (bool ascii, const void *pData, size_t num)> handler = [this](bool ascii, const void *pData, size_t num) {
|
|
28
|
+
if(ascii) {
|
|
29
|
+
this->data = (char *)pData;
|
|
30
|
+
this->length = num;
|
|
31
|
+
this->valid = true;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
value.asString(rt).getStringData(rt, handler);
|
|
35
|
+
} else if(value.isObject()) {
|
|
36
|
+
auto obj = value.asObject(rt);
|
|
37
|
+
if(obj.isArrayBuffer(rt)) {
|
|
38
|
+
auto arrayBuffer = obj.getArrayBuffer(rt);
|
|
39
|
+
this->data = reinterpret_cast<char *>(arrayBuffer.data(rt));
|
|
40
|
+
this->length = arrayBuffer.size(rt);
|
|
41
|
+
this->valid = true;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if(withCheck.has_value() && withCheck.value()) {
|
|
46
|
+
this->check(rt);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public:
|
|
51
|
+
void check(facebook::jsi::Runtime &rt) const {
|
|
52
|
+
if(!this->valid) {
|
|
53
|
+
throw facebook::jsi::JSError(rt, "Text and data can only be passed by string or ArrayBuffer");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
bool isValid() const {
|
|
58
|
+
return this->valid;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
std::string_view getStringView() {
|
|
62
|
+
return {this->data, this->length};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
std::string getString() {
|
|
66
|
+
return {this->data, this->length};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
}
|
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <ReactCommon/CallInvoker.h>
|
|
4
|
+
#include <ReactCommon/SchedulerPriority.h>
|
|
5
|
+
#include <algorithm>
|
|
6
|
+
#include <jsi/jsi.h>
|
|
7
|
+
#include <mutex>
|
|
8
|
+
#include <sstream>
|
|
9
|
+
#include <utility>
|
|
10
|
+
#include "AppRunner.h"
|
|
11
|
+
#include "HttpRequestObject.h"
|
|
12
|
+
#include "HttpResponseObject.h"
|
|
13
|
+
#include "RecognizedString.h"
|
|
14
|
+
#include "uWebSockets/App.h"
|
|
15
|
+
|
|
16
|
+
namespace uws_react_native {
|
|
17
|
+
|
|
18
|
+
class TemplatedAppObject : public facebook::jsi::Object {
|
|
19
|
+
|
|
20
|
+
private:
|
|
21
|
+
enum UwsRouteMethod {
|
|
22
|
+
ANY,
|
|
23
|
+
DEL,
|
|
24
|
+
GET,
|
|
25
|
+
HEAD,
|
|
26
|
+
OPTIONS,
|
|
27
|
+
PATCH,
|
|
28
|
+
POST,
|
|
29
|
+
PUT,
|
|
30
|
+
TRACE,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
static void routeRegister(AppRunner &appRunner,
|
|
34
|
+
UwsRouteMethod &&method,
|
|
35
|
+
facebook::jsi::Runtime &rt,
|
|
36
|
+
std::shared_ptr<facebook::react::CallInvoker> &jsInvoker,
|
|
37
|
+
const facebook::jsi::Value *arguments) {
|
|
38
|
+
auto pattern = RecognizedString(rt, arguments[0]).getString();
|
|
39
|
+
auto callback = arguments[1].asObject(rt).asFunction(rt);
|
|
40
|
+
|
|
41
|
+
/// This is not working if the route handler is
|
|
42
|
+
/// doing long operation or async function.
|
|
43
|
+
/// It may throw an Error
|
|
44
|
+
/// `terminating due to uncaught exception of type facebook::jsi::JSError: Exception in HostFunction: Unable to retrieve jni environment. Is the thread attached?`
|
|
45
|
+
|
|
46
|
+
// std::function<void (uWS::HttpResponse<false> *res, uWS::HttpRequest *req)> uwsRouteHandler = [&rt, &jsInvoker, cb = std::make_shared<facebook::jsi::Function>(std::move(callback))](uWS::HttpResponse<false> *res, uWS::HttpRequest *req) {
|
|
47
|
+
// auto httpResponseObject = std::make_shared<HttpResponseObject>(rt, res, jsInvoker);
|
|
48
|
+
// auto httpRequestObject = std::make_shared<HttpRequestObject>(rt, req);
|
|
49
|
+
//
|
|
50
|
+
// cb->call(rt,
|
|
51
|
+
// *httpResponseObject,
|
|
52
|
+
// *httpRequestObject);
|
|
53
|
+
// };
|
|
54
|
+
|
|
55
|
+
/// Same, it also doesn't work with SyncCallback.
|
|
56
|
+
/// We can't make a sync call to JS
|
|
57
|
+
/// from arbitrary thread where the uWebSockets runner lives,
|
|
58
|
+
/// even the route handler is not doing anything long opt
|
|
59
|
+
|
|
60
|
+
// std::function<void (uWS::HttpResponse<false> *res, uWS::HttpRequest *req)> uwsRouteHandler = [&rt, syncCallback = std::make_shared<facebook::react::SyncCallback<void (facebook::jsi::Value, facebook::jsi::Value)>>(rt, std::move(callback), jsInvoker)](auto *res, auto *req) {
|
|
61
|
+
// auto httpResponseObject = std::make_shared<HttpResponseObject>(rt, res);
|
|
62
|
+
// auto httpRequestObject = std::make_shared<HttpRequestObject>(rt, req);
|
|
63
|
+
//
|
|
64
|
+
// syncCallback->call(httpResponseObject.get(), httpRequestObject.get());
|
|
65
|
+
// };
|
|
66
|
+
|
|
67
|
+
bool disableBodyRead = false;
|
|
68
|
+
unsigned long maxBodySize = 0;
|
|
69
|
+
|
|
70
|
+
/// See /uws-react-native/package/src/types/HttpRouterOptions.ts
|
|
71
|
+
if(arguments[2].isObject()) {
|
|
72
|
+
auto httpRouterOptions = arguments[2].asObject(rt);
|
|
73
|
+
|
|
74
|
+
{
|
|
75
|
+
std::string key = "disableBodyRead";
|
|
76
|
+
if(httpRouterOptions.getProperty(rt, key.c_str()).isBool()) {
|
|
77
|
+
disableBodyRead = httpRouterOptions.getProperty(rt, key.c_str()).asBool();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
{
|
|
82
|
+
std::string key = "maxBodySize";
|
|
83
|
+
if(httpRouterOptions.getProperty(rt, key.c_str()).isNumber()) {
|
|
84
|
+
auto _maxBodySize = httpRouterOptions.getProperty(rt, key.c_str()).asNumber();
|
|
85
|
+
if(_maxBodySize < 0) {
|
|
86
|
+
throw facebook::jsi::JSError(rt, "Illegal maxBodySize number expression");
|
|
87
|
+
}
|
|
88
|
+
maxBodySize = static_cast<unsigned long>(_maxBodySize);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
std::function<void (uWS::HttpResponse<false> *res, uWS::HttpRequest *req)> uwsRouteHandler = [pattern, disableBodyRead, maxBodySize, &rt, &jsInvoker, asyncCallback = facebook::react::AsyncCallback(rt, std::move(callback), jsInvoker)](uWS::HttpResponse<false> *res, uWS::HttpRequest *req) {
|
|
94
|
+
auto httpResponseObject = std::make_shared<HttpResponseObject>(rt,
|
|
95
|
+
res,
|
|
96
|
+
jsInvoker,
|
|
97
|
+
HttpResponseObjectOptions{ .disableBodyRead = disableBodyRead, .maxBodySize = maxBodySize });
|
|
98
|
+
|
|
99
|
+
auto httpRequestObject = std::make_shared<HttpRequestObject>(rt, req);
|
|
100
|
+
|
|
101
|
+
asyncCallback.callWithPriority(facebook::react::SchedulerPriority::ImmediatePriority, [httpResponseObject, httpRequestObject](facebook::jsi::Runtime &rt_1, facebook::jsi::Function &cb) {
|
|
102
|
+
cb.call(rt_1,
|
|
103
|
+
*httpResponseObject,
|
|
104
|
+
*httpRequestObject);
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
if(method == UwsRouteMethod::ANY) {
|
|
109
|
+
appRunner.app.any(pattern, std::move(uwsRouteHandler));
|
|
110
|
+
} else if(method == UwsRouteMethod::DEL) {
|
|
111
|
+
appRunner.app.del(pattern, std::move(uwsRouteHandler));
|
|
112
|
+
} else if(method == UwsRouteMethod::GET) {
|
|
113
|
+
appRunner.app.get(pattern, std::move(uwsRouteHandler));
|
|
114
|
+
} else if(method == UwsRouteMethod::HEAD) {
|
|
115
|
+
appRunner.app.head(pattern, std::move(uwsRouteHandler));
|
|
116
|
+
} else if(method == UwsRouteMethod::OPTIONS) {
|
|
117
|
+
appRunner.app.options(pattern, std::move(uwsRouteHandler));
|
|
118
|
+
} else if(method == UwsRouteMethod::PATCH) {
|
|
119
|
+
appRunner.app.patch(pattern, std::move(uwsRouteHandler));
|
|
120
|
+
} else if(method == UwsRouteMethod::POST) {
|
|
121
|
+
appRunner.app.post(pattern, std::move(uwsRouteHandler));
|
|
122
|
+
} else if(method == UwsRouteMethod::PUT) {
|
|
123
|
+
appRunner.app.put(pattern, std::move(uwsRouteHandler));
|
|
124
|
+
} else {
|
|
125
|
+
appRunner.app.trace(pattern, std::move(uwsRouteHandler));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
public:
|
|
130
|
+
TemplatedAppObject(AppRunner &appRunner,
|
|
131
|
+
|
|
132
|
+
facebook::jsi::Runtime &rt,
|
|
133
|
+
|
|
134
|
+
std::shared_ptr<facebook::react::CallInvoker> &jsInvoker,
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Important! Please pass a number larger than 0.
|
|
138
|
+
*
|
|
139
|
+
* This `id` number will be passed to the "listen" method handler.
|
|
140
|
+
* We don't actually pass the us_listen_socket_context_t there. The actual reason is
|
|
141
|
+
* we need to remove the AppHost instance which stored inside of vector.
|
|
142
|
+
* So, when user use the us_listen_socket_close JS module with this `id` passed,
|
|
143
|
+
* we don't really use the us_listen_socket_close from uSockets directly,
|
|
144
|
+
* instead, we just call the `close` method from AppRunner which a member of AppHost.
|
|
145
|
+
* See ReactNativeUwsModule.cpp.
|
|
146
|
+
*
|
|
147
|
+
* It's also used by us_socket_local_port JS module to get assigned port from uWebSockets app.
|
|
148
|
+
* We use the us_socket_local_port from uSockets tho, but we need to retrieve us_listen_socket_t
|
|
149
|
+
* from the AppRunner which a member of AppHost.
|
|
150
|
+
*/
|
|
151
|
+
unsigned short id,
|
|
152
|
+
|
|
153
|
+
const std::function<void ()> &closeHandler) : facebook::jsi::Object(rt) {
|
|
154
|
+
this->setProperty(rt,
|
|
155
|
+
"close",
|
|
156
|
+
facebook::jsi::Function::createFromHostFunction(rt,
|
|
157
|
+
facebook::jsi::PropNameID::forUtf8(rt, "close"),
|
|
158
|
+
0,
|
|
159
|
+
[closeHandler](facebook::jsi::Runtime &rt_1,
|
|
160
|
+
const facebook::jsi::Value &thisValue,
|
|
161
|
+
const facebook::jsi::Value *arguments,
|
|
162
|
+
size_t count) -> facebook::jsi::Value {
|
|
163
|
+
closeHandler();
|
|
164
|
+
return facebook::jsi::Value::undefined();
|
|
165
|
+
}));
|
|
166
|
+
|
|
167
|
+
this->setProperty(rt,
|
|
168
|
+
"domain",
|
|
169
|
+
facebook::jsi::Function::createFromHostFunction(rt,
|
|
170
|
+
facebook::jsi::PropNameID::forUtf8(rt, "domain"),
|
|
171
|
+
0,
|
|
172
|
+
[&appRunner](facebook::jsi::Runtime &rt_1,
|
|
173
|
+
const facebook::jsi::Value &thisValue,
|
|
174
|
+
const facebook::jsi::Value *arguments,
|
|
175
|
+
size_t count) -> facebook::jsi::Value {
|
|
176
|
+
auto serverName = arguments[0].asString(rt_1).utf8(rt_1);
|
|
177
|
+
appRunner.app.domain(serverName);
|
|
178
|
+
|
|
179
|
+
return {rt_1, thisValue};
|
|
180
|
+
}));
|
|
181
|
+
|
|
182
|
+
this->setProperty(rt,
|
|
183
|
+
"filter",
|
|
184
|
+
facebook::jsi::Function::createFromHostFunction(rt,
|
|
185
|
+
facebook::jsi::PropNameID::forUtf8(rt, "filter"),
|
|
186
|
+
0,
|
|
187
|
+
[&appRunner, &jsInvoker](facebook::jsi::Runtime &rt_1,
|
|
188
|
+
const facebook::jsi::Value &thisValue,
|
|
189
|
+
const facebook::jsi::Value *arguments,
|
|
190
|
+
size_t count) -> facebook::jsi::Value {
|
|
191
|
+
auto callback = arguments[0].asObject(rt_1).asFunction(rt_1);
|
|
192
|
+
|
|
193
|
+
appRunner.app.filter([&jsInvoker, asyncCallback = facebook::react::AsyncCallback(rt_1, std::move(callback), jsInvoker)](auto *res, int count) {
|
|
194
|
+
asyncCallback.call([&jsInvoker, &res, count](facebook::jsi::Runtime &rt_2, facebook::jsi::Function &cb) {
|
|
195
|
+
auto httpResponseObject = std::make_shared<uws_react_native::HttpResponseObject>(rt_2, res, jsInvoker);
|
|
196
|
+
cb.call(rt_2,
|
|
197
|
+
*httpResponseObject,
|
|
198
|
+
count);
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
return {rt_1, thisValue};
|
|
203
|
+
}));
|
|
204
|
+
|
|
205
|
+
/// UNTESTED
|
|
206
|
+
/// It's copied and modified method from uWebSockets.js (for the Node.js).
|
|
207
|
+
/// Yet, I don't even know what the method is for.
|
|
208
|
+
// this->setProperty(rt,
|
|
209
|
+
// "getDescriptor",
|
|
210
|
+
// facebook::jsi::Function::createFromHostFunction(rt,
|
|
211
|
+
// facebook::jsi::PropNameID::forUtf8(rt, "getDescriptor"),
|
|
212
|
+
// 0,
|
|
213
|
+
// [&appRunner](facebook::jsi::Runtime &rt_1,
|
|
214
|
+
// const facebook::jsi::Value &thisValue,
|
|
215
|
+
// const facebook::jsi::Value *arguments,
|
|
216
|
+
// size_t count) -> facebook::jsi::Value {
|
|
217
|
+
// static_assert(sizeof(double) >= sizeof(appRunner));
|
|
218
|
+
//
|
|
219
|
+
// uWS::App *app = &(appRunner.app);
|
|
220
|
+
//
|
|
221
|
+
// double descriptor = 0;
|
|
222
|
+
// memcpy(&descriptor, &app, sizeof(app));
|
|
223
|
+
//
|
|
224
|
+
// return descriptor;
|
|
225
|
+
// }));
|
|
226
|
+
|
|
227
|
+
this->setProperty(rt,
|
|
228
|
+
"listen",
|
|
229
|
+
facebook::jsi::Function::createFromHostFunction(rt,
|
|
230
|
+
facebook::jsi::PropNameID::forUtf8(rt, "listen"),
|
|
231
|
+
4,
|
|
232
|
+
[&appRunner, &jsInvoker, id](facebook::jsi::Runtime &rt_1,
|
|
233
|
+
const facebook::jsi::Value &thisValue,
|
|
234
|
+
const facebook::jsi::Value *arguments,
|
|
235
|
+
size_t count) -> facebook::jsi::Value {
|
|
236
|
+
std::optional<std::string> host = std::nullopt;
|
|
237
|
+
double port = -1; // it could be unsigned short, but JSI provide it as double
|
|
238
|
+
std::optional<int> options = std::nullopt;
|
|
239
|
+
|
|
240
|
+
if(arguments[0].isString()) {
|
|
241
|
+
host = RecognizedString(rt_1, arguments[0]).getString();
|
|
242
|
+
if(arguments[1].isNumber()) {
|
|
243
|
+
port = arguments[1].asNumber();
|
|
244
|
+
}
|
|
245
|
+
if(arguments[2].isNumber()) {
|
|
246
|
+
options = arguments[2].asNumber();
|
|
247
|
+
}
|
|
248
|
+
} else if(arguments[0].isNumber()) {
|
|
249
|
+
port = arguments[0].asNumber();
|
|
250
|
+
if(arguments[1].isNumber()) {
|
|
251
|
+
options = arguments[1].asNumber();
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
if(port < 0 || port > 65535) {
|
|
256
|
+
throw facebook::jsi::JSError(rt_1, "Illegal port number expression");
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
auto callback = arguments[count - 1].asObject(rt_1).asFunction(rt_1);
|
|
260
|
+
|
|
261
|
+
appRunner.listen(host, static_cast<int>(port), options, [id, asyncCallback = facebook::react::AsyncCallback(rt_1, std::move(callback), jsInvoker)](us_listen_socket_t *listenedSocket) {
|
|
262
|
+
asyncCallback.call([id, listenedSocket](facebook::jsi::Runtime &rt_2, facebook::jsi::Function &cb) {
|
|
263
|
+
cb.call(rt_2,
|
|
264
|
+
listenedSocket ? static_cast<double>(id) : 0);
|
|
265
|
+
});
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
return {rt_1, thisValue};
|
|
269
|
+
}));
|
|
270
|
+
|
|
271
|
+
this->setProperty(rt,
|
|
272
|
+
"numSubscribers",
|
|
273
|
+
facebook::jsi::Function::createFromHostFunction(rt,
|
|
274
|
+
facebook::jsi::PropNameID::forUtf8(rt, "numSubscribers"),
|
|
275
|
+
1,
|
|
276
|
+
[&appRunner](facebook::jsi::Runtime &rt_1,
|
|
277
|
+
const facebook::jsi::Value &thisValue,
|
|
278
|
+
const facebook::jsi::Value *arguments,
|
|
279
|
+
size_t count) -> facebook::jsi::Value {
|
|
280
|
+
auto topic = RecognizedString(rt_1, arguments[0]).getStringView();
|
|
281
|
+
return static_cast<int>(appRunner.app.numSubscribers(topic));
|
|
282
|
+
}));
|
|
283
|
+
|
|
284
|
+
this->setProperty(rt,
|
|
285
|
+
"publish",
|
|
286
|
+
facebook::jsi::Function::createFromHostFunction(rt,
|
|
287
|
+
facebook::jsi::PropNameID::forUtf8(rt, "publish"),
|
|
288
|
+
4,
|
|
289
|
+
[&appRunner](facebook::jsi::Runtime &rt_1,
|
|
290
|
+
const facebook::jsi::Value &thisValue,
|
|
291
|
+
const facebook::jsi::Value *arguments,
|
|
292
|
+
size_t count) -> facebook::jsi::Value {
|
|
293
|
+
auto topic = RecognizedString(rt_1, arguments[0]).getStringView();
|
|
294
|
+
auto message = RecognizedString(rt_1, arguments[1]).getStringView();
|
|
295
|
+
|
|
296
|
+
bool isBinary = false;
|
|
297
|
+
if(arguments[2].isBool()) {
|
|
298
|
+
isBinary = arguments[2].asBool();
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
bool compress = false;
|
|
302
|
+
if(arguments[3].isBool()) {
|
|
303
|
+
compress = arguments[3].asBool();
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
return appRunner.app.publish(topic,
|
|
307
|
+
message,
|
|
308
|
+
isBinary ? uWS::OpCode::BINARY : uWS::TEXT,
|
|
309
|
+
compress);
|
|
310
|
+
}));
|
|
311
|
+
|
|
312
|
+
// +++++ ROUTER +++++
|
|
313
|
+
|
|
314
|
+
this->setProperty(rt,
|
|
315
|
+
"any",
|
|
316
|
+
facebook::jsi::Function::createFromHostFunction(rt,
|
|
317
|
+
facebook::jsi::PropNameID::forUtf8(rt, "any"),
|
|
318
|
+
3,
|
|
319
|
+
[&appRunner, &jsInvoker](facebook::jsi::Runtime &rt_1,
|
|
320
|
+
const facebook::jsi::Value &thisValue,
|
|
321
|
+
const facebook::jsi::Value *arguments,
|
|
322
|
+
size_t count) -> facebook::jsi::Value {
|
|
323
|
+
TemplatedAppObject::routeRegister(appRunner,
|
|
324
|
+
UwsRouteMethod::ANY,
|
|
325
|
+
rt_1,
|
|
326
|
+
jsInvoker,
|
|
327
|
+
arguments);
|
|
328
|
+
return {rt_1, thisValue};
|
|
329
|
+
}));
|
|
330
|
+
|
|
331
|
+
this->setProperty(rt,
|
|
332
|
+
"del",
|
|
333
|
+
facebook::jsi::Function::createFromHostFunction(rt,
|
|
334
|
+
facebook::jsi::PropNameID::forUtf8(rt, "del"),
|
|
335
|
+
3,
|
|
336
|
+
[&appRunner, &jsInvoker](facebook::jsi::Runtime &rt_1,
|
|
337
|
+
const facebook::jsi::Value &thisValue,
|
|
338
|
+
const facebook::jsi::Value *arguments,
|
|
339
|
+
size_t count) -> facebook::jsi::Value {
|
|
340
|
+
TemplatedAppObject::routeRegister(appRunner,
|
|
341
|
+
UwsRouteMethod::DEL,
|
|
342
|
+
rt_1,
|
|
343
|
+
jsInvoker,
|
|
344
|
+
arguments);
|
|
345
|
+
return {rt_1, thisValue};
|
|
346
|
+
}));
|
|
347
|
+
|
|
348
|
+
this->setProperty(rt,
|
|
349
|
+
"get",
|
|
350
|
+
facebook::jsi::Function::createFromHostFunction(rt,
|
|
351
|
+
facebook::jsi::PropNameID::forUtf8(rt, "get"),
|
|
352
|
+
3,
|
|
353
|
+
[&appRunner, &jsInvoker](facebook::jsi::Runtime &rt_1,
|
|
354
|
+
const facebook::jsi::Value &thisValue,
|
|
355
|
+
const facebook::jsi::Value *arguments,
|
|
356
|
+
size_t count) -> facebook::jsi::Value {
|
|
357
|
+
TemplatedAppObject::routeRegister(appRunner,
|
|
358
|
+
UwsRouteMethod::GET,
|
|
359
|
+
rt_1,
|
|
360
|
+
jsInvoker,
|
|
361
|
+
arguments);
|
|
362
|
+
return {rt_1, thisValue};
|
|
363
|
+
}));
|
|
364
|
+
|
|
365
|
+
this->setProperty(rt,
|
|
366
|
+
"head",
|
|
367
|
+
facebook::jsi::Function::createFromHostFunction(rt,
|
|
368
|
+
facebook::jsi::PropNameID::forUtf8(rt, "head"),
|
|
369
|
+
3,
|
|
370
|
+
[&appRunner, &jsInvoker](facebook::jsi::Runtime &rt_1,
|
|
371
|
+
const facebook::jsi::Value &thisValue,
|
|
372
|
+
const facebook::jsi::Value *arguments,
|
|
373
|
+
size_t count) -> facebook::jsi::Value {
|
|
374
|
+
TemplatedAppObject::routeRegister(appRunner,
|
|
375
|
+
UwsRouteMethod::HEAD,
|
|
376
|
+
rt_1,
|
|
377
|
+
jsInvoker,
|
|
378
|
+
arguments);
|
|
379
|
+
return {rt_1, thisValue};
|
|
380
|
+
}));
|
|
381
|
+
|
|
382
|
+
this->setProperty(rt,
|
|
383
|
+
"options",
|
|
384
|
+
facebook::jsi::Function::createFromHostFunction(rt,
|
|
385
|
+
facebook::jsi::PropNameID::forUtf8(rt, "options"),
|
|
386
|
+
3,
|
|
387
|
+
[&appRunner, &jsInvoker](facebook::jsi::Runtime &rt_1,
|
|
388
|
+
const facebook::jsi::Value &thisValue,
|
|
389
|
+
const facebook::jsi::Value *arguments,
|
|
390
|
+
size_t count) -> facebook::jsi::Value {
|
|
391
|
+
TemplatedAppObject::routeRegister(appRunner,
|
|
392
|
+
UwsRouteMethod::OPTIONS,
|
|
393
|
+
rt_1,
|
|
394
|
+
jsInvoker,
|
|
395
|
+
arguments);
|
|
396
|
+
return {rt_1, thisValue};
|
|
397
|
+
}));
|
|
398
|
+
|
|
399
|
+
this->setProperty(rt,
|
|
400
|
+
"patch",
|
|
401
|
+
facebook::jsi::Function::createFromHostFunction(rt,
|
|
402
|
+
facebook::jsi::PropNameID::forUtf8(rt, "patch"),
|
|
403
|
+
3,
|
|
404
|
+
[&appRunner, &jsInvoker](facebook::jsi::Runtime &rt_1,
|
|
405
|
+
const facebook::jsi::Value &thisValue,
|
|
406
|
+
const facebook::jsi::Value *arguments,
|
|
407
|
+
size_t count) -> facebook::jsi::Value {
|
|
408
|
+
TemplatedAppObject::routeRegister(appRunner,
|
|
409
|
+
UwsRouteMethod::PATCH,
|
|
410
|
+
rt_1,
|
|
411
|
+
jsInvoker,
|
|
412
|
+
arguments);
|
|
413
|
+
return {rt_1, thisValue};
|
|
414
|
+
}));
|
|
415
|
+
|
|
416
|
+
this->setProperty(rt,
|
|
417
|
+
"post",
|
|
418
|
+
facebook::jsi::Function::createFromHostFunction(rt,
|
|
419
|
+
facebook::jsi::PropNameID::forUtf8(rt, "post"),
|
|
420
|
+
3,
|
|
421
|
+
[&appRunner, &jsInvoker](facebook::jsi::Runtime &rt_1,
|
|
422
|
+
const facebook::jsi::Value &thisValue,
|
|
423
|
+
const facebook::jsi::Value *arguments,
|
|
424
|
+
size_t count) -> facebook::jsi::Value {
|
|
425
|
+
TemplatedAppObject::routeRegister(appRunner,
|
|
426
|
+
UwsRouteMethod::POST,
|
|
427
|
+
rt_1,
|
|
428
|
+
jsInvoker,
|
|
429
|
+
arguments);
|
|
430
|
+
return {rt_1, thisValue};
|
|
431
|
+
}));
|
|
432
|
+
|
|
433
|
+
this->setProperty(rt,
|
|
434
|
+
"put",
|
|
435
|
+
facebook::jsi::Function::createFromHostFunction(rt,
|
|
436
|
+
facebook::jsi::PropNameID::forUtf8(rt, "put"),
|
|
437
|
+
3,
|
|
438
|
+
[&appRunner, &jsInvoker](facebook::jsi::Runtime &rt_1,
|
|
439
|
+
const facebook::jsi::Value &thisValue,
|
|
440
|
+
const facebook::jsi::Value *arguments,
|
|
441
|
+
size_t count) -> facebook::jsi::Value {
|
|
442
|
+
TemplatedAppObject::routeRegister(appRunner,
|
|
443
|
+
UwsRouteMethod::PUT,
|
|
444
|
+
rt_1,
|
|
445
|
+
jsInvoker,
|
|
446
|
+
arguments);
|
|
447
|
+
return {rt_1, thisValue};
|
|
448
|
+
}));
|
|
449
|
+
|
|
450
|
+
this->setProperty(rt,
|
|
451
|
+
"trace",
|
|
452
|
+
facebook::jsi::Function::createFromHostFunction(rt,
|
|
453
|
+
facebook::jsi::PropNameID::forUtf8(rt, "trace"),
|
|
454
|
+
3,
|
|
455
|
+
[&appRunner, &jsInvoker](facebook::jsi::Runtime &rt_1,
|
|
456
|
+
const facebook::jsi::Value &thisValue,
|
|
457
|
+
const facebook::jsi::Value *arguments,
|
|
458
|
+
size_t count) -> facebook::jsi::Value {
|
|
459
|
+
TemplatedAppObject::routeRegister(appRunner,
|
|
460
|
+
UwsRouteMethod::TRACE,
|
|
461
|
+
rt_1,
|
|
462
|
+
jsInvoker,
|
|
463
|
+
arguments);
|
|
464
|
+
return {rt_1, thisValue};
|
|
465
|
+
}));
|
|
466
|
+
|
|
467
|
+
// ----- ROUTER -----
|
|
468
|
+
};
|
|
469
|
+
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
}
|