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

envision-sdk

v0.2.1

Published

Envision SDK

Downloads

12

Readme

envision-sdk

Envision SDK

Getting started

package.json

You can put informations in your package.json, will be used for marketplace interface in Envision

{
  "name": "envision-nes",
  "author": "Florian H-J",
  "main": "index.js",
  "envision": {
    "name": "NES Emulator",
    "icon": "https://upload.wikimedia.org/wikipedia/commons/3/30/Nes_controller.svg",
    "category": "games",
    "description": "Emulator of Nintendo NES, controllable from any computer (WS remote) to play with 2 colleagues.",
    "screen": true,
    "config": true
  }
}

index.js

Your main file, specified in package.json

const EnvisionModule = require('envision-sdk')

class MonSuperModule extends EnvisionModule {

  /*
    Functions needed for starting
  */

  // Called when module is initialized, by envision start or installing
  onStart (server, cb) {
    //server is `express()`, you can handle other routes if needed
    return cb()
  }


  // Called when dashboard is stopped or system shutdown
  onStop (cb) {
    console.log('Good bye!')
    return cb()
  }


  /*
    Express handler, refer to https://expressjs.com/en/4x/api.html for API
  */

  // Route for settings (on your computer)
  onRemote (req, res) {
    res.send('We are on a remote client')
  }

  // Route for envision system, displayed on screen
  onLocal (req, res) {
    res.send('We are on envision dashboard')
  }
}

exports = new MonSuperModule()

Methods

this.setDashboardUrl(<url>)
this.getDashboards(cb)
this.getModules(cb)
this.getDashboardInfos(cb)
this.pushNotification(<type(error)>, <text>)

Serve static files

You can override express functions

const express = require('express')

class MonSuperModule extends EnvisionModule {
  onStart (server, cb) {
    this.onRemote = express.static('remote')
    cb()
  }
}

Add routes

Example with POST upload route for remote configuration

const remoteRouter = express.Router()

var upload = multer({ dest: process.env.HOME + '/' })

remoteRouter.get('/', (req, res) => {
  res.sendFile(__dirname + '/remote.html')
})

remoteRouter.post('/upload', upload.single('file'), function(req, res) {
  let source = fs.createReadStream(req.file.path)
  let destination = fs.createWriteStream(process.env.HOME + '/video.mp4')

  source.pipe(destination, { end: false });
  source.on("end", function(){
      fs.unlinkSync(req.file.path)
      res.send('Good!')
  })
})

class MonSuperModule extends EnvisionModule {
  onStart (server, cb) {
    console.log('started')
    this.onRemote = remoteRouter
    return cb()
  }
}

API

EnvisionModule contains API to make some actions on Envision

setDashboardUrl

Can set Envision interface to a specific URL

Example:

this.setDashboardUrl('https://keymetrics.io/')

getDashboards

List all dashboards in your internal networks NB: development and production dashboards are separated.

Example:

this.getDashboards(dashboards => {
  dashboards = [
    {
      "port": 3110,
      "host": "192.168.0.138",
      "infos": {
        "ip": "192.168.0.138",
        "version": "0.2.34",
        "hostname": "florian-debian",
        "name": "florian-debian",
        "uptime": 417300
      }
    }
  ]

})

getModules

List all modules installed in current Envision system

Example:

this.getModules(modules => {
  modules = [
    {
      "id": "envision-nes",
      "name": "NES Emulator",
      "icon": "https://upload.wikimedia.org/wikipedia/commons/3/30/Nes_controller.svg",
      "author": {
        "name": "Florian H-J"
      },
      "version": "1.0.9",
      "category": "games",
      "description": "Emulator of Nintendo NES, controllable from any computer (WS remote) to play with 2 colleagues.",
      "screen": true,
      "config": true,
      "status": "online",
      "linked": true
    }
  ]

})

getDashboardInfos

Get current informations about current Envision system

Example:

this.getDashboardInfos(infos => {
  infos = {
    "ip": "192.168.0.138",
    "version": "0.2.34",
    "hostname": "florian-debian",
    "name": "florian-debian",
    "uptime": 417803
  }
})

pushNotification

Send notification to Envision interface NB: if sound is at 0%, notification sound is not played

Example:

this.pushNotification('confirm', 'Success!', () => {
  console.log('Notification sent')
})