hadron-ipc
Advanced tools
Comparing version 0.0.0-next-0b7bdbac2841bb29f779dc118427209fea404a6b to 0.0.0-next-0bc694b0ba963200ad1a131c46db3b9479b6e928
{ | ||
"name": "hadron-ipc", | ||
"description": "Simplified IPC for electron apps.", | ||
"version": "0.0.0-next-0b7bdbac2841bb29f779dc118427209fea404a6b", | ||
"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-0bc694b0ba963200ad1a131c46db3b9479b6e928", | ||
"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,24 +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": "^4.17.21" | ||
"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-0bc694b0ba963200ad1a131c46db3b9479b6e928", | ||
"@mongodb-js/mocha-config-compass": "0.0.0-next-0bc694b0ba963200ad1a131c46db3b9479b6e928", | ||
"@mongodb-js/prettier-config-compass": "0.0.0-next-0bc694b0ba963200ad1a131c46db3b9479b6e928", | ||
"@mongodb-js/tsconfig-compass": "0.0.0-next-0bc694b0ba963200ad1a131c46db3b9479b6e928", | ||
"@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": "^24.8.2", | ||
"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": "^29.4.5", | ||
"is-electron-renderer": "^2.0.1" | ||
}, | ||
"gitHead": "0b7bdbac2841bb29f779dc118427209fea404a6b" | ||
"gitHead": "0bc694b0ba963200ad1a131c46db3b9479b6e928" | ||
} |
# 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 |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
65487
3
23
346
0
169
16
2
1
+ Addedelectron@^29.4.5
+ Added@electron/get@2.0.3(transitive)
+ Added@sindresorhus/is@4.6.0(transitive)
+ Added@szmarczak/http-timer@4.0.6(transitive)
+ Added@types/cacheable-request@6.0.3(transitive)
+ Added@types/http-cache-semantics@4.0.4(transitive)
+ Added@types/keyv@3.1.4(transitive)
+ Added@types/node@20.17.10(transitive)
+ Added@types/responselike@1.0.3(transitive)
+ Added@types/yauzl@2.10.3(transitive)
+ Addedboolean@3.2.0(transitive)
+ Addedbuffer-crc32@0.2.13(transitive)
+ Addedcacheable-lookup@5.0.4(transitive)
+ Addedcacheable-request@7.0.4(transitive)
+ Addedclone-response@1.0.3(transitive)
+ Addeddecompress-response@6.0.0(transitive)
+ Addeddefer-to-connect@2.0.1(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddefine-properties@1.2.1(transitive)
+ Addeddetect-node@2.1.0(transitive)
+ Addedelectron@29.4.6(transitive)
+ Addedend-of-stream@1.4.4(transitive)
+ Addedenv-paths@2.2.1(transitive)
+ Addedes-define-property@1.0.1(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedes6-error@4.1.1(transitive)
+ Addedescape-string-regexp@4.0.0(transitive)
+ Addedextract-zip@2.0.1(transitive)
+ Addedfd-slicer@1.1.0(transitive)
+ Addedfs-extra@8.1.0(transitive)
+ Addedget-stream@5.2.0(transitive)
+ Addedglobal-agent@3.0.0(transitive)
+ Addedglobalthis@1.0.4(transitive)
+ Addedgopd@1.2.0(transitive)
+ Addedgot@11.8.6(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhttp-cache-semantics@4.1.1(transitive)
+ Addedhttp2-wrapper@1.0.3(transitive)
+ Addedjson-buffer@3.0.1(transitive)
+ Addedjson-stringify-safe@5.0.1(transitive)
+ Addedjsonfile@4.0.0(transitive)
+ Addedkeyv@4.5.4(transitive)
+ Addedlowercase-keys@2.0.0(transitive)
+ Addedmatcher@3.0.0(transitive)
+ Addedmimic-response@1.0.13.1.0(transitive)
+ Addednormalize-url@6.1.0(transitive)
+ Addedobject-keys@1.1.1(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedp-cancelable@2.1.1(transitive)
+ Addedpend@1.2.0(transitive)
+ Addedprogress@2.0.3(transitive)
+ Addedpump@3.0.2(transitive)
+ Addedquick-lru@5.1.1(transitive)
+ Addedresolve-alpn@1.2.1(transitive)
+ Addedresponselike@2.0.1(transitive)
+ Addedroarr@2.15.4(transitive)
+ Addedsemver@6.3.17.6.3(transitive)
+ Addedsemver-compare@1.0.0(transitive)
+ Addedserialize-error@7.0.1(transitive)
+ Addedsprintf-js@1.1.3(transitive)
+ Addedsumchecker@3.0.1(transitive)
+ Addedtype-fest@0.13.1(transitive)
+ Addedundici-types@6.19.8(transitive)
+ Addeduniversalify@0.1.2(transitive)
+ Addedwrappy@1.0.2(transitive)
+ Addedyauzl@2.10.0(transitive)
- Removedis-promise@^2.1.0
- Removedlodash@^4.17.21
- Removedis-promise@2.2.2(transitive)
- Removedlodash@4.17.21(transitive)
Updateddebug@^4.3.4