open-index/open-npm huggingface dataset:
npm package: @seayoo-web/utils
Description: utils for seayoo web development
Author: web@seayoo.com
Latest version: 4.4.1

# 从业务代码中抽离的常用工具函数

## 公网工具包备忘

这些工具包都内置支持 ts 声明或有 @types 声明

- [store2](https://www.npmjs.com/package/store2) 一种功能丰富且友好的方式来利用localStorage和sessionStorage（JSON、名称空间、扩展等）
- [mime](https://www.npmjs.com/package/mime) 一个全面、紧凑的MIME类型模块
- [spark-md5](https://www.npmjs.com/package/spark-md5) SparkMD5是md5算法的一个快速md5实现。这个脚本基于JKM md5库，这是目前最快的算法
- [idb](https://www.npmjs.com/package/idb) 这是一个很小的库，主要包装了IndexedDB API，但有一些小的改进，对可用性有很大的影响
- [idb-keyval](https://www.npmjs.com/package/idb-keyval) 这是一个超级简单的基于promise的keyval存储，使用IndexedDB实现
- [echarts](https://www.npmjs.com/package/echarts) ApacheECharts是一个免费、强大的图表和可视化库
npm package: @seayoo-web/web-api
Description: agent for web api
Author: web@seayoo.com
Latest version: 3.0.2

# Web Api Agent

```js
import { ComboPublicApi, AccountWebApi } from "@seayoo-web/web-api";
import { NetRequest } from "@seayoo-web/request";
import { captureException } from "@sentry/vue";

// 创建 combo api 实例
const comboApi = new ComboPublicApi(SY_COMBO_API, NetRequest);
comboApi.req.setConfig({
  messageHandler(_, message) {
    toast(message);
  },
  errorHandler({ rawError, sentryError, sentryTags, sentryExtra }) {
    // 意外错误进行上报
    if (rawError) {
      captureException(sentryError, {
        extra: sentryExtra,
        tags: sentryTags,
      });
    }
  },
});

// 创建 account api 实例
const accountApi = new AccountWebApi(SY_ACCOUNT_API, NetRequest);
accountApi.req.setConfig({
  messageHandler(_, message) {
    toast(message);
  },
  errorHandler({ rawError, sentryError, sentryTags, sentryExtra }) {
    // 意外错误进行上报
    if (rawError) {
      captureException(sentryError, {
        extra: sentryExtra,
        tags: sentryTags,
      });
    }
  },
});

// 导出实例供其他模块使用
export { comboApi, accountApi };
```
npm package: @seayoo-web/webview
Description: social media webview js bridge
Author: web@seayoo.com
Latest version: 1.0.11

# Social Media WebView

## Alipay

### `pushAlipayClientWindow(url: string, callback?: (pageWillReload: boolean) => void): Promise<void>`

使用客户端方式打开一个新的页面，如果不在支付宝客户端 webview 中则直接跳转 url，[参考链接](https://opendocs.alipay.com/open/025160)

### `closeAlipayWindow(): Promise<void>`

关闭支付宝 WebView 当前页面

### `triggerAlipayTradePayWithNo(tradeNo: string): Promise<AlipayTradePayResult>`

使用支付流水号唤起支付宝快捷支付，[参考链接](https://opendocs.alipay.com/open/02502j)

### `triggerAlipayTradePayWithOrderStr(orderStr: string): Promise<AlipayTradePayResult>`

使用订单串唤起支付宝快捷支付，[参考链接](https://opendocs.alipay.com/open/02502j)

### `onAlipayPageVisible(fn: ()=>void): void`

支付宝 WebView 页面显示时触发，[参考链接](https://opendocs.alipay.com/open/024nki)

## Weixin

### `triggerWeixinJsApiPay(args: WeixinJSApiRequestPaymentParams): Promise<boolean | null>`

唤起微信 JS API 支付，此处返回的支付结果不保证可靠性。[参考链接](https://pay.weixin.qq.com/doc/v3/merchant/4012791857)

- `null` 不在微信 Webview 内
- `false` 用户取消或支付失败
- `true` 用户可能支付成功，💡不保证可靠性，需要查询后端接口以确认结果

### `updateWeixinShareData(info: ShareInfo, verifyData: WeixinApiVerifyData): Promise<boolean>`

设置微信分享信息，仅在微信 WebView 中有效，[参考链接](https://developers.weixin.qq.com/doc/service/guide/h5/jssdk.html)
npm package: @seb-l/i18n-xlsx-loader
Description: Directly import an XLSX file in your project as source for i18n locales messages.
Author: Seb.L.
Latest version: 1.0.0

# i18n-xlsx-loader

Directly import an XLSX file in your project as source for i18n locales messages.

This loader extract the locales messages from an Xlsx file then convert them in javascript exported objects named after the locale name.

Each sheet name is used as root attribute in the final locale js object.

**Example:**

**Sheet Name:** common

| key | fr | en |
| --- | --- | --- |
| sidebar.hideSidebar | Masquer la barre latérale | Hide Sidebar |

**Sheet Name:** login

| key | fr | en |
| --- | --- | --- |
| form.password | Mot de passe | Password |

will result to:

```javascript
export const fr = {
  common: {
    sidebar: {
      hideSidebar: 'Masquer la barre latérale'
    }
  },
  login: {
    form: {
      password: 'Mot de passe'
    }
  }
}

export const en = {
  common: {
    sidebar: {
      hideSidebar: 'Hide Sidebar'
    }
  },
  login: {
    form: {
      password: 'Password'
    }
  }
}
```

## Install

```bash
yarn add @seb-l/i18n-xlsx-loader -D
```

or

```bash
npm install @seb-l/i18n-xlsx-loader -D
```

## Usage

### Update your Webpack configuration

**In your `webpack.config.js` file:**

```javascript
const path = require('path')

{
  ...,
  module: {
    rules: [
      {
        test: path.resolve('locales/translations.xlsx'),
        use: {
          loader: '@seb-l/i18n-xlsx-loader'
        },
      },
    ],
  },
  ...
}
```

**Using with webpack-extend (for a Nuxt app in this example):**

```javascript
const path = require('path')

{
  ...
  extend (config, { isDev, isClient }) {
    config.module.rules.push(
      {
        test: path.resolve('locales/translations.xlsx'),
        loader: '@seb-l/i18n-xlsx-loader',
      }
    )
  }
  ...
}
```

### In the file you want to use your translations in

```javascript
import { fr, en } from '@/locales/translations.xlsx'
```