rclnodejs 0.31.0 → 0.32.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 (50) hide show
  1. package/README.md +1 -1
  2. package/eslint.config.mjs +65 -0
  3. package/lib/action/client.js +1 -1
  4. package/lib/clock_type.js +0 -2
  5. package/lib/distro.js +1 -1
  6. package/lib/interface_loader.js +1 -2
  7. package/lib/lifecycle.js +0 -5
  8. package/lib/lifecycle_publisher.js +1 -1
  9. package/lib/node.js +3 -3
  10. package/lib/parameter.js +6 -9
  11. package/lib/parameter_service.js +1 -2
  12. package/lib/publisher.js +1 -1
  13. package/lib/qos.js +0 -2
  14. package/lib/rate.js +0 -1
  15. package/lib/rmw.js +12 -0
  16. package/lib/time_source.js +0 -1
  17. package/package.json +20 -21
  18. package/rosidl_gen/action_msgs.js +0 -1
  19. package/rosidl_gen/filter.js +14 -1
  20. package/rosidl_gen/generator.json +1 -1
  21. package/rosidl_gen/index.js +0 -1
  22. package/rosidl_gen/message_translator.js +2 -9
  23. package/rosidl_gen/packages.js +1 -3
  24. package/rosidl_gen/primitive_types.js +0 -4
  25. package/rosidl_gen/templates/message.dot +4 -0
  26. package/rostsd_gen/index.js +0 -3
  27. package/scripts/cpplint.js +3 -4
  28. package/scripts/generate_messages.js +1 -1
  29. package/scripts/npmjs-readme.md +1 -1
  30. package/scripts/ros_distro.js +12 -0
  31. package/scripts/run_test.js +0 -2
  32. package/src/executor.hpp +3 -3
  33. package/src/handle_manager.hpp +3 -3
  34. package/src/macros.hpp +3 -3
  35. package/src/rcl_action_bindings.hpp +3 -3
  36. package/src/rcl_bindings.cpp +7 -7
  37. package/src/rcl_bindings.hpp +3 -3
  38. package/src/rcl_handle.hpp +3 -3
  39. package/src/rcl_lifecycle_bindings.hpp +3 -3
  40. package/src/rcl_utilities.hpp +3 -3
  41. package/src/shadow_node.hpp +3 -3
  42. package/types/action_client.d.ts +0 -1
  43. package/types/action_server.d.ts +0 -1
  44. package/types/base.d.ts +27 -28
  45. package/types/index.d.ts +1 -2
  46. package/types/lifecycle.d.ts +1 -3
  47. package/types/node.d.ts +0 -1
  48. package/types/parameter.d.ts +0 -2
  49. package/types/publisher.d.ts +0 -1
  50. package/types/time.d.ts +1 -5
package/README.md CHANGED
@@ -45,7 +45,7 @@ npm i rclnodejs@x.y.z
45
45
 
46
46
  | RCLNODEJS Version | Compatible ROS 2 LTS |
47
47
  | :------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------: |
