@zlink-systems/zlink 0.17.3

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 (199) hide show
  1. package/LICENSE +373 -0
  2. package/README.md +198 -0
  3. package/README.typedoc.md +56 -0
  4. package/THIRD_PARTY_NOTICES.md +84 -0
  5. package/binding.gyp +27 -0
  6. package/dist/index.d.mts +3 -0
  7. package/dist/index.d.ts +24 -0
  8. package/dist/index.js +117 -0
  9. package/dist/index.mjs +4 -0
  10. package/dist/zlink/contracts/core/buffer_like.d.ts +2 -0
  11. package/dist/zlink/contracts/core/buffer_like.js +3 -0
  12. package/dist/zlink/contracts/core/context.d.ts +103 -0
  13. package/dist/zlink/contracts/core/context.js +11 -0
  14. package/dist/zlink/contracts/core/index.d.ts +3 -0
  15. package/dist/zlink/contracts/core/index.js +20 -0
  16. package/dist/zlink/contracts/core/routing_id.d.ts +28 -0
  17. package/dist/zlink/contracts/core/routing_id.js +120 -0
  18. package/dist/zlink/contracts/errors/errors.d.ts +44 -0
  19. package/dist/zlink/contracts/errors/errors.js +89 -0
  20. package/dist/zlink/contracts/errors/index.d.ts +2 -0
  21. package/dist/zlink/contracts/errors/index.js +29 -0
  22. package/dist/zlink/contracts/errors/results.d.ts +106 -0
  23. package/dist/zlink/contracts/errors/results.js +102 -0
  24. package/dist/zlink/contracts/eventing/index.d.ts +3 -0
  25. package/dist/zlink/contracts/eventing/index.js +20 -0
  26. package/dist/zlink/contracts/eventing/monitor.d.ts +157 -0
  27. package/dist/zlink/contracts/eventing/monitor.js +82 -0
  28. package/dist/zlink/contracts/eventing/poller.d.ts +76 -0
  29. package/dist/zlink/contracts/eventing/poller.js +3 -0
  30. package/dist/zlink/contracts/eventing/timer.d.ts +38 -0
  31. package/dist/zlink/contracts/eventing/timer.js +3 -0
  32. package/dist/zlink/contracts/index.d.ts +5 -0
  33. package/dist/zlink/contracts/index.js +22 -0
  34. package/dist/zlink/contracts/messaging/handlers.d.ts +5 -0
  35. package/dist/zlink/contracts/messaging/handlers.js +3 -0
  36. package/dist/zlink/contracts/messaging/index.d.ts +8 -0
  37. package/dist/zlink/contracts/messaging/index.js +15 -0
  38. package/dist/zlink/contracts/messaging/message.d.ts +68 -0
  39. package/dist/zlink/contracts/messaging/message.js +280 -0
  40. package/dist/zlink/contracts/messaging/message_parts_envelope.d.ts +14 -0
  41. package/dist/zlink/contracts/messaging/message_parts_envelope.js +56 -0
  42. package/dist/zlink/contracts/messaging/operations.d.ts +54 -0
  43. package/dist/zlink/contracts/messaging/operations.js +3 -0
  44. package/dist/zlink/contracts/messaging/received.d.ts +41 -0
  45. package/dist/zlink/contracts/messaging/received.js +130 -0
  46. package/dist/zlink/contracts/messaging/stream_packet.d.ts +14 -0
  47. package/dist/zlink/contracts/messaging/stream_packet.js +33 -0
  48. package/dist/zlink/contracts/messaging/subscription_event.d.ts +12 -0
  49. package/dist/zlink/contracts/messaging/subscription_event.js +20 -0
  50. package/dist/zlink/contracts/messaging/topic_message.d.ts +14 -0
  51. package/dist/zlink/contracts/messaging/topic_message.js +36 -0
  52. package/dist/zlink/contracts/sockets/dealer_socket.d.ts +29 -0
  53. package/dist/zlink/contracts/sockets/dealer_socket.js +3 -0
  54. package/dist/zlink/contracts/sockets/index.d.ts +10 -0
  55. package/dist/zlink/contracts/sockets/index.js +15 -0
  56. package/dist/zlink/contracts/sockets/pair_socket.d.ts +20 -0
  57. package/dist/zlink/contracts/sockets/pair_socket.js +3 -0
  58. package/dist/zlink/contracts/sockets/pubsub_sockets.d.ts +40 -0
  59. package/dist/zlink/contracts/sockets/pubsub_sockets.js +3 -0
  60. package/dist/zlink/contracts/sockets/router_socket.d.ts +32 -0
  61. package/dist/zlink/contracts/sockets/router_socket.js +3 -0
  62. package/dist/zlink/contracts/sockets/socket.d.ts +58 -0
  63. package/dist/zlink/contracts/sockets/socket.js +3 -0
  64. package/dist/zlink/contracts/sockets/socket_constants.d.ts +88 -0
  65. package/dist/zlink/contracts/sockets/socket_constants.js +67 -0
  66. package/dist/zlink/contracts/sockets/socket_options.d.ts +105 -0
  67. package/dist/zlink/contracts/sockets/socket_options.js +3 -0
  68. package/dist/zlink/contracts/sockets/stream_socket.d.ts +31 -0
  69. package/dist/zlink/contracts/sockets/stream_socket.js +3 -0
  70. package/dist/zlink/runtime/buffers/message_conversion.d.ts +6 -0
  71. package/dist/zlink/runtime/buffers/message_conversion.js +49 -0
  72. package/dist/zlink/runtime/core/context.d.ts +43 -0
  73. package/dist/zlink/runtime/core/context.js +150 -0
  74. package/dist/zlink/runtime/core/context_options.d.ts +19 -0
  75. package/dist/zlink/runtime/core/context_options.js +23 -0
  76. package/dist/zlink/runtime/core/routing_id.d.ts +3 -0
  77. package/dist/zlink/runtime/core/routing_id.js +30 -0
  78. package/dist/zlink/runtime/core/routing_id_conversion.d.ts +2 -0
  79. package/dist/zlink/runtime/core/routing_id_conversion.js +11 -0
  80. package/dist/zlink/runtime/core/runtime_info.d.ts +8 -0
  81. package/dist/zlink/runtime/core/runtime_info.js +39 -0
  82. package/dist/zlink/runtime/errors/error_mapping.d.ts +4 -0
  83. package/dist/zlink/runtime/errors/error_mapping.js +132 -0
  84. package/dist/zlink/runtime/errors/error_state.d.ts +1 -0
  85. package/dist/zlink/runtime/errors/error_state.js +15 -0
  86. package/dist/zlink/runtime/errors/native_errors.d.ts +16 -0
  87. package/dist/zlink/runtime/errors/native_errors.js +86 -0
  88. package/dist/zlink/runtime/eventing/counters.d.ts +16 -0
  89. package/dist/zlink/runtime/eventing/counters.js +33 -0
  90. package/dist/zlink/runtime/eventing/index.d.ts +6 -0
  91. package/dist/zlink/runtime/eventing/index.js +22 -0
  92. package/dist/zlink/runtime/eventing/monitor_event_state.d.ts +3 -0
  93. package/dist/zlink/runtime/eventing/monitor_event_state.js +19 -0
  94. package/dist/zlink/runtime/eventing/monitor_raw.d.ts +50 -0
  95. package/dist/zlink/runtime/eventing/monitor_raw.js +3 -0
  96. package/dist/zlink/runtime/eventing/monitor_socket.d.ts +9 -0
  97. package/dist/zlink/runtime/eventing/monitor_socket.js +39 -0
  98. package/dist/zlink/runtime/eventing/monitor_status.d.ts +3 -0
  99. package/dist/zlink/runtime/eventing/monitor_status.js +52 -0
  100. package/dist/zlink/runtime/eventing/poll_events.d.ts +20 -0
  101. package/dist/zlink/runtime/eventing/poll_events.js +92 -0
  102. package/dist/zlink/runtime/eventing/poller.d.ts +34 -0
  103. package/dist/zlink/runtime/eventing/poller.js +275 -0
  104. package/dist/zlink/runtime/eventing/thread.d.ts +6 -0
  105. package/dist/zlink/runtime/eventing/thread.js +52 -0
  106. package/dist/zlink/runtime/eventing/timer.d.ts +8 -0
  107. package/dist/zlink/runtime/eventing/timer.js +45 -0
  108. package/dist/zlink/runtime/handles/native_handle.d.ts +7 -0
  109. package/dist/zlink/runtime/handles/native_handle.js +24 -0
  110. package/dist/zlink/runtime/messaging/completion_owner.d.ts +86 -0
  111. package/dist/zlink/runtime/messaging/completion_owner.js +570 -0
  112. package/dist/zlink/runtime/messaging/message_materializer.d.ts +36 -0
  113. package/dist/zlink/runtime/messaging/message_materializer.js +199 -0
  114. package/dist/zlink/runtime/messaging/message_parts_state.d.ts +4 -0
  115. package/dist/zlink/runtime/messaging/message_parts_state.js +20 -0
  116. package/dist/zlink/runtime/messaging/message_snapshot.d.ts +13 -0
  117. package/dist/zlink/runtime/messaging/message_snapshot.js +42 -0
  118. package/dist/zlink/runtime/messaging/received_operations.d.ts +5 -0
  119. package/dist/zlink/runtime/messaging/received_operations.js +46 -0
  120. package/dist/zlink/runtime/messaging/received_state.d.ts +13 -0
  121. package/dist/zlink/runtime/messaging/received_state.js +29 -0
  122. package/dist/zlink/runtime/messaging/request_executor.d.ts +2 -0
  123. package/dist/zlink/runtime/messaging/request_executor.js +8 -0
  124. package/dist/zlink/runtime/messaging/send_operation_base.d.ts +13 -0
  125. package/dist/zlink/runtime/messaging/send_operation_base.js +52 -0
  126. package/dist/zlink/runtime/messaging/subscription_event_state.d.ts +4 -0
  127. package/dist/zlink/runtime/messaging/subscription_event_state.js +17 -0
  128. package/dist/zlink/runtime/messaging/topic_message_state.d.ts +11 -0
  129. package/dist/zlink/runtime/messaging/topic_message_state.js +75 -0
  130. package/dist/zlink/runtime/native/binding.d.ts +6 -0
  131. package/dist/zlink/runtime/native/binding.js +3 -0
  132. package/dist/zlink/runtime/native/binding_context.d.ts +14 -0
  133. package/dist/zlink/runtime/native/binding_context.js +3 -0
  134. package/dist/zlink/runtime/native/binding_core.d.ts +21 -0
  135. package/dist/zlink/runtime/native/binding_core.js +3 -0
  136. package/dist/zlink/runtime/native/binding_eventing.d.ts +40 -0
  137. package/dist/zlink/runtime/native/binding_eventing.js +3 -0
  138. package/dist/zlink/runtime/native/binding_socket.d.ts +52 -0
  139. package/dist/zlink/runtime/native/binding_socket.js +3 -0
  140. package/dist/zlink/runtime/native/binding_types.d.ts +8 -0
  141. package/dist/zlink/runtime/native/binding_types.js +3 -0
  142. package/dist/zlink/runtime/native/native.d.ts +2 -0
  143. package/dist/zlink/runtime/native/native.js +40 -0
  144. package/dist/zlink/runtime/native/native_load_paths.d.ts +16 -0
  145. package/dist/zlink/runtime/native/native_load_paths.js +165 -0
  146. package/dist/zlink/runtime/options/byte_values.d.ts +3 -0
  147. package/dist/zlink/runtime/options/byte_values.js +27 -0
  148. package/dist/zlink/runtime/options/option_mapping.d.ts +72 -0
  149. package/dist/zlink/runtime/options/option_mapping.js +41 -0
  150. package/dist/zlink/runtime/options/validation.d.ts +1 -0
  151. package/dist/zlink/runtime/options/validation.js +17 -0
  152. package/dist/zlink/runtime/public_bridge.d.ts +6 -0
  153. package/dist/zlink/runtime/public_bridge.js +23 -0
  154. package/dist/zlink/runtime/sockets/dealer_socket.d.ts +16 -0
  155. package/dist/zlink/runtime/sockets/dealer_socket.js +56 -0
  156. package/dist/zlink/runtime/sockets/index.d.ts +19 -0
  157. package/dist/zlink/runtime/sockets/index.js +27 -0
  158. package/dist/zlink/runtime/sockets/pair_socket.d.ts +7 -0
  159. package/dist/zlink/runtime/sockets/pair_socket.js +12 -0
  160. package/dist/zlink/runtime/sockets/pub_socket.d.ts +7 -0
  161. package/dist/zlink/runtime/sockets/pub_socket.js +12 -0
  162. package/dist/zlink/runtime/sockets/router_socket.d.ts +19 -0
  163. package/dist/zlink/runtime/sockets/router_socket.js +70 -0
  164. package/dist/zlink/runtime/sockets/socket_base.d.ts +21 -0
  165. package/dist/zlink/runtime/sockets/socket_base.js +102 -0
  166. package/dist/zlink/runtime/sockets/socket_operation_builders.d.ts +38 -0
  167. package/dist/zlink/runtime/sockets/socket_operation_builders.js +93 -0
  168. package/dist/zlink/runtime/sockets/socket_operations.d.ts +40 -0
  169. package/dist/zlink/runtime/sockets/socket_operations.js +177 -0
  170. package/dist/zlink/runtime/sockets/socket_options.d.ts +104 -0
  171. package/dist/zlink/runtime/sockets/socket_options.js +259 -0
  172. package/dist/zlink/runtime/sockets/socket_submit_errors.d.ts +3 -0
  173. package/dist/zlink/runtime/sockets/socket_submit_errors.js +13 -0
  174. package/dist/zlink/runtime/sockets/stream_socket.d.ts +15 -0
  175. package/dist/zlink/runtime/sockets/stream_socket.js +93 -0
  176. package/dist/zlink/runtime/sockets/sub_socket.d.ts +7 -0
  177. package/dist/zlink/runtime/sockets/sub_socket.js +12 -0
  178. package/dist/zlink/runtime/sockets/xpub_socket.d.ts +10 -0
  179. package/dist/zlink/runtime/sockets/xpub_socket.js +39 -0
  180. package/dist/zlink/runtime/sockets/xsub_socket.d.ts +7 -0
  181. package/dist/zlink/runtime/sockets/xsub_socket.js +12 -0
  182. package/native/src/addon.cc +11 -0
  183. package/native/src/addon_common_api.h +57 -0
  184. package/native/src/addon_core.cc +3974 -0
  185. package/native/src/addon_core_api.h +110 -0
  186. package/native/src/addon_core_options.cc +119 -0
  187. package/native/src/addon_core_options.h +9 -0
  188. package/native/src/addon_exports.cc +151 -0
  189. package/native/src/addon_exports.h +7 -0
  190. package/native/src/addon_message_parts.h +67 -0
  191. package/native/src/addon_message_values.h +345 -0
  192. package/native/src/addon_monitor_status_values.h +71 -0
  193. package/native/src/addon_submit_results.h +30 -0
  194. package/package.json +74 -0
  195. package/prebuilds/linux-x64/libzlink.so.0.17.3 +0 -0
  196. package/prebuilds/linux-x64/zlink.node +0 -0
  197. package/provenance/core-package-provenance.json +73 -0
  198. package/scripts/install.js +37 -0
  199. package/scripts/resolve_core.js +86 -0
