open-index/open-npm huggingface dataset:
npm package: @klutch-card/klutch-cli
Description: Klutch Client
Author: klutchcard
Latest version: 1.1.3

# Klutch Card CLI

Klutch CLI early access is available in early access for mini app developers. The primary feature available in this CLI is 

## Prerequisites
* Klutch developer account. Register at (dev.klutchcard.com)[https://dev.klutchcard.com/#!/docs]
* Nodejs and NPM installed
* A configured miniapp uploaded to the dev portal.
* Expo app for launching the app in debug mode.

## Installation
```
npm i -g @klutch-card/klutch-cli
```

After installing, the CLI is available using the `klutch` command.


## Commands

```
klutch generateKey           //Generate Keys for the miniapp
klutch init                  //Creates a blank miniapp template.
klutch login                 //Logs you in as a developer
klutch publish               //Publish your miniapp to our sandbox environment
klutch test-users list       //List Test Users
klutch test-users create     //Creates a sandbox test user
```
npm package: @klw/fetch
Description: A thin wrapper around the fetch api
Author: Karl Ludwig Weise
Latest version: 2.2.0
Deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

# fetch

A thin wrapper around the fetch api

- normalizes `response.ok`
- returns the response body as JSON
- uses the localstorage item `token` to authenticate with the api

## Usage

```
yarn add @klw/fetch
```

```
import { get, post, put, delete } from "@klw/fetch";

const resp = await get(`/api/users`);
if (resp.ok) {
    ...
}

const resp = await post(`/api/users/login`, { email, password });
if (resp.ok) {
    ...
}

const resp = await put(`/api/users/u_id`, { firstName, lastName });
if (resp.ok) {
    ...
}

const resp = await del(`/api/users/u_id`);
if (resp.ok) {
    ...
}

```

Options are available (not documented at the moment).
npm package: @klw/jwt
Description: A very thin wrapper around the jwt api
Author: Karl Ludwig Weise
Latest version: 1.0.2
Deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

# jwt

A very thin wrapper around the `jsonwebtoken` package with `useJwt()` for the front-end.

## Usage

```
yarn add @klw/jwt
```

```
import { useJwt } from "@klw/jwt";

const jwt = useJwt();
const data = jwt.decode(token);
if (data && data.hasOwnProperty("permissions")) {
    ...
}
```
npm package: @klw/localstorage
Description: A thin wrapper around the localStorage api
Author: Karl Ludwig Weise
Latest version: 1.0.1
Deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

# localstorage

A thin wrapper around the localStorage api

## Usage

```
yarn add @klw/localstorage
```

```
import { useLocalStorage } from "@klw/localstorage";

const storage = useLocalStorage();
storage.set("alive", true);
storage.get("alive");
```
npm package: @klw/node-database-migration
Description: A tiny script to run your sql database migrations
Author: Karl Ludwig Weise
Latest version: 1.1.0
Deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

# node-database-migration

A database migration runner that

- will run your migration functions
- will find and run migrations based on your settings (defaults to latest version and a new database).
- stops running migrations, when one fails
- runs all remaining migrations, if `currentVersion` is `null`.

## Usage

Import package and run migrations:

```
yarn add @klw/node-database-migration
```

```
import { migrate } from "@klw/node-database-migration";

const currentVersion = null;
const migrations = {
  one: {
      version: "1",
      up: () => Promise.resolve(), // Your migration function
      down: () => Promise.resolve(),
  },
  two: {
      version: "2",
      up: () => Promise.resolve(),
      down: () => Promise.resolve(),
  },
  three: {
      version: "3",
      up: () => Promise.resolve(),
      down: () => Promise.resolve(),
  },
};

const result = await migrate([migrations.one, migrations.two, migrations.three], currentVersion);
```

### Your Migration Functions

The migration runner uses the Promise API:

- `return Promise.resolve()` to show a successful migration
- `return Promise.reject()` to stop executing
- `return Promise.reject(error)` to stop executing and have your custom error returned

`error` can be `string` or `Error`.

### Advanced Options

You may add `options` to your migrations.

```
const options = { targetVersion: "5" }
const result = await migrate(migrations, currentVersion, options);
```

Currently only the `targetVersion` option is available. This will enable you to downgrade.

You may pass an async function as `currentVersion`.

```
const result = await migrate(migrations, async () => Promise.resolve("X"));
```

This way you can avoid top level `await`, if needed.

## Return value

The migration runner will stop running migrations, if one fails. In either case you will get a resolved `Promise`.
When all migrations succeed:

```
{
    success: true,
    targetVersion: "3",
    direction: "UP",
    started: ["1", "2", "3"],
    fulfilled: ["1", "2", "3"],
}
```

When migration 2 fails:

```
{
    success: false,
    targetVersion: "3",
    direction: "UP",
    started: ["1", "2"],
    fulfilled: ["1"],
    errorMessage: "Migration function 2 failed and this is the custom error message for it.",
}
```
npm package: @klw/node-sequential-promises
Description: A tiny script to run async functions aka promises one after the other
Author: Karl Ludwig Weise
Latest version: 0.8.0

# node-sequential-promises

A tiny script to run async functions aka promises one after the other

## Usage

Import package:

```
import { runSequence } from "@klw/node-sequential-promises";
```

Your async functions must follow a few rules:

- If it's successful, it must `return Promise.resolve()`
- If it fails, it must
  - `return Promise.reject()` or
  - `return Promise.reject("Your Error Message Here")` or
  - `return Promise.reject(new Error("Your Error Message Here"))`

```
const myAsyncFunc1 = async () => {
    if (1 + 1 = 2) {
        return Promise.resolve();
    } else {
        return Promise.reject("Your Error Message Here");
    }
}
```

Run your async functions on the order you like:

```
const result = await runSequence([myAsyncFunc1, myAsyncFunc2, myAsyncFunc3]);
```

`node-sequential-promises` will run them one after the other.

- If one should fail, it will stop running all others.
- Even if it fails, you will get a resolved result.

## Return value

A positive result:

```
{
  success: true,
  started: [0, 1, 2],
  fulfilled: [0, 1, 2],
}
```

A negative result (2nd async function failed):

```
{
  success: false,
  started: [0, 1],
  fulfilled: [0],
  errorMessage: "Your Error Message Here",
}
```
npm package: @klweb/chunk-import-style
Description: 昆仑组装应用引擎生产组件脚手架的辅助插件, 自动为指定产物文件添加导入 CSS 文件语句, 如: import './style.css'
Author: kunlun/zzh
Latest version: 1.0.0

# @klweb/chunk-import-style

昆仑组装应用引擎生产组件脚手架的辅助插件，自动为指定产物文件添加导入 `CSS` 文件语句， 如： `import './style.css'`。

## 安装插件

```bash
npm install @klweb/chunk-import-style -D
```

## 如何使用

```typescript
import { defineConfig } from 'vite'
import ViteChunkImportStyle from '@klweb/chunk-import-style'

export default defineConfig({
  // ...
  plugins: [
    ViteChunkImportStyle({
        outDir: './src/engine-core/vendor',  // 产物编译后的输出目录
        styleFile: 'style.css',             // 样式文件名称
        effectFiles: ['index.mjs']          // 要作用的文件名称
    })
  ]
})
```
npm package: @klweb/cli
Description: 昆仑 Web 脚手架(KLWeb-CLI), 是快速生成基础框架源码的终端命令行工具
Author: kunlun/zzh
Latest version: 1.0.2

# @klweb/cli

昆仑 `Web` 脚手架（KLWeb-CLI），是快速生成基础框架源码的终端命令行工具。

### 快速创建项目

- 首先全局安装 `KLWeb-CLI`（终端命令行工具）
```sh
npm install @klweb/cli -g
```

- 然后运行 `cmd` 或其它命令行界面，定位到你的目录位置，输入以下命令
```sh
klweb create

// 或
klweb c
```

- 接下来按命令提示向导式创建你的应用即可
```sh
? Project name: ()   // 项目名称，如：my-project
? Project description: () // 项目描述
? Author: ()  // 项目作者

// 是否集成第三方插件，非必选，可多选
? Check the plugins needed for your project: (Press <space> to select, <a> to toggle all, <i> to invert selection, and <enter> to proceed)
>( ) KLWeb3D
 ( ) KLCloud3D
```
### 查看 cli 配置信息

```sh
klweb get config
```
### 指定源码包仓库地址

```sh
klweb set -h
klweb set [option] [repository url]
```
npm package: @klweb/setup-extend
Description: Vue3 setup 语法糖扩展增强插件，支持在单文件组件 script 标签中定义 name 属性
Author: kunlun/zzh
Latest version: 1.0.1

# @klweb/setup-extend

`@klweb/setup-extend` 是一款 Vue3 `setup` 语法糖扩展增强插件，支持在单文件组件 `script` 标签中定义 `name` 属性。

## 安装插件

```bash
npm install @klweb/setup-extend -D
```

## 如何使用

在 `vite.config.ts` 文件中的 `plugin[]` 中使用插件：

```typescript
import SetupExtend from '@klweb/setup-extend';
export default defineConfig({
	plugins: [
		SetupExtend()
	]
})

// 禁用扩展

SetupExtend({
	name: false  // 默认 true
})

```

在组件的 `script` 标签中定义 `name` 属性，如：

```typescript
<script setup lang="ts" name="CustomName">
// ...
</script>

```
npm package: @klweb/theme-chalk
Description: Theme chalk for element plus
Author: kunlun/zzh
Latest version: 1.0.1

# @klweb/theme-chalk

`@klweb/theme-chalk` 它允许用户根据自己的喜好和需求在线自定义 `Element Plus` 的主题颜色。

## 安装插件

```bash
npm install @klweb/theme-chalk -D
```

## 如何使用

```typescript
import { setColorScheme, setThemeColor } from '@klweb/theme-chalk'

/**
 * 设置颜色方案
 * @params { string } type 支持两种模式：light | dark
*/
setColorScheme('dark')

/**
 * 设置主题颜色
 * @params { string } themeType 'primary' | 'success' | 'warning' | 'danger' | 'error' | 'info'
 * @params { string } hexColor 十六进制颜色值
*/
setThemeColor('primary', '#ff600')

```
npm package: @klweb/vite-compression
Description: 一款 Vite 进行项目打包时, 开启静态资源压缩性能优化策略插件
Author: kunlun/zzh
Latest version: 1.0.1

# @klweb/vite-compression

`@klweb/vite-compression` 是一款非常实用的 `Vite` 扩展插件，它可以帮助你在Vite进行项目打包时，开启静态资源压缩性能优化策略，自动压缩所有静态资源文件（如css、js、图片和音频等），很大程度减少静态资源的体积，以实现最佳的性能和用户体验。

> `@klweb/vite-compression` 支持多种压缩算法，并且具有可配置选项，以便根据您的需求进行定制。默认开启 `gzip` 压缩算法，在客户端请求时，服务器返回的 `gzip` 类型资源时，会自动解压缩，从而还原原始的数据，这样，既能减少网络传输的带宽损耗，也能提高资源传输的效率。

## 安装插件

```bash
npm install @klweb/vite-compression -D
```

## 如何使用

在 `vite.config.ts` 文件中的 `plugin[]` 中使用插件：

```typescript
import ViteCompress from '@klweb/vite-compression';
export default defineConfig({
	plugins: [
		ViteCompress({
			limitFileSize: 10240, // 启用压缩的文件大小限制，单位是字节，默认为 10240(B)（即10KB以上文件进行压缩）
			compressAlgorithm: 'gzip',  // 压缩算法，默认 gzip
			ext: '.gz'  // 生成的压缩包后缀
		})
	]
})
```

## 配置参考

### disableCompress

*   类型：boolean
*   默认：false

是否禁用压缩

***

### fileExtFilter

*   类型：RegExp
*   默认：/.(js|mjs|cjs|json|css|html)\$/i

过滤器-对哪些类型的文件进行压缩

***

### isDeleteOriginFile

*   类型：boolean
*   默认：false

压缩后是否删除源文件

***

### isOutputLog

*   类型：boolean
*   默认：true

是否在控制台输出压缩结果信息

***

### limitFileSize

*   类型：number
*   默认：10240

启用压缩的文件大小限制，单位是字节

***

### compressAlgorithm

*   类型：'gzip' | 'brotliCompress' | 'deflate' | 'deflateRaw'
*   默认：gzip

压缩算法

***

### ext

*   类型：'.gz' | '.br' | '.z' | '.z'
*   默认：.gz

生成的压缩包后缀


## 进阶

`@klweb/vite-compression` 支持 `gzip`、`brotliCompress` 、`deflate` 和 `deflateRaw` 四种压缩算法，这些压缩算法都是无损压缩算法，可以将原本较大的文件或数据流压缩成较小的文件或数据流，从而减少网络传输的数据量，提高传输效率。

#### 压缩算法说明：

*   `gzip`：使用 gzip 压缩算法进行压缩，生成的后缀是“.gz”
*   `brotliCompress`：使用 Brotli 压缩算法进行压缩，生成的后缀是“.br”
*   `deflate`：使用 deflate 压缩算法进行压缩，生成的后缀是“.z”
*   `deflateRaw`：使用 deflate 压缩算法进行压缩，但是不使用任何字典，生成的后缀也是“.z”

#### 在选择使用哪种压缩算法时，需要考虑以下几个因素：

1.  压缩比：不同的压缩算法可以达到不同的压缩比，一般来说，`Brotli` 压缩算法的压缩比最高，其次是 `gzip` 和 `deflate`，而 `deflateRaw` 的压缩比最低。
2.  解压缩时间：不同的压缩算法解压缩时间不同，一般来说，`gzip`  和 `deflate` 的解压缩时间较短， `Brotli`和 `deflateRaw` 的解压缩时间较长。
3.  浏览器支持度：不同的压缩算法在浏览器中的支持度也不同，一般来说，`gzip` 是最常用的压缩算法，几乎所有现代浏览器都支持它。而 `Brotli` 压缩算法在一些较老的浏览器中可能不被支持。

#### 在选择使用哪种后缀时，需要考虑以下几个因素：

1.  文件类型：不同的后缀适用于不同的文件类型，例如 `.gz` 通常用于文本文件的压缩，`.br` 通常用于图片和网页的压缩等。
2.  兼容性：不同的后缀在不同的操作系统和软件中可能存在兼容性问题，例如一些早期的软件可能只支持 `.z` 后缀的压缩文件。
3.  个人偏好：不同的开发者可能有不同的喜好和习惯，因此可能会选择不同的后缀来命名压缩文件。