@blueking/bk-weweb 0.0.35-beta.3 → 0.0.35-beta.5
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/dist/index.esm.js +35 -24
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1481,10 +1481,8 @@ var MicroInstanceModel = class {
|
|
|
1481
1481
|
setupContainer() {
|
|
1482
1482
|
if (this.container) {
|
|
1483
1483
|
this.container.innerHTML = "";
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
this.container.appendChild(instanceWrapper);
|
|
1487
|
-
}
|
|
1484
|
+
const instanceWrapper = this.createInstanceWrapper();
|
|
1485
|
+
this.container.appendChild(instanceWrapper);
|
|
1488
1486
|
}
|
|
1489
1487
|
}
|
|
1490
1488
|
/** 执行样式 */
|
|
@@ -1503,7 +1501,7 @@ var MicroInstanceModel = class {
|
|
|
1503
1501
|
renderInstance() {
|
|
1504
1502
|
const scriptInfo = this.getScriptInfo();
|
|
1505
1503
|
if (scriptInfo?.exportInstance?.render && this.container) {
|
|
1506
|
-
const targetContainer = this.
|
|
1504
|
+
const targetContainer = this.container.querySelector(`#${this.name}${WRAPPER_SUFFIX}`);
|
|
1507
1505
|
if (targetContainer) {
|
|
1508
1506
|
scriptInfo.exportInstance.render(targetContainer, this.data);
|
|
1509
1507
|
}
|
|
@@ -1516,7 +1514,7 @@ var MicroInstanceModel = class {
|
|
|
1516
1514
|
}
|
|
1517
1515
|
/** 检查是否需要重新加载 */
|
|
1518
1516
|
needsReload() {
|
|
1519
|
-
return this.status === AppState.ERROR;
|
|
1517
|
+
return this.status === AppState.ERROR || this.status === AppState.UNSET;
|
|
1520
1518
|
}
|
|
1521
1519
|
};
|
|
1522
1520
|
|
|
@@ -1907,16 +1905,21 @@ var MicroAppModel = class {
|
|
|
1907
1905
|
this.setupNodeProperties(node);
|
|
1908
1906
|
fragment.appendChild(node);
|
|
1909
1907
|
}
|
|
1908
|
+
container.innerHTML = "";
|
|
1910
1909
|
container.appendChild(fragment);
|
|
1911
1910
|
}
|
|
1912
1911
|
/** 设置节点属性 */
|
|
1913
1912
|
setupNodeProperties(node) {
|
|
1913
|
+
const app = this;
|
|
1914
1914
|
const nodeWithProps = node;
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1915
|
+
nodeWithProps.__BK_WEWEB_APP_KEY__ = this.appCacheKey;
|
|
1916
|
+
Object.defineProperties(node, {
|
|
1917
|
+
ownerDocument: {
|
|
1918
|
+
get() {
|
|
1919
|
+
return app.sandBox?.rawDocument;
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1922
|
+
});
|
|
1920
1923
|
}
|
|
1921
1924
|
/** 创建iframe元素 */
|
|
1922
1925
|
createIframeElement() {
|
|
@@ -1928,7 +1931,8 @@ var MicroAppModel = class {
|
|
|
1928
1931
|
}
|
|
1929
1932
|
/** 构建iframe源地址 */
|
|
1930
1933
|
buildIframeSrc(url) {
|
|
1931
|
-
|
|
1934
|
+
const isChrome = this.isChromeUserAgent();
|
|
1935
|
+
return `${isChrome ? IFRAME_CONSTANTS.BLANK_ORIGIN : location.origin}${url.pathname || "/"}${url.search}${url.hash}`;
|
|
1932
1936
|
}
|
|
1933
1937
|
/** 检查是否为Chrome浏览器 */
|
|
1934
1938
|
isChromeUserAgent() {
|
|
@@ -1936,24 +1940,30 @@ var MicroAppModel = class {
|
|
|
1936
1940
|
}
|
|
1937
1941
|
/** 处理非Chrome浏览器iframe */
|
|
1938
1942
|
handleNonChromeIframe(iframe, resolve) {
|
|
1939
|
-
const
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
}
|
|
1943
|
+
const interval = setInterval(() => {
|
|
1944
|
+
if (iframe.contentWindow && iframe.contentWindow.location.href !== IFRAME_CONSTANTS.BLANK_ORIGIN) {
|
|
1945
|
+
iframe.contentWindow.stop();
|
|
1946
|
+
iframe.contentDocument.body.parentElement.innerHTML = IFRAME_CONSTANTS.DEFAULT_HTML;
|
|
1947
|
+
clearInterval(interval);
|
|
1948
|
+
resolve(iframe);
|
|
1949
|
+
}
|
|
1950
|
+
}, IFRAME_CONSTANTS.POLLING_INTERVAL);
|
|
1947
1951
|
}
|
|
1948
1952
|
/** 渲染应用内容 */
|
|
1949
1953
|
renderAppContent() {
|
|
1950
|
-
if (this.
|
|
1951
|
-
|
|
1954
|
+
if (!this.source) return;
|
|
1955
|
+
const clonedNode = this.source.html.cloneNode(true);
|
|
1956
|
+
const fragment = document.createDocumentFragment();
|
|
1957
|
+
for (const node of Array.from(clonedNode.childNodes)) {
|
|
1958
|
+
this.setupNodeProperties(node);
|
|
1959
|
+
fragment.appendChild(node);
|
|
1952
1960
|
}
|
|
1961
|
+
this.container.innerHTML = "";
|
|
1962
|
+
this.container.appendChild(fragment);
|
|
1953
1963
|
}
|
|
1954
1964
|
/** 检查是否需要重新加载 */
|
|
1955
1965
|
needsReload() {
|
|
1956
|
-
return this.status === AppState.ERROR;
|
|
1966
|
+
return this.status === AppState.ERROR || this.status === AppState.UNSET;
|
|
1957
1967
|
}
|
|
1958
1968
|
};
|
|
1959
1969
|
|
|
@@ -2181,7 +2191,8 @@ var EntrySource = class {
|
|
|
2181
2191
|
* 检查是否应该忽略脚本
|
|
2182
2192
|
*/
|
|
2183
2193
|
shouldIgnoreScript = (script) => {
|
|
2184
|
-
return script.hasAttribute("ignore") || script.type !==
|
|
2194
|
+
return script.hasAttribute("ignore") || // (script.type !== 'module' && isJsonpUrl(script.getAttribute('src'))) ||
|
|
2195
|
+
script.hasAttribute("type") && !SCRIPT_TYPE_NAMES.includes(script.type);
|
|
2185
2196
|
};
|
|
2186
2197
|
/**
|
|
2187
2198
|
* 处理被排除的脚本
|