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 🙏

© 2025 – Pkg Stats / Ryan Hefner

jarvis-replica

v0.2.5

Published

Jarvis受控端

Readme

Jarvis Replica

Jarvis 大屏受控端, 查看演示项目

安装

npm install jarvis-replica

使用

import JarvisReplica from 'jarvis-replica'

const replica = new JarvisReplica({
  url: `ws:127.0.0.1:3000`,
  secrets: '5r9b4vto246doa9hwk55rr',
  id: 'vis-1'
})

// 连接服务器
replica.connect()

| 参数名 | 说明 | 类型 | 必填 | |-----------|------------------------------------|---------|---------| | url | Jarvis 服务器地址 | string | true | | secrets | 服务器设置的密码 | string | true | | id | 受控端的唯一ID | string | false |

监听事件

你可以使用 on 方法监听事件:

replica.on('open', (e) => {
  console.log('已经连接到控制服务器!')
})

replica.on('command', (e) => {
  console.log('接收自定义事件')
})

replica.on('*', data => {
  console.log('接收所有的自定义事件')
})

目前支持的事件如下:

| 事件名 | 说明 | 参数 | |-----------|------------------------------------|---------------------------------- | | open | 连接到控制服务器 | - | | error | 连接出错 | - | | close | 连接断开 | - | | reconnect-fail | 重连失败 | - | | * | 所有自定义 command 事件 | {command: 'type', arguments: {}}| |[ command ]| 自定义事件 | 参数对象 |

心跳检测

服务端每隔 10s 会向受控端发送 ping 事件, 受控端返回 pong, 若检测到断开连接, 则每隔 10s 尝试重连一次, 连续三次重连失败, 受控端会发送 reconnect-fail 事件给页面, 后续逻辑需要监听事件自行处理

replica.on('reconnect-fail', () => {
  console.log('replica跟server断开连接, 并尝试重连失败')
})

其他

目前受控端支持接收来自三种方式发送的指令, 具体使用方式请参考相关文档

  • controller.send 发送的指令
  • 直接通过服务端, 使用 server.sendToReplica 发送的指令
  • 其他server通过http发送的指令

服务端和控制端的使用方式, 可查阅下方文档

Jarvis 服务端地址

Jarvis 控制端地址

Jarvis 演示项目代码地址