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

@hhfenpm/miu-sdk

v0.4.0

Published

MIU AI 助手 SDK — 门户侧接入

Readme

@hhfenpm/miu-sdk

微前端门户 Shell SDK,在 HIS 页面中管理 AI 助手侧边栏、子应用生命周期和跨窗口通信。

安装

pnpm add @hhfenpm/miu-sdk

或通过 CDN:

<script src="miu-sdk.umd.js"></script>
<!-- 全局变量: window.MiuSDK -->

快速开始

MiuSDK.init({
  credentials: {
    hospitalId: 'H001',
    doctorUsername: 'zhangsan'
  },
  gateway: { baseUrl: '/hospital/api' },
  onError: function(err) { console.error(err.code); }
}).then(function() {
  MiuSDK.open();
});

API

初始化 & 销毁

| 方法 | 说明 | |------|------| | init(config): Promise<void> | 初始化 SDK,完成鉴权和应用列表拉取 | | destroy() | 销毁实例,释放所有资源 | | createInstance(): MiuSDK | 多实例工厂(高级用法) |

面板控制

| 方法 | 说明 | |------|------| | open() | 打开面板 | | close() | 关闭面板 | | toggle() | 切换面板开/关 | | showTrigger() | 显示触发按钮 | | hideTrigger() | 隐藏触发按钮 |

应用管理

| 方法 | 说明 | |------|------| | openApp(appId, options?) | 打开子应用 | | closeApp(appId) | 关闭子应用 | | switchApp(appId) | 切换到已打开的子应用 |

消息通信

| 方法 | 说明 | |------|------| | broadcast(action, payload?) | 广播消息到所有子应用 | | sendTo(appId, action, payload?) | 发送消息到指定子应用 |

全局状态

| 方法 | 说明 | |------|------| | setState(delta) | 合并更新全局状态 | | getState() | 获取当前全局状态快照 | | onStateChange(cb): () => void | 订阅状态变化,返回取消函数 |

事件系统

| 方法 | 说明 | |------|------| | on(event, handler) | 订阅事件 | | once(event, handler) | 订阅事件(仅触发一次) | | off(event, handler) | 取消订阅(需传入原始 handler 引用) | | removeAllListeners(event?) | 移除所有监听器 |

事件列表

| 事件 | 触发时机 | |------|---------| | ready | SDK 初始化完成 | | panel:opened | 面板打开 | | panel:closed | 面板关闭 | | app:opened | 子应用打开 | | app:closed | 子应用关闭 | | app:switched | 应用切换完成 | | app:registered | 子应用注册完成 | | app:ready | 子应用握手就绪 | | app:error | 子应用异常 | | app:route-change | 子应用路由变化 | | token:refreshed | Token 刷新成功 | | token:error | Token 刷新失败 | | auth:expired | Refresh Token 过期 | | state-change | 全局状态变更 | | message:child | 收到子应用消息 |

核心配置 (MiuConfig)

MiuSDK.init({
  // 必填 -- 医生身份
  credentials: {
    hospitalId: 'H001',        // 必填
    doctorUsername: 'zhangsan', // 必填
    doctorCode: '1001',        // 可选
    doctorName: '张三',        // 可选
    // ...更多可选字段(支持驼峰和下划线两种写法)
  },
  // 可选 -- 网关
  gateway: {
    baseUrl: '/hospital/api',
    endpoints: { embedLogin: '/auth/embed-login', /* ... */ },
    authHeaderName: 'miu-authorization',
    withCredentials: false,
    tokenExchangeEnabled: false,
  },
  // 可选 -- UI
  ui: { mode: 'widget' /* 或 'page' */ },
  // 可选 -- 回调
  onError: function(err) {},
  onReady: function() {},
  onWorkbenchClick: function(url) {},
  // 可选 -- 其他
  allowedOrigins: ['https://app.example.com'],
  logger: { level: 'warn' },
  timeouts: { handshakeTimeout: 10000 },
  formatAppSubtitle: function(agent) { return '同科 ' + agent.deptUsedCount + ' 人用过'; },
});

详见 Shell SDK API 文档

浏览器兼容性

IE11、Edge、Chrome、Firefox、Safari 最近 2 个版本。

产物为纯 ES5 UMD,零运行时第三方依赖。