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

@jswork/react-pwa-promotion

v1.0.22

Published

A tiny React update prompt for Vite PWA (vite-plugin-pwa).

Readme

@jswork/react-pwa-promotion

React PWA 版本升级提示组件(纯 UI,不绑定构建工具)。

安装

pnpm add @jswork/react-pwa-promotion

样式是独立文件,在入口引入一次:

import '@jswork/react-pwa-promotion/dist/style.css';

构建

pnpm build
  • tsup → dist/index.cjs.js / dist/index.esm.js / dist/index.d.ts
  • @jswork/tsup-plugin-lightningcss(挂在配置 esbuildPlugins 上)→ 构建结束时用 Lightning CSS 把 src/style.css 压缩并按 targets 降级,输出 dist/style.css

插件已抽成独立仓库 /Users/afei/github/tsup-plugin-lightningcss,本包用 link:../../../tsup-plugin-lightningcss 做本地联调;插件发布到 npm 后把依赖改成版本号即可。可选参数:entry、outFile、targets、minify、silent,输出目录自动跟随 tsup 的 outDir。

src/style.css 用原生 CSS Nesting 写(嵌套更好维护),构建时按 targets 展开成扁平选择器,产物不依赖浏览器对 nesting 的支持。注意写法遵循 CSS Nesting 规范(& .xxx / &.xxx),不是 Sass 的 &__xxx 后缀拼接。

组件本身不往 DOM 注入 <style>,样式完全由 CSS 文件控制。

配合 vite-plugin-pwa

vite.config.ts:

import { VitePWA } from 'vite-plugin-pwa';

export default defineConfig({
  plugins: [
    react(),
    VitePWA({ registerType: 'prompt', injectRegister: null })
  ]
});

src/vite-env.d.ts 加一行:

/// <reference types="vite-plugin-pwa/client" />

App.tsx:

import { useRegisterSW } from 'virtual:pwa-register/react';
import PwaUpdatePrompt from '@jswork/react-pwa-promotion';

export default function App() {
  const {
    needRefresh: [needRefresh, setNeedRefresh],
    updateServiceWorker
  } = useRegisterSW();

  return (
    <PwaUpdatePrompt
      open={needRefresh}
      onUpdate={() => void updateServiceWorker(true)}
      onDismiss={() => setNeedRefresh(false)}
    />
  );
}

Props

| 名称 | 类型 | 默认值 | 说明 | | --- | --- | --- | --- | | open | boolean | — | 是否有新版本待更新,由宿主 SW 状态提供 | | onUpdate | () => void | — | 点击「立即更新」,宿主负责让新 SW 接管并刷新 | | onDismiss | () => void | — | 点击「稍后」 | | position | PwaUpdatePosition \| CSSProperties | 'bottom-right' | 四角,或传样式对象自定义坐标 | | className | string | — | 追加根类名 | | texts | Partial<PwaUpdateTexts> | 中文 | 覆盖标题 / 描述 / 两个按钮文案(dismiss 传空字符串可隐藏「稍后」按钮) | | theme | PwaUpdateTheme | 'default' | 内置主题预设:weiyun(微云风大卡:340px、16px 圆角、通栏主按钮、右上角关闭) |

PwaUpdatePosition = 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left'。

特性

  • 240px 紧凑卡片、无圆角、小按钮;按钮带 hover / 按下 / 键盘焦点反馈
  • 自带入场动画,并尊重 prefers-reduced-motion
  • 不依赖 vite-plugin-pwa,非 Vite 项目也可以自己控制 open 使用