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

@yanqirenshi/colonoscope

v0.1.0

Published

Element inspector panel for the d3.* diagram family — view and edit a clicked element's data (the endoscope that looks inside the Colon)

Readme

@yanqirenshi/colonoscope

図の要素を「覗いて」表示・編集する汎用インスペクタパネル(React コンポーネント)です。

assh0le / Colon / Rectum に連なる命名 — Colon の中を覗く内視鏡(colonoscope)。 内視鏡は観察だけでなく処置もできる、つまり「表示 + 編集」です。

設計原則

d3.* パッケージは描画のみの原則を保ちます。Colonoscope は:

  • d3.* のクリックコールバックが渡す datum を受け取って表示する
  • 編集結果は onApply({ path: 値 }) で通知するだけ
  • データの所有と再描画はホストアプリの責務(多くのペインタは enter-only join のため、 再マウント方式 — 例えば key={version} — が確実)

d3.* 側は Colonoscope を知りません(依存は一方向)。スタイルは自己完結(インライン)で、 className(colonoscope / colonoscope__*)も付与するので CSS での上書きも可能です。

使い方

import Colonoscope from '@yanqirenshi/colonoscope';

// 例: d3.deployment との接続
const [selected, setSelected] = useState(null);
const [version, setVersion] = useState(0);

const rectum = useMemo(() => {
  const r = new Rectum({
    callbacks: { node: { click: (node) => setSelected(node) } },
  });
  r.data(data);
  return r;
}, [version]);

<div style={{ position: 'relative' }}>
  <D3Deployment key={version} rectum={rectum} />

  <Colonoscope
    target={selected}                          // null で非表示
    title={(t) => t.label?.text}               // 省略時は _id
    subtitle={(t) => t.type}
    fields={[
      { path: 'label.text',  label: '名称', type: 'text' },
      { path: 'description', label: '説明', type: 'textarea' },
      { path: '_id',         label: 'ID',   type: 'readonly' },
    ]}
    onApply={(values) => {                     // { 'label.text': '...', ... }
      applyToData(values);                     // 入力データへ書き戻し(ホスト側)
      setSelected(null);
      setVersion((v) => v + 1);                // 再描画
    }}
    onClose={() => setSelected(null)}
  />
</div>

フィールド型

| type | 表示 | |---|---| | text | 1行テキスト入力 | | textarea | 複数行入力 | | number | 数値入力 | | readonly | テキスト表示のみ |

「適用」ボタンは値が変更されたときだけ有効になります。

コマンド

npm run build     -w @yanqirenshi/colonoscope   # tsc で dist/ へビルド(d.ts 含む)
npm run typecheck -w @yanqirenshi/colonoscope
npm test          -w @yanqirenshi/colonoscope   # vitest