# @versea/core

> versea 的核心能力，应用注册，加载，切换能力。

Latest version **0.3.1** (published 2023-03-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install @versea/core
pnpm add @versea/core
yarn add @versea/core
bun add @versea/core
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.1 |
| Published | 2023-03-21 |
| First published | 2022-01-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 10 |
| Unpacked size | 1.5 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 16 |
| Maintainers | chhu1 |

## Links

- npm: https://www.npmjs.com/package/@versea/core
- Repository: https://github.com/versea/versea
- Homepage: https://github.com/versea/versea#readme
- Issues: https://github.com/versea/versea/issues
- npm.io page: https://npm.io/package/@versea/core

## Dependencies (10)

- [ramda](https://npm.io/package/ramda.md) ^0.28.0
- [tslib](https://npm.io/package/tslib.md) ^2.3.1
- [inversify](https://npm.io/package/inversify.md) ^6.0.1
- [@types/ramda](https://npm.io/package/@types/ramda.md) ^0.28.3
- [query-string](https://npm.io/package/query-string.md) ^7.1.1
- [@versea/shared](https://npm.io/package/@versea/shared.md) 0.3.1
- [path-to-regexp](https://npm.io/package/path-to-regexp.md) ^6.2.0
- [@versea/tapable](https://npm.io/package/@versea/tapable.md) 0.3.1
- [reflect-metadata](https://npm.io/package/reflect-metadata.md) ^0.1.13
- [typescript-lodash](https://npm.io/package/typescript-lodash.md) ^0.0.6

## Recent versions

- 0.3.1 (latest) — 2023-03-21
- 0.3.0 — 2023-01-31
- 0.2.6 — 2023-01-31
- 0.2.5 — 2023-01-29
- 0.2.4 — 2023-01-29
- 0.2.3 — 2023-01-28
- 0.2.2 — 2023-01-28
- 0.2.1 — 2023-01-28
- 0.2.0 — 2022-06-20
- 0.1.1 — 2022-05-17
- 0.1.0 — 2022-04-22
- 0.0.5 — 2022-01-14
- 0.0.4 — 2022-01-14

## README

# @versea/core

versea 的核心能力，应用注册，加载，切换能力。

### 安装

```bash
npm install --save @versea/core
```

### 使用

```ts
import { buildProviderModule, IAppService, IStarter, AppLifeCycles } from '@versea/core';
import { Container } from 'inversify';

async function loadScript(url): Promise<void> {
  console.log(url);
  // ...
  await Promise.resolve();
}

// 创建容器
const container = new Container({ defaultScope: 'Singleton' });

// 绑定依赖容器
container.load(buildProviderModule(container));

// 注册子应用
container.get<IAppService>(IAppService).registerApps([
  {
    name: 'subApp',
    routes: [
      {
        path: 'sub-app',
        pathToRegexpOptions: {
          end: false,
        },
      },
    ],
    loadApp: async (): AppLifeCycles => {
      await loadScript('http://localhost:3000/static/js/bundle.js');
      return (window as any).microApp;
    },
  },
]);

// 在合适的时机启动 versea
void container.get<IStarter>(IStarter).start();
```

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