1.0.3 • Published 6 years ago

electron-lib v1.0.3

Weekly downloads
1
License
Apache-2.0
Repository
github
Last release
6 years ago

Electron-Lib

npm version

Some helper functions to accelerate your Electron development work

Register App Protocol

Why you need to use file protocol or local file path to locate your files? With the follow code, you can use app://views/welcome/index.html to locate file://path/to/app/views/welcome/index.html

In app.js

const elib = require('electron-lib')
elib.registerAppProtocol()

Window Creation and Management

const elib = require('electron-lib')
const options = {width: 600, height: 400}
elib.windows.createOrActivate('welcome', 'app://views/welcome/index.html', options)
// some time later...
elib.windows.activate('welcome')

IPC Between Browser Window and Main Process

The default ipc methods are too complex. We need just one line

// In main process
const elib = require('electron-lib')
elib.ipc.registerIPCHandler('newwin', (url, name) => {
  elib.windows.createOrActivate(name, url, {width: 640, height: 480})
})

// In renderer process (browser window)
ipc.handleIPCRequest('newwin', ['https://github.com/', 'github'])
1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago