# plugxable

> Js framework for pluggable application development.

Latest version **1.0.0-alpha.3** (published 2020-09-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install plugxable
pnpm add plugxable
yarn add plugxable
bun add plugxable
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0-alpha.3 |
| Published | 2020-09-15 |
| First published | 2020-03-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 116.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | qingbii |
| Maintainers | bliky |

## Links

- npm: https://www.npmjs.com/package/plugxable
- Homepage: https://github.com/kenblikylee/plugxable.git
- npm.io page: https://npm.io/package/plugxable

## Dependencies (1)

- [plugxable-shared](https://npm.io/package/plugxable-shared.md) ^1.0.0-alpha.0

## Recent versions

- 1.0.0-alpha.3 (latest) — 2020-09-15
- 1.0.0-alpha.2 — 2020-09-15
- 0.0.0 — 2020-03-27

## README

# Plugxable

Js framework for pluggable application development.

> 目的是将前端系统进行插件化解藕和跨系统的插件化复用，实现业务级模块的热插拔，可配置，一次开发，多次使用。

## Usage

### Develop a plugin

``` js
import { Plugin } from "plugxable"
import { LoginComponent, RegisterComponent, ForgotPasswdComponent } from "./component"
import VueEngine from '@plugxable/engine-vue'

export default class UserPlugin extends Plugin {
  apply(api) {
    api.page('login', '/login', LoginComponent)
    api.page('register', '/register', RegisterComponent)
    api.page('forgot', '/forgot', ForgotPasswdComponent)

    // 将插件配置注入到页面组件中
    super.apply(api)
    // 提供退出登录服务
    api.provide({
      'user:logout': (...arg) => {
        // ...
      },
    })
    // 注入其他插件提供的服务到插件页面实例中
    api.inject({
      success: 'common:success',
      info: 'common:info',
      warn: 'common:warn',
      error: 'common:error',
      logout: 'user:logout',
      // ...
    })
  }
}
```

### Run a plugxable app

``` js
import plugxable from "plugxable"
import UserPlugin from "./UserPlugin"

const userPluginOptions = {
  pages: {
    // 公共配置
    _: {
      brand: 'xxx',
      logo: 'https?://cdn.xxx.com/xxx.png'
      // ...
    },
    // 登录页面配置
    login: {
      text: 'xxx',
      loginIcon: 'https?://cdn.xxx.com/xxx.png'
      // ...
    },
    // 注册页面配置
    register: {
      registerIcon: 'https?://cdn.xxx.com/icons/register.png',
      registerText: '注册'
      // ...
    }
    // ...
  },
  services: {
    login: 'https?://api.xxx.com/login',
    logout: 'https?://api.xxx.com/logout',
    register: 'https?://api.xxx.com/register',
    forgot: 'https?://api.xxx.com/forgot'
  }
}

const app = plugxable({
  engine: VueEngine,
  plugins: {
    user: new UserPlugin(userPluginOptions),
    // ... other plugin
  }
})

app.run()
```

## Status: Dev

## TODOs

- rollup build script
- test in browser

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