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

knectron

v0.1.16

Published

Connect Electron to remote source such as Create React App.

Downloads

32

Readme

Knectron

Utility to connect Electron to remote source such as Create React App.

At first you may think this is overkill but we wrote this as it just connects/fires up in a little cleaner manner. Once you get the hang of it, you'll likely find it useful.

Quick Start

$ npm install knectron

Using API

const knectron = require('../dist/knectron');

knectron({
  args: ['./dist'] // first arg is path to electron app
});

Knectron Options

interface IConnectOptions {
  port?: number;                  // port to listen on (default: 3000)
  host?: string;                  // host to listen on (default: 127.0.0.1)
  spawnOptions?: SpawnOptions;    // child_process options (default: { stdio: pipe })
  args?: any[];                   // args passed to Electron (default: './dist')
  maxTries?: number;              // max reconnect tries (default: 5)
  retryDelay?: number;            // delay between retries (default: 1200)

  // API ONLY - NO CLI
  onConnected?: (url?: string) => void;
  onFailed?: (tries?: number) => void;
  onRetry?: (tries?: number) => void;
  onExit?: (err: Error) => void;
}

Using CLI

Knectron comes with a simple CLI. You can either install globally:

Using Globally

Install Knectron globally.

$ npm install knectron -g

One in your path you can do the following where args after "--" are passed directly to electron as shown here below.

$ knectron ./main.js -- --enable-logging

Using NPM Script

Or you can use npm scripts to execute:

{
  "scripts": {
    "knectron": "knectron ./main.js"
  }
}

Then simply run the script as you would any npm script:

$ npm run knectron

CLI Help

To display help from your terminal run:

$ knectron --help

You will see the below help:

`Usage: knectron <path> [options]

Options:
  --port            the port to connect to
  --host            the host to connect to
  --silent          hides retries
  --max-tries       maximum connection retries
  --retry-delay     delay until retry
  --spawn-options   Node child_process spawn options
  --help, -h        display help
  --examples        show examples

Args provided after "--" directly passed to Electron`

CLI Examples

From your terminal type:

$ knectron --examples

The following will be shown:


`Examples:
  knectron ./main.js --host=127.0.0.1 --port=5000
  knectron ./main.js -- --enable-logging --v=5
  knectron ./main.js --spawn-options.stdio=inherit
  knectron ./main.js --spawn-options.stdio='[0,1,2]'`