@@ -0,0 +1,40 @@
1
+ import type { MonitorEventValueRaw, MonitorStatusRaw, NativeHandle } from './binding_types';
2
+ export interface EventingNativeBinding {
3
+ atomicCounterDec: (counter: NativeHandle) => number;
4
+ atomicCounterDestroy: (counter: NativeHandle) => void;
5
+ atomicCounterInc: (counter: NativeHandle) => number;
6
+ atomicCounterNew: () => NativeHandle;
7
+ atomicCounterSet: (counter: NativeHandle, value: number) => void;
8
+ atomicCounterValue: (counter: NativeHandle) => number;
9
+ monitorClose: (monitor: NativeHandle) => void;
10
+ monitorRecv: (monitor: NativeHandle) => MonitorEventValueRaw;
11
+ monitorRecvNoWait: (monitor: NativeHandle) => MonitorEventValueRaw | null;
12
+ monitorStatus: (monitor: NativeHandle) => MonitorStatusRaw;
13
+ pollEventsDestroy: (events: NativeHandle) => void;
14
+ pollEventsFd: (events: NativeHandle, index: number) => number;
15
+ pollEventsNew: (capacity: number) => NativeHandle;
16
+ pollEventsRevents: (events: NativeHandle, index: number) => number;
17
+ pollEventsSlot: (events: NativeHandle, index: number) => number;
18
+ pollEventsSourceKind: (events: NativeHandle, index: number) => number;
19
+ pollerAdd: (poller: NativeHandle, handle: NativeHandle, slot: bigint | null, events: number) => void;
20
+ pollerAddFd: (poller: NativeHandle, fd: number, slot: bigint, events: number) => void;
21
+ pollerAddTimer: (poller: NativeHandle, timer: NativeHandle, slot: bigint) => void;
22
+ pollerDestroy: (poller: NativeHandle) => void;
23
+ pollerModify: (poller: NativeHandle, handle: NativeHandle, events: number) => void;
24
+ pollerModifyFd: (poller: NativeHandle, fd: number, events: number) => void;
25
+ pollerNew: () => NativeHandle;
26
+ pollerRemove: (poller: NativeHandle, handle: NativeHandle) => void;
27
+ pollerRemoveFd: (poller: NativeHandle, fd: number) => void;
28
+ pollerRemoveTimer: (poller: NativeHandle, timer: NativeHandle) => void;
29
+ pollerSize: (poller: NativeHandle) => number;
30
+ pollerWait: (poller: NativeHandle, timeoutMs: number) => number;
31
+ pollerWaitInto: (poller: NativeHandle, events: NativeHandle, capacity: number, timeoutMs: number) => number;
32
+ stopwatchIntermediate: (watch: NativeHandle) => number;
33
+ stopwatchStart: () => NativeHandle;
34
+ stopwatchStop: (watch: NativeHandle) => number;
35
+ timerDestroy: (timer: NativeHandle) => void;
36
+ timerNew: () => NativeHandle;
37
+ timerRecv: (timer: NativeHandle, flags: number) => bigint | null;
38
+ timerStart: (timer: NativeHandle, intervalNs: bigint, repeatCount: bigint) => void;
39
+ timerStop: (timer: NativeHandle) => void;
40
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // SPDX-License-Identifier: MPL-2.0
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,52 @@
1
+ import type { NativeHandle, NativeReceivedRaw, NativeTopicMessageRaw, SubscriptionEntry } from './binding_types';
2
+ import type { NativeCompletion, NativeSubmitResult, NativeSyncRequestResult } from '../messaging/completion_owner';
3
+ export interface SocketNativeBinding {
4
+ socketSubmitSend: (socket: NativeHandle, parts: unknown, routingId: Buffer | null, flags: number, token: bigint) => NativeSubmitResult;
5
+ socketSubmitRequest: (socket: NativeHandle, target: Buffer | null, parts: unknown, timeoutMs: number, flags: number, token: bigint) => NativeSubmitResult;
6
+ socketRequestSync: (socket: NativeHandle, target: Buffer | null, parts: unknown, timeoutMs: number) => NativeSyncRequestResult;
7
+ socketCompletionRecv: (socket: NativeHandle, flags: number) => NativeCompletion | null;
8
+ socketReadableWatchStart: (socket: NativeHandle, callback: (status: number) => void) => NativeHandle;
9
+ socketReadableWatchStop: (watch: NativeHandle) => void;
10
+ socketReply: (socket: NativeHandle, sourceRid: Buffer, replyToken: bigint, parts: unknown) => void;
11
+ socketStreamRecvPacket: (socket: NativeHandle, flags: number) => {
12
+ routingId: Buffer;
13
+ header: Buffer;
14
+ body: Buffer;
15
+ } | null;
16
+ handleGetRoutingId: (handle: NativeHandle) => Buffer;
17
+ handleSetRoutingId: (handle: NativeHandle, routingId: Buffer) => void;
18
+ monitorOpen: (socket: NativeHandle, eventMask: number, monitorHwmBytes: bigint) => NativeHandle;
19
+ routerRecvMessage: (socket: NativeHandle, flags: number, preferManagedSinglePart?: boolean, routingIdStorage?: Buffer | null) => NativeReceivedRaw | null;
20
+ routerRecvMessageNoWait: (socket: NativeHandle, preferManagedSinglePart?: boolean, routingIdStorage?: Buffer | null) => NativeReceivedRaw | null;
21
+ socketBind: (socket: NativeHandle, endpoint: string) => void;
22
+ socketClose: (socket: NativeHandle) => void;
23
+ socketConnect: (socket: NativeHandle, endpoint: string) => void;
24
+ socketDisconnect: (socket: NativeHandle, endpoint: string) => void;
25
+ socketDisconnectRid: (socket: NativeHandle, routingId: Buffer) => void;
26
+ socketGetOpt: (socket: NativeHandle, option: number) => Buffer;
27
+ socketNew: (ctx: NativeHandle, type: number) => NativeHandle;
28
+ socketPublish: (socket: NativeHandle, topic: string, payload: unknown, flags: number) => number;
29
+ socketRecvMessage: (socket: NativeHandle, flags: number) => NativeReceivedRaw | null;
30
+ socketRecvMessageNoWait: (socket: NativeHandle) => NativeReceivedRaw | null;
31
+ socketSetOpt: (socket: NativeHandle, option: number, value: Buffer) => void;
32
+ socketSetReceiveFlowState: (socket: NativeHandle, state: number) => void;
33
+ socketSetSubscription: (socket: NativeHandle, topic: string) => void;
34
+ socketSetTlsClient: (socket: NativeHandle, ca: string, hostname: string, trustSystem: number) => void;
35
+ socketSetTlsServer: (socket: NativeHandle, cert: string, key: string, requireClientCert: number) => void;
36
+ socketSubscribeMessage: (socket: NativeHandle, flags: number) => NativeTopicMessageRaw | null;
37
+ socketSubscriptionEvent: (socket: NativeHandle, flags: number) => {
38
+ routingId?: Buffer | null;
39
+ topic: string;
40
+ subscribed: boolean;
41
+ } | null;
42
+ socketTryPublish: (socket: NativeHandle, topic: string, payload: unknown) => number;
43
+ socketTrySubscribeMessage: (socket: NativeHandle) => NativeTopicMessageRaw | null;
44
+ socketTrySubscriptionEvent: (socket: NativeHandle) => {
45
+ routingId?: Buffer | null;
46
+ topic: string;
47
+ subscribed: boolean;
48
+ } | null;
49
+ socketUnbind: (socket: NativeHandle, endpoint: string) => void;
50
+ socketUnsetSubscription: (socket: NativeHandle, topic: string) => void;
51
+ subscriptionAt: (socket: NativeHandle, index: number) => SubscriptionEntry | null;
52
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // SPDX-License-Identifier: MPL-2.0
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ import type { NativeReceivedRaw, NativeTopicMessageRaw } from '../messaging/message_materializer';
2
+ import type { MonitorEventValueRaw, MonitorStatusRaw } from '../eventing/monitor_raw';
3
+ import type { SubscriptionEntry } from '../../contracts/messaging';
4
+ export type NativeHandle = unknown;
5
+ export type NativeBuffer = Buffer;
6
+ export type NullableNativeHandle = NativeHandle | null;
7
+ export type NativeVersion = [number, number, number];
8
+ export type { MonitorEventValueRaw, MonitorStatusRaw, NativeReceivedRaw, NativeTopicMessageRaw, SubscriptionEntry };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // SPDX-License-Identifier: MPL-2.0
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ import type { NativeBinding } from './binding';
2
+ export declare function requireNative(): NativeBinding;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ // SPDX-License-Identifier: MPL-2.0
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.requireNative = requireNative;
5
+ const native_load_paths_1 = require("./native_load_paths");
6
+ function loadNative() {
7
+ const paths = (0, native_load_paths_1.nativeLoadPaths)();
8
+ const failures = [];
9
+ try {
10
+ (0, native_load_paths_1.prepareDevelopmentRuntimeLink)(paths.packageRoot);
11
+ return (0, native_load_paths_1.requireNativeAt)(paths.buildAddon);
12
+ }
13
+ catch (error) {
14
+ failures.push({ target: paths.buildAddon, error });
15
+ try {
16
+ (0, native_load_paths_1.preparePrebuiltRuntimePath)(paths.prebuiltDir);
17
+ return (0, native_load_paths_1.requireNativeAt)(paths.prebuiltAddon);
18
+ }
19
+ catch (error) {
20
+ failures.push({ target: paths.prebuiltAddon, error });
21
+ }
22
+ }
23
+ throw new Error([
24
+ 'zlink native addon not found. Build with node-gyp.',
25
+ ...failures.map((failure) => `- ${(0, native_load_paths_1.describeLoadFailure)(failure)}`)
26
+ ].join('\n'));
27
+ }
28
+ let native = null;
29
+ let loadError = null;
30
+ try {
31
+ native = loadNative();
32
+ }
33
+ catch (error) {
34
+ loadError = error instanceof Error ? error : new Error(String(error));
35
+ }
36
+ function requireNative() {
37
+ if (!native)
38
+ throw loadError ?? new Error('zlink native addon not found. Build with node-gyp.');
39
+ return native;
40
+ }
@@ -0,0 +1,16 @@
1
+ import type { NativeBinding } from './binding';
2
+ export interface NativeLoadFailure {
3
+ target: string;
4
+ error: unknown;
5
+ }
6
+ export interface NativeLoadPaths {
7
+ packageRoot: string;
8
+ buildAddon: string;
9
+ prebuiltDir: string;
10
+ prebuiltAddon: string;
11
+ }
12
+ export declare function nativeLoadPaths(): NativeLoadPaths;
13
+ export declare function describeLoadFailure(failure: NativeLoadFailure): string;
14
+ export declare function prepareDevelopmentRuntimeLink(packageRoot: string): void;
15
+ export declare function preparePrebuiltRuntimePath(prebuiltDir: string): void;
16
+ export declare function requireNativeAt(target: string): NativeBinding;
@@ -0,0 +1,165 @@
1
+ "use strict";
2
+ // SPDX-License-Identifier: MPL-2.0
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.nativeLoadPaths = nativeLoadPaths;
38
+ exports.describeLoadFailure = describeLoadFailure;
39
+ exports.prepareDevelopmentRuntimeLink = prepareDevelopmentRuntimeLink;
40
+ exports.preparePrebuiltRuntimePath = preparePrebuiltRuntimePath;
41
+ exports.requireNativeAt = requireNativeAt;
42
+ const fs = __importStar(require("node:fs"));
43
+ const path = __importStar(require("node:path"));
44
+ const LINUX_SONAME = 'libzlink.so.0';
45
+ function nativeLoadPaths() {
46
+ const packageRoot = path.join(__dirname, '..', '..', '..', '..');
47
+ const prebuiltDir = path.join(packageRoot, 'prebuilds', `${process.platform}-${process.arch}`);
48
+ return {
49
+ packageRoot,
50
+ buildAddon: path.join(packageRoot, 'build', 'Release', 'zlink.node'),
51
+ prebuiltDir,
52
+ prebuiltAddon: path.join(prebuiltDir, 'zlink.node')
53
+ };
54
+ }
55
+ function describeLoadFailure(failure) {
56
+ const message = failure.error instanceof Error
57
+ ? failure.error.message
58
+ : String(failure.error);
59
+ return `${failure.target}: ${message}`;
60
+ }
61
+ function prepareDevelopmentRuntimeLink(packageRoot) {
62
+ if (process.platform !== 'linux') {
63
+ return;
64
+ }
65
+ const addonDir = path.join(packageRoot, 'build', 'Release');
66
+ const coreDir = path.join(packageRoot, '..', '..', 'core', 'build', 'lib');
67
+ const coreAltDir = path.join(packageRoot, '..', 'build_cpp', 'lib');
68
+ const releaseDir = process.env.ZLINK_CORE_SOURCE === 'release'
69
+ && process.env.ZLINK_CORE_PACKAGE_PREFIX
70
+ ? path.join(process.env.ZLINK_CORE_PACKAGE_PREFIX, 'lib')
71
+ : undefined;
72
+ const localDir = process.env.ZLINK_CORE_SOURCE === 'local'
73
+ ? process.env.ZLINK_CORE_LIB_DIR
74
+ : undefined;
75
+ const runtimeDirs = [localDir, releaseDir, coreDir, coreAltDir].filter((entry) => entry !== undefined);
76
+ refreshAddonRuntimeLink(path.join(addonDir, LINUX_SONAME), runtimeDirs.map((entry) => path.join(entry, LINUX_SONAME)));
77
+ prependLibraryPath([...runtimeDirs, addonDir]);
78
+ }
79
+ function preparePrebuiltRuntimePath(prebuiltDir) {
80
+ if (process.platform === 'linux') {
81
+ const soname = path.join(prebuiltDir, LINUX_SONAME);
82
+ if (!fs.existsSync(soname)) {
83
+ const packageRoot = path.dirname(path.dirname(prebuiltDir));
84
+ let versionedLibrary;
85
+ try {
86
+ const provenance = JSON.parse(fs.readFileSync(path.join(packageRoot, 'provenance', 'core-package-provenance.json'), 'utf8'));
87
+ if (provenance.version !== undefined) {
88
+ const candidate = path.join(prebuiltDir, `libzlink.so.${provenance.version}`);
89
+ if (fs.existsSync(candidate))
90
+ versionedLibrary = candidate;
91
+ }
92
+ }
93
+ catch {
94
+ // The normal package path has Core provenance. If it is unavailable,
95
+ // leave native loading to the development fallback below.
96
+ }
97
+ if (versionedLibrary !== undefined)
98
+ fs.symlinkSync(versionedLibrary, soname);
99
+ }
100
+ prependLibraryPath([prebuiltDir]);
101
+ return;
102
+ }
103
+ if (process.platform !== 'win32') {
104
+ return;
105
+ }
106
+ prependPathEntries([
107
+ prebuiltDir,
108
+ windowsRuntimePath(process.env.ZLINK_LIBRARY_PATH),
109
+ process.env.ZLINK_CORE_PREFIX
110
+ ? path.join(process.env.ZLINK_CORE_PREFIX, 'bin')
111
+ : undefined,
112
+ process.env.ZLINK_CORE_PREFIX,
113
+ process.env.ZLINK_OPENSSL_BIN,
114
+ process.env.OPENSSL_BIN,
115
+ 'C:\\Program Files\\OpenSSL-Win64\\bin',
116
+ 'C:\\Program Files\\Git\\mingw64\\bin',
117
+ 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\Common7\\IDE\\CommonExtensions\\Microsoft\\TeamFoundation\\Team Explorer\\Git\\mingw64\\bin'
118
+ ]);
119
+ }
120
+ function windowsRuntimePath(entry) {
121
+ if (!entry)
122
+ return undefined;
123
+ try {
124
+ if (fs.statSync(entry).isFile())
125
+ return path.dirname(entry);
126
+ }
127
+ catch {
128
+ // Let the native loader report a missing runtime with its normal error.
129
+ }
130
+ return entry;
131
+ }
132
+ function requireNativeAt(target) {
133
+ return require(target);
134
+ }
135
+ function refreshAddonRuntimeLink(addonLib, sourceLibs) {
136
+ for (const sourceLib of sourceLibs) {
137
+ if (!fs.existsSync(sourceLib))
138
+ continue;
139
+ const sourceReal = fs.realpathSync(sourceLib);
140
+ const currentReal = fs.existsSync(addonLib) ? fs.realpathSync(addonLib) : null;
141
+ if (currentReal === sourceReal)
142
+ return;
143
+ fs.rmSync(addonLib, { force: true });
144
+ fs.symlinkSync(sourceLib, addonLib);
145
+ return;
146
+ }
147
+ }
148
+ function prependLibraryPath(entries) {
149
+ const existing = (process.env.LD_LIBRARY_PATH || '').split(':').filter(Boolean);
150
+ for (const entry of entries) {
151
+ if (!existing.includes(entry))
152
+ existing.unshift(entry);
153
+ }
154
+ process.env.LD_LIBRARY_PATH = existing.join(':');
155
+ }
156
+ function prependPathEntries(entries) {
157
+ const existing = (process.env.PATH || '').split(';').filter(Boolean);
158
+ for (const entry of entries) {
159
+ if (!entry || !fs.existsSync(entry))
160
+ continue;
161
+ if (!existing.includes(entry))
162
+ existing.unshift(entry);
163
+ }
164
+ process.env.PATH = existing.join(';');
165
+ }
@@ -0,0 +1,3 @@
1
+ export declare function validateUInt64(value: bigint, name: string): bigint;
2
+ export declare function uint64Buffer(value: bigint, name: string): Buffer;
3
+ export declare function readUInt64Option(buffer: Buffer, name: string): bigint;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ // SPDX-License-Identifier: MPL-2.0
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.validateUInt64 = validateUInt64;
5
+ exports.uint64Buffer = uint64Buffer;
6
+ exports.readUInt64Option = readUInt64Option;
7
+ function validateUInt64(value, name) {
8
+ if (typeof value !== 'bigint') {
9
+ throw new TypeError(`${name} must be a bigint`);
10
+ }
11
+ const max = (1n << 64n) - 1n;
12
+ if (value < 0n || value > max) {
13
+ throw new RangeError(`${name} must fit in uint64`);
14
+ }
15
+ return value;
16
+ }
17
+ function uint64Buffer(value, name) {
18
+ validateUInt64(value, name);
19
+ const buf = Buffer.allocUnsafe(8);
20
+ buf.writeBigUInt64LE(value, 0);
21
+ return buf;
22
+ }
23
+ function readUInt64Option(buffer, name) {
24
+ if (buffer.length !== 8)
25
+ throw new Error(`${name} option returned an invalid payload`);
26
+ return buffer.readBigUInt64LE(0);
27
+ }
@@ -0,0 +1,72 @@
1
+ export declare const SocketOption: Readonly<{
2
+ readonly AFFINITY: 12289;
3
+ readonly RATE: 12291;
4
+ readonly RECOVERY_IVL: 12292;
5
+ readonly SNDBUF: 12293;
6
+ readonly RCVBUF: 12294;
7
+ readonly FD: 12295;
8
+ readonly EVENTS: 12296;
9
+ readonly TYPE: 12297;
10
+ readonly LINGER: 12298;
11
+ readonly RECONNECT_IVL: 12299;
12
+ readonly BACKLOG: 12300;
13
+ readonly RECONNECT_IVL_MAX: 12301;
14
+ readonly MAXMSGSIZE: 12302;
15
+ readonly SNDHWM: 12303;
16
+ readonly RCVHWM: 12304;
17
+ readonly MULTICAST_HOPS: 12305;
18
+ readonly RCVTIMEO: 12306;
19
+ readonly SNDTIMEO: 12307;
20
+ readonly LAST_ENDPOINT: 12308;
21
+ readonly TCP_KEEPALIVE: 12309;
22
+ readonly TCP_KEEPALIVE_CNT: 12310;
23
+ readonly TCP_KEEPALIVE_IDLE: 12311;
24
+ readonly TCP_KEEPALIVE_INTVL: 12312;
25
+ readonly IMMEDIATE: 12313;
26
+ readonly IPV6: 12314;
27
+ readonly CONFLATE: 12315;
28
+ readonly TOS: 12316;
29
+ readonly HANDSHAKE_IVL: 12317;
30
+ readonly BLOCKY: 12318;
31
+ readonly INVERT_MATCHING: 12320;
32
+ readonly CONNECT_TIMEOUT: 12324;
33
+ readonly TCP_MAXRT: 12325;
34
+ readonly MULTICAST_MAXTPDU: 12326;
35
+ readonly BINDTODEVICE: 12327;
36
+ readonly TLS_CERT: 12328;
37
+ readonly TLS_KEY: 12329;
38
+ readonly TLS_CA: 12330;
39
+ readonly TLS_VERIFY: 12331;
40
+ readonly TLS_REQUIRE_CLIENT_CERT: 12332;
41
+ readonly TLS_HOSTNAME: 12333;
42
+ readonly TLS_TRUST_SYSTEM: 12334;
43
+ readonly TLS_PASSWORD: 12335;
44
+ readonly ZMP_METADATA: 12336;
45
+ readonly TCP_NODELAY: 12337;
46
+ readonly RID_DUPLICATE_POLICY: 12339;
47
+ readonly SUBMIT_RETRY_MODE: 12343;
48
+ readonly SUBMIT_RETRY_TIMEOUT: 12344;
49
+ readonly SUBMIT_RETRY_ATTEMPTS: 12345;
50
+ readonly PENDING_MAX_MSGS: 12346;
51
+ readonly PENDING_MAX_BYTES: 12347;
52
+ readonly ROUTER_MANDATORY: 12545;
53
+ readonly PROBE_ROUTER: 12547;
54
+ readonly CONNECT_ROUTING_ID: 12548;
55
+ readonly ROUTER_REQUEST_TIMEOUT_MS: 12549;
56
+ readonly ROUTER_WEIGHT: 12550;
57
+ readonly DEALER_PROBE: 12801;
58
+ readonly DEALER_REQUEST_TIMEOUT_MS: 12802;
59
+ readonly DEALER_WEIGHT: 12803;
60
+ readonly XPUB_VERBOSE: 13057;
61
+ readonly XPUB_VERBOSER: 13058;
62
+ readonly XPUB_MANUAL: 13059;
63
+ readonly XPUB_MANUAL_LAST_VALUE: 13060;
64
+ readonly XPUB_NODROP: 13061;
65
+ readonly XPUB_WELCOME_MSG: 13062;
66
+ readonly XPUB_TOPICS_COUNT: 13063;
67
+ readonly XPUB_APPROVE_SUBSCRIBE: 13064;
68
+ readonly XPUB_REJECT_SUBSCRIBE: 13065;
69
+ readonly SUB_TOPICS_COUNT: 13312;
70
+ readonly STREAM_NOTIFY: 13569;
71
+ readonly STREAM_RECV_MODE: 13570;
72
+ }>;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ // SPDX-License-Identifier: MPL-2.0
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.SocketOption = void 0;
5
+ exports.SocketOption = Object.freeze({
6
+ AFFINITY: 0x3001, RATE: 0x3003, RECOVERY_IVL: 0x3004,
7
+ SNDBUF: 0x3005, RCVBUF: 0x3006, FD: 0x3007, EVENTS: 0x3008,
8
+ TYPE: 0x3009, LINGER: 0x300A, RECONNECT_IVL: 0x300B,
9
+ BACKLOG: 0x300C, RECONNECT_IVL_MAX: 0x300D, MAXMSGSIZE: 0x300E,
10
+ SNDHWM: 0x300F, RCVHWM: 0x3010, MULTICAST_HOPS: 0x3011,
11
+ RCVTIMEO: 0x3012, SNDTIMEO: 0x3013, LAST_ENDPOINT: 0x3014,
12
+ TCP_KEEPALIVE: 0x3015, TCP_KEEPALIVE_CNT: 0x3016,
13
+ TCP_KEEPALIVE_IDLE: 0x3017, TCP_KEEPALIVE_INTVL: 0x3018,
14
+ IMMEDIATE: 0x3019, IPV6: 0x301A, CONFLATE: 0x301B,
15
+ TOS: 0x301C, HANDSHAKE_IVL: 0x301D, BLOCKY: 0x301E,
16
+ INVERT_MATCHING: 0x3020,
17
+ CONNECT_TIMEOUT: 0x3024, TCP_MAXRT: 0x3025,
18
+ MULTICAST_MAXTPDU: 0x3026, BINDTODEVICE: 0x3027,
19
+ TLS_CERT: 0x3028, TLS_KEY: 0x3029, TLS_CA: 0x302A,
20
+ TLS_VERIFY: 0x302B, TLS_REQUIRE_CLIENT_CERT: 0x302C,
21
+ TLS_HOSTNAME: 0x302D, TLS_TRUST_SYSTEM: 0x302E,
22
+ TLS_PASSWORD: 0x302F, ZMP_METADATA: 0x3030,
23
+ TCP_NODELAY: 0x3031, RID_DUPLICATE_POLICY: 0x3033,
24
+ SUBMIT_RETRY_MODE: 0x3037,
25
+ SUBMIT_RETRY_TIMEOUT: 0x3038,
26
+ SUBMIT_RETRY_ATTEMPTS: 0x3039,
27
+ // ABI-stable legacy values. Core stores them but SEND and REQUEST ignore them.
28
+ PENDING_MAX_MSGS: 0x303A,
29
+ PENDING_MAX_BYTES: 0x303B,
30
+ ROUTER_MANDATORY: 0x3101,
31
+ PROBE_ROUTER: 0x3103, CONNECT_ROUTING_ID: 0x3104,
32
+ ROUTER_REQUEST_TIMEOUT_MS: 0x3105, ROUTER_WEIGHT: 0x3106,
33
+ DEALER_PROBE: 0x3201, DEALER_REQUEST_TIMEOUT_MS: 0x3202,
34
+ DEALER_WEIGHT: 0x3203,
35
+ XPUB_VERBOSE: 0x3301, XPUB_VERBOSER: 0x3302, XPUB_MANUAL: 0x3303,
36
+ XPUB_MANUAL_LAST_VALUE: 0x3304, XPUB_NODROP: 0x3305,
37
+ XPUB_WELCOME_MSG: 0x3306, XPUB_TOPICS_COUNT: 0x3307,
38
+ XPUB_APPROVE_SUBSCRIBE: 0x3308, XPUB_REJECT_SUBSCRIBE: 0x3309,
39
+ SUB_TOPICS_COUNT: 0x3400,
40
+ STREAM_NOTIFY: 0x3501, STREAM_RECV_MODE: 0x3502
41
+ });
@@ -0,0 +1 @@
1
+ export declare function validateCString(value: string, name: string, maxLength?: number): string;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ // SPDX-License-Identifier: MPL-2.0
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.validateCString = validateCString;
5
+ const FIXED_C_STRING_MAX_LENGTH = 255;
6
+ function validateCString(value, name, maxLength = FIXED_C_STRING_MAX_LENGTH) {
7
+ if (typeof value !== 'string') {
8
+ throw new TypeError(`${name} must be a string`);
9
+ }
10
+ if (value.includes('\0')) {
11
+ throw new RangeError(`${name} must not contain embedded null characters`);
12
+ }
13
+ if (Buffer.byteLength(value, 'utf8') > maxLength) {
14
+ throw new RangeError(`${name} must be at most ${maxLength} bytes`);
15
+ }
16
+ return value;
17
+ }
@@ -0,0 +1,6 @@
1
+ import type { BaseSocket, Context } from '../contracts';
2
+ import type { RuntimeContext } from './core/context';
3
+ import type { RuntimeBaseSocket } from './sockets';
4
+ export declare function asRuntimeContext(ctx: Context): RuntimeContext;
5
+ export declare function asRuntimeSocket(socket: BaseSocket): RuntimeBaseSocket;
6
+ export declare function asPublicContract<T>(value: unknown): T;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ // SPDX-License-Identifier: MPL-2.0
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.asRuntimeContext = asRuntimeContext;
5
+ exports.asRuntimeSocket = asRuntimeSocket;
6
+ exports.asPublicContract = asPublicContract;
7
+ const native_handle_1 = require("./handles/native_handle");
8
+ function assertRuntimeHandle(value, name) {
9
+ if (!(value instanceof native_handle_1.NativeHandle)) {
10
+ throw new TypeError(`${name} must be created by this zlink package`);
11
+ }
12
+ }
13
+ function asRuntimeContext(ctx) {
14
+ assertRuntimeHandle(ctx, 'context');
15
+ return ctx;
16
+ }
17
+ function asRuntimeSocket(socket) {
18
+ assertRuntimeHandle(socket, 'socket');
19
+ return socket;
20
+ }
21
+ function asPublicContract(value) {
22
+ return value;
23
+ }
@@ -0,0 +1,16 @@
1
+ import { RoutingId } from '../../contracts';
2
+ import type { Received, RequestOperation, SendOperation } from '../../contracts/messaging';
3
+ import { RecvFlags } from '../../contracts/sockets/socket_constants';
4
+ import type { RuntimeContext as Context } from '../core/context';
5
+ import { ReceiveSocket } from './socket_operations';
6
+ import { DealerSocketOptions } from './socket_options';
7
+ export declare class DealerSocket extends ReceiveSocket {
8
+ readonly options: DealerSocketOptions;
9
+ constructor(ctx: Context);
10
+ setRoutingId(routingId: RoutingId): void;
11
+ getRoutingId(): RoutingId;
12
+ send(): SendOperation;
13
+ request(): RequestOperation;
14
+ recv(result: Received, flags?: RecvFlags): boolean;
15
+ private resolveRequestTimeout;
16
+ }
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ // SPDX-License-Identifier: MPL-2.0
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.DealerSocket = void 0;
5
+ const contracts_1 = require("../../contracts");
6
+ const socket_constants_1 = require("../../contracts/sockets/socket_constants");
7
+ const routing_id_1 = require("../core/routing_id");
8
+ const native_errors_1 = require("../errors/native_errors");
9
+ const native_handle_1 = require("../handles/native_handle");
10
+ const completion_owner_1 = require("../messaging/completion_owner");
11
+ const message_materializer_1 = require("../messaging/message_materializer");
12
+ const native_1 = require("../native/native");
13
+ const socket_operations_1 = require("./socket_operations");
14
+ const socket_options_1 = require("./socket_options");
15
+ const native = (0, native_1.requireNative)();
16
+ class DealerSocket extends socket_operations_1.ReceiveSocket {
17
+ options;
18
+ constructor(ctx) {
19
+ super(ctx, socket_constants_1.SocketType.DEALER);
20
+ this.options = socket_options_1.DealerSocketOptions.create(this);
21
+ }
22
+ setRoutingId(routingId) {
23
+ const normalized = (0, routing_id_1.normalizeRoutingId)(routingId);
24
+ (0, native_errors_1.configCall)('routing id set failed', () => native.handleSetRoutingId((0, native_handle_1.getNativeHandle)(this), normalized));
25
+ }
26
+ getRoutingId() {
27
+ return contracts_1.RoutingId.from((0, native_errors_1.configCall)('routing id get failed', () => native.handleGetRoutingId((0, native_handle_1.getNativeHandle)(this))));
28
+ }
29
+ send() {
30
+ return new socket_operations_1.RuntimeSendOperation((parts) => (0, completion_owner_1.completionOwnerOf)(this).submitSend(parts, null), (parts) => (0, completion_owner_1.completionOwnerOf)(this).sendSync(parts, null));
31
+ }
32
+ request() {
33
+ return new socket_operations_1.RuntimeRequestOperation((parts, timeoutMs) => (0, completion_owner_1.completionOwnerOf)(this).submitRequest(parts, null, this.resolveRequestTimeout(timeoutMs)), (parts, timeoutMs) => (0, completion_owner_1.completionOwnerOf)(this).requestSync(parts, null, this.resolveRequestTimeout(timeoutMs)));
34
+ }
35
+ recv(result, flags = socket_constants_1.RecvFlags.None) {
36
+ let raw;
37
+ try {
38
+ raw = ((flags | 0) & (socket_constants_1.RecvFlags.DontWait | 0))
39
+ ? native.socketRecvMessageNoWait((0, native_handle_1.getNativeHandle)(this))
40
+ : native.socketRecvMessage((0, native_handle_1.getNativeHandle)(this), flags | 0);
41
+ }
42
+ catch (error) {
43
+ throw (0, native_errors_1.recvNativeError)(error, flags, 'recv failed');
44
+ }
45
+ if (raw == null)
46
+ return false;
47
+ (0, message_materializer_1.materializeReceivedInto)(result, raw);
48
+ return true;
49
+ }
50
+ resolveRequestTimeout(timeoutMs) {
51
+ return timeoutMs === 0
52
+ ? (this.options.requestTimeout === 0 ? 5_000 : this.options.requestTimeout)
53
+ : timeoutMs;
54
+ }
55
+ }
56
+ exports.DealerSocket = DealerSocket;
@@ -0,0 +1,19 @@
1
+ import type { PairSocket } from './pair_socket';
2
+ import type { PubSocket } from './pub_socket';
3
+ import type { XPubSocket } from './xpub_socket';
4
+ import type { SubSocket } from './sub_socket';
5
+ import type { XSubSocket } from './xsub_socket';
6
+ import type { DealerSocket } from './dealer_socket';
7
+ import type { RouterSocket } from './router_socket';
8
+ import type { StreamSocket } from './stream_socket';
9
+ export { CommonSocketOptions as RuntimeCommonSocketOptions, DealerSocketOptions as RuntimeDealerSocketOptions, PubSocketOptions as RuntimePubSocketOptions, RouterSocketOptions as RuntimeRouterSocketOptions, StreamSocketOptions as RuntimeStreamSocketOptions, SubSocketOptions as RuntimeSubSocketOptions, } from './socket_options';
10
+ export { PairSocket as RuntimePairSocket } from './pair_socket';
11
+ export { PubSocket as RuntimePubSocket } from './pub_socket';
12
+ export { XPubSocket as RuntimeXPubSocket } from './xpub_socket';
13
+ export { SubSocket as RuntimeSubSocket } from './sub_socket';
14
+ export { XSubSocket as RuntimeXSubSocket } from './xsub_socket';
15
+ export { DealerSocket as RuntimeDealerSocket } from './dealer_socket';
16
+ export { RouterSocket as RuntimeRouterSocket } from './router_socket';
17
+ export { StreamSocket as RuntimeStreamSocket } from './stream_socket';
18
+ export type BaseSocket = PairSocket | PubSocket | XPubSocket | SubSocket | XSubSocket | DealerSocket | RouterSocket | StreamSocket;
19
+ export type { BaseSocket as RuntimeBaseSocket };