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 🙏

© 2026 – Pkg Stats / Ryan Hefner

tinky-mouse

v1.0.1

Published

Mouse event handling for tinky applications

Readme

tinky-mouse 🐭

适用于 tinky 应用程序的鼠标事件处理。

tinky-mouse 为使用 tinky 构建的终端应用程序提供了一套强大的鼠标事件处理系统。它显式支持 SGR (1006) 和 X11 鼠标追踪协议,并提供了 React 友好的 API。

功能特性

  • 协议支持:同时处理 SGR (1006) 和传统的 X11 鼠标追踪。
  • 丰富的事件:检测点击(左键、右键、中键)、释放、滚动(上、下、左、右)以及移动。
  • React Hooks:易于使用的 useMouse hook,方便在组件中使用。
  • 基于 Context:通过 MouseContext 进行高效的事件分发。

安装

npm install tinky-mouse

使用方法

使用 MouseProvider 包裹你的应用程序,并在组件中使用 useMouse hook。

1. 设置 Provider

import React from "react";
import { render } from "tinky";
import { MouseProvider } from "tinky-mouse";
import App from "./App";

render(
  <MouseProvider mouseEventsEnabled={true}>
    <App />
  </MouseProvider>,
);

2. 监听事件

import React, { useState } from "react";
import { Text } from "tinky";
import { useMouse } from "tinky-mouse";

function ClickCounter() {
  const [count, setCount] = useState(0);

  useMouse((event) => {
    if (event.name === "left-press") {
      setCount((c) => c + 1);
    }
  });

  return <Text>Clicks: {count}</Text>;
}

API 参考

MouseProvider

启用鼠标追踪的顶层组件。

| 属性 | 类型 | 描述 | | -------------------- | ----------- | ----------------------------------- | | children | ReactNode | 子组件。 | | mouseEventsEnabled | boolean | 是否启用鼠标追踪。默认值:false。 |

useMouse(handler, options)

用于订阅鼠标事件的 Hook。

| 参数 | 类型 | 描述 | | --------- | ----------------------------- | ------------------------------------ | | handler | (event: MouseEvent) => void | 鼠标事件的回调函数。 | | options | { isActive?: boolean } | 可选配置。isActive 默认为 true。 |

MouseEvent 对象

interface MouseEvent {
  name: MouseEventName; // 'left-press', 'scroll-up', 'move' 等
  col: number; // 列 (x)
  row: number; // 行 (y)
  shift: boolean; // 是否按住 Shift 键
  meta: boolean; // 是否按住 Meta/Alt 键
  ctrl: boolean; // 是否按住 Ctrl 键
  button: "left" | "middle" | "right" | "none";
}

许可证

Apache-2.0