@encharm/cws 4.3.0 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (234) hide show
  1. package/README.md +5 -7
  2. package/dist/bindings/cws_darwin_arm64_node108.node +0 -0
  3. package/dist/bindings/cws_darwin_arm64_node115.node +0 -0
  4. package/dist/bindings/cws_darwin_arm64_node83.node +0 -0
  5. package/dist/bindings/cws_darwin_arm64_node93.node +0 -0
  6. package/dist/bindings/cws_darwin_x64_node108.node +0 -0
  7. package/dist/bindings/cws_darwin_x64_node115.node +0 -0
  8. package/dist/bindings/cws_darwin_x64_node83.node +0 -0
  9. package/dist/bindings/cws_darwin_x64_node93.node +0 -0
  10. package/dist/bindings/cws_linux_arm64_node108.node +0 -0
  11. package/dist/bindings/cws_linux_arm64_node115.node +0 -0
  12. package/dist/bindings/cws_linux_arm64_node83.node +0 -0
  13. package/dist/bindings/cws_linux_arm64_node93.node +0 -0
  14. package/dist/bindings/cws_linux_x64_node108.node +0 -0
  15. package/dist/bindings/cws_linux_x64_node115.node +0 -0
  16. package/dist/bindings/cws_linux_x64_node83.node +0 -0
  17. package/dist/bindings/cws_linux_x64_node93.node +0 -0
  18. package/dist/bindings/cws_win32_x64_node108.node +0 -0
  19. package/dist/bindings/cws_win32_x64_node115.node +0 -0
  20. package/dist/bindings/cws_win32_x64_node83.node +0 -0
  21. package/dist/bindings/cws_win32_x64_node93.node +0 -0
  22. package/dist/shared.js +1 -1
  23. package/package.json +5 -5
  24. package/src/Addon.cpp +4 -12
  25. package/src/Addon.h +55 -90
  26. package/src/Socket.h +1 -0
  27. package/src/cSNode.cpp +3 -8
  28. package/src/headers/20/acorn_version.h +6 -0
  29. package/src/headers/20/aliased_buffer-inl.h +243 -0
  30. package/src/headers/20/aliased_buffer.h +206 -0
  31. package/src/headers/20/aliased_struct-inl.h +54 -0
  32. package/src/headers/20/aliased_struct.h +63 -0
  33. package/src/headers/20/async_wrap-inl.h +93 -0
  34. package/src/headers/20/async_wrap.h +252 -0
  35. package/src/headers/20/base64-inl.h +193 -0
  36. package/src/headers/20/base64.h +53 -0
  37. package/src/headers/20/base64_version.h +6 -0
  38. package/src/headers/20/base_object-inl.h +316 -0
  39. package/src/headers/20/base_object.h +320 -0
  40. package/src/headers/20/base_object_types.h +73 -0
  41. package/src/headers/20/blob_serializer_deserializer-inl.h +361 -0
  42. package/src/headers/20/blob_serializer_deserializer.h +132 -0
  43. package/src/headers/20/callback_queue-inl.h +97 -0
  44. package/src/headers/20/callback_queue.h +79 -0
  45. package/src/headers/20/cares_wrap.h +524 -0
  46. package/src/headers/20/cjs_module_lexer_version.h +6 -0
  47. package/src/headers/20/cleanup_queue-inl.h +62 -0
  48. package/src/headers/20/cleanup_queue.h +85 -0
  49. package/src/headers/20/connect_wrap.h +26 -0
  50. package/src/headers/20/connection_wrap.h +29 -0
  51. package/src/headers/20/cppgc/DEPS +8 -0
  52. package/src/headers/20/cppgc/OWNERS +2 -0
  53. package/src/headers/20/cppgc/README.md +135 -0
  54. package/src/headers/20/cppgc/allocation.h +310 -0
  55. package/src/headers/20/cppgc/common.h +28 -0
  56. package/src/headers/20/cppgc/cross-thread-persistent.h +466 -0
  57. package/src/headers/20/cppgc/custom-space.h +97 -0
  58. package/src/headers/20/cppgc/default-platform.h +67 -0
  59. package/src/headers/20/cppgc/ephemeron-pair.h +30 -0
  60. package/src/headers/20/cppgc/explicit-management.h +100 -0
  61. package/src/headers/20/cppgc/garbage-collected.h +106 -0
  62. package/src/headers/20/cppgc/heap-consistency.h +309 -0
  63. package/src/headers/20/cppgc/heap-handle.h +48 -0
  64. package/src/headers/20/cppgc/heap-state.h +82 -0
  65. package/src/headers/20/cppgc/heap-statistics.h +120 -0
  66. package/src/headers/20/cppgc/heap.h +202 -0
  67. package/src/headers/20/cppgc/internal/api-constants.h +68 -0
  68. package/src/headers/20/cppgc/internal/atomic-entry-flag.h +48 -0
  69. package/src/headers/20/cppgc/internal/base-page-handle.h +45 -0
  70. package/src/headers/20/cppgc/internal/caged-heap-local-data.h +111 -0
  71. package/src/headers/20/cppgc/internal/caged-heap.h +61 -0
  72. package/src/headers/20/cppgc/internal/compiler-specific.h +38 -0
  73. package/src/headers/20/cppgc/internal/finalizer-trait.h +93 -0
  74. package/src/headers/20/cppgc/internal/gc-info.h +157 -0
  75. package/src/headers/20/cppgc/internal/logging.h +50 -0
  76. package/src/headers/20/cppgc/internal/member-storage.h +248 -0
  77. package/src/headers/20/cppgc/internal/name-trait.h +137 -0
  78. package/src/headers/20/cppgc/internal/persistent-node.h +214 -0
  79. package/src/headers/20/cppgc/internal/pointer-policies.h +243 -0
  80. package/src/headers/20/cppgc/internal/write-barrier.h +487 -0
  81. package/src/headers/20/cppgc/liveness-broker.h +78 -0
  82. package/src/headers/20/cppgc/macros.h +35 -0
  83. package/src/headers/20/cppgc/member.h +604 -0
  84. package/src/headers/20/cppgc/name-provider.h +65 -0
  85. package/src/headers/20/cppgc/object-size-trait.h +58 -0
  86. package/src/headers/20/cppgc/persistent.h +373 -0
  87. package/src/headers/20/cppgc/platform.h +158 -0
  88. package/src/headers/20/cppgc/prefinalizer.h +75 -0
  89. package/src/headers/20/cppgc/process-heap-statistics.h +36 -0
  90. package/src/headers/20/cppgc/sentinel-pointer.h +32 -0
  91. package/src/headers/20/cppgc/source-location.h +92 -0
  92. package/src/headers/20/cppgc/testing.h +106 -0
  93. package/src/headers/20/cppgc/trace-trait.h +120 -0
  94. package/src/headers/20/cppgc/type-traits.h +250 -0
  95. package/src/headers/20/cppgc/visitor.h +426 -0
  96. package/src/headers/20/crypto/crypto_clienthello.h +131 -0
  97. package/src/headers/20/crypto/crypto_context.h +160 -0
  98. package/src/headers/20/crypto/crypto_keys.h +416 -0
  99. package/src/headers/20/crypto/crypto_tls.h +295 -0
  100. package/src/headers/20/crypto/crypto_util.h +805 -0
  101. package/src/headers/20/crypto_clienthello.h +131 -0
  102. package/src/headers/20/debug_utils-inl.h +226 -0
  103. package/src/headers/20/debug_utils.h +188 -0
  104. package/src/headers/20/diagnosticfilename-inl.h +33 -0
  105. package/src/headers/20/encoding_binding.h +59 -0
  106. package/src/headers/20/env-inl.h +923 -0
  107. package/src/headers/20/env.h +1193 -0
  108. package/src/headers/20/env_properties.h +444 -0
  109. package/src/headers/20/handle_wrap.h +123 -0
  110. package/src/headers/20/histogram-inl.h +107 -0
  111. package/src/headers/20/histogram.h +240 -0
  112. package/src/headers/20/inspector_agent.h +144 -0
  113. package/src/headers/20/inspector_io.h +78 -0
  114. package/src/headers/20/inspector_profiler.h +149 -0
  115. package/src/headers/20/inspector_socket.h +60 -0
  116. package/src/headers/20/inspector_socket_server.h +110 -0
  117. package/src/headers/20/js_native_api.h +591 -0
  118. package/src/headers/20/js_native_api_types.h +168 -0
  119. package/src/headers/20/js_native_api_v8.h +426 -0
  120. package/src/headers/20/js_native_api_v8_internals.h +39 -0
  121. package/src/headers/20/js_stream.h +52 -0
  122. package/src/headers/20/json_parser.h +38 -0
  123. package/src/headers/20/json_utils.h +172 -0
  124. package/src/headers/20/memory_tracker-inl.h +356 -0
  125. package/src/headers/20/memory_tracker.h +289 -0
  126. package/src/headers/20/module_wrap.h +117 -0
  127. package/src/headers/20/node.h +1514 -0
  128. package/src/headers/20/node_api.h +260 -0
  129. package/src/headers/20/node_api_internals.h +42 -0
  130. package/src/headers/20/node_api_types.h +52 -0
  131. package/src/headers/20/node_binding.h +142 -0
  132. package/src/headers/20/node_blob.h +159 -0
  133. package/src/headers/20/node_bob-inl.h +36 -0
  134. package/src/headers/20/node_bob.h +107 -0
  135. package/src/headers/20/node_buffer.h +92 -0
  136. package/src/headers/20/node_builtins.h +197 -0
  137. package/src/headers/20/node_constants.h +79 -0
  138. package/src/headers/20/node_context_data.h +98 -0
  139. package/src/headers/20/node_contextify.h +182 -0
  140. package/src/headers/20/node_crypto.h +56 -0
  141. package/src/headers/20/node_dir.h +52 -0
  142. package/src/headers/20/node_dotenv.h +37 -0
  143. package/src/headers/20/node_errors.h +313 -0
  144. package/src/headers/20/node_exit_code.h +54 -0
  145. package/src/headers/20/node_external_reference.h +172 -0
  146. package/src/headers/20/node_file-inl.h +357 -0
  147. package/src/headers/20/node_file.h +524 -0
  148. package/src/headers/20/node_http2.h +1146 -0
  149. package/src/headers/20/node_http2_state.h +147 -0
  150. package/src/headers/20/node_http_common-inl.h +201 -0
  151. package/src/headers/20/node_http_common.h +532 -0
  152. package/src/headers/20/node_i18n.h +145 -0
  153. package/src/headers/20/node_internals.h +443 -0
  154. package/src/headers/20/node_main_instance.h +67 -0
  155. package/src/headers/20/node_mem-inl.h +112 -0
  156. package/src/headers/20/node_mem.h +45 -0
  157. package/src/headers/20/node_messaging.h +377 -0
  158. package/src/headers/20/node_metadata.h +138 -0
  159. package/src/headers/20/node_mutex.h +323 -0
  160. package/src/headers/20/node_object_wrap.h +132 -0
  161. package/src/headers/20/node_options-inl.h +478 -0
  162. package/src/headers/20/node_options.h +538 -0
  163. package/src/headers/20/node_perf.h +166 -0
  164. package/src/headers/20/node_perf_common.h +98 -0
  165. package/src/headers/20/node_platform.h +195 -0
  166. package/src/headers/20/node_process-inl.h +26 -0
  167. package/src/headers/20/node_process.h +99 -0
  168. package/src/headers/20/node_realm-inl.h +139 -0
  169. package/src/headers/20/node_realm.h +184 -0
  170. package/src/headers/20/node_report.h +42 -0
  171. package/src/headers/20/node_revert.h +82 -0
  172. package/src/headers/20/node_root_certs.h +3443 -0
  173. package/src/headers/20/node_sea.h +56 -0
  174. package/src/headers/20/node_shadow_realm.h +46 -0
  175. package/src/headers/20/node_snapshot_builder.h +54 -0
  176. package/src/headers/20/node_snapshotable.h +164 -0
  177. package/src/headers/20/node_sockaddr-inl.h +266 -0
  178. package/src/headers/20/node_sockaddr.h +405 -0
  179. package/src/headers/20/node_stat_watcher.h +73 -0
  180. package/src/headers/20/node_threadsafe_cow-inl.h +54 -0
  181. package/src/headers/20/node_threadsafe_cow.h +105 -0
  182. package/src/headers/20/node_union_bytes.h +81 -0
  183. package/src/headers/20/node_url.h +92 -0
  184. package/src/headers/20/node_v8.h +77 -0
  185. package/src/headers/20/node_v8_platform-inl.h +205 -0
  186. package/src/headers/20/node_version.h +109 -0
  187. package/src/headers/20/node_wasi.h +184 -0
  188. package/src/headers/20/node_wasm_web_api.h +55 -0
  189. package/src/headers/20/node_watchdog.h +154 -0
  190. package/src/headers/20/node_worker.h +151 -0
  191. package/src/headers/20/permission/child_process_permission.h +28 -0
  192. package/src/headers/20/permission/fs_permission.h +152 -0
  193. package/src/headers/20/permission/permission.h +71 -0
  194. package/src/headers/20/permission/permission_base.h +49 -0
  195. package/src/headers/20/permission/worker_permission.h +28 -0
  196. package/src/headers/20/pipe_wrap.h +80 -0
  197. package/src/headers/20/req_wrap-inl.h +171 -0
  198. package/src/headers/20/req_wrap.h +77 -0
  199. package/src/headers/20/spawn_sync.h +242 -0
  200. package/src/headers/20/stream_base-inl.h +173 -0
  201. package/src/headers/20/stream_base.h +469 -0
  202. package/src/headers/20/stream_pipe.h +76 -0
  203. package/src/headers/20/stream_wrap.h +131 -0
  204. package/src/headers/20/string_bytes.h +120 -0
  205. package/src/headers/20/string_decoder-inl.h +37 -0
  206. package/src/headers/20/string_decoder.h +50 -0
  207. package/src/headers/20/string_search.h +638 -0
  208. package/src/headers/20/tcp_wrap.h +105 -0
  209. package/src/headers/20/threadpoolwork-inl.h +70 -0
  210. package/src/headers/20/timer_wrap-inl.h +32 -0
  211. package/src/headers/20/timer_wrap.h +85 -0
  212. package/src/headers/20/timers.h +70 -0
  213. package/src/headers/20/tracing/agent.h +195 -0
  214. package/src/headers/20/tracing/trace_event.h +720 -0
  215. package/src/headers/20/tracing/trace_event_common.h +1109 -0
  216. package/src/headers/20/tty_wrap.h +65 -0
  217. package/src/headers/20/udp_wrap.h +227 -0
  218. package/src/headers/20/undici_version.h +6 -0
  219. package/src/headers/20/util-inl.h +623 -0
  220. package/src/headers/20/util.h +988 -0
  221. package/src/headers/20/v8-cppgc.h +245 -0
  222. package/src/headers/20/v8-fast-api-calls.h +957 -0
  223. package/dist/bindings/cws_darwin_arm64_node64.node +0 -0
  224. package/dist/bindings/cws_darwin_arm64_node72.node +0 -0
  225. package/dist/bindings/cws_darwin_arm64_node79.node +0 -0
  226. package/dist/bindings/cws_darwin_x64_node64.node +0 -0
  227. package/dist/bindings/cws_darwin_x64_node72.node +0 -0
  228. package/dist/bindings/cws_darwin_x64_node79.node +0 -0
  229. package/dist/bindings/cws_linux_x64_node64.node +0 -0
  230. package/dist/bindings/cws_linux_x64_node72.node +0 -0
  231. package/dist/bindings/cws_linux_x64_node79.node +0 -0
  232. package/dist/bindings/cws_win32_x64_node64.node +0 -0
  233. package/dist/bindings/cws_win32_x64_node72.node +0 -0
  234. package/dist/bindings/cws_win32_x64_node79.node +0 -0
