Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hadron-ipc

Package Overview
Dependencies
Maintainers
0
Versions
495
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hadron-ipc - npm Package Compare versions

Comparing version 0.0.0-next-4222a9637dad37c08ecb1baac59d26c8a4ecd88f to 0.0.0-next-42294867749aa34faf6b8e7c48d946d3f3cc2b5e

dist/common.d.ts

84

package.json
{
"name": "hadron-ipc",
"description": "Simplified IPC for electron apps.",
"version": "0.0.0-next-4222a9637dad37c08ecb1baac59d26c8a4ecd88f",
"scripts": {
"test-electron": "xvfb-maybe electron-mocha --no-sandbox",
"lint": "eslint \"./{src,lib,test,bin}/**/*.{js,jsx,ts,tsx}\" \"./*.js\" --no-error-on-unmatched-pattern",
"depcheck": "depcheck",
"check": "npm run lint && npm run depcheck",
"test-ci-electron": "npm run test-electron"
"version": "0.0.0-next-42294867749aa34faf6b8e7c48d946d3f3cc2b5e",
"author": {
"name": "MongoDB Inc",
"email": "compass@mongodb.com"
},
"publishConfig": {
"access": "public"
},
"bugs": {
"url": "https://jira.mongodb.org/projects/COMPASS/issues",
"email": "compass@mongodb.com"
},
"homepage": "https://github.com/mongodb-js/compass",

@@ -17,25 +21,57 @@ "repository": {

},
"main": "index.js",
"compass:main": "index.js",
"dependencies": {
"debug": "^4.2.0",
"is-electron-renderer": "^2.0.1",
"is-promise": "^2.1.0",
"lodash.forin": "^4.4.0",
"lodash.isplainobject": "^4.0.6"
"files": [
"dist"
],
"license": "SSPL",
"main": "dist/index.js",
"compass:main": "src/index.ts",
"exports": {
"import": "./dist/index.js",
"require": "./dist/index.js"
},
"compass:exports": {
".": "./src/index.ts"
},
"types": "./dist/index.d.ts",
"scripts": {
"bootstrap": "npm run compile",
"prepublishOnly": "npm run compile && compass-scripts check-exports-exist",
"compile": "tsc -p tsconfig.json",
"typecheck": "tsc -p tsconfig-lint.json --noEmit",
"eslint": "eslint",
"prettier": "prettier",
"lint": "npm run eslint . && npm run prettier -- --check .",
"depcheck": "compass-scripts check-peer-deps && depcheck",
"check": "npm run typecheck && npm run lint && npm run depcheck",
"check-ci": "npm run check",
"test": "mocha",
"test-cov": "nyc --compact=false --produce-source-map=false -x \"**/*.spec.*\" --reporter=lcov --reporter=text --reporter=html npm run test",
"test-watch": "npm run test -- --watch",
"test-ci": "npm run test-cov",
"reformat": "npm run eslint . -- --fix && npm run prettier -- --write ."
},
"devDependencies": {
"@mongodb-js/eslint-config-compass": "0.0.0-next-42294867749aa34faf6b8e7c48d946d3f3cc2b5e",
"@mongodb-js/mocha-config-compass": "0.0.0-next-42294867749aa34faf6b8e7c48d946d3f3cc2b5e",
"@mongodb-js/prettier-config-compass": "0.0.0-next-42294867749aa34faf6b8e7c48d946d3f3cc2b5e",
"@mongodb-js/tsconfig-compass": "0.0.0-next-42294867749aa34faf6b8e7c48d946d3f3cc2b5e",
"@types/chai": "^4.2.21",
"@types/is-electron-renderer": "^2.0.1",
"@types/mocha": "^9.0.0",
"@types/sinon-chai": "^3.2.5",
"chai": "^4.3.6",
"depcheck": "^1.4.1",
"electron": "^15.5.7",
"electron-mocha": "^10.1.0",
"eslint": "^7.25.0",
"eslint-config-mongodb-js": "^5.0.3",
"xvfb-maybe": "^0.2.1"
"mocha": "^10.2.0",
"nyc": "^15.1.0",
"prettier": "^2.7.1",
"sinon": "^9.2.3",
"typescript": "^5.0.4"
},
"license": "SSPL",
"bugs": {
"url": "https://jira.mongodb.org/projects/COMPASS/issues",
"email": "compass@mongodb.com"
"dependencies": {
"debug": "^4.3.4",
"electron": "^30.5.1",
"is-electron-renderer": "^2.0.1"
},
"gitHead": "4222a9637dad37c08ecb1baac59d26c8a4ecd88f"
"gitHead": "42294867749aa34faf6b8e7c48d946d3f3cc2b5e"
}
# hadron-ipc [![npm][npm_img]][npm_url]
Simplified wrapper around Electron's IPC events.
Simplified wrapper around Electron's IPC events.

@@ -31,6 +31,10 @@ # Usage

## API - from Main Process
Communication from the main process to a renderer process.
Communication from the main process to a renderer process.
### ipc.respondTo(methodName, handler)
Respond to an event sent from a renderer process. `handler` keeps track of
`BrowserWindow` instance and any of the `args`.
```js

@@ -50,2 +54,3 @@ const ipc = require('hadron-ipc');

You can also use `broadcast` as part of the response:
```js

@@ -60,5 +65,7 @@ const ipc = require('hadron-ipc');

### ipc.broadcast(methodName, [...args])
Broadcast an event to renderer process(es).
For example, here is a broadcast from a Menu Item:
```js

@@ -84,9 +91,13 @@ const ipc = require('hadron-ipc');

### ipc.broadcastFocused(methodName, [...args])
Broadcast to renderer process(es) only if the current window is focused.
Broadcast to renderer process(es) only if the current window is focused.
```js
ipc.broadcastFocused('app:disconnect');
ipc.broadcastFocused('app:disconnect');
```
### ipc.remove(channel, listener)
Remove a listener from the main process' ipc.
```js

@@ -102,6 +113,7 @@ const ipc = require('hadron-ipc');

ipc.remove('app:stop-find-in-page', onStopFindInPage);
ipc.remove('app:stop-find-in-page', onStopFindInPage);
```
## API - from Renderer process
## API - from Renderer process
Communication from a renderer proces to the main process. All of the

@@ -112,2 +124,3 @@ [ipcRenderer][ipc-renderer] events are kept as

### ipc.call(methodName, [...args])
Call the main process under the provided `methodName`. Under the hood `args`

@@ -126,3 +139,3 @@ are serialised as JSON.

ipc.call('app:open-export', args, (res) = {
console.log('callback from renderer process', res)
console.log('callback from renderer process', res)
});

@@ -132,14 +145,16 @@ ```

### ipc.on(methodName, handler)
From Electron's `ipcRenderer` API. Useful for when replying to Main process'
`ipc.broadcast` events.
```js
const ipc = require('hadron-ipc');
const app = require('hadron-app')
global.hadronApp = app;
ipc.on('app:refresh-data', () => global.hadronApp.appRegistry.emit('refresh-data'));
ipc.on('app:refresh-data', () =>
// do something
);
```
# Install
```shell

@@ -150,2 +165,3 @@ npm install hadron-ipc

# Related Content
- [Electron's ipcMain][ipc-main]

@@ -161,2 +177,2 @@ - [Electron's ipcRenderer][ipc-renderer]

[hadron-app]: https://github.com/mongodb-js/hadron-app
[hadron-app-registry]: https://github.com/mongodb-js/hadron-app-registr://github.com/mongodb-js/hadron-app-registry
[hadron-app-registry]: https://github.com/mongodb-js/hadron-app-registr://github.com/mongodb-js/hadron-app-registry
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc