@blueking/bk-weweb 0.0.22 → 0.0.23
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 +16 -41
- package/dist/collect-source.js.map +1 -1
- package/dist/index.esm.js +16 -41
- 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/readme.md +4 -6
- package/typings/context/document.d.ts +2 -0
- package/typings/base-app/base-element.d.ts +0 -6
- package/typings/context/memory.d.ts +0 -10
- package/typings/utils/element-event.d.ts +0 -2
package/dist/collect-source.js
CHANGED
|
@@ -164,31 +164,6 @@ const isJsonpUrl = (url) => {
|
|
|
164
164
|
return !pathname.match(/\.js$/);
|
|
165
165
|
};
|
|
166
166
|
|
|
167
|
-
/*
|
|
168
|
-
* Tencent is pleased to support the open source community by making
|
|
169
|
-
* 蓝鲸智云PaaS平台 (BlueKing PaaS) available.
|
|
170
|
-
*
|
|
171
|
-
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
|
|
172
|
-
*
|
|
173
|
-
* 蓝鲸智云PaaS平台 (BlueKing PaaS) is licensed under the MIT License.
|
|
174
|
-
*
|
|
175
|
-
* License for 蓝鲸智云PaaS平台 (BlueKing PaaS):
|
|
176
|
-
*
|
|
177
|
-
* ---------------------------------------------------
|
|
178
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
|
179
|
-
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation
|
|
180
|
-
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
|
|
181
|
-
* to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
182
|
-
*
|
|
183
|
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of
|
|
184
|
-
* the Software.
|
|
185
|
-
*
|
|
186
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
|
|
187
|
-
* THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
188
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
189
|
-
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
190
|
-
* IN THE SOFTWARE.
|
|
191
|
-
*/
|
|
192
167
|
const { document: document$1 } = window;
|
|
193
168
|
const { createElement, getElementById, getElementsByClassName, getElementsByName, getElementsByTagName, querySelector, querySelectorAll, } = Document.prototype;
|
|
194
169
|
const { querySelector: bodyQuerySelector } = HTMLBodyElement.prototype;
|
|
@@ -221,8 +196,6 @@ function rewriteDocumentPrototypeMethods() {
|
|
|
221
196
|
*/
|
|
222
197
|
function querySelectorNew(selectors) {
|
|
223
198
|
const app = getCurrentRunningApp();
|
|
224
|
-
if (selectors.includes('data-bk-mask-uid'))
|
|
225
|
-
debugger;
|
|
226
199
|
// 如果选择器是特殊元素标签
|
|
227
200
|
if (SPECIAL_ELEMENT_TAG.includes(selectors)) {
|
|
228
201
|
// 如果当前应用程序容器是 ShadowRoot 类型
|
|
@@ -297,6 +270,15 @@ function resetDocumentPrototypeMethods() {
|
|
|
297
270
|
Document.prototype.getElementsByName = getElementsByName;
|
|
298
271
|
hasRewrite$1 = false;
|
|
299
272
|
}
|
|
273
|
+
// vue3.3之后会换成document 这些需要初始化调用的app
|
|
274
|
+
function createRewriteDocument(rawDocument, app) {
|
|
275
|
+
return Object.defineProperty(rawDocument, 'createElement', {
|
|
276
|
+
get() {
|
|
277
|
+
app?.registerRunningApp();
|
|
278
|
+
return Document.prototype.createElement;
|
|
279
|
+
},
|
|
280
|
+
});
|
|
281
|
+
}
|
|
300
282
|
|
|
301
283
|
/*
|
|
302
284
|
* Tencent is pleased to support the open source community by making
|
|
@@ -717,15 +699,7 @@ class Style {
|
|
|
717
699
|
const rules = Array.from(templateStyle.sheet?.cssRules ?? []);
|
|
718
700
|
const cssPrefix = `#${app.name}`;
|
|
719
701
|
const scopedCss = this.scopeRule(rules, cssPrefix);
|
|
720
|
-
|
|
721
|
-
if (/Safari/.test(navigator.userAgent)) {
|
|
722
|
-
cssText = cssText.replace(/([;{]\s*content:\s*)([^\s"][^";}]*)/gm, (all, $1, $2) => {
|
|
723
|
-
if ($2 === 'none' || /^(url\()|(counter\()|(attr\()|(open-quote)|(close-quote)/.test($2)) {
|
|
724
|
-
return all;
|
|
725
|
-
}
|
|
726
|
-
return `${$1}"${$2}"`;
|
|
727
|
-
});
|
|
728
|
-
}
|
|
702
|
+
const cssText = this.resetUrlHost(scopedCss, app.url, this.url);
|
|
729
703
|
styleElement.textContent = cssText;
|
|
730
704
|
this.scopedCode = cssText;
|
|
731
705
|
}
|
|
@@ -1534,7 +1508,7 @@ function setMarkElement(element, app, keepAlive) {
|
|
|
1534
1508
|
* IN THE SOFTWARE.
|
|
1535
1509
|
*/
|
|
1536
1510
|
const { setAttribute } = Element.prototype;
|
|
1537
|
-
const { append, appendChild: bodyAppendChild, removeChild: bodyRemoveChild } = HTMLBodyElement.prototype;
|
|
1511
|
+
const { append, appendChild: bodyAppendChild, insertBefore: bodyInsertBefore, removeChild: bodyRemoveChild, } = HTMLBodyElement.prototype;
|
|
1538
1512
|
const { appendChild: headAppendChild, insertBefore: headInsertBefore, removeChild: headRemoveChild, } = HTMLHeadElement.prototype;
|
|
1539
1513
|
const rawHead = document.head;
|
|
1540
1514
|
let hasRewrite = false;
|
|
@@ -1572,6 +1546,9 @@ function rewriteBodyAndHeaderMethods() {
|
|
|
1572
1546
|
HTMLHeadElement.prototype.insertBefore = function (newChild, refChild) {
|
|
1573
1547
|
return elementInsertHandler(this, newChild, refChild, headInsertBefore);
|
|
1574
1548
|
};
|
|
1549
|
+
HTMLBodyElement.prototype.insertBefore = function (newChild, refChild) {
|
|
1550
|
+
return elementInsertHandler(this, newChild, refChild, headInsertBefore);
|
|
1551
|
+
};
|
|
1575
1552
|
HTMLBodyElement.prototype.removeChild = function removeChildNew(oldChild) {
|
|
1576
1553
|
const app = appCache.getApp(oldChild.__BK_WEWEB_APP_KEY__);
|
|
1577
1554
|
if (app?.container?.contains(oldChild)) {
|
|
@@ -1591,6 +1568,7 @@ function resetBodyAndHeaderMethods() {
|
|
|
1591
1568
|
HTMLBodyElement.prototype.appendChild = bodyAppendChild;
|
|
1592
1569
|
HTMLBodyElement.prototype.append = append;
|
|
1593
1570
|
HTMLBodyElement.prototype.removeChild = bodyRemoveChild;
|
|
1571
|
+
HTMLBodyElement.prototype.insertBefore = bodyInsertBefore;
|
|
1594
1572
|
HTMLHeadElement.prototype.appendChild = headAppendChild;
|
|
1595
1573
|
HTMLHeadElement.prototype.insertBefore = headInsertBefore;
|
|
1596
1574
|
HTMLHeadElement.prototype.removeChild = headRemoveChild;
|
|
@@ -1958,9 +1936,6 @@ function rewriteDocumentAndBodyEvent() {
|
|
|
1958
1936
|
*/
|
|
1959
1937
|
/* eslint-disable max-len */
|
|
1960
1938
|
/* eslint-disable no-prototype-builtins */
|
|
1961
|
-
/*
|
|
1962
|
-
inspired by https://github.com/umijs/qiankun
|
|
1963
|
-
*/
|
|
1964
1939
|
// 正则表达式,用于匹配类定义
|
|
1965
1940
|
const CLASS_REGEX = /^class\b/;
|
|
1966
1941
|
// 正则表达式,用于匹配以大写字母开头的函数定义
|
|
@@ -2127,7 +2102,7 @@ class SandBox {
|
|
|
2127
2102
|
this.app = app;
|
|
2128
2103
|
const windowDescriptorSet = new Set();
|
|
2129
2104
|
const rawWindow = window;
|
|
2130
|
-
const rawDocument =
|
|
2105
|
+
const rawDocument = createRewriteDocument(document, this.app);
|
|
2131
2106
|
this.fakeWindow.__POWERED_BY_BK_WEWEB__ = true;
|
|
2132
2107
|
this.fakeWindow.__BK_WEWEB_APP_KEY__ = app.appCacheKey;
|
|
2133
2108
|
this.rawWindow = rawWindow;
|