@micro-zoe/micro-app 1.0.0-rc.3 → 1.0.0-rc.30

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://micro-zoe.github.io/micro-app/">
3
- <img src="https://zeroing.jd.com/micro-app/media/logo.png" alt="logo" width="200"/>
2
+ <a href="https://jd-opensource.github.io/micro-app/">
3
+ <img src="https://jd-opensource.github.io/micro-app/home/assets/logo.png" alt="logo" width="200"/>
4
4
  </a>
5
5
  </p>
6
6
 
@@ -11,21 +11,21 @@
11
11
  <a href="https://www.npmjs.com/package/@micro-zoe/micro-app">
12
12
  <img src="https://img.shields.io/npm/dt/@micro-zoe/micro-app.svg" alt="downloads"/>
13
13
  </a>
14
- <a href="https://github.com/micro-zoe/micro-app/blob/master/LICENSE">
14
+ <a href="https://github.com/jd-opensource/micro-app/blob/master/LICENSE">
15
15
  <img src="https://img.shields.io/npm/l/@micro-zoe/micro-app.svg" alt="license"/>
16
16
  </a>
17
- <a href="https://github.com/micro-zoe/micro-app/blob/dev/Contact.md">
17
+ <a href="https://github.com/jd-opensource/micro-app/blob/dev/Contact.md">
18
18
  <img src="https://img.shields.io/badge/chat-wechat-blue" alt="WeChat">
19
19
  </a>
20
- <a href="https://travis-ci.com/github/micro-zoe/micro-app">
21
- <img src="https://api.travis-ci.com/micro-zoe/micro-app.svg?branch=master" alt="travis"/>
20
+ <a href="https://travis-ci.com/github/jd-opensource/micro-app">
21
+ <img src="https://api.travis-ci.com/jd-opensource/micro-app.svg?branch=master" alt="travis"/>
22
22
  </a>
23
- <a href="https://coveralls.io/github/micro-zoe/micro-app?branch=master">
24
- <img src="https://coveralls.io/repos/github/micro-zoe/micro-app/badge.svg?branch=master" alt="coveralls"/>
23
+ <a href="https://coveralls.io/github/jd-opensource/micro-app?branch=master">
24
+ <img src="https://coveralls.io/repos/github/jd-opensource/micro-app/badge.svg?branch=master" alt="coveralls"/>
25
25
  </a>
26
26
  </p>
27
27
 
