@alicloud/console-os-browser-vm 1.4.21-alpha.0 → 1.4.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/es/Context.js +31 -53
- package/es/Document.js +8 -40
- package/es/Elements.js +8 -18
- package/es/History.js +2 -11
- package/es/Location.js +0 -9
- package/es/Window.js +1 -19
- package/es/events.js +0 -6
- package/es/index.js +37 -54
- package/es/utils/HTMLScriptElement.js +4 -7
- package/es/utils/injectScriptCallBack.js +0 -8
- package/lib/Context.js +36 -62
- package/lib/Document.js +13 -41
- package/lib/Elements.js +8 -24
- package/lib/History.js +2 -13
- package/lib/Location.js +0 -10
- package/lib/Window.js +2 -21
- package/lib/events.js +0 -14
- package/lib/index.js +42 -65
- package/lib/utils/HTMLScriptElement.js +4 -15
- package/lib/utils/common.js +0 -2
- package/lib/utils/credentials.js +0 -2
- package/lib/utils/injectScriptCallBack.js +0 -10
- package/lib/utils/isSSR.js +0 -2
- package/lib/utils/not-implemented.js +0 -2
- package/package.json +2 -2
- package/dist/index.js +0 -1
package/lib/History.js
CHANGED
|
@@ -1,55 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
|
-
|
|
12
9
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
-
|
|
14
10
|
var History = /*#__PURE__*/(0, _createClass2.default)(function History(id, frame) {
|
|
15
11
|
(0, _classCallCheck2.default)(this, History);
|
|
16
|
-
|
|
17
12
|
if (!id) {
|
|
18
13
|
return frame.history;
|
|
19
14
|
}
|
|
20
|
-
|
|
21
15
|
var postMessage = function postMessage() {
|
|
22
16
|
frame.postMessage({
|
|
23
17
|
type: "".concat(id, ":history-change"),
|
|
24
18
|
data: JSON.parse(JSON.stringify(frame.location))
|
|
25
19
|
}, '*');
|
|
26
|
-
};
|
|
27
|
-
|
|
20
|
+
};
|
|
28
21
|
|
|
22
|
+
// throw error when iframe src is about:blank
|
|
29
23
|
try {
|
|
30
24
|
var originalPushStatus = frame.history.pushState;
|
|
31
25
|
var originalReplaceStatus = frame.history.replaceState;
|
|
32
|
-
|
|
33
26
|
frame.history.pushState = function () {
|
|
34
27
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
35
28
|
args[_key] = arguments[_key];
|
|
36
29
|
}
|
|
37
|
-
|
|
38
30
|
var returnValue = originalPushStatus.apply(frame.history, [].concat(args));
|
|
39
31
|
postMessage();
|
|
40
32
|
return returnValue;
|
|
41
33
|
};
|
|
42
|
-
|
|
43
34
|
frame.history.replaceState = function () {
|
|
44
35
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
45
36
|
args[_key2] = arguments[_key2];
|
|
46
37
|
}
|
|
47
|
-
|
|
48
38
|
var returnValue = originalReplaceStatus.apply(frame.history, [].concat(args));
|
|
49
39
|
postMessage();
|
|
50
40
|
return returnValue;
|
|
51
41
|
};
|
|
52
|
-
|
|
53
42
|
return frame.history;
|
|
54
43
|
} catch (e) {
|
|
55
44
|
return undefined;
|
package/lib/Location.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
|
-
|
|
12
9
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
-
|
|
14
10
|
var Location = /*#__PURE__*/(0, _createClass2.default)(function Location(location) {
|
|
15
11
|
(0, _classCallCheck2.default)(this, Location);
|
|
16
12
|
return new Proxy({}, {
|
|
@@ -18,11 +14,9 @@ var Location = /*#__PURE__*/(0, _createClass2.default)(function Location(locatio
|
|
|
18
14
|
switch (name) {
|
|
19
15
|
case 'href':
|
|
20
16
|
break;
|
|
21
|
-
|
|
22
17
|
default:
|
|
23
18
|
location[name] = value;
|
|
24
19
|
}
|
|
25
|
-
|
|
26
20
|
return true;
|
|
27
21
|
},
|
|
28
22
|
get: function get(target, name) {
|
|
@@ -31,10 +25,8 @@ var Location = /*#__PURE__*/(0, _createClass2.default)(function Location(locatio
|
|
|
31
25
|
return function () {
|
|
32
26
|
return window.location.reload();
|
|
33
27
|
};
|
|
34
|
-
|
|
35
28
|
case 'replace':
|
|
36
29
|
return function () {};
|
|
37
|
-
|
|
38
30
|
case 'toString':
|
|
39
31
|
return function () {
|
|
40
32
|
try {
|
|
@@ -43,11 +35,9 @@ var Location = /*#__PURE__*/(0, _createClass2.default)(function Location(locatio
|
|
|
43
35
|
return location.href;
|
|
44
36
|
}
|
|
45
37
|
};
|
|
46
|
-
|
|
47
38
|
default:
|
|
48
39
|
break;
|
|
49
40
|
}
|
|
50
|
-
|
|
51
41
|
if (typeof location[name] === 'function') {
|
|
52
42
|
return location[name].bind && location[name].bind(target);
|
|
53
43
|
} else {
|
package/lib/Window.js
CHANGED
|
@@ -1,27 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
-
|
|
12
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
|
|
14
10
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
15
|
-
|
|
16
11
|
var _events = require("./events");
|
|
17
|
-
|
|
18
12
|
var _common = require("./utils/common");
|
|
19
|
-
|
|
20
13
|
/**
|
|
21
14
|
* Window.js
|
|
22
15
|
*/
|
|
16
|
+
|
|
23
17
|
var globalFnName = ['setTimeout', 'setInterval', 'clearInterval', 'clearTimeout'];
|
|
24
|
-
var defaultExternals = ['requestAnimationFrame', 'webkitRequestAnimationFrame', 'mozRequestAnimationFrame', 'oRequestAnimationFrame', 'msRequestAnimationFrame', 'cancelAnimationFrame', 'webkitCancelAnimationFrame', 'mozCancelAnimationFrame', 'oCancelAnimationFrame', 'msCancelAnimationFrame'];
|
|
18
|
+
var defaultExternals = ['requestAnimationFrame', 'webkitRequestAnimationFrame', 'mozRequestAnimationFrame', 'oRequestAnimationFrame', 'msRequestAnimationFrame', 'cancelAnimationFrame', 'webkitCancelAnimationFrame', 'mozCancelAnimationFrame', 'oCancelAnimationFrame', 'msCancelAnimationFrame', 'matchMedia'];
|
|
25
19
|
var Window = /*#__PURE__*/(0, _createClass2.default)(function Window() {
|
|
26
20
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
27
21
|
var context = arguments.length > 1 ? arguments[1] : undefined;
|
|
@@ -33,7 +27,6 @@ var Window = /*#__PURE__*/(0, _createClass2.default)(function Window() {
|
|
|
33
27
|
if (externals.includes(name)) {
|
|
34
28
|
return;
|
|
35
29
|
}
|
|
36
|
-
|
|
37
30
|
__CONSOLE_OS_GLOBAL_VARS_[name] = frame.contentWindow[name].bind(frame.contentWindow);
|
|
38
31
|
});
|
|
39
32
|
return new Proxy(frame.contentWindow, {
|
|
@@ -45,46 +38,34 @@ var Window = /*#__PURE__*/(0, _createClass2.default)(function Window() {
|
|
|
45
38
|
get: function get(target, name) {
|
|
46
39
|
if (externals.includes(name)) {
|
|
47
40
|
var windowValue = window[name];
|
|
48
|
-
|
|
49
41
|
if (typeof windowValue === 'function' && !(0, _common.isBoundedFunction)(windowValue) && !(0, _common.isConstructable)(windowValue)) {
|
|
50
42
|
var bindFn = windowValue.bind(window);
|
|
51
|
-
|
|
52
43
|
for (var key in windowValue) {
|
|
53
44
|
bindFn[key] = windowValue[key];
|
|
54
45
|
}
|
|
55
|
-
|
|
56
46
|
return bindFn;
|
|
57
47
|
} else {
|
|
58
48
|
return windowValue;
|
|
59
49
|
}
|
|
60
50
|
}
|
|
61
|
-
|
|
62
51
|
switch (name) {
|
|
63
52
|
case 'document':
|
|
64
53
|
return context.document;
|
|
65
|
-
|
|
66
54
|
case 'location':
|
|
67
55
|
return context.location;
|
|
68
|
-
|
|
69
56
|
case 'history':
|
|
70
57
|
return context.history;
|
|
71
|
-
|
|
72
58
|
case '__CONSOLE_OS_GLOBAL_VARS_':
|
|
73
59
|
return __CONSOLE_OS_GLOBAL_VARS_;
|
|
74
|
-
|
|
75
60
|
case 'addEventListener':
|
|
76
61
|
return (0, _events.addEventListener)(context);
|
|
77
|
-
|
|
78
62
|
case 'removeEventListener':
|
|
79
63
|
return (0, _events.removeEventListener)(context);
|
|
80
64
|
}
|
|
81
|
-
|
|
82
65
|
if (__CONSOLE_OS_GLOBAL_VARS_[name]) {
|
|
83
66
|
return __CONSOLE_OS_GLOBAL_VARS_[name];
|
|
84
67
|
}
|
|
85
|
-
|
|
86
68
|
var value = target[name];
|
|
87
|
-
|
|
88
69
|
if (typeof value === 'function' && !(0, _common.isBoundedFunction)(value) && !(0, _common.isConstructable)(value)) {
|
|
89
70
|
return value.bind && value.bind(target);
|
|
90
71
|
} else {
|
package/lib/events.js
CHANGED
|
@@ -1,52 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.removeEventListener = exports.domEventsListeningTo = exports.addEventListener = void 0;
|
|
9
|
-
|
|
10
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
-
|
|
12
9
|
var _isSSR = require("./utils/isSSR");
|
|
13
|
-
|
|
14
10
|
var rawAddEventListener = !(0, _isSSR.isSSR)() ? window.addEventListener : function () {};
|
|
15
11
|
var rawRemoveEventListener = !(0, _isSSR.isSSR)() ? window.removeEventListener : function () {};
|
|
16
12
|
;
|
|
17
13
|
var domEventsListeningTo = ['webkitmouseforcedown', 'webkitmouseforcewillbegin', 'visibilitychange', 'error', 'mousemove', 'mousedown', 'mouseup', 'touchcancel', 'touchend', 'touchstart', 'auxclick', 'dblclick', 'pointercancel', 'pointerdown', 'pointerup', 'dragend', 'dragstart', 'drop', 'compositionend', 'compositionstart', 'keydown', 'keypress', 'keyup', 'input', 'textInput', 'close', 'cancel', 'copy', 'cut', 'paste', 'click', 'change', 'contextmenu', 'reset', 'submit', 'resize', 'scroll', 'foucs', 'blur'];
|
|
18
14
|
exports.domEventsListeningTo = domEventsListeningTo;
|
|
19
|
-
|
|
20
15
|
var addEventListener = function addEventListener(context) {
|
|
21
16
|
return function (type, listener, options) {
|
|
22
17
|
var listeners = context._listenerMap.get(type) || [];
|
|
23
|
-
|
|
24
18
|
context._listenerMap.set(type, [].concat((0, _toConsumableArray2.default)(listeners), [listener]));
|
|
25
|
-
|
|
26
19
|
if (domEventsListeningTo.indexOf(type) === -1) {
|
|
27
20
|
return context.baseFrame.addEventListener.apply(context.baseFrame.contentWindow, [type, listener, options]);
|
|
28
21
|
}
|
|
29
|
-
|
|
30
22
|
return rawAddEventListener.apply(window, [type, listener, options]);
|
|
31
23
|
};
|
|
32
24
|
};
|
|
33
|
-
|
|
34
25
|
exports.addEventListener = addEventListener;
|
|
35
|
-
|
|
36
26
|
var removeEventListener = function removeEventListener(context) {
|
|
37
27
|
return function (type, listener, options) {
|
|
38
28
|
var storedTypeListeners = context._listenerMap.get(type);
|
|
39
|
-
|
|
40
29
|
if (storedTypeListeners && storedTypeListeners.length && storedTypeListeners.indexOf(listener) !== -1) {
|
|
41
30
|
storedTypeListeners.splice(storedTypeListeners.indexOf(listener), 1);
|
|
42
31
|
}
|
|
43
|
-
|
|
44
32
|
if (domEventsListeningTo.indexOf(type) === -1) {
|
|
45
33
|
return context.baseFrame.removeEventListener.apply(context.baseFrame.contentWindow, [type, listener, options]);
|
|
46
34
|
}
|
|
47
|
-
|
|
48
35
|
return rawRemoveEventListener.apply(window, [type, listener, options]);
|
|
49
36
|
};
|
|
50
37
|
};
|
|
51
|
-
|
|
52
38
|
exports.removeEventListener = removeEventListener;
|
package/lib/index.js
CHANGED
|
@@ -1,113 +1,90 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.removeContext = exports.evalScripts = exports.createContext = void 0;
|
|
9
|
-
|
|
10
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
-
|
|
12
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
-
|
|
14
10
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
15
|
-
|
|
16
11
|
require("./Elements");
|
|
17
|
-
|
|
18
12
|
var _Context = _interopRequireDefault(require("./Context"));
|
|
19
|
-
|
|
20
13
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } /**
|
|
15
|
+
* index.js
|
|
16
|
+
* @lastModified 2019085
|
|
17
|
+
* @forwardCompatibleTo 2019085
|
|
18
|
+
* @createAt 2019085
|
|
19
|
+
*/
|
|
24
20
|
var createContext = /*#__PURE__*/function () {
|
|
25
21
|
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
26
22
|
var conf,
|
|
27
|
-
|
|
23
|
+
_args = arguments;
|
|
28
24
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
29
|
-
while (1) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
case 4:
|
|
40
|
-
case "end":
|
|
41
|
-
return _context.stop();
|
|
42
|
-
}
|
|
25
|
+
while (1) switch (_context.prev = _context.next) {
|
|
26
|
+
case 0:
|
|
27
|
+
conf = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
|
|
28
|
+
_context.next = 3;
|
|
29
|
+
return _Context.default.create(conf);
|
|
30
|
+
case 3:
|
|
31
|
+
return _context.abrupt("return", _context.sent);
|
|
32
|
+
case 4:
|
|
33
|
+
case "end":
|
|
34
|
+
return _context.stop();
|
|
43
35
|
}
|
|
44
36
|
}, _callee);
|
|
45
37
|
}));
|
|
46
|
-
|
|
47
38
|
return function createContext() {
|
|
48
39
|
return _ref.apply(this, arguments);
|
|
49
40
|
};
|
|
50
41
|
}();
|
|
51
|
-
|
|
52
42
|
exports.createContext = createContext;
|
|
53
|
-
|
|
54
43
|
var removeContext = /*#__PURE__*/function () {
|
|
55
44
|
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(context) {
|
|
56
45
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
57
|
-
while (1) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
case 3:
|
|
67
|
-
case "end":
|
|
68
|
-
return _context2.stop();
|
|
69
|
-
}
|
|
46
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
47
|
+
case 0:
|
|
48
|
+
_context2.next = 2;
|
|
49
|
+
return _Context.default.remove(context);
|
|
50
|
+
case 2:
|
|
51
|
+
return _context2.abrupt("return", _context2.sent);
|
|
52
|
+
case 3:
|
|
53
|
+
case "end":
|
|
54
|
+
return _context2.stop();
|
|
70
55
|
}
|
|
71
56
|
}, _callee2);
|
|
72
57
|
}));
|
|
73
|
-
|
|
74
58
|
return function removeContext(_x) {
|
|
75
59
|
return _ref2.apply(this, arguments);
|
|
76
60
|
};
|
|
77
61
|
}();
|
|
78
|
-
|
|
79
62
|
exports.removeContext = removeContext;
|
|
80
|
-
|
|
81
63
|
var evalScripts = /*#__PURE__*/function () {
|
|
82
64
|
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(code) {
|
|
83
65
|
var conf,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
66
|
+
ctx,
|
|
67
|
+
resolver,
|
|
68
|
+
_args3 = arguments;
|
|
87
69
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
88
|
-
while (1) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
case "end":
|
|
102
|
-
return _context3.stop();
|
|
103
|
-
}
|
|
70
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
71
|
+
case 0:
|
|
72
|
+
conf = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
|
|
73
|
+
_context3.next = 3;
|
|
74
|
+
return _Context.default.create(conf);
|
|
75
|
+
case 3:
|
|
76
|
+
ctx = _context3.sent;
|
|
77
|
+
// eslint-disable-next-line no-new-func
|
|
78
|
+
resolver = new Function("\n return function({window, location, history, document}){ \n with(window.__CONSOLE_OS_GLOBAL_VARS_) { \n ".concat(code, "\n }\n }//@sourceURL=").concat(conf.name));
|
|
79
|
+
return _context3.abrupt("return", resolver(_objectSpread({}, ctx)));
|
|
80
|
+
case 6:
|
|
81
|
+
case "end":
|
|
82
|
+
return _context3.stop();
|
|
104
83
|
}
|
|
105
84
|
}, _callee3);
|
|
106
85
|
}));
|
|
107
|
-
|
|
108
86
|
return function evalScripts(_x2) {
|
|
109
87
|
return _ref3.apply(this, arguments);
|
|
110
88
|
};
|
|
111
89
|
}();
|
|
112
|
-
|
|
113
90
|
exports.evalScripts = evalScripts;
|
|
@@ -1,46 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.removeEventListener = exports.injectHTMLScriptElement = exports.addEventListener = void 0;
|
|
9
|
-
|
|
10
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
-
|
|
12
9
|
var addEventListener = function addEventListener(el, originEvent) {
|
|
13
10
|
return function (type, listener, options) {
|
|
14
11
|
var listeners = el._listenerMap.get(type) || [];
|
|
15
|
-
|
|
16
12
|
el._listenerMap.set(type, [].concat((0, _toConsumableArray2.default)(listeners), [listener]));
|
|
17
|
-
|
|
18
13
|
return originEvent.apply(el, [type, listener, options]);
|
|
19
14
|
};
|
|
20
15
|
};
|
|
21
|
-
|
|
22
16
|
exports.addEventListener = addEventListener;
|
|
23
|
-
|
|
24
17
|
var removeEventListener = function removeEventListener(el, originEvent) {
|
|
25
18
|
return function (type, listener, options) {
|
|
26
19
|
var storedTypeListeners = el._listenerMap.get(type);
|
|
27
|
-
|
|
28
20
|
if (storedTypeListeners && storedTypeListeners.length && storedTypeListeners.indexOf(listener) !== -1) {
|
|
29
21
|
storedTypeListeners.splice(storedTypeListeners.indexOf(listener), 1);
|
|
30
22
|
}
|
|
31
|
-
|
|
32
23
|
return originEvent.apply(el, [type, listener, options]);
|
|
33
24
|
};
|
|
34
25
|
};
|
|
35
|
-
|
|
36
26
|
exports.removeEventListener = removeEventListener;
|
|
37
27
|
var elProperties = ['innerHTML', 'text', 'innerText'];
|
|
38
|
-
|
|
39
28
|
var injectHTMLScriptElement = function injectHTMLScriptElement(el) {
|
|
40
29
|
el._listenerMap = new Map();
|
|
41
30
|
el.addEventListener = addEventListener(el, el.addEventListener);
|
|
42
|
-
el.removeEventListener = removeEventListener(el, el.removeEventListener);
|
|
31
|
+
el.removeEventListener = removeEventListener(el, el.removeEventListener);
|
|
43
32
|
|
|
33
|
+
// do not redefine property in sandbox
|
|
44
34
|
if (!el._evalScriptInSandbox) {
|
|
45
35
|
elProperties.forEach(function (property) {
|
|
46
36
|
Object.defineProperty(el, property, {
|
|
@@ -48,8 +38,8 @@ var injectHTMLScriptElement = function injectHTMLScriptElement(el) {
|
|
|
48
38
|
return this.scriptText || '';
|
|
49
39
|
},
|
|
50
40
|
set: function set(value) {
|
|
51
|
-
this.scriptText = value;
|
|
52
|
-
|
|
41
|
+
this.scriptText = value;
|
|
42
|
+
// 如果是已经插入到 dom 树里面,则直接执行
|
|
53
43
|
if (el.parentNode) {
|
|
54
44
|
this.ownerContext.evalScript && el.ownerContext.evalScript(value.toString());
|
|
55
45
|
}
|
|
@@ -60,5 +50,4 @@ var injectHTMLScriptElement = function injectHTMLScriptElement(el) {
|
|
|
60
50
|
el._evalScriptInSandbox = true;
|
|
61
51
|
}
|
|
62
52
|
};
|
|
63
|
-
|
|
64
53
|
exports.injectHTMLScriptElement = injectHTMLScriptElement;
|
package/lib/utils/common.js
CHANGED
|
@@ -5,13 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.isBoundedFunction = isBoundedFunction;
|
|
7
7
|
exports.isConstructable = isConstructable;
|
|
8
|
-
|
|
9
8
|
function isConstructable(fn) {
|
|
10
9
|
var classRegex = /^class\b/;
|
|
11
10
|
var constructable = fn.prototype && fn.prototype.constructor === fn && Object.getOwnPropertyNames(fn.prototype).length > 1 || classRegex.test(fn.toString());
|
|
12
11
|
return constructable;
|
|
13
12
|
}
|
|
14
|
-
|
|
15
13
|
function isBoundedFunction(fn) {
|
|
16
14
|
var bounded = fn.name.indexOf('bound ') === 0 && !fn.hasOwnProperty('prototype');
|
|
17
15
|
return bounded;
|
package/lib/utils/credentials.js
CHANGED
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getFetchCredentials = void 0;
|
|
7
|
-
|
|
8
7
|
var getFetchCredentials = function getFetchCredentials(url) {
|
|
9
8
|
return url.includes('console.aliyun.com') ? 'include' : 'omit';
|
|
10
9
|
};
|
|
11
|
-
|
|
12
10
|
exports.getFetchCredentials = getFetchCredentials;
|
|
@@ -4,36 +4,27 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getJsonCallback = exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var getJsonCallback = function getJsonCallback(src) {
|
|
9
8
|
var u;
|
|
10
|
-
|
|
11
9
|
try {
|
|
12
10
|
u = new URL(src);
|
|
13
11
|
} catch (error) {
|
|
14
12
|
return;
|
|
15
13
|
}
|
|
16
|
-
|
|
17
14
|
var sp = u.searchParams;
|
|
18
|
-
|
|
19
15
|
if (!sp) {
|
|
20
16
|
return null;
|
|
21
17
|
}
|
|
22
|
-
|
|
23
18
|
return sp.get('callback') || sp.get('cb');
|
|
24
19
|
};
|
|
25
|
-
|
|
26
20
|
exports.getJsonCallback = getJsonCallback;
|
|
27
|
-
|
|
28
21
|
var injectScriptCallBack = function injectScriptCallBack(scriptEl) {
|
|
29
22
|
setTimeout(function () {
|
|
30
23
|
if (!scriptEl.src) {
|
|
31
24
|
return;
|
|
32
25
|
}
|
|
33
|
-
|
|
34
26
|
var appWindow = scriptEl.ownerContext.window;
|
|
35
27
|
var callbackName = getJsonCallback(scriptEl.src);
|
|
36
|
-
|
|
37
28
|
if (callbackName && typeof appWindow[callbackName] === 'function') {
|
|
38
29
|
window[callbackName] = function () {
|
|
39
30
|
var result = appWindow[callbackName].apply(appWindow, arguments);
|
|
@@ -43,6 +34,5 @@ var injectScriptCallBack = function injectScriptCallBack(scriptEl) {
|
|
|
43
34
|
}
|
|
44
35
|
}, 0);
|
|
45
36
|
};
|
|
46
|
-
|
|
47
37
|
var _default = injectScriptCallBack;
|
|
48
38
|
exports.default = _default;
|
package/lib/utils/isSSR.js
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alicloud/console-os-browser-vm",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.23",
|
|
4
4
|
"description": "browser virtual machine",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
7
7
|
"typings": "index.d.ts",
|
|
8
8
|
"scripts": {
|
|
9
|
-
"
|
|
9
|
+
"prepublishOnly": "npm run clean && npm run build && npm run babel && npm run babel:esm",
|
|
10
10
|
"babel": "breezr build --engine babel",
|
|
11
11
|
"babel:esm": "breezr build --engine babel --es-module",
|
|
12
12
|
"build": "breezr build --engine webpack",
|
package/dist/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.aliOSBrowserVM=e():t.aliOSBrowserVM=e()}(window,function(){return n=[function(t,e,n){t.exports=n(2)},function(t,e,n){t.exports=n(3)},function(e,t,n){e=function(a){"use strict";var u,t=Object.prototype,s=t.hasOwnProperty,e="function"==typeof Symbol?Symbol:{},r=e.iterator||"@@iterator",n=e.asyncIterator||"@@asyncIterator",o=e.toStringTag||"@@toStringTag";function i(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{i({},"")}catch(t){i=function(t,e,n){return t[e]=n}}function c(t,e,n,r){var o,i,a,c,e=e&&e.prototype instanceof v?e:v,e=Object.create(e.prototype),r=new _(r||[]);return e._invoke=(o=t,i=n,a=r,c=f,function(t,e){if(c===h)throw new Error("Generator is already running");if(c===d){if("throw"===t)throw e;return j()}for(a.method=t,a.arg=e;;){var n=a.delegate;if(n){n=function t(e,n){var r=e.iterator[n.method];if(r===u){if(n.delegate=null,"throw"===n.method){if(e.iterator.return&&(n.method="return",n.arg=u,t(e,n),"throw"===n.method))return y;n.method="throw",n.arg=new TypeError("The iterator does not provide a 'throw' method")}return y}r=l(r,e.iterator,n.arg);if("throw"===r.type)return n.method="throw",n.arg=r.arg,n.delegate=null,y;r=r.arg;if(!r)return n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,y;{if(!r.done)return r;n[e.resultName]=r.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=u)}n.delegate=null;return y}(n,a);if(n){if(n===y)continue;return n}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if(c===f)throw c=d,a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);c=h;n=l(o,i,a);if("normal"===n.type){if(c=a.done?d:p,n.arg!==y)return{value:n.arg,done:a.done}}else"throw"===n.type&&(c=d,a.method="throw",a.arg=n.arg)}}),e}function l(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}a.wrap=c;var f="suspendedStart",p="suspendedYield",h="executing",d="completed",y={};function v(){}function m(){}function w(){}var e={},b=(i(e,r,function(){return this}),Object.getPrototypeOf),b=b&&b(b(L([]))),g=(b&&b!==t&&s.call(b,r)&&(e=b),w.prototype=v.prototype=Object.create(e));function O(t){["next","throw","return"].forEach(function(e){i(t,e,function(t){return this._invoke(e,t)})})}function x(a,c){var e;this._invoke=function(n,r){function t(){return new c(function(t,e){!function e(t,n,r,o){var i,t=l(a[t],a,n);if("throw"!==t.type)return i=t.arg,n=i.value,n&&"object"==typeof n&&s.call(n,"__await")?c.resolve(n.__await).then(function(t){e("next",t,r,o)},function(t){e("throw",t,r,o)}):c.resolve(n).then(function(t){i.value=t,r(i)},function(t){return e("throw",t,r,o)});o(t.arg)}(n,r,t,e)})}return e=e?e.then(t,t):t()}}function S(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function _(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(S,this),this.reset(!0)}function L(e){if(e){var n,t=e[r];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return n=-1,t=function t(){for(;++n<e.length;)if(s.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=u,t.done=!0,t},t.next=t}return{next:j}}function j(){return{value:u,done:!0}}return m.prototype=w,i(g,"constructor",w),i(w,"constructor",m),m.displayName=i(w,o,"GeneratorFunction"),a.isGeneratorFunction=function(t){t="function"==typeof t&&t.constructor;return!!t&&(t===m||"GeneratorFunction"===(t.displayName||t.name))},a.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,i(t,o,"GeneratorFunction")),t.prototype=Object.create(g),t},a.awrap=function(t){return{__await:t}},O(x.prototype),i(x.prototype,n,function(){return this}),a.AsyncIterator=x,a.async=function(t,e,n,r,o){void 0===o&&(o=Promise);var i=new x(c(t,e,n,r),o);return a.isGeneratorFunction(e)?i:i.next().then(function(t){return t.done?t.value:i.next()})},O(g),i(g,o,"Generator"),i(g,r,function(){return this}),i(g,"toString",function(){return"[object Generator]"}),a.keys=function(n){var t,r=[];for(t in n)r.push(t);return r.reverse(),function t(){for(;r.length;){var e=r.pop();if(e in n)return t.value=e,t.done=!1,t}return t.done=!0,t}},a.values=L,_.prototype={constructor:_,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=u,this.done=!1,this.delegate=null,this.method="next",this.arg=u,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&s.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=u)},stop:function(){this.done=!0;var t=this.tryEntries[0],t=t.completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(n){if(this.done)throw n;var r=this;function t(t,e){return i.type="throw",i.arg=n,r.next=t,e&&(r.method="next",r.arg=u),!!e}for(var e=this.tryEntries.length-1;0<=e;--e){var o=this.tryEntries[e],i=o.completion;if("root"===o.tryLoc)return t("end");if(o.tryLoc<=this.prev){var a=s.call(o,"catchLoc"),c=s.call(o,"finallyLoc");if(a&&c){if(this.prev<o.catchLoc)return t(o.catchLoc,!0);if(this.prev<o.finallyLoc)return t(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return t(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return t(o.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;0<=n;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&s.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var o=r;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,y):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),y},finish:function(t){for(var e=this.tryEntries.length-1;0<=e;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),E(n),y}},catch:function(t){for(var e=this.tryEntries.length-1;0<=e;--e){var n,r,o=this.tryEntries[e];if(o.tryLoc===t)return n=o.completion,"throw"===n.type&&(r=n.arg,E(o)),r}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:L(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=u),y}},a}(e.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}},function(I,t,e){"use strict";function a(t,e,n){e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n}function u(t,e,n,r,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void n(t)}c.done?e(u):Promise.resolve(u).then(r,o)}function o(c){return function(){var t=this,a=arguments;return new Promise(function(e,n){var r=c.apply(t,a);function o(t){u(r,e,n,o,i,"next",t)}function i(t){u(r,e,n,o,i,"throw",t)}o(void 0)})}}e.r(t),e.d(t,"createContext",function(){return G}),e.d(t,"removeContext",function(){return B}),e.d(t,"evalScripts",function(){return D});var t=e(0),c=e.n(t);function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function l(t){return function(t){if(Array.isArray(t))return r(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(t){var e;try{e=new URL(t)}catch(t){return}return t=e.searchParams,t?t.get("callback")||t.get("cb"):null}function n(){return"undefined"==typeof document}var f=function(t){setTimeout(function(){var e,n;t.src&&(e=t.ownerContext.window,n=s(t.src),n&&"function"==typeof e[n]&&(window[n]=function(){var t=e[n].apply(e,arguments);return window[n]=null,t}))},0)};if(!n()&&"function"==typeof window.Element)for(var i=0,p=["appendChild","insertBefore","append"];i<p.length;i++){var h=p[i],d=window.Element.prototype[h];window.Element.prototype[h]=function(i,a){return function(n){var e=n.ownerContext&&-1===n.ownerContext.allowResources.indexOf(n.src)&&"*"!==n.ownerContext.allowResources;if(n&&n._evalScriptInSandbox&&n.ownerContext&&"SCRIPT"===n.nodeName&&n.src&&e&&!s(n.src))return n.ownerContext.loadScripts(n.src).then(function(){var t=n._listenerMap.get("load"),t=(t&&t.forEach(function(t){t()}),new Event("load"));n.onload&&n.onload(t)}).catch(function(e){console.error(e);var t=n._listenerMap.get("error");t&&t.forEach(function(t){t(e)}),n.onerror&&n.onerror(e)});n&&"SCRIPT"===n.nodeName&&n.ownerContext&&f(n),n&&n.scriptText&&n.ownerContext.evalScript(n.scriptText);for(var t=arguments.length,r=new Array(1<t?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];e=("append"===a&&void 0===n?[]:[n]).concat(r);try{return i.call.apply(i,[this].concat(l(e)))}catch(t){return i.apply(this,e)}}}(d,h)}function y(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function v(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function m(t,e,n){return e&&v(t.prototype,e),n&&v(t,n),t}var w=n()?function(){}:window.addEventListener,b=n()?function(){}:window.removeEventListener,g=["webkitmouseforcedown","webkitmouseforcewillbegin","visibilitychange","error","mousemove","mousedown","mouseup","touchcancel","touchend","touchstart","auxclick","dblclick","pointercancel","pointerdown","pointerup","dragend","dragstart","drop","compositionend","compositionstart","keydown","keypress","keyup","input","textInput","close","cancel","copy","cut","paste","click","change","contextmenu","reset","submit","resize","scroll","foucs","blur"];function O(t){t=t.prototype&&t.prototype.constructor===t&&1<Object.getOwnPropertyNames(t.prototype).length||/^class\b/.test(t.toString());return t}function x(t){t=0===t.name.indexOf("bound ")&&!t.hasOwnProperty("prototype");return t}function S(e){var o,i,a,c;e._listenerMap=new Map,e.addEventListener=(o=e,i=e.addEventListener,function(t,e,n){var r=o._listenerMap.get(t)||[];return o._listenerMap.set(t,[].concat(l(r),[e])),i.apply(o,[t,e,n])}),e.removeEventListener=(a=e,c=e.removeEventListener,function(t,e,n){var r=a._listenerMap.get(t);return r&&r.length&&-1!==r.indexOf(e)&&r.splice(r.indexOf(e),1),c.apply(a,[t,e,n])}),e._evalScriptInSandbox||(j.forEach(function(t){Object.defineProperty(e,t,{get:function(){return this.scriptText||""},set:function(t){this.scriptText=t,e.parentNode&&this.ownerContext.evalScript&&e.ownerContext.evalScript(t.toString())},enumerable:!1})}),e._evalScriptInSandbox=!0)}var E=["setTimeout","setInterval","clearInterval","clearTimeout"],_=["requestAnimationFrame","webkitRequestAnimationFrame","mozRequestAnimationFrame","oRequestAnimationFrame","msRequestAnimationFrame","cancelAnimationFrame","webkitCancelAnimationFrame","mozCancelAnimationFrame","oCancelAnimationFrame","msCancelAnimationFrame"],e=m(function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},c=1<arguments.length?arguments[1]:void 0,n=2<arguments.length?arguments[2]:void 0,u=(y(this,t),[].concat(_,l(e.externals||[]))),s={};return E.forEach(function(t){u.includes(t)||(s[t]=n.contentWindow[t].bind(n.contentWindow))}),new Proxy(n.contentWindow,{set:function(t,e,n){return t[e]=n,s[e]=n,!0},get:function(t,e){if(u.includes(e)){var n=window[e];if("function"!=typeof n||x(n)||O(n))return n;var r,o=n.bind(window);for(r in n)o[r]=n[r];return o}switch(e){case"document":return c.document;case"location":return c.location;case"history":return c.history;case"__CONSOLE_OS_GLOBAL_VARS_":return s;case"addEventListener":return a=c,function(t,e,n){var r=a._listenerMap.get(t)||[];return a._listenerMap.set(t,[].concat(l(r),[e])),-1===g.indexOf(t)?a.baseFrame.addEventListener.apply(a.baseFrame.contentWindow,[t,e,n]):w.apply(window,[t,e,n])};case"removeEventListener":return i=c,function(t,e,n){var r=i._listenerMap.get(t);return r&&r.length&&-1!==r.indexOf(e)&&r.splice(r.indexOf(e),1),-1===g.indexOf(t)?i.baseFrame.removeEventListener.apply(i.baseFrame.contentWindow,[t,e,n]):b.apply(window,[t,e,n])}}var i,a;if(s[e])return s[e];e=t[e];return"function"!=typeof e||x(e)||O(e)?e:e.bind&&e.bind(t)}})}),L=e,j=["innerHTML","text","innerText"];function P(t,e){var n,r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return A(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?A(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length)return r&&(t=r),n=0,e=function(){},{s:e,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:e};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return i=t.done,t},e:function(t){a=!0,o=t},f:function(){try{i||null==r.return||r.return()}finally{if(a)throw o}}}}function A(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var t=m(function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},n=1<arguments.length?arguments[1]:void 0,o=(y(this,t),[]);return new Proxy(document,{set:function(t,e,n){return"cookie"===e?document.cookie=n:t[e]=n,!0},get:function(r,t){switch(t){case"body":return n.body;case"location":return n.location;case"defaultView":return n.window;case"write":case"writeln":return function(){};case"createElement":return function(){var t=(t=document).createElement.apply(t,arguments);return t.ownerContext=n,t.appId=e.id,"SCRIPT"!==t.tagName||e.enableScriptEscape||S(t),t};case"addEventListener":return function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return o.push(e),r.addEventListener.apply(r,e)};case"removeEventListeners":return function(){var t,e=P(o);try{for(e.s();!(t=e.n()).done;){var n=t.value;r.removeEventListener.apply(r,l(n))}}catch(t){e.e(t)}finally{e.f()}}}return"function"==typeof r[t]?r[t].bind&&r[t].bind(r):r[t]}})}),k=t,e=m(function t(r){return y(this,t),new Proxy({},{set:function(t,e,n){return"href"!==e&&(r[e]=n),!0},get:function(t,e){switch(e){case"reload":return function(){return window.location.reload()};case"replace":return function(){};case"toString":return function(){try{return r.toString()}catch(t){return r.href}}}return"function"==typeof r[e]?r[e].bind&&r[e].bind(t):r[e]}})}),C=e,t=m(function t(e,o){if(y(this,t),!e)return o.history;function i(){o.postMessage({type:"".concat(e,":history-change"),data:JSON.parse(JSON.stringify(o.location))},"*")}try{var a=o.history.pushState,c=o.history.replaceState;return o.history.pushState=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=a.apply(o.history,[].concat(e));return i(),r},o.history.replaceState=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=c.apply(o.history,[].concat(e));return i(),r},o.history}catch(t){return}}),R=t;function F(e,t){var n,r=Object.keys(e);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(e),t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)),r}function T(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?F(Object(n),!0).forEach(function(t){a(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):F(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var e=function(){function r(t,e){y(this,r),this.location=new C(e.contentWindow.location),this.history=new R(t.id,e.contentWindow),this.window=new L(t,this,e,location),this.allowResources=t.allowResources||[];var n=t.body;t.disableBody?n=document.body:t.body||(n=document.createElement("body"),document.documentElement.appendChild(n)),this.body=n,this.document=new k(T({enableScriptEscape:!0},t),this,e,location),this.baseFrame=e,this._listenerMap=new Map,this.window.__IS_CONSOLE_OS_CONTEXT__=!0}var e,n;return m(r,[{key:"loadScripts",value:(n=o(c.a.mark(function t(n){var r;return c.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch(n,{credentials:(e=n,e.includes("console.aliyun.com")?"include":"omit")});case 2:return r=t.sent,t.next=5,r.text();case 5:r=t.sent,this.evalScript(r,n);case 7:case"end":return t.stop()}var e},t,this)})),function(t){return n.apply(this,arguments)})},{key:"evalScript",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",t=new Function("\n return function ({window, location, history, document}){ \n with(window.__CONSOLE_OS_GLOBAL_VARS_) {\n try {\n ".concat(t,"\n }\n catch(e) {\n console.log(e)\n }\n }\n }//@ sourceMappingURL=").concat(e));t().call(this.window,T({},this))}},{key:"updateBody",value:function(t){!t&&this.body||(this.body=t)}},{key:"remove",value:function(){this.document.removeEventListeners(),this.baseFrame&&(this.baseFrame.parentNode?this.baseFrame.parentNode.removeChild(this.baseFrame):this.baseFrame.setAttribute("src","about:blank"))}}],[{key:"create",value:function(r){var o=this;return new Promise(function(t){var e=document.createElement("iframe"),n=(e.setAttribute("src",r.url||"/api.json"),e.style.cssText="position: absolute; top: -20000px; width: 1px; height: 1px;",r.id&&e.setAttribute("data-id",r.id),(null==(n=document.documentElement)?void 0:n.getElementsByTagName("body")[0])||document.body);if(n.appendChild(e),"about:blank"===r.url)return t(new o(r,e));e.onload=function(){t(new o(r,e))}})}},{key:"remove",value:(e=o(c.a.mark(function t(e){return c.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:e.remove&&e.remove();case 1:case"end":return t.stop()}},t)})),function(t){return e.apply(this,arguments)})}]),r}(),M=e;function N(e,t){var n,r=Object.keys(e);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(e),t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)),r}var G=function(){var t=o(c.a.mark(function t(){var e,n=arguments;return c.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return e=0<n.length&&void 0!==n[0]?n[0]:{},t.next=3,M.create(e);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}},t)}));return function(){return t.apply(this,arguments)}}(),B=function(){var e=o(c.a.mark(function t(e){return c.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,M.remove(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(t){return e.apply(this,arguments)}}(),D=function(){var e=o(c.a.mark(function t(e){var n,r,o,i=arguments;return c.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n=1<i.length&&void 0!==i[1]?i[1]:{},t.next=3,M.create(n);case 3:return r=t.sent,o=new Function("\n return function({window, location, history, document}){ \n with(window.__CONSOLE_OS_GLOBAL_VARS_) { \n ".concat(e,"\n }\n }//@sourceURL=").concat(n.name)),t.abrupt("return",o(function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?N(Object(n),!0).forEach(function(t){a(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):N(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}({},r)));case 6:case"end":return t.stop()}},t)}));return function(t){return e.apply(this,arguments)}}()}],r={},o.m=n,o.c=r,o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)o.d(n,r,function(t){return e[t]}.bind(null,r));return n},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="/",o(o.s=1);function o(t){if(r[t])return r[t].exports;var e=r[t]={i:t,l:!1,exports:{}};return n[t].call(e.exports,e,e.exports,o),e.l=!0,e.exports}var n,r});
|