@alicloud/console-os-browser-vm 1.4.35 → 1.4.37-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 +1 -1
- package/es/Document.js +0 -1
- package/es/Location.js +8 -9
- package/es/Window.js +0 -11
- package/es/events.js +0 -1
- package/es/utils/HTMLScriptElement.js +10 -4
- package/lib/Context.js +1 -1
- package/lib/Document.js +0 -1
- package/lib/Location.js +8 -9
- package/lib/Window.js +0 -11
- package/lib/events.js +0 -1
- package/lib/utils/HTMLScriptElement.js +10 -4
- package/package.json +1 -2
package/es/Context.js
CHANGED
|
@@ -22,7 +22,7 @@ var Context = /*#__PURE__*/function () {
|
|
|
22
22
|
if (disableBody) {
|
|
23
23
|
body = document.body;
|
|
24
24
|
} else if (!body) {
|
|
25
|
-
body = document.createElement('
|
|
25
|
+
body = document.createElement('div');
|
|
26
26
|
document.documentElement.appendChild(body);
|
|
27
27
|
}
|
|
28
28
|
this.body = body;
|
package/es/Document.js
CHANGED
|
@@ -12,7 +12,6 @@ import { injectHTMLScriptElement } from './utils/HTMLScriptElement';
|
|
|
12
12
|
var Document = /*#__PURE__*/_createClass(function Document() {
|
|
13
13
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
14
14
|
var context = arguments.length > 1 ? arguments[1] : undefined;
|
|
15
|
-
var frame = arguments.length > 2 ? arguments[2] : undefined;
|
|
16
15
|
_classCallCheck(this, Document);
|
|
17
16
|
var eventListeners = [];
|
|
18
17
|
return new Proxy(document, {
|
package/es/Location.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
2
2
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
3
|
function isAboutBlank(loc) {
|
|
4
|
-
return loc && loc.href
|
|
4
|
+
return loc && loc.href.startsWith('about:blank');
|
|
5
5
|
}
|
|
6
6
|
var Location = /*#__PURE__*/_createClass(function Location(location) {
|
|
7
7
|
_classCallCheck(this, Location);
|
|
@@ -32,14 +32,13 @@ var Location = /*#__PURE__*/_createClass(function Location(location) {
|
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
34
|
default:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return location[name];
|
|
35
|
+
if (typeof location[name] === 'function') {
|
|
36
|
+
return location[name].bind && location[name].bind(target);
|
|
37
|
+
} else if (isAboutBlank(location)) {
|
|
38
|
+
return window.location[name];
|
|
39
|
+
} else {
|
|
40
|
+
return location[name];
|
|
41
|
+
}
|
|
43
42
|
}
|
|
44
43
|
}
|
|
45
44
|
});
|
package/es/Window.js
CHANGED
|
@@ -9,17 +9,6 @@ import { isConstructable, isBoundedFunction } from './utils/common';
|
|
|
9
9
|
var globalFnName = ['setTimeout', 'setInterval', 'clearInterval', 'clearTimeout'];
|
|
10
10
|
var globalVars = ['location', 'history'];
|
|
11
11
|
var defaultExternals = ['requestAnimationFrame', 'webkitRequestAnimationFrame', 'mozRequestAnimationFrame', 'oRequestAnimationFrame', 'msRequestAnimationFrame', 'cancelAnimationFrame', 'webkitCancelAnimationFrame', 'mozCancelAnimationFrame', 'oCancelAnimationFrame', 'msCancelAnimationFrame', 'matchMedia', 'getSelection', 'open'];
|
|
12
|
-
function getContextWindow(context) {
|
|
13
|
-
var descriptor = Object.getOwnPropertyDescriptor(context, 'window');
|
|
14
|
-
if (descriptor) {
|
|
15
|
-
descriptor.configurable = true;
|
|
16
|
-
var hasGetter = Object.prototype.hasOwnProperty.call(descriptor, 'get');
|
|
17
|
-
if (!hasGetter) {
|
|
18
|
-
descriptor.writable = true;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return context.window;
|
|
22
|
-
}
|
|
23
12
|
var Window = /*#__PURE__*/_createClass(function Window() {
|
|
24
13
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
25
14
|
var context = arguments.length > 1 ? arguments[1] : undefined;
|
package/es/events.js
CHANGED
|
@@ -2,7 +2,6 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
|
2
2
|
import { isSSR } from './utils/isSSR';
|
|
3
3
|
var rawAddEventListener = !isSSR() ? window.addEventListener : function () {};
|
|
4
4
|
var rawRemoveEventListener = !isSSR() ? window.removeEventListener : function () {};
|
|
5
|
-
;
|
|
6
5
|
export 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'];
|
|
7
6
|
export var addEventListener = function addEventListener(context) {
|
|
8
7
|
return function (type, listener, options) {
|
|
@@ -1,22 +1,28 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
-
export var addEventListener = function addEventListener(el,
|
|
2
|
+
export var addEventListener = function addEventListener(el, originEventListener) {
|
|
3
3
|
return function (type, listener, options) {
|
|
4
4
|
var listeners = el._listenerMap.get(type) || [];
|
|
5
5
|
el._listenerMap.set(type, [].concat(_toConsumableArray(listeners), [listener]));
|
|
6
|
-
return
|
|
6
|
+
return originEventListener.apply(el, [type, listener, options]);
|
|
7
7
|
};
|
|
8
8
|
};
|
|
9
|
-
export var removeEventListener = function removeEventListener(el,
|
|
9
|
+
export var removeEventListener = function removeEventListener(el, originEventListener) {
|
|
10
10
|
return function (type, listener, options) {
|
|
11
11
|
var storedTypeListeners = el._listenerMap.get(type);
|
|
12
12
|
if (storedTypeListeners && storedTypeListeners.length && storedTypeListeners.indexOf(listener) !== -1) {
|
|
13
13
|
storedTypeListeners.splice(storedTypeListeners.indexOf(listener), 1);
|
|
14
14
|
}
|
|
15
|
-
return
|
|
15
|
+
return originEventListener.apply(el, [type, listener, options]);
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
18
|
var elProperties = ['innerHTML', 'text', 'innerText'];
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 劫持 script element 上的事件监听
|
|
22
|
+
* @param {*} el
|
|
23
|
+
*/
|
|
19
24
|
export var injectHTMLScriptElement = function injectHTMLScriptElement(el) {
|
|
25
|
+
// _listenerMap 记录 element 上的事件监听,当被拦截通过 fetch 加载时,执行记录的回调函数
|
|
20
26
|
el._listenerMap = new Map();
|
|
21
27
|
el.addEventListener = addEventListener(el, el.addEventListener);
|
|
22
28
|
el.removeEventListener = removeEventListener(el, el.removeEventListener);
|
package/lib/Context.js
CHANGED
|
@@ -29,7 +29,7 @@ var Context = /*#__PURE__*/function () {
|
|
|
29
29
|
if (disableBody) {
|
|
30
30
|
body = document.body;
|
|
31
31
|
} else if (!body) {
|
|
32
|
-
body = document.createElement('
|
|
32
|
+
body = document.createElement('div');
|
|
33
33
|
document.documentElement.appendChild(body);
|
|
34
34
|
}
|
|
35
35
|
this.body = body;
|
package/lib/Document.js
CHANGED
|
@@ -18,7 +18,6 @@ var _HTMLScriptElement = require("./utils/HTMLScriptElement");
|
|
|
18
18
|
var Document = /*#__PURE__*/(0, _createClass2.default)(function Document() {
|
|
19
19
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
20
20
|
var context = arguments.length > 1 ? arguments[1] : undefined;
|
|
21
|
-
var frame = arguments.length > 2 ? arguments[2] : undefined;
|
|
22
21
|
(0, _classCallCheck2.default)(this, Document);
|
|
23
22
|
var eventListeners = [];
|
|
24
23
|
return new Proxy(document, {
|
package/lib/Location.js
CHANGED
|
@@ -8,7 +8,7 @@ exports.default = void 0;
|
|
|
8
8
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
9
9
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
10
|
function isAboutBlank(loc) {
|
|
11
|
-
return loc && loc.href
|
|
11
|
+
return loc && loc.href.startsWith('about:blank');
|
|
12
12
|
}
|
|
13
13
|
var Location = /*#__PURE__*/(0, _createClass2.default)(function Location(location) {
|
|
14
14
|
(0, _classCallCheck2.default)(this, Location);
|
|
@@ -39,14 +39,13 @@ var Location = /*#__PURE__*/(0, _createClass2.default)(function Location(locatio
|
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
default:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return location[name];
|
|
42
|
+
if (typeof location[name] === 'function') {
|
|
43
|
+
return location[name].bind && location[name].bind(target);
|
|
44
|
+
} else if (isAboutBlank(location)) {
|
|
45
|
+
return window.location[name];
|
|
46
|
+
} else {
|
|
47
|
+
return location[name];
|
|
48
|
+
}
|
|
50
49
|
}
|
|
51
50
|
}
|
|
52
51
|
});
|
package/lib/Window.js
CHANGED
|
@@ -17,17 +17,6 @@ var _common = require("./utils/common");
|
|
|
17
17
|
var globalFnName = ['setTimeout', 'setInterval', 'clearInterval', 'clearTimeout'];
|
|
18
18
|
var globalVars = ['location', 'history'];
|
|
19
19
|
var defaultExternals = ['requestAnimationFrame', 'webkitRequestAnimationFrame', 'mozRequestAnimationFrame', 'oRequestAnimationFrame', 'msRequestAnimationFrame', 'cancelAnimationFrame', 'webkitCancelAnimationFrame', 'mozCancelAnimationFrame', 'oCancelAnimationFrame', 'msCancelAnimationFrame', 'matchMedia', 'getSelection', 'open'];
|
|
20
|
-
function getContextWindow(context) {
|
|
21
|
-
var descriptor = Object.getOwnPropertyDescriptor(context, 'window');
|
|
22
|
-
if (descriptor) {
|
|
23
|
-
descriptor.configurable = true;
|
|
24
|
-
var hasGetter = Object.prototype.hasOwnProperty.call(descriptor, 'get');
|
|
25
|
-
if (!hasGetter) {
|
|
26
|
-
descriptor.writable = true;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return context.window;
|
|
30
|
-
}
|
|
31
20
|
var Window = /*#__PURE__*/(0, _createClass2.default)(function Window() {
|
|
32
21
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
33
22
|
var context = arguments.length > 1 ? arguments[1] : undefined;
|
package/lib/events.js
CHANGED
|
@@ -9,7 +9,6 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
|
|
|
9
9
|
var _isSSR = require("./utils/isSSR");
|
|
10
10
|
var rawAddEventListener = !(0, _isSSR.isSSR)() ? window.addEventListener : function () {};
|
|
11
11
|
var rawRemoveEventListener = !(0, _isSSR.isSSR)() ? window.removeEventListener : function () {};
|
|
12
|
-
;
|
|
13
12
|
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'];
|
|
14
13
|
exports.domEventsListeningTo = domEventsListeningTo;
|
|
15
14
|
var addEventListener = function addEventListener(context) {
|
|
@@ -6,26 +6,32 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.removeEventListener = exports.injectHTMLScriptElement = exports.addEventListener = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
-
var addEventListener = function addEventListener(el,
|
|
9
|
+
var addEventListener = function addEventListener(el, originEventListener) {
|
|
10
10
|
return function (type, listener, options) {
|
|
11
11
|
var listeners = el._listenerMap.get(type) || [];
|
|
12
12
|
el._listenerMap.set(type, [].concat((0, _toConsumableArray2.default)(listeners), [listener]));
|
|
13
|
-
return
|
|
13
|
+
return originEventListener.apply(el, [type, listener, options]);
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
16
|
exports.addEventListener = addEventListener;
|
|
17
|
-
var removeEventListener = function removeEventListener(el,
|
|
17
|
+
var removeEventListener = function removeEventListener(el, originEventListener) {
|
|
18
18
|
return function (type, listener, options) {
|
|
19
19
|
var storedTypeListeners = el._listenerMap.get(type);
|
|
20
20
|
if (storedTypeListeners && storedTypeListeners.length && storedTypeListeners.indexOf(listener) !== -1) {
|
|
21
21
|
storedTypeListeners.splice(storedTypeListeners.indexOf(listener), 1);
|
|
22
22
|
}
|
|
23
|
-
return
|
|
23
|
+
return originEventListener.apply(el, [type, listener, options]);
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
26
|
exports.removeEventListener = removeEventListener;
|
|
27
27
|
var elProperties = ['innerHTML', 'text', 'innerText'];
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 劫持 script element 上的事件监听
|
|
31
|
+
* @param {*} el
|
|
32
|
+
*/
|
|
28
33
|
var injectHTMLScriptElement = function injectHTMLScriptElement(el) {
|
|
34
|
+
// _listenerMap 记录 element 上的事件监听,当被拦截通过 fetch 加载时,执行记录的回调函数
|
|
29
35
|
el._listenerMap = new Map();
|
|
30
36
|
el.addEventListener = addEventListener(el, el.addEventListener);
|
|
31
37
|
el.removeEventListener = removeEventListener(el, el.removeEventListener);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alicloud/console-os-browser-vm",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.37-alpha.0",
|
|
4
4
|
"description": "browser virtual machine",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -26,7 +26,6 @@
|
|
|
26
26
|
"scripts": {
|
|
27
27
|
"babel": "breezr build --engine babel",
|
|
28
28
|
"babel:esm": "breezr build --engine babel --es-module",
|
|
29
|
-
"build": "breezr build --engine webpack",
|
|
30
29
|
"storybook": "breezr start-storybook",
|
|
31
30
|
"test": "breezr test:unit --coverage --env jsdom",
|
|
32
31
|
"clean": "rm -rf es build lib yarn.lock"
|