@blueking/bk-weweb 0.0.26-beta.1 → 0.0.26-beta.3
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/base-app/collect-source.esm.js +18 -17
- package/dist/base-app/collect-source.esm.js.map +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.esm.js +18 -17
- package/dist/index.esm.js.map +1 -1
- package/package.json +14 -19
|
@@ -6,11 +6,11 @@ function getCurrentRunningApp() {
|
|
|
6
6
|
function setCurrentRunningApp(appInstance) {
|
|
7
7
|
currentRunningApp = appInstance;
|
|
8
8
|
}
|
|
9
|
-
var windowNativeFuncMap =
|
|
9
|
+
var windowNativeFuncMap = {};
|
|
10
10
|
var collectNativeWindowFunc = () => {
|
|
11
11
|
Object.getOwnPropertyNames(window).forEach((key) => {
|
|
12
|
-
if (!windowNativeFuncMap
|
|
13
|
-
windowNativeFuncMap
|
|
12
|
+
if (!windowNativeFuncMap[key] && key.match(/^[A-Z]/) && typeof window[key] === "function" && window[key].toString().includes("[native code]")) {
|
|
13
|
+
windowNativeFuncMap[key] = true;
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
16
|
};
|
|
@@ -70,7 +70,7 @@ function fillUpPath(path, baseURI) {
|
|
|
70
70
|
function randomUrl() {
|
|
71
71
|
return `inline-${random(16)}`;
|
|
72
72
|
}
|
|
73
|
-
var requestIdleCallback = window.requestIdleCallback ||
|
|
73
|
+
var requestIdleCallback = window.requestIdleCallback || ((cb) => {
|
|
74
74
|
const start = Date.now();
|
|
75
75
|
return setTimeout(() => {
|
|
76
76
|
cb({
|
|
@@ -80,14 +80,14 @@ var requestIdleCallback = window.requestIdleCallback || function(cb) {
|
|
|
80
80
|
}
|
|
81
81
|
});
|
|
82
82
|
}, 1);
|
|
83
|
-
};
|
|
84
|
-
var cancelIdleCallback = window.cancelIdleCallback ||
|
|
83
|
+
});
|
|
84
|
+
var cancelIdleCallback = window.cancelIdleCallback || ((id) => {
|
|
85
85
|
clearTimeout(id);
|
|
86
|
-
};
|
|
86
|
+
});
|
|
87
87
|
var random = (n, str = "abcdefghijklmnopqrstuvwxyz0123456789") => {
|
|
88
88
|
let result = "";
|
|
89
89
|
for (let i = 0; i < n; i++) {
|
|
90
|
-
result += str[parseInt((Math.random() * str.length).toString(), 10)];
|
|
90
|
+
result += str[Number.parseInt((Math.random() * str.length).toString(), 10)];
|
|
91
91
|
}
|
|
92
92
|
return result;
|
|
93
93
|
};
|
|
@@ -330,11 +330,11 @@ function rewriteWindowFunction(fakeWindow) {
|
|
|
330
330
|
const intervalTimerList = [];
|
|
331
331
|
const rawWindow = window;
|
|
332
332
|
const { addEventListener, clearInterval: clearInterval2, removeEventListener, setInterval: setInterval2 } = window;
|
|
333
|
-
fakeWindow.addEventListener =
|
|
333
|
+
fakeWindow.addEventListener = (type, listener, options) => {
|
|
334
334
|
windowEventLisenerMap.set(type, [...windowEventLisenerMap.get(type) || [], listener]);
|
|
335
335
|
addEventListener.call(rawWindow, type, listener, options);
|
|
336
336
|
};
|
|
337
|
-
fakeWindow.removeEventListener =
|
|
337
|
+
fakeWindow.removeEventListener = (type, listener, options) => {
|
|
338
338
|
const listenerList = windowEventLisenerMap.get(type);
|
|
339
339
|
if (listenerList?.length) {
|
|
340
340
|
const index = listenerList.indexOf(listener);
|
|
@@ -342,12 +342,12 @@ function rewriteWindowFunction(fakeWindow) {
|
|
|
342
342
|
}
|
|
343
343
|
removeEventListener.call(rawWindow, type, listener, options);
|
|
344
344
|
};
|
|
345
|
-
fakeWindow.setInterval =
|
|
345
|
+
fakeWindow.setInterval = (handler, timeout, ...args) => {
|
|
346
346
|
const timer = setInterval2.call(rawWindow, handler, timeout, ...args);
|
|
347
347
|
intervalTimerList.push(timer);
|
|
348
348
|
return timer;
|
|
349
349
|
};
|
|
350
|
-
fakeWindow.clearInterval =
|
|
350
|
+
fakeWindow.clearInterval = (timer) => {
|
|
351
351
|
const index = intervalTimerList.indexOf(timer);
|
|
352
352
|
index > -1 && intervalTimerList.splice(index, 1);
|
|
353
353
|
clearInterval2.call(rawWindow, timer);
|
|
@@ -407,7 +407,8 @@ var SandBox = class {
|
|
|
407
407
|
return true;
|
|
408
408
|
},
|
|
409
409
|
get: (target, key) => {
|
|
410
|
-
if (windowNativeFuncMap
|
|
410
|
+
if (windowNativeFuncMap[key]) return rawWindow[key];
|
|
411
|
+
if (key === Symbol.unscopables) return rawWindow[Symbol.unscopables];
|
|
411
412
|
if (DEV_MICRO_APP_WINDOE_KEY_MAP[key]) return this.fakeWindow[key];
|
|
412
413
|
if (WINDOW_ALIAS_LIST.includes(key)) return this.proxyWindow;
|
|
413
414
|
if (key === "document") {
|
|
@@ -455,7 +456,7 @@ var SandBox = class {
|
|
|
455
456
|
}
|
|
456
457
|
return void 0;
|
|
457
458
|
},
|
|
458
|
-
has: (target, key) => windowNativeFuncMap
|
|
459
|
+
has: (target, key) => windowNativeFuncMap[key] || key in target || key in rawWindow,
|
|
459
460
|
// Object.getOwnPropertyNames(window)
|
|
460
461
|
ownKeys: (target) => Array.from(new Set(Reflect.ownKeys(rawWindow).concat(Reflect.ownKeys(target)))),
|
|
461
462
|
set: (target, key, value) => {
|
|
@@ -855,7 +856,7 @@ var BkWewebElement = class extends HTMLElement {
|
|
|
855
856
|
return ["url" /* url */];
|
|
856
857
|
}
|
|
857
858
|
getBooleanAttr(name) {
|
|
858
|
-
return this.hasAttribute(name) || this.hasAttribute(name.replace(/([A-Z])/g,
|
|
859
|
+
return this.hasAttribute(name) || this.hasAttribute(name.replace(/([A-Z])/g, "-$1").toLocaleLowerCase()) ? this.getAttribute(name) !== "false" : void 0;
|
|
859
860
|
}
|
|
860
861
|
async handleAttributeChanged() {
|
|
861
862
|
if (!this.appKey) return;
|
|
@@ -1312,7 +1313,7 @@ var MicroInstanceModel = class {
|
|
|
1312
1313
|
this.isPreLoad = false;
|
|
1313
1314
|
this.state = "ACTIVATED" /* ACTIVATED */;
|
|
1314
1315
|
if (this.container && container) {
|
|
1315
|
-
if (container instanceof Element) container
|
|
1316
|
+
if (container instanceof Element) container?.setAttribute(CSS_ATTRIBUTE_KEY, this.name);
|
|
1316
1317
|
const fragment = document.createDocumentFragment();
|
|
1317
1318
|
Array.from(this.container.childNodes).forEach((node) => {
|
|
1318
1319
|
fragment.appendChild(node);
|
|
@@ -2047,7 +2048,7 @@ var AppCache = class {
|
|
|
2047
2048
|
}
|
|
2048
2049
|
};
|
|
2049
2050
|
var appCache = new AppCache();
|
|
2050
|
-
window.__getAppOrInstance__ =
|
|
2051
|
+
window.__getAppOrInstance__ = (id) => {
|
|
2051
2052
|
if (!id) return appCache;
|
|
2052
2053
|
return appCache.getApp(id);
|
|
2053
2054
|
};
|