Registry / aws / weak-node-api

weak-node-api

JSON →
library0.1.1jsnpmunverified

A linkable and runtime-injectable Node-API implementation that allows native addons to be built without direct linking against a Node-API provider. Version 0.1.1 is the latest stable release, part of the React Native Node-API project. It is a thin shim that exposes only Node-API function declarations, enabling runtime injection of the actual implementation by the host (e.g., React Native runtime), solving Android dynamic linker symbol resolution issues. Unlike typical Node-API bindings, it decouples addon compilation from the runtime, supporting React Native and potentially other contexts. Dependencies: none. Release cadence: early stage, active development.

aws
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Renamed from WeakNodeApiHost to NodeApiHost in v0.1.0.

import { NodeApiHost } from 'weak-node-api'

ESM only; no CommonJS support documented.

import { NapiMixin } from 'weak-node-api'

TypeScript type export, no value runtime.

import type { ModuleFunctionMap } from 'weak-node-api'

Named export; default import is not available.

import { defineNapiModule } from 'weak-node-api'

Demonstrates creating a NodeApiHost and defining a module with weak-node-api.

import { NodeApiHost, defineNapiModule, NapiMixin } from 'weak-node-api'; // Define a simple Node-API module const myModule = defineNapiModule({ napiVersion: 8, functions: { add: (env, napiValue) => { // implementation placeholder return 42; } } as any }); // Create a host that injects the implementation const host = new NodeApiHost({ module: myModule, // other options }); // Mixin example class MyAddon extends NapiMixin { // NapiMixin provides Node-API context } console.log('weak-node-api initialized');
Debug
Known footguns
breakingWeakNodeApiHost class renamed to NodeApiHost in v0.1.0.
gotchaAll exports are ESM-only; there is no CommonJS build. Using require() will fail.
gotchaTypeScript users must ensure 'resolveJsonModule' and 'esModuleInterop' are set for proper type support.
deprecatedThe package is in early alpha; API may change without major semver bump.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
13 hits · last 30 days
claudebot
4
gptbot
3
ahrefsbot
3
amazonbot
3
Resources