package/README.md CHANGED
@@ -12,13 +12,11 @@
12
12
 
13
13
  This table is true if you run ssl directly with `cws` (`Node.js`). In case if you use proxy for example `nginx`, `cws` can be run on bigger coverage.
14
14
 
15
- | CWS Version | Node 10 | Node 11 | Node 12 | Node 13 | Node 14 | Node 16 |
16
- |--------------|----------|---------|------------------|-----------|---------|----------|
17
- | 4.x.x | >=10.0 | X | >=12.16 | >=13.9 | >=14.5 | >= 16.11 |
18
- | *The versions below are available via @clusterws/cws* |
19
- | 3.0.0 | >=10.0 | X | >=12.16 | >=13.9 | >=14.5 | X |
20
- | 2.0.0 | >=10.0 | X | >=12.16 | >=13.9 | X | X |
21
- | 1.6.0 | >=10.0 | >=11.0 | >=12.0 & <12.16 | >=13.9 | X | X |
15
+ | cWS Version | Node 14 | Node 16 | Node 18 | Node 20 |
16
+ |-------------|----------|---------|-------------------|
17
+ | 4.4.x | X | X | X | X |
18
+
19
+ Node <14 are supported with @clusterws/cws.
22
20
 
23
21
  ## Documentation
24
22
 
