@micro-zoe/micro-app 1.0.0-rc.25 → 1.0.0-rc.27
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 +40 -19
- 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 +2 -0
package/lib/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const version = '1.0.0-rc.
|
|
1
|
+
const version = '1.0.0-rc.27';
|
|
2
2
|
// do not use isUndefined
|
|
3
3
|
const isBrowser = typeof window !== 'undefined';
|
|
4
4
|
// do not use isUndefined
|
|
@@ -3118,7 +3118,7 @@ function getIframeParentNodeDesc(appName, parentNodeDesc) {
|
|
|
3118
3118
|
configurable: true,
|
|
3119
3119
|
enumerable: true,
|
|
3120
3120
|
get() {
|
|
3121
|
-
var _a, _b, _c, _d;
|
|
3121
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
3122
3122
|
throttleDeferForIframeAppName(appName);
|
|
3123
3123
|
const result = (_a = parentNodeDesc.get) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
3124
3124
|
/**
|
|
@@ -3133,7 +3133,14 @@ function getIframeParentNodeDesc(appName, parentNodeDesc) {
|
|
|
3133
3133
|
* e.g. target.parentNode.remove(target)
|
|
3134
3134
|
*/
|
|
3135
3135
|
if (isMicroAppBody(result) && ((_b = appInstanceMap.get(appName)) === null || _b === void 0 ? void 0 : _b.container)) {
|
|
3136
|
-
|
|
3136
|
+
const customParent = (_d = (_c = microApp.options).getRootElementParentNode) === null || _d === void 0 ? void 0 : _d.call(_c, this, appName);
|
|
3137
|
+
if (customParent) {
|
|
3138
|
+
return customParent;
|
|
3139
|
+
}
|
|
3140
|
+
if (((_e = microApp === null || microApp === void 0 ? void 0 : microApp.options) === null || _e === void 0 ? void 0 : _e.inheritBaseBody) !== true) {
|
|
3141
|
+
return ((_g = (_f = appInstanceMap.get(appName)) === null || _f === void 0 ? void 0 : _f.container) === null || _g === void 0 ? void 0 : _g.querySelector('micro-app-body')) || globalEnv.rawDocument.body;
|
|
3142
|
+
}
|
|
3143
|
+
return globalEnv.rawDocument.body;
|
|
3137
3144
|
}
|
|
3138
3145
|
return result;
|
|
3139
3146
|
}
|
|
@@ -4976,7 +4983,7 @@ function createMicroXMLHttpRequest(url, target) {
|
|
|
4976
4983
|
const rawXMLHttpRequest = !isUndefined(target) ? target : globalEnv.rawWindow.XMLHttpRequest;
|
|
4977
4984
|
if (!isConstructor(rawXMLHttpRequest))
|
|
4978
4985
|
return rawXMLHttpRequest;
|
|
4979
|
-
|
|
4986
|
+
class MicroXMLHttpRequest extends rawXMLHttpRequest {
|
|
4980
4987
|
open(method, reqUrl, ...rests) {
|
|
4981
4988
|
if ((isString(reqUrl) && !/^f(ile|tp):\/\//.test(reqUrl)) || isURL(reqUrl)) {
|
|
4982
4989
|
reqUrl = createURL(reqUrl, url).toString();
|
|
@@ -4984,7 +4991,10 @@ function createMicroXMLHttpRequest(url, target) {
|
|
|
4984
4991
|
removeDomScope();
|
|
4985
4992
|
super.open(method, reqUrl, ...rests);
|
|
4986
4993
|
}
|
|
4987
|
-
}
|
|
4994
|
+
}
|
|
4995
|
+
// The methods defined by class are hung on the prototype, and enumerable is false by default
|
|
4996
|
+
MicroXMLHttpRequest.prototype && Object.defineProperty(MicroXMLHttpRequest.prototype, 'open', { enumerable: true });
|
|
4997
|
+
return MicroXMLHttpRequest;
|
|
4988
4998
|
}
|
|
4989
4999
|
function useMicroEventSource() {
|
|
4990
5000
|
let eventSourceMap;
|
|
@@ -5715,6 +5725,7 @@ function patchWindowProperty$1(appName, microAppWindow, sandbox) {
|
|
|
5715
5725
|
});
|
|
5716
5726
|
Object.getOwnPropertyNames(microAppWindow)
|
|
5717
5727
|
.filter((key) => {
|
|
5728
|
+
var _a;
|
|
5718
5729
|
escape2RawWindowRegExpKeys.some((reg) => {
|
|
5719
5730
|
if (reg.test(key) && key in microAppWindow.parent) {
|
|
5720
5731
|
if (isFunction(rawWindow[key])) {
|
|
@@ -5748,7 +5759,10 @@ function patchWindowProperty$1(appName, microAppWindow, sandbox) {
|
|
|
5748
5759
|
* 4. native url instanceof iframe window.URL
|
|
5749
5760
|
* ...
|
|
5750
5761
|
*/
|
|
5751
|
-
if (isConstructor(microAppWindow[key]) &&
|
|
5762
|
+
if (isConstructor(microAppWindow[key]) &&
|
|
5763
|
+
key in rawWindow &&
|
|
5764
|
+
!UN_PROXY_INSTANCEOF_KEYS.includes(key) &&
|
|
5765
|
+
!((_a = microApp.options.excludeRewriteIframeConstructor) === null || _a === void 0 ? void 0 : _a.includes(key))) {
|
|
5752
5766
|
rawDefineProperty(microAppWindow[key], Symbol.hasInstance, {
|
|
5753
5767
|
configurable: true,
|
|
5754
5768
|
enumerable: false,
|
|
@@ -5867,14 +5881,14 @@ function patchWindowEffect$1(microAppWindow) {
|
|
|
5867
5881
|
const eventListenerMap = new Map();
|
|
5868
5882
|
const sstEventListenerMap = new Map();
|
|
5869
5883
|
function getEventTarget(type) {
|
|
5870
|
-
var _a
|
|
5884
|
+
var _a;
|
|
5871
5885
|
/**
|
|
5872
5886
|
* TODO: SCOPE_WINDOW_EVENT_OF_IFRAME的事件非常少,有可能导致问题
|
|
5873
5887
|
* 1、一些未知的需要绑定到iframe的事件被错误的绑定到原生window上
|
|
5874
5888
|
*/
|
|
5875
5889
|
let escapeSandboxEvent = [];
|
|
5876
5890
|
if (Array.isArray((_a = microApp === null || microApp === void 0 ? void 0 : microApp.options) === null || _a === void 0 ? void 0 : _a.escapeIframeWindowEvents)) {
|
|
5877
|
-
escapeSandboxEvent =
|
|
5891
|
+
escapeSandboxEvent = microApp.options.escapeIframeWindowEvents;
|
|
5878
5892
|
}
|
|
5879
5893
|
const scopeWindowEvent = SCOPE_WINDOW_EVENT_OF_IFRAME.filter(item => !escapeSandboxEvent.includes(item));
|
|
5880
5894
|
return scopeWindowEvent.includes(type) ? microAppWindow : rawWindow;
|
|
@@ -5968,6 +5982,13 @@ function patchDocument$1(appName, microAppWindow, sandbox) {
|
|
|
5968
5982
|
patchDocumentProperty(appName, microAppWindow, sandbox);
|
|
5969
5983
|
return patchDocumentEffect(appName, microAppWindow);
|
|
5970
5984
|
}
|
|
5985
|
+
function getElementDocument(microDocument, rawDocument) {
|
|
5986
|
+
var _a;
|
|
5987
|
+
if ((_a = microApp === null || microApp === void 0 ? void 0 : microApp.options) === null || _a === void 0 ? void 0 : _a.disableIframeRootDocument) {
|
|
5988
|
+
return rawDocument;
|
|
5989
|
+
}
|
|
5990
|
+
return microDocument;
|
|
5991
|
+
}
|
|
5971
5992
|
function patchDocumentPrototype(appName, microAppWindow) {
|
|
5972
5993
|
const rawDocument = globalEnv.rawDocument;
|
|
5973
5994
|
const microRootDocument = microAppWindow.Document;
|
|
@@ -5993,26 +6014,26 @@ function patchDocumentPrototype(appName, microAppWindow) {
|
|
|
5993
6014
|
return range;
|
|
5994
6015
|
};
|
|
5995
6016
|
microRootDocument.prototype.createElement = function createElement(tagName, options) {
|
|
5996
|
-
let element = rawMicroCreateElement.call(this, tagName, options);
|
|
6017
|
+
let element = rawMicroCreateElement.call(getElementDocument(this, rawDocument), tagName, options);
|
|
5997
6018
|
if (isWebComponentElement(element)) {
|
|
5998
6019
|
element = rawMicroCreateElement.call(rawDocument, tagName, options);
|
|
5999
6020
|
}
|
|
6000
6021
|
return updateElementInfo(element, appName);
|
|
6001
6022
|
};
|
|
6002
6023
|
microRootDocument.prototype.createElementNS = function createElementNS(namespaceURI, name, options) {
|
|
6003
|
-
const element = rawMicroCreateElementNS.call(this, namespaceURI, name, options);
|
|
6024
|
+
const element = rawMicroCreateElementNS.call(getElementDocument(this, rawDocument), namespaceURI, name, options);
|
|
6004
6025
|
return updateElementInfo(element, appName);
|
|
6005
6026
|
};
|
|
6006
6027
|
microRootDocument.prototype.createTextNode = function createTextNode(data) {
|
|
6007
|
-
const element = rawMicroCreateTextNode.call(this, data);
|
|
6028
|
+
const element = rawMicroCreateTextNode.call(getElementDocument(this, rawDocument), data);
|
|
6008
6029
|
return updateElementInfo(element, appName);
|
|
6009
6030
|
};
|
|
6010
6031
|
microRootDocument.prototype.createDocumentFragment = function createDocumentFragment() {
|
|
6011
|
-
const element = rawMicroCreateDocumentFragment.call(this);
|
|
6032
|
+
const element = rawMicroCreateDocumentFragment.call(getElementDocument(this, rawDocument));
|
|
6012
6033
|
return updateElementInfo(element, appName);
|
|
6013
6034
|
};
|
|
6014
6035
|
microRootDocument.prototype.createComment = function createComment(data) {
|
|
6015
|
-
const element = rawMicroCreateComment.call(this, data);
|
|
6036
|
+
const element = rawMicroCreateComment.call(getElementDocument(this, rawDocument), data);
|
|
6016
6037
|
return updateElementInfo(element, appName);
|
|
6017
6038
|
};
|
|
6018
6039
|
function getBindTarget(target) {
|
|
@@ -6071,7 +6092,7 @@ function patchDocumentPrototype(appName, microAppWindow) {
|
|
|
6071
6092
|
return rawMicroGetElementById.call(_this, key);
|
|
6072
6093
|
}
|
|
6073
6094
|
try {
|
|
6074
|
-
return querySelector.call(this, `#${key}`);
|
|
6095
|
+
return querySelector.call(getElementDocument(this, rawDocument), `#${key}`);
|
|
6075
6096
|
}
|
|
6076
6097
|
catch (_a) {
|
|
6077
6098
|
return rawMicroGetElementById.call(_this, key);
|
|
@@ -6083,14 +6104,14 @@ function patchDocumentPrototype(appName, microAppWindow) {
|
|
|
6083
6104
|
return rawMicroGetElementsByClassName.call(_this, key);
|
|
6084
6105
|
}
|
|
6085
6106
|
try {
|
|
6086
|
-
return querySelectorAll.call(this, `.${key}`);
|
|
6107
|
+
return querySelectorAll.call(getElementDocument(this, rawDocument), `.${key}`);
|
|
6087
6108
|
}
|
|
6088
6109
|
catch (_a) {
|
|
6089
6110
|
return rawMicroGetElementsByClassName.call(_this, key);
|
|
6090
6111
|
}
|
|
6091
6112
|
};
|
|
6092
6113
|
microRootDocument.prototype.getElementsByTagName = function getElementsByTagName(key) {
|
|
6093
|
-
const _this = getBindTarget(this);
|
|
6114
|
+
const _this = getBindTarget(getElementDocument(this, rawDocument));
|
|
6094
6115
|
if (isUniqueElement(key) ||
|
|
6095
6116
|
isInvalidQuerySelectorKey(key)) {
|
|
6096
6117
|
return rawMicroGetElementsByTagName.call(_this, key);
|
|
@@ -6100,19 +6121,19 @@ function patchDocumentPrototype(appName, microAppWindow) {
|
|
|
6100
6121
|
return rawMicroGetElementsByTagName.call(microDocument, key);
|
|
6101
6122
|
}
|
|
6102
6123
|
try {
|
|
6103
|
-
return querySelectorAll.call(this, key);
|
|
6124
|
+
return querySelectorAll.call(getElementDocument(this, rawDocument), key);
|
|
6104
6125
|
}
|
|
6105
6126
|
catch (_a) {
|
|
6106
6127
|
return rawMicroGetElementsByTagName.call(_this, key);
|
|
6107
6128
|
}
|
|
6108
6129
|
};
|
|
6109
6130
|
microRootDocument.prototype.getElementsByName = function getElementsByName(key) {
|
|
6110
|
-
const _this = getBindTarget(this);
|
|
6131
|
+
const _this = getBindTarget(getElementDocument(this, rawDocument));
|
|
6111
6132
|
if (isInvalidQuerySelectorKey(key)) {
|
|
6112
6133
|
return rawMicroGetElementsByName.call(_this, key);
|
|
6113
6134
|
}
|
|
6114
6135
|
try {
|
|
6115
|
-
return querySelectorAll.call(this, `[name=${key}]`);
|
|
6136
|
+
return querySelectorAll.call(getElementDocument(this, rawDocument), `[name=${key}]`);
|
|
6116
6137
|
}
|
|
6117
6138
|
catch (_a) {
|
|
6118
6139
|
return rawMicroGetElementsByName.call(_this, key);
|