# @mongchhi/plugin-sdk

> > 为了有更好的类型提示，请结合 `@mongchhi/types` 使用。

Latest version **0.0.4** (published 2024-01-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install @mongchhi/plugin-sdk
pnpm add @mongchhi/plugin-sdk
yarn add @mongchhi/plugin-sdk
bun add @mongchhi/plugin-sdk
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2024-01-10 |
| First published | 2023-12-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 3.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | xiaohuoni |

## Links

- npm: https://www.npmjs.com/package/@mongchhi/plugin-sdk
- npm.io page: https://npm.io/package/@mongchhi/plugin-sdk

## Dependencies (2)

- [@umijs/utils](https://npm.io/package/@umijs/utils.md) 4.0.89
- [@mongchhi/types](https://npm.io/package/@mongchhi/types.md) ^0.0.4

## Recent versions

- 0.0.4 (latest) — 2024-01-10
- 0.0.3 — 2023-12-11
- 0.0.3-alpha.0 — 2023-12-08

## README

# Mongchhi 插件 api

> 为了有更好的类型提示，请结合 `@mongchhi/types` 使用。

## onMongChhiSocket

扩展 Socket 响应的 node 端服务，拥有三个参数 `type, payload, send`，主要行为是根据 `type` 识别是否是自己需要响应的事件。

```ts
export interface SocketAction {
  type?: string;
  payload?: any;
  send?: any;
}
```

比如：

```ts
import { IApi } from '@mongchhi/types';

export default (api: IApi) => {
  api.onMongChhiSocket(async ({ type, send }) => {
    switch (type) {
      case 'app-data':
        // 发送 localUmiAppData
        send(
          JSON.stringify({
            type: 'app-data',
            payload: {},
          }),
        );
        break;
    }
  });
};
```

> 存在一个特殊的服务是 `type:'call'`，它用于前端和前端通信使用，所以在定义 ui 服务的时候，请不要使用这个 type。

---
_Source: https://npm.io/package/@mongchhi/plugin-sdk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
