rclnodejs 1.5.1 → 1.6.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 (64) hide show
  1. package/README.md +25 -2
  2. package/binding.gyp +2 -0
  3. package/index.js +21 -4
  4. package/lib/action/client.js +1 -1
  5. package/lib/action/graph.js +1 -1
  6. package/lib/action/server.js +1 -1
  7. package/lib/action/server_goal_handle.js +1 -1
  8. package/lib/client.js +1 -1
  9. package/lib/clock.js +1 -1
  10. package/lib/context.js +1 -1
  11. package/lib/duration.js +1 -1
  12. package/lib/event_handler.js +1 -1
  13. package/lib/guard_condition.js +1 -1
  14. package/lib/lifecycle.js +1 -1
  15. package/lib/lifecycle_publisher.js +1 -1
  16. package/lib/logging.js +1 -1
  17. package/lib/message_serialization.js +171 -0
  18. package/lib/native_loader.js +173 -0
  19. package/lib/node.js +16 -1
  20. package/lib/parameter.js +4 -10
  21. package/lib/publisher.js +1 -1
  22. package/lib/serialization.js +1 -1
  23. package/lib/service.js +1 -1
  24. package/lib/subscription.js +17 -2
  25. package/lib/time.js +1 -1
  26. package/lib/time_source.js +1 -1
  27. package/lib/timer.js +1 -1
  28. package/lib/type_description_service.js +1 -1
  29. package/lib/utils.js +324 -0
  30. package/lib/validator.js +1 -1
  31. package/package.json +14 -18
  32. package/prebuilds/linux-arm64/humble-jammy-arm64-rclnodejs.node +0 -0
  33. package/prebuilds/linux-arm64/jazzy-noble-arm64-rclnodejs.node +0 -0
  34. package/prebuilds/linux-arm64/kilted-noble-arm64-rclnodejs.node +0 -0
  35. package/prebuilds/linux-x64/humble-jammy-x64-rclnodejs.node +0 -0
  36. package/prebuilds/linux-x64/jazzy-noble-x64-rclnodejs.node +0 -0
  37. package/prebuilds/linux-x64/kilted-noble-x64-rclnodejs.node +0 -0
  38. package/rosidl_convertor/idl_convertor.js +3 -2
  39. package/rosidl_gen/deallocator.js +1 -1
  40. package/rosidl_gen/generate_worker.js +1 -1
  41. package/rosidl_gen/generator.json +1 -1
  42. package/rosidl_gen/idl_generator.js +11 -24
  43. package/rosidl_gen/index.js +1 -1
  44. package/rosidl_gen/primitive_types.js +2 -2
  45. package/rosidl_gen/templates/action-template.js +68 -0
  46. package/rosidl_gen/templates/message-template.js +1113 -0
  47. package/rosidl_gen/templates/service-event-template.js +31 -0
  48. package/rosidl_gen/templates/service-template.js +44 -0
  49. package/rosidl_parser/rosidl_parser.js +2 -2
  50. package/scripts/install.js +113 -0
  51. package/scripts/tag_prebuilds.js +70 -0
  52. package/src/addon.cpp +3 -0
  53. package/third_party/ref-napi/index.js +15 -0
  54. package/third_party/ref-napi/lib/ref.js +1696 -0
  55. package/third_party/ref-napi/src/ref_napi_bindings.cpp +736 -0
  56. package/third_party/ref-napi/src/ref_napi_bindings.h +26 -0
  57. package/types/index.d.ts +17 -0
  58. package/types/node.d.ts +16 -1
  59. package/rosidl_gen/templates/CMakeLists.dot +0 -40
  60. package/rosidl_gen/templates/action.dot +0 -50
  61. package/rosidl_gen/templates/message.dot +0 -851
  62. package/rosidl_gen/templates/package.dot +0 -16
  63. package/rosidl_gen/templates/service.dot +0 -26
  64. package/rosidl_gen/templates/service_event.dot +0 -10
@@ -0,0 +1,26 @@
1
+ // Copyright (c) 2025, The Robot Web Tools Contributors
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ #ifndef THIRD_PARTY_REF_NAPI_SRC_REF_NAPI_BINDINGS_H_
16
+ #define THIRD_PARTY_REF_NAPI_SRC_REF_NAPI_BINDINGS_H_
17
+
18
+ #include <napi.h>
19
+
20
+ namespace rclnodejs {
21
+
22
+ Napi::Object InitRefNapi(Napi::Env env);
23
+
24
+ } // namespace rclnodejs
25
+
26
+ #endif // THIRD_PARTY_REF_NAPI_SRC_REF_NAPI_BINDINGS_H_
package/types/index.d.ts CHANGED
@@ -235,4 +235,21 @@ declare module 'rclnodejs' {
235
235
  launchFile: string,
236
236
  args: string[]
237
237
  ): Promise<{ process: ChildProcess }>;
238
+
239
+ /**
240
+ * Convert a message object to be JSON-safe by converting TypedArrays to regular arrays
241
+ * and handling BigInt, Infinity, NaN, etc. for JSON serialization.
242
+ * @param obj - The message object to convert
243
+ * @returns A JSON-safe version of the object
244
+ */
245
+ function toJSONSafe(obj: any): any;
246
+
247
+ /**
248
+ * Convert a message object to a JSON string with proper handling of TypedArrays,
249
+ * BigInt, and other non-JSON-serializable values.
250
+ * @param obj - The message object to convert
251
+ * @param space - Space parameter for JSON.stringify formatting
252
+ * @returns The JSON string representation
253
+ */
254
+ function toJSONString(obj: any, space?: number): string;
238
255
  }
package/types/node.d.ts CHANGED
@@ -12,6 +12,11 @@ declare module 'rclnodejs' {
12
12
  name: string;
13
13
  };
14
14
 
15
+ /**
16
+ * Valid serialization modes for message conversion
17
+ */
18
+ type SerializationMode = 'default' | 'plain' | 'json';
19
+
15
20
  /**
16
21
  * A filter description similar to a SQL WHERE clause that limits
17
22
  * the data wanted by a Subscription.
@@ -56,6 +61,15 @@ declare module 'rclnodejs' {
56
61
  */
57
62
  isRaw?: boolean;
58
63
 
64
+ /**
65
+ * Controls message serialization format, default: 'default'.
66
+ *
67
+ * - 'default': Use native rclnodejs behavior (respects enableTypedArray setting)
68
+ * - 'plain': Convert TypedArrays to regular arrays
69
+ * - 'json': Fully JSON-safe (handles TypedArrays, BigInt, etc.)
70
+ */
71
+ serializationMode?: SerializationMode;
72
+
59
73
  /**
60
74
  * ROS Middleware "quality of service" setting, default: QoS.profileDefault.
61
75
  */
@@ -76,7 +90,8 @@ declare module 'rclnodejs' {
76
90
  * enableTypedArray: true,
77
91
  * qos: QoS.profileDefault,
78
92
  * isRaw: false,
79
- * contentFilter: undefined
93
+ * contentFilter: undefined,
94
+ * serializationMode: 'default'
80
95
  * }
81
96
  * ```
82
97
  */
@@ -1,40 +0,0 @@
1
- # This file is automatically generated by Intel rclnodejs
2
- #
3
- # *** DO NOT EDIT directly
4
-
5
- cmake_minimum_required(VERSION 3.5)
6
-
7
- project({{=it.projectName}})
8
-
9
- # Default to C++14
10
- if(NOT CMAKE_CXX_STANDARD)
11
- set(CMAKE_CXX_STANDARD 14)
12
- endif()
13
- if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
14
- # we dont use add_compile_options with pedantic in message packages
15
- # because the Python C extensions dont comply with it
16
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic")
17
- endif()
18
-
19
- {{~ it.dependencies :dependency}}
20
- find_package({{=dependency}} REQUIRED)
21
- {{~}}
22
- find_package(actionlib_msgs REQUIRED)
23
- find_package(ament_cmake REQUIRED)
24
- find_package(rosidl_default_generators REQUIRED)
25
-
26
- set(msg_files
27
- {{~ it.msgFiles :msgFile}}
28
- "msg/{{=msgFile}}.msg"
29
- {{~}}
30
- )
31
-
32
- rosidl_generate_interfaces(${PROJECT_NAME}
33
- ${msg_files}
34
- {{~ it.dependencies :dependency}}
35
- DEPENDENCIES {{=dependency}}
36
- {{~}}
37
- DEPENDENCIES actionlib_msgs
38
- )
39
-
40
- ament_package()
@@ -1,50 +0,0 @@
1
- // This file is automatically generated by rclnodejs
2
- //
3
- // *** DO NOT EDIT directly
4
- //
5
-
6
- 'use strict';
7
-
8
- {{
9
- const className = it.actionInfo.pkgName + '__' + it.actionInfo.subFolder + '__' + it.actionInfo.interfaceName;
10
- }}
11
-
12
- class {{=className}} {
13
- static get Goal() {
14
- return require('./{{=className}}_Goal.js');
15
- }
16
-
17
- static get Result() {
18
- return require('./{{=className}}_Result.js');
19
- }
20
-
21
- static get Feedback() {
22
- return require('./{{=className}}_Feedback.js');
23
- }
24
-
25
- static get impl() {
26
- return {
27
- get SendGoalService() {
28
- return require('./{{=className}}_SendGoal.js');
29
- },
30
- get GetResultService() {
31
- return require('./{{=className}}_GetResult.js');
32
- },
33
- get FeedbackMessage() {
34
- return require('./{{=className}}_FeedbackMessage.js');
35
- },
36
- get CancelGoal() {
37
- return require('../action_msgs/action_msgs__srv__CancelGoal.js');
38
- },
39
- get GoalStatusArray() {
40
- return require('../action_msgs/action_msgs__msg__GoalStatusArray.js');
41
- }
42
- };
43
- }
44
-
45
- static type() {
46
- return {pkgName: '{{=it.actionInfo.pkgName}}', subFolder: '{{=it.actionInfo.subFolder}}', interfaceName: '{{=it.actionInfo.interfaceName}}'};
47
- }
48
- }
49
-
50
- module.exports = {{=className}};