Skip to content

Commit d4d2d7c

Browse files
authored
Integrate rclnodejs/ref-napi into rclnodejs (#1285)
This PR integrates the `ref-napi` package directly into the rclnodejs native module as a third-party dependency, eliminating the need for separate npm package installation. - Vendors the ref-napi package into `third_party/ref-napi/` directory - Adds native C++ bindings integration into the main addon module - Updates all module references to use the vendored version instead of external package Fix: #1284
1 parent 8762f13 commit d4d2d7c

File tree

9 files changed

+2529
-3
lines changed

9 files changed

+2529
-3
lines changed

binding.gyp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@
4242
'./src/rcl_timer_bindings.cpp',
4343
'./src/rcl_utilities.cpp',
4444
'./src/shadow_node.cpp',
45+
'./third_party/ref-napi/src/ref_napi_bindings.cpp',
4546
],
4647
'include_dirs': [
4748
'.',
49+
'./third_party/ref-napi/src',
4850
'<(ros_include_root)',
4951
"<!@(node -p \"require('node-addon-api').include\")",
5052
],

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@
7272
},
7373
"dependencies": {
7474
"@rclnodejs/ref-array-di": "^1.2.2",
75-
"@rclnodejs/ref-napi": "^4.0.0",
7675
"@rclnodejs/ref-struct-di": "^1.1.1",
7776
"bindings": "^1.5.0",
7877
"compare-versions": "^6.1.1",

rosidl_gen/primitive_types.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
'use strict';
1616

17-
const ref = require('@rclnodejs/ref-napi');
17+
const ref = require('../third_party/ref-napi');
1818
const StructType = require('@rclnodejs/ref-struct-di')(ref);
1919
const rclnodejs = require('bindings')('rclnodejs');
2020

rosidl_gen/templates/message.dot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ function extractMemberNames(fields) {
226226
{{? willUseTypedArray}}
227227
const rclnodejs = require('bindings')('rclnodejs');
228228
{{?}}
229-
const ref = require('@rclnodejs/ref-napi');
229+
const ref = require('../../third_party/ref-napi');
230230
const StructType = require('@rclnodejs/ref-struct-di')(ref);
231231
const ArrayType = require('@rclnodejs/ref-array-di')(ref);
232232
const primitiveTypes = require('../../rosidl_gen/primitive_types.js');

src/addon.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "rcl_type_description_service_bindings.h"
4141
#endif
4242
#include "rcl_utilities.h"
43+
#include "ref_napi_bindings.h"
4344
#include "shadow_node.h"
4445

4546
bool IsRunningInElectronRenderer(const Napi::Env& env) {
@@ -93,6 +94,8 @@ Napi::Object InitModule(Napi::Env env, Napi::Object exports) {
9394
rclnodejs::ShadowNode::Init(env, exports);
9495
rclnodejs::RclHandle::Init(env, exports);
9596

97+
exports.Set("ref", rclnodejs::InitRefNapi(env));
98+
9699
#ifdef DEBUG_ON
97100
int result = rcutils_logging_set_logger_level(PACKAGE_NAME,
98101
RCUTILS_LOG_SEVERITY_DEBUG);

third_party/ref-napi/index.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
module.exports = require('./lib/ref');

0 commit comments

Comments
 (0)