Helpers for Node.js addons and dependency packages
Go to file
Luis Blanco b05666869a Fix build 2023-01-03 23:45:14 +04:00
.github/workflows Fix build 2023-01-03 23:45:14 +04:00
.vscode Update dependencies 2023-01-02 17:09:33 +04:00
conf Fix exports 2023-01-03 23:14:04 +04:00
include Fix build 2023-01-03 23:45:14 +04:00
test-addon Fix build 2023-01-03 23:45:14 +04:00
utils Fix exports 2023-01-03 23:14:04 +04:00
.eslintrc Update info 2022-12-05 22:44:35 +04:00
.gitattributes Update deps 2022-09-24 19:02:48 +04:00
.gitignore Update deps 2022-09-24 19:02:48 +04:00
CPPLINT.cfg Update dependencies 2023-01-02 17:09:33 +04:00
LICENSE Update deps 2022-09-24 19:02:48 +04:00
README.md Update module structure 2023-01-03 22:20:39 +04:00
index.d.ts Allow unknown platforms 2022-12-24 17:20:48 +04:00
index.js Fix build 2023-01-03 23:45:14 +04:00
package-lock.json Update module structure 2023-01-03 22:20:39 +04:00
package.json Fix build 2023-01-03 23:45:14 +04:00
utils.d.ts Add actionVersion test 2023-01-03 22:55:49 +04:00
utils.js Fix exports 2023-01-03 23:14:04 +04:00

README.md

Addon Tools

This is a part of Node3D project.

NPM CodeFactor

npm i addon-tools-raub

This module contains helpers for Node.js NAPI addons and dependency packages. On this page, helper scripts are described. For details on addon-tools.hpp and some additional snippets follow the links below.

include/addon-tools.hpp

Macro shortcuts for C++ addons using NAPI. See docs inside the folder.

Example of an addon method definition:

// hpp:
#include <addon-tools.hpp>
DBG_EXPORT JS_METHOD(doSomething);
// cpp:
DBG_EXPORT JS_METHOD(doSomething) { NAPI_ENV;
	LET_INT32_ARG(0, param0);
	std::cout << "param0: " << param0 << std::endl;
	RET_UNDEFINED;
}

index.js

Main exports for cross-platform addon configuration. See the TypeScript definitions with comments.

NOTE: the peer dependency node-addon-api is used by this helper.

Example for an ADDON's index.js:

	const { bin } = require('addon-tools-raub');
	const core = require(`./${bin}/ADDON`); // uses the platform-specific ADDON.node

Example for binding.gyp:

	'include_dirs': [
		'<!@(node -p "require(\'addon-tools-raub\').include")',
	],

utils.js

JS utils for Node.js modules and addons.

const utils = require('addon-tools-raub/utils');

Example of cpbin usage in package.json :: scripts:

	"build-all": "cd src && node-gyp rebuild -j max --silent && node -e \"require('addon-tools-raub/utils').cpbin('segfault')\" && cd ..",
	"build-only": "cd src && node-gyp build -j max --silent && node -e \"require('addon-tools-raub/utils').cpbin('segfault')\" && cd ..",

See the TypeScript definitions with comments.