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

bs-react-sdk

v0.0.26

Published

AI 组件库,包含 AIAssentComponent 等 React 组件。

Readme

AIAssentComponent 集成与页面适配说明

组件功能

  • 支持 AI 助手弹窗模式(可拖拽、缩放、悬浮按钮触发)
  • 支持嵌入模式(页面右侧 300px 区域平铺)
  • 模式切换按钮可在两种模式间切换
  • 支持通过 assentIdurl 参数初始化

页面集成方式

1. 页面结构调整(推荐带历史同步的写法)

import React, { useState } from 'react';
import AIAssentComponent from '@/components/AIAssentComponent';

export default function IndexPage(props) {
  const [embedMode, setEmbedMode] = useState(false);
  const [history, setHistory] = useState([]);
  return (
    <div style={{ display: 'flex', height: '100vh' }}>
      <div style={{ flex: embedMode ? '0 0 calc(100vw - 300px)' : 1, transition: 'flex 0.3s', minWidth: 0 }}>
        {/* 页面主内容 */}
        {props.children}
      </div>
      {/* 嵌入模式下助手区域 */}
      <div style={{ width: embedMode ? 300 : 0, transition: 'width 0.3s', background: embedMode ? '#fff' : 'transparent', boxShadow: embedMode ? '0 2px 8px #0001' : 'none', overflow: 'hidden', height: '100vh' }}>
        {embedMode && (
          <AIAssentComponent
            assentId="demo-assistant-001"
            url=""
            mode="embed"
            visible={embedMode}
            history={history}
            onModeSwitch={(mode, newHistory) => {
              setEmbedMode(mode === 'embed');
              if (newHistory) setHistory(newHistory);
            }}
          />
        )}
      </div>
      {/* 浮窗模式下助手 */}
      {!embedMode && (
        <AIAssentComponent
          assentId="demo-assistant-001"
          url=""
          mode="float"
          visible={!embedMode}
          history={history}
          onModeSwitch={(mode, newHistory) => {
            setEmbedMode(mode === 'embed');
            if (newHistory) setHistory(newHistory);
          }}
        />
      )}
    </div>
  );
}

2. 模式切换通信

  • 推荐通过全局状态管理(如 React Context、Redux)或自定义事件实现 embedMode 状态同步。
  • 组件内部可通过 props、window 事件等方式通知父级切换模式。

3. 组件参数

  • assentId:助手唯一标识,必填
  • url:可选,后端接口地址

4. 适配建议

  • 页面主内容区域需设置 flex,以便助手嵌入时自动收缩宽度
  • 嵌入模式下助手区域宽度建议为 300px
  • 保证页面高度为 100vh,避免助手区域溢出

如需自定义样式或交互,可参考 src/components/AIAssentComponent.tsx 进行扩展。