@encharm/cws 4.5.3 → 4.8.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 (305) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/CLAUDE.md +83 -0
  3. package/README.md +20 -4
  4. package/binding.gyp +8 -2
  5. package/dist/bindings/cws_darwin_arm64_node115.node +0 -0
  6. package/dist/bindings/cws_darwin_arm64_node127.node +0 -0
  7. package/dist/bindings/cws_darwin_arm64_node137.node +0 -0
  8. package/dist/bindings/cws_darwin_arm64_node147.node +0 -0
  9. package/dist/bindings/cws_linux_arm64_node115.node +0 -0
  10. package/dist/bindings/cws_linux_arm64_node127.node +0 -0
  11. package/dist/bindings/cws_linux_arm64_node137.node +0 -0
  12. package/dist/bindings/cws_linux_arm64_node147.node +0 -0
  13. package/dist/bindings/cws_linux_x64_node115.node +0 -0
  14. package/dist/bindings/cws_linux_x64_node127.node +0 -0
  15. package/dist/bindings/cws_linux_x64_node137.node +0 -0
  16. package/dist/bindings/cws_linux_x64_node147.node +0 -0
  17. package/dist/bindings/cws_win32_x64_node115.node +0 -0
  18. package/dist/bindings/cws_win32_x64_node127.node +0 -0
  19. package/dist/bindings/cws_win32_x64_node137.node +0 -0
  20. package/dist/bindings/cws_win32_x64_node147.node +0 -0
  21. package/dist/client.d.ts +1 -0
  22. package/dist/client.js +15 -1
  23. package/dist/index.d.ts +6 -1
  24. package/dist/index.js +2 -0
  25. package/dist/server.d.ts +1 -0
  26. package/dist/server.js +16 -2
  27. package/dist/shared.d.ts +1 -0
  28. package/dist/shared.js +3 -2
  29. package/package.json +1 -1
  30. package/src/Addon.cpp +4 -1
  31. package/src/Addon.h +80 -15
  32. package/src/Extensions.cpp +7 -1
  33. package/src/Extensions.h +2 -1
  34. package/src/Group.cpp +1 -1
  35. package/src/Group.h +4 -1
  36. package/src/HTTPSocket.cpp +1 -1
  37. package/src/Hub.cpp +11 -76
  38. package/src/Hub.h +12 -10
  39. package/src/Networking.h +11 -0
  40. package/src/Socket.h +201 -6
  41. package/src/WebSocket.cpp +8 -5
  42. package/src/Zlib.cpp +138 -0
  43. package/src/Zlib.h +38 -0
  44. package/src/cSNode.cpp +2 -0
  45. package/src/cSNode.h +4 -0
  46. package/src/headers/26/acorn_version.h +6 -0
  47. package/src/headers/26/aliased_buffer-inl.h +264 -0
  48. package/src/headers/26/aliased_buffer.h +205 -0
  49. package/src/headers/26/aliased_struct-inl.h +143 -0
  50. package/src/headers/26/aliased_struct.h +248 -0
  51. package/src/headers/26/amaro_version.h +6 -0
  52. package/src/headers/26/async_context_frame.h +33 -0
  53. package/src/headers/26/async_wrap-inl.h +123 -0
  54. package/src/headers/26/async_wrap.h +254 -0
  55. package/src/headers/26/base_object-inl.h +333 -0
  56. package/src/headers/26/base_object.h +339 -0
  57. package/src/headers/26/base_object_types.h +76 -0
  58. package/src/headers/26/blob_serializer_deserializer-inl.h +385 -0
  59. package/src/headers/26/blob_serializer_deserializer.h +142 -0
  60. package/src/headers/26/builtin_info.h +57 -0
  61. package/src/headers/26/callback_queue-inl.h +97 -0
  62. package/src/headers/26/callback_queue.h +79 -0
  63. package/src/headers/26/cares_wrap.h +475 -0
  64. package/src/headers/26/cleanup_queue-inl.h +36 -0
  65. package/src/headers/26/cleanup_queue.h +79 -0
  66. package/src/headers/26/compile_cache.h +134 -0
  67. package/src/headers/26/connect_wrap.h +26 -0
  68. package/src/headers/26/connection_wrap.h +30 -0
  69. package/src/headers/26/cppgc_helpers-inl.h +69 -0
  70. package/src/headers/26/cppgc_helpers.h +162 -0
  71. package/src/headers/26/crypto/crypto_aes.h +107 -0
  72. package/src/headers/26/crypto/crypto_argon2.h +88 -0
  73. package/src/headers/26/crypto/crypto_bio.h +193 -0
  74. package/src/headers/26/crypto/crypto_chacha20_poly1305.h +62 -0
  75. package/src/headers/26/crypto/crypto_cipher.h +291 -0
  76. package/src/headers/26/crypto/crypto_common.h +48 -0
  77. package/src/headers/26/crypto/crypto_context.h +219 -0
  78. package/src/headers/26/crypto/crypto_dh.h +104 -0
  79. package/src/headers/26/crypto/crypto_dsa.h +50 -0
  80. package/src/headers/26/crypto/crypto_ec.h +102 -0
  81. package/src/headers/26/crypto/crypto_hash.h +157 -0
  82. package/src/headers/26/crypto/crypto_hkdf.h +62 -0
  83. package/src/headers/26/crypto/crypto_hmac.h +92 -0
  84. package/src/headers/26/crypto/crypto_kem.h +131 -0
  85. package/src/headers/26/crypto/crypto_keygen.h +382 -0
  86. package/src/headers/26/crypto/crypto_keys.h +366 -0
  87. package/src/headers/26/crypto/crypto_kmac.h +79 -0
  88. package/src/headers/26/crypto/crypto_pbkdf2.h +76 -0
  89. package/src/headers/26/crypto/crypto_pqc.h +39 -0
  90. package/src/headers/26/crypto/crypto_random.h +127 -0
  91. package/src/headers/26/crypto/crypto_rsa.h +108 -0
  92. package/src/headers/26/crypto/crypto_scrypt.h +85 -0
  93. package/src/headers/26/crypto/crypto_sig.h +159 -0
  94. package/src/headers/26/crypto/crypto_spkac.h +21 -0
  95. package/src/headers/26/crypto/crypto_timing.h +20 -0
  96. package/src/headers/26/crypto/crypto_tls.h +342 -0
  97. package/src/headers/26/crypto/crypto_turboshake.h +105 -0
  98. package/src/headers/26/crypto/crypto_util.h +775 -0
  99. package/src/headers/26/crypto/crypto_x509.h +140 -0
  100. package/src/headers/26/dataqueue/queue.h +311 -0
  101. package/src/headers/26/debug_utils-inl.h +291 -0
  102. package/src/headers/26/debug_utils.h +200 -0
  103. package/src/headers/26/diagnosticfilename-inl.h +33 -0
  104. package/src/headers/26/embedded_data.h +17 -0
  105. package/src/headers/26/encoding_binding.h +59 -0
  106. package/src/headers/26/env-inl.h +956 -0
  107. package/src/headers/26/env.h +1294 -0
  108. package/src/headers/26/env_properties.h +562 -0
  109. package/src/headers/26/ffi/data.h +30 -0
  110. package/src/headers/26/ffi/fast.h +96 -0
  111. package/src/headers/26/ffi/jit_memory.h +26 -0
  112. package/src/headers/26/ffi/types.h +99 -0
  113. package/src/headers/26/handle_wrap.h +123 -0
  114. package/src/headers/26/histogram-inl.h +211 -0
  115. package/src/headers/26/histogram.h +474 -0
  116. package/src/headers/26/inspector/dom_storage_agent.h +68 -0
  117. package/src/headers/26/inspector/inspector_object_utils.h +38 -0
  118. package/src/headers/26/inspector/io_agent.h +30 -0
  119. package/src/headers/26/inspector/main_thread_interface.h +116 -0
  120. package/src/headers/26/inspector/network_agent.h +110 -0
  121. package/src/headers/26/inspector/network_inspector.h +45 -0
  122. package/src/headers/26/inspector/network_requests_buffer.h +195 -0
  123. package/src/headers/26/inspector/network_resource_manager.h +29 -0
  124. package/src/headers/26/inspector/node_json.h +24 -0
  125. package/src/headers/26/inspector/node_string.h +101 -0
  126. package/src/headers/26/inspector/notification_emitter.h +38 -0
  127. package/src/headers/26/inspector/protocol_helper.h +27 -0
  128. package/src/headers/26/inspector/runtime_agent.h +41 -0
  129. package/src/headers/26/inspector/storage_agent.h +33 -0
  130. package/src/headers/26/inspector/target_agent.h +59 -0
  131. package/src/headers/26/inspector/target_manager.h +70 -0
  132. package/src/headers/26/inspector/tracing_agent.h +43 -0
  133. package/src/headers/26/inspector/worker_agent.h +40 -0
  134. package/src/headers/26/inspector/worker_inspector.h +124 -0
  135. package/src/headers/26/inspector_agent.h +168 -0
  136. package/src/headers/26/inspector_io.h +78 -0
  137. package/src/headers/26/inspector_profiler.h +149 -0
  138. package/src/headers/26/inspector_socket.h +60 -0
  139. package/src/headers/26/inspector_socket_server.h +110 -0
  140. package/src/headers/26/js_native_api.h +634 -0
  141. package/src/headers/26/js_native_api_types.h +244 -0
  142. package/src/headers/26/js_native_api_v8.h +485 -0
  143. package/src/headers/26/js_native_api_v8_internals.h +45 -0
  144. package/src/headers/26/js_stream.h +57 -0
  145. package/src/headers/26/json_utils.h +172 -0
  146. package/src/headers/26/large_pages/node_large_page.h +34 -0
  147. package/src/headers/26/lru_cache-inl.h +69 -0
  148. package/src/headers/26/memory_tracker-inl.h +461 -0
  149. package/src/headers/26/memory_tracker.h +341 -0
  150. package/src/headers/26/module_wrap.h +231 -0
  151. package/src/headers/26/ncrypto.h +2008 -0
  152. package/src/headers/26/node.h +1693 -0
  153. package/src/headers/26/node_api.h +265 -0
  154. package/src/headers/26/node_api_internals.h +48 -0
  155. package/src/headers/26/node_api_types.h +58 -0
  156. package/src/headers/26/node_binding.h +170 -0
  157. package/src/headers/26/node_blob.h +160 -0
  158. package/src/headers/26/node_bob-inl.h +36 -0
  159. package/src/headers/26/node_bob.h +107 -0
  160. package/src/headers/26/node_buffer.h +92 -0
  161. package/src/headers/26/node_builtins.h +239 -0
  162. package/src/headers/26/node_concepts.h +46 -0
  163. package/src/headers/26/node_config_file.h +77 -0
  164. package/src/headers/26/node_constants.h +82 -0
  165. package/src/headers/26/node_context_data.h +171 -0
  166. package/src/headers/26/node_contextify.h +261 -0
  167. package/src/headers/26/node_crypto.h +66 -0
  168. package/src/headers/26/node_debug.h +30 -0
  169. package/src/headers/26/node_diagnostics_channel.h +121 -0
  170. package/src/headers/26/node_dir.h +52 -0
  171. package/src/headers/26/node_dotenv.h +45 -0
  172. package/src/headers/26/node_errors.h +378 -0
  173. package/src/headers/26/node_exit_code.h +54 -0
  174. package/src/headers/26/node_external_reference.h +171 -0
  175. package/src/headers/26/node_ffi.h +212 -0
  176. package/src/headers/26/node_file-inl.h +421 -0
  177. package/src/headers/26/node_file.h +561 -0
  178. package/src/headers/26/node_file_utils.h +39 -0
  179. package/src/headers/26/node_hash.h +212 -0
  180. package/src/headers/26/node_http2.h +1202 -0
  181. package/src/headers/26/node_http2_state.h +159 -0
  182. package/src/headers/26/node_http_common-inl.h +199 -0
  183. package/src/headers/26/node_http_common.h +535 -0
  184. package/src/headers/26/node_i18n.h +132 -0
  185. package/src/headers/26/node_internals.h +485 -0
  186. package/src/headers/26/node_locks.h +184 -0
  187. package/src/headers/26/node_main_instance.h +67 -0
  188. package/src/headers/26/node_mem-inl.h +113 -0
  189. package/src/headers/26/node_mem.h +45 -0
  190. package/src/headers/26/node_messaging.h +389 -0
  191. package/src/headers/26/node_metadata.h +172 -0
  192. package/src/headers/26/node_modules.h +102 -0
  193. package/src/headers/26/node_mutex.h +323 -0
  194. package/src/headers/26/node_object_wrap.h +145 -0
  195. package/src/headers/26/node_options-inl.h +524 -0
  196. package/src/headers/26/node_options.h +710 -0
  197. package/src/headers/26/node_perf.h +167 -0
  198. package/src/headers/26/node_perf_common.h +103 -0
  199. package/src/headers/26/node_platform.h +290 -0
  200. package/src/headers/26/node_process-inl.h +26 -0
  201. package/src/headers/26/node_process.h +112 -0
  202. package/src/headers/26/node_profiling.h +38 -0
  203. package/src/headers/26/node_realm-inl.h +156 -0
  204. package/src/headers/26/node_realm.h +236 -0
  205. package/src/headers/26/node_report.h +43 -0
  206. package/src/headers/26/node_revert.h +82 -0
  207. package/src/headers/26/node_root_certs.h +2937 -0
  208. package/src/headers/26/node_sea.h +101 -0
  209. package/src/headers/26/node_shadow_realm.h +46 -0
  210. package/src/headers/26/node_snapshot_builder.h +57 -0
  211. package/src/headers/26/node_snapshotable.h +167 -0
  212. package/src/headers/26/node_sockaddr-inl.h +248 -0
  213. package/src/headers/26/node_sockaddr.h +459 -0
  214. package/src/headers/26/node_sqlite.h +607 -0
  215. package/src/headers/26/node_stat_watcher.h +73 -0
  216. package/src/headers/26/node_task_runner.h +92 -0
  217. package/src/headers/26/node_threadsafe_cow-inl.h +54 -0
  218. package/src/headers/26/node_threadsafe_cow.h +105 -0
  219. package/src/headers/26/node_union_bytes.h +81 -0
  220. package/src/headers/26/node_url.h +101 -0
  221. package/src/headers/26/node_url_pattern.h +118 -0
  222. package/src/headers/26/node_v8.h +78 -0
  223. package/src/headers/26/node_v8_embedder.h +26 -0
  224. package/src/headers/26/node_v8_platform-inl.h +96 -0
  225. package/src/headers/26/node_version.h +116 -0
  226. package/src/headers/26/node_wasi.h +184 -0
  227. package/src/headers/26/node_wasm_web_api.h +55 -0
  228. package/src/headers/26/node_watchdog.h +164 -0
  229. package/src/headers/26/node_webstorage.h +62 -0
  230. package/src/headers/26/node_worker.h +162 -0
  231. package/src/headers/26/path.h +36 -0
  232. package/src/headers/26/permission/boolean_permission.h +50 -0
  233. package/src/headers/26/permission/fs_permission.h +192 -0
  234. package/src/headers/26/permission/permission.h +155 -0
  235. package/src/headers/26/permission/permission_base.h +79 -0
  236. package/src/headers/26/pipe_wrap.h +80 -0
  237. package/src/headers/26/quic/application.h +279 -0
  238. package/src/headers/26/quic/arena.h +373 -0
  239. package/src/headers/26/quic/bindingdata.h +440 -0
  240. package/src/headers/26/quic/cid.h +127 -0
  241. package/src/headers/26/quic/data.h +358 -0
  242. package/src/headers/26/quic/defs.h +417 -0
  243. package/src/headers/26/quic/endpoint.h +519 -0
  244. package/src/headers/26/quic/guard.h +5 -0
  245. package/src/headers/26/quic/http3.h +25 -0
  246. package/src/headers/26/quic/packet.h +166 -0
  247. package/src/headers/26/quic/preferredaddress.h +72 -0
  248. package/src/headers/26/quic/session.h +770 -0
  249. package/src/headers/26/quic/session_manager.h +107 -0
  250. package/src/headers/26/quic/sessionticket.h +110 -0
  251. package/src/headers/26/quic/streams.h +518 -0
  252. package/src/headers/26/quic/tlscontext.h +353 -0
  253. package/src/headers/26/quic/tokens.h +263 -0
  254. package/src/headers/26/quic/transportparams.h +184 -0
  255. package/src/headers/26/req_wrap-inl.h +175 -0
  256. package/src/headers/26/req_wrap.h +79 -0
  257. package/src/headers/26/spawn_sync.h +243 -0
  258. package/src/headers/26/stream_base-inl.h +170 -0
  259. package/src/headers/26/stream_base.h +487 -0
  260. package/src/headers/26/stream_pipe.h +76 -0
  261. package/src/headers/26/stream_wrap.h +137 -0
  262. package/src/headers/26/string_bytes.h +114 -0
  263. package/src/headers/26/string_decoder-inl.h +31 -0
  264. package/src/headers/26/string_decoder.h +49 -0
  265. package/src/headers/26/tcp_wrap.h +138 -0
  266. package/src/headers/26/threadpoolwork-inl.h +70 -0
  267. package/src/headers/26/timer_wrap-inl.h +32 -0
  268. package/src/headers/26/timer_wrap.h +87 -0
  269. package/src/headers/26/timers.h +70 -0
  270. package/src/headers/26/tracing/agent.h +125 -0
  271. package/src/headers/26/tracing/agent_legacy.h +146 -0
  272. package/src/headers/26/tracing/agent_perfetto.h +145 -0
  273. package/src/headers/26/tracing/node_trace_buffer.h +91 -0
  274. package/src/headers/26/tracing/node_trace_writer.h +79 -0
  275. package/src/headers/26/tracing/trace_event.h +27 -0
  276. package/src/headers/26/tracing/trace_event_helper.h +40 -0
  277. package/src/headers/26/tracing/trace_event_legacy.h +1113 -0
  278. package/src/headers/26/tracing/trace_event_legacy_inl.h +711 -0
  279. package/src/headers/26/tracing/trace_event_perfetto.h +47 -0
  280. package/src/headers/26/tracing/traced_value.h +167 -0
  281. package/src/headers/26/tty_wrap.h +65 -0
  282. package/src/headers/26/udp_wrap.h +231 -0
  283. package/src/headers/26/undici_version.h +6 -0
  284. package/src/headers/26/util-inl.h +788 -0
  285. package/src/headers/26/util.h +1207 -0
  286. package/src/headers/26/v8-cpp-heap-external.h +56 -0
  287. package/src/headers/26/v8-external-memory-accounter.h +60 -0
  288. package/src/headers/26/v8-fast-api-calls.h +784 -0
  289. package/src/headers/26/v8-inspector-protocol.h +13 -0
  290. package/src/headers/26/v8-inspector.h +458 -0
  291. package/src/headers/26/v8-metrics.h +273 -0
  292. package/src/headers/26/v8-trace-categories.h +28 -0
  293. package/src/headers/26/v8-unwinder-state.h +30 -0
  294. package/src/headers/26/v8-util.h +549 -0
  295. package/src/headers/26/v8-value-serializer-version.h +24 -0
  296. package/src/headers/26/v8-version-string.h +38 -0
  297. package/src/headers/26/v8-wasm-trap-handler-posix.h +31 -0
  298. package/src/headers/26/v8-wasm-trap-handler-win.h +28 -0
  299. package/src/headers/26/zlib_version.h +6 -0
  300. package/dist/bindings/cws_darwin_arm64_node115.node.dSYM/Contents/Info.plist +0 -20
  301. package/dist/bindings/cws_darwin_arm64_node115.node.dSYM/Contents/Resources/DWARF/cws_darwin_arm64_node115.node +0 -0
  302. package/dist/bindings/cws_darwin_arm64_node115.node.dSYM/Contents/Resources/Relocations/aarch64/cws_darwin_arm64_node115.node.yml +0 -931
  303. package/dist/bindings/cws_darwin_arm64_node127.node.dSYM/Contents/Info.plist +0 -20
  304. package/dist/bindings/cws_darwin_arm64_node127.node.dSYM/Contents/Resources/DWARF/cws_darwin_arm64_node127.node +0 -0
  305. package/dist/bindings/cws_darwin_arm64_node127.node.dSYM/Contents/Resources/Relocations/aarch64/cws_darwin_arm64_node127.node.yml +0 -931
