npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

electron-window-helper

v0.1.2

Published

A window helper for electron

Downloads

4

Readme

Electron Window Helper

This is an helper tool for electron window management and communication inter renderer process or between renderer process and main process

Electron's main process and renderer process execute script in differert environment, we can use ipcMain and ipcRenderer send and receive message between main process and render process,there is also a BrowserWindow.webContents.send method.

**How we send message to other renderder process from renderer process directly? **

First, we call remote.BrowserWindow.getAllWindows method get all windows, then find the window object, then call webContents.send of the window object.

**How we find the target window? Does target window have a name attribute? **

There is only an id attribute.

**How about add a name to the window? ** I did this for you.

Features

have a container that contains all window we create, so we can find a target window by calling helper.get(name) method.

  1. Add name attribute to BrowserWindow
  2. There is a Window Container, it is easy to create and get a window object
  3. A Wrapper for IPC, renderer process can communication win each other "directly"

More detail see the docs

Before i wrote this tool, I find electron-window-manager, I tryed to commit to this module, but it is very hard to make big change.

I am still working on it, issue me when you get problems

Install

npm install --save electron-window-helper

install with --save, this package should be packed into you app client

Usage

// in main process
const electron = require('electron')
const app = electron.app
const helper = require('electron-window-helper')

let url = {
  home: `file://${__dirname}/app/home.html`,
  login: `file://${__dirname}/app/login.html`
}

app.on('ready', () => {
  // create and open home window
  let home = helper.open('home', url['home'], {
  	width: 800,
    height: 600,
    title: 'home window'
  })

  // create login window but hide
  let login = helper.create('home', url['login'], {
    width: 400,
    height: 300,
    title: 'login window',
    frame: false,
    show: false,
    center: true,
    movable: false
  })
})
-----------------------------------------------------------
// in home window js file
const electron = require('electron')
const helper = require('electron-window-helper/renderer')

// get current window
let win = helper.currentWindow
console.log('currentWindow is ', win.name)

// register linstener on `hello` channel
helper.on('hello', (data, from) => {
  console.log(`received ${data} from ${from} window`)
  // print `receive i am login from login window`
})

// show login window
helper.show('login')
-----------------------------------------------------------
// in login window js file
const electron = require('electron')
const helper = require('electron-window-helper/renderer')

// send msg to home window
helper.currentWindow.on('show', () => {
  helper.send('hello', 'i am login', 'home')
})

Detailed usage