rclnodejs 1.6.0 → 1.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 (84) hide show
  1. package/binding.gyp +2 -0
  2. package/index.js +152 -0
  3. package/lib/action/client.js +109 -10
  4. package/lib/action/deferred.js +8 -2
  5. package/lib/action/server.js +10 -1
  6. package/lib/action/uuid.js +4 -1
  7. package/lib/client.js +218 -4
  8. package/lib/clock.js +182 -1
  9. package/lib/clock_change.js +49 -0
  10. package/lib/clock_event.js +88 -0
  11. package/lib/context.js +12 -2
  12. package/lib/duration.js +37 -12
  13. package/lib/errors.js +621 -0
  14. package/lib/event_handler.js +21 -4
  15. package/lib/interface_loader.js +52 -12
  16. package/lib/lifecycle.js +8 -2
  17. package/lib/logging.js +90 -3
  18. package/lib/message_introspector.js +123 -0
  19. package/lib/message_serialization.js +10 -2
  20. package/lib/message_validation.js +512 -0
  21. package/lib/native_loader.js +9 -4
  22. package/lib/node.js +403 -50
  23. package/lib/node_options.js +40 -1
  24. package/lib/observable_subscription.js +105 -0
  25. package/lib/parameter.js +172 -35
  26. package/lib/parameter_client.js +506 -0
  27. package/lib/parameter_watcher.js +309 -0
  28. package/lib/publisher.js +56 -1
  29. package/lib/qos.js +79 -5
  30. package/lib/rate.js +6 -1
  31. package/lib/serialization.js +7 -2
  32. package/lib/subscription.js +8 -0
  33. package/lib/time.js +136 -21
  34. package/lib/time_source.js +13 -4
  35. package/lib/timer.js +42 -0
  36. package/lib/utils.js +27 -1
  37. package/lib/validator.js +74 -19
  38. package/package.json +4 -2
  39. package/prebuilds/linux-arm64/humble-jammy-arm64-rclnodejs.node +0 -0
  40. package/prebuilds/linux-arm64/jazzy-noble-arm64-rclnodejs.node +0 -0
  41. package/prebuilds/linux-arm64/kilted-noble-arm64-rclnodejs.node +0 -0
  42. package/prebuilds/linux-x64/humble-jammy-x64-rclnodejs.node +0 -0
  43. package/prebuilds/linux-x64/jazzy-noble-x64-rclnodejs.node +0 -0
  44. package/prebuilds/linux-x64/kilted-noble-x64-rclnodejs.node +0 -0
  45. package/rosidl_gen/message_translator.js +0 -61
  46. package/scripts/config.js +1 -0
  47. package/src/addon.cpp +2 -0
  48. package/src/clock_event.cpp +268 -0
  49. package/src/clock_event.hpp +62 -0
  50. package/src/macros.h +2 -4
  51. package/src/rcl_action_server_bindings.cpp +21 -3
  52. package/src/rcl_bindings.cpp +59 -0
  53. package/src/rcl_context_bindings.cpp +5 -0
  54. package/src/rcl_graph_bindings.cpp +73 -0
  55. package/src/rcl_logging_bindings.cpp +158 -0
  56. package/src/rcl_node_bindings.cpp +14 -2
  57. package/src/rcl_publisher_bindings.cpp +12 -0
  58. package/src/rcl_service_bindings.cpp +7 -6
  59. package/src/rcl_subscription_bindings.cpp +51 -14
  60. package/src/rcl_time_point_bindings.cpp +135 -0
  61. package/src/rcl_timer_bindings.cpp +140 -0
  62. package/src/rcl_utilities.cpp +103 -2
  63. package/src/rcl_utilities.h +7 -1
  64. package/types/action_client.d.ts +27 -2
  65. package/types/base.d.ts +6 -0
  66. package/types/client.d.ts +65 -1
  67. package/types/clock.d.ts +86 -0
  68. package/types/clock_change.d.ts +27 -0
  69. package/types/clock_event.d.ts +51 -0
  70. package/types/errors.d.ts +496 -0
  71. package/types/index.d.ts +10 -0
  72. package/types/logging.d.ts +32 -0
  73. package/types/message_introspector.d.ts +75 -0
  74. package/types/message_validation.d.ts +183 -0
  75. package/types/node.d.ts +107 -0
  76. package/types/node_options.d.ts +13 -0
  77. package/types/observable_subscription.d.ts +39 -0
  78. package/types/parameter_client.d.ts +252 -0
  79. package/types/parameter_watcher.d.ts +104 -0
  80. package/types/publisher.d.ts +28 -1
  81. package/types/qos.d.ts +18 -0
  82. package/types/subscription.d.ts +6 -0
  83. package/types/timer.d.ts +18 -0
  84. package/types/validator.d.ts +86 -0
package/lib/duration.js CHANGED
@@ -15,6 +15,7 @@
15
15
  'use strict';
16
16
 
17
17
  const rclnodejs = require('./native_loader.js');
18
+ const { TypeValidationError, RangeValidationError } = require('./errors.js');
18
19
  const S_TO_NS = 10n ** 9n;
19
20
 
20
21
  /**
@@ -29,17 +30,31 @@ class Duration {
29
30
  */
30
31
  constructor(seconds = 0n, nanoseconds = 0n) {
31
32
  if (typeof seconds !== 'bigint') {
32
- throw new TypeError('Invalid argument of seconds');
33
+ throw new TypeValidationError('seconds', seconds, 'bigint', {
34
+ entityType: 'duration',
35
+ });
33
36
  }
34
37
 
35
38
  if (typeof nanoseconds !== 'bigint') {
36
- throw new TypeError('Invalid argument of nanoseconds');
39
+ throw new TypeValidationError('nanoseconds', nanoseconds, 'bigint', {
40
+ entityType: 'duration',
41
+ });
37
42
  }
38
43
 
39
44
  const total = seconds * S_TO_NS + nanoseconds;
40
45
  if (total >= 2n ** 63n) {
41
- throw new RangeError(
42
- 'Total nanoseconds value is too large to store in C time point.'
46
+ throw new RangeValidationError(
47
+ 'total nanoseconds',
48
+ total,
49
+ '< 2^63 (max C duration)',
50
+ {
51
+ entityType: 'duration',
52
+ details: {
53
+ seconds: seconds,
54
+ nanoseconds: nanoseconds,
55
+ total: total,
56
+ },
57
+ }
43
58
  );
44
59
  }
45
60
 
@@ -67,9 +82,9 @@ class Duration {
67
82
  if (other instanceof Duration) {
68
83
  return this._nanoseconds === other.nanoseconds;
69
84
  }
70
- throw new TypeError(
71
- `Can't compare duration with object of type: ${other.constructor.name}`
72
- );
85
+ throw new TypeValidationError('other', other, 'Duration', {
86
+ entityType: 'duration',
87
+ });
73
88
  }
74
89
 
75
90
  /**
@@ -81,7 +96,9 @@ class Duration {
81
96
  if (other instanceof Duration) {
82
97
  return this._nanoseconds !== other.nanoseconds;
83
98
  }
84
- throw new TypeError('Invalid argument');
99
+ throw new TypeValidationError('other', other, 'Duration', {
100
+ entityType: 'duration',
101
+ });
85
102
  }
86
103
 
87
104
  /**
@@ -93,7 +110,9 @@ class Duration {
93
110
  if (other instanceof Duration) {
94
111
  return this._nanoseconds < other.nanoseconds;
95
112
  }
96
- throw new TypeError('Invalid argument');
113
+ throw new TypeValidationError('other', other, 'Duration', {
114
+ entityType: 'duration',
115
+ });
97
116
  }
98
117
 
99
118
  /**
@@ -105,7 +124,9 @@ class Duration {
105
124
  if (other instanceof Duration) {
106
125
  return this._nanoseconds <= other.nanoseconds;
107
126
  }
108
- throw new TypeError('Invalid argument');
127
+ throw new TypeValidationError('other', other, 'Duration', {
128
+ entityType: 'duration',
129
+ });
109
130
  }
110
131
 
111
132
  /**
@@ -117,7 +138,9 @@ class Duration {
117
138
  if (other instanceof Duration) {
118
139
  return this._nanoseconds > other.nanoseconds;
119
140
  }
120
- throw new TypeError('Invalid argument');
141
+ throw new TypeValidationError('other', other, 'Duration', {
142
+ entityType: 'duration',
143
+ });
121
144
  }
122
145
 
123
146
  /**
@@ -129,7 +152,9 @@ class Duration {
129
152
  if (other instanceof Duration) {
130
153
  return this._nanoseconds >= other.nanoseconds;
131
154
  }
132
- throw new TypeError('Invalid argument');
155
+ throw new TypeValidationError('other', other, 'Duration', {
156
+ entityType: 'duration',
157
+ });
133
158
  }
134
159
  }
135
160