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-wendy

v0.1.3

Published

A window manager for your Electron apps !

Downloads

1

Readme

electron-wendy

A window manager for your Electron apps !

Installation

npm i --save electron-wendy or git clone https://github.com/nash403/electron-wendy.git

Usage

TL;DR:

Wendy is a window manager for Electron that provides convenient methods to create, remove, replace or give names to windows/modals.

With Wendy you can create and show a window at the same time and even pass argument to the new window in a single call:

const { app } = require('electron')
const path = require('path')
const Wendy = require('electron-wendy')
app.on('ready', () => {
  const mainWindow = Wendy.create('mainWin', {
    showNow: true,
    showPath: path.resolve(__dirname, '..', 'some-location', 'index.html'),
    showArgs: { data: 'hello' }
  }) // this creates a window called 'mainWin' and shows it. window.__args__ will then be populated in the new window
})

/**
  * To show the window immediately at creation, the property 'showNow' must be set to true,
  * otherwise you need to call showUrl on the returned instance.
  */

This package relies on the simple but powerful package electron-window. You can go and see their repo for more informations.

API Fields

windows

Object that keeps track of all windows created by Wendy.

API Methods

create([name], [options])

Class method that creates a new BrowserWindow with the following default options: { show: false, width:600, height:400 }.

createModal(parent, [name], [options])

Creates a modal window whose parent window is parent. Properties name and and options are optional and same as for create except that default width is now 400 and height is 250.

createModalWithResponse(parent, eventName, [name], [options])

Same as above except that you must give an eventName that is used to transfer the response data from the modal to the parent window.

In the modal window, when you are finished and need to emit the response, send via ipcRenderer a message with your data to the channel provided as argument above. Then in the parent window (with window instance, not with ipcRenderer !!), listen for an event on that channel.

Example:

// in the renderer process of the parent window
const Wendy = require('electron-wendy')
document.getElementById('modalise-btn').onclick = function () {
  let thisWindow = require('electron').remote.getCurrentWindow()
  let modal = Wendy.createModalWithResponse(thisWindow,'some-channel-name')
  thisWindow.once('some-channel-name', (...response) => {
    console.log('your response is here !', ...response)
  })
}

// in the renderer process of your modal
document.getElementById('close-btn').onclick = function () {
  require('electron').ipcRenderer.send('some-channel-name',{data:'some data 1'}, {status:'some data 2'})
  window.close() // You should always close the modal after emitting your result
}

getName(win)

Retrieves the name of the given window or null if not found

getByName(name)

Gets the window named by the given parameter.

Note: If you have stored a reference to a window created with Wendy you can check the name at the property winName.

getById(id)

Gets the window whose id is the given parameter or null if not found

has(name)

Tests if Wendy is currenty managing a window named by the given parameter. Returns true or false.

add(win, [name])

If you somehow have a window instance created without Wendy, you can add it to Wendy with this method.

remove(win)

Removes the given window from Wendy.

replace(name, newWindowOptions)

Removes a window whose name is name and creates a new one with the same name. newWindowOptions are the same as the create method.

on(evName, callback), once(evName, callback), off(evName, callback)

Wendy has a emitter property that is a Node.js EventEmitter. With these methods you can register and unregister events with Wendy.

emit(evName, options, [...args])

Emits events through the emmitter property of Wendy.

  • options is an object you can set with the following properties:
    • options.emittedBy: BrowserWindow instance that initiated the event.
    • options.target: string or BrowserWindow that represents the target window for this event.
  • ...args is a set of argument that can be passed through this event.

Methods in the created BrowserWindow instance

showUrl(indexPath, [someArgs], [callback])

Shows the url. When the url is finished loading, the callback is returned. If the optional argsForRenderer is set then args will be a global object for the page in the renderer process. This is a convenient way to pass arguments from the main process to the renderer process.

Note : All other methods available in electron-window are also available in the instance returned by Wendy.

Native dialogs

Wendy also provides links to the Electron native functions for dialogs (showOpenDialog, showSaveDialog, showMessageBox and showErrorBox). You can read the related doc here.

License

MIT