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

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,6 +143,10 @@ 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;
145
151
  export function isStyleElement(target: unknown): target is HTMLStyleElement;
146
152
  export function isScriptElement(target: unknown): target is HTMLScriptElement;
@@ -148,8 +154,14 @@ declare module '@micro-zoe/micro-app/libs/utils' {
148
154
  export function isDivElement(target: unknown): target is HTMLDivElement;
149
155
  export function isImageElement(target: unknown): target is HTMLImageElement;
150
156
  export function isBaseElement(target: unknown): target is HTMLBaseElement;
157
+ export function isDocumentFragment(target: unknown): target is DocumentFragment;
158
+ export function isDocumentShadowRoot(target: unknown): target is DocumentFragment;
151
159
  export function isMicroAppBody(target: unknown): target is HTMLElement;
160
+ export function isMicroAppHead(target: unknown): target is HTMLElement;
161
+ export function isWebComponentElement(target: unknown): boolean;
152
162
  export function isProxyDocument(target: unknown): target is Document;
163
+ export function isTargetExtension(path: string, suffix: string): boolean;
164
+ export function includes(target: unknown[], searchElement: unknown, fromIndex?: number): boolean;
153
165
  /**
154
166
  * format error log
155
167
  * @param msg message
@@ -168,6 +180,12 @@ declare module '@micro-zoe/micro-app/libs/utils' {
168
180
  * @param args params
169
181
  */
170
182
  export function defer(fn: Func, ...args: unknown[]): void;
183
+ /**
184
+ * async execution with macro task
185
+ * @param fn callback
186
+ * @param args params
187
+ */
188
+ export function macro(fn: Func, delay?: number, ...args: unknown[]): void;
171
189
  /**
172
190
  * create URL as MicroLocation
173
191
  */
@@ -196,7 +214,9 @@ declare module '@micro-zoe/micro-app/libs/utils' {
196
214
  */
197
215
  export function formatAppName(name: string | null): string;
198
216
  /**
199
- * Get valid address, such as https://xxx/xx/xx.html to https://xxx/xx/
217
+ * Get valid address, such as
218
+ * 1. https://domain/xx/xx.html to https://domain/xx/
219
+ * 2. https://domain/xx to https://domain/xx/
200
220
  * @param url app.url
201
221
  */
202
222
  export function getEffectivePath(url: string): string;
@@ -230,28 +250,33 @@ declare module '@micro-zoe/micro-app/libs/utils' {
230
250
  */
231
251
  export function promiseRequestIdle(callback: CallableFunction): Promise<void>;
232
252
  export function setCurrentAppName(appName: string | null): void;
233
- export function throttleDeferForSetAppName(appName: string): void;
234
253
  export function getCurrentAppName(): string | null;
235
- export function removeDomScope(): void;
254
+ export function throttleDeferForSetAppName(appName: string): void;
255
+ export function setIframeCurrentAppName(appName: string | null): void;
256
+ export function getIframeCurrentAppName(): string | null;
257
+ export function throttleDeferForIframeAppName(appName: string): void;
258
+ export function getPreventSetState(): boolean;
259
+ /**
260
+ * prevent set appName
261
+ * usage:
262
+ * removeDomScope(true)
263
+ * -----> element scope point to base app <-----
264
+ * removeDomScope(false)
265
+ */
266
+ export function removeDomScope(force?: boolean): void;
236
267
  export function isSafari(): boolean;
237
268
  /**
238
269
  * Create pure elements
239
270
  */
240
271
  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
272
  export function isInvalidQuerySelectorKey(key: string): boolean;
249
273
  export function isUniqueElement(key: string): boolean;
274
+ export type RootContainer = HTMLElement & MicroAppElementInterface;
250
275
  /**
251
276
  * get micro-app element
252
277
  * @param target app container
253
278
  */
254
- export function getRootContainer(target: HTMLElement | ShadowRoot): HTMLElement;
279
+ export function getRootContainer(target: HTMLElement | ShadowRoot): RootContainer;
255
280
  /**
256
281
  * trim start & end
257
282
  */
@@ -314,16 +339,13 @@ declare module '@micro-zoe/micro-app/libs/utils' {
314
339
  * @param $dom target node
315
340
  */
316
341
  export function clearDOM($dom: HTMLElement | ShadowRoot | Document): void;
317
- type BaseHTMLElementType = HTMLElement & {
318
- new (): HTMLElement;
319
- prototype: HTMLElement;
320
- };
342
+ export function instanceOf<T extends new (...args: unknown[]) => unknown>(instance: unknown, constructor: T): instance is T extends new (...args: unknown[]) => infer R ? R : boolean;
343
+ export function formatEventType(type: string, appName: string): string;
321
344
  /**
322
- * get HTMLElement from base app
323
- * @returns HTMLElement
345
+ * Is the object empty
346
+ * target maybe number, string, array ...
324
347
  */
325
- export function getBaseHTMLElement(): BaseHTMLElementType;
326
- export {};
348
+ export function isEmptyObject(target: unknown): boolean;
327
349
  }
328
350
 
329
351
  declare module '@micro-zoe/micro-app/interact' {