@alicloud/console-os-browser-vm 1.4.24 → 1.4.25-alpha.0
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/es/Context.js +3 -2
- package/es/Window.js +10 -0
- package/lib/Context.js +3 -2
- package/lib/Window.js +10 -0
- package/package.json +1 -1
package/es/Context.js
CHANGED
|
@@ -25,9 +25,10 @@ var Context = /*#__PURE__*/function () {
|
|
|
25
25
|
this.window = new Window(conf, this, frame, location);
|
|
26
26
|
this.allowResources = conf.allowResources || [];
|
|
27
27
|
var body = conf.body;
|
|
28
|
-
|
|
28
|
+
var disableBody = conf.disableBody;
|
|
29
|
+
if (disableBody) {
|
|
29
30
|
body = document.body;
|
|
30
|
-
} else if (!
|
|
31
|
+
} else if (!body) {
|
|
31
32
|
body = document.createElement('body');
|
|
32
33
|
document.documentElement.appendChild(body);
|
|
33
34
|
}
|
package/es/Window.js
CHANGED
|
@@ -7,6 +7,7 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
|
7
7
|
import { addEventListener, removeEventListener } from './events';
|
|
8
8
|
import { isConstructable, isBoundedFunction } from './utils/common';
|
|
9
9
|
var globalFnName = ['setTimeout', 'setInterval', 'clearInterval', 'clearTimeout'];
|
|
10
|
+
var globalVars = ['location', 'history'];
|
|
10
11
|
var defaultExternals = ['requestAnimationFrame', 'webkitRequestAnimationFrame', 'mozRequestAnimationFrame', 'oRequestAnimationFrame', 'msRequestAnimationFrame', 'cancelAnimationFrame', 'webkitCancelAnimationFrame', 'mozCancelAnimationFrame', 'oCancelAnimationFrame', 'msCancelAnimationFrame', 'matchMedia'];
|
|
11
12
|
var Window = /*#__PURE__*/_createClass(function Window() {
|
|
12
13
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -15,12 +16,21 @@ var Window = /*#__PURE__*/_createClass(function Window() {
|
|
|
15
16
|
_classCallCheck(this, Window);
|
|
16
17
|
var externals = [].concat(defaultExternals, _toConsumableArray(options.externals || []));
|
|
17
18
|
var __CONSOLE_OS_GLOBAL_VARS_ = {};
|
|
19
|
+
|
|
20
|
+
// 拦截全局方法
|
|
18
21
|
globalFnName.forEach(function (name) {
|
|
19
22
|
if (externals.includes(name)) {
|
|
20
23
|
return;
|
|
21
24
|
}
|
|
22
25
|
__CONSOLE_OS_GLOBAL_VARS_[name] = frame.contentWindow[name].bind(frame.contentWindow);
|
|
23
26
|
});
|
|
27
|
+
|
|
28
|
+
// 通过拦截外置的全局变量,指向外部变量
|
|
29
|
+
globalVars.forEach(function (name) {
|
|
30
|
+
if (externals.includes(name)) {
|
|
31
|
+
__CONSOLE_OS_GLOBAL_VARS_[name] = window[name];
|
|
32
|
+
}
|
|
33
|
+
});
|
|
24
34
|
return new Proxy(frame.contentWindow, {
|
|
25
35
|
set: function set(target, name, value) {
|
|
26
36
|
target[name] = value;
|
package/lib/Context.js
CHANGED
|
@@ -30,9 +30,10 @@ var Context = /*#__PURE__*/function () {
|
|
|
30
30
|
this.window = new _Window.default(conf, this, frame, location);
|
|
31
31
|
this.allowResources = conf.allowResources || [];
|
|
32
32
|
var body = conf.body;
|
|
33
|
-
|
|
33
|
+
var disableBody = conf.disableBody;
|
|
34
|
+
if (disableBody) {
|
|
34
35
|
body = document.body;
|
|
35
|
-
} else if (!
|
|
36
|
+
} else if (!body) {
|
|
36
37
|
body = document.createElement('body');
|
|
37
38
|
document.documentElement.appendChild(body);
|
|
38
39
|
}
|
package/lib/Window.js
CHANGED
|
@@ -15,6 +15,7 @@ var _common = require("./utils/common");
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
var globalFnName = ['setTimeout', 'setInterval', 'clearInterval', 'clearTimeout'];
|
|
18
|
+
var globalVars = ['location', 'history'];
|
|
18
19
|
var defaultExternals = ['requestAnimationFrame', 'webkitRequestAnimationFrame', 'mozRequestAnimationFrame', 'oRequestAnimationFrame', 'msRequestAnimationFrame', 'cancelAnimationFrame', 'webkitCancelAnimationFrame', 'mozCancelAnimationFrame', 'oCancelAnimationFrame', 'msCancelAnimationFrame', 'matchMedia'];
|
|
19
20
|
var Window = /*#__PURE__*/(0, _createClass2.default)(function Window() {
|
|
20
21
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -23,12 +24,21 @@ var Window = /*#__PURE__*/(0, _createClass2.default)(function Window() {
|
|
|
23
24
|
(0, _classCallCheck2.default)(this, Window);
|
|
24
25
|
var externals = [].concat(defaultExternals, (0, _toConsumableArray2.default)(options.externals || []));
|
|
25
26
|
var __CONSOLE_OS_GLOBAL_VARS_ = {};
|
|
27
|
+
|
|
28
|
+
// 拦截全局方法
|
|
26
29
|
globalFnName.forEach(function (name) {
|
|
27
30
|
if (externals.includes(name)) {
|
|
28
31
|
return;
|
|
29
32
|
}
|
|
30
33
|
__CONSOLE_OS_GLOBAL_VARS_[name] = frame.contentWindow[name].bind(frame.contentWindow);
|
|
31
34
|
});
|
|
35
|
+
|
|
36
|
+
// 通过拦截外置的全局变量,指向外部变量
|
|
37
|
+
globalVars.forEach(function (name) {
|
|
38
|
+
if (externals.includes(name)) {
|
|
39
|
+
__CONSOLE_OS_GLOBAL_VARS_[name] = window[name];
|
|
40
|
+
}
|
|
41
|
+
});
|
|
32
42
|
return new Proxy(frame.contentWindow, {
|
|
33
43
|
set: function set(target, name, value) {
|
|
34
44
|
target[name] = value;
|