Skip to content

Commit

Permalink
feat: init
Browse files Browse the repository at this point in the history
  • Loading branch information
yiludege committed Jun 29, 2022
0 parents commit 30397aa
Show file tree
Hide file tree
Showing 328 changed files with 22,112 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
node_modules
npm-debug.log
dist
site
lib
esm
.DS_Store
.vscode
yarn.lock
package-lock.json
coverage
.history
8 changes: 8 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

# npx --no-install commitlint --edit "$1"

npm run husky-commitlint


4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

lerna run --scope wujie lint
3 changes: 3 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
printWidth: 120,
};
145 changes: 145 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
## 调试代码

克隆代码后,运行以下脚本就可以在本地调试代码:

```bash
npm i // 安装包依赖
npx husky install // Enable Git hooks
npm i -g lerna // 安装 lerna
lerna bootstrap // 安装所有子应用包依赖
npm run start // 启动子应用
```

## Issue 提交

#### 对于贡献者

在提 issue 前请确保满足一下条件:

- 必须是一个 bug 或者功能新增。
- 已经在 issue 中搜索过,并且没有找到相似的 issue 或者解决方案。

## Pull request

我们除了希望听到您的反馈和建议外,我们也希望您接受代码形式的直接帮助,对我们的 GitHub 发出 pull request 请求。

以下是具体步骤:

#### Fork 仓库

点击 `Fork` 按钮,将需要参与的项目仓库 fork 到自己的 Github 中。

#### Clone 已 fork 项目

在自己的 github 中,找到 fork 下来的项目,git clone 到本地。

```bash
$ git clone git@github.com:<yourname>/wujie.git
```

#### 添加 wujie 仓库

将 fork 源仓库连接到本地仓库:

```bash
$ git remote add <name> <url>
# 例如:
$ git remote add tencent git@github.com:Tencent/wujie.git
```

#### 发起 pull request 前同步最新代码

更新上游仓库:

```bash
$ git pull --rebase <name> <branch>
# 等同于以下两条命令
$ git fetch <name> <branch>
$ git rebase <name>/<branch>
```

## Commit

对于如何提交 git commit message,我们有非常精确的规则。我们希望所有的 commit message 更具可读性,这样在查看项目历史记录会变得容易,同时我们使用 commit message 生成 Changelog.

