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

@pingansec/qixin.sharepublic.sdk

v1.0.0

Published

SDK for initializing shared public components into a container

Readme

@pingansec/qixin.sharepublic.sdk

在页面指定容器中按 componentId 加载水滴企信「共享公开组件」(iframe),并支持传入鉴权 token、业务 props 与自定义 baseUrl

本包为 ES 模块"type": "module"),适用于 Vite、Webpack 等现代打包工具;需在 浏览器环境 中使用(依赖 documentfetch)。

安装

pnpm add @pingansec/qixin.sharepublic.sdk
# 或
npm install @pingansec/qixin.sharepublic.sdk

在 monorepo 中也可通过 workspace 协议引用本仓库内的包。

引入方式

1. 默认导入(推荐)

import SharePublicSDK from '@pingansec/qixin.sharepublic.sdk';

SharePublicSDK.init({
  containerId: 'embed-root',
  componentId: 'your-component-id',
  token: 'optional-token',
  props: { foo: 'bar' },
}).then(instance => {
  // iframe 已挂载
});

2. 命名导入

import { init, BASE_URL } from '@pingansec/qixin.sharepublic.sdk';

// 未传 baseUrl 时使用模块内置的 BASE_URL(与默认导出上的常量一致)
init({
  containerId: 'embed-root',
  componentId: 'your-component-id',
});

3. 仅执行副作用(挂载全局)

import '@pingansec/qixin.sharepublic.sdk';
// 等价于在 globalThis 上挂载:globalThis.QixinSharePublicSDK = { init, BASE_URL }

window.QixinSharePublicSDK.init({
  /* ... */
});

init(options)

| 字段 | 类型 | 必填 | 说明 | | ------------- | ------------------------- | ---- | ---------------------------------------------------------------- | | containerId | string | HTMLElement | 是 | 容器元素 id,或直接传入 DOM 节点 | | componentId | string | 是 | 组件 id | | token | string | 否 | 会作为查询参数拼到 iframe 地址上 | | props | object | 否 | 键值对会编码进 iframe URL;对象/数组会 JSON.stringify 后再编码 | | baseUrl | string | 否 | 接口根地址,默认使用导出对象上的 BASE_URL(见下) |

流程简述:请求 {baseUrl}/api/v1/developer/components/detail?component_id=... 拉取组件详情,校验为 iframe 类型后创建 iframe 并写入容器。

返回值Promise,resolve 为组件实例(见下);失败时 reject(网络错误、非 200 业务码、非 iframe 类型等)。

默认 BASE_URLhttps://qixin.shuidi.cn/(导出为 SharePublicSDK.BASE_URL 或命名导出 BASE_URL)。

组件实例

init resolve 后得到:

| 属性 / 方法 | 说明 | | --------------------------------- | ------------------------------------------------------------------------- | | iframe | 创建的 HTMLIFrameElement | | componentId | 传入的组件 id | | methods | 服务端返回的可用方法名映射(供 callMethod 校验) | | callMethod(methodName, params?) | 通过 postMessage 调用 iframe 内方法;返回 Promise(成功时表示已发送) | | on(eventName, callback) | 监听 iframe 通过 postMessage 上报的事件;返回取消监听的函数 |

TypeScript

包内已自带 TypeScript 类型声明(sharepublicsdk.d.ts)。TypeScript 项目中可以直接 import 使用,无需再额外补写 declare module

import SharePublicSDK, { init, BASE_URL } from '@pingansec/qixin.sharepublic.sdk';
import type { QixinSharePublicInitOptions } from '@pingansec/qixin.sharepublic.sdk';

const options: QixinSharePublicInitOptions = {
  containerId: 'embed-root',
  componentId: 'your-component-id',
  token: 'optional-token',
  props: { foo: 'bar' },
};

// 推荐:默认导出对象方式
SharePublicSDK.init(options);

// 或:命名导出方式
init(options);

如果某些仓库仍残留了应用侧的 declare module '@pingansec/qixin.sharepublic.sdk' 声明,建议在确认无冲突后逐步移除,统一以包内类型为准。

shuidi.sharepublic.sdk 的区别

npm 上的 shuidi.sharepublic.sdk 是另一条发布线与接口形态;本包 @pingansec/qixin.sharepublic.sdk 面向水滴企信开发者组件详情接口(/api/v1/developer/components/detail)。接入前请确认后端与环境与本文档一致。

License

MIT