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

vite-plugin-vibe

v0.1.1

Published

Inject data-source metadata and the Vibe Canvas preview SDK into a Vite + React dev server.

Downloads

561

Readme

@vibe/vite-plugin

Vibe Canvas 的开发期 Vite 插件。它只影响 vite dev:

  1. 给第一方 JSX/TSX 的每个 JSX 元素注入:

    data-source="src/components/Card.tsx:12:5"
    data-source-kind="host|component-usage"
    data-component="Card"
  2. 在 index.html 头部自动注入 /@vibe/sdk.js;

  3. 在内存中维护源码片段注册表,并通过 /__vibe/snippets 提供给 SDK;

  4. 生产构建不注入任何属性、片段或 SDK。

构建与分发

cd vite-plugin-vibe
npm install
npm run build      # 输出 dist/index.js + dist/sdk.js
npm pack           # 生成 vibe-vite-plugin-0.1.0.tgz
  • package.json 的 main / module / exports 均指向 dist/index.js;
  • sdk.js 必须与 index.js 同目录,运行时通过 import.meta.url 读取;
  • prepare 会在安装或打包前自动构建;
  • dist/ 是构建产物,不提交到 Git。

接入用户项目

方式一:打包后安装(推荐用于跨项目验证)

npm install -D /absolute/path/to/vite-plugin-vibe/vibe-vite-plugin-0.1.0.tgz

方式二:npm link

cd vite-plugin-vibe
npm install
npm run build
npm link

cd /path/to/your-vite-react-app
npm link @vibe/vite-plugin

方式三:直接引用本地目录

npm install -D file:/absolute/path/to/vite-plugin-vibe
// vite.config.js
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite'
import vibe from '@vibe/vite-plugin'

export default defineConfig({
  // vibe 必须在 react 之前执行;插件自身也声明了 enforce: 'pre'。
  plugins: [vibe(), react()],
})

启动项目:

npm run dev -- --host 127.0.0.1 --port 5173

然后在画布输入 http://127.0.0.1:5173。不需要导入 HTML 文件,也不需要手写 SDK 脚本。

选项

vibe({
  // 默认只处理 .jsx / .tsx;如果项目使用 .js 写 JSX,可显式放宽。
  include: /\.(jsx|tsx)$/,
})

端点(仅 dev server)

| 路径 | 用途 | |---|---| | /@vibe/sdk.js | 注入到页面的浏览器 SDK | | /__vibe/snippets | data-source → JSX 片段注册表 | | /__vibe/health | 插件状态与已收集片段数量 |

边界

  • 只处理 Vite root 内、文件名符合后端 Source 正则的第一方文件;node_modules 不处理。
  • 组件若吞掉未知 props,data-source 可能不落到 DOM;此时可用组件内部根宿主节点的锚点,或该元素不可提交。
  • 动态字符串/innerHTML/第三方 DOM 不在编译期覆盖范围。
  • Fragment、非 JSX 节点不注入。
  • HMR 会重新收集当前文件片段;历史行号可能随源码编辑改变,这是 dev 期预期行为。

验证

curl http://127.0.0.1:5173/__vibe/health
curl http://127.0.0.1:5173/__vibe/snippets
curl http://127.0.0.1:5173/src/App.jsx | grep data-source