electron-re
Advanced tools
Comparing version 1.0.2 to 1.0.3
{ | ||
"name": "electron-re", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "electron sugar utils", | ||
@@ -14,3 +14,3 @@ "main": "./lib/index", | ||
"author": "NoJsJa", | ||
"license": "ISC", | ||
"license": "MIT", | ||
"repository": { | ||
@@ -21,2 +21,5 @@ "type": "git", | ||
"homepage": "https://github.com/NoJsJa/electron-re#readme", | ||
"dependencies": { | ||
"electron": "8.2.0" | ||
}, | ||
"devDependencies": { | ||
@@ -27,5 +30,4 @@ "babel-preset-es2015": "^6.24.1", | ||
"cross-env": "^7.0.2", | ||
"electron": "8.2.0", | ||
"electron-mocha": "^9.3.2" | ||
} | ||
} |
### electron-re | ||
--------------- | ||
Using `electron-re` to generate some service processs and communicate between `main process`,`render process` and `service`. In some `Best Practices` of electron tutorials, it suggest to put your code that occupy the CPU into rendering process instead of in main process, exactly `electron-re` means to do. | ||
> can only be used in electron project and test on electron@8.2.0 | ||
Using `electron-re` to generate some service processs and communicate between `main process`,`render process` and `service`. In some `Best Practices` of electron tutorials, it suggests to put your code that occupy the CPU into rendering process instead of in main process, exactly `electron-re` means to do. | ||
#### I ) Instruction | ||
@@ -44,3 +45,3 @@ | ||
In order to send data from main or other process to a service you need use `MesssageChannel`, such as: `MessageChannel.send('service-name', 'channel', 'params')` | ||
In order to send data from main/other process to a service you need to use `MesssageChannel`, such as: `MessageChannel.send('service-name', 'channel', 'params')` | ||
@@ -51,8 +52,17 @@ #### II ) Usage | ||
The service is a customized `BrowserWindow` instance, it has only method `connected()` which return a resolved `Promise` when service is ready, suggest to put some business-related code into a service. | ||
The service is a customized `BrowserWindow` instance, initialized by a file worked with `commonJs` module, so you can use `require('name')` and can't use `import some from 'name'` syntax. It has two extension methods: | ||
* `connected()` - return a resolved `Promise` when service is ready. | ||
* `openDevTools` - open an undocked window for debugging. | ||
suggest to put some business-related code into a service. | ||
```js | ||
/* --- main.js --- */ | ||
const { BrowserService } = require('electron-re'); | ||
const { | ||
BrowserService, | ||
MessageChannel // must required in main.js even if you don't use it | ||
} = require('electron-re'); | ||
... | ||
@@ -85,8 +95,13 @@ | ||
##### 2. MessageChannel | ||
> confirm to require it in main.js(main process entry) first | ||
This is a messaging tool expanding some method from electron build-in ipc: | ||
This is a messaging tool expanding some methods from electron build-in ipc: | ||
```js | ||
/* --- main --- */ | ||
const { BrowserService, MessageChannel } = require('electron-re'); | ||
const { | ||
BrowserService, | ||
MessageChannel // must required in main.js even if you don't use it | ||
} = require('electron-re'); | ||
const isInDev = process.env.NODE_ENV === 'dev'; | ||
... | ||
@@ -139,3 +154,3 @@ | ||
// send data to another service and return a promise , just like ipcRenderer.invoke | ||
MessageChannel.invoke('app2', 'channel3' (event, result) => { | ||
MessageChannel.invoke('app2', 'channel3', { value: 'channel3' }).then((event, result) => { | ||
console.log(result); | ||
@@ -172,3 +187,3 @@ }); | ||
const { ipcRenderer } = require('electron'); | ||
const { MessageChannel } = rrequire('electron-re'); | ||
const { MessageChannel } = require('electron-re'); | ||
@@ -186,3 +201,3 @@ // send data to a service | ||
[electronux](https://github.com/NoJsJa/electronux) - this is a project of mine that uses `electron-re`, also you can check the `index.test.js` and `test` dir in root, there are some cases, then run `npm run test` to see test result of the library. | ||
[electronux](https://github.com/NoJsJa/electronux) - A project of mine that uses `electron-re`, also you can check the `index.test.js` and `test` dir in root, there are some cases, then run `npm run test` to see test result of the library. | ||
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
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
78552
5
20
198
1
+ Addedelectron@8.2.0
+ Added@electron/get@1.14.1(transitive)
+ Added@sindresorhus/is@0.14.0(transitive)
+ Added@szmarczak/http-timer@1.1.2(transitive)
+ Added@types/node@12.20.55(transitive)
+ Addedboolean@3.2.0(transitive)
+ Addedbuffer-crc32@0.2.13(transitive)
+ Addedbuffer-from@1.1.2(transitive)
+ Addedcacheable-request@6.1.0(transitive)
+ Addedclone-response@1.0.3(transitive)
+ Addedconcat-stream@1.6.2(transitive)
+ Addedconfig-chain@1.1.13(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addeddebug@2.6.94.3.7(transitive)
+ Addeddecompress-response@3.3.0(transitive)
+ Addeddefer-to-connect@1.1.3(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddefine-properties@1.2.1(transitive)
+ Addeddetect-node@2.1.0(transitive)
+ Addedduplexer3@0.1.5(transitive)
+ Addedelectron@8.2.0(transitive)
+ Addedencodeurl@1.0.2(transitive)
+ Addedend-of-stream@1.4.4(transitive)
+ Addedenv-paths@2.2.1(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedes6-error@4.1.1(transitive)
+ Addedescape-string-regexp@4.0.0(transitive)
+ Addedextract-zip@1.7.0(transitive)
+ Addedfd-slicer@1.1.0(transitive)
+ Addedfs-extra@8.1.0(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.4(transitive)
+ Addedget-stream@4.1.05.2.0(transitive)
+ Addedglobal-agent@3.0.0(transitive)
+ Addedglobal-tunnel-ng@2.7.1(transitive)
+ Addedglobalthis@1.0.4(transitive)
+ Addedgopd@1.0.1(transitive)
+ Addedgot@9.6.0(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.0.3(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedhttp-cache-semantics@4.1.1(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedini@1.3.8(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedjson-buffer@3.0.0(transitive)
+ Addedjson-stringify-safe@5.0.1(transitive)
+ Addedjsonfile@4.0.0(transitive)
+ Addedkeyv@3.1.0(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedlowercase-keys@1.0.12.0.0(transitive)
+ Addedmatcher@3.0.0(transitive)
+ Addedmimic-response@1.0.1(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp@0.5.6(transitive)
+ Addedms@2.0.02.1.3(transitive)
+ Addednormalize-url@4.5.1(transitive)
+ Addednpm-conf@1.1.3(transitive)
+ Addedobject-keys@1.1.1(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedp-cancelable@1.1.0(transitive)
+ Addedpend@1.2.0(transitive)
+ Addedpify@3.0.0(transitive)
+ Addedprepend-http@2.0.0(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedprogress@2.0.3(transitive)
+ Addedproto-list@1.2.4(transitive)
+ Addedpump@3.0.2(transitive)
+ Addedreadable-stream@2.3.8(transitive)
+ Addedresponselike@1.0.2(transitive)
+ Addedroarr@2.15.4(transitive)
+ Addedsafe-buffer@5.1.2(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)
+ Addedstring_decoder@1.1.1(transitive)
+ Addedsumchecker@3.0.1(transitive)
+ Addedto-readable-stream@1.0.0(transitive)
+ Addedtunnel@0.0.6(transitive)
+ Addedtype-fest@0.13.1(transitive)
+ Addedtypedarray@0.0.6(transitive)
+ Addeduniversalify@0.1.2(transitive)
+ Addedurl-parse-lax@3.0.0(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addedwrappy@1.0.2(transitive)
+ Addedyauzl@2.10.0(transitive)