48
- | latest version (currently [v0.31.0](https://github.com/RobotWebTools/rclnodejs/tree/0.31.0)) | [Humble](https://github.com/RobotWebTools/rclnodejs/tree/humble-hawksbill)<br>[Jazzy](https://github.com/RobotWebTools/rclnodejs/tree/jazzy) |
48
+ | latest version (currently [v0.32.0](https://github.com/RobotWebTools/rclnodejs/tree/0.32.0)) | [Humble](https://github.com/RobotWebTools/rclnodejs/tree/humble-hawksbill)<br>[Jazzy](https://github.com/RobotWebTools/rclnodejs/tree/jazzy) |
49
49
 
50
50
  ## Documentation
51
51
 
@@ -0,0 +1,65 @@
1
+ import typescriptEslint from "@typescript-eslint/eslint-plugin";
2
+ import prettier from "eslint-plugin-prettier";
3
+ import globals from "globals";
4
+ import tsParser from "@typescript-eslint/parser";
5
+ import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
6
+ import js from "@eslint/js";
7
+
8
+ export default [
9
+ {
10
+ ignores: [
11
+ "eslint.config.mjs",
12
+ "types/interfaces.d.ts",
13
+ "test/types/index.test-d.ts",
14
+ "**/generated/",
15
+ "**/scripts/",
16
+ "**/benchmark/",
17
+ "**/docs/",
18
+ "**/electron_demo/",
19
+ ],
20
+ },
21
+ {
22
+ ...js.configs.recommended,
23
+ files: ["lib/**/*.js", "index.js"],
24
+ },
25
+ {
26
+ rules: {
27
+ 'no-dupe-class-members': 'off',
28
+ },
29
+ },
30
+ {
31
+ plugins: {
32
+ "@typescript-eslint": typescriptEslint,
33
+ },
34
+ languageOptions: {
35
+ globals: {
36
+ ...globals.node,
37
+ },
38
+ parser: tsParser,
39
+ ecmaVersion: "latest",
40
+ sourceType: "module",
41
+ },
42
+ files: ['types/*.d.ts'],
43
+ rules: {
44
+ ...typescriptEslint.configs.recommended.rules,
45
+ "@typescript-eslint/no-explicit-any": "off",
46
+ },
47
+ },
48
+ {
49
+ plugins: {
50
+ prettier,
51
+ },
52
+ languageOptions: {
53
+ globals: {
54
+ ...globals.node,
55
+ },
56
+ ecmaVersion: "latest",
57
+ sourceType: "commonjs",
58
+ },
59
+ files: ["lib/**/*.js", "rosidl_parser/**/*.js", "rosidl_gen/**/*.js",
60
+ "rostsd_gen/**/*.js", "test/**/*.js", "example/**/*.js", "index.js"],
61
+ rules: {
62
+ ...eslintPluginPrettierRecommended.rules,
63
+ },
64
+ }
65
+ ];
@@ -172,7 +172,7 @@ class ActionClient extends Entity {
172
172
  goalHandle.status = status;
173
173
 
174
174
  // Remove done handles from the list
175
- // eslint-disable-next-line max-depth
175
+
176
176
  if (
177
177
  status === ActionInterfaces.GoalStatus.STATUS_SUCCEEDED ||
178
178
  status === ActionInterfaces.GoalStatus.STATUS_CANCELED ||
package/lib/clock_type.js CHANGED
@@ -14,8 +14,6 @@
14
14
 
15
15
  'use strict';
16
16
 
17
- /* eslint-disable camelcase */
18
-
19
17
  /**
20
18
  * Enum for ClockType
21
19
  * @readonly
package/lib/distro.js CHANGED
@@ -63,7 +63,7 @@ const DistroUtils = {
63
63
  return process.env.ROS_DISTRO;
64
64
  }
65
65
 
66
- return [...DistroNameIdMap].find(([key, val]) => val == distroId)[0];
66
+ return [...DistroNameIdMap].find(([, val]) => val == distroId)[0];
67
67
  },
68
68
 
69
69
  getKnownDistroNames: function () {
@@ -59,7 +59,6 @@ let interfaceLoader = {
59
59
  // Suppose the name is a package, and traverse the path to collect the IDL files.
60
60
  let packagePath = path.join(generator.generatedRoot, name);
61
61
 
62
- // eslint-disable-next-line
63
62
  let interfaces = fs.readdirSync(packagePath);
64
63
  if (interfaces.length > 0) {
65
64
  return this.loadInterfaceByPath(packagePath, interfaces);
@@ -108,7 +107,7 @@ let interfaceLoader = {
108
107
  packageName,
109
108
  packageName + '__' + type + '__' + messageName + '.js'
110
109
  );
111
- // eslint-disable-next-line
110
+
112
111
  if (fs.existsSync(filePath)) {
113
112
  return require(filePath);
114
113
  }
package/lib/lifecycle.js CHANGED
@@ -588,8 +588,6 @@ class LifecycleNode extends Node {
588
588
  * @throws {Error} If transition is invalid for the current state.
589
589
  */
590
590
  shutdown(callbackReturnValue) {
591
- let state = this.currentState;
592
-
593
591
  return this._changeState(SHUTDOWN_TRANSITION_LABEL, callbackReturnValue);
594
592
  }
595
593
 
@@ -603,7 +601,6 @@ class LifecycleNode extends Node {
603
601
  _onGetState(request, response) {
604
602
  let result = response.template;
605
603
 
606
- // eslint-disable-next-line camelcase
607
604
  result.current_state = this.currentState;
608
605
 
609
606
  response.send(result);
@@ -619,7 +616,6 @@ class LifecycleNode extends Node {
619
616
  _onGetAvailableStates(request, response) {
620
617
  let result = response.template;
621
618
 
622
- // eslint-disable-next-line camelcase
623
619
  result.available_states = this.availableStates;
624
620
 
625
621
  response.send(result);
@@ -634,7 +630,6 @@ class LifecycleNode extends Node {
634
630
  _onGetAvailableTransitions(request, response) {
635
631
  let result = response.template;
636
632
 
637
- // eslint-disable-next-line camelcase
638
633
  result.available_transitions = this.availableTransitions;
639
634
 
640
635
  response.send(result);
@@ -37,7 +37,7 @@ class LifecyclePublisher extends Publisher {
37
37
  * Publish a message only when activated; otherwise do nothing (nop);
38
38
  *
39
39
  * @param {object|Buffer} message - The message to be sent, could be kind of JavaScript message generated from .msg
40
- * or be a Buffer for a raw message.
40
+ * or be a Buffer for a raw message.
41
41
  * @returns {undefined}
42
42
  */
43
43
  publish(message) {
package/lib/node.js CHANGED
@@ -1496,7 +1496,7 @@ class Node extends rclnodejs.ShadowNode {
1496
1496
  );
1497
1497
  }
1498
1498
 
1499
- // publish ParameterEvent
1499
+ // Publish ParameterEvent.
1500
1500
  this._parameterEventPublisher.publish(parameterEvent);
1501
1501
 
1502
1502
  return {
@@ -1549,7 +1549,7 @@ class Node extends rclnodejs.ShadowNode {
1549
1549
  // detect invalid parameter
1550
1550
  try {
1551
1551
  parameter.validate();
1552
- } catch (e) {
1552
+ } catch {
1553
1553
  return {
1554
1554
  successful: false,
1555
1555
  reason: `Invalid ${parameter.name}`,
@@ -1577,7 +1577,7 @@ class Node extends rclnodejs.ShadowNode {
1577
1577
  if (parameter.type != ParameterType.PARAMETER_NOT_SET) {
1578
1578
  try {
1579
1579
  descriptor.validateParameter(parameter);
1580
- } catch (e) {
1580
+ } catch {
1581
1581
  return {
1582
1582
  successful: false,
1583
1583
  reason: `Parameter ${parameter.name} does not readonly`,
package/lib/parameter.js CHANGED
@@ -1,5 +1,3 @@
1
- /* eslint-disable camelcase */
2
-
3
1
  // Copyright (c) 2020 Wayne Parrott. All rights reserved.
4
2
  //
5
3
  // Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,7 +20,6 @@
22
20
  'use strict';
23
21
 
24
22
  const IsClose = require('is-close');
25
- const rclnodejs = require('bindings')('rclnodejs');
26
23
 
27
24
  /**
28
25
  * The plus/minus tolerance for determining number equivalence.
@@ -274,7 +271,6 @@ class ParameterDescriptor {
274
271
  static fromParameter(parameter) {
275
272
  const name = parameter.name;
276
273
  const type = parameter.type;
277
- const value = parameter.value;
278
274
  return new ParameterDescriptor(name, type, 'Created from parameter.');
279
275
  }
280
276
 
@@ -387,7 +383,7 @@ class ParameterDescriptor {
387
383
  return;
388
384
  }
389
385
  if (!(range instanceof Range)) {
390
- throw TypeException('Expected instance of Range.');
386
+ throw TypeError('Expected instance of Range.');
391
387
  }
392
388
  if (!range.isValidType(this.type)) {
393
389
  throw TypeError('Incompatible Range');
@@ -443,14 +439,14 @@ class ParameterDescriptor {
443
439
  // ensure parameter is valid
444
440
  try {
445
441
  parameter.validate();
446
- } catch (e) {
442
+ } catch {
447
443
  throw new TypeError('Parameter is invalid');
448
444
  }
449
445
 
450
446
  // ensure this descriptor is valid
451
447
  try {
452
448
  this.validate();
453
- } catch (e) {
449
+ } catch {
454
450
  throw new Error('Descriptor is invalid.');
455
451
  }
456
452
 
@@ -567,6 +563,7 @@ class Range {
567
563
  * @param {ParameterType} parameterType - The parameter type to test.
568
564
  * @return {boolean} - True if parameterType is compatible; otherwise return false.
569
565
  */
566
+ // eslint-disable-next-line no-unused-vars
570
567
  isValidType(parameterType) {
571
568
  return false;
572
569
  }
@@ -702,6 +699,7 @@ class IntegerRange extends Range {
702
699
  * @param {any} value - The value to infer it's ParameterType
703
700
  * @returns {ParameterType} - The ParameterType that best scribes the value.
704
701
  */
702
+ // eslint-disable-next-line no-unused-vars
705
703
  function parameterTypeFromValue(value) {
706
704
  if (!value) return ParameterType.PARAMETER_NOT_SET;
707
705
  if (typeof value === 'boolean') return ParameterType.PARAMETER_BOOL;
@@ -778,8 +776,7 @@ function validValue(value, type) {
778
776
  case ParameterType.PARAMETER_INTEGER_ARRAY:
779
777
  case ParameterType.PARAMETER_DOUBLE_ARRAY:
780
778
  case ParameterType.PARAMETER_STRING_ARRAY:
781
- const values = value;
782
- result = _validArray(values, type);
779
+ result = _validArray(value, type);
783
780
  break;
784
781
  default:
785
782
  result = false;
@@ -1,4 +1,3 @@
1
- /* eslint-disable max-depth */
2
1
  // Copyright (c) 2020 Wayne Parrott. All rights reserved.
3
2
  //
4
3
  // Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,7 +14,6 @@
15
14
 
16
15
  'use strict';
17
16
 
18
- const rclnodejs = require('bindings')('rclnodejs');
19
17
  const { Parameter, PARAMETER_SEPARATOR } = require('./parameter.js');
20
18
 
21
19
  /**
@@ -27,6 +25,7 @@ const { Parameter, PARAMETER_SEPARATOR } = require('./parameter.js');
27
25
  * rcl_interfaces/srv/GetParameters
28
26
  * rcl_interfaces/srv/SetParameters
29
27
  * rcl_interfaces/srv/SetParametersAtomically
28
+ * rcl_interfaces/srv/GetParameterTypes
30
29
  *
31
30
  * Call start() to begin receiving client request.
32
31
  * All service requests are forwarded to the node this service works for.
package/lib/publisher.js CHANGED
@@ -38,7 +38,7 @@ class Publisher extends Entity {
38
38
  /**
39
39
  * Publish a message
40
40
  * @param {object|Buffer} message - The message to be sent, could be kind of JavaScript message generated from .msg
41
- * or be a Buffer for a raw message.
41
+ * or be a Buffer for a raw message.
42
42
  * @return {undefined}
43
43
  */
44
44
  publish(message) {
package/lib/qos.js CHANGED
@@ -14,8 +14,6 @@
14
14
 
15
15
  'use strict';
16
16
 
17
- /* eslint-disable */
18
-
19
17
  /**
20
18
  * Enum for HistoryPolicy
21
19
  * @readonly
package/lib/rate.js CHANGED
@@ -1,4 +1,3 @@
1
- //
2
1
  // Licensed under the Apache License, Version 2.0 (the "License");
3
2
  // you may not use this file except in compliance with the License.
4
3
  // You may obtain a copy of the License at
package/lib/rmw.js CHANGED
@@ -1,3 +1,15 @@
1
+ // Licensed under the Apache License, Version 2.0 (the "License");
2
+ // you may not use this file except in compliance with the License.
3
+ // You may obtain a copy of the License at
4
+ //
5
+ // http://www.apache.org/licenses/LICENSE-2.0
6
+ //
7
+ // Unless required by applicable law or agreed to in writing, software
8
+ // distributed under the License is distributed on an "AS IS" BASIS,
9
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ // See the License for the specific language governing permissions and
11
+ // limitations under the License.
12
+
1
13
  'use strict';
2
14
 
3
15
  const DistroUtils = require('./distro');
@@ -17,7 +17,6 @@
17
17
  const rclnodejs = require('bindings')('rclnodejs');
18
18
  const { Clock, ROSClock } = require('./clock.js');
19
19
  const { ClockType } = Clock;
20
- const Node = require('./node.js');
21
20
  const { Parameter, ParameterType } = require('./parameter.js');
22
21
  const Time = require('./time.js');
23
22
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rclnodejs",
3
- "version": "0.31.0",
3
+ "version": "0.32.0",
4
4
  "description": "ROS2.0 JavaScript client with Node.js",
5
5
  "main": "index.js",
6
6
  "types": "types/index.d.ts",
@@ -17,15 +17,14 @@
17
17
  "build:dev": "node-gyp -j 16 build --debug",
18
18
  "rebuild": "npm run clean && node-gyp -j 16 rebuild",
19
19
  "rebuild:dev": "npm run clean && node-gyp -j 16 rebuild --debug",
20
- "generate-messages": "node scripts/generate_messages.js",
21
- "generate-messages:dev": "node scripts/generate_messages.js --debug",
20
+ "generate-messages": "node scripts/generate_messages.js && node scripts/generate_tsd.js",
21
+ "generate-messages:dev": "node scripts/generate_messages.js --debug && node scripts/generate_tsd.js",
22
22
  "clean": "node-gyp clean && rimraf ./generated",
23
23
  "install": "npm run rebuild",
24
24
  "postinstall": "npm run generate-messages",
25
25
  "docs": "cd docs && make",
26
- "test": "node --expose-gc ./scripts/run_test.js && npm run dtslint",
27
- "dtslint": "node scripts/generate_tsd.js",
28
- "lint": "eslint --max-warnings=0 --ext js,ts index.js types scripts lib example rosidl_gen rosidl_parser test benchmark/rclnodejs && node ./scripts/cpplint.js",
26
+ "test": "node --expose-gc ./scripts/run_test.js && npx tsd",
27
+ "lint": "eslint && node ./scripts/cpplint.js",
29
28
  "format": "clang-format -i -style=file ./src/*.cpp ./src/*.hpp && prettier --write \"{lib,rosidl_gen,rostsd_gen,rosidl_parser,types,example,test,scripts,benchmark}/**/*.{js,md,ts}\" ./*.{js,md,ts}",
30
29
  "prepare": "husky"
31
30
  },
@@ -43,46 +42,43 @@
43
42
  "type": "git",
44
43
  "url": "git+https://github.com/RobotWebTools/rclnodejs.git"
45
44
  },
46
- "//": "Pin deep-equal to ^1.1.1",
47
45
  "devDependencies": {
48
- "@babel/eslint-parser": "^7.25.9",
46
+ "@eslint/js": "^10.0.0",
47
+ "@types/node": "^22.13.9",
49
48
  "@typescript-eslint/eslint-plugin": "^8.18.0",
50
49
  "@typescript-eslint/parser": "^8.18.0",
51
- "babel-eslint": "^10.1.0",
52
50
  "clang-format": "^1.8.0",
53
51
  "commander": "^13.1.0",
54
- "deep-equal": "^1.1.1",
52
+ "deep-equal": "^2.2.3",
55
53
  "eslint": "^9.16.0",
56
- "eslint-config-prettier": "^10.0.1",
54
+ "eslint-config-prettier": "^10.0.2",
57
55
  "eslint-plugin-prettier": "^5.2.1",
56
+ "globals": "^16.0.0",
58
57
  "husky": "^9.1.7",
59
58
  "jsdoc": "^4.0.4",
60
59
  "lint-staged": "^15.2.10",
61
60
  "mocha": "^11.0.2",
61
+ "rimraf": "^6.0.1",
62
62
  "sinon": "^19.0.2",
63
63
  "tree-kill": "^1.2.2",
64
- "typescript": "^5.7.2"
64
+ "tsd": "^0.31.2",
65
+ "typescript": "^5.7.2",
66
+ "uuid": "^11.0.3"
65
67
  },
66
68
  "dependencies": {
67
69
  "@rclnodejs/ref-array-di": "^1.2.2",
68
70
  "@rclnodejs/ref-napi": "^4.0.0",
69
71
  "@rclnodejs/ref-struct-di": "^1.1.1",
70
- "array.prototype.flat": "^1.3.2",
71
72
  "bindings": "^1.5.0",
72
73
  "compare-versions": "^6.1.1",
73
74
  "debug": "^4.4.0",
74
75
  "dot": "^1.1.3",
75
- "dtslint": "^4.2.1",
76
76
  "fs-extra": "^11.2.0",
77
- "json-bigint": "^1.0.0",
78
77
  "is-close": "^1.3.3",
79
- "mkdirp": "^3.0.1",
80
- "mz": "^2.7.0",
78
+ "json-bigint": "^1.0.0",
81
79
  "nan": "^2.22.0",
82
- "rimraf": "^6.0.1",
83
- "uuid": "^11.0.3",
84
- "walk": "^2.3.15",
85
- "prettier": "^3.4.2"
80
+ "prettier": "^3.4.2",
81
+ "walk": "^2.3.15"
86
82
  },
87
83
  "husky": {
88
84
  "hooks": {
@@ -97,6 +93,9 @@
97
93
  "clang-format -i -style=file"
98
94
  ]
99
95
  },
96
+ "tsd": {
97
+ "directory": "test/types"
98
+ },
100
99
  "engines": {
101
100
  "node": ">= 16.13.0"
102
101
  }
@@ -12,7 +12,6 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- /* eslint-disable camelcase */
16
15
  const GOAL_ID_FIELD = {
17
16
  name: 'goal_id',
18
17
  type: {
@@ -1,3 +1,17 @@
1
+ // Licensed under the Apache License, Version 2.0 (the "License");
2
+ // you may not use this file except in compliance with the License.
3
+ // You may obtain a copy of the License at
4
+ //
5
+ // http://www.apache.org/licenses/LICENSE-2.0
6
+ //
7
+ // Unless required by applicable law or agreed to in writing, software
8
+ // distributed under the License is distributed on an "AS IS" BASIS,
9
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ // See the License for the specific language governing permissions and
11
+ // limitations under the License.
12
+
13
+ 'use strict';
14
+
1
15
  const fs = require('fs');
2
16
  const path = require('path');
3
17
  const os = require('os');
@@ -73,7 +87,6 @@ const RosPackageFilters = {
73
87
 
74
88
  if (!fs.existsSync(blocklistPath)) return;
75
89
 
76
- // eslint-disable-next-line
77
90
  let blocklistData = JSON.parse(fs.readFileSync(blocklistPath, 'utf8'));
78
91
 
79
92
  let filters = blocklistData.map((pkgFilterData) => {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rosidl-generator",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Generate JavaScript object from ROS IDL(.msg) files",
5
5
  "main": "index.js",
6
6
  "authors": [
@@ -64,7 +64,6 @@ async function generateAll(forcedGenerating) {
64
64
 
65
65
  const generator = {
66
66
  version() {
67
- // eslint-disable-next-line
68
67
  return fse.readJsonSync(path.join(__dirname, 'generator.json')).version;
69
68
  },
70
69
 
@@ -14,10 +14,6 @@
14
14
 
15
15
  'use strict';
16
16
 
17
- /* eslint-disable max-depth */
18
-
19
- const debug = require('debug')('rclnodejs:message_translator');
20
-
21
17
  function isTypedArray(value) {
22
18
  return ArrayBuffer.isView(value) && !(value instanceof DataView);
23
19
  }
@@ -39,7 +35,6 @@ function copyMsgObject(msg, obj) {
39
35
  // It's an array
40
36
  if (typeof obj[i][0] === 'object') {
41
37
  // It's an array of objects: converting to ROS message objects
42
-
43
38
  // 1. Extract the element-type first
44
39
  // 2. Build the array by translate every elements
45
40
  let msgArray = [];
@@ -66,8 +61,7 @@ function copyMsgObject(msg, obj) {
66
61
  function verifyMessage(message, obj) {
67
62
  if (message.constructor.isROSArray) {
68
63
  // It's a ROS message array
69
- // Note: there won't be any JavaScript array in message
70
-
64
+ // Note: there won't be any JavaScript array in message.
71
65
  if (!Array.isArray(obj)) {
72
66
  return false;
73
67
  }
@@ -131,13 +125,12 @@ function toPlainObject(message, enableTypedArray = true) {
131
125
 
132
126
  if (message.constructor.isROSArray) {
133
127
  // It's a ROS message array
134
- // Note: there won't be any JavaScript array in message
128
+ // Note: there won't be any JavaScript array in message.
135
129
  let array = [];
136
130
  message.data.forEach((e) => {
137
131
  array.push(toPlainObject(e, enableTypedArray)); // Translate every elements
138
132
  });
139
133
  return array;
140
- // eslint-disable-next-line no-else-return
141
134
  } else {
142
135
  // It's a ROS message
143
136
  const def = message.constructor.ROSMessageDef;
@@ -20,7 +20,6 @@ const readline = require('readline');
20
20
  const path = require('path');
21
21
  const walk = require('walk');
22
22
  const os = require('os');
23
- const flat = require('array.prototype.flat');
24
23
  const pkgFilters = require('../rosidl_gen/filter.js');
25
24
 
26
25
  const fsp = fs.promises;
@@ -193,8 +192,7 @@ async function findAmentPackagesInDirectory(dir) {
193
192
  pkgs.map((pkg) => getPackageDefinitionsFiles(pkg, dir))
194
193
  );
195
194
 
196
- // Support flat() method for nodejs < 11.
197
- const rosFiles = Array.prototype.flat ? files.flat() : flat(files);
195
+ const rosFiles = files.flat();
198
196
  const pkgMap = new Map();
199
197
  await Promise.all(
200
198
  rosFiles.map((filePath) => addInterfaceInfos(filePath, dir, pkgMap))
@@ -18,8 +18,6 @@ const ref = require('@rclnodejs/ref-napi');
18
18
  const StructType = require('@rclnodejs/ref-struct-di')(ref);
19
19
  const rclnodejs = require('bindings')('rclnodejs');
20
20
 
21
- /* eslint-disable camelcase */
22
-
23
21
  const StringRefStruct = StructType({
24
22
  data: ref.types.CString,
25
23
  size: ref.types.size_t,
@@ -65,5 +63,3 @@ module.exports = {
65
63
  wstring: StringRefStruct,
66
64
  initString: initString,
67
65
  };
68
-
69
- /* eslint-enable camelcase */
@@ -824,6 +824,10 @@ class {{=arrayWrapper}} {
824
824
  get classType() {
825
825
  return {{=arrayWrapper}};
826
826
  }
827
+
828
+ toPlainObject(enableTypedArray) {
829
+ return translator.toPlainObject(this, enableTypedArray);
830
+ }
827
831
  }
828
832
 
829
833
  {{? it.spec.constants != undefined && it.spec.constants.length}}
@@ -1,6 +1,3 @@
1
- /* eslint-disable max-depth */
2
- /* eslint-disable no-sync */
3
- /* eslint-disable camelcase */
4
1
  // Licensed under the Apache License, Version 2.0 (the "License");
5
2
  // you may not use this file except in compliance with the License.
6
3
  // You may obtain a copy of the License at
@@ -18,10 +18,9 @@ const exec = require('child_process').exec;
18
18
 
19
19
  const cmd = 'wget -nc ';
20
20
  const cpplintUrl =
21
- 'https://raw.githubusercontent.com/google/styleguide' +
22
- '/gh-pages/cpplint/cpplint.py';
21
+ 'https://raw.githubusercontent.com/cpplint/cpplint/refs/heads/develop/cpplint.py';
23
22
  const root = `${__dirname}/../src`;
24
- const args = `--extensions=cpp,h,hpp,cc ${root}/*`;
23
+ const args = `--filter=-build/include_subdir,-whitespace/indent_namespace --extensions=cpp,h,hpp,cc ${root}/*`;
25
24
 
26
25
  console.log('Downloading the cpplint...');
27
26
  exec(cmd + cpplintUrl, (err, stdout, stderr) => {
@@ -29,7 +28,7 @@ exec(cmd + cpplintUrl, (err, stdout, stderr) => {
29
28
  console.log(`Downloading failed: ${stderr}`);
30
29
  } else {
31
30
  console.log('Running the cpplint...');
32
- exec('python cpplint.py ' + args, (err, stdout, stderr) => {
31
+ exec('python3 cpplint.py ' + args, (err, stdout, stderr) => {
33
32
  console.log(stdout);
34
33
  if (err) {
35
34
  console.log(stderr);
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- /* eslint-disable camelcase */
4
3
  // Copyright (c) 2018 Intel Corporation. All rights reserved.
5
4
 
6
5
  // Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,6 +14,7 @@
15
14
  // See the License for the specific language governing permissions and
16
15
  // limitations under the License.
17
16
 
17
+ /* eslint-disable camelcase */
18
18
  'use strict';
19
19
 
20
20
  const generator = require('../rosidl_gen/index.js');
@@ -45,7 +45,7 @@ npm i rclnodejs@x.y.z
45
45
 
46
46
  | RCLNODEJS Version | Compatible ROS 2 LTS |
47
47
  | :------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------: |
48
- | latest version (currently [v0.31.0](https://github.com/RobotWebTools/rclnodejs/tree/0.31.0)) | [Humble](https://github.com/RobotWebTools/rclnodejs/tree/humble-hawksbill)<br>[Jazzy](https://github.com/RobotWebTools/rclnodejs/tree/jazzy) |
48
+ | latest version (currently [v0.32.0](https://github.com/RobotWebTools/rclnodejs/tree/0.32.0)) | [Humble](https://github.com/RobotWebTools/rclnodejs/tree/humble-hawksbill)<br>[Jazzy](https://github.com/RobotWebTools/rclnodejs/tree/jazzy) |
49
49
 
50
50
  ## Documentation
51
51
 
@@ -1,3 +1,15 @@
1
+ // Licensed under the Apache License, Version 2.0 (the "License");
2
+ // you may not use this file except in compliance with the License.
3
+ // You may obtain a copy of the License at
4
+
5
+ // http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ // Unless required by applicable law or agreed to in writing, software
8
+ // distributed under the License is distributed on an "AS IS" BASIS,
9
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ // See the License for the specific language governing permissions and
11
+ // limitations under the License.
12
+
1
13
  'use strict';
2
14
 
3
15
  const DistroUtils = require('../lib/distro');
@@ -19,8 +19,6 @@ const Mocha = require('mocha');
19
19
  const os = require('os');
20
20
  const path = require('path');
21
21
 
22
- let rootDir = path.dirname(__dirname);
23
-
24
22
  fs.remove(path.join(path.dirname(__dirname), 'generated'), (err) => {
25
23
  if (!err) {
26
24
  let mocha = new Mocha();
package/src/executor.hpp CHANGED
@@ -12,8 +12,8 @@
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
14
 
15
- #ifndef RCLNODEJS_EXECUTOR_HPP_
16
- #define RCLNODEJS_EXECUTOR_HPP_
15
+ #ifndef SRC_EXECUTOR_HPP_
16
+ #define SRC_EXECUTOR_HPP_
17
17
 
18
18
  #include <rcl/wait.h>
19
19
  #include <uv.h>
@@ -74,4 +74,4 @@ class Executor {
74
74
 
75
75
  } // namespace rclnodejs
76
76
 
77
- #endif
77
+ #endif // SRC_EXECUTOR_HPP_
@@ -12,8 +12,8 @@
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
14
 
15
- #ifndef RCLNODEJS_HANDLE_MANAGER_HPP_
16
- #define RCLNODEJS_HANDLE_MANAGER_HPP_
15
+ #ifndef SRC_HANDLE_MANAGER_HPP_
16
+ #define SRC_HANDLE_MANAGER_HPP_
17
17
 
18
18
  #include <nan.h>
19
19
  #include <rcl/wait.h>
@@ -132,4 +132,4 @@ class HandleManager {
132
132
 
133
133
  } // namespace rclnodejs
134
134
 
135
- #endif
135
+ #endif // SRC_HANDLE_MANAGER_HPP_
package/src/macros.hpp CHANGED
@@ -12,8 +12,8 @@
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
14
 
15
- #ifndef RCLNODEJS_MARCOS_HPP_
16
- #define RCLNODEJS_MARCOS_HPP_
15
+ #ifndef SRC_MACROS_HPP_
16
+ #define SRC_MACROS_HPP_
17
17
 
18
18
  #include "rcutils/logging_macros.h"
19
19
 
@@ -43,4 +43,4 @@
43
43
  #define RCLNODEJS_DEBUG(...)
44
44
  #endif
45
45
 
46
- #endif
46
+ #endif // SRC_MACROS_HPP_
@@ -12,8 +12,8 @@
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
14
 
15
- #ifndef RCLNODEJS_RCL_ACTION_BINDINGS_HPP_
16
- #define RCLNODEJS_RCL_ACTION_BINDINGS_HPP_
15
+ #ifndef SRC_RCL_ACTION_BINDINGS_HPP_
16
+ #define SRC_RCL_ACTION_BINDINGS_HPP_
17
17
 
18
18
  #include <nan.h>
19
19
  #include <rcl/rcl.h>
@@ -28,4 +28,4 @@ extern std::vector<BindingMethod> action_binding_methods;
28
28
 
29
29
  } // namespace rclnodejs
30
30
 
31
- #endif
31
+ #endif // SRC_RCL_ACTION_BINDINGS_HPP_
@@ -40,6 +40,7 @@
40
40
  #include <rcl/service_introspection.h>
41
41
  #endif
42
42
 
43
+ #include <cstdio>
43
44
  #include <iostream>
44
45
  #include <memory>
45
46
  #include <string>
@@ -710,7 +711,6 @@ NAN_METHOD(HasContentFilter) {
710
711
  info.GetReturnValue().Set(Nan::False());
711
712
  return;
712
713
  #else
713
-
714
714
  RclHandle* subscription_handle = RclHandle::Unwrap<RclHandle>(
715
715
  Nan::To<v8::Object>(info[0]).ToLocalChecked());
716
716
  rcl_subscription_t* subscription =
@@ -964,7 +964,7 @@ NAN_METHOD(SendRequest) {
964
964
  THROW_ERROR_IF_NOT_EQUAL(rcl_send_request(client, buffer, &sequence_number),
965
965
  RCL_RET_OK, rcl_get_error_string().str);
966
966
 
967
- info.GetReturnValue().Set(Nan::New((uint32_t)sequence_number));
967
+ info.GetReturnValue().Set(Nan::New(static_cast<uint32_t>(sequence_number)));
968
968
  }
969
969
 
970
970
  NAN_METHOD(RclTakeResponse) {
@@ -981,7 +981,7 @@ NAN_METHOD(RclTakeResponse) {
981
981
  int64_t sequence_number = header.request_id.sequence_number;
982
982
 
983
983
  if (ret == RCL_RET_OK) {
984
- info.GetReturnValue().Set(Nan::New((uint32_t)sequence_number));
984
+ info.GetReturnValue().Set(Nan::New(static_cast<uint32_t>(sequence_number)));
985
985
  return;
986
986
  }
987
987
 
@@ -1162,7 +1162,7 @@ NAN_METHOD(ValidateFullTopicName) {
1162
1162
  Nan::Set(
1163
1163
  result_list, 0,
1164
1164
  Nan::New<v8::String>(std::string(validation_message)).ToLocalChecked());
1165
- Nan::Set(result_list, 1, Nan::New((int32_t)invalid_index));
1165
+ Nan::Set(result_list, 1, Nan::New(static_cast<int32_t>(invalid_index)));
1166
1166
 
1167
1167
  info.GetReturnValue().Set(result_list);
1168
1168
  }
@@ -1197,7 +1197,7 @@ NAN_METHOD(ValidateNodeName) {
1197
1197
  Nan::Set(
1198
1198
  result_list, 0,
1199
1199
  Nan::New<v8::String>(std::string(validation_message)).ToLocalChecked());
1200
- Nan::Set(result_list, 1, Nan::New((int32_t)invalid_index));
1200
+ Nan::Set(result_list, 1, Nan::New(static_cast<int32_t>(invalid_index)));
1201
1201
 
1202
1202
  info.GetReturnValue().Set(result_list);
1203
1203
  }
@@ -1232,7 +1232,7 @@ NAN_METHOD(ValidateTopicName) {
1232
1232
  Nan::Set(
1233
1233
  result_list, 0,
1234
1234
  Nan::New<v8::String>(std::string(validation_message)).ToLocalChecked());
1235
- Nan::Set(result_list, 1, Nan::New((int32_t)invalid_index));
1235
+ Nan::Set(result_list, 1, Nan::New(static_cast<int32_t>(invalid_index)));
1236
1236
 
1237
1237
  info.GetReturnValue().Set(result_list);
1238
1238
  }
@@ -1267,7 +1267,7 @@ NAN_METHOD(ValidateNamespace) {
1267
1267
  Nan::Set(
1268
1268
  result_list, 0,
1269
1269
  Nan::New<v8::String>(std::string(validation_message)).ToLocalChecked());
1270
- Nan::Set(result_list, 1, Nan::New((int32_t)invalid_index));
1270
+ Nan::Set(result_list, 1, Nan::New(static_cast<int32_t>(invalid_index)));
1271
1271
 
1272
1272
  info.GetReturnValue().Set(result_list);
1273
1273
  }
@@ -12,8 +12,8 @@
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
14
 
15
- #ifndef RCLNODEJS_RCL_BINDINGS_HPP_
16
- #define RCLNODEJS_RCL_BINDINGS_HPP_
15
+ #ifndef SRC_RCL_BINDINGS_HPP_
16
+ #define SRC_RCL_BINDINGS_HPP_
17
17
 
18
18
  #include <nan.h>
19
19
  #include <rcl/graph.h>
@@ -43,4 +43,4 @@ extern std::vector<BindingMethod> binding_methods;
43
43
 
44
44
  } // namespace rclnodejs
45
45
 
46
- #endif
46
+ #endif // SRC_RCL_BINDINGS_HPP_
@@ -12,8 +12,8 @@
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
14
 
15
- #ifndef RCLNODEJS_RCL_HANDLE_HPP_
16
- #define RCLNODEJS_RCL_HANDLE_HPP_
15
+ #ifndef SRC_RCL_HANDLE_HPP_
16
+ #define SRC_RCL_HANDLE_HPP_
17
17
 
18
18
  #include <nan.h>
19
19
 
@@ -68,4 +68,4 @@ class RclHandle : public Nan::ObjectWrap {
68
68
 
69
69
  } // namespace rclnodejs
70
70
 
71
- #endif
71
+ #endif // SRC_RCL_HANDLE_HPP_
@@ -12,8 +12,8 @@
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
14
 
15
- #ifndef RCLNODEJS_RCL_LIFECYCLE_BINDINGS_HPP_
16
- #define RCLNODEJS_RCL_LIFECYCLE_BINDINGS_HPP_
15
+ #ifndef SRC_RCL_LIFECYCLE_BINDINGS_HPP_
16
+ #define SRC_RCL_LIFECYCLE_BINDINGS_HPP_
17
17
 
18
18
  #include <vector>
19
19
 
@@ -25,4 +25,4 @@ extern std::vector<BindingMethod> lifecycle_binding_methods;
25
25
 
26
26
  } // namespace rclnodejs
27
27
 
28
- #endif
28
+ #endif // SRC_RCL_LIFECYCLE_BINDINGS_HPP_
@@ -12,8 +12,8 @@
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
14
 
15
- #ifndef RCLNODEJS_RCL_UTILITIES_HPP_
16
- #define RCLNODEJS_RCL_UTILITIES_HPP_
15
+ #ifndef SRC_RCL_UTILITIES_HPP_
16
+ #define SRC_RCL_UTILITIES_HPP_
17
17
 
18
18
  #include <string>
19
19
 
@@ -37,4 +37,4 @@ std::string GetErrorMessageAndClear();
37
37
 
38
38
  } // namespace rclnodejs
39
39
 
40
- #endif
40
+ #endif // SRC_RCL_UTILITIES_HPP_
@@ -12,8 +12,8 @@
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
14
 
15
- #ifndef RCLNODEJS_SHADOW_NODE_HPP_
16
- #define RCLNODEJS_SHADOW_NODE_HPP_
15
+ #ifndef SRC_SHADOW_NODE_HPP_
16
+ #define SRC_SHADOW_NODE_HPP_
17
17
 
18
18
  #include <nan.h>
19
19
 
@@ -60,4 +60,4 @@ class ShadowNode : public Nan::ObjectWrap, public Executor::Delegate {
60
60
 
61
61
  } // namespace rclnodejs
62
62
 
63
- #endif
63
+ #endif // SRC_SHADOW_NODE_HPP_
@@ -1,4 +1,3 @@
1
- /* eslint-disable camelcase */
2
1
  declare module 'rclnodejs' {
3
2
  type ActionGoal<T> = T extends ActionTypeClassName
4
3
  ? InstanceType<ActionsMap[T]['Goal']>
@@ -1,4 +1,3 @@
1
- /* eslint-disable camelcase */
2
1
  declare module 'rclnodejs' {
3
2
  /**
4
3
  * Goal handle for working with Action Servers.
package/types/base.d.ts CHANGED
@@ -1,28 +1,27 @@
1
- /* eslint-disable spaced-comment */
2
- /// <reference path="action_client.d.ts" />
3
- /// <reference path="action_server.d.ts" />
4
- /// <reference path="action_uuid.d.ts" />
5
- /// <reference path="client.d.ts" />
6
- /// <reference path="clock_type.d.ts" />
7
- /// <reference path="clock.d.ts" />
8
- /// <reference path="context.d.ts" />
9
- /// <reference path="distro.d.ts" />
10
- /// <reference path="duration.d.ts" />
11
- /// <reference path="entity.d.ts" />
12
- /// <reference path="guard_condition.d.ts" />
13
- /// <reference path="interfaces.d.ts" />
14
- /// <reference path="lifecycle.d.ts" />
15
- /// <reference path="lifecycle_publisher.d.ts" />
16
- /// <reference path="logging.d.ts" />
17
- /// <reference path="node.d.ts" />
18
- /// <reference path="node_options.d.ts" />
19
- /// <reference path="parameter.d.ts" />
20
- /// <reference path="publisher.d.ts" />
21
- /// <reference path="qos.d.ts" />
22
- /// <reference path="rate.d.ts" />
23
- /// <reference path="service.d.ts" />
24
- /// <reference path="service_introspection.d.ts" />
25
- /// <reference path="subscription.d.ts" />
26
- /// <reference path="time_source.d.ts" />
27
- /// <reference path="time.d.ts" />
28
- /// <reference path="timer.d.ts" />
1
+ /// <reference types="./action_client.d.ts" />
2
+ /// <reference types="./action_server.d.ts" />
3
+ /// <reference types="./action_uuid.d.ts" />
4
+ /// <reference types="./client.d.ts" />
5
+ /// <reference types="./clock_type.d.ts" />
6
+ /// <reference types="./clock.d.ts" />
7
+ /// <reference types="./context.d.ts" />
8
+ /// <reference types="./distro.d.ts" />
9
+ /// <reference types="./duration.d.ts" />
10
+ /// <reference types="./entity.d.ts" />
11
+ /// <reference types="./guard_condition.d.ts" />
12
+ /// <reference types="./interfaces.d.ts" />
13
+ /// <reference types="./lifecycle.d.ts" />
14
+ /// <reference types="./lifecycle_publisher.d.ts" />
15
+ /// <reference types="./logging.d.ts" />
16
+ /// <reference types="./node.d.ts" />
17
+ /// <reference types="./node_options.d.ts" />
18
+ /// <reference types="./parameter.d.ts" />
19
+ /// <reference types="./publisher.d.ts" />
20
+ /// <reference types="./qos.d.ts" />
21
+ /// <reference types="./rate.d.ts" />
22
+ /// <reference types="./service.d.ts" />
23
+ /// <reference types="./service_introspection.d.ts" />
24
+ /// <reference types="./subscription.d.ts" />
25
+ /// <reference types="./time_source.d.ts" />
26
+ /// <reference types="./time.d.ts" />
27
+ /// <reference types="./timer.d.ts" />
package/types/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- // eslint-disable-next-line spaced-comment
2
- /// <reference path="base.d.ts" />
1
+ /// <reference types="./base.d.ts" />
3
2
 
4
3
  declare module 'rclnodejs' {
5
4
  /**
@@ -53,10 +53,8 @@ declare module 'rclnodejs' {
53
53
  asMessage(): {
54
54
  transition: SerializedState;
55
55
 
56
- // eslint-disable-next-line camelcase
57
56
  start_state: SerializedState;
58
57
 
59
- // eslint-disable-next-line camelcase
60
58
  goal_state: SerializedState;
61
59
  };
62
60
  }
@@ -249,7 +247,7 @@ declare module 'rclnodejs' {
249
247
  * Register a callback function to be invoked during the deactivate() action.
250
248
  * @param cb - The callback function to invoke.
251
249
  */
252
- registerOnDectivate(cb: TransitionCallback): void;
250
+ registerOnDeactivate(cb: TransitionCallback): void;
253
251
 
254
252
  /**
255
253
  * Register a callback function to be invoked during the cleanup() action.
package/types/node.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /* eslint-disable camelcase */
2
1
  declare module 'rclnodejs' {
3
2
  /**
4
3
  * Identifies type of ROS message such as msg or srv.
@@ -1,5 +1,3 @@
1
- /* eslint-disable camelcase */
2
-
3
1
  declare module 'rclnodejs' {
4
2
  /**
5
3
  * The plus/minus tolerance for determining number equivalence.
@@ -8,7 +8,6 @@ declare module 'rclnodejs' {
8
8
  * Topic on which messages are published.
9
9
  */
10
10
  readonly topic: string;
11
-
12
11
  /**
13
12
  * Publish a message
14
13
  *
package/types/time.d.ts CHANGED
@@ -1,6 +1,4 @@
1
- /* eslint-disable camelcase */
2
-
3
- import { Message, builtin_interfaces } from 'rclnodejs';
1
+ import { builtin_interfaces } from 'rclnodejs';
4
2
 
5
3
  declare module 'rclnodejs' {
6
4
  /**
@@ -100,7 +98,6 @@ declare module 'rclnodejs' {
100
98
  *
101
99
  * @returns The new Time message.
102
100
  */
103
- // eslint-disable-next-line camelcase
104
101
  toMsg(): builtin_interfaces.msg.Time;
105
102
 
106
103
  /**
@@ -110,7 +107,6 @@ declare module 'rclnodejs' {
110
107
  * @param clockType - The type of the time object. Default is ClockType.ROS_TIME
111
108
  * @returns The new Time.
112
109
  */
113
- // eslint-disable-next-line camelcase
114
110
  static fromMsg(
115
111
  msg: builtin_interfaces.msg.Time,
116
112
  clockType?: ClockType