@micro-zoe/micro-app 1.0.0-rc.2 → 1.0.0-rc.21

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
@@ -110,7 +110,7 @@ declare module '@micro-zoe/micro-app/prefetch' {
110
110
  }
111
111
 
112
112
  declare module '@micro-zoe/micro-app/libs/utils' {
113
- import { Func, LocationQueryObject, MicroLocation, AttrsType, fiberTasks, MicroAppElementTagNameMap } from '@micro-app/types';
113
+ import { Func, LocationQueryObject, MicroLocation, AttrsType, fiberTasks, MicroAppElementTagNameMap, MicroAppElementInterface } from '@micro-app/types';
114
114
  export const version = "__MICRO_APP_VERSION__";
115
115
  export const isBrowser: boolean;
116
116
  export const globalThis: any;
@@ -125,7 +125,9 @@ declare module '@micro-zoe/micro-app/libs/utils' {
125
125
  };
126
126
  export const rawDefineProperty: (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any;
127
127
  export const rawDefineProperties: (o: any, properties: PropertyDescriptorMap & ThisType<any>) => any;
128
+ export const rawToString: () => string;
128
129
  export const rawHasOwnProperty: (v: string | number | symbol) => boolean;
130
+ export const toTypeString: (value: unknown) => string;
129
131
  export function isUndefined(target: unknown): target is undefined;
130
132
  export function isNull(target: unknown): target is null;
131
133
  export function isString(target: unknown): target is string;
@@ -141,15 +143,26 @@ declare module '@micro-zoe/micro-app/libs/utils' {
141
143
  export function isURL(target: unknown): target is URL;
142
144
  export function isElement(target: unknown): target is Element;
143
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;
144
150
  export function isLinkElement(target: unknown): target is HTMLLinkElement;
151
+ export function isBodyElement(target: unknown): target is HTMLBodyElement;
145
152
  export function isStyleElement(target: unknown): target is HTMLStyleElement;
146
153
  export function isScriptElement(target: unknown): target is HTMLScriptElement;
147
154
  export function isIFrameElement(target: unknown): target is HTMLIFrameElement;
148
155
  export function isDivElement(target: unknown): target is HTMLDivElement;
149
156
  export function isImageElement(target: unknown): target is HTMLImageElement;
150
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;
151
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;
152
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;
153
166
  /**
154
167
  * format error log
155
168
  * @param msg message
@@ -168,6 +181,12 @@ declare module '@micro-zoe/micro-app/libs/utils' {
168
181
  * @param args params
169
182
  */
170
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;
171
190
  /**
172
191
  * create URL as MicroLocation
173
192
  */
@@ -196,7 +215,9 @@ declare module '@micro-zoe/micro-app/libs/utils' {
196
215
  */
197
216
  export function formatAppName(name: string | null): string;
198
217
  /**
199
- * 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/
200
221
  * @param url app.url
201
222
  */
202
223
  export function getEffectivePath(url: string): string;
@@ -230,28 +251,33 @@ declare module '@micro-zoe/micro-app/libs/utils' {
230
251
  */
231
252
  export function promiseRequestIdle(callback: CallableFunction): Promise<void>;
232
253
  export function setCurrentAppName(appName: string | null): void;
233
- export function throttleDeferForSetAppName(appName: string): void;
234
254
  export function getCurrentAppName(): string | null;
235
- 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;
236
268
  export function isSafari(): boolean;
237
269
  /**
238
270
  * Create pure elements
239
271
  */
240
272
  export function pureCreateElement<K extends keyof MicroAppElementTagNameMap>(tagName: K, options?: ElementCreationOptions): MicroAppElementTagNameMap[K];
241
- /**
242
- * clone origin elements to target
243
- * @param origin Cloned element
244
- * @param target Accept cloned elements
245
- * @param deep deep clone or transfer dom
246
- */
247
- export function cloneContainer<T extends Element | ShadowRoot, Q extends Element | ShadowRoot>(target: Q, origin: T, deep: boolean): Q;
248
273
  export function isInvalidQuerySelectorKey(key: string): boolean;
249
274
  export function isUniqueElement(key: string): boolean;
275
+ export type RootContainer = HTMLElement & MicroAppElementInterface;
250
276
  /**
251
277
  * get micro-app element
252
278
  * @param target app container
253
279
  */
254
- export function getRootContainer(target: HTMLElement | ShadowRoot): HTMLElement;
280
+ export function getRootContainer(target: HTMLElement | ShadowRoot): RootContainer;
255
281
  /**
256
282
  * trim start & end
257
283
  */
@@ -314,16 +340,13 @@ declare module '@micro-zoe/micro-app/libs/utils' {
314
340
  * @param $dom target node
315
341
  */
316
342
  export function clearDOM($dom: HTMLElement | ShadowRoot | Document): void;
317
- type BaseHTMLElementType = HTMLElement & {
318
- new (): HTMLElement;
319
- prototype: HTMLElement;
320
- };
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;
321
345
  /**
322
- * get HTMLElement from base app
323
- * @returns HTMLElement
346
+ * Is the object empty
347
+ * target maybe number, string, array ...
324
348
  */
325
- export function getBaseHTMLElement(): BaseHTMLElementType;
326
- export {};
349
+ export function isEmptyObject(target: unknown): boolean;
327
350
  }
328
351
 
329
352
  declare module '@micro-zoe/micro-app/interact' {