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

@xiao-ying/miniapp-xy-kit

v1.2.0

Published

Reusable kit for XiaoYing backend miniapps

Readme

@xiao-ying/miniapp-xy-kit

面向小应后端小程序的通用业务套件,基于 miniapp SDK 与 UI 体系封装常用能力与高阶组件。

安装

pnpm add @xiao-ying/miniapp-xy-kit

包含内容

  • 认证守卫与登录拦截
  • 请求客户端中间件(错误提示/登录过期处理)
  • 小应选校门禁 Hook(自动弹出选校提示与选校 Sheet)
  • 直传上传辅助

API 概览

  • createAuthGuardLoader:路由级登录守卫(配合 react-router-dom loader)。
  • createLoginInterceptor:请求 401 处理(默认触发 xy.signIn)。
  • createErrorToastMiddleware / defaultErrorSchema:请求错误 toast 提示。
  • directXyUpload:直传上传(先取 token,再上传文件)。
  • createXyKit:注入业务请求客户端,获得 xyKit.useSchoolGate 等小应业务能力。
  • useSelectedSchool:轻量选中学校 Hook(env / storage 双源)。
  • SchoolSelectionProvider / useSchoolSelection / SchoolSelectionGate / SchoolSelectPanel 已废弃:请改用业务树内的 OverlayProvider + createXyKit({ apiClient }).useSchoolGate

快速示例

认证守卫(React Router):

import { createAuthGuardLoader } from '@xiao-ying/miniapp-xy-kit'

export const loader = createAuthGuardLoader({
  redirectTo: '/login'
})

请求中间件(miniapp-request):

import { createXyRequestClient } from '@xiao-ying/miniapp-request'
import {
  createLoginInterceptor,
  createErrorToastMiddleware
} from '@xiao-ying/miniapp-xy-kit'

const client = createXyRequestClient()
client.use(createLoginInterceptor())
client.use(createErrorToastMiddleware())

直传上传:

import { directXyUpload } from '@xiao-ying/miniapp-xy-kit'

const res = await directXyUpload({
  client,
  tokenUrl: '/api/upload/token',
  filePath: '/tmp/demo.jpg'
})
console.log(res.url)

选校门禁:

import { OverlayProvider } from '@xiao-ying/miniapp-ui'
import { createXyRequestClient } from '@xiao-ying/miniapp-request'
import { createXyKit, useSelectedSchool } from '@xiao-ying/miniapp-xy-kit'

const apiClient = createXyRequestClient({
  baseURL: 'https://api.xiaoying.life'
})

const xyKit = createXyKit({
  apiClient
})

const App = () => (
  <OverlayProvider>
    <YourRoutes />
  </OverlayProvider>
)

const Page = () => {
  xyKit.useSchoolGate({
    message: '请先选择学校以继续浏览'
  })

  return <YourPage />
}

const CurrentSchool = () => {
  const { school, isLocked } = useSelectedSchool()
  return <span>{isLocked ? '小应已锁定学校' : school?.name}</span>
}

xyKit.useSchoolGate 会在未选校时自动展示提示 Dialog,点击按钮后打开选校 Sheet,并通过传入的 apiClient 请求 /v1/schools。业务项目负责创建和配置请求客户端(例如 dev proxy、登录拦截、错误提示),xy-kit 只负责门禁与选校流程;业务项目不再需要注册 /schools/select 路由。

依赖说明

该套件通常与以下包搭配使用:

  • @xiao-ying/miniapp-sdk
  • @xiao-ying/miniapp-hooks
  • @xiao-ying/miniapp-request
  • @xiao-ying/miniapp-ui
  • @xiao-ying/miniapp-ui-pro
  • swr