package/dist/shared.js CHANGED
@@ -15,7 +15,7 @@ exports.native = (() => {
15
15
  return require(`../dist/bindings/cws_${process.platform}_${process.arch}_node${process.versions.modules}`);
16
16
  }
17
17
  catch (err) {
18
- err.message = err.message + ` check './node_modules/@clusterws/cws/build_log.txt' for post install build logs`;
18
+ err.message = err.message + ` check './node_modules/@encharm/cws/build_log.txt' for post install build logs`;
19
19
  throw err;
20
20
  }
21
21
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
- {
1
+ {
2
2
  "name": "@encharm/cws",
3
- "version": "4.3.0",
3
+ "version": "4.4.0",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "description": "cWS - fast C++ WebSocket implementation for Node.js",
@@ -30,12 +30,12 @@
30
30
  "@types/node": "^13.11.1",
31
31
  "chai": "^4.2.0",
32
32
  "mocha": "^7.1.1",
33
- "nyc": "^15.0.1",
33
+ "nyc": "^15.1.0",
34
34
  "rimraf": "^3.0.2",
35
35
  "ts-node": "^8.8.2",
36
- "tslint": "^6.1.1",
37
36
  "tslint-eslint-rules": "^5.4.0",
38
- "typescript": "^3.8.3"
37
+ "typescript": "^3.8.3",
38
+ "ws": "^8.8.0"
39
39
  },
40
40
  "nyc": {
41
41
  "all": true,
package/src/Addon.cpp CHANGED
@@ -4,18 +4,10 @@
4
4
 
5
5
  void Initialize(Local<Object> exports) {
6
6
  Isolate *isolate = exports->GetIsolate();
7
-
8
- #if NODE_MAJOR_VERSION >= 13
9
- exports->Set(isolate->GetCurrentContext(), String::NewFromUtf8(isolate, "server").ToLocalChecked(),
10
- Namespace<cWS::SERVER>(isolate).object);
11
- exports->Set(isolate->GetCurrentContext(), String::NewFromUtf8(isolate, "client").ToLocalChecked(),
12
- Namespace<cWS::CLIENT>(isolate).object);
13
- #else
14
- exports->Set(String::NewFromUtf8(isolate, "server"),
15
- Namespace<cWS::SERVER>(isolate).object);
16
- exports->Set(String::NewFromUtf8(isolate, "client"),
17
- Namespace<cWS::CLIENT>(isolate).object);
18
- #endif
7
+ exports->Set(isolate->GetCurrentContext(), String::NewFromUtf8(isolate, "server").ToLocalChecked(),
8
+ Namespace<cWS::SERVER>(isolate).object);
9
+ exports->Set(isolate->GetCurrentContext(), String::NewFromUtf8(isolate, "client").ToLocalChecked(),
10
+ Namespace<cWS::CLIENT>(isolate).object);
19
11
 
20
12
  NODE_SET_METHOD(exports, "getSSLContext", getSSLContext);
21
13
  NODE_SET_METHOD(exports, "getBufferedAmount", getBufferedAmount<cWS::SERVER>);
package/src/Addon.h CHANGED
@@ -1,3 +1,5 @@
1
+ #define NODE_API_DEFAULT_MODULE_API_VERSION 115
2
+
1
3
  #include <node.h>
2
4
  #include <node_buffer.h>
3
5
  #include <openssl/bio.h>
@@ -5,23 +7,10 @@
5
7
  #include <uv.h>
6
8
  #include <cstring>
7
9
 
10
+ // TODO: remove below
8
11
  #if NODE_MAJOR_VERSION>=10
9
12
  #define NODE_WANT_INTERNALS 1
10
13
 
11
- #if NODE_MAJOR_VERSION==10
12
- #include "headers/10/tls_wrap.h"
13
- #endif
14
-
15
- #if NODE_MAJOR_VERSION==12
16
- #include "headers/12/tls_wrap.h"
17
- #include "headers/12/base_object-inl.h"
18
- #endif
19
-
20
- #if NODE_MAJOR_VERSION==13
21
- #include "headers/13/tls_wrap.h"
22
- #include "headers/13/base_object-inl.h"
23
- #endif
24
-
25
14
  #if NODE_MAJOR_VERSION==14
26
15
  #include "headers/14/tls_wrap.h"
27
16
  #include "headers/14/base_object-inl.h"
@@ -37,8 +26,15 @@
37
26
  #include "headers/18/base_object-inl.h"
38
27
  #endif
39
28
 
29
+ #if NODE_MAJOR_VERSION==20
30
+ #include "headers/20/crypto/crypto_tls.h"
31
+ #include "headers/20/base_object-inl.h"
32
+ #endif
33
+
34
+ #include <tcp_wrap.h>
35
+
40
36
  using BaseObject = node::BaseObject;
41
- #if NODE_MAJOR_VERSION==16 || NODE_MAJOR_VERSION==18
37
+ #if NODE_MAJOR_VERSION==16 || NODE_MAJOR_VERSION==18 || NODE_MAJOR_VERSION==20
42
38
  using TLSWrap = node::crypto::TLSWrap;
43
39
  #else
44
40
  using TLSWrap = node::TLSWrap;
@@ -59,32 +55,15 @@ public:
59
55
 
60
56
  // Fix windows not resolved symbol issue
61
57
  #if defined(_MSC_VER)
62
- #if NODE_MAJOR_VERSION>10
63
- [[noreturn]] void node::Assert(const node::AssertionInfo& info) {
64
- char name[1024];
65
- char title[1024] = "Node.js";
66
- uv_get_process_title(title, sizeof(title));
67
- snprintf(name, sizeof(name), "%s[%d]", title, uv_os_getpid());
68
- fprintf(stderr, "%s: Assertion failed.\n", name);
69
- fflush(stderr);
70
- ABORT_NO_BACKTRACE();
71
- }
72
- #else
73
- [[noreturn]] void node::Assert(const char* const (*args)[4]) {
74
- auto filename = (*args)[0];
75
- auto linenum = (*args)[1];
76
- auto message = (*args)[2];
77
- auto function = (*args)[3];
78
- char name[1024];
79
- char title[1024] = "Node.js";
80
- uv_get_process_title(title, sizeof(title));
81
- snprintf(name, sizeof(name), "%s[%d]", title, uv_os_getpid());
82
- fprintf(stderr, "%s: %s:%s:%s%s Assertion `%s' failed.\n",
83
- name, filename, linenum, function, *function ? ":" : "", message);
84
- fflush(stderr);
85
- ABORT_NO_BACKTRACE();
86
- }
87
- #endif
58
+ [[noreturn]] void node::Assert(const node::AssertionInfo& info) {
59
+ char name[1024];
60
+ char title[1024] = "Node.js";
61
+ uv_get_process_title(title, sizeof(title));
62
+ snprintf(name, sizeof(name), "%s[%d]", title, uv_os_getpid());
63
+ fprintf(stderr, "%s: Assertion failed.\n", name);
64
+ fflush(stderr);
65
+ ABORT_NO_BACKTRACE();
66
+ }
88
67
  #endif
89
68
 
90
69
  #undef NODE_WANT_INTERNALS
@@ -130,10 +109,10 @@ class NativeString {
130
109
  } else if (value->IsTypedArray()) {
131
110
  Local<ArrayBufferView> arrayBufferView =
132
111
  Local<ArrayBufferView>::Cast(value);
133
- #if NODE_MAJOR_VERSION == 18
134
- std::shared_ptr<v8::BackingStore> contents = arrayBufferView->Buffer()->GetBackingStore();
112
+ #if NODE_MAJOR_VERSION >= 18
135
113
  length = arrayBufferView->ByteLength();
136
- data = (char *)contents->Data();
114
+ auto store = arrayBufferView->Buffer()->GetBackingStore();
115
+ data = reinterpret_cast<char*>(store->Data());
137
116
  #else
138
117
  ArrayBuffer::Contents contents = arrayBufferView->Buffer()->GetContents();
139
118
  length = contents.ByteLength();
@@ -141,10 +120,10 @@ class NativeString {
141
120
  #endif
142
121
  } else if (value->IsArrayBuffer()) {
143
122
  Local<ArrayBuffer> arrayBuffer = Local<ArrayBuffer>::Cast(value);
144
- #if NODE_MAJOR_VERSION == 18
145
- std::shared_ptr<v8::BackingStore> contents = arrayBuffer->GetBackingStore();
123
+ #if NODE_MAJOR_VERSION >= 18
146
124
  length = arrayBuffer->ByteLength();
147
- data = (char *)contents->Data();
125
+ auto store = arrayBuffer->GetBackingStore();
126
+ data = reinterpret_cast<char*>(store->Data());
148
127
  #else
149
128
  ArrayBuffer::Contents contents = arrayBuffer->GetContents();
150
129
  length = contents.ByteLength();
@@ -212,11 +191,7 @@ inline Local<Value> wrapMessage(const char *message, size_t length,
212
191
  return (Local<Value>)v8::ArrayBuffer::New(isolate, std::move(backing));
213
192
  }
214
193
 
215
- #if NODE_MAJOR_VERSION >= 13
216
- return (Local<Value>)String::NewFromUtf8(isolate, message, NewStringType::kNormal, length).ToLocalChecked();
217
- #else
218
- return (Local<Value>)String::NewFromUtf8(isolate, message, String::kNormalString, length);
219
- #endif
194
+ return (Local<Value>)String::NewFromUtf8(isolate, message, NewStringType::kNormal, length).ToLocalChecked();
220
195
  }
221
196
 
222
197
  template <bool isServer>
@@ -271,28 +246,26 @@ void getAddress(const FunctionCallbackInfo<Value> &args) {
271
246
  unwrapSocket<isServer>(args[0].As<External>())->getAddress();
272
247
  Local<Array> array = Array::New(args.GetIsolate(), 3);
273
248
 
274
- #if NODE_MAJOR_VERSION >= 13
275
- array->Set(args.GetIsolate()->GetCurrentContext(), 0, Integer::New(args.GetIsolate(), address.port));
276
- array->Set(args.GetIsolate()->GetCurrentContext(), 1, String::NewFromUtf8(args.GetIsolate(), address.address).ToLocalChecked());
277
- array->Set(args.GetIsolate()->GetCurrentContext(), 2, String::NewFromUtf8(args.GetIsolate(), address.family).ToLocalChecked());
278
- #else
279
- array->Set(0, Integer::New(args.GetIsolate(), address.port));
280
- array->Set(1, String::NewFromUtf8(args.GetIsolate(), address.address));
281
- array->Set(2, String::NewFromUtf8(args.GetIsolate(), address.family));
282
- #endif
249
+ array->Set(args.GetIsolate()->GetCurrentContext(), 0, Integer::New(args.GetIsolate(), address.port));
250
+ array->Set(args.GetIsolate()->GetCurrentContext(), 1, String::NewFromUtf8(args.GetIsolate(), address.address).ToLocalChecked());
251
+ array->Set(args.GetIsolate()->GetCurrentContext(), 2, String::NewFromUtf8(args.GetIsolate(), address.family).ToLocalChecked());
283
252
 
284
253
  args.GetReturnValue().Set(array);
285
254
  }
286
255
 
287
256
  uv_handle_t *getTcpHandle(void *handleWrap) {
288
- volatile char *memory = (volatile char *)handleWrap;
289
- for (volatile uv_handle_t *tcpHandle = (volatile uv_handle_t *)memory;
290
- tcpHandle->type != UV_TCP || tcpHandle->data != handleWrap ||
291
- tcpHandle->loop != uv_default_loop();
292
- tcpHandle = (volatile uv_handle_t *)memory) {
293
- memory++;
294
- }
295
- return (uv_handle_t *)memory;
257
+ // volatile char *memory = (volatile char *)handleWrap;
258
+ // for (volatile uv_handle_t *tcpHandle = (volatile uv_handle_t *)memory;
259
+ // tcpHandle->type != UV_TCP || tcpHandle->data != handleWrap ||
260
+ // tcpHandle->loop != uv_default_loop();
261
+ // tcpHandle = (volatile uv_handle_t *)memory) {
262
+ // memory++;
263
+ // }
264
+ // return (uv_handle_t *)memory;
265
+
266
+ // TODO? above is the old @clusterws/cWS code. Is the above needed for TLS handles?
267
+ // Below is the proper way to get the handle in a type-safe way.
268
+ return static_cast<node::TCPWrap*>(handleWrap)->GetHandle();
296
269
  }
297
270
 
298
271
  struct SendCallbackData {
@@ -372,6 +345,10 @@ void upgrade(const FunctionCallbackInfo<Value> &args) {
372
345
  delete ticket;
373
346
  }
374
347
 
348
+ constexpr uint16_t kDefaultCppGCEmebdderID = 0x90de;
349
+ // https://github.com/nodejs/node/blob/22f383dcd529d6bf790856db614a35fea78e825f/src/env.cc#L506
350
+
351
+
375
352
  void transfer(const FunctionCallbackInfo<Value> &args) {
376
353
  // (_handle.fd OR _handle), SSL
377
354
  uv_handle_t *handle = nullptr;
@@ -379,9 +356,11 @@ void transfer(const FunctionCallbackInfo<Value> &args) {
379
356
  if (args[0]->IsObject()) {
380
357
  Isolate* isolate = args.GetIsolate();
381
358
  Local<Context> context = isolate->GetCurrentContext();
359
+ auto arg_0 = args[0]->ToObject(context).ToLocalChecked();
360
+ auto field_to_get = arg_0->InternalFieldCount() > 3 ? 1 : 0;
382
361
 
383
362
  uv_fileno((handle = getTcpHandle(
384
- args[0]->ToObject(context).ToLocalChecked()->GetAlignedPointerFromInternalField(0))),
363
+ arg_0->GetAlignedPointerFromInternalField(field_to_get))),
385
364
  (uv_os_fd_t *)&ticket->fd);
386
365
  } else {
387
366
  ticket->fd = args[0].As<Integer>()->Value();
@@ -637,13 +616,8 @@ void getSSLContext(const FunctionCallbackInfo<Value> &args) {
637
616
  Isolate* isolate = args.GetIsolate();
638
617
  if(args.Length() < 1 || !args[0]->IsObject()){
639
618
 
640
- #if NODE_MAJOR_VERSION >= 13
641
- isolate->ThrowException(Exception::TypeError(
642
- String::NewFromUtf8(isolate, "Error: One object expected").ToLocalChecked()));
643
- #else
644
- isolate->ThrowException(Exception::TypeError(
645
- String::NewFromUtf8(isolate, "Error: One object expected")));
646
- #endif
619
+ isolate->ThrowException(Exception::TypeError(
620
+ String::NewFromUtf8(isolate, "Error: One object expected").ToLocalChecked()));
647
621
 
648
622
  return;
649
623
  }
@@ -651,14 +625,9 @@ void getSSLContext(const FunctionCallbackInfo<Value> &args) {
651
625
  Local<Context> context = isolate->GetCurrentContext();
652
626
  Local<Object> obj = args[0]->ToObject(context).ToLocalChecked();
653
627
 
654
- #if NODE_MAJOR_VERSION < 10
655
- Local<Value> ext = obj->Get(String::NewFromUtf8(isolate, "_external"));
656
- args.GetReturnValue().Set(ext);
657
- #else
658
- TLSWrapSSLGetter* tw;
659
- ASSIGN_OR_RETURN_UNWRAP(&tw, obj);
660
- tw->setSSL(args);
661
- #endif
628
+ TLSWrapSSLGetter* tw;
629
+ ASSIGN_OR_RETURN_UNWRAP(&tw, obj);
630
+ tw->setSSL(args);
662
631
  }
663
632
 
664
633
  void setNoop(const FunctionCallbackInfo<Value> &args) {
@@ -705,10 +674,6 @@ struct Namespace {
705
674
  NODE_SET_METHOD(group, "terminate", terminateGroup<isServer>);
706
675
  NODE_SET_METHOD(group, "broadcast", broadcast<isServer>);
707
676
 
708
- #if NODE_MAJOR_VERSION >= 13
709
- object->Set(isolate->GetCurrentContext(), String::NewFromUtf8(isolate, "group").ToLocalChecked(), group);
710
- #else
711
- object->Set(String::NewFromUtf8(isolate, "group"), group);
712
- #endif
677
+ object->Set(isolate->GetCurrentContext(), String::NewFromUtf8(isolate, "group").ToLocalChecked(), group);
713
678
  }
714
679
  };
package/src/Socket.h CHANGED
@@ -407,6 +407,7 @@ protected:
407
407
  }
408
408
  }
409
409
  } else {
410
+ printf("Enqueue\n");
410
411
  Queue::Message *messagePtr = allocMessage(estimatedLength - sizeof(Queue::Message));
411
412
  messagePtr->length = T::transform(message, (char *) messagePtr->data, length, transformData);
412
413
  messagePtr->callback = callback;
package/src/cSNode.cpp CHANGED
@@ -56,14 +56,9 @@ Node::Node(int recvLength, int prePadding, int postPadding, bool useDefaultLoop)
56
56
  nodeData->preAlloc[i] = nullptr;
57
57
  }
58
58
 
59
- #if (NODE_MAJOR_VERSION>=10)
60
- nodeData->clientContext = SSL_CTX_new(TLS_method());
61
- SSL_CTX_set_min_proto_version(nodeData->clientContext, TLS1_VERSION);
62
- SSL_CTX_set_max_proto_version(nodeData->clientContext, TLS1_2_VERSION);
63
- #else
64
- nodeData->clientContext = SSL_CTX_new(SSLv23_client_method());
65
- SSL_CTX_set_options(nodeData->clientContext, SSL_OP_NO_SSLv3);
66
- #endif
59
+ nodeData->clientContext = SSL_CTX_new(TLS_method());
60
+ SSL_CTX_set_min_proto_version(nodeData->clientContext, TLS1_VERSION);
61
+ SSL_CTX_set_max_proto_version(nodeData->clientContext, TLS1_2_VERSION);
67
62
  }
68
63
 
69
64
  void Node::run() {
@@ -0,0 +1,6 @@
1
+ // This is an auto generated file, please do not edit.
2
+ // Refer to tools/update-acorn.sh
3
+ #ifndef SRC_ACORN_VERSION_H_
4
+ #define SRC_ACORN_VERSION_H_
5
+ #define ACORN_VERSION "8.10.0"
6
+ #endif // SRC_ACORN_VERSION_H_
@@ -0,0 +1,243 @@
1
+ #ifndef SRC_ALIASED_BUFFER_INL_H_
2
+ #define SRC_ALIASED_BUFFER_INL_H_
3
+
4
+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
+
6
+ #include "aliased_buffer.h"
7
+ #include "util-inl.h"
8
+
9
+ namespace node {
10
+
11
+ typedef size_t AliasedBufferIndex;
12
+
13
+ template <typename NativeT, typename V8T>
14
+ AliasedBufferBase<NativeT, V8T>::AliasedBufferBase(
15
+ v8::Isolate* isolate, const size_t count, const AliasedBufferIndex* index)
16
+ : isolate_(isolate), count_(count), byte_offset_(0), index_(index) {
17
+ CHECK_GT(count, 0);
18
+ if (index != nullptr) {
19
+ // Will be deserialized later.
20
+ return;
21
+ }
22
+ const v8::HandleScope handle_scope(isolate_);
23
+ const size_t size_in_bytes =
24
+ MultiplyWithOverflowCheck(sizeof(NativeT), count);
25
+
26
+ // allocate v8 ArrayBuffer
27
+ v8::Local<v8::ArrayBuffer> ab = v8::ArrayBuffer::New(isolate_, size_in_bytes);
28
+ buffer_ = static_cast<NativeT*>(ab->Data());
29
+
30
+ // allocate v8 TypedArray
31
+ v8::Local<V8T> js_array = V8T::New(ab, byte_offset_, count);
32
+ js_array_ = v8::Global<V8T>(isolate, js_array);
33
+ }
34
+
35
+ template <typename NativeT, typename V8T>
36
+ AliasedBufferBase<NativeT, V8T>::AliasedBufferBase(
37
+ v8::Isolate* isolate,
38
+ const size_t byte_offset,
39
+ const size_t count,
40
+ const AliasedBufferBase<uint8_t, v8::Uint8Array>& backing_buffer,
41
+ const AliasedBufferIndex* index)
42
+ : isolate_(isolate),
43
+ count_(count),
44
+ byte_offset_(byte_offset),
45
+ index_(index) {
46
+ if (index != nullptr) {
47
+ // Will be deserialized later.
48
+ return;
49
+ }
50
+ const v8::HandleScope handle_scope(isolate_);
51
+ v8::Local<v8::ArrayBuffer> ab = backing_buffer.GetArrayBuffer();
52
+
53
+ // validate that the byte_offset is aligned with sizeof(NativeT)
54
+ CHECK_EQ(byte_offset & (sizeof(NativeT) - 1), 0);
55
+ // validate this fits inside the backing buffer
56
+ CHECK_LE(MultiplyWithOverflowCheck(sizeof(NativeT), count),
57
+ ab->ByteLength() - byte_offset);
58
+
59
+ buffer_ = reinterpret_cast<NativeT*>(
60
+ const_cast<uint8_t*>(backing_buffer.GetNativeBuffer() + byte_offset));
61
+
62
+ v8::Local<V8T> js_array = V8T::New(ab, byte_offset, count);
63
+ js_array_ = v8::Global<V8T>(isolate, js_array);
64
+ }
65
+
66
+ template <typename NativeT, typename V8T>
67
+ AliasedBufferBase<NativeT, V8T>::AliasedBufferBase(
68
+ const AliasedBufferBase& that)
69
+ : isolate_(that.isolate_),
70
+ count_(that.count_),
71
+ byte_offset_(that.byte_offset_),
72
+ buffer_(that.buffer_) {
73
+ js_array_ = v8::Global<V8T>(that.isolate_, that.GetJSArray());
74
+ DCHECK(is_valid());
75
+ }
76
+
77
+ template <typename NativeT, typename V8T>
78
+ AliasedBufferIndex AliasedBufferBase<NativeT, V8T>::Serialize(
79
+ v8::Local<v8::Context> context, v8::SnapshotCreator* creator) {
80
+ DCHECK(is_valid());
81
+ return creator->AddData(context, GetJSArray());
82
+ }
83
+
84
+ template <typename NativeT, typename V8T>
85
+ inline void AliasedBufferBase<NativeT, V8T>::Deserialize(
86
+ v8::Local<v8::Context> context) {
87
+ DCHECK_NOT_NULL(index_);
88
+ v8::Local<V8T> arr =
89
+ context->GetDataFromSnapshotOnce<V8T>(*index_).ToLocalChecked();
90
+ // These may not hold true for AliasedBuffers that have grown, so should
91
+ // be removed when we expand the snapshot support.
92
+ DCHECK_EQ(count_, arr->Length());
93
+ DCHECK_EQ(byte_offset_, arr->ByteOffset());
94
+ uint8_t* raw = static_cast<uint8_t*>(arr->Buffer()->Data());
95
+ buffer_ = reinterpret_cast<NativeT*>(raw + byte_offset_);
96
+ js_array_.Reset(isolate_, arr);
97
+ index_ = nullptr;
98
+ }
99
+
100
+ template <typename NativeT, typename V8T>
101
+ AliasedBufferBase<NativeT, V8T>& AliasedBufferBase<NativeT, V8T>::operator=(
102
+ AliasedBufferBase<NativeT, V8T>&& that) noexcept {
103
+ DCHECK(is_valid());
104
+ this->~AliasedBufferBase();
105
+ isolate_ = that.isolate_;
106
+ count_ = that.count_;
107
+ byte_offset_ = that.byte_offset_;
108
+ buffer_ = that.buffer_;
109
+
110
+ js_array_.Reset(isolate_, that.js_array_.Get(isolate_));
111
+
112
+ that.buffer_ = nullptr;
113
+ that.js_array_.Reset();
114
+ return *this;
115
+ }
116
+
117
+ template <typename NativeT, typename V8T>
118
+ v8::Local<V8T> AliasedBufferBase<NativeT, V8T>::GetJSArray() const {
119
+ DCHECK(is_valid());
120
+ return js_array_.Get(isolate_);
121
+ }
122
+
123
+ template <typename NativeT, typename V8T>
124
+ void AliasedBufferBase<NativeT, V8T>::Release() {
125
+ DCHECK_NULL(index_);
126
+ js_array_.Reset();
127
+ }
128
+
129
+ template <typename NativeT, typename V8T>
130
+ inline void AliasedBufferBase<NativeT, V8T>::MakeWeak() {
131
+ DCHECK(is_valid());
132
+ js_array_.SetWeak();
133
+ }
134
+
135
+ template <typename NativeT, typename V8T>
136
+ v8::Local<v8::ArrayBuffer> AliasedBufferBase<NativeT, V8T>::GetArrayBuffer()
137
+ const {
138
+ return GetJSArray()->Buffer();
139
+ }
140
+
141
+ template <typename NativeT, typename V8T>
142
+ inline const NativeT* AliasedBufferBase<NativeT, V8T>::GetNativeBuffer() const {
143
+ DCHECK(is_valid());
144
+ return buffer_;
145
+ }
146
+
147
+ template <typename NativeT, typename V8T>
148
+ inline const NativeT* AliasedBufferBase<NativeT, V8T>::operator*() const {
149
+ return GetNativeBuffer();
150
+ }
151
+
152
+ template <typename NativeT, typename V8T>
153
+ inline void AliasedBufferBase<NativeT, V8T>::SetValue(const size_t index,
154
+ NativeT value) {
155
+ DCHECK_LT(index, count_);
156
+ DCHECK(is_valid());
157
+ buffer_[index] = value;
158
+ }
159
+
160
+ template <typename NativeT, typename V8T>
161
+ inline const NativeT AliasedBufferBase<NativeT, V8T>::GetValue(
162
+ const size_t index) const {
163
+ DCHECK(is_valid());
164
+ DCHECK_LT(index, count_);
165
+ return buffer_[index];
166
+ }
167
+
168
+ template <typename NativeT, typename V8T>
169
+ typename AliasedBufferBase<NativeT, V8T>::Reference
170
+ AliasedBufferBase<NativeT, V8T>::operator[](size_t index) {
171
+ DCHECK(is_valid());
172
+ return Reference(this, index);
173
+ }
174
+
175
+ template <typename NativeT, typename V8T>
176
+ NativeT AliasedBufferBase<NativeT, V8T>::operator[](size_t index) const {
177
+ return GetValue(index);
178
+ }
179
+
180
+ template <typename NativeT, typename V8T>
181
+ size_t AliasedBufferBase<NativeT, V8T>::Length() const {
182
+ return count_;
183
+ }
184
+
185
+ template <typename NativeT, typename V8T>
186
+ void AliasedBufferBase<NativeT, V8T>::reserve(size_t new_capacity) {
187
+ DCHECK(is_valid());
188
+ DCHECK_GE(new_capacity, count_);
189
+ DCHECK_EQ(byte_offset_, 0);
190
+ const v8::HandleScope handle_scope(isolate_);
191
+
192
+ const size_t old_size_in_bytes = sizeof(NativeT) * count_;
193
+ const size_t new_size_in_bytes =
194
+ MultiplyWithOverflowCheck(sizeof(NativeT), new_capacity);
195
+
196
+ // allocate v8 new ArrayBuffer
197
+ v8::Local<v8::ArrayBuffer> ab =
198
+ v8::ArrayBuffer::New(isolate_, new_size_in_bytes);
199
+
200
+ // allocate new native buffer
201
+ NativeT* new_buffer = static_cast<NativeT*>(ab->Data());
202
+ // copy old content
203
+ memcpy(new_buffer, buffer_, old_size_in_bytes);
204
+
205
+ // allocate v8 TypedArray
206
+ v8::Local<V8T> js_array = V8T::New(ab, byte_offset_, new_capacity);
207
+
208
+ // move over old v8 TypedArray
209
+ js_array_ = std::move(v8::Global<V8T>(isolate_, js_array));
210
+
211
+ buffer_ = new_buffer;
212
+ count_ = new_capacity;
213
+ }
214
+
215
+ template <typename NativeT, typename V8T>
216
+ inline bool AliasedBufferBase<NativeT, V8T>::is_valid() const {
217
+ return index_ == nullptr && !js_array_.IsEmpty();
218
+ }
219
+
220
+ template <typename NativeT, typename V8T>
221
+ inline size_t AliasedBufferBase<NativeT, V8T>::SelfSize() const {
222
+ return sizeof(*this);
223
+ }
224
+
225
+ #define VM(NativeT, V8T) \
226
+ template <> \
227
+ inline const char* AliasedBufferBase<NativeT, v8::V8T>::MemoryInfoName() \
228
+ const { \
229
+ return "Aliased" #V8T; \
230
+ } \
231
+ template <> \
232
+ inline void AliasedBufferBase<NativeT, v8::V8T>::MemoryInfo( \
233
+ node::MemoryTracker* tracker) const { \
234
+ tracker->TrackField("js_array", js_array_); \
235
+ }
236
+ ALIASED_BUFFER_LIST(VM)
237
+ #undef VM
238
+
239
+ } // namespace node
240
+
241
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
242
+
243
+ #endif // SRC_ALIASED_BUFFER_INL_H_