@micro-zoe/micro-app 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <p align="center">
2
- <a href="https://zeroing.jd.com/micro-app/">
3
- <img src="https://cangdu.org/micro-app/_media/logo.png" alt="logo" width="200"/>
2
+ <a href="https://micro-zoe.github.io/micro-app/">
3
+ <img src="https://zeroing.jd.com/micro-app/media/logo.png" alt="logo" width="200"/>
4
4
  </a>
5
5
  </p>
6
6
 
@@ -25,7 +25,7 @@
25
25
  </a>
26
26
  </p>
27
27
 
28
- English|[简体中文](https://github.com/micro-zoe/micro-app/blob/master/README.zh-cn.md)|[Documentation](https://zeroing.jd.com/micro-app/)|[Discussions](https://github.com/micro-zoe/micro-app/discussions)|[Gitter](https://gitter.im/microzoe/micro-app)
28
+ English|[简体中文](./README.zh-cn.md)|[Documentation](https://micro-zoe.github.io/micro-app/)|[Discussions](https://github.com/micro-zoe/micro-app/discussions)|[Gitter](https://gitter.im/microzoe/micro-app)
29
29
 
30
30
  # 📖Introduction
31
31
  micro-app is a micro front-end framework launched by JD Retail. It renders based on webcomponent-like and realizes the micro front-end from component thinking, it aiming to reduce the difficulty of getting started and improve work efficiency.
@@ -80,18 +80,18 @@ export default routes
80
80
  <template>
81
81
  <div>
82
82
  <h1>micro application</h1>
83
- <!-- name is the application name, globally unique, url is the html address -->
84
- <micro-app name='app1' url='http://localhost:3000/' baseurl='/my-page'></micro-app>
83
+ <!-- 👇 name is the application name, globally unique, url is the html address -->
84
+ <micro-app name='app1' url='http://localhost:3000/' baseroute='/my-page'></micro-app>
85
85
  </div>
86
86
  </template>
87
87
  ```
88
88
 
89
- > Please refer to [Routing Chapter](https://zeroing.jd.com/micro-app/docs.html#/zh-cn/route) for the relationship between url and micro application routing
89
+ > Please refer to [Routing Chapter](https://micro-zoe.github.io/micro-app/docs.html#/zh-cn/route) for the relationship between url and micro application routing
90
90
 
91
91
  ## micro application
92
92
  > The micro application takes the react framework as an example
93
93
 
94
- 1、Add basename for route(If the base application is history route and the micro application is hash route, it is not necessary to set the baseurl, this step can be skipped)
94
+ 1、Add basename for route(If the base application is history route and the micro application is hash route, it is not necessary to set the baseroute, this step can be skipped)
95
95
 
96
96
  ```js
97
97
  // router.js
@@ -99,8 +99,8 @@ import { BrowserRouter, Switch, Route } from 'react-router-dom'
99
99
 
100
100
  export default function AppRoute () {
101
101
  return (
102
- // 👇 the micro application can get the baseurl issued by the base application through window.__MICRO_APP_BASE_URL__
103
- <BrowserRouter basename={window.__MICRO_APP_BASE_URL__ || '/'}>
102
+ // 👇 the micro application can get the baseroute issued by the base application through window.__MICRO_APP_BASE_ROUTE__
103
+ <BrowserRouter basename={window.__MICRO_APP_BASE_ROUTE__ || '/'}>
104
104
  <Switch>
105
105
  ...
106
106
  </Switch>
@@ -124,13 +124,11 @@ Then micro front-end can be rendered normally, and the react micro application i
124
124
 
125
125
  The above lists the usage of react and Vue framework. They can be combined freely. For example, the base application is react, the micro application is Vue, or the base application is Vue, the micro application is react, or both the base application and the micro application are react and Vue. The micro-app has no restrictions on the front-end framework, and any framework can be used as a base application to embed any type of micro application of the framework.
126
126
 
127
- More detailed configuration can be viewed [Documentation](https://zeroing.jd.com/micro-app/docs.html#/zh-cn/start).
127
+ More detailed configuration can be viewed [Documentation](https://micro-zoe.github.io/micro-app/docs.html#/zh-cn/start).
128
128
 
129
129
  # 🤝 Contribution
130
130
  If you're interested in this project, you're welcome to mention pull request, and also welcome your "Star" ^_^
131
131
 
132
- If you are using it, please [tell us](https://github.com/micro-zoe/micro-app/issues/35)
133
-
134
132
  ### development
135
133
  1、Clone
136
134
  ```
@@ -192,12 +190,13 @@ For more commands, see [DEVELP](https://github.com/micro-zoe/micro-app/blob/mast
192
190
  <details>
193
191
  <summary>Does it support vite?</summary>
194
192
 
195
- Yes, please see [adapt vite](https://zeroing.jd.com/micro-app/docs.html#/zh-cn/advanced?id=_2%e3%80%81%e9%80%82%e9%85%8dvite) for details.
193
+ Yes, please see [adapt vite](https://micro-zoe.github.io/micro-app/docs.html#/zh-cn/advanced?id=_2%e3%80%81%e9%80%82%e9%85%8dvite) for details.
196
194
  </details>
197
195
 
198
196
  # Contributors
197
+ <a href="https://github.com/micro-zoe/micro-app/graphs/contributors"><img src="./.github/contributors.svg" /></a>
199
198
  <!-- opencollective is inaccurate -->
200
- <a href="https://github.com/micro-zoe/micro-app/graphs/contributors"><img src="https://opencollective.com/micro-app/contributors.svg?width=890&button=false" /></a>
199
+ <!-- <a href="https://github.com/micro-zoe/micro-app/graphs/contributors"><img src="https://opencollective.com/micro-app/contributors.svg?width=890&button=false" /></a> -->
201
200
 
202
201
  # License
203
202
  [MIT License](https://github.com/micro-zoe/micro-app/blob/master/LICENSE)
package/README.zh-cn.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <p align="center">
2
- <a href="https://zeroing.jd.com/micro-app/">
3
- <img src="https://cangdu.org/micro-app/_media/logo.png" alt="logo" width="180"/>
2
+ <a href="https://micro-zoe.github.io/micro-app/">
3
+ <img src="https://zeroing.jd.com/micro-app/media/logo.png" alt="logo" width="200"/>
4
4
  </a>
5
5
  </p>
6
6
 
@@ -25,18 +25,13 @@
25
25
  </a>
26
26
  </p>
27
27
 
28
- [English](https://github.com/micro-zoe/micro-app)|简体中文|[官网文档](https://zeroing.jd.com/micro-app/)|[讨论组](https://github.com/micro-zoe/micro-app/discussions)|[Gitter群聊](https://gitter.im/microzoe/micro-app)
28
+ [English](https://github.com/micro-zoe/micro-app)|简体中文|[官网文档](https://micro-zoe.github.io/micro-app/)|[讨论组](https://github.com/micro-zoe/micro-app/discussions)|[Gitter群聊](https://gitter.im/microzoe/micro-app)
29
29
 
30
30
  # 📖简介
31
31
  micro-app是京东零售推出的一款微前端框架,它基于类WebComponent进行渲染,从组件化的思维实现微前端,旨在降低上手难度、提升工作效率。它是目前接入微前端成本最低的框架,并且提供了JS沙箱、样式隔离、元素隔离、预加载、资源地址补全、插件系统、数据通信等一系列完善的功能。
32
32
 
33
33
  micro-app与技术栈无关,也不和业务绑定,可以用于任何前端框架。
34
34
 
35
- #### 概念图
36
- <p>
37
- <img src="https://img10.360buyimg.com/imagetools/jfs/t1/168885/23/20790/54203/6084d445E0c9ec00e/d879637b4bb34253.png" alt="概念图" width='850'/>
38
- </p>
39
-
40
35
  # 🔧开始使用
41
36
  微前端分为基座应用和子应用,我们分别列出基座应用和子应用需要进行的修改,具体介绍micro-app的使用方式。
42
37
 
@@ -67,7 +62,7 @@ Vue.use(VueRouter)
67
62
 
68
63
  const routes = [
69
64
  {
70
- // 👇 非严格匹配,/my-page/xxx 都将匹配到 MyPage 组件
65
+ // 👇 非严格匹配,/my-page/xxx 都将匹配到 MyPage 页面
71
66
  path: '/my-page/*',
72
67
  name: 'my-page',
73
68
  component: MyPage,
@@ -77,24 +72,24 @@ const routes = [
77
72
  export default routes
78
73
  ```
79
74
 
80
- 4、在`my-page`页面中使用组件
75
+ 4、在`MyPage`页面中嵌入微前端应用
81
76
  ```html
82
77
  <!-- my-page.vue -->
83
78
  <template>
84
79
  <div>
85
80
  <h1>子应用</h1>
86
- <!-- name为应用名称,url为html地址 -->
87
- <micro-app name='app1' url='http://localhost:3000/' baseurl='/my-page'></micro-app>
81
+ <!-- 👇 name为应用名称,url为html地址 -->
82
+ <micro-app name='app1' url='http://localhost:3000/' baseroute='/my-page'></micro-app>
88
83
  </div>
89
84
  </template>
90
85
  ```
91
86
 
92
- > url和子应用路由的关系请查看[路由一章](https://zeroing.jd.com/micro-app/docs.html#/zh-cn/route)
87
+ > url和子应用路由的关系请查看[路由一章](https://micro-zoe.github.io/micro-app/docs.html#/zh-cn/route)
93
88
 
94
89
  ## 子应用
95
90
  > 子应用以react框架为例
96
91
 
97
- 1、添加路由前缀(如果基座应用是history路由,子应用是hash路由,不需要设置路由前缀,这一步可以省略)
92
+ 1、设置基础路由(如果基座应用是history路由,子应用是hash路由,不需要设置基础路由,这一步可以省略)
98
93
 
99
94
  ```js
100
95
  // router.js
@@ -102,8 +97,8 @@ import { BrowserRouter, Switch, Route } from 'react-router-dom'
102
97
 
103
98
  export default function AppRoute () {
104
99
  return (
105
- // 👇 添加路由前缀,子应用可以通过window.__MICRO_APP_BASE_URL__获取基座应用下发的baseurl
106
- <BrowserRouter basename={window.__MICRO_APP_BASE_URL__ || '/'}>
100
+ // 👇 设置基础路由,子应用可以通过window.__MICRO_APP_BASE_ROUTE__获取基座应用下发的baseroute
101
+ <BrowserRouter basename={window.__MICRO_APP_BASE_ROUTE__ || '/'}>
107
102
  <Switch>
108
103
  ...
109
104
  </Switch>
@@ -127,13 +122,11 @@ devServer: {
127
122
 
128
123
  上面列出了react和vue框架的使用方式,它们是可以自由组合的,比如基座应用是react,子应用是vue,或者基座应用是vue,子应用是react,或者基座应用和子应用都是react、vue。 micro-app对前端框架没有限制,任何框架都可以作为基座应用嵌入任何类型框架的子应用。
129
124
 
130
- 更多详细配置可以查看[官网文档](https://zeroing.jd.com/micro-app/docs.html#/zh-cn/start)
125
+ 更多详细配置可以查看[官网文档](https://micro-zoe.github.io/micro-app/docs.html#/zh-cn/start)
131
126
 
132
127
  # 🤝 参与共建
133
128
  如果您对这个项目感兴趣,欢迎提 pull request,也欢迎 "Star" 支持一下 ^_^
134
129
 
135
- 如果您正在使用,请务必[告诉我们](https://github.com/micro-zoe/micro-app/issues/35)
136
-
137
130
  ### 本地运行
138
131
  1、克隆项目
139
132
  ```
@@ -153,7 +146,7 @@ yarn start # 访问 http://localhost:3000
153
146
  更多命令请查看[DEVELP](https://github.com/micro-zoe/micro-app/blob/master/DEVELOP.zh-cn.md)
154
147
 
155
148
  # FAQ
156
- [问题汇总](https://zeroing.jd.com/micro-app/docs.html#/zh-cn/questions)
149
+ [问题汇总](https://micro-zoe.github.io/micro-app/docs.html#/zh-cn/questions)
157
150
  <details>
158
151
 
159
152
  <summary>micro-app的优势在哪里?</summary>
@@ -196,13 +189,13 @@ yarn start # 访问 http://localhost:3000
196
189
  <details>
197
190
  <summary>支持vite吗?</summary>
198
191
 
199
- 支持,详情请查看[适配vite](https://zeroing.jd.com/micro-app/docs.html#/zh-cn/advanced?id=_2%e3%80%81%e9%80%82%e9%85%8dvite)
192
+ 支持,详情请查看[适配vite](https://micro-zoe.github.io/micro-app/docs.html#/zh-cn/advanced?id=_2%e3%80%81%e9%80%82%e9%85%8dvite)
200
193
  </details>
201
194
 
202
195
  # 贡献者们
203
-
196
+ <a href="https://github.com/micro-zoe/micro-app/graphs/contributors"><img src="./.github/contributors.svg" /></a>
204
197
  <!-- opencollective is inaccurate -->
205
- <a href="https://github.com/micro-zoe/micro-app/graphs/contributors"><img src="https://opencollective.com/micro-app/contributors.svg?width=890&button=false" /></a>
198
+ <!-- <a href="https://github.com/micro-zoe/micro-app/graphs/contributors"><img src="https://opencollective.com/micro-app/contributors.svg?width=890&button=false" /></a> -->
206
199
 
207
200
  # License
208
201
  [MIT License](https://github.com/micro-zoe/micro-app/blob/master/LICENSE)
package/lib/index.d.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  declare module '@micro-zoe/micro-app' {
7
7
  export { default as preFetch } from '@micro-zoe/micro-app/prefetch';
8
8
  export { default } from '@micro-zoe/micro-app/micro_app';
9
- export { removeDomScope, pureCreateElement, version } from '@micro-zoe/micro-app/libs/utils';
9
+ export { removeDomScope, pureCreateElement, version, setCurrentAppName } from '@micro-zoe/micro-app/libs/utils';
10
10
  }
11
11
 
12
12
  declare module '@micro-zoe/micro-app/prefetch' {
@@ -59,24 +59,9 @@ declare module '@micro-zoe/micro-app/micro_app' {
59
59
 
60
60
  declare module '@micro-zoe/micro-app/libs/utils' {
61
61
  import type { Func } from '@micro-app/types';
62
- type RequestIdleCallbackOptions = {
63
- timeout: number;
64
- };
65
- type RequestIdleCallbackInfo = {
66
- readonly didTimeout: boolean;
67
- timeRemaining: () => number;
68
- };
69
- global {
70
- interface Window {
71
- requestIdleCallback(callback: (info: RequestIdleCallbackInfo) => void, opts?: RequestIdleCallbackOptions): number;
72
- _babelPolyfill: boolean;
73
- proxyWindow: WindowProxy;
74
- __MICRO_APP_ENVIRONMENT__: boolean;
75
- }
76
- }
77
- export const rawWindow: any;
78
- export const rawDocument: any;
79
62
  export const version = "__VERSION__";
63
+ export const isBrowser: boolean;
64
+ export const globalThis: Window;
80
65
  /**
81
66
  * format error log
82
67
  * @param msg message
@@ -131,7 +116,12 @@ declare module '@micro-zoe/micro-app/libs/utils' {
131
116
  export function isSupportModuleScript(): boolean;
132
117
  export function createNonceStr(): string;
133
118
  export function unique(array: any[]): any[];
134
- export const requestIdleCallback: (callback: (info: RequestIdleCallbackInfo) => void, opts?: RequestIdleCallbackOptions | undefined) => number;
119
+ export const requestIdleCallback: (callback: (info: {
120
+ readonly didTimeout: boolean;
121
+ timeRemaining: () => number;
122
+ }) => void, opts?: {
123
+ timeout: number;
124
+ } | undefined) => number;
135
125
  export function setCurrentAppName(appName: string | null): void;
136
126
  export function getCurrentAppName(): string | null;
137
127
  export function removeDomScope(): void;
@@ -146,8 +136,7 @@ declare module '@micro-zoe/micro-app/libs/utils' {
146
136
  * @param origin Cloned element
147
137
  * @param target Accept cloned elements
148
138
  */
149
- export function cloneNode<T extends Node, Q extends Node>(origin: T, target: Q): void;
150
- export {};
139
+ export function cloneNode<T extends Element, Q extends Element>(origin: T, target: Q): void;
151
140
  }
152
141
 
153
142
  declare module '@micro-zoe/micro-app/interact' {