@micro-zoe/micro-app 1.0.0-rc.23 → 1.0.0-rc.25
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/lib/index.esm.js +32 -14
- 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 +1 -1
- package/typings/global.d.ts +3 -1
package/lib/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const version = '1.0.0-rc.
|
|
1
|
+
const version = '1.0.0-rc.25';
|
|
2
2
|
// do not use isUndefined
|
|
3
3
|
const isBrowser = typeof window !== 'undefined';
|
|
4
4
|
// do not use isUndefined
|
|
@@ -919,8 +919,8 @@ class CSSParser {
|
|
|
919
919
|
* should be ==> micro-app[name=xxx] :where(.a, .b, .c) a {}
|
|
920
920
|
*/
|
|
921
921
|
const attributeValues = {};
|
|
922
|
-
const matchRes = m[0].replace(/\[([^\]=]+)(?:=([^\]]+))?\]/g, (match, p1, p2) => {
|
|
923
|
-
const mock = `__mock_${p1}Value__`;
|
|
922
|
+
const matchRes = m[0].replace(/\[([^\]=]+)(?:=([^\]]+))?\]/g, (match, p1, p2, offset) => {
|
|
923
|
+
const mock = `__mock_${p1}_${offset}Value__`;
|
|
924
924
|
attributeValues[mock] = p2;
|
|
925
925
|
return match.replace(p2, mock);
|
|
926
926
|
});
|
|
@@ -5867,11 +5867,17 @@ function patchWindowEffect$1(microAppWindow) {
|
|
|
5867
5867
|
const eventListenerMap = new Map();
|
|
5868
5868
|
const sstEventListenerMap = new Map();
|
|
5869
5869
|
function getEventTarget(type) {
|
|
5870
|
+
var _a, _b;
|
|
5870
5871
|
/**
|
|
5871
5872
|
* TODO: SCOPE_WINDOW_EVENT_OF_IFRAME的事件非常少,有可能导致问题
|
|
5872
5873
|
* 1、一些未知的需要绑定到iframe的事件被错误的绑定到原生window上
|
|
5873
5874
|
*/
|
|
5874
|
-
|
|
5875
|
+
let escapeSandboxEvent = [];
|
|
5876
|
+
if (Array.isArray((_a = microApp === null || microApp === void 0 ? void 0 : microApp.options) === null || _a === void 0 ? void 0 : _a.escapeIframeWindowEvents)) {
|
|
5877
|
+
escapeSandboxEvent = (_b = microApp === null || microApp === void 0 ? void 0 : microApp.options) === null || _b === void 0 ? void 0 : _b.escapeIframeWindowEvents;
|
|
5878
|
+
}
|
|
5879
|
+
const scopeWindowEvent = SCOPE_WINDOW_EVENT_OF_IFRAME.filter(item => !escapeSandboxEvent.includes(item));
|
|
5880
|
+
return scopeWindowEvent.includes(type) ? microAppWindow : rawWindow;
|
|
5875
5881
|
}
|
|
5876
5882
|
// TODO: listener 是否需要绑定microAppWindow,否则函数中的this指向原生window
|
|
5877
5883
|
microAppWindow.addEventListener = function (type, listener, options) {
|
|
@@ -6510,18 +6516,14 @@ function patchIframeAttribute(url, microAppWindow, appName) {
|
|
|
6510
6516
|
const microRootElement = microAppWindow.Element;
|
|
6511
6517
|
const rawMicroSetAttribute = microRootElement.prototype.setAttribute;
|
|
6512
6518
|
microRootElement.prototype.setAttribute = function setAttribute(key, value) {
|
|
6513
|
-
var _a
|
|
6519
|
+
var _a;
|
|
6514
6520
|
if (/^micro-app(-\S+)?/i.test(this.tagName) &&
|
|
6515
6521
|
key === 'data' &&
|
|
6516
6522
|
this.setAttribute !== microRootElement.prototype.setAttribute) {
|
|
6517
6523
|
this.setAttribute(key, value);
|
|
6518
6524
|
}
|
|
6519
6525
|
else {
|
|
6520
|
-
|
|
6521
|
-
if (!isArray(appPlugins)) {
|
|
6522
|
-
appPlugins = [];
|
|
6523
|
-
}
|
|
6524
|
-
const aHrefResolver = (_d = appPlugins[0]) === null || _d === void 0 ? void 0 : _d.aHrefResolver;
|
|
6526
|
+
const aHrefResolver = (_a = microApp === null || microApp === void 0 ? void 0 : microApp.options) === null || _a === void 0 ? void 0 : _a.aHrefResolver;
|
|
6525
6527
|
if (key === 'href' && /^a$/i.test(this.tagName) && typeof aHrefResolver === 'function') {
|
|
6526
6528
|
// 试验性质:a 标签开放自定义补齐功能
|
|
6527
6529
|
value = aHrefResolver(value, appName, url);
|
|
@@ -7783,6 +7785,7 @@ function isPendMethod(method) {
|
|
|
7783
7785
|
* @param newChild target node
|
|
7784
7786
|
*/
|
|
7785
7787
|
function completePathDynamic(app, newChild) {
|
|
7788
|
+
var _a;
|
|
7786
7789
|
if (isElement(newChild)) {
|
|
7787
7790
|
if (/^(img|script)$/i.test(newChild.tagName)) {
|
|
7788
7791
|
if (newChild.hasAttribute('src')) {
|
|
@@ -7795,7 +7798,16 @@ function completePathDynamic(app, newChild) {
|
|
|
7795
7798
|
else if ((/^(link|image)$/i.test(newChild.tagName) && newChild.hasAttribute('href')) ||
|
|
7796
7799
|
// If it is the anchor tag,eg. <a href="#xxx"/>, the path will not be completed
|
|
7797
7800
|
(/^(a)$/i.test(newChild.tagName) && newChild.hasAttribute('href') && !/^#/.test(newChild.getAttribute('href') || ''))) {
|
|
7798
|
-
|
|
7801
|
+
const aHrefResolver = (_a = microApp === null || microApp === void 0 ? void 0 : microApp.options) === null || _a === void 0 ? void 0 : _a.aHrefResolver;
|
|
7802
|
+
const hrefValue = newChild.getAttribute('href');
|
|
7803
|
+
let nextHrefValue;
|
|
7804
|
+
if ((/^(a)$/i.test(newChild.tagName) && typeof aHrefResolver === 'function')) {
|
|
7805
|
+
nextHrefValue = aHrefResolver(hrefValue, app.name, app.url);
|
|
7806
|
+
}
|
|
7807
|
+
else {
|
|
7808
|
+
nextHrefValue = CompletionPath(hrefValue, app.url);
|
|
7809
|
+
}
|
|
7810
|
+
globalEnv.rawSetAttribute.call(newChild, 'href', nextHrefValue);
|
|
7799
7811
|
}
|
|
7800
7812
|
}
|
|
7801
7813
|
}
|
|
@@ -7958,7 +7970,7 @@ function patchElementAndDocument() {
|
|
|
7958
7970
|
};
|
|
7959
7971
|
// rewrite setAttribute, complete resource address
|
|
7960
7972
|
rawRootElement.prototype.setAttribute = function setAttribute(key, value) {
|
|
7961
|
-
var _a;
|
|
7973
|
+
var _a, _b;
|
|
7962
7974
|
if (/^micro-app(-\S+)?/i.test(this.tagName) &&
|
|
7963
7975
|
key === 'data' &&
|
|
7964
7976
|
this.setAttribute !== rawRootElement.prototype.setAttribute) {
|
|
@@ -7973,12 +7985,18 @@ function patchElementAndDocument() {
|
|
|
7973
7985
|
// If it is the anchor tag,eg. <a href="#xxx"/>, the path will not be completed
|
|
7974
7986
|
(key === 'href' && /^(a)$/i.test(this.tagName) && !/^#/.test(value)))) {
|
|
7975
7987
|
const app = appInstanceMap.get(appName);
|
|
7976
|
-
|
|
7988
|
+
const aHrefResolver = (_a = microApp === null || microApp === void 0 ? void 0 : microApp.options) === null || _a === void 0 ? void 0 : _a.aHrefResolver;
|
|
7989
|
+
if (key === 'href' && /^a$/i.test(this.tagName) && typeof aHrefResolver === 'function') {
|
|
7990
|
+
value = aHrefResolver(value, appName, app.url);
|
|
7991
|
+
}
|
|
7992
|
+
else {
|
|
7993
|
+
value = CompletionPath(value, app.url);
|
|
7994
|
+
}
|
|
7977
7995
|
}
|
|
7978
7996
|
globalEnv.rawSetAttribute.call(this, key, value);
|
|
7979
7997
|
if (isImageElement(this) || isVideoElement(this) || isAudioElement(this)) {
|
|
7980
7998
|
let includeCrossOrigin = false;
|
|
7981
|
-
if (((
|
|
7999
|
+
if (((_b = microApp === null || microApp === void 0 ? void 0 : microApp.options) === null || _b === void 0 ? void 0 : _b.includeCrossOrigin) && isFunction(microApp.options.includeCrossOrigin)) {
|
|
7982
8000
|
includeCrossOrigin = microApp.options.includeCrossOrigin(value);
|
|
7983
8001
|
}
|
|
7984
8002
|
// @ts-ignore
|