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.
Files changed (315) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +84 -0
  3. package/UwsReactNative.podspec +71 -0
  4. package/android/build.gradle.kts +138 -0
  5. package/android/src/main/AndroidManifest.xml +2 -0
  6. package/android/src/main/java/id/sufeni/oss/uwsreactnative/UwsReactNativePackage.kt +18 -0
  7. package/apple/OnLoad.mm +17 -0
  8. package/cpp/CMakeLists.txt +154 -0
  9. package/cpp/UwsReactNativeModule.cpp +191 -0
  10. package/cpp/UwsReactNativeModule.h +30 -0
  11. package/cpp/app/AppHost.h +37 -0
  12. package/cpp/app/AppRunner.h +88 -0
  13. package/cpp/app/CMakeLists.txt +39 -0
  14. package/cpp/app/HttpRequestObject.h +173 -0
  15. package/cpp/app/HttpResponseObject.h +623 -0
  16. package/cpp/app/RecognizedString.h +71 -0
  17. package/cpp/app/TemplatedAppObject.h +472 -0
  18. package/cpp/bridging/ArrayBuffer.h +150 -0
  19. package/cpp/bridging/CMakeLists.txt +34 -0
  20. package/cpp/jsi/Buffer.h +91 -0
  21. package/cpp/jsi/CMakeLists.txt +34 -0
  22. package/cpp/uSockets/bsd.c +767 -0
  23. package/cpp/uSockets/context.c +524 -0
  24. package/cpp/uSockets/crypto/openssl.c +858 -0
  25. package/cpp/uSockets/crypto/sni_tree.cpp +218 -0
  26. package/cpp/uSockets/eventing/asio.cpp +475 -0
  27. package/cpp/uSockets/eventing/epoll_kqueue.c +458 -0
  28. package/cpp/uSockets/eventing/gcd.c +278 -0
  29. package/cpp/uSockets/eventing/libuv.c +305 -0
  30. package/cpp/uSockets/internal/eventing/asio.h +45 -0
  31. package/cpp/uSockets/internal/eventing/epoll_kqueue.h +67 -0
  32. package/cpp/uSockets/internal/eventing/gcd.h +40 -0
  33. package/cpp/uSockets/internal/eventing/libuv.h +45 -0
  34. package/cpp/uSockets/internal/internal.h +224 -0
  35. package/cpp/uSockets/internal/loop_data.h +38 -0
  36. package/cpp/uSockets/internal/networking/bsd.h +109 -0
  37. package/cpp/uSockets/io_uring/internal.h +98 -0
  38. package/cpp/uSockets/io_uring/io_context.c +302 -0
  39. package/cpp/uSockets/io_uring/io_loop.c +422 -0
  40. package/cpp/uSockets/io_uring/io_socket.c +139 -0
  41. package/cpp/uSockets/libusockets.h +350 -0
  42. package/cpp/uSockets/loop.c +396 -0
  43. package/cpp/uSockets/quic.c +1071 -0
  44. package/cpp/uSockets/quic.h +68 -0
  45. package/cpp/uSockets/socket.c +231 -0
  46. package/cpp/uSockets/udp.c +151 -0
  47. package/cpp/uWebSockets/uWebSockets/App.h +676 -0
  48. package/cpp/uWebSockets/uWebSockets/AsyncSocket.h +376 -0
  49. package/cpp/uWebSockets/uWebSockets/AsyncSocketData.h +94 -0
  50. package/cpp/uWebSockets/uWebSockets/BloomFilter.h +83 -0
  51. package/cpp/uWebSockets/uWebSockets/CachingApp.h +115 -0
  52. package/cpp/uWebSockets/uWebSockets/ChunkedEncoding.h +237 -0
  53. package/cpp/uWebSockets/uWebSockets/ClientApp.h +36 -0
  54. package/cpp/uWebSockets/uWebSockets/Http3App.h +140 -0
  55. package/cpp/uWebSockets/uWebSockets/Http3Context.h +157 -0
  56. package/cpp/uWebSockets/uWebSockets/Http3ContextData.h +21 -0
  57. package/cpp/uWebSockets/uWebSockets/Http3Request.h +22 -0
  58. package/cpp/uWebSockets/uWebSockets/Http3Response.h +120 -0
  59. package/cpp/uWebSockets/uWebSockets/Http3ResponseData.h +25 -0
  60. package/cpp/uWebSockets/uWebSockets/HttpContext.h +521 -0
  61. package/cpp/uWebSockets/uWebSockets/HttpContextData.h +60 -0
  62. package/cpp/uWebSockets/uWebSockets/HttpErrors.h +53 -0
  63. package/cpp/uWebSockets/uWebSockets/HttpParser.h +747 -0
  64. package/cpp/uWebSockets/uWebSockets/HttpResponse.h +605 -0
  65. package/cpp/uWebSockets/uWebSockets/HttpResponseData.h +123 -0
  66. package/cpp/uWebSockets/uWebSockets/HttpRouter.h +384 -0
  67. package/cpp/uWebSockets/uWebSockets/LocalCluster.h +64 -0
  68. package/cpp/uWebSockets/uWebSockets/Loop.h +238 -0
  69. package/cpp/uWebSockets/uWebSockets/LoopData.h +113 -0
  70. package/cpp/uWebSockets/uWebSockets/MessageParser.h +64 -0
  71. package/cpp/uWebSockets/uWebSockets/MoveOnlyFunction.h +389 -0
  72. package/cpp/uWebSockets/uWebSockets/Multipart.h +231 -0
  73. package/cpp/uWebSockets/uWebSockets/PerMessageDeflate.h +303 -0
  74. package/cpp/uWebSockets/uWebSockets/ProxyParser.h +187 -0
  75. package/cpp/uWebSockets/uWebSockets/QueryParser.h +120 -0
  76. package/cpp/uWebSockets/uWebSockets/TopicTree.h +364 -0
  77. package/cpp/uWebSockets/uWebSockets/Utilities.h +66 -0
  78. package/cpp/uWebSockets/uWebSockets/WebSocket.h +407 -0
  79. package/cpp/uWebSockets/uWebSockets/WebSocketContext.h +436 -0
  80. package/cpp/uWebSockets/uWebSockets/WebSocketContextData.h +109 -0
  81. package/cpp/uWebSockets/uWebSockets/WebSocketData.h +86 -0
  82. package/cpp/uWebSockets/uWebSockets/WebSocketExtensions.h +256 -0
  83. package/cpp/uWebSockets/uWebSockets/WebSocketHandshake.h +145 -0
  84. package/cpp/uWebSockets/uWebSockets/WebSocketProtocol.h +525 -0
  85. package/lib/commonjs/_internal/native-modules/NativeReactNativeUws.js +12 -0
  86. package/lib/commonjs/_internal/native-modules/NativeReactNativeUws.js.map +1 -0
  87. package/lib/commonjs/index.js +28 -0
  88. package/lib/commonjs/index.js.map +1 -0
  89. package/lib/commonjs/modules/App.js +17 -0
  90. package/lib/commonjs/modules/App.js.map +1 -0
  91. package/lib/commonjs/modules/CompressOptions.js +103 -0
  92. package/lib/commonjs/modules/CompressOptions.js.map +1 -0
  93. package/lib/commonjs/modules/EnvironmentVariables.js +17 -0
  94. package/lib/commonjs/modules/EnvironmentVariables.js.map +1 -0
  95. package/lib/commonjs/modules/ListenOptions.js +12 -0
  96. package/lib/commonjs/modules/ListenOptions.js.map +1 -0
  97. package/lib/commonjs/modules/SSLApp.js +15 -0
  98. package/lib/commonjs/modules/SSLApp.js.map +1 -0
  99. package/lib/commonjs/modules/getParts.js +28 -0
  100. package/lib/commonjs/modules/getParts.js.map +1 -0
  101. package/lib/commonjs/modules/index.js +61 -0
  102. package/lib/commonjs/modules/index.js.map +1 -0
  103. package/lib/commonjs/modules/us_listen_socket_close.js +21 -0
  104. package/lib/commonjs/modules/us_listen_socket_close.js.map +1 -0
  105. package/lib/commonjs/modules/us_socket_local_port.js +22 -0
  106. package/lib/commonjs/modules/us_socket_local_port.js.map +1 -0
  107. package/lib/commonjs/package.json +1 -0
  108. package/lib/commonjs/types/AppDescriptor.js +2 -0
  109. package/lib/commonjs/types/AppDescriptor.js.map +1 -0
  110. package/lib/commonjs/types/AppOptions.js +2 -0
  111. package/lib/commonjs/types/AppOptions.js.map +1 -0
  112. package/lib/commonjs/types/HttpRequest.js +6 -0
  113. package/lib/commonjs/types/HttpRequest.js.map +1 -0
  114. package/lib/commonjs/types/HttpResponse.js +6 -0
  115. package/lib/commonjs/types/HttpResponse.js.map +1 -0
  116. package/lib/commonjs/types/HttpRouterOptions.js +2 -0
  117. package/lib/commonjs/types/HttpRouterOptions.js.map +1 -0
  118. package/lib/commonjs/types/MultipartField.js +2 -0
  119. package/lib/commonjs/types/MultipartField.js.map +1 -0
  120. package/lib/commonjs/types/RecognizedString.js +2 -0
  121. package/lib/commonjs/types/RecognizedString.js.map +1 -0
  122. package/lib/commonjs/types/TemplatedApp.js +6 -0
  123. package/lib/commonjs/types/TemplatedApp.js.map +1 -0
  124. package/lib/commonjs/types/WebSocket.js +6 -0
  125. package/lib/commonjs/types/WebSocket.js.map +1 -0
  126. package/lib/commonjs/types/WebSocketBehaviour.js +139 -0
  127. package/lib/commonjs/types/WebSocketBehaviour.js.map +1 -0
  128. package/lib/commonjs/types/index.js +2 -0
  129. package/lib/commonjs/types/index.js.map +1 -0
  130. package/lib/commonjs/types/us_listen_socket.js +2 -0
  131. package/lib/commonjs/types/us_listen_socket.js.map +1 -0
  132. package/lib/commonjs/types/us_socket.js +2 -0
  133. package/lib/commonjs/types/us_socket.js.map +1 -0
  134. package/lib/commonjs/types/us_socket_context_t.js +2 -0
  135. package/lib/commonjs/types/us_socket_context_t.js.map +1 -0
  136. package/lib/module/_internal/native-modules/NativeReactNativeUws.js +10 -0
  137. package/lib/module/_internal/native-modules/NativeReactNativeUws.js.map +1 -0
  138. package/lib/module/index.js +5 -0
  139. package/lib/module/index.js.map +1 -0
  140. package/lib/module/modules/App.js +12 -0
  141. package/lib/module/modules/App.js.map +1 -0
  142. package/lib/module/modules/CompressOptions.js +103 -0
  143. package/lib/module/modules/CompressOptions.js.map +1 -0
  144. package/lib/module/modules/EnvironmentVariables.js +13 -0
  145. package/lib/module/modules/EnvironmentVariables.js.map +1 -0
  146. package/lib/module/modules/ListenOptions.js +8 -0
  147. package/lib/module/modules/ListenOptions.js.map +1 -0
  148. package/lib/module/modules/SSLApp.js +15 -0
  149. package/lib/module/modules/SSLApp.js.map +1 -0
  150. package/lib/module/modules/getParts.js +23 -0
  151. package/lib/module/modules/getParts.js.map +1 -0
  152. package/lib/module/modules/index.js +11 -0
  153. package/lib/module/modules/index.js.map +1 -0
  154. package/lib/module/modules/us_listen_socket_close.js +17 -0
  155. package/lib/module/modules/us_listen_socket_close.js.map +1 -0
  156. package/lib/module/modules/us_socket_local_port.js +18 -0
  157. package/lib/module/modules/us_socket_local_port.js.map +1 -0
  158. package/lib/module/package.json +1 -0
  159. package/lib/module/types/AppDescriptor.js +2 -0
  160. package/lib/module/types/AppDescriptor.js.map +1 -0
  161. package/lib/module/types/AppOptions.js +2 -0
  162. package/lib/module/types/AppOptions.js.map +1 -0
  163. package/lib/module/types/HttpRequest.js +4 -0
  164. package/lib/module/types/HttpRequest.js.map +1 -0
  165. package/lib/module/types/HttpResponse.js +4 -0
  166. package/lib/module/types/HttpResponse.js.map +1 -0
  167. package/lib/module/types/HttpRouterOptions.js +2 -0
  168. package/lib/module/types/HttpRouterOptions.js.map +1 -0
  169. package/lib/module/types/MultipartField.js +2 -0
  170. package/lib/module/types/MultipartField.js.map +1 -0
  171. package/lib/module/types/RecognizedString.js +2 -0
  172. package/lib/module/types/RecognizedString.js.map +1 -0
  173. package/lib/module/types/TemplatedApp.js +4 -0
  174. package/lib/module/types/TemplatedApp.js.map +1 -0
  175. package/lib/module/types/WebSocket.js +4 -0
  176. package/lib/module/types/WebSocket.js.map +1 -0
  177. package/lib/module/types/WebSocketBehaviour.js +139 -0
  178. package/lib/module/types/WebSocketBehaviour.js.map +1 -0
  179. package/lib/module/types/index.js +2 -0
  180. package/lib/module/types/index.js.map +1 -0
  181. package/lib/module/types/us_listen_socket.js +2 -0
  182. package/lib/module/types/us_listen_socket.js.map +1 -0
  183. package/lib/module/types/us_socket.js +2 -0
  184. package/lib/module/types/us_socket.js.map +1 -0
  185. package/lib/module/types/us_socket_context_t.js +2 -0
  186. package/lib/module/types/us_socket_context_t.js.map +1 -0
  187. package/lib/typescript/commonjs/_internal/native-modules/NativeReactNativeUws.d.ts +22 -0
  188. package/lib/typescript/commonjs/_internal/native-modules/NativeReactNativeUws.d.ts.map +1 -0
  189. package/lib/typescript/commonjs/index.d.ts +3 -0
  190. package/lib/typescript/commonjs/index.d.ts.map +1 -0
  191. package/lib/typescript/commonjs/modules/App.d.ts +7 -0
  192. package/lib/typescript/commonjs/modules/App.d.ts.map +1 -0
  193. package/lib/typescript/commonjs/modules/CompressOptions.d.ts +1 -0
  194. package/lib/typescript/commonjs/modules/CompressOptions.d.ts.map +1 -0
  195. package/lib/typescript/commonjs/modules/EnvironmentVariables.d.ts +16 -0
  196. package/lib/typescript/commonjs/modules/EnvironmentVariables.d.ts.map +1 -0
  197. package/lib/typescript/commonjs/modules/ListenOptions.d.ts +5 -0
  198. package/lib/typescript/commonjs/modules/ListenOptions.d.ts.map +1 -0
  199. package/lib/typescript/commonjs/modules/SSLApp.d.ts +1 -0
  200. package/lib/typescript/commonjs/modules/SSLApp.d.ts.map +1 -0
  201. package/lib/typescript/commonjs/modules/getParts.d.ts +6 -0
  202. package/lib/typescript/commonjs/modules/getParts.d.ts.map +1 -0
  203. package/lib/typescript/commonjs/modules/index.d.ts +6 -0
  204. package/lib/typescript/commonjs/modules/index.d.ts.map +1 -0
  205. package/lib/typescript/commonjs/modules/us_listen_socket_close.d.ts +5 -0
  206. package/lib/typescript/commonjs/modules/us_listen_socket_close.d.ts.map +1 -0
  207. package/lib/typescript/commonjs/modules/us_socket_local_port.d.ts +5 -0
  208. package/lib/typescript/commonjs/modules/us_socket_local_port.d.ts.map +1 -0
  209. package/lib/typescript/commonjs/package.json +1 -0
  210. package/lib/typescript/commonjs/types/AppDescriptor.d.ts +8 -0
  211. package/lib/typescript/commonjs/types/AppDescriptor.d.ts.map +1 -0
  212. package/lib/typescript/commonjs/types/AppOptions.d.ts +17 -0
  213. package/lib/typescript/commonjs/types/AppOptions.d.ts.map +1 -0
  214. package/lib/typescript/commonjs/types/HttpRequest.d.ts +54 -0
  215. package/lib/typescript/commonjs/types/HttpRequest.d.ts.map +1 -0
  216. package/lib/typescript/commonjs/types/HttpResponse.d.ts +169 -0
  217. package/lib/typescript/commonjs/types/HttpResponse.d.ts.map +1 -0
  218. package/lib/typescript/commonjs/types/HttpRouterOptions.d.ts +24 -0
  219. package/lib/typescript/commonjs/types/HttpRouterOptions.d.ts.map +1 -0
  220. package/lib/typescript/commonjs/types/MultipartField.d.ts +7 -0
  221. package/lib/typescript/commonjs/types/MultipartField.d.ts.map +1 -0
  222. package/lib/typescript/commonjs/types/RecognizedString.d.ts +10 -0
  223. package/lib/typescript/commonjs/types/RecognizedString.d.ts.map +1 -0
  224. package/lib/typescript/commonjs/types/TemplatedApp.d.ts +108 -0
  225. package/lib/typescript/commonjs/types/TemplatedApp.d.ts.map +1 -0
  226. package/lib/typescript/commonjs/types/WebSocket.d.ts +96 -0
  227. package/lib/typescript/commonjs/types/WebSocket.d.ts.map +1 -0
  228. package/lib/typescript/commonjs/types/WebSocketBehaviour.d.ts +1 -0
  229. package/lib/typescript/commonjs/types/WebSocketBehaviour.d.ts.map +1 -0
  230. package/lib/typescript/commonjs/types/index.d.ts +6 -0
  231. package/lib/typescript/commonjs/types/index.d.ts.map +1 -0
  232. package/lib/typescript/commonjs/types/us_listen_socket.d.ts +7 -0
  233. package/lib/typescript/commonjs/types/us_listen_socket.d.ts.map +1 -0
  234. package/lib/typescript/commonjs/types/us_socket.d.ts +7 -0
  235. package/lib/typescript/commonjs/types/us_socket.d.ts.map +1 -0
  236. package/lib/typescript/commonjs/types/us_socket_context_t.d.ts +7 -0
  237. package/lib/typescript/commonjs/types/us_socket_context_t.d.ts.map +1 -0
  238. package/lib/typescript/module/_internal/native-modules/NativeReactNativeUws.d.ts +22 -0
  239. package/lib/typescript/module/_internal/native-modules/NativeReactNativeUws.d.ts.map +1 -0
  240. package/lib/typescript/module/index.d.ts +3 -0
  241. package/lib/typescript/module/index.d.ts.map +1 -0
  242. package/lib/typescript/module/modules/App.d.ts +7 -0
  243. package/lib/typescript/module/modules/App.d.ts.map +1 -0
  244. package/lib/typescript/module/modules/CompressOptions.d.ts +1 -0
  245. package/lib/typescript/module/modules/CompressOptions.d.ts.map +1 -0
  246. package/lib/typescript/module/modules/EnvironmentVariables.d.ts +16 -0
  247. package/lib/typescript/module/modules/EnvironmentVariables.d.ts.map +1 -0
  248. package/lib/typescript/module/modules/ListenOptions.d.ts +5 -0
  249. package/lib/typescript/module/modules/ListenOptions.d.ts.map +1 -0
  250. package/lib/typescript/module/modules/SSLApp.d.ts +1 -0
  251. package/lib/typescript/module/modules/SSLApp.d.ts.map +1 -0
  252. package/lib/typescript/module/modules/getParts.d.ts +6 -0
  253. package/lib/typescript/module/modules/getParts.d.ts.map +1 -0
  254. package/lib/typescript/module/modules/index.d.ts +6 -0
  255. package/lib/typescript/module/modules/index.d.ts.map +1 -0
  256. package/lib/typescript/module/modules/us_listen_socket_close.d.ts +5 -0
  257. package/lib/typescript/module/modules/us_listen_socket_close.d.ts.map +1 -0
  258. package/lib/typescript/module/modules/us_socket_local_port.d.ts +5 -0
  259. package/lib/typescript/module/modules/us_socket_local_port.d.ts.map +1 -0
  260. package/lib/typescript/module/package.json +1 -0
  261. package/lib/typescript/module/types/AppDescriptor.d.ts +8 -0
  262. package/lib/typescript/module/types/AppDescriptor.d.ts.map +1 -0
  263. package/lib/typescript/module/types/AppOptions.d.ts +17 -0
  264. package/lib/typescript/module/types/AppOptions.d.ts.map +1 -0
  265. package/lib/typescript/module/types/HttpRequest.d.ts +54 -0
  266. package/lib/typescript/module/types/HttpRequest.d.ts.map +1 -0
  267. package/lib/typescript/module/types/HttpResponse.d.ts +169 -0
  268. package/lib/typescript/module/types/HttpResponse.d.ts.map +1 -0
  269. package/lib/typescript/module/types/HttpRouterOptions.d.ts +24 -0
  270. package/lib/typescript/module/types/HttpRouterOptions.d.ts.map +1 -0
  271. package/lib/typescript/module/types/MultipartField.d.ts +7 -0
  272. package/lib/typescript/module/types/MultipartField.d.ts.map +1 -0
  273. package/lib/typescript/module/types/RecognizedString.d.ts +10 -0
  274. package/lib/typescript/module/types/RecognizedString.d.ts.map +1 -0
  275. package/lib/typescript/module/types/TemplatedApp.d.ts +108 -0
  276. package/lib/typescript/module/types/TemplatedApp.d.ts.map +1 -0
  277. package/lib/typescript/module/types/WebSocket.d.ts +96 -0
  278. package/lib/typescript/module/types/WebSocket.d.ts.map +1 -0
  279. package/lib/typescript/module/types/WebSocketBehaviour.d.ts +1 -0
  280. package/lib/typescript/module/types/WebSocketBehaviour.d.ts.map +1 -0
  281. package/lib/typescript/module/types/index.d.ts +6 -0
  282. package/lib/typescript/module/types/index.d.ts.map +1 -0
  283. package/lib/typescript/module/types/us_listen_socket.d.ts +7 -0
  284. package/lib/typescript/module/types/us_listen_socket.d.ts.map +1 -0
  285. package/lib/typescript/module/types/us_socket.d.ts +7 -0
  286. package/lib/typescript/module/types/us_socket.d.ts.map +1 -0
  287. package/lib/typescript/module/types/us_socket_context_t.d.ts +7 -0
  288. package/lib/typescript/module/types/us_socket_context_t.d.ts.map +1 -0
  289. package/lib/typescript/tsconfig.tsbuildinfo +1 -0
  290. package/package.json +62 -0
  291. package/src/_internal/native-modules/NativeUwsReactNative.ts +40 -0
  292. package/src/index.ts +2 -0
  293. package/src/modules/App.ts +14 -0
  294. package/src/modules/CompressOptions.ts +101 -0
  295. package/src/modules/EnvironmentVariables.ts +16 -0
  296. package/src/modules/ListenOptions.ts +4 -0
  297. package/src/modules/SSLApp.ts +13 -0
  298. package/src/modules/getParts.ts +29 -0
  299. package/src/modules/index.ts +8 -0
  300. package/src/modules/us_listen_socket_close.ts +15 -0
  301. package/src/modules/us_socket_local_port.ts +16 -0
  302. package/src/types/AppDescriptor.ts +7 -0
  303. package/src/types/AppOptions.ts +22 -0
  304. package/src/types/HttpRequest.ts +74 -0
  305. package/src/types/HttpResponse.ts +309 -0
  306. package/src/types/HttpRouterOptions.ts +24 -0
  307. package/src/types/MultipartField.ts +6 -0
  308. package/src/types/RecognizedString.ts +11 -0
  309. package/src/types/TemplatedApp.ts +285 -0
  310. package/src/types/WebSocket.ts +147 -0
  311. package/src/types/WebSocketBehaviour.ts +137 -0
  312. package/src/types/index.ts +12 -0
  313. package/src/types/us_listen_socket.ts +6 -0
  314. package/src/types/us_socket.ts +6 -0
  315. package/src/types/us_socket_context_t.ts +6 -0
