open-index/open-npm huggingface dataset:
npm package: @irim/cli
Description: Project Generator CLI
Author: Pluto
Latest version: 1.2.1

# IRIM TOOLKIT CLI

![version](https://img.shields.io/npm/v/@irim/cli)
![license](https://img.shields.io/npm/l/@irim/cli)
![downloads](https://img.shields.io/npm/dw/@irim/cli)

## 快速使用

### 安装

```bash
$ npm install -g @irim/cli
```

### 初始化项目

```bash
# 默认的项目初始化方法，需要二次选择官方包（也有选择输入自定义包路径: CDN zip 包、npm 包、git 地址）
$ irim init

# 跳过版本检查（如果网络卡在版本检查中，可加上此项）
$ irim init --no-check

# 指定初始化官方包
$ irim init pc

# 指定模板 git 仓库
$ irim init -g git@github.com:xxx/xxx.git
```

## CHANGELOG

- **1.2.0**: 引用 `@irim/bin-tool` 库
- **1.1.0**: 使用 Typescript 重构

## LICENSE

BSD-3-Clause License

## Contact Us

- [Pluto Cai](mailto:huarse@gmail.com)
npm package: @irim/ds-core
Description: digital space sdk core
Author: Pluto Cai
Latest version: 1.0.3

# DS-CORE

![version](https://img.shields.io/npm/v/@irim/ds-core)
![license](https://img.shields.io/npm/l/@irim/ds-core)
![downloads](https://img.shields.io/npm/dw/@irim/ds-core)

## 快速使用

### 安装

```shell
$ npm install --save @irim/ds-core
```

```js
import { Core, Plugin, createApplyChain, uuid, random } from '@irim/ds-core';
```

### Core

DS 核心引擎，用于注册插件、处理事件等 (继承自 [Events](https://nodejs.org/docs/latest/api/events.html) )

```js
const ds = new Core();

// 修改配置项
ds.setConfig({
  pluginA: { foo: 'bar' }, // 用于 pluginA 的初始化参数
});

// 注册插件，初始化后会执行插件的 init 方法
//     注册成功后，可用 ds.pluginA 的方式获取到插件实例
ds.register('pluginA', PluginA, {
  goo: 1001, // 实际初始化的参数是此参数与 config.pluginA 的合并数据
});

// 卸载插件，会执行插件的 destroy 方法
ds.unregister('pluginA');
```

_事件相关的接口请参考 Events 文档_

### Plugin

基础插件类，所有 ds 插件必须继承此类，不能直接用 new 的方式初始化；Plugin 继承自 Events，同样包含事件能力。

需要重写的抽象方法：

- init() 在插件注册时会被调用
- destroy() 在插件卸载前会被调用

```js
// 向调用链添加一个中间件
ds.pluginA.use(async ctx => {
  console.log('before...');
  ctx.next();
  console.log('after...');
});

// 创建并执行调用链
ds.pluginA.run(options);
```

### 工具类方法

1. `createApplyChain(middlewares: Function[], scope?: Object): Function` 创建一个调用链

scope 表示执行每个 middleware 的上下文

```js
async function middlewareA(ctx) {
  console.log('---- 1');
  ctx.next();
  console.log('---- 4');
}

async function middlewareB(ctx) {
  console.log('---- 2');
  ctx.next();
  console.log('---- 3');
}

const invoke = createApplyChain([middlewareA, middlewareB]);
invoke(); // 打印顺序: 1, 2, 3, 4
```

2. `random(min: number, max?: number): number` 返回 `[min, max]` 的随机整数

3. `uuid(): string` 创建一个唯一的ID

4. `logger.{debug|error|warn|info|success|line}(...args): void` 控制台打印日志

```js
logger.debug('Hello', 'Lilith');
logger.info('GET /api/todo', { message: 'say hello' });
```

5. `batchExecSync(callbacks: Function[], args?: Array, scope?: object)` 批量同步执行方法

```js
const callback1 = (data) => { return data.content };
const callback2 = (data) => { throw new Error('custom error') };

// [{ success: true, result: 'hello' }, { success: false, error: Error }]
const result = batchExecSync([callback1, callback2], [{ content: 'hello' }]);
```

6. `batchExecAsync(callbacks: Function[], args?: Array, scope?: object)` 批量异步执行方法

```js
const callback1 = (data) => { return Promise.resolve(data.content) };
const callback2 = (data) => { return Promise.reject(new Error('custom error')) };

// [{ success: true, result: 'hello' }, { success: false, error: Error }]
const result = await batchExecAsync([callback1, callback2], [{ content: 'hello' }]);
```

### 定义一个插件

```js
class PluginA extends Plugin {
  init() {
    this.registerMiddleware();
  }

  // 注册插件执行中间件
  registerMiddleware() {
    this.use(async ctx => {
      console.log('before');
      await ctx.next();
      console.log('after');
    });

    this.use(async ctx => {
      ctx.response = await request('/api/todo');
      await ctx.next();
    });
  }

  async getTodoList() {
    const { response } = await this.run();
    // ....
  }
}

```

## LICENSE

BSD-3-Clause License
npm package: @irim/ds-net
Description: digital space net plugin
Author: Pluto
Latest version: 1.0.7

# ds-net

![version](https://img.shields.io/npm/v/@irim/ds-net)
![license](https://img.shields.io/npm/l/@irim/ds-net)
![downloads](https://img.shields.io/npm/dw/@irim/ds-net)

## 快速使用

### install

```shell
$ npm install --save @irim/ds-core @irim/ds-net
```

```js
import { Core } from '@irim/ds-core';
import { Net } from '@irim/ds-net';

const ds = new Core();
ds.register('net', Net);

// 请求数据
ds.net.request('/api/todo.list', {
  type: 'jsonp',
}).then(response => {
  console.log('>>>', response);
});

// 连接 socket
await ds.net.initSocket('wss://echo.websocket.org');
ds.net.socket.sendMessage({ content: 'hello world' });
ds.net.socket.onMessage(data => {
  console.log('on message', data);
});
```

### 进阶使用

1. 初始化时指定数据能力

```js
// 这里的参数也可以放到 ds.setConfig({ net: ... }) 或初始化 ds 中，详见 DsCore 文档
ds.register('net', Net, {
  abilities: ['ajax', 'upload'],
});

// 也可以在指定能力时，指定初始化的参数，如:
ds.register('net', Net, {
  abilities: ['ajax', 
    ['jsonp', { timeout: 5000 }]
  ],
});

ds.net.request('/api.aaa.bbb', {
  type: 'jsonp',
  data: { id: 1001 },
});
```

2. 初始化时指定数据处理中间件

```js
import { middlewares } from '@irim/ds-net';

ds.setConfig({ net: {
  middlewares: [
    middlewares.printLogger,
    middlewares.delay,

    async ctx => {
      // do something...
      await ctx.next();
      // do something...
    }
  ],
}});
```

## 术语规范

### 参数名规范

- `api` 定义接口名，`url` 不再使用
- `search` 用于拼接在请求的 URL 中，即 GET 请求
- `payload` 用于传 POST|PUT 请求的数据传输
- `data` 用于通用的传递数据或请求参数，`query`、`params` 不再使用（可在中间件作兼容）
- `options` 方法的通用参数名，`settings`、`props` 不再使用
- `response` 用于定义服务器响应后的数据
- `message` 用于定义服务器响应的错误消息

## LICENSE

BSD-3-Clause License
npm package: @irim/rc-ripple
Description: React Ripple Effect Wrapper
Author: Pluto
Latest version: 0.1.2

# Ripple Effect Wrapper

![version](https://img.shields.io/npm/v/@irim/rc-ripple)
![license](https://img.shields.io/npm/l/@irim/rc-ripple)
![downloads](https://img.shields.io/npm/dw/@irim/rc-ripple)

React Component of Ripple Effect.

<!-- 组件截图 -->

## Getting Started

- `$ npm install @irim/rc-ripple --save`

```js
import Ripple from '@irim/rc-ripple';

ReactDOM.render(
  <Ripple>
    <button>HELLO</button>
  </Ripple>,
  document.getElementById('mountNode'),
);
```

```scss
@import "~@irim/rc-ripple/lib/index";
```

## API

| props    | desc                      | type                          | required | default |
| -------- | ------------------------- | ----------------------------- | -------- | ------- |
| wrapper  | wrapper of effect element | `'div' | 'li' | 'a' | 'span'` | no       | 'span'  |
| disabled | cancel click effect       | boolean                       | no       | false   |


### SCSS Variables

Define scss variables before import component scss file will change default values.

```scss
$ripple-effect-color: rgba(0, 0, 0, 0.15);
```

## LICENSE

BSD-3-Clause License
npm package: @irim/redux-store
Description: react redux store hoc
Author: Pluto Cai
Latest version: 1.0.2
Deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

# REDUX STORE

![version](https://img.shields.io/npm/v/@irim/redux-store)
![license](https://img.shields.io/npm/l/@irim/redux-store)
![downloads](https://img.shields.io/npm/dw/@irim/redux-store)

## Getting Started

- `$ tnpm install @irim/redux-store --save`

```js
// store.js
export const initialState = {
  bizName: 'lucy'
};

export function reducer(state = initialState, action) {
  const { type, payload } = action;
  if (type === 'UPDATE') {
    return { ...state, ...payload };
  }
  return state;
}

export const actions = {
  queryBizName() {
    return async dispatch => {
      const response = await fetch('/demo/bizname');
      const result = await response.json();

      dispatch({
        type: 'UPDATE',
        payload: { bizName: result.data },
      });
    }
  }
};
```

```js
// DemoPage.jsx
import { connect } from '@irim/redux-store';
import { action } from './store';

@connect(actions)
export default class OrangePage extends React.Component {
  render() {
    const { payload: { bizName }} = this.props;

    return <h1>Hello, {bizName}!</h1>
  }
}

// or use `export default connect(actions)(OrangePage)` for instead.
```

```js
// app.jsx
import { createStore, Provider } from '@irim/redux-store';
import { reducer } from './store';
import DemoPage from './orange';

ReactDOM.render(
  <Provider store={store}>
    <DemoPage />
  </Provider>,
  document.getElementById('root')
);
```

### Advanced

Use 2 HOC instead of DemoPage + App.

```js
// DemoPage.jsx
import { connect, providerHOC } from '@irim/redux-store';
import { actions, reducer } from './store';

@providerHOC(reducer)
@connect(action)
export default class OrangePage extends React.Component {
  // ....
}
```

```js
// app.jsx
import DemoPage from './orange';

ReactDOM.render(
  <DemoPage />,
  document.getElementById('root')
);
```

### Notice

If you use `react-redux@7.x`, the `react` version must greater then **16.8**.

## LICENSE

BSD-3-Clause License
npm package: @irim/saber
Description: A toolbox for http connect
Author: CAIHUAZHI
Latest version: 2.0.0

# saber tools

![version](https://img.shields.io/npm/v/@irim/saber)
![license](https://img.shields.io/npm/l/@irim/saber)
![downloads](https://img.shields.io/npm/dw/@irim/saber)

A toolbox for http connect.

## Getting Started

- `$ npm install @irim/saber --save`

```ts
import Saber from '@irim/saber';

const saber = new Saber(); // or saber = Saber.singleton()
saber.request('https://httpbin.org/post', {
  method: 'POST',
  data: { foo: 'bar' },
}).then(response => {
  console.log('> response: ', response);
});
```

## Advanced

```ts
import Saber from '@irim/saber';

const saber = new Saber();
// add a middleware
saber.use(async ctx => {
  console.log('>>>> before...');
  await ctx.next();
  console.log('>>> after ...');
});
```

## API

### 工具类方法

* logger 打印日志

```ts
import { logger } from '@irim/saber';

logger.debug('hello world~');
logger.info('hello world~');
logger.success('hello world~');
logger.warn('hello world~');
logger.error('hello world~');
logger.line('hello world~');
```

## CHANGELOG

<!-- - **version**: change logs -->
- **1.1.0**: 移除 socket 能力，fetcher 方法增加 `dataType` 参数
- **1.2.0**: 构建结果降级成 ES5
- **1.3.0**: 构建结果移除 dist

## LICENSE

BSD-3-Clause License

## Contact Us

[CAIHUAZHI](mailto:huarse@gmail.com)