nodejs bridge to support browser.runtime api
browser.runtime
implementation in nodejs.
See also Native Messaging.
npm install browser.runtime
const runtime = require('browser.runtime')
const port = runtime.connectNative(`${__dirname}/py_ping_pong`)
port.onMessage.addListener((response) => {
t.equal(response, 'pong')
port.disconnect()
})
port.postMessage('ping')
You can reuse low level transform streams to encode/decode messages:
const {NativeEncoder, NativeDecoder} = require('browser.runtime')
See tests.