@@ -0,0 +1,607 @@
1
+ #ifndef SRC_NODE_SQLITE_H_
2
+ #define SRC_NODE_SQLITE_H_
3
+
4
+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
+
6
+ #include "base_object.h"
7
+ #include "lru_cache-inl.h"
8
+ #include "node_mem.h"
9
+ #include "sqlite3.h"
10
+ #include "util.h"
11
+
12
+ #include <algorithm>
13
+ #include <array>
14
+ #include <list>
15
+ #include <map>
16
+ #include <optional>
17
+ #include <string_view>
18
+ #include <unordered_set>
19
+ #include <vector>
20
+
21
+ namespace node {
22
+
23
+ namespace diagnostics_channel {
24
+ class Channel;
25
+ } // namespace diagnostics_channel
26
+
27
+ class ExternalReferenceRegistry;
28
+
29
+ namespace sqlite {
30
+
31
+ // Mapping from JavaScript property names to SQLite limit constants
32
+ struct LimitInfo {
33
+ std::string_view js_name;
34
+ int sqlite_limit_id;
35
+ };
36
+
37
+ inline constexpr std::array<LimitInfo, 11> kLimitMapping = {{
38
+ {"length", SQLITE_LIMIT_LENGTH},
39
+ {"sqlLength", SQLITE_LIMIT_SQL_LENGTH},
40
+ {"column", SQLITE_LIMIT_COLUMN},
41
+ {"exprDepth", SQLITE_LIMIT_EXPR_DEPTH},
42
+ {"compoundSelect", SQLITE_LIMIT_COMPOUND_SELECT},
43
+ {"vdbeOp", SQLITE_LIMIT_VDBE_OP},
44
+ {"functionArg", SQLITE_LIMIT_FUNCTION_ARG},
45
+ {"attach", SQLITE_LIMIT_ATTACHED},
46
+ {"likePatternLength", SQLITE_LIMIT_LIKE_PATTERN_LENGTH},
47
+ {"variableNumber", SQLITE_LIMIT_VARIABLE_NUMBER},
48
+ {"triggerDepth", SQLITE_LIMIT_TRIGGER_DEPTH},
49
+ }};
50
+
51
+ constexpr bool CheckLimitIndices() {
52
+ for (size_t i = 0; i < kLimitMapping.size(); ++i) {
53
+ if (kLimitMapping[i].sqlite_limit_id != static_cast<int>(i)) {
54
+ return false;
55
+ }
56
+ }
57
+ return true;
58
+ }
59
+ static_assert(
60
+ CheckLimitIndices(),
61
+ "Each kLimitMapping entry's sqlite_limit_id must match its index");
62
+
63
+ // Mapping from JavaScript counter names to SQLite statement status constants
64
+ struct StatusInfo {
65
+ std::string_view js_name;
66
+ int sqlite_status_id;
67
+ };
68
+
69
+ // SQLITE_STMTSTATUS_FILTER_HIT and SQLITE_STMTSTATUS_FILTER_MISS require
70
+ // SQLite >= 3.38.0. Older shared-library builds omit the two counters.
71
+ #if SQLITE_VERSION_NUMBER >= 3038000
72
+ #define NODE_SQLITE_HAS_FILTER_STATUS 1
73
+ #endif
74
+
75
+ inline constexpr auto kStatusMapping = std::to_array<StatusInfo>({
76
+ {"fullscanStep", SQLITE_STMTSTATUS_FULLSCAN_STEP},
77
+ {"sort", SQLITE_STMTSTATUS_SORT},
78
+ {"autoindex", SQLITE_STMTSTATUS_AUTOINDEX},
79
+ {"vmStep", SQLITE_STMTSTATUS_VM_STEP},
80
+ {"reprepare", SQLITE_STMTSTATUS_REPREPARE},
81
+ {"run", SQLITE_STMTSTATUS_RUN},
82
+ #ifdef NODE_SQLITE_HAS_FILTER_STATUS
83
+ {"filterMiss", SQLITE_STMTSTATUS_FILTER_MISS},
84
+ {"filterHit", SQLITE_STMTSTATUS_FILTER_HIT},
85
+ #endif
86
+ {"memused", SQLITE_STMTSTATUS_MEMUSED},
87
+ });
88
+
89
+ class DatabaseOpenConfiguration {
90
+ public:
91
+ explicit DatabaseOpenConfiguration(std::string&& location)
92
+ : location_(std::move(location)) {}
93
+
94
+ inline const std::string& location() const { return location_; }
95
+
96
+ inline bool get_read_only() const { return read_only_; }
97
+
98
+ inline void set_read_only(bool flag) { read_only_ = flag; }
99
+
100
+ inline bool get_enable_foreign_keys() const { return enable_foreign_keys_; }
101
+
102
+ inline void set_enable_foreign_keys(bool flag) {
103
+ enable_foreign_keys_ = flag;
104
+ }
105
+
106
+ inline bool get_enable_dqs() const { return enable_dqs_; }
107
+
108
+ inline void set_enable_dqs(bool flag) { enable_dqs_ = flag; }
109
+
110
+ inline void set_timeout(int timeout) { timeout_ = timeout; }
111
+
112
+ inline int get_timeout() { return timeout_; }
113
+
114
+ inline void set_use_big_ints(bool flag) { use_big_ints_ = flag; }
115
+
116
+ inline bool get_use_big_ints() const { return use_big_ints_; }
117
+
118
+ inline void set_return_arrays(bool flag) { return_arrays_ = flag; }
119
+
120
+ inline bool get_return_arrays() const { return return_arrays_; }
121
+
122
+ inline void set_allow_bare_named_params(bool flag) {
123
+ allow_bare_named_params_ = flag;
124
+ }
125
+
126
+ inline bool get_allow_bare_named_params() const {
127
+ return allow_bare_named_params_;
128
+ }
129
+
130
+ inline void set_allow_unknown_named_params(bool flag) {
131
+ allow_unknown_named_params_ = flag;
132
+ }
133
+
134
+ inline bool get_allow_unknown_named_params() const {
135
+ return allow_unknown_named_params_;
136
+ }
137
+
138
+ inline void set_enable_defensive(bool flag) { defensive_ = flag; }
139
+
140
+ inline bool get_enable_defensive() const { return defensive_; }
141
+
142
+ inline void set_initial_limit(int sqlite_limit_id, int value) {
143
+ initial_limits_.at(sqlite_limit_id) = value;
144
+ }
145
+
146
+ inline const std::array<std::optional<int>, kLimitMapping.size()>&
147
+ initial_limits() const {
148
+ return initial_limits_;
149
+ }
150
+
151
+ private:
152
+ std::string location_;
153
+ bool read_only_ = false;
154
+ bool enable_foreign_keys_ = true;
155
+ bool enable_dqs_ = false;
156
+ int timeout_ = 0;
157
+ bool use_big_ints_ = false;
158
+ bool return_arrays_ = false;
159
+ bool allow_bare_named_params_ = true;
160
+ bool allow_unknown_named_params_ = false;
161
+ bool defensive_ = true;
162
+ std::array<std::optional<int>, kLimitMapping.size()> initial_limits_{};
163
+ };
164
+
165
+ class DatabaseSync;
166
+ class DatabaseSyncLimits;
167
+ class StatementSyncIterator;
168
+ class StatementSync;
169
+ class BackupJob;
170
+ class Session;
171
+
172
+ inline void FinalizeStatement(sqlite3_stmt* stmt) {
173
+ sqlite3_finalize(stmt);
174
+ }
175
+
176
+ using StatementPtr = DeleteFnPtr<sqlite3_stmt, FinalizeStatement>;
177
+
178
+ class StatementExecutionHelper {
179
+ public:
180
+ static v8::MaybeLocal<v8::Value> All(Environment* env,
181
+ StatementSync* statement);
182
+ static v8::MaybeLocal<v8::Object> Run(Environment* env,
183
+ StatementSync* statement);
184
+ static BaseObjectPtr<StatementSyncIterator> Iterate(
185
+ Environment* env, BaseObjectPtr<StatementSync> stmt);
186
+ static v8::MaybeLocal<v8::Value> ColumnToValue(Environment* env,
187
+ sqlite3_stmt* stmt,
188
+ const int column,
189
+ bool use_big_ints);
190
+ static v8::MaybeLocal<v8::Value> Get(Environment* env,
191
+ StatementSync* statement);
192
+ };
193
+
194
+ class DatabaseSync;
195
+
196
+ class BindingData : public BaseObject {
197
+ public:
198
+ SET_BINDING_ID(sqlite_binding_data)
199
+
200
+ BindingData(Realm* realm, v8::Local<v8::Object> wrap);
201
+
202
+ void MemoryInfo(MemoryTracker* tracker) const override;
203
+ SET_MEMORY_INFO_NAME(BindingData)
204
+ SET_SELF_SIZE(BindingData)
205
+
206
+ std::unordered_set<DatabaseSync*> open_databases;
207
+
208
+ static void CreatePerContextProperties(v8::Local<v8::Object> target,
209
+ v8::Local<v8::Value> unused,
210
+ v8::Local<v8::Context> context,
211
+ void* priv);
212
+ static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
213
+ };
214
+
215
+ class DatabaseSync : public BaseObject {
216
+ public:
217
+ enum InternalFields {
218
+ kAuthorizerCallback = BaseObject::kInternalFieldCount,
219
+ kLimitsObject,
220
+ kInternalFieldCount
221
+ };
222
+
223
+ DatabaseSync(Environment* env,
224
+ v8::Local<v8::Object> object,
225
+ DatabaseOpenConfiguration&& open_config,
226
+ bool open,
227
+ bool allow_load_extension);
228
+ void MemoryInfo(MemoryTracker* tracker) const override;
229
+ static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
230
+ static void Open(const v8::FunctionCallbackInfo<v8::Value>& args);
231
+ static void IsOpenGetter(const v8::FunctionCallbackInfo<v8::Value>& args);
232
+ static void IsTransactionGetter(
233
+ const v8::FunctionCallbackInfo<v8::Value>& args);
234
+ static void Close(const v8::FunctionCallbackInfo<v8::Value>& args);
235
+ static void Dispose(const v8::FunctionCallbackInfo<v8::Value>& args);
236
+ static void Prepare(const v8::FunctionCallbackInfo<v8::Value>& args);
237
+ static void Exec(const v8::FunctionCallbackInfo<v8::Value>& args);
238
+ static void CreateTagStore(const v8::FunctionCallbackInfo<v8::Value>& args);
239
+ static void Location(const v8::FunctionCallbackInfo<v8::Value>& args);
240
+ static void CustomFunction(const v8::FunctionCallbackInfo<v8::Value>& args);
241
+ static void AggregateFunction(
242
+ const v8::FunctionCallbackInfo<v8::Value>& args);
243
+ static void CreateSession(const v8::FunctionCallbackInfo<v8::Value>& args);
244
+ static void ApplyChangeset(const v8::FunctionCallbackInfo<v8::Value>& args);
245
+ static void EnableLoadExtension(
246
+ const v8::FunctionCallbackInfo<v8::Value>& args);
247
+ static void EnableDefensive(const v8::FunctionCallbackInfo<v8::Value>& args);
248
+ static void LimitsGetter(const v8::FunctionCallbackInfo<v8::Value>& args);
249
+ static void LoadExtension(const v8::FunctionCallbackInfo<v8::Value>& args);
250
+ static void Serialize(const v8::FunctionCallbackInfo<v8::Value>& args);
251
+ static void Deserialize(const v8::FunctionCallbackInfo<v8::Value>& args);
252
+ static void SetAuthorizer(const v8::FunctionCallbackInfo<v8::Value>& args);
253
+ static int AuthorizerCallback(void* user_data,
254
+ int action_code,
255
+ const char* param1,
256
+ const char* param2,
257
+ const char* param3,
258
+ const char* param4);
259
+ static int TraceCallback(unsigned int type,
260
+ void* user_data,
261
+ void* p,
262
+ void* x);
263
+ void FinalizeStatements();
264
+ void RemoveBackup(BackupJob* backup);
265
+ void AddBackup(BackupJob* backup);
266
+ void FinalizeBackups();
267
+ void UntrackStatement(StatementSync* statement);
268
+ bool IsOpen();
269
+ bool use_big_ints() const { return open_config_.get_use_big_ints(); }
270
+ bool return_arrays() const { return open_config_.get_return_arrays(); }
271
+ bool allow_bare_named_params() const {
272
+ return open_config_.get_allow_bare_named_params();
273
+ }
274
+ bool allow_unknown_named_params() const {
275
+ return open_config_.get_allow_unknown_named_params();
276
+ }
277
+ sqlite3* Connection();
278
+
279
+ // In some situations, such as when using custom functions, it is possible
280
+ // that SQLite reports an error while JavaScript already has a pending
281
+ // exception. In this case, the SQLite error should be ignored. These methods
282
+ // enable that use case.
283
+ void SetIgnoreNextSQLiteError(bool ignore);
284
+ bool ShouldIgnoreSQLiteError();
285
+ void EnableTracing();
286
+ void DisableTracing();
287
+
288
+ void IncrementCallbackDepth() { ++callback_depth_; }
289
+ void DecrementCallbackDepth() { --callback_depth_; }
290
+ bool IsInCallback() const { return callback_depth_ > 0; }
291
+
292
+ // SQLite forbids an authorizer callback from doing anything that modifies
293
+ // the database connection that invoked it, which includes preparing and
294
+ // stepping statements. See https://www.sqlite.org/c3ref/set_authorizer.html.
295
+ void IncrementAuthorizerDepth() { ++authorizer_depth_; }
296
+ void DecrementAuthorizerDepth() { --authorizer_depth_; }
297
+ bool IsInAuthorizerCallback() const { return authorizer_depth_ > 0; }
298
+
299
+ // A callback must not finalize the statement being stepped. Other statements
300
+ // are safe unless they are busy during an authorizer callback.
301
+ void PushSteppingStatement(sqlite3_stmt* stmt) {
302
+ stepping_statements_.push_back(stmt);
303
+ }
304
+ void PopSteppingStatement() { stepping_statements_.pop_back(); }
305
+ bool IsSteppingStatement(sqlite3_stmt* stmt) const {
306
+ return std::find(stepping_statements_.begin(),
307
+ stepping_statements_.end(),
308
+ stmt) != stepping_statements_.end();
309
+ }
310
+
311
+ void IncrementTraceSuppressionDepth() { ++trace_suppression_depth_; }
312
+ void DecrementTraceSuppressionDepth() { --trace_suppression_depth_; }
313
+ bool AreTraceEventsSuppressed() const { return trace_suppression_depth_ > 0; }
314
+
315
+ SET_MEMORY_INFO_NAME(DatabaseSync)
316
+ SET_SELF_SIZE(DatabaseSync)
317
+
318
+ private:
319
+ bool Open();
320
+ void DeleteSessions();
321
+
322
+ ~DatabaseSync() override;
323
+ DatabaseOpenConfiguration open_config_;
324
+ bool allow_load_extension_;
325
+ bool enable_load_extension_;
326
+ sqlite3* connection_;
327
+ bool ignore_next_sqlite_error_;
328
+ int callback_depth_ = 0;
329
+ int authorizer_depth_ = 0;
330
+ int trace_suppression_depth_ = 0;
331
+ std::vector<sqlite3_stmt*> stepping_statements_;
332
+
333
+ std::set<BackupJob*> backups_;
334
+ std::unordered_set<Session*> sessions_;
335
+ std::unordered_set<StatementSync*> statements_;
336
+ BaseObjectPtr<diagnostics_channel::Channel> trace_channel_;
337
+
338
+ friend class DatabaseSyncLimits;
339
+ friend class Session;
340
+ friend class SQLTagStore;
341
+ friend class StatementExecutionHelper;
342
+ };
343
+
344
+ class StatementSync : public BaseObject {
345
+ public:
346
+ StatementSync(Environment* env,
347
+ v8::Local<v8::Object> object,
348
+ BaseObjectPtr<DatabaseSync> db,
349
+ StatementPtr stmt);
350
+ void MemoryInfo(MemoryTracker* tracker) const override;
351
+ static v8::Local<v8::FunctionTemplate> GetConstructorTemplate(
352
+ Environment* env);
353
+ static BaseObjectPtr<StatementSync> Create(Environment* env,
354
+ BaseObjectPtr<DatabaseSync> db,
355
+ StatementPtr stmt);
356
+ static void All(const v8::FunctionCallbackInfo<v8::Value>& args);
357
+ static void Iterate(const v8::FunctionCallbackInfo<v8::Value>& args);
358
+ static void Get(const v8::FunctionCallbackInfo<v8::Value>& args);
359
+ static void Run(const v8::FunctionCallbackInfo<v8::Value>& args);
360
+ static void Columns(const v8::FunctionCallbackInfo<v8::Value>& args);
361
+ static void SourceSQLGetter(const v8::FunctionCallbackInfo<v8::Value>& args);
362
+ static void ExpandedSQLGetter(
363
+ const v8::FunctionCallbackInfo<v8::Value>& args);
364
+ static void Stat(const v8::FunctionCallbackInfo<v8::Value>& args);
365
+ static void ResetStats(const v8::FunctionCallbackInfo<v8::Value>& args);
366
+ static void SetAllowBareNamedParameters(
367
+ const v8::FunctionCallbackInfo<v8::Value>& args);
368
+ static void SetAllowUnknownNamedParameters(
369
+ const v8::FunctionCallbackInfo<v8::Value>& args);
370
+ static void SetReadBigInts(const v8::FunctionCallbackInfo<v8::Value>& args);
371
+ static void SetReturnArrays(const v8::FunctionCallbackInfo<v8::Value>& args);
372
+ static void Close(const v8::FunctionCallbackInfo<v8::Value>& args);
373
+ static void Dispose(const v8::FunctionCallbackInfo<v8::Value>& args);
374
+ v8::MaybeLocal<v8::Value> ColumnToValue(const int column);
375
+ v8::MaybeLocal<v8::Name> ColumnNameToName(const int column);
376
+ bool GetCachedColumnNames(v8::LocalVector<v8::Name>* keys);
377
+ void Finalize();
378
+ bool IsFinalized();
379
+
380
+ SET_MEMORY_INFO_NAME(StatementSync)
381
+ SET_SELF_SIZE(StatementSync)
382
+
383
+ private:
384
+ ~StatementSync() override;
385
+ void Close();
386
+ BaseObjectPtr<DatabaseSync> db_;
387
+ StatementPtr statement_;
388
+ bool return_arrays_ = false;
389
+ bool use_big_ints_;
390
+ bool allow_bare_named_params_;
391
+ bool allow_unknown_named_params_;
392
+ uint64_t reset_generation_ = 0;
393
+ std::optional<std::map<std::string, std::string>> bare_named_params_;
394
+ inline int ResetStatement();
395
+ std::vector<v8::Global<v8::Name>> cached_column_names_;
396
+ int cached_column_names_reprepare_count_ = -1;
397
+ void InvalidateColumnNameCache();
398
+ bool BindParams(const v8::FunctionCallbackInfo<v8::Value>& args);
399
+ bool BindValue(const v8::Local<v8::Value>& value, const int index);
400
+
401
+ friend class DatabaseSync;
402
+ friend class StatementSyncIterator;
403
+ friend class SQLTagStore;
404
+ friend class StatementExecutionHelper;
405
+ };
406
+
407
+ class StatementSyncIterator : public BaseObject {
408
+ public:
409
+ StatementSyncIterator(Environment* env,
410
+ v8::Local<v8::Object> object,
411
+ BaseObjectPtr<StatementSync> stmt);
412
+ void MemoryInfo(MemoryTracker* tracker) const override;
413
+ static v8::Local<v8::FunctionTemplate> GetConstructorTemplate(
414
+ Environment* env);
415
+ static BaseObjectPtr<StatementSyncIterator> Create(
416
+ Environment* env, BaseObjectPtr<StatementSync> stmt);
417
+ static void Next(const v8::FunctionCallbackInfo<v8::Value>& args);
418
+ static void Return(const v8::FunctionCallbackInfo<v8::Value>& args);
419
+
420
+ SET_MEMORY_INFO_NAME(StatementSyncIterator)
421
+ SET_SELF_SIZE(StatementSyncIterator)
422
+
423
+ private:
424
+ ~StatementSyncIterator() override;
425
+ BaseObjectPtr<StatementSync> stmt_;
426
+ bool done_;
427
+ uint64_t statement_reset_generation_;
428
+ };
429
+
430
+ using Sqlite3ChangesetGenFunc = int (*)(sqlite3_session*, int*, void**);
431
+
432
+ class Session : public BaseObject {
433
+ public:
434
+ Session(Environment* env,
435
+ v8::Local<v8::Object> object,
436
+ BaseObjectPtr<DatabaseSync> database,
437
+ sqlite3_session* session);
438
+ ~Session() override;
439
+ template <Sqlite3ChangesetGenFunc sqliteChangesetFunc>
440
+ static void Changeset(const v8::FunctionCallbackInfo<v8::Value>& args);
441
+ static void Close(const v8::FunctionCallbackInfo<v8::Value>& args);
442
+ static void Dispose(const v8::FunctionCallbackInfo<v8::Value>& args);
443
+ static v8::Local<v8::FunctionTemplate> GetConstructorTemplate(
444
+ Environment* env);
445
+ static BaseObjectPtr<Session> Create(Environment* env,
446
+ BaseObjectPtr<DatabaseSync> database,
447
+ sqlite3_session* session);
448
+
449
+ void MemoryInfo(MemoryTracker* tracker) const override;
450
+ SET_MEMORY_INFO_NAME(Session)
451
+ SET_SELF_SIZE(Session)
452
+
453
+ private:
454
+ void Delete();
455
+ sqlite3_session* session_;
456
+ BaseObjectPtr<DatabaseSync> database_; // The Parent Database
457
+ bool is_generating_changeset_ = false;
458
+
459
+ friend class DatabaseSync;
460
+ };
461
+
462
+ class SQLTagStore : public BaseObject {
463
+ public:
464
+ enum InternalFields {
465
+ kDatabaseObject = BaseObject::kInternalFieldCount,
466
+ kInternalFieldCount
467
+ };
468
+
469
+ SQLTagStore(Environment* env,
470
+ v8::Local<v8::Object> object,
471
+ BaseObjectWeakPtr<DatabaseSync> database,
472
+ int capacity);
473
+ ~SQLTagStore() override;
474
+ static BaseObjectPtr<SQLTagStore> Create(
475
+ Environment* env, BaseObjectWeakPtr<DatabaseSync> database, int capacity);
476
+ static v8::Local<v8::FunctionTemplate> GetConstructorTemplate(
477
+ Environment* env);
478
+ static void All(const v8::FunctionCallbackInfo<v8::Value>& args);
479
+ static void Get(const v8::FunctionCallbackInfo<v8::Value>& args);
480
+ static void Iterate(const v8::FunctionCallbackInfo<v8::Value>& args);
481
+ static void Run(const v8::FunctionCallbackInfo<v8::Value>& args);
482
+ static void Clear(const v8::FunctionCallbackInfo<v8::Value>& args);
483
+ static void CapacityGetter(const v8::FunctionCallbackInfo<v8::Value>& args);
484
+ static void DatabaseGetter(const v8::FunctionCallbackInfo<v8::Value>& args);
485
+ static void SizeGetter(const v8::FunctionCallbackInfo<v8::Value>& args);
486
+ void MemoryInfo(MemoryTracker* tracker) const override;
487
+ SET_MEMORY_INFO_NAME(SQLTagStore)
488
+ SET_SELF_SIZE(SQLTagStore)
489
+
490
+ private:
491
+ static BaseObjectPtr<StatementSync> PrepareStatement(
492
+ const v8::FunctionCallbackInfo<v8::Value>& args);
493
+ static bool ResetAndBindStatement(
494
+ Environment* env,
495
+ StatementSync* stmt,
496
+ const v8::FunctionCallbackInfo<v8::Value>& args);
497
+ BaseObjectWeakPtr<DatabaseSync> database_;
498
+ LRUCache<std::string, BaseObjectPtr<StatementSync>> sql_tags_;
499
+ friend class StatementExecutionHelper;
500
+ };
501
+
502
+ class CallbackDepthGuard {
503
+ public:
504
+ explicit CallbackDepthGuard(DatabaseSync* db) : db_(db) {
505
+ db_->IncrementCallbackDepth();
506
+ }
507
+ ~CallbackDepthGuard() { db_->DecrementCallbackDepth(); }
508
+ CallbackDepthGuard(const CallbackDepthGuard&) = delete;
509
+ CallbackDepthGuard& operator=(const CallbackDepthGuard&) = delete;
510
+
511
+ private:
512
+ DatabaseSync* db_;
513
+ };
514
+
515
+ class TraceEventSuppressionGuard {
516
+ public:
517
+ explicit TraceEventSuppressionGuard(DatabaseSync* db) : db_(db) {
518
+ db_->IncrementTraceSuppressionDepth();
519
+ }
520
+ ~TraceEventSuppressionGuard() { db_->DecrementTraceSuppressionDepth(); }
521
+ TraceEventSuppressionGuard(const TraceEventSuppressionGuard&) = delete;
522
+ TraceEventSuppressionGuard& operator=(const TraceEventSuppressionGuard&) =
523
+ delete;
524
+
525
+ private:
526
+ DatabaseSync* db_;
527
+ };
528
+
529
+ class SteppingStatementGuard {
530
+ public:
531
+ SteppingStatementGuard(DatabaseSync* db, sqlite3_stmt* stmt) : db_(db) {
532
+ db_->PushSteppingStatement(stmt);
533
+ }
534
+ ~SteppingStatementGuard() { db_->PopSteppingStatement(); }
535
+ SteppingStatementGuard(const SteppingStatementGuard&) = delete;
536
+ SteppingStatementGuard& operator=(const SteppingStatementGuard&) = delete;
537
+
538
+ private:
539
+ DatabaseSync* db_;
540
+ };
541
+
542
+ class AuthorizerDepthGuard {
543
+ public:
544
+ explicit AuthorizerDepthGuard(DatabaseSync* db) : db_(db) {
545
+ db_->IncrementAuthorizerDepth();
546
+ }
547
+ ~AuthorizerDepthGuard() { db_->DecrementAuthorizerDepth(); }
548
+ AuthorizerDepthGuard(const AuthorizerDepthGuard&) = delete;
549
+ AuthorizerDepthGuard& operator=(const AuthorizerDepthGuard&) = delete;
550
+
551
+ private:
552
+ DatabaseSync* db_;
553
+ };
554
+
555
+ class UserDefinedFunction {
556
+ public:
557
+ UserDefinedFunction(Environment* env,
558
+ v8::Local<v8::Function> fn,
559
+ BaseObjectWeakPtr<DatabaseSync> db,
560
+ bool use_bigint_args);
561
+ ~UserDefinedFunction();
562
+ static void xFunc(sqlite3_context* ctx, int argc, sqlite3_value** argv);
563
+ static void xDestroy(void* self);
564
+
565
+ private:
566
+ Environment* env_;
567
+ v8::Global<v8::Function> fn_;
568
+ BaseObjectWeakPtr<DatabaseSync> db_;
569
+ bool use_bigint_args_;
570
+ };
571
+
572
+ class DatabaseSyncLimits : public BaseObject {
573
+ public:
574
+ DatabaseSyncLimits(Environment* env,
575
+ v8::Local<v8::Object> object,
576
+ BaseObjectWeakPtr<DatabaseSync> database);
577
+ ~DatabaseSyncLimits() override;
578
+
579
+ void MemoryInfo(MemoryTracker* tracker) const override;
580
+ static v8::Local<v8::ObjectTemplate> GetTemplate(Environment* env);
581
+ static BaseObjectPtr<DatabaseSyncLimits> Create(
582
+ Environment* env, BaseObjectWeakPtr<DatabaseSync> database);
583
+
584
+ static v8::Intercepted LimitsGetter(
585
+ v8::Local<v8::Name> property,
586
+ const v8::PropertyCallbackInfo<v8::Value>& info);
587
+ static v8::Intercepted LimitsSetter(
588
+ v8::Local<v8::Name> property,
589
+ v8::Local<v8::Value> value,
590
+ const v8::PropertyCallbackInfo<void>& info);
591
+ static v8::Intercepted LimitsQuery(
592
+ v8::Local<v8::Name> property,
593
+ const v8::PropertyCallbackInfo<v8::Integer>& info);
594
+ static void LimitsEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info);
595
+
596
+ SET_MEMORY_INFO_NAME(DatabaseSyncLimits)
597
+ SET_SELF_SIZE(DatabaseSyncLimits)
598
+
599
+ private:
600
+ BaseObjectWeakPtr<DatabaseSync> database_;
601
+ };
602
+
603
+ } // namespace sqlite
604
+ } // namespace node
605
+
606
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
607
+ #endif // SRC_NODE_SQLITE_H_
@@ -0,0 +1,73 @@
1
+ // Copyright Joyent, Inc. and other Node contributors.
2
+ //
3
+ // Permission is hereby granted, free of charge, to any person obtaining a
4
+ // copy of this software and associated documentation files (the
5
+ // "Software"), to deal in the Software without restriction, including
6
+ // without limitation the rights to use, copy, modify, merge, publish,
7
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
8
+ // persons to whom the Software is furnished to do so, subject to the
9
+ // following conditions:
10
+ //
11
+ // The above copyright notice and this permission notice shall be included
12
+ // in all copies or substantial portions of the Software.
13
+ //
14
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ #ifndef SRC_NODE_STAT_WATCHER_H_
23
+ #define SRC_NODE_STAT_WATCHER_H_
24
+
25
+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
26
+
27
+ #include "node.h"
28
+ #include "handle_wrap.h"
29
+ #include "uv.h"
30
+ #include "v8.h"
31
+
32
+ namespace node {
33
+ namespace fs {
34
+ class BindingData;
35
+ }
36
+
37
+ class Environment;
38
+ class ExternalReferenceRegistry;
39
+
40
+ class StatWatcher : public HandleWrap {
41
+ public:
42
+ static void CreatePerIsolateProperties(IsolateData* isolate_data,
43
+ v8::Local<v8::ObjectTemplate> ctor);
44
+ static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
45
+
46
+ protected:
47
+ StatWatcher(fs::BindingData* binding_data,
48
+ v8::Local<v8::Object> wrap,
49
+ bool use_bigint);
50
+
51
+ static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
52
+ static void Start(const v8::FunctionCallbackInfo<v8::Value>& args);
53
+
54
+ SET_NO_MEMORY_INFO()
55
+ SET_MEMORY_INFO_NAME(StatWatcher)
56
+ SET_SELF_SIZE(StatWatcher)
57
+
58
+ private:
59
+ static void Callback(uv_fs_poll_t* handle,
60
+ int status,
61
+ const uv_stat_t* prev,
62
+ const uv_stat_t* curr);
63
+
64
+ uv_fs_poll_t watcher_;
65
+ const bool use_bigint_;
66
+ BaseObjectPtr<fs::BindingData> binding_data_;
67
+ };
68
+
69
+ } // namespace node
70
+
71
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
72
+
73
+ #endif // SRC_NODE_STAT_WATCHER_H_