@@ -0,0 +1,285 @@
1
+ import type {
2
+ ListenOptions,
3
+ } from "../modules/ListenOptions"
4
+
5
+ // import type {
6
+ // AppDescriptor,
7
+ // } from "./AppDescriptor"
8
+
9
+ // import type {
10
+ // AppOptions,
11
+ // } from "./AppOptions"
12
+
13
+ import type {
14
+ HttpRequest,
15
+ } from "./HttpRequest"
16
+
17
+ import type {
18
+ HttpResponse,
19
+ } from "./HttpResponse"
20
+
21
+ import type {
22
+ HttpRouterOptions,
23
+ } from "./HttpRouterOptions"
24
+
25
+ import type {
26
+ RecognizedString,
27
+ } from "./RecognizedString"
28
+
29
+ // import type {
30
+ // WebSocketBehavior,
31
+ // } from "./WebSocketBehaviour"
32
+
33
+ // import type {
34
+ // us_listen_socket,
35
+ // } from "./us_listen_socket"
36
+
37
+ /**
38
+ * Definitions of the `App` and `SSLApp`. This is entirely copied from uWebSockets.js
39
+ */
40
+ export interface TemplatedApp {
41
+ // Can't figure it out how to implement it in React Native
42
+ /**
43
+ * Add a child app descriptor for worker thread distribution.
44
+ */
45
+ // addChildAppDescriptor(
46
+ // descriptor: AppDescriptor,
47
+ // ): void,
48
+
49
+ // TODO
50
+ // Need the SSL implementation
51
+ /**
52
+ * Adds a server name.
53
+ */
54
+ // addServerName(
55
+ // hostname: string,
56
+ // options: AppOptions,
57
+ // ) : TemplatedApp,
58
+
59
+ /**
60
+ * Closes all sockets including listen sockets. This will forcefully terminate all connections.
61
+ */
62
+ close() : void,
63
+
64
+ /**
65
+ * Browse to SNI domain. Used together with .get, .post and similar to attach routes under SNI domains.
66
+ */
67
+ domain(
68
+ domain: string,
69
+ ) : TemplatedApp,
70
+
71
+ /**
72
+ * Attaches a "filter" function to track socket connections / disconnections.
73
+ */
74
+ filter(
75
+ cb: (res: HttpResponse, count: number) => void | Promise<void>,
76
+ ) : TemplatedApp,
77
+
78
+ // Can't figure it out how to implement it in React Native
79
+ /**
80
+ * Returns the app descriptor for worker thread distribution.
81
+ */
82
+ // getDescriptor(): AppDescriptor,
83
+
84
+ /**
85
+ * Listens to hostname & port and sets Listen Options. Callback hands either false or a listen socket.
86
+ */
87
+ listen(
88
+ host: RecognizedString,
89
+ port: number,
90
+ options: ListenOptions,
91
+ cb: (
92
+ id: number,
93
+ // listenSocket: us_listen_socket | false,
94
+ ) => void | Promise<void>,
95
+ ) : TemplatedApp,
96
+
97
+ /**
98
+ * Listens to hostname & port. Callback hands either false or a listen socket.
99
+ */
100
+ listen(
101
+ host: RecognizedString,
102
+ port: number,
103
+ cb: (
104
+ token: number,
105
+ // listenSocket: us_listen_socket | false,
106
+ ) => void | Promise<void>,
107
+ ) : TemplatedApp,
108
+
109
+ /**
110
+ * Listens to port and sets Listen Options. Callback hands either false or a listen socket.
111
+ */
112
+ listen(
113
+ port: number,
114
+ options: ListenOptions,
115
+ cb: (
116
+ token: number,
117
+ // listenSocket: us_listen_socket | false,
118
+ ) => void | Promise<void>,
119
+ ) : TemplatedApp,
120
+
121
+ /**
122
+ * Listens to port. Callback hands either false or a listen socket.
123
+ */
124
+ listen(
125
+ port: number,
126
+ cb: (
127
+ token: number,
128
+ // listenSocket: us_listen_socket | false,
129
+ ) => void | Promise<void>,
130
+ ) : TemplatedApp,
131
+
132
+ // TODO
133
+ // Need the SSL implementation
134
+ /**
135
+ * Registers a synchronous callback on missing server names. See /examples/ServerName.js.
136
+ */
137
+ // missingServerName(
138
+ // cb: (hostname: string) => void,
139
+ // ) : TemplatedApp,
140
+
141
+ /**
142
+ * Returns number of subscribers for this topic.
143
+ */
144
+ numSubscribers(
145
+ topic: RecognizedString,
146
+ ) : number,
147
+
148
+ /**
149
+ * Publishes a message under topic, for all WebSockets under this app. See WebSocket.publish.
150
+ */
151
+ publish(
152
+ topic: RecognizedString,
153
+ message: RecognizedString,
154
+ isBinary?: boolean,
155
+ compress?: boolean,
156
+ ) : boolean,
157
+
158
+ // Can't figure it out how to implement it in React Native
159
+ /**
160
+ * Remove a child app descriptor.
161
+ */
162
+ // removeChildAppDescriptor(
163
+ // descriptor: AppDescriptor,
164
+ // ): void,
165
+
166
+ // TODO
167
+ // Need the SSL implementation
168
+ /**
169
+ * Removes a server name.
170
+ */
171
+ // removeServerName(
172
+ // hostname: string,
173
+ // ) : TemplatedApp,
174
+
175
+ // /**
176
+ // * Registers a handler matching specified URL pattern where WebSocket upgrade requests are caught.
177
+ // */
178
+ // ws/* <UserData> */(
179
+ // pattern: RecognizedString,
180
+ // behavior: WebSocketBehavior/* <UserData> */,
181
+ // ) : TemplatedApp,
182
+
183
+ // we can't provide this in Reaact Native
184
+ /**
185
+ * Listens to unix socket. Callback hands either false or a listen socket.
186
+ */
187
+ // listen_unix(
188
+ // cb: (listenSocket: us_listen_socket) => void | Promise<void>,
189
+ // path: RecognizedString,
190
+ // ) : TemplatedApp,
191
+
192
+ // +++++ ROUTER +++++
193
+
194
+ /**
195
+ * Registers an HTTP handler matching specified URL pattern on any HTTP method.
196
+ */
197
+ any(
198
+ pattern: RecognizedString,
199
+ handler: (res: HttpResponse, req: HttpRequest) => void | Promise<void>,
200
+ options?: HttpRouterOptions,
201
+ ) : TemplatedApp,
202
+
203
+ /**
204
+ * Registers an HTTP CONNECT handler matching specified URL pattern.
205
+ */
206
+ connect(
207
+ pattern: RecognizedString,
208
+ handler: (res: HttpResponse, req: HttpRequest) => void | Promise<void>,
209
+ options?: HttpRouterOptions,
210
+ ) : TemplatedApp,
211
+
212
+ /**
213
+ * Registers an HTTP DELETE handler matching specified URL pattern.
214
+ */
215
+ del(
216
+ pattern: RecognizedString,
217
+ handler: (res: HttpResponse, req: HttpRequest) => void | Promise<void>,
218
+ options?: HttpRouterOptions,
219
+ ) : TemplatedApp,
220
+
221
+ /**
222
+ * Registers an HTTP GET handler matching specified URL pattern.
223
+ */
224
+ get(
225
+ pattern: RecognizedString,
226
+ handler: (res: HttpResponse, req: HttpRequest) => void | Promise<void>,
227
+ options?: HttpRouterOptions,
228
+ ) : TemplatedApp,
229
+
230
+ /**
231
+ * Registers an HTTP HEAD handler matching specified URL pattern.
232
+ */
233
+ head(
234
+ pattern: RecognizedString,
235
+ handler: (res: HttpResponse, req: HttpRequest) => void | Promise<void>,
236
+ options?: HttpRouterOptions,
237
+ ) : TemplatedApp,
238
+
239
+ /**
240
+ * Registers an HTTP OPTIONS handler matching specified URL pattern.
241
+ */
242
+ options(
243
+ pattern: RecognizedString,
244
+ handler: (res: HttpResponse, req: HttpRequest) => void | Promise<void>,
245
+ options?: HttpRouterOptions,
246
+ ) : TemplatedApp,
247
+
248
+ /**
249
+ * Registers an HTTP PATCH handler matching specified URL pattern.
250
+ */
251
+ patch(
252
+ pattern: RecognizedString,
253
+ handler: (res: HttpResponse, req: HttpRequest) => void | Promise<void>,
254
+ options?: HttpRouterOptions,
255
+ ) : TemplatedApp,
256
+
257
+ /**
258
+ * Registers an HTTP POST handler matching specified URL pattern.
259
+ */
260
+ post(
261
+ pattern: RecognizedString,
262
+ handler: (res: HttpResponse, req: HttpRequest) => void | Promise<void>,
263
+ options?: HttpRouterOptions,
264
+ ) : TemplatedApp,
265
+
266
+ /**
267
+ * Registers an HTTP PUT handler matching specified URL pattern.
268
+ */
269
+ put(
270
+ pattern: RecognizedString,
271
+ handler: (res: HttpResponse, req: HttpRequest) => void | Promise<void>,
272
+ options?: HttpRouterOptions,
273
+ ) : TemplatedApp,
274
+
275
+ /**
276
+ * Registers an HTTP TRACE handler matching specified URL pattern.
277
+ */
278
+ trace(
279
+ pattern: RecognizedString,
280
+ handler: (res: HttpResponse, req: HttpRequest) => void | Promise<void>,
281
+ options?: HttpRouterOptions,
282
+ ) : TemplatedApp,
283
+
284
+ // ----- ROUTER -----
285
+ }
@@ -0,0 +1,147 @@
1
+ import type {
2
+ RecognizedString,
3
+ } from "./RecognizedString"
4
+
5
+ /**
6
+ * A WebSocket connection that is valid from open to close event.
7
+ * Read more about this in the user manual.
8
+ */
9
+ export interface WebSocket/* <UserData> */ {
10
+ /**
11
+ * Sends a message. Returns 1 for success, 2 for dropped due to backpressure limit, and 0 for built up backpressure that will drain over time. You can check backpressure before or after sending by calling getBufferedAmount().
12
+ *
13
+ * Make sure you properly understand the concept of backpressure. Check the backpressure example file.
14
+ */
15
+ send(
16
+ message: RecognizedString,
17
+ isBinary?: boolean,
18
+ compress?: boolean,
19
+ ) : number,
20
+
21
+ /**
22
+ * Returns the bytes buffered in backpressure. This is similar to the bufferedAmount property in the browser counterpart.
23
+ * Check backpressure example.
24
+ */
25
+ getBufferedAmount() : number,
26
+
27
+ /**
28
+ * Gracefully closes this WebSocket. Immediately calls the close handler.
29
+ * A WebSocket close message is sent with code and shortMessage.
30
+ */
31
+ end(
32
+ code?: number,
33
+ shortMessage?: RecognizedString,
34
+ ) : void,
35
+
36
+ /**
37
+ * Forcefully closes this WebSocket. Immediately calls the close handler.
38
+ * No WebSocket close message is sent.
39
+ */
40
+ close() : void,
41
+
42
+ /**
43
+ * Sends a ping control message. Returns sendStatus similar to WebSocket.send (regarding backpressure). This helper function correlates to WebSocket::send(message, uWS::OpCode::PING, ...) in C++.
44
+ */
45
+ ping(
46
+ message?: RecognizedString,
47
+ ) : number,
48
+
49
+ /**
50
+ * Subscribe to a topic.
51
+ */
52
+ subscribe(
53
+ topic: RecognizedString,
54
+ ) : boolean,
55
+
56
+ /**
57
+ * Unsubscribe from a topic. Returns true on success, if the WebSocket was subscribed.
58
+ */
59
+ unsubscribe(
60
+ topic: RecognizedString,
61
+ ) : boolean,
62
+
63
+ /**
64
+ * Returns whether this websocket is subscribed to topic.
65
+ */
66
+ isSubscribed(
67
+ topic: RecognizedString,
68
+ ) : boolean,
69
+
70
+ /**
71
+ * Returns a list of topics this websocket is subscribed to.
72
+ */
73
+ getTopics() : string[],
74
+
75
+ /**
76
+ * Publish a message under topic. Backpressure is managed according to maxBackpressure, closeOnBackpressureLimit settings.
77
+ * Order is guaranteed since v20.
78
+ */
79
+ publish(
80
+ topic: RecognizedString,
81
+ message: RecognizedString,
82
+ isBinary?: boolean,
83
+ compress?: boolean,
84
+ ) : boolean,
85
+
86
+ /**
87
+ * See `HttpResponse.cork`. Takes a function in which the socket is corked (packing many sends into one single syscall/SSL block)
88
+ */
89
+ cork(
90
+ cb: () => void,
91
+ ) : WebSocket/* <UserData> */,
92
+
93
+ /**
94
+ * Returns the remote IP address. Note that the returned IP is binary, not text.
95
+ *
96
+ * IPv4 is 4 byte long and can be converted to text by printing every byte as a digit between 0 and 255.
97
+ * IPv6 is 16 byte long and can be converted to text in similar ways, but you typically print digits in HEX.
98
+ *
99
+ * See getRemoteAddressAsText() for a text version.
100
+ *
101
+ * @experimental It's an experimental due to unstable of ArrayBuffer support from React Native.
102
+ */
103
+ getRemoteAddress() : ArrayBuffer,
104
+
105
+ /**
106
+ * Returns the remote IP address as text.
107
+ */
108
+ getRemoteAddressAsText() : /* ArrayBuffer */string,
109
+
110
+ /**
111
+ * Returns the remote port number.
112
+ */
113
+ getRemotePort() : number,
114
+
115
+ /**
116
+ * Returns the UserData ~object~ string.
117
+ */
118
+ getUserData() : /* UserData */string,
119
+
120
+ /**
121
+ * Sends the first fragment of a fragmented message. Use for sending large messages in chunks.
122
+ * Returns 1 for success, 2 for dropped due to backpressure limit, and 0 for built up backpressure.
123
+ */
124
+ sendFirstFragment(
125
+ message: RecognizedString,
126
+ isBinary?: boolean,
127
+ compress?: boolean,
128
+ ) : number,
129
+
130
+ /**
131
+ * Sends a middle fragment of a fragmented message.
132
+ * Returns 1 for success, 2 for dropped due to backpressure limit, and 0 for built up backpressure.
133
+ */
134
+ sendFragment(
135
+ message: RecognizedString,
136
+ compress?: boolean,
137
+ ) : number,
138
+
139
+ /**
140
+ * Sends the last fragment of a fragmented message.
141
+ * Returns 1 for success, 2 for dropped due to backpressure limit, and 0 for built up backpressure.
142
+ */
143
+ sendLastFragment(
144
+ message: RecognizedString,
145
+ compress?: boolean,
146
+ ) : number,
147
+ }
@@ -0,0 +1,137 @@
1
+ // import type {
2
+ // CompressOptions,
3
+ // } from "../modules/CompressOptions"
4
+
5
+ // import type {
6
+ // HttpRequest,
7
+ // } from "./HttpRequest"
8
+
9
+ // import type {
10
+ // HttpResponse,
11
+ // } from "./HttpResponse"
12
+
13
+ // import type {
14
+ // WebSocket,
15
+ // } from "./WebSocket"
16
+
17
+ // import type {
18
+ // us_socket_context_t,
19
+ // } from "./us_socket_context_t"
20
+
21
+ // /**
22
+ // * A structure holding settings and handlers for a WebSocket URL route handler.
23
+ // */
24
+ // export interface WebSocketBehavior/* <UserData> */ {
25
+ // /**
26
+ // * Maximum length of received message. If a client tries to send you a message larger than this, the connection is immediately closed. Defaults to 16 * 1024.
27
+ // */
28
+ // maxPayloadLength?: number,
29
+
30
+ // /**
31
+ // * Whether or not we should automatically close the socket when a message is dropped due to backpressure. Defaults to false.
32
+ // */
33
+ // closeOnBackpressureLimit?: boolean,
34
+
35
+ // /**
36
+ // * Maximum number of minutes a WebSocket may be connected before being closed by the server. 0 disables the feature. Valid values are 0 and 1-239.
37
+ // */
38
+ // maxLifetime?: number,
39
+
40
+ // /**
41
+ // * Maximum amount of seconds that may pass without sending or getting a message. Connection is closed if this timeout passes. Resolution (granularity) for timeouts are typically 4 seconds, rounded to closest.
42
+ // * Disable by using 0. Defaults to 120.
43
+ // */
44
+ // idleTimeout?: number,
45
+
46
+ // /**
47
+ // * What permessage-deflate compression to use. uWS.DISABLED, uWS.SHARED_COMPRESSOR or any of the uWS.DEDICATED_COMPRESSOR_xxxKB. Defaults to uWS.DISABLED.
48
+ // */
49
+ // compression?: CompressOptions,
50
+
51
+ // /**
52
+ // * Maximum length of allowed backpressure per socket when publishing or sending messages. Slow receivers with too high backpressure will be skipped until they catch up or timeout. Defaults to 64 * 1024.
53
+ // */
54
+ // maxBackpressure?: number,
55
+
56
+ // /**
57
+ // * Whether or not we should automatically send pings to uphold a stable connection given whatever idleTimeout.
58
+ // */
59
+ // sendPingsAutomatically?: boolean,
60
+
61
+ // /**
62
+ // * Upgrade handler used to intercept HTTP upgrade requests and potentially upgrade to WebSocket.
63
+ // * See UpgradeAsync and UpgradeSync example files.
64
+ // */
65
+ // upgrade?: (
66
+ // res: HttpResponse,
67
+ // req: HttpRequest,
68
+ // context: us_socket_context_t,
69
+ // ) => void | Promise<void>,
70
+
71
+ // /**
72
+ // * Handler for new WebSocket connection. WebSocket is valid from open to close, no errors.
73
+ // */
74
+ // open?: (
75
+ // ws: WebSocket/* <UserData> */,
76
+ // ) => void | Promise<void>,
77
+
78
+ // /**
79
+ // * Handler for a WebSocket message. Messages are given as ArrayBuffer no matter if they are binary or not. Given ArrayBuffer is valid during the lifetime of this callback (until first await or return) and will be neutered.
80
+ // */
81
+ // message?: (
82
+ // ws: WebSocket/* <UserData> */,
83
+ // message: ArrayBuffer,
84
+ // isBinary: boolean,
85
+ // ) => void | Promise<void>,
86
+
87
+ // /**
88
+ // * Handler for a dropped WebSocket message. Messages can be dropped due to specified backpressure settings. Messages are given as ArrayBuffer no matter if they are binary or not. Given ArrayBuffer is valid during the lifetime of this callback (until first await or return) and will be neutered.
89
+ // */
90
+ // dropped?: (
91
+ // ws: WebSocket/* <UserData> */,
92
+ // message: ArrayBuffer,
93
+ // isBinary: boolean,
94
+ // ) => void | Promise<void>,
95
+
96
+ // /**
97
+ // * Handler for when WebSocket backpressure drains. Check ws.getBufferedAmount(). Use this to guide / drive your backpressure throttling.
98
+ // */
99
+ // drain?: (
100
+ // ws: WebSocket/* <UserData> */,
101
+ // ) => void,
102
+
103
+ // /**
104
+ // * Handler for close event, no matter if error, timeout or graceful close. You may not use WebSocket after this event. Do not send on this WebSocket from within here, it is closed.
105
+ // */
106
+ // close?: (
107
+ // ws: WebSocket/* <UserData> */,
108
+ // code: number,
109
+ // message: ArrayBuffer,
110
+ // ) => void,
111
+
112
+ // /**
113
+ // * Handler for received ping control message. You do not need to handle this, pong messages are automatically sent as per the standard.
114
+ // */
115
+ // ping?: (
116
+ // ws: WebSocket/* <UserData> */,
117
+ // message: ArrayBuffer,
118
+ // ) => void,
119
+
120
+ // /**
121
+ // * Handler for received pong control message.
122
+ // */
123
+ // pong?: (
124
+ // ws: WebSocket/* <UserData> */,
125
+ // message: ArrayBuffer,
126
+ // ) => void,
127
+
128
+ // /**
129
+ // * Handler for subscription changes.
130
+ // */
131
+ // subscription?: (
132
+ // ws: WebSocket/* <UserData> */,
133
+ // topic: ArrayBuffer,
134
+ // newCount: number,
135
+ // oldCount: number,
136
+ // ) => void,
137
+ // }
@@ -0,0 +1,12 @@
1
+ // export type * from "./AppDescriptor"
2
+ // export type * from "./AppOptions"
3
+ export type * from "./HttpRequest"
4
+ export type * from "./HttpResponse"
5
+ export type * from "./MultipartField"
6
+ export type * from "./RecognizedString"
7
+ export type * from "./TemplatedApp"
8
+ // export type * from "./WebSocket"
9
+ // export type * from "./WebSocketBehaviour"
10
+ // export type * from "./us_listen_socket"
11
+ // export type * from "./us_socket"
12
+ // export type * from "./us_socket_context_t"
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Native type representing a raw uSockets struct us_listen_socket_t.
3
+ * Careful with this one, it is entirely unchecked and native so invalid usage will blow up.
4
+ */
5
+ export interface us_listen_socket {
6
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Native type representing a raw uSockets struct us_socket_t.
3
+ * Careful with this one, it is entirely unchecked and native so invalid usage will blow up.
4
+ */
5
+ export interface us_socket {
6
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Native type representing a raw uSockets struct us_socket_context_t.
3
+ * Used while upgrading a WebSocket manually.
4
+ */
5
+ export interface us_socket_context_t {
6
+ }