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

@openlee/virtual-parcel-widget

v0.1.6

Published

Virtual Parcel Widget - Drop-in activation UI for your apps

Readme

@openlee/virtual-parcel-widget

数字包裹系统 UI 集成 SDK,提供开箱即用的核销界面。

安装

npm install @openlee/virtual-parcel-widget

快速开始

方式 1:Script 标签(CDN)

<!DOCTYPE html>
<html>
<head>
  <title>我的应用</title>
  <script src="https://cdn.jsdelivr.net/npm/@openlee/virtual-parcel-widget@latest/dist/index.global.js"></script>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@openlee/virtual-parcel-widget@latest/dist/style.css">
</head>
<body>
  <div id="widget-container"></div>
  
  <script>
    const widget = new VirtualParcelWidget({
      backendUrl: 'https://api.virtual-parcel.com',
      container: '#widget-container',
      onSuccess: (result) => {
        console.log('激活成功!', result);
        // 解锁功能
      }
    });
    
    widget.show();
  </script>
</body>
</html>

方式 2:NPM 包

import { VirtualParcelWidget } from '@openlee/virtual-parcel-widget';
import '@openlee/virtual-parcel-widget/style.css';

const widget = new VirtualParcelWidget({
  backendUrl: 'https://api.virtual-parcel.com',
  container: '#widget-container',
  theme: 'light',
  locale: 'zh-CN',
  onSuccess: (result) => {
    console.log('激活成功!', result);
  },
  onFail: (error) => {
    console.error('激活失败:', error.message);
  }
});

widget.show();

方式 3:React 组件

import { useEffect, useRef } from 'react';
import { VirtualParcelWidget } from '@openlee/virtual-parcel-widget';

function ActivationWidget() {
  const containerRef = useRef<HTMLDivElement>(null);
  
  useEffect(() => {
    const widget = new VirtualParcelWidget({
      backendUrl: 'https://api.virtual-parcel.com',
      container: containerRef.current!,
      onSuccess: (result) => {
        console.log('激活成功!');
      }
    });
    
    return () => widget.destroy();
  }, []);
  
  return <div ref={containerRef} />;
}

配置选项

interface WidgetConfig {
  /** 后端 URL */
  backendUrl?: string;
  /** 挂载容器(CSS 选择器或 HTMLElement) */
  container?: string | HTMLElement;
  /** 主题:light | dark | auto */
  theme?: 'light' | 'dark' | 'auto';
  /** 语言:zh-CN | en-US */
  locale?: 'zh-CN' | 'en-US';
  /** 主色调(十六进制) */
  primaryColor?: string;
  /** 验证成功回调 */
  onSuccess?: (result: VerifyResult) => void;
  /** 验证失败回调 */
  onFail?: (error: { message: string }) => void;
  /** 关闭回调 */
  onClose?: () => void;
}

API

new VirtualParcelWidget(config)

创建 Widget 实例。

widget.show()

显示 Widget。

widget.hide()

隐藏 Widget。

widget.destroy()

销毁 Widget,清理资源。

widget.on(event, callback)

监听事件。

  • success: 验证成功
  • fail: 验证失败
  • close: 关闭 Widget

widget.off(event, callback)

取消监听事件。

自定义样式

方式 1:配置项

const widget = new VirtualParcelWidget({
  // ...
  primaryColor: '#6366f1', // 自定义主色调
});

方式 2:覆盖 CSS

.widget-container {
  /* 自定义容器样式 */
}

.btn-primary {
  /* 自定义按钮样式 */
}

.input-code {
  /* 自定义输入框样式 */
}

界面预览

默认状态

┌─────────────────────────────────────────┐
│  🔓 激活服务                             │
│                                         │
│  请输入取件码以激活本服务                 │
│                                         │
│  ┌─────────────────────────────────┐   │
│  │         XXXX-XXXX                │   │
│  └─────────────────────────────────┘   │
│                                         │
│  ┌─────────────────────────────────┐   │
│  │         立即激活                 │   │
│  └─────────────────────────────────┘   │
└─────────────────────────────────────────┘

验证成功

┌─────────────────────────────────────────┐
│            ✅                            │
│         激活成功                         │
│                                         │
│      您已成功激活本服务!                │
└─────────────────────────────────────────┘

验证失败

┌─────────────────────────────────────────┐
│            ❌                            │
│         激活失败                         │
│                                         │
│      取件码无效或已被使用                │
│                                         │
│      ┌─────────────────────┐           │
│      │       重试          │           │
│      └─────────────────────┘           │
└─────────────────────────────────────────┘

License

MIT