本项目使用了 `@commitlint` 作为 commit lint 工具,并使用 [`@commitlint/config-conventional`](https://www.npmjs.com/package/@commitlint/config-conventional)作为校验规则.

### 提交格式

每个 commit message 包括 **header**, **body****footer**.

header 具有特殊的格式,包括 **type**, **scope****subject**, type 和 subject 是必须的,scope 是可选的。

```vim
<type>(<scope>): <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>
```

提交 message 的任何行不能超过 100 个字符!确保 message 在 GitHub 以及各种 git 工具中更易于阅读。

注脚应该包含 [closing reference to an issue](https://help.github.com/articles/closing-issues-via-commit-messages/) 如果有的话.

示例:

```vim
docs(changelog): update change log to beta.5
```

```vim
fix(editor): resize error
Component doesn't refresh when resize it.
fix #123
```

### Type

必须是以下选项之一:

- **feat**: 一个新特性
- **fix**: 一次 bug 修复
- **docs**: 只是对文档进行修改
- **style**: 不影响代码本身含义的代码风格修改
- **refactor**: 既不属于新特性又不是 bug 修改的代码修改
- **perf**: 性能优化
- **test**: 添加或修改测试用例
- **build**: 修改构建工具
- **ci**: 修改自动化脚本
- **revert**: 回滚提交

### Scope

Scope 应该是本次修改所影响模块的名称(文件夹名称或其他有意义的单词)。

```vim
<prefix:name>
<prefix:name1,name2>
```

其他情况可以忽略 scope:

- 使用 `docs`, `build``ci` 等全局修改(例如:`docs: add missing type`).

### Subject

Subject 是本次修改的简洁描述:

- 使用祈使句、现在时,例如:使用 "change" 而不是 "changed"、"changes"
- 不大写第一个字母
- 不以小数点(.)结尾

### Body

Body 应包含修改的动机,并对比这与以前的行为,是本次修改的详细描述:

- 使用祈使句、现在时,例如:使用 "change" 而不是 "changed"、"changes"

### Footer

Footer 应包含 **Breaking Changes** 和关闭或关联的 **Issues**

- **Breaking Changes** 应该以 `BREAKING CHANGE:` 开头
- 关联的 **Issues** 使用 `issue #2`
- 关闭 **Issues** 使用 `close #2`
23 changes: 23 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
MIT License

Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Other dependencies:

The below software in this distribution may have been modified by THL A29 Limited ("Tencent Modifications").
All Tencent Modifications are Copyright (C) 2022 THL A29 Limited.

---------------------------------------------------------------------------------------------------------------

1. import-html-entry
Copyright (c) 2018 Kuitos

2. qiankun
Copyright (c) 2019 Kuitos
152 changes: 152 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
<p align="center">
<a href="https://wujie-micro.github.io/doc/" target="_blank">
<img src="https://vfiles.gtimg.cn/wuji_dashboard/xy/test_wuji_damy/phFSuhUC.png" width="100" height="100" alt="logo">
</a>
</p>

# wujie(无界)

无界微前端是一款基于 webcomponent + iframe 微前端框架,具备成本低、速度快、原生隔离、功能强等一系列优点。

## 文档

文档详见:[文档](https://wujie-micro.github.io/doc/)

演示详见:[demo](https://wujie-demo.pages.woa.com/home)

## 背景

微前端已经是一个非常成熟的领域了,但开发者不管采用哪个现有方案,在适配成本、样式隔离、运行性能、页面白屏、子应用通信、子应用保活、多应用激活、vite 框架支持、应用共享等用户核心诉求都或存在问题、或无法提供支持。

webcomponent 是一个浏览器原生支持的组件封装技术,可以有效隔离元素之间的样式,iframe 可以给子应用提供一个原生隔离的运行环境,相比自行构造的沙箱 iframe 提供了独立的 window、document、history、location,可以更好的和外部解耦。无界微前端采用 webcomponent + iframe 的沙箱模式,在实现原生隔离的前提下比较完善的解决了上述问题。

## 特性

1. 成本低
- 主应用使用成本低
- 子应用适配成本低
2. 速度快
- 子应用首屏打开速度快
- 子应用运行速度快
3. 原生隔离
- css 样式通过 webcomponent 可以做到严格的原生隔离
- js 运行在 iframe 中做到严格的原生隔离
4. 功能强大
- 支持子应用保活
- 支持子应用嵌套
- 支持多应用激活
- 支持应用共享
- 支持去中心化通信
- 支持生命周期钩子
- 支持插件系统
- 支持 vite 框架
- 兼容 IE9(需自行 babel 编译)

## 快速上手

### 直接使用

- 安装

```bash
npm install wujie -S
```

- 使用

```javascript
import { startApp } from "wujie";

startApp({ name: "唯一id", url: "子应用路径", el: "容器", sync: true });
```

### vue 框架

- 安装

```bash
# vue2 框架
npm i wujie-vue2 -S
# vue3 框架
npm i wujie-vue3 -S

```

- 引入

```javascript
// vue2
import WujieVue from "wujie-vue2";
// vue3
import WujieVue from "wujie-vue3";
Vue.use(WujieVue);
```

- 使用

```html
<WujieVue
width="100%"
height="100%"
name="xxx"
:url="xxx"
:sync="true"
:fetch="fetch"
:props="props"
:beforeLoad="beforeLoad"
:beforeMount="beforeMount"
:afterMount="afterMount"
:beforeUnmount="beforeUnmount"
:afterUnmount="afterUnmount"
></WujieVue>
```

### react 框架

- 安装

```bash
npm i wujie-react -S

```

- 引入

```javascript
import WujieReact from "wujie-react";
```

- 使用

```html
<WujieReact
width="100%"
height="100%"
name="xxx"
url="{xxx}"
sync="{true}"
fetch="{fetch}"
props="{props}"
beforeLoad="{beforeLoad}"
beforeMount="{beforeMount}"
afterMount="{afterMount}"
beforeUnmount="{beforeUnmount}"
afterUnmount="{afterUnmount}"
></WujieReact>
```

## 常见问题

[详见文档](https://wujie-micro.github.io/doc/question/#_1%E3%80%81%E8%AF%B7%E6%B1%82%E8%B5%84%E6%BA%90%E6%8A%A5%E9%94%99)

## 本地开发

运行以下脚本,可以本地开发无界微前端框架,支持实时编译调试开发。

```bash
npm i // 安装包依赖
npx husky install // Enable Git hooks
npm i -g lerna // 安装 lerna
lerna bootstrap // 安装所有子应用包依赖
npm run start // 启动子应用
```
3 changes: 3 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ['@commitlint/config-conventional']
}
17 changes: 17 additions & 0 deletions examples/angular12/.browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries

# For the full list of supported browsers by the Angular framework, please see:
# https://angular.io/guide/browser-support

# You can see what browsers were selected by your queries by running:
# npx browserslist

last 1 Chrome version
last 1 Firefox version
last 2 Edge major versions
last 2 Safari major versions
last 2 iOS major versions
Firefox ESR
not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.
16 changes: 16 additions & 0 deletions examples/angular12/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Editor configuration, see https://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.ts]
quote_type = single

[*.md]
max_line_length = off
trim_trailing_whitespace = false
Loading

0 comments on commit 30397aa

Please sign in to comment.