28
- English|[简体中文](./README.zh-cn.md)|[Documentation](https://micro-zoe.github.io/micro-app/)|[Discussions](https://github.com/micro-zoe/micro-app/discussions)|[WeChat](./Contact.md)
28
+ English|[简体中文](./README.zh-cn.md)|[Documentation](https://jd-opensource.github.io/micro-app/)|[Discussions](https://github.com/jd-opensource/micro-app/discussions)|[WeChat](./Contact.md)
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.
@@ -72,7 +72,7 @@ The above micro front-end rendering is completed, and the effect is as follows:
72
72
 
73
73
  ![image](https://img10.360buyimg.com/imagetools/jfs/t1/188373/14/17696/41854/6111f4a0E532736ba/4b86f4f8e2044519.png)
74
74
 
75
- More detailed configuration can be viewed [Documentation](https://micro-zoe.github.io/micro-app/docs.html#/zh-cn/start).
75
+ More detailed configuration can be viewed [Documentation](https://jd-opensource.github.io/micro-app/docs.html#/zh-cn/start).
76
76
 
77
77
  # 🤝 Contribution
78
78
  If you're interested in this project, you're welcome to mention pull request, and also welcome your "Star" ^_^
@@ -80,7 +80,7 @@ If you're interested in this project, you're welcome to mention pull request, an
80
80
  ### development
81
81
  1、Clone
82
82
  ```
83
- git clone https://github.com/micro-zoe/micro-app.git
83
+ git clone https://github.com/jd-opensource/micro-app.git
84
84
  ```
85
85
 
86
86
  2、Install dependencies
@@ -93,7 +93,7 @@ yarn bootstrap
93
93
  yarn start
94
94
  ```
95
95
 
96
- For more commands, see [DEVELOP](https://github.com/micro-zoe/micro-app/blob/master/DEVELOP.md)
96
+ For more commands, see [DEVELOP](https://github.com/jd-opensource/micro-app/blob/master/DEVELOP.md)
97
97
 
98
98
  # FAQ
99
99
  <details>
@@ -138,19 +138,19 @@ For more commands, see [DEVELOP](https://github.com/micro-zoe/micro-app/blob/mas
138
138
  <details>
139
139
  <summary>Does it support vite?</summary>
140
140
 
141
- Yes, please see [adapt vite](https://micro-zoe.github.io/micro-app/docs.html#/zh-cn/framework/vite) for details.
141
+ Yes, please see [adapt vite](https://jd-opensource.github.io/micro-app/docs.html#/zh-cn/framework/vite) for details.
142
142
  </details>
143
143
 
144
144
  <details>
145
145
  <summary>Does it support ssr?</summary>
146
146
 
147
- Yes, please see [nextjs](https://micro-zoe.github.io/micro-app/docs.html#/zh-cn/framework/nextjs), [nuxtjs](https://micro-zoe.github.io/micro-app/docs.html#/zh-cn/framework/nuxtjs) for details.
147
+ Yes, please see [nextjs](https://jd-opensource.github.io/micro-app/docs.html#/zh-cn/framework/nextjs), [nuxtjs](https://jd-opensource.github.io/micro-app/docs.html#/zh-cn/framework/nuxtjs) for details.
148
148
  </details>
149
149
 
150
150
  # Contributors
151
- <a href="https://github.com/micro-zoe/micro-app/graphs/contributors">
152
- <img src="https://contrib.rocks/image?repo=micro-zoe/micro-app" />
151
+ <a href="https://github.com/jd-opensource/micro-app/graphs/contributors">
152
+ <img src="https://contrib.rocks/image?repo=jd-opensource/micro-app" />
153
153
  </a>
154
154
 
155
155
  # License
156
- [MIT License](https://github.com/micro-zoe/micro-app/blob/master/LICENSE)
156
+ [MIT License](https://github.com/jd-opensource/micro-app/blob/master/LICENSE)
package/README.zh-cn.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <p align="center">
2
- <a href="https://micro-zoe.github.io/micro-app/">
2
+ <a href="https://jd-opensource.github.io/micro-app/">
3
3
  <img src="https://zeroing.jd.com/micro-app/media/logo.png" alt="logo" width="200"/>
4
4
  </a>
5
5
  </p>
@@ -11,21 +11,21 @@
11
11
  <a href="https://www.npmjs.com/package/@micro-zoe/micro-app">
12
12
  <img src="https://img.shields.io/npm/dt/@micro-zoe/micro-app.svg" alt="downloads"/>
13
13
  </a>
14
- <a href="https://github.com/micro-zoe/micro-app/blob/master/LICENSE">
14
+ <a href="https://github.com/jd-opensource/micro-app/blob/master/LICENSE">
15
15
  <img src="https://img.shields.io/npm/l/@micro-zoe/micro-app.svg" alt="license"/>
16
16
  </a>
17
- <a href="https://github.com/micro-zoe/micro-app/blob/dev/Contact.md">
17
+ <a href="https://github.com/jd-opensource/micro-app/blob/dev/Contact.md">
18
18
  <img src="https://img.shields.io/badge/chat-wechat-blue" alt="WeChat">
19
19
  </a>
20
- <a href="https://travis-ci.com/github/micro-zoe/micro-app">
21
- <img src="https://api.travis-ci.com/micro-zoe/micro-app.svg?branch=master" alt="travis"/>
20
+ <a href="https://travis-ci.com/github/jd-opensource/micro-app">
21
+ <img src="https://api.travis-ci.com/jd-opensource/micro-app.svg?branch=master" alt="travis"/>
22
22
  </a>
23
- <a href="https://coveralls.io/github/micro-zoe/micro-app?branch=master">
24
- <img src="https://coveralls.io/repos/github/micro-zoe/micro-app/badge.svg?branch=master" alt="coveralls"/>
23
+ <a href="https://coveralls.io/github/jd-opensource/micro-app?branch=master">
24
+ <img src="https://coveralls.io/repos/github/jd-opensource/micro-app/badge.svg?branch=master" alt="coveralls"/>
25
25
  </a>
26
26
  </p>
27
27
 
28
- [English](https://github.com/micro-zoe/micro-app)|简体中文|[官网文档](https://micro-zoe.github.io/micro-app/)|[讨论组](https://github.com/micro-zoe/micro-app/discussions)|[微信群](./Contact.md)
28
+ [English](https://github.com/jd-opensource/micro-app)|简体中文|[官网文档](https://jd-opensource.github.io/micro-app/)|[讨论组](https://github.com/jd-opensource/micro-app/discussions)|[微信群](./Contact.md)
29
29
 
30
30
  # 📖简介
31
31
  micro-app是京东零售推出的一款微前端框架,它基于类WebComponent进行渲染,从组件化的思维实现微前端,旨在降低上手难度、提升工作效率。它是目前接入微前端成本最低的框架,并且提供了JS沙箱、样式隔离、元素隔离、预加载、虚拟路由系统、插件系统、数据通信等一系列完善的功能。
@@ -69,7 +69,7 @@ devServer: {
69
69
 
70
70
  <img src="https://img12.360buyimg.com/imagetools/jfs/t1/196940/34/1541/38365/610a14fcE46c21374/c321b9f8fa50a8fc.png" alt="result" width='900'/>
71
71
 
72
- 更多详细配置可以查看[官网文档](https://micro-zoe.github.io/micro-app/docs.html#/zh-cn/start)
72
+ 更多详细配置可以查看[官网文档](https://jd-opensource.github.io/micro-app/docs.html#/zh-cn/start)
73
73
 
74
74
  # 🤝 参与共建
75
75
  如果您对这个项目感兴趣,欢迎参与贡献,也欢迎 "Star" 支持一下 ^_^
@@ -77,7 +77,7 @@ devServer: {
77
77
  ### 本地运行
78
78
  1、克隆项目
79
79
  ```
80
- git clone https://github.com/micro-zoe/micro-app.git
80
+ git clone https://github.com/jd-opensource/micro-app.git
81
81
  ```
82
82
 
83
83
  2、安装依赖
@@ -90,16 +90,16 @@ yarn bootstrap
90
90
  yarn start # 访问 http://localhost:3000
91
91
  ```
92
92
 
93
- 更多命令请查看[DEVELP](https://github.com/micro-zoe/micro-app/blob/master/DEVELOP.zh-cn.md)
93
+ 更多命令请查看[DEVELP](https://github.com/jd-opensource/micro-app/blob/master/DEVELOP.zh-cn.md)
94
94
 
95
95
  # FAQ
96
- [问题汇总](https://micro-zoe.github.io/micro-app/docs.html#/zh-cn/questions)
96
+ [问题汇总](https://jd-opensource.github.io/micro-app/docs.html#/zh-cn/questions)
97
97
  <details>
98
98
 
99
99
  <summary>micro-app的优势在哪里?</summary>
100
100
  上手简单、侵入性低,只需改动少量的代码即可接入微前端,同时提供丰富的功能。
101
101
 
102
- 具体细节请参考文章:[micro-app介绍](https://github.com/micro-zoe/micro-app/issues/8)
102
+ 具体细节请参考文章:[micro-app介绍](https://github.com/jd-opensource/micro-app/issues/8)
103
103
 
104
104
  </details>
105
105
  <details>
@@ -136,21 +136,21 @@ yarn start # 访问 http://localhost:3000
136
136
  <details>
137
137
  <summary>支持vite吗?</summary>
138
138
 
139
- 支持,详情请查看[适配vite](https://micro-zoe.github.io/micro-app/docs.html#/zh-cn/framework/vite)
139
+ 支持,详情请查看[适配vite](https://jd-opensource.github.io/micro-app/docs.html#/zh-cn/framework/vite)
140
140
  </details>
141
141
 
142
142
  <details>
143
143
  <summary>支持ssr吗?</summary>
144
144
 
145
- 支持,详情请查看[nextjs](https://micro-zoe.github.io/micro-app/docs.html#/zh-cn/framework/nextjs)、[nuxtjs](https://micro-zoe.github.io/micro-app/docs.html#/zh-cn/framework/nuxtjs)
145
+ 支持,详情请查看[nextjs](https://jd-opensource.github.io/micro-app/docs.html#/zh-cn/framework/nextjs)、[nuxtjs](https://jd-opensource.github.io/micro-app/docs.html#/zh-cn/framework/nuxtjs)
146
146
  </details>
147
147
 
148
148
 
149
149
  # 贡献者们
150
- <a href="https://github.com/micro-zoe/micro-app/graphs/contributors">
151
- <img src="https://contrib.rocks/image?repo=micro-zoe/micro-app" />
150
+ <a href="https://github.com/jd-opensource/micro-app/graphs/contributors">
151
+ <img src="https://contrib.rocks/image?repo=jd-opensource/micro-app" />
152
152
  </a>
153
153
 
154
154
 
155
155
  # License
156
- [MIT License](https://github.com/micro-zoe/micro-app/blob/master/LICENSE)
156
+ [MIT License](https://github.com/jd-opensource/micro-app/blob/master/LICENSE)
package/lib/index.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  // ../../@micro-app/types
5
5
 
6
6
  declare module '@micro-zoe/micro-app' {
7
- export { default, MicroApp, getActiveApps, getAllApps, unmountApp, unmountAllApps, reload, renderApp, getAppStatus } from '@micro-zoe/micro-app/micro_app';
7
+ export { default, MicroApp, getActiveApps, getAllApps, unmountApp, unmountAllApps, reload, renderApp, } from '@micro-zoe/micro-app/micro_app';
8
8
  export { default as preFetch, } from '@micro-zoe/micro-app/prefetch';
9
9
  export { removeDomScope, pureCreateElement, version, } from '@micro-zoe/micro-app/libs/utils';
10
10
  export { EventCenterForMicroApp, } from '@micro-zoe/micro-app/interact';
@@ -60,12 +60,6 @@ declare module '@micro-zoe/micro-app/micro_app' {
60
60
  * @returns Promise<boolean>
61
61
  */
62
62
  export function renderApp(options: RenderAppOptions): Promise<boolean>;
63
- /**
64
- * get app state
65
- * @param appName app.name
66
- * @returns app.state
67
- */
68
- export function getAppStatus(appName: string): string | void;
69
63
  export class MicroApp extends EventCenterForBaseApp implements MicroAppBaseType {
70
64
  tagName: string;
71
65
  hasInit: boolean;
@@ -78,7 +72,6 @@ declare module '@micro-zoe/micro-app/micro_app' {
78
72
  getAllApps: typeof getAllApps;
79
73
  reload: typeof reload;
80
74
  renderApp: typeof renderApp;
81
- getAppStatus: typeof getAppStatus;
82
75
  start(options?: OptionsType): void;
83
76
  }
84
77
  const microApp: MicroApp;
@@ -117,10 +110,10 @@ declare module '@micro-zoe/micro-app/prefetch' {
117
110
  }
118
111
 
119
112
  declare module '@micro-zoe/micro-app/libs/utils' {
120
- import { Func, LocationQueryObject, MicroLocation, AttrsType, fiberTasks, MicroAppElementTagNameMap } from '@micro-app/types';
113
+ import { Func, LocationQueryObject, MicroLocation, AttrsType, fiberTasks, MicroAppElementTagNameMap, MicroAppElementInterface } from '@micro-app/types';
121
114
  export const version = "__MICRO_APP_VERSION__";
122
115
  export const isBrowser: boolean;
123
- export const globalThis: any;
116
+ export const globalObj: any;
124
117
  export const noop: () => void;
125
118
  export const noopFalse: () => boolean;
126
119
  export const isArray: (arg: any) => arg is any[];
@@ -150,15 +143,26 @@ declare module '@micro-zoe/micro-app/libs/utils' {
150
143
  export function isURL(target: unknown): target is URL;
151
144
  export function isElement(target: unknown): target is Element;
152
145
  export function isNode(target: unknown): target is Node;
146
+ export function isCanvasElement(target: unknown): target is HTMLCanvasElement;
147
+ export function isAnchorElement(target: unknown): target is HTMLAnchorElement;
148
+ export function isAudioElement(target: unknown): target is HTMLAudioElement;
149
+ export function isVideoElement(target: unknown): target is HTMLVideoElement;
153
150
  export function isLinkElement(target: unknown): target is HTMLLinkElement;
151
+ export function isBodyElement(target: unknown): target is HTMLBodyElement;
154
152
  export function isStyleElement(target: unknown): target is HTMLStyleElement;
155
153
  export function isScriptElement(target: unknown): target is HTMLScriptElement;
156
154
  export function isIFrameElement(target: unknown): target is HTMLIFrameElement;
157
155
  export function isDivElement(target: unknown): target is HTMLDivElement;
158
156
  export function isImageElement(target: unknown): target is HTMLImageElement;
159
157
  export function isBaseElement(target: unknown): target is HTMLBaseElement;
158
+ export function isDocumentFragment(target: unknown): target is DocumentFragment;
159
+ export function isDocumentShadowRoot(target: unknown): target is DocumentFragment;
160
160
  export function isMicroAppBody(target: unknown): target is HTMLElement;
161
+ export function isMicroAppHead(target: unknown): target is HTMLElement;
162
+ export function isWebComponentElement(target: unknown): boolean;
161
163
  export function isProxyDocument(target: unknown): target is Document;
164
+ export function isTargetExtension(path: string, suffix: string): boolean;
165
+ export function includes(target: unknown[], searchElement: unknown, fromIndex?: number): boolean;
162
166
  /**
163
167
  * format error log
164
168
  * @param msg message
@@ -177,6 +181,12 @@ declare module '@micro-zoe/micro-app/libs/utils' {
177
181
  * @param args params
178
182
  */
179
183
  export function defer(fn: Func, ...args: unknown[]): void;
184
+ /**
185
+ * async execution with macro task
186
+ * @param fn callback
187
+ * @param args params
188
+ */
189
+ export function macro(fn: Func, delay?: number, ...args: unknown[]): void;
180
190
  /**
181
191
  * create URL as MicroLocation
182
192
  */
@@ -205,7 +215,9 @@ declare module '@micro-zoe/micro-app/libs/utils' {
205
215
  */
206
216
  export function formatAppName(name: string | null): string;
207
217
  /**
208
- * Get valid address, such as https://xxx/xx/xx.html to https://xxx/xx/
218
+ * Get valid address, such as
219
+ * 1. https://domain/xx/xx.html to https://domain/xx/
220
+ * 2. https://domain/xx to https://domain/xx/
209
221
  * @param url app.url
210
222
  */
211
223
  export function getEffectivePath(url: string): string;
@@ -239,28 +251,33 @@ declare module '@micro-zoe/micro-app/libs/utils' {
239
251
  */
240
252
  export function promiseRequestIdle(callback: CallableFunction): Promise<void>;
241
253
  export function setCurrentAppName(appName: string | null): void;
242
- export function throttleDeferForSetAppName(appName: string): void;
243
254
  export function getCurrentAppName(): string | null;
244
- export function removeDomScope(): void;
255
+ export function throttleDeferForSetAppName(appName: string): void;
256
+ export function setIframeCurrentAppName(appName: string | null): void;
257
+ export function getIframeCurrentAppName(): string | null;
258
+ export function throttleDeferForIframeAppName(appName: string): void;
259
+ export function getPreventSetState(): boolean;
260
+ /**
261
+ * prevent set appName
262
+ * usage:
263
+ * removeDomScope(true)
264
+ * -----> element scope point to base app <-----
265
+ * removeDomScope(false)
266
+ */
267
+ export function removeDomScope(force?: boolean): void;
245
268
  export function isSafari(): boolean;
246
269
  /**
247
270
  * Create pure elements
248
271
  */
249
272
  export function pureCreateElement<K extends keyof MicroAppElementTagNameMap>(tagName: K, options?: ElementCreationOptions): MicroAppElementTagNameMap[K];
250
- /**
251
- * clone origin elements to target
252
- * @param origin Cloned element
253
- * @param target Accept cloned elements
254
- * @param deep deep clone or transfer dom
255
- */
256
- export function cloneContainer<T extends Element | ShadowRoot, Q extends Element | ShadowRoot>(target: Q, origin: T, deep: boolean): Q;
257
273
  export function isInvalidQuerySelectorKey(key: string): boolean;
258
274
  export function isUniqueElement(key: string): boolean;
275
+ export type RootContainer = HTMLElement & MicroAppElementInterface;
259
276
  /**
260
277
  * get micro-app element
261
278
  * @param target app container
262
279
  */
263
- export function getRootContainer(target: HTMLElement | ShadowRoot): HTMLElement;
280
+ export function getRootContainer(target: HTMLElement | ShadowRoot): RootContainer;
264
281
  /**
265
282
  * trim start & end
266
283
  */
@@ -323,16 +340,13 @@ declare module '@micro-zoe/micro-app/libs/utils' {
323
340
  * @param $dom target node
324
341
  */
325
342
  export function clearDOM($dom: HTMLElement | ShadowRoot | Document): void;
326
- type BaseHTMLElementType = HTMLElement & {
327
- new (): HTMLElement;
328
- prototype: HTMLElement;
329
- };
343
+ export function instanceOf<T extends new (...args: unknown[]) => unknown>(instance: unknown, constructor: T): instance is T extends new (...args: unknown[]) => infer R ? R : boolean;
344
+ export function formatEventType(type: string, appName: string): string;
330
345
  /**
331
- * get HTMLElement from base app
332
- * @returns HTMLElement
346
+ * Is the object empty
347
+ * target maybe number, string, array ...
333
348
  */
334
- export function getBaseHTMLElement(): BaseHTMLElementType;
335
- export {};
349
+ export function isEmptyObject(target: unknown): boolean;
336
350
  }
337
351
 
338
352
  declare module '@micro-zoe/micro-app/interact' {
@@ -408,6 +422,7 @@ declare module '@micro-zoe/micro-app/interact' {
408
422
  * @param appName app.name
409
423
  */
410
424
  clearDataListener(appName: string): void;
425
+ changeEventAppName(newAppName: string, oldAppName: string): void;
411
426
  }
412
427
  export class EventCenterForMicroApp extends EventCenterForGlobal {
413
428
  appName: string;