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

cx-component-library

v1.0.0

Published

畅学通用组件和API库

Readme

@your-org/shared-lib

跨团队、跨技术栈复用的通用组件和 API 库。

特性

  • 🚀 支持 ESM 和 CommonJS 双模块格式
  • 📦 TypeScript 类型支持
  • 🎨 框架无关的核心逻辑
  • ⚛️ React 组件支持
  • 💚 Vue 2/3 组件支持
  • 🔧 Node.js 20+ 支持

安装

npm install @your-org/shared-lib
# 或
yarn add @your-org/shared-lib
# 或
pnpm add @your-org/shared-lib

使用

初始化 HTTP 客户端

import { initHttp } from '@your-org/shared-lib/api'

initHttp({
  baseUrl: 'https://api.example.com',
  timeout: 30000,
  getToken: () => localStorage.getItem('token'),
  getLanguage: () => 'zh-CN',
  onUnauthorized: () => {
    window.location.href = '/login'
  }
})

使用 API

import { getUserInfo, getApplab, postSession } from '@your-org/shared-lib/api'

// 获取用户信息
const user = await getUserInfo()

// 获取 Applab 数据
const applab = await getApplab('123')

// 创建会话
const session = await postSession({ gpt_id: 1 })

OSS 上传

import { uploadImage, uploadVideo, uploadBase64Image } from '@your-org/shared-lib/api'

// 上传图片
const imageUrl = await uploadImage(file)

// 上传视频
const videoUrl = await uploadVideo(file, 'gpt-video')

// 上传 Base64 图片
const url = await uploadBase64Image(base64String)

React 组件

import { SharedHeader } from '@your-org/shared-lib/react'

function App() {
  return (
    <SharedHeader
      userInfo={{ id: 1, name: '用户名' }}
      schoolInfo={{ logo: '/logo.png', name: '学校名' }}
      isLogin={true}
      hasRoles={true}
      onLogout={() => console.log('logout')}
      onLogin={() => console.log('login')}
    />
  )
}

Vue 组件

<template>
  <SharedHeader
    :user-info="userInfo"
    :school-info="schoolInfo"
    :is-login="true"
    @logout="handleLogout"
    @login="handleLogin"
  />
</template>

<script>
import { SharedHeader } from '@your-org/shared-lib/vue'

export default {
  components: { SharedHeader },
  data() {
    return {
      userInfo: { id: 1, name: '用户名' },
      schoolInfo: { logo: '/logo.png', name: '学校名' }
    }
  },
  methods: {
    handleLogout() { /* ... */ },
    handleLogin() { /* ... */ }
  }
}
</script>

工具函数

import { getCookies, setCookies, removeCookies } from '@your-org/shared-lib'
import { dataURLtoFile, readFileAsArrayBuffer } from '@your-org/shared-lib'

// Cookie 操作
setCookies('token', 'xxx')
const token = getCookies('token')
removeCookies('token')

// 文件操作
const file = dataURLtoFile(dataUrl, 'image.png')
const buffer = await readFileAsArrayBuffer(file)

API 列表

用户相关

  • getUserInfo() - 获取用户信息
  • getAccounts() - 获取用户资金信息
  • bindPhone(data) - 绑定手机
  • getPhoneCode(params) - 获取手机验证码

GPT 相关

  • getCustomGptList(params) - GPT 列表
  • getCustomGpt(id) - GPT 详情
  • postCustomGpt(data) - 创建 GPT
  • putCustomGpt(data, id) - 更新 GPT
  • delCustomGpt(id) - 删除 GPT

会话相关

  • postSession(data) - 创建会话
  • getSessionList(params) - 会话列表
  • putSession(data, id) - 更新会话
  • delSession(id) - 删除会话

OSS 上传

  • uploadImage(file) - 上传图片
  • uploadVideo(file, folder) - 上传视频
  • uploadText(content) - 上传文本
  • uploadHtml(content) - 上传 HTML
  • uploadMusic(file) - 上传音乐
  • uploadBase64Image(base64) - 上传 Base64 图片

开发

# 安装依赖
npm install

# 开发模式
npm run dev

# 构建
npm run build

# 测试
npm test

# 代码检查
npm run lint

发布

# 更新版本号
npm version patch/minor/major

# 发布到 npm
npm publish --access public

License

MIT