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

js-desktop-base

v5.5.1

Published

Helper utilities for creating an electron desktop app.

Downloads

26

Readme

JS Desktop Base

Helper utilities for creating an electron desktop app.

Platform support

The keySender and keyHook utilities, which sends and listen to key presses respectively, have OS specific dependencies:

  • For windows, this relies on powershell, user32.dll, and kernel32.dll.
  • For linux, this relies on bash, xdotool, and xinput.
  • Not tested on mac, but should work with replacements for xdotool and xinput.

Utilities

keySender

const {keySender} = require('js-desktop-base');
keySender.string(keySender.TYPE, 'hello world');
keySender.strings([
	keySender.PRESS, '{shift}',
	keySender.TYPE, 'hello world',
	keySender.RELEASE, '{shift}',
	keySender.COMBO, '{ctrl}a',
	keySender.COMBO, '{ctrl}c',
]);

keyHook

const {keyHook} = require('js-desktop-base');

keyHook.addShortcut('{ctrl}{l_shift}', 'ab', () =>
	console.log('Either "a" or "b" was pressed while holding down the left shift and either the left or right ctrl modifiers.'));

appReadyPromise

ClipboardListener

const {ClipboardListener} = require('js-desktop-base');
let clipboardListener = new ClipboardListener();
clipboardListener.addListener(data =>
	console.log('each time user copies, this will be called', data));
clipboardListener.getNext().then(data =>
	console.log('the next time the user copies, this will be called', data));
clipboardListener.copy().then(data =>
	console.log('will send ctrl+c and then invoke getNext()', data));
clipboardListener.paste('sets this text as the clipboard data and sends ctrl+v');

httpRequest

const {httpRequest} = require('js-desktop-base');
httpRequest.get('endpoint.com')
    .then(response => console.log(response));
httpRequest.get('endpoint.com', {queryParam1: 1, queryParam2: 2})
    .then(response => console.log(response));
httpRequest.post('endpoint.com', {data1: 1, data2: 2})
    .then(response => console.log(response));

ScreenMouse

const {ScreenMouse} = require('js-desktop-base');
ScreenMouse.getMouse().then(({x, y}) => console.log(x, y));
ScreenMouse.getScreenBounds().then(({x, y, width, height}) => console.log(x, y, width, height));

ShortcutListener

Note: try using keyHook instead.

const {ShortcutListener} = require('js-desktop-base');
ShortcutListener.add('Control+Shift+X', () => console.log('ctrl+shift+x preessed'));

TrayHelper

const {TrayHelper} = require('js-desktop-base');
TrayHelper.createExitTray('icon.png', 'tooltip');

ViewHandle

const {ViewHandle} = require('js-desktop-base');

class MyViewHandle extends ViewHandle {
	constructor() {
        super({
            width: 500,
            height: 450,
            frame: false,
            thickFrame: false,
            skipTaskbar: true,
            alwaysOnTop: true,
            show: false,
            webPreferences: {nodeIntegration: true}
        }, path.join(__dirname, './view/View.html'));
	}
	
    onMessage(message){
    	console.log('recieved message from renderer process', message)
    }
}

let viewHandle = new MyViewHandle();
viewHandle.resize(300, 300);
viewHandle.move(500, 500);
viewHandle.validateOnScreen();
viewHandle.show(3000); // show for n seconds. If 0 or not provided, will keep visible.
viewHandle.hide();
console.log('view handle is visible?', viewHandle.visible);
viewHandle.send('hi from main process');
viewHandle.addWindowListener('blur', () => console.log('window blurred'));

XPromise

const {XPromise} = require('js-desktop-base');
let promise = new XPromise();
promise.then(a => console.log(a));
promise.catch(a => console.log(a));
if (Math.random() > .5) 
    promise.resolve('resolved');
 else
    promise.reject('rejected');

RateLimitedRetryQueue

const {RateLimitedRetryQueue} = require('js-desktop-base');
let queue = new RateLimitedRetryQueue();
queue.add(asyncGet1);
queue.add(asyncGet2);
queue.add(asyncGet3);