@blueking/bk-weweb 0.0.13 → 0.0.14
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/collect-source.js +24 -6
- package/dist/collect-source.js.map +1 -1
- package/dist/index.esm.js +24 -6
- package/dist/index.esm.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/collect-source.js
CHANGED
|
@@ -48,14 +48,26 @@ function rewriteDocumentPrototypeMethods() {
|
|
|
48
48
|
};
|
|
49
49
|
function querySelectorNew(selectors) {
|
|
50
50
|
const app = getCurrentRunningApp();
|
|
51
|
-
if (
|
|
51
|
+
if (SPECIAL_ELEMENT_TAG.includes(selectors)) {
|
|
52
|
+
if (app?.container instanceof ShadowRoot) {
|
|
53
|
+
return app?.container;
|
|
54
|
+
}
|
|
55
|
+
querySelector.call(this, selectors);
|
|
56
|
+
}
|
|
57
|
+
if (!app || !selectors || document$1 !== this) {
|
|
52
58
|
return querySelector.call(this, selectors);
|
|
53
59
|
}
|
|
54
60
|
return app?.container?.querySelector(selectors) ?? null;
|
|
55
61
|
}
|
|
56
62
|
function querySelectorAllNew(selectors) {
|
|
57
63
|
const app = getCurrentRunningApp();
|
|
58
|
-
if (
|
|
64
|
+
if (SPECIAL_ELEMENT_TAG.includes(selectors)) {
|
|
65
|
+
if (app?.container instanceof ShadowRoot) {
|
|
66
|
+
return app?.container;
|
|
67
|
+
}
|
|
68
|
+
querySelector.call(this, selectors);
|
|
69
|
+
}
|
|
70
|
+
if (!app || !selectors || document$1 !== this) {
|
|
59
71
|
return querySelectorAll.call(this, selectors);
|
|
60
72
|
}
|
|
61
73
|
return app?.container?.querySelectorAll(selectors) ?? [];
|
|
@@ -94,7 +106,11 @@ function resetDocumentPrototypeMethods() {
|
|
|
94
106
|
|
|
95
107
|
const nextTask = cb => Promise.resolve().then(cb);
|
|
96
108
|
function addUrlProtocol(url) {
|
|
97
|
-
|
|
109
|
+
if (url.startsWith('//'))
|
|
110
|
+
return `${location.protocol}${url}`;
|
|
111
|
+
if (!url.startsWith('http'))
|
|
112
|
+
return `${location.protocol}//${url}`;
|
|
113
|
+
return url;
|
|
98
114
|
}
|
|
99
115
|
// 补齐url地址
|
|
100
116
|
function fillUpPath(path, baseURI) {
|
|
@@ -117,7 +133,9 @@ const random = (n, str = 'abcdefghijklmnopqrstuvwxyz0123456789') => {
|
|
|
117
133
|
return result;
|
|
118
134
|
};
|
|
119
135
|
const isJsonpUrl = (url) => {
|
|
120
|
-
if (!url
|
|
136
|
+
if (!url)
|
|
137
|
+
return false;
|
|
138
|
+
if (url.match(/\.js$/))
|
|
121
139
|
return false;
|
|
122
140
|
const { pathname } = new URL(addUrlProtocol(url));
|
|
123
141
|
return !pathname.match(/\.js$/);
|
|
@@ -1751,7 +1769,7 @@ class MicroAppModel {
|
|
|
1751
1769
|
createIframe() {
|
|
1752
1770
|
return new Promise((resolve) => {
|
|
1753
1771
|
const iframe = document.createElement('iframe');
|
|
1754
|
-
const url = new URL(this.url);
|
|
1772
|
+
const url = new URL(addUrlProtocol(this.url));
|
|
1755
1773
|
const isChrome = navigator.userAgent.indexOf('Chrome') > -1;
|
|
1756
1774
|
iframe.setAttribute('src', `${isChrome ? BLANK_ORIGN : location.origin}${url.pathname || '/'}${url.search}${url.hash}`);
|
|
1757
1775
|
iframe.style.cssText = 'display: none;';
|
|
@@ -1809,7 +1827,7 @@ class EntrySource {
|
|
|
1809
1827
|
async importHtmlEntry(app) {
|
|
1810
1828
|
let htmlStr = appCache.getCacheHtml(this.url);
|
|
1811
1829
|
if (!htmlStr) {
|
|
1812
|
-
htmlStr = await fetchSource(this.url, { cache: 'no-cache' });
|
|
1830
|
+
htmlStr = await fetchSource(addUrlProtocol(this.url), { cache: 'no-cache' });
|
|
1813
1831
|
if (!htmlStr) {
|
|
1814
1832
|
console.error('load app entry error, pleace check');
|
|
1815
1833
|
return Promise.reject();
|