@alicloud/console-os-browser-vm 1.4.37-alpha.0 → 1.4.37
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 +6 -5
- package/es/Elements.js +1 -1
- package/lib/Context.js +6 -5
- package/lib/Elements.js +1 -1
- package/package.json +1 -1
package/es/Context.js
CHANGED
|
@@ -36,7 +36,7 @@ var Context = /*#__PURE__*/function () {
|
|
|
36
36
|
_createClass(Context, [{
|
|
37
37
|
key: "loadScripts",
|
|
38
38
|
value: function () {
|
|
39
|
-
var _loadScripts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(url) {
|
|
39
|
+
var _loadScripts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(url, script) {
|
|
40
40
|
var resp, code;
|
|
41
41
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
42
42
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -51,14 +51,14 @@ var Context = /*#__PURE__*/function () {
|
|
|
51
51
|
return resp.text();
|
|
52
52
|
case 5:
|
|
53
53
|
code = _context.sent;
|
|
54
|
-
this.evalScript(code, url);
|
|
54
|
+
this.evalScript(code, url, script);
|
|
55
55
|
case 7:
|
|
56
56
|
case "end":
|
|
57
57
|
return _context.stop();
|
|
58
58
|
}
|
|
59
59
|
}, _callee, this);
|
|
60
60
|
}));
|
|
61
|
-
function loadScripts(_x) {
|
|
61
|
+
function loadScripts(_x, _x2) {
|
|
62
62
|
return _loadScripts.apply(this, arguments);
|
|
63
63
|
}
|
|
64
64
|
return loadScripts;
|
|
@@ -67,13 +67,14 @@ var Context = /*#__PURE__*/function () {
|
|
|
67
67
|
key: "evalScript",
|
|
68
68
|
value: function evalScript(code) {
|
|
69
69
|
var url = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
70
|
+
var script = arguments.length > 2 ? arguments[2] : undefined;
|
|
70
71
|
var currentScript = this.document.createElement('script');
|
|
71
72
|
currentScript.src = url;
|
|
72
73
|
|
|
73
74
|
// eslint-disable-next-line no-new-func
|
|
74
75
|
var resolver = new Function("\n return function ({window, location, history, document, __os_current_script__}){\n var document = new Proxy(document, {\n get: function get(target, prop) {\n if (prop === \"currentScript\" && __os_current_script__) {\n return __os_current_script__;\n }\n return target[prop];\n }\n });\n var window = new Proxy(window, {\n get: function get(target, prop) {\n if (prop === \"document\") return document;\n return target[prop];\n }\n })\n var globalThis = window;\n with(window.__CONSOLE_OS_GLOBAL_VARS_) {\n try {\n ".concat(code, "\n } catch(e) {\n console.log(e)\n }\n }\n }//# sourceMappingURL=").concat(url));
|
|
75
76
|
resolver().call(this.window, _objectSpread(_objectSpread({}, this), {}, {
|
|
76
|
-
__os_current_script__: currentScript
|
|
77
|
+
__os_current_script__: script || currentScript
|
|
77
78
|
}));
|
|
78
79
|
}
|
|
79
80
|
}, {
|
|
@@ -136,7 +137,7 @@ var Context = /*#__PURE__*/function () {
|
|
|
136
137
|
}
|
|
137
138
|
}, _callee2);
|
|
138
139
|
}));
|
|
139
|
-
function remove(
|
|
140
|
+
function remove(_x3) {
|
|
140
141
|
return _remove.apply(this, arguments);
|
|
141
142
|
}
|
|
142
143
|
return remove;
|
package/es/Elements.js
CHANGED
|
@@ -7,7 +7,7 @@ var makeElInjector = function makeElInjector(originMethod, methodName) {
|
|
|
7
7
|
|
|
8
8
|
// 如果不在 BrowserVM 的白名单内,尝试通过 context 的 load script 通过 xhr 获取脚本内容,并在沙箱中执行
|
|
9
9
|
if (el && el._evalScriptInSandbox && el.ownerContext && el.nodeName === 'SCRIPT' && el.src && notAllowed && !getJsonCallback(el.src)) {
|
|
10
|
-
return el.ownerContext.loadScripts(el.src).then(function () {
|
|
10
|
+
return el.ownerContext.loadScripts(el.src, el).then(function () {
|
|
11
11
|
var fns = el._listenerMap.get('load');
|
|
12
12
|
if (fns) {
|
|
13
13
|
fns.forEach(function (fn) {
|
package/lib/Context.js
CHANGED
|
@@ -43,7 +43,7 @@ var Context = /*#__PURE__*/function () {
|
|
|
43
43
|
(0, _createClass2.default)(Context, [{
|
|
44
44
|
key: "loadScripts",
|
|
45
45
|
value: function () {
|
|
46
|
-
var _loadScripts = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(url) {
|
|
46
|
+
var _loadScripts = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(url, script) {
|
|
47
47
|
var resp, code;
|
|
48
48
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
49
49
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -58,14 +58,14 @@ var Context = /*#__PURE__*/function () {
|
|
|
58
58
|
return resp.text();
|
|
59
59
|
case 5:
|
|
60
60
|
code = _context.sent;
|
|
61
|
-
this.evalScript(code, url);
|
|
61
|
+
this.evalScript(code, url, script);
|
|
62
62
|
case 7:
|
|
63
63
|
case "end":
|
|
64
64
|
return _context.stop();
|
|
65
65
|
}
|
|
66
66
|
}, _callee, this);
|
|
67
67
|
}));
|
|
68
|
-
function loadScripts(_x) {
|
|
68
|
+
function loadScripts(_x, _x2) {
|
|
69
69
|
return _loadScripts.apply(this, arguments);
|
|
70
70
|
}
|
|
71
71
|
return loadScripts;
|
|
@@ -74,13 +74,14 @@ var Context = /*#__PURE__*/function () {
|
|
|
74
74
|
key: "evalScript",
|
|
75
75
|
value: function evalScript(code) {
|
|
76
76
|
var url = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
77
|
+
var script = arguments.length > 2 ? arguments[2] : undefined;
|
|
77
78
|
var currentScript = this.document.createElement('script');
|
|
78
79
|
currentScript.src = url;
|
|
79
80
|
|
|
80
81
|
// eslint-disable-next-line no-new-func
|
|
81
82
|
var resolver = new Function("\n return function ({window, location, history, document, __os_current_script__}){\n var document = new Proxy(document, {\n get: function get(target, prop) {\n if (prop === \"currentScript\" && __os_current_script__) {\n return __os_current_script__;\n }\n return target[prop];\n }\n });\n var window = new Proxy(window, {\n get: function get(target, prop) {\n if (prop === \"document\") return document;\n return target[prop];\n }\n })\n var globalThis = window;\n with(window.__CONSOLE_OS_GLOBAL_VARS_) {\n try {\n ".concat(code, "\n } catch(e) {\n console.log(e)\n }\n }\n }//# sourceMappingURL=").concat(url));
|
|
82
83
|
resolver().call(this.window, _objectSpread(_objectSpread({}, this), {}, {
|
|
83
|
-
__os_current_script__: currentScript
|
|
84
|
+
__os_current_script__: script || currentScript
|
|
84
85
|
}));
|
|
85
86
|
}
|
|
86
87
|
}, {
|
|
@@ -143,7 +144,7 @@ var Context = /*#__PURE__*/function () {
|
|
|
143
144
|
}
|
|
144
145
|
}, _callee2);
|
|
145
146
|
}));
|
|
146
|
-
function remove(
|
|
147
|
+
function remove(_x3) {
|
|
147
148
|
return _remove.apply(this, arguments);
|
|
148
149
|
}
|
|
149
150
|
return remove;
|
package/lib/Elements.js
CHANGED
|
@@ -13,7 +13,7 @@ var makeElInjector = function makeElInjector(originMethod, methodName) {
|
|
|
13
13
|
|
|
14
14
|
// 如果不在 BrowserVM 的白名单内,尝试通过 context 的 load script 通过 xhr 获取脚本内容,并在沙箱中执行
|
|
15
15
|
if (el && el._evalScriptInSandbox && el.ownerContext && el.nodeName === 'SCRIPT' && el.src && notAllowed && !(0, _injectScriptCallBack.getJsonCallback)(el.src)) {
|
|
16
|
-
return el.ownerContext.loadScripts(el.src).then(function () {
|
|
16
|
+
return el.ownerContext.loadScripts(el.src, el).then(function () {
|
|
17
17
|
var fns = el._listenerMap.get('load');
|
|
18
18
|
if (fns) {
|
|
19
19
|
fns.forEach(function (fn) {
|