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

l2d-widget

v0.1.0

Published

<p align="center"> <img width="240" src="https://hacxy-1259720482.cos.ap-hongkong.myqcloud.com/images/logo.svg"/> </p> <h1 align="center">l2d-widget</h1> <h4 align="center">仅一个函数调用,把 Live2D 模型放进任何网页</h4>

Readme

文档 | English

[!IMPORTANT] 本项目是基于 l2d 库对 oh-my-live2d 的完全重构版本,原 oh-my-live2d 已更名为 l2d-widget。如果你正在从 oh-my-live2d 迁移,请查阅文档站了解更新后的 API。

特性

  • 单次调用集成createWidget() 一个函数完成 canvas 创建、WebGL 上下文初始化、模型加载与交互绑定
  • Cubism 2 & 6 运行时 — 基于 l2d,自动识别模型版本并加载对应 Cubism 运行时
  • 嘴型参数驱动 — 逐字打字动画实时驱动模型口型参数(PARAM_MOUTH_OPEN_Y),支持配置开合值域
  • 完整生命周期管控switchModel() 退场过渡 → WebGL 销毁 → 重建 → 入场过渡,原子化异步操作;destroy() 确保资源释放
  • ~500 行,零运行时依赖 — 纯 DOM + CSS Animation,无框架。同时输出 ESM 和 IIFE,支持 tree-shaking

安装

npm install l2d-widget

或通过 CDN 引入:

<script src="https://unpkg.com/l2d-widget/dist/index.min.js"></script>

快速开始

import { createWidget } from 'l2d-widget';

const widget = createWidget({
  model: {
    path: 'https://model.hacxy.cn/cat-black/model.json',
  },
});

跑完之后页面左下角会出现一个 Live2D 角色,带悬浮菜单和提示气泡,可以交互。

示例

多模型切换

createWidget({
  model: [
    { path: '/models/cat-black/model.json' },
    { path: '/models/cat-white/model.json' },
  ],
});

传入数组时,菜单会自动出现切换按钮。

打字动画与嘴型同步

createWidget({
  model: {
    path: '/models/cat-black/model.json',
    tips: {
      typing: {
        param: 'PARAM_MOUTH_OPEN_Y',
        speed: 200,
      },
      welcomeMessage: ['你好!', '很高兴见到你!'],
      messages: ['休息一下吧~', '记得多喝水!'],
      duration: 4000,
      interval: 6000,
    },
  },
});

提示气泡会逐字显示文字,同时驱动模型的嘴型参数做开合动画。

Widget 实例

createWidget() 返回一个 Widget 对象:

| 方法 / 属性 | 说明 | | -------------------- | ------------------------------------ | | l2d | 底层 l2d 实例,用于高级控制 | | switchModel(index) | 异步切换到指定索引的模型 | | sleep() | 隐藏模型并显示休眠状态栏,点击可唤醒 | | destroy() | 销毁挂件,释放 WebGL 资源并移除 DOM |

完整配置项见文档站

开发

| 命令 | 说明 | | ------------ | ---------------------------------- | | pnpm dev | 监听构建(含 sourcemap) | | pnpm demo | 启动 demo 服务器(localhost:3000) | | pnpm build | 生产构建 | | pnpm lint | 代码检查 |

许可证

MIT


English documentation: README.md