@micro-zoe/micro-app 1.0.0-rc.17 → 1.0.0-rc.19
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 +17 -17
- package/README.zh-cn.md +18 -18
- package/lib/index.esm.js +39 -26
- package/lib/index.esm.js.map +1 -1
- package/lib/index.min.js +1 -1
- package/lib/index.min.js.map +1 -1
- package/lib/index.umd.js +1 -1
- package/lib/index.umd.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<a href="https://
|
|
3
|
-
<img src="https://
|
|
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/
|
|
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/
|
|
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/
|
|
21
|
-
<img src="https://api.travis-ci.com/
|
|
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/
|
|
24
|
-
<img src="https://coveralls.io/repos/github/
|
|
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://
|
|
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
|

|
|
74
74
|
|
|
75
|
-
More detailed configuration can be viewed [Documentation](https://
|
|
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/
|
|
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/
|
|
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://
|
|
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://
|
|
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/
|
|
152
|
-
<img src="https://contrib.rocks/image?repo=
|
|
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/
|
|
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://
|
|
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/
|
|
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/
|
|
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/
|
|
21
|
-
<img src="https://api.travis-ci.com/
|
|
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/
|
|
24
|
-
<img src="https://coveralls.io/repos/github/
|
|
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/
|
|
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://
|
|
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/
|
|
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/
|
|
93
|
+
更多命令请查看[DEVELP](https://github.com/jd-opensource/micro-app/blob/master/DEVELOP.zh-cn.md)
|
|
94
94
|
|
|
95
95
|
# FAQ
|
|
96
|
-
[问题汇总](https://
|
|
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/
|
|
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://
|
|
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://
|
|
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/
|
|
151
|
-
<img src="https://contrib.rocks/image?repo=
|
|
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/
|
|
156
|
+
[MIT License](https://github.com/jd-opensource/micro-app/blob/master/LICENSE)
|
package/lib/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const version = '1.0.0-rc.
|
|
1
|
+
const version = '1.0.0-rc.19';
|
|
2
2
|
// do not use isUndefined
|
|
3
3
|
const isBrowser = typeof window !== 'undefined';
|
|
4
4
|
// do not use isUndefined
|
|
@@ -245,7 +245,7 @@ function formatAppURL(url, appName = null) {
|
|
|
245
245
|
const { origin, pathname, search } = createURL(addProtocol(url), (window.rawWindow || window).location.href);
|
|
246
246
|
/**
|
|
247
247
|
* keep the original url unchanged, such as .html .node .php .net .etc, search, except hash
|
|
248
|
-
* BUG FIX: Never using '/' to complete url, refer to https://github.com/
|
|
248
|
+
* BUG FIX: Never using '/' to complete url, refer to https://github.com/jd-opensource/micro-app/issues/1147
|
|
249
249
|
*/
|
|
250
250
|
const fullPath = `${origin}${pathname}${search}`;
|
|
251
251
|
return /^https?:\/\//.test(fullPath) ? fullPath : '';
|
|
@@ -648,7 +648,7 @@ function instanceOf(instance, constructor) {
|
|
|
648
648
|
/**
|
|
649
649
|
* Format event name
|
|
650
650
|
* In with sandbox, child event and lifeCycles bind to microAppElement, there are two events with same name - mounted unmount, it should be handled specifically to prevent conflicts
|
|
651
|
-
* Issue: https://github.com/
|
|
651
|
+
* Issue: https://github.com/jd-opensource/micro-app/issues/1161
|
|
652
652
|
* @param type event name
|
|
653
653
|
* @param appName app name
|
|
654
654
|
*/
|
|
@@ -919,7 +919,7 @@ class CSSParser {
|
|
|
919
919
|
});
|
|
920
920
|
return matchRes.replace(/(^|,[\n\s]*)([^,]+)/g, (_, separator, selector) => {
|
|
921
921
|
selector = trim(selector);
|
|
922
|
-
selector = selector.replace(/\[
|
|
922
|
+
selector = selector.replace(/\[[^\]=]+(?:=([^\]]+))?\]/g, (match, p1) => {
|
|
923
923
|
if (attributeValues[p1]) {
|
|
924
924
|
return match.replace(p1, attributeValues[p1]);
|
|
925
925
|
}
|
|
@@ -1186,7 +1186,7 @@ class CSSParser {
|
|
|
1186
1186
|
}
|
|
1187
1187
|
// splice string
|
|
1188
1188
|
recordResult(strFragment) {
|
|
1189
|
-
// Firefox performance degradation when string contain special characters, see https://github.com/
|
|
1189
|
+
// Firefox performance degradation when string contain special characters, see https://github.com/jd-opensource/micro-app/issues/256
|
|
1190
1190
|
if (isFireFox()) {
|
|
1191
1191
|
this.result += encodeURIComponent(strFragment);
|
|
1192
1192
|
}
|
|
@@ -1232,6 +1232,15 @@ function scopedCSS(styleElement, app, linkPath) {
|
|
|
1232
1232
|
parser = new CSSParser();
|
|
1233
1233
|
if (styleElement.textContent) {
|
|
1234
1234
|
commonAction(styleElement, app.name, prefix, app.url, linkPath);
|
|
1235
|
+
const observer = new MutationObserver(() => {
|
|
1236
|
+
const isPrefixed = styleElement.textContent && new RegExp(prefix).test(styleElement.textContent);
|
|
1237
|
+
observer.disconnect();
|
|
1238
|
+
if (!isPrefixed) {
|
|
1239
|
+
styleElement.__MICRO_APP_HAS_SCOPED__ = false;
|
|
1240
|
+
}
|
|
1241
|
+
scopedCSS(styleElement, app, linkPath);
|
|
1242
|
+
});
|
|
1243
|
+
observer.observe(styleElement, { childList: true, characterData: true });
|
|
1235
1244
|
}
|
|
1236
1245
|
else {
|
|
1237
1246
|
const observer = new MutationObserver(function () {
|
|
@@ -2216,7 +2225,7 @@ function runCode2InlineScript(address, code, module, scriptElement, attrs, callb
|
|
|
2216
2225
|
if (isInlineScript(address)) {
|
|
2217
2226
|
/**
|
|
2218
2227
|
* inline module script cannot convert to blob mode
|
|
2219
|
-
* Issue: https://github.com/
|
|
2228
|
+
* Issue: https://github.com/jd-opensource/micro-app/issues/805
|
|
2220
2229
|
*/
|
|
2221
2230
|
scriptElement.textContent = code;
|
|
2222
2231
|
}
|
|
@@ -2960,7 +2969,7 @@ function fixBabelPolyfill6() {
|
|
|
2960
2969
|
}
|
|
2961
2970
|
/**
|
|
2962
2971
|
* Fix error of hot reload when parent&child created by create-react-app in development environment
|
|
2963
|
-
* Issue: https://github.com/
|
|
2972
|
+
* Issue: https://github.com/jd-opensource/micro-app/issues/382
|
|
2964
2973
|
*/
|
|
2965
2974
|
function fixReactHMRConflict(app) {
|
|
2966
2975
|
var _a;
|
|
@@ -3458,7 +3467,7 @@ function createProxyWindow(appName, microAppWindow, sandbox) {
|
|
|
3458
3467
|
* Some keywords, such as Vue, need to meet two conditions at the same time:
|
|
3459
3468
|
* 1. window.Vue --> undefined
|
|
3460
3469
|
* 2. 'Vue' in window --> false
|
|
3461
|
-
* Issue https://github.com/
|
|
3470
|
+
* Issue https://github.com/jd-opensource/micro-app/issues/686
|
|
3462
3471
|
*/
|
|
3463
3472
|
if (includes(sandbox.scopeProperties, key)) {
|
|
3464
3473
|
if (sandbox.injectedKeys.has(key)) {
|
|
@@ -5506,7 +5515,7 @@ const UN_PROXY_INSTANCEOF_KEYS = [
|
|
|
5506
5515
|
];
|
|
5507
5516
|
const escape2RawWindowKeys = [
|
|
5508
5517
|
'getComputedStyle',
|
|
5509
|
-
// FIX ISSUE: https://github.com/
|
|
5518
|
+
// FIX ISSUE: https://github.com/jd-opensource/micro-app/issues/1292
|
|
5510
5519
|
'DOMParser',
|
|
5511
5520
|
'visualViewport',
|
|
5512
5521
|
'matchMedia',
|
|
@@ -6001,7 +6010,7 @@ function patchDocumentPrototype(appName, microAppWindow) {
|
|
|
6001
6010
|
* const baseEl = document.querySelector('base')
|
|
6002
6011
|
* base = (baseEl && baseEl.getAttribute('href')) || '/'
|
|
6003
6012
|
*
|
|
6004
|
-
* Issue: https://github.com/
|
|
6013
|
+
* Issue: https://github.com/jd-opensource/micro-app/issues/1335
|
|
6005
6014
|
*/
|
|
6006
6015
|
const result = (_a = appInstanceMap.get(appName)) === null || _a === void 0 ? void 0 : _a.querySelector(selectors);
|
|
6007
6016
|
return result || selectors === 'base' ? result : rawMicroQuerySelector.call(microDocument, selectors);
|
|
@@ -6516,7 +6525,7 @@ function patchIframeAttribute(url, microAppWindow) {
|
|
|
6516
6525
|
}
|
|
6517
6526
|
|
|
6518
6527
|
class IframeSandbox {
|
|
6519
|
-
constructor(appName, url) {
|
|
6528
|
+
constructor(appName, url, options) {
|
|
6520
6529
|
this.active = false;
|
|
6521
6530
|
// Properties that can be escape to rawWindow
|
|
6522
6531
|
this.escapeProperties = [];
|
|
@@ -6528,9 +6537,10 @@ class IframeSandbox {
|
|
|
6528
6537
|
};
|
|
6529
6538
|
this.appName = appName;
|
|
6530
6539
|
this.url = url;
|
|
6540
|
+
this.options = options;
|
|
6531
6541
|
const rawLocation = globalEnv.rawWindow.location;
|
|
6532
6542
|
const browserHost = rawLocation.protocol + '//' + rawLocation.host;
|
|
6533
|
-
this.deleteIframeElement = this.createIframeElement(appName, browserHost + rawLocation.pathname);
|
|
6543
|
+
this.deleteIframeElement = this.createIframeElement(appName, browserHost + rawLocation.pathname, options);
|
|
6534
6544
|
this.microAppWindow = this.iframe.contentWindow;
|
|
6535
6545
|
this.patchIframe(this.microAppWindow, (resolve) => {
|
|
6536
6546
|
// create new html to iframe
|
|
@@ -6561,14 +6571,9 @@ class IframeSandbox {
|
|
|
6561
6571
|
* @param browserPath browser origin
|
|
6562
6572
|
* @returns release callback
|
|
6563
6573
|
*/
|
|
6564
|
-
createIframeElement(appName, browserPath) {
|
|
6574
|
+
createIframeElement(appName, browserPath, options) {
|
|
6565
6575
|
this.iframe = pureCreateElement('iframe');
|
|
6566
|
-
const iframeAttrs = {
|
|
6567
|
-
id: appName,
|
|
6568
|
-
src: microApp.options.iframeSrc || browserPath,
|
|
6569
|
-
style: 'display: none',
|
|
6570
|
-
'powered-by': 'micro-app',
|
|
6571
|
-
};
|
|
6576
|
+
const iframeAttrs = Object.assign(Object.assign({}, options === null || options === void 0 ? void 0 : options.attrs), { id: appName, src: microApp.options.iframeSrc || browserPath, style: 'display: none', 'powered-by': 'micro-app' });
|
|
6572
6577
|
Object.keys(iframeAttrs).forEach((key) => this.iframe.setAttribute(key, iframeAttrs[key]));
|
|
6573
6578
|
// effect action during construct
|
|
6574
6579
|
globalEnv.rawDocument.body.appendChild(this.iframe);
|
|
@@ -6907,7 +6912,7 @@ IframeSandbox.activeCount = 0; // number of active sandbox
|
|
|
6907
6912
|
// micro app instances
|
|
6908
6913
|
const appInstanceMap = new Map();
|
|
6909
6914
|
class CreateApp {
|
|
6910
|
-
constructor({ name, url, container, scopecss, useSandbox, inline, iframe, ssrUrl, isPrefetch, prefetchLevel, routerMode, }) {
|
|
6915
|
+
constructor({ name, url, container, scopecss, useSandbox, inline, iframe, ssrUrl, isPrefetch, prefetchLevel, routerMode, attrs, }) {
|
|
6911
6916
|
this.state = appStates.CREATED;
|
|
6912
6917
|
this.keepAliveState = null;
|
|
6913
6918
|
this.loadSourceLevel = 0;
|
|
@@ -6923,6 +6928,7 @@ class CreateApp {
|
|
|
6923
6928
|
this.url = url;
|
|
6924
6929
|
this.useSandbox = useSandbox;
|
|
6925
6930
|
this.scopecss = this.useSandbox && scopecss;
|
|
6931
|
+
this.attrs = attrs;
|
|
6926
6932
|
// exec before getInlineModeState
|
|
6927
6933
|
this.iframe = iframe !== null && iframe !== void 0 ? iframe : false;
|
|
6928
6934
|
this.inline = this.getInlineModeState(inline);
|
|
@@ -7382,7 +7388,7 @@ class CreateApp {
|
|
|
7382
7388
|
/**
|
|
7383
7389
|
* NOTE:
|
|
7384
7390
|
* 1. this.container must set to container(micro-app element) before exec rebuildEffectSnapshot
|
|
7385
|
-
* ISSUE: https://github.com/
|
|
7391
|
+
* ISSUE: https://github.com/jd-opensource/micro-app/issues/1115
|
|
7386
7392
|
* 2. rebuildEffectSnapshot must exec before dispatch beforeshow event
|
|
7387
7393
|
*/
|
|
7388
7394
|
const oldContainer = this.container;
|
|
@@ -7459,7 +7465,7 @@ class CreateApp {
|
|
|
7459
7465
|
*/
|
|
7460
7466
|
createSandbox() {
|
|
7461
7467
|
if (this.useSandbox && !this.sandBox) {
|
|
7462
|
-
this.sandBox = this.iframe ? new IframeSandbox(this.name, this.url) : new WithSandBox(this.name, this.url);
|
|
7468
|
+
this.sandBox = this.iframe ? new IframeSandbox(this.name, this.url, { attrs: this.attrs }) : new WithSandBox(this.name, this.url);
|
|
7463
7469
|
}
|
|
7464
7470
|
}
|
|
7465
7471
|
// set app state
|
|
@@ -7609,7 +7615,7 @@ function invokePrototypeMethod(app, rawMethod, parent, targetNode, passiveNode)
|
|
|
7609
7615
|
* 1. When operate child from parentNode async, may have been unmount
|
|
7610
7616
|
* e.g. target.parentNode.remove(target)
|
|
7611
7617
|
* ISSUE:
|
|
7612
|
-
* 1. https://github.com/
|
|
7618
|
+
* 1. https://github.com/jd-opensource/micro-app/issues/739
|
|
7613
7619
|
* Solution: Return the true value when node not in document
|
|
7614
7620
|
*/
|
|
7615
7621
|
if (!isIframeSandbox(app.name) &&
|
|
@@ -7650,7 +7656,7 @@ function invokePrototypeMethod(app, rawMethod, parent, targetNode, passiveNode)
|
|
|
7650
7656
|
* E.g: document.head.replaceChild(targetNode, document.scripts[0])
|
|
7651
7657
|
* 2. If passiveNode not in hijackParent but in parent and method is insertBefore, try insert it into the position corresponding to hijackParent
|
|
7652
7658
|
* E.g: document.head.insertBefore(targetNode, document.head.childNodes[0])
|
|
7653
|
-
* ISSUE: https://github.com/
|
|
7659
|
+
* ISSUE: https://github.com/jd-opensource/micro-app/issues/1071
|
|
7654
7660
|
*/
|
|
7655
7661
|
if (passiveNode && !hijackParent.contains(passiveNode)) {
|
|
7656
7662
|
if (rawMethod === globalEnv.rawInsertBefore && parent.contains(passiveNode)) {
|
|
@@ -8063,7 +8069,7 @@ function patchDocument$2() {
|
|
|
8063
8069
|
if (!currentAppName ||
|
|
8064
8070
|
!selectors ||
|
|
8065
8071
|
isUniqueElement(selectors) ||
|
|
8066
|
-
// ISSUE: https://github.com/
|
|
8072
|
+
// ISSUE: https://github.com/jd-opensource/micro-app/issues/56
|
|
8067
8073
|
rawDocument !== _this) {
|
|
8068
8074
|
return globalEnv.rawQuerySelector.call(_this, selectors);
|
|
8069
8075
|
}
|
|
@@ -8586,6 +8592,12 @@ function defineElement(tagName) {
|
|
|
8586
8592
|
}
|
|
8587
8593
|
// create app instance
|
|
8588
8594
|
handleCreateApp() {
|
|
8595
|
+
const attrs = {};
|
|
8596
|
+
Array.prototype.slice.call(this.attributes).forEach(({ name, value }) => {
|
|
8597
|
+
if (name.startsWith('data-')) {
|
|
8598
|
+
attrs[name] = value;
|
|
8599
|
+
}
|
|
8600
|
+
});
|
|
8589
8601
|
const createAppInstance = () => {
|
|
8590
8602
|
var _a;
|
|
8591
8603
|
return new CreateApp({
|
|
@@ -8598,6 +8610,7 @@ function defineElement(tagName) {
|
|
|
8598
8610
|
iframe: this.getDisposeResult('iframe'),
|
|
8599
8611
|
ssrUrl: this.ssrUrl,
|
|
8600
8612
|
routerMode: this.getMemoryRouterMode(),
|
|
8613
|
+
attrs
|
|
8601
8614
|
});
|
|
8602
8615
|
};
|
|
8603
8616
|
/**
|
|
@@ -8632,7 +8645,7 @@ function defineElement(tagName) {
|
|
|
8632
8645
|
app.isPrefetch = false;
|
|
8633
8646
|
/**
|
|
8634
8647
|
* Fix error when navigate before app.mount by microApp.router.push(...)
|
|
8635
|
-
* Issue: https://github.com/
|
|
8648
|
+
* Issue: https://github.com/jd-opensource/micro-app/issues/908
|
|
8636
8649
|
*/
|
|
8637
8650
|
app.setAppState(appStates.BEFORE_MOUNT);
|
|
8638
8651
|
// exec mount async, simulate the first render scene
|