@alicloud/console-os-browser-vm 1.3.4-alpha.1 → 1.3.4

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/index.js CHANGED
@@ -1 +1 @@
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=l,function(t,e){if(c===h)throw new Error("Generator is already running");if(c===d){if("throw"===t)throw e;return L()}for(a.method=t,a.arg=e;;){var n=a.delegate;if(n){var r=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}var r=f(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(r){if(r===y)continue;return r}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if(c===l)throw c=d,a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);c=h;r=f(o,i,a);if("normal"===r.type){if(c=a.done?d:p,r.arg!==y)return{value:r.arg,done:a.done}}else"throw"===r.type&&(c=d,a.method="throw",a.arg=r.arg)}}),e}function f(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}a.wrap=c;var l="suspendedStart",p="suspendedYield",h="executing",d="completed",y={};function v(){}function m(){}function w(){}var b={};i(b,r,function(){return this});e=Object.getPrototypeOf,e=e&&e(e(j([])));e&&e!==t&&s.call(e,r)&&(b=e);var g=w.prototype=v.prototype=Object.create(b);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){t=f(a[t],a,n);if("throw"!==t.type){var i=t.arg,n=i.value;return 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 j(e){if(e){var t=e[r];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var 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};return t.next=t}}return{next:L}}function L(){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=j,_.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=this.tryEntries[e];if(n.tryLoc===t){var r,o=n.completion;return"throw"===o.type&&(r=o.arg,E(n)),r}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:j(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(t,e,n){"use strict";function a(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}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)})}}n.r(e),n.d(e,"createContext",function(){return G}),n.d(e,"removeContext",function(){return B}),n.d(e,"evalScripts",function(){return D});function i(t){try{e=new URL(t)}catch(t){return}var e=e.searchParams;return e?e.get("callback")||e.get("cb"):null}function r(){return"undefined"==typeof document}function c(o){return function(n){if(n&&n._evalScriptInSandbox&&n.ownerContext&&"SCRIPT"===n.nodeName&&n.src&&function(t,e){if(Array.isArray(t)){t=t.find(function(t){return"string"==typeof t?t===e:t instanceof RegExp&&!!e.match(t)});return!!t}return!1}(n.ownerContext.allowResources,n.src)&&!i(n.src))return n.ownerContext.loadScripts(n.src).then(function(){var t=n._listenerMap.get("load");t&&t.forEach(function(t){t()}),n.onload&&n.onload()}).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,e=new Array(1<t?t-1:0),r=1;r<t;r++)e[r-1]=arguments[r];try{return o.call.apply(o,[this,n].concat(e))}catch(t){return o.apply(this,[n].concat(e))}}}var e=n(0),s=n.n(e),f=function(t){setTimeout(function(){var e,n;t.src&&(e=t.ownerContext.window,n=i(t.src),n&&"function"==typeof e[n]&&(window[n]=function(){var t=e[n].apply(e,arguments);return window[n]=null,t}))},0)};if(!r()&&"function"==typeof window.Element)for(var l=0,p=["appendChild","insertBefore","append"];l<p.length;l++){var h=p[l],d=window.Element.prototype[h];window.Element.prototype[h]=c(d)}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),Object.defineProperty(t,"prototype",{writable:!1}),t}function w(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 b(t){return function(t){if(Array.isArray(t))return w(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return w(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)?w(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.")}()}var g=r()?function(){}:window.addEventListener,O=r()?function(){}:window.removeEventListener;function x(t){t=t.prototype&&t.prototype.constructor===t&&1<Object.getOwnPropertyNames(t.prototype).length||/^class\b/.test(t.toString());return t}function S(t){t=0===t.name.indexOf("bound ")&&!t.hasOwnProperty("prototype");return t}function E(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(b(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])}),P.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})})}var _=["setTimeout","setInterval","clearInterval","clearTimeout"],j=["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;y(this,t);var u=[].concat(j,b(e.externals||[])),s={},f=new Proxy(n.contentWindow,{set:function(t,e,n){return s[e]=n,!0},has:function(t,e){return"eval"!==e&&e in t},get:function(t,e){if(u.includes(e)){if(e in s)return s[e];var n=window[e];if("function"!=typeof n||S(n)||x(n))return n;var r,o=n.bind(window);for(r in n)o[r]=n[r];return o}switch(e){case"window":return f;case"document":return c.document;case"location":return c.location;case"history":return c.history;case"__CONSOLE_OS_GLOBAL_VARS_":return f;case"addEventListener":return a=c,function(t,e,n){var r=a._listenerMap.get(t)||[];return a._listenerMap.set(t,[].concat(b(r),[e])),g.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),O.apply(window,[t,e,n])}}var i,a;if(e in s)return s[e];if(e in t){e=window[e];return"function"!=typeof e||S(e)||x(e)?e:e.bind&&e.bind(window)}}});return _.forEach(function(t){u.includes(t)||(f[t]=n.contentWindow[t].bind(n.contentWindow))}),f}),L=e,P=["innerHTML","text","innerText"];function A(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return C(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)?C(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,e=function(){};return{s:e,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},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(){n=n.call(t)},n:function(){var t=n.next();return i=t.done,t},e:function(t){a=!0,o=t},f:function(){try{i||null==n.return||n.return()}finally{if(a)throw o}}}}function C(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 e=m(function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},n=1<arguments.length?arguments[1]:void 0;y(this,t);var o=[];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||(t._evalScriptInSandbox=!0,E(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=A(o);try{for(e.s();!(t=e.n()).done;){var n=t.value;r.removeEventListener.apply(r,b(n))}}catch(t){e.e(t)}finally{e.f()}}}return"function"==typeof r[t]?r[t].bind&&r[t].bind(r):r[t]}})}),k=e,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":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]}})}),T=e,e=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))},"*")}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}),F=e;function M(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 N(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?M(Object(n),!0).forEach(function(t){a(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):M(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 T(e.contentWindow.location),this.history=new F(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(N({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(s.a.mark(function t(n){var r;return s.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]:"",e=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));e().call(this.window,N({},this))}},{key:"updateBody",value:function(t){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(n){var r=this;return new Promise(function(t){var e=document.createElement("iframe");if(e.setAttribute("src",n.url||"/api.json"),e.style.cssText="position: absolute; top: -20000px; width: 100%; height: 1px;",document.body.appendChild(e),"about:blank"===n.url)return t(new r(n,e));e.onload=function(){t(new r(n,e))}})}},{key:"remove",value:(e=o(s.a.mark(function t(e){return s.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}(),R=e;function I(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(s.a.mark(function t(){var e,n=arguments;return s.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,R.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(s.a.mark(function t(e){return s.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,R.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(s.a.mark(function t(e){var n,r,o,i=arguments;return s.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,R.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?I(Object(n),!0).forEach(function(t){a(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):I(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});
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){var r=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}var 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(r){if(r===y)continue;return r}}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;r=l(o,i,a);if("normal"===r.type){if(c=a.done?d:p,r.arg!==y)return{value:r.arg,done:a.done}}else"throw"===r.type&&(c=d,a.method="throw",a.arg=r.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 b={};i(b,r,function(){return this});e=Object.getPrototypeOf,e=e&&e(e(L([])));e&&e!==t&&s.call(e,r)&&(b=e);var g=w.prototype=v.prototype=Object.create(b);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){t=l(a[t],a,n);if("throw"!==t.type){var i=t.arg,n=i.value;return 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 t=e[r];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var 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};return 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=this.tryEntries[e];if(n.tryLoc===t){var r,o=n.completion;return"throw"===o.type&&(r=o.arg,E(n)),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(t,e,n){"use strict";function a(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}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)})}}n.r(e),n.d(e,"createContext",function(){return G}),n.d(e,"removeContext",function(){return B}),n.d(e,"evalScripts",function(){return D});function i(t){try{e=new URL(t)}catch(t){return}var e=e.searchParams;return e?e.get("callback")||e.get("cb"):null}function r(){return"undefined"==typeof document}var e=n(0),c=n.n(e),s=function(t){setTimeout(function(){var e,n;t.src&&(e=t.ownerContext.window,n=i(t.src),n&&"function"==typeof e[n]&&(window[n]=function(){var t=e[n].apply(e,arguments);return window[n]=null,t}))},0)};if(!r()&&"function"==typeof window.Element)for(var l=0,f=["appendChild","insertBefore","append"];l<f.length;l++){var p=f[l],h=window.Element.prototype[p];window.Element.prototype[p]=function(o){return function(n){if(n&&n._evalScriptInSandbox&&n.ownerContext&&"SCRIPT"===n.nodeName&&n.src&&-1===n.ownerContext.allowResources.indexOf(n.src)&&!i(n.src))return n.ownerContext.loadScripts(n.src).then(function(){var t=n._listenerMap.get("load");t&&t.forEach(function(t){t()}),n.onload&&n.onload()}).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&&s(n),n&&n.scriptText&&n.ownerContext.evalScript(n.scriptText);for(var t=arguments.length,e=new Array(1<t?t-1:0),r=1;r<t;r++)e[r-1]=arguments[r];try{return o.call.apply(o,[this,n].concat(e))}catch(t){return o.apply(this,[n].concat(e))}}}(h)}function d(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function y(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 v(t,e,n){return e&&y(t.prototype,e),n&&y(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function m(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 w(t){return function(t){if(Array.isArray(t))return m(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return m(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)?m(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.")}()}var b=r()?function(){}:window.addEventListener,g=r()?function(){}:window.removeEventListener,O=["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 x(t){t=t.prototype&&t.prototype.constructor===t&&1<Object.getOwnPropertyNames(t.prototype).length||/^class\b/.test(t.toString());return t}function S(t){t=0===t.name.indexOf("bound ")&&!t.hasOwnProperty("prototype");return t}function E(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(w(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])}),P.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})})}var _=["setTimeout","setInterval","clearInterval","clearTimeout"],L=["requestAnimationFrame","webkitRequestAnimationFrame","mozRequestAnimationFrame","oRequestAnimationFrame","msRequestAnimationFrame","cancelAnimationFrame","webkitCancelAnimationFrame","mozCancelAnimationFrame","oCancelAnimationFrame","msCancelAnimationFrame"],e=v(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;d(this,t);var u=[].concat(L,w(e.externals||[])),s={};return _.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||S(n)||x(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(w(r),[e])),-1===O.indexOf(t)?a.baseFrame.addEventListener.apply(a.baseFrame.contentWindow,[t,e,n]):b.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===O.indexOf(t)?i.baseFrame.removeEventListener.apply(i.baseFrame.contentWindow,[t,e,n]):g.apply(window,[t,e,n])}}var i,a;if(s[e])return s[e];e=t[e];return"function"!=typeof e||S(e)||x(e)?e:e.bind&&e.bind(t)}})}),j=e,P=["innerHTML","text","innerText"];function k(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=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){n&&(t=n);var r=0,e=function(){};return{s:e,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},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(){n=n.call(t)},n:function(){var t=n.next();return i=t.done,t},e:function(t){a=!0,o=t},f:function(){try{i||null==n.return||n.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 e=v(function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},n=1<arguments.length?arguments[1]:void 0;d(this,t);var o=[];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||(t._evalScriptInSandbox=!0,E(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=k(o);try{for(e.s();!(t=e.n()).done;){var n=t.value;r.removeEventListener.apply(r,w(n))}}catch(t){e.e(t)}finally{e.f()}}}return"function"==typeof r[t]?r[t].bind&&r[t].bind(r):r[t]}})}),C=e,e=v(function t(r){return d(this,t),new Proxy({},{set:function(t,e,n){return"href"===e||(r[e]=n),!0},get:function(t,e){switch(e){case"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]}})}),F=e,e=v(function t(e,o){if(d(this,t),!e)return o.history;function i(){o.postMessage({type:"".concat(e,":history-change"),data:JSON.parse(JSON.stringify(o.location))},"*")}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}),T=e;function M(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 N(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?M(Object(n),!0).forEach(function(t){a(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):M(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var e=function(){function r(t,e){d(this,r),this.location=new F(e.contentWindow.location),this.history=new T(t.id,e.contentWindow),this.window=new j(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 C(N({enableScriptEscape:!0},t),this,e,location),this.baseFrame=e,this._listenerMap=new Map,this.window.__IS_CONSOLE_OS_CONTEXT__=!0}var e,n;return v(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]:"",e=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));e().call(this.window,N({},this))}},{key:"updateBody",value:function(t){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(n){var r=this;return new Promise(function(t){var e=document.createElement("iframe");if(e.setAttribute("src",n.url||"/api.json"),e.style.cssText="position: absolute; top: -20000px; width: 100%; height: 1px;",document.body.appendChild(e),"about:blank"===n.url)return t(new r(n,e));e.onload=function(){t(new r(n,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}(),I=e;function R(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,I.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,I.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,I.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?R(Object(n),!0).forEach(function(t){a(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):R(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});
package/es/Elements.js CHANGED
@@ -7,23 +7,10 @@
7
7
  import injectScriptCallBack, { getJsonCallback } from './utils/injectScriptCallBack';
8
8
  import { isSSR } from './utils/isSSR';
9
9
 
10
- var isAllowed = function isAllowed(allowResources, url) {
11
- if (Array.isArray(allowResources)) {
12
- var result = allowResources.find(function (rule) {
13
- if (typeof rule === 'string') return rule === url;
14
- if (rule instanceof RegExp) return !!url.match(rule);
15
- return false;
16
- });
17
- return !!result;
18
- }
19
-
20
- return false;
21
- };
22
-
23
10
  var makeElInjector = function makeElInjector(originMethod) {
24
11
  return function (el) {
25
12
  // 如果不在 BrowserVM 的白名单内,尝试通过 context 的 load script 通过 xhr 获取脚本内容,并在沙箱中执行
26
- if (el && el._evalScriptInSandbox && el.ownerContext && el.nodeName === 'SCRIPT' && el.src && isAllowed(el.ownerContext.allowResources, el.src) && !getJsonCallback(el.src)) {
13
+ if (el && el._evalScriptInSandbox && el.ownerContext && el.nodeName === 'SCRIPT' && el.src && el.ownerContext.allowResources.indexOf(el.src) === -1 && !getJsonCallback(el.src)) {
27
14
  return el.ownerContext.loadScripts(el.src).then(function () {
28
15
  var fns = el._listenerMap.get('load');
29
16
 
package/es/Window.js CHANGED
@@ -8,11 +8,7 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
8
8
  import { addEventListener, removeEventListener } from './events';
9
9
  import { isConstructable, isBoundedFunction } from './utils/common';
10
10
  var globalFnName = ['setTimeout', 'setInterval', 'clearInterval', 'clearTimeout'];
11
- var defaultExternals = ['requestAnimationFrame', 'webkitRequestAnimationFrame', 'mozRequestAnimationFrame', 'oRequestAnimationFrame', 'msRequestAnimationFrame', 'cancelAnimationFrame', 'webkitCancelAnimationFrame', 'mozCancelAnimationFrame', 'oCancelAnimationFrame', 'msCancelAnimationFrame']; // 1. if var in externals, read it from cache or window
12
- // 2. if var in hack list, read it from iframe's window
13
- // 3. if var in cache which wrote by micro app, read it from cache
14
- // 4. if var is native, read it from window
15
- // 5. otherwise return undefined
11
+ var defaultExternals = ['requestAnimationFrame', 'webkitRequestAnimationFrame', 'mozRequestAnimationFrame', 'oRequestAnimationFrame', 'msRequestAnimationFrame', 'cancelAnimationFrame', 'webkitCancelAnimationFrame', 'mozCancelAnimationFrame', 'oCancelAnimationFrame', 'msCancelAnimationFrame'];
16
12
 
17
13
  var Window = /*#__PURE__*/_createClass(function Window() {
18
14
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -22,21 +18,22 @@ var Window = /*#__PURE__*/_createClass(function Window() {
22
18
  _classCallCheck(this, Window);
23
19
 
24
20
  var externals = [].concat(defaultExternals, _toConsumableArray(options.externals || []));
25
- var cache = {};
21
+ var __CONSOLE_OS_GLOBAL_VARS_ = {};
22
+ globalFnName.forEach(function (name) {
23
+ if (externals.includes(name)) {
24
+ return;
25
+ }
26
26
 
27
- var __CONSOLE_OS_GLOBAL_VARS_ = new Proxy(frame.contentWindow, {
27
+ __CONSOLE_OS_GLOBAL_VARS_[name] = frame.contentWindow[name].bind(frame.contentWindow);
28
+ });
29
+ return new Proxy(frame.contentWindow, {
28
30
  set: function set(target, name, value) {
29
- cache[name] = value;
31
+ target[name] = value;
32
+ __CONSOLE_OS_GLOBAL_VARS_[name] = value;
30
33
  return true;
31
34
  },
32
- // eval will lose it context in with
33
- has: function has(target, name) {
34
- if (name === 'eval') return false;
35
- return name in target;
36
- },
37
35
  get: function get(target, name) {
38
36
  if (externals.includes(name)) {
39
- if (name in cache) return cache[name];
40
37
  var windowValue = window[name];
41
38
 
42
39
  if (typeof windowValue === 'function' && !isBoundedFunction(windowValue) && !isConstructable(windowValue)) {
@@ -50,13 +47,9 @@ var Window = /*#__PURE__*/_createClass(function Window() {
50
47
  } else {
51
48
  return windowValue;
52
49
  }
53
- } // hack
54
-
50
+ }
55
51
 
56
52
  switch (name) {
57
- case 'window':
58
- return __CONSOLE_OS_GLOBAL_VARS_;
59
-
60
53
  case 'document':
61
54
  return context.document;
62
55
 
@@ -76,33 +69,19 @@ var Window = /*#__PURE__*/_createClass(function Window() {
76
69
  return removeEventListener(context);
77
70
  }
78
71
 
79
- if (name in cache) {
80
- return cache[name];
81
- } // target has it when it is native
82
-
83
-
84
- if (name in target) {
85
- var value = window[name];
72
+ if (__CONSOLE_OS_GLOBAL_VARS_[name]) {
73
+ return __CONSOLE_OS_GLOBAL_VARS_[name];
74
+ }
86
75
 
87
- if (typeof value === 'function' && !isBoundedFunction(value) && !isConstructable(value)) {
88
- return value.bind && value.bind(window);
89
- }
76
+ var value = target[name];
90
77
 
78
+ if (typeof value === 'function' && !isBoundedFunction(value) && !isConstructable(value)) {
79
+ return value.bind && value.bind(target);
80
+ } else {
91
81
  return value;
92
82
  }
93
-
94
- return undefined;
95
- }
96
- });
97
-
98
- globalFnName.forEach(function (name) {
99
- if (externals.includes(name)) {
100
- return;
101
83
  }
102
-
103
- __CONSOLE_OS_GLOBAL_VARS_[name] = frame.contentWindow[name].bind(frame.contentWindow);
104
84
  });
105
- return __CONSOLE_OS_GLOBAL_VARS_;
106
85
  });
107
86
 
108
87
  export default Window;
package/es/events.js CHANGED
@@ -1,23 +1,18 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
2
  import { isSSR } from './utils/isSSR';
3
3
  var rawAddEventListener = !isSSR() ? window.addEventListener : function () {};
4
- var rawRemoveEventListener = !isSSR() ? window.removeEventListener : function () {}; // export const domEventsListeningTo = [
5
- // 'webkitmouseforcedown', 'webkitmouseforcewillbegin', 'visibilitychange', 'error',
6
- // 'mousemove', 'mousedown', 'mouseup', 'touchcancel', 'touchend', 'touchstart', 'auxclick',
7
- // 'dblclick', 'pointercancel', 'pointerdown', 'pointerup', 'dragend', 'dragstart', 'drop',
8
- // 'compositionend', 'compositionstart', 'keydown', 'keypress', 'keyup', 'input', 'textInput',
9
- // 'close', 'cancel', 'copy', 'cut', 'paste', 'click', 'change', 'contextmenu', 'reset', 'submit',
10
- // 'resize', 'scroll', 'foucs', 'blur',
11
- // ];
12
-
4
+ var rawRemoveEventListener = !isSSR() ? window.removeEventListener : function () {};
5
+ ;
6
+ 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'];
13
7
  export var addEventListener = function addEventListener(context) {
14
8
  return function (type, listener, options) {
15
9
  var listeners = context._listenerMap.get(type) || [];
16
10
 
17
- context._listenerMap.set(type, [].concat(_toConsumableArray(listeners), [listener])); // if (domEventsListeningTo.indexOf(type) === -1) {
18
- // return context.baseFrame.addEventListener.apply(context.baseFrame.contentWindow, [type, listener, options]);
19
- // }
11
+ context._listenerMap.set(type, [].concat(_toConsumableArray(listeners), [listener]));
20
12
 
13
+ if (domEventsListeningTo.indexOf(type) === -1) {
14
+ return context.baseFrame.addEventListener.apply(context.baseFrame.contentWindow, [type, listener, options]);
15
+ }
21
16
 
22
17
  return rawAddEventListener.apply(window, [type, listener, options]);
23
18
  };
@@ -28,10 +23,11 @@ export var removeEventListener = function removeEventListener(context) {
28
23
 
29
24
  if (storedTypeListeners && storedTypeListeners.length && storedTypeListeners.indexOf(listener) !== -1) {
30
25
  storedTypeListeners.splice(storedTypeListeners.indexOf(listener), 1);
31
- } // if (domEventsListeningTo.indexOf(type) === -1) {
32
- // return context.baseFrame.removeEventListener.apply(context.baseFrame.contentWindow, [type, listener, options]);
33
- // }
26
+ }
34
27
 
28
+ if (domEventsListeningTo.indexOf(type) === -1) {
29
+ return context.baseFrame.removeEventListener.apply(context.baseFrame.contentWindow, [type, listener, options]);
30
+ }
35
31
 
36
32
  return rawRemoveEventListener.apply(window, [type, listener, options]);
37
33
  };
package/index.d.ts CHANGED
@@ -16,7 +16,7 @@ export interface ContextOption {
16
16
  url?: string;
17
17
  id?: string;
18
18
  disableBody?: boolean;
19
- allowResources?: string[];
19
+ allowResources?: Array<string | RegExp>;
20
20
  enableScriptEscape?: boolean;
21
21
  }
22
22
 
package/lib/Elements.js CHANGED
@@ -16,23 +16,10 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
16
16
  * @forwardCompatibleTo 2019085
17
17
  * @createAt 2019085
18
18
  */
19
- var isAllowed = function isAllowed(allowResources, url) {
20
- if (Array.isArray(allowResources)) {
21
- var result = allowResources.find(function (rule) {
22
- if (typeof rule === 'string') return rule === url;
23
- if (rule instanceof RegExp) return !!url.match(rule);
24
- return false;
25
- });
26
- return !!result;
27
- }
28
-
29
- return false;
30
- };
31
-
32
19
  var makeElInjector = function makeElInjector(originMethod) {
33
20
  return function (el) {
34
21
  // 如果不在 BrowserVM 的白名单内,尝试通过 context 的 load script 通过 xhr 获取脚本内容,并在沙箱中执行
35
- if (el && el._evalScriptInSandbox && el.ownerContext && el.nodeName === 'SCRIPT' && el.src && isAllowed(el.ownerContext.allowResources, el.src) && !(0, _injectScriptCallBack.getJsonCallback)(el.src)) {
22
+ if (el && el._evalScriptInSandbox && el.ownerContext && el.nodeName === 'SCRIPT' && el.src && el.ownerContext.allowResources.indexOf(el.src) === -1 && !(0, _injectScriptCallBack.getJsonCallback)(el.src)) {
36
23
  return el.ownerContext.loadScripts(el.src).then(function () {
37
24
  var fns = el._listenerMap.get('load');
38
25
 
package/lib/Window.js CHANGED
@@ -21,33 +21,29 @@ var _common = require("./utils/common");
21
21
  * Window.js
22
22
  */
23
23
  var globalFnName = ['setTimeout', 'setInterval', 'clearInterval', 'clearTimeout'];
24
- var defaultExternals = ['requestAnimationFrame', 'webkitRequestAnimationFrame', 'mozRequestAnimationFrame', 'oRequestAnimationFrame', 'msRequestAnimationFrame', 'cancelAnimationFrame', 'webkitCancelAnimationFrame', 'mozCancelAnimationFrame', 'oCancelAnimationFrame', 'msCancelAnimationFrame']; // 1. if var in externals, read it from cache or window
25
- // 2. if var in hack list, read it from iframe's window
26
- // 3. if var in cache which wrote by micro app, read it from cache
27
- // 4. if var is native, read it from window
28
- // 5. otherwise return undefined
29
-
24
+ var defaultExternals = ['requestAnimationFrame', 'webkitRequestAnimationFrame', 'mozRequestAnimationFrame', 'oRequestAnimationFrame', 'msRequestAnimationFrame', 'cancelAnimationFrame', 'webkitCancelAnimationFrame', 'mozCancelAnimationFrame', 'oCancelAnimationFrame', 'msCancelAnimationFrame'];
30
25
  var Window = /*#__PURE__*/(0, _createClass2.default)(function Window() {
31
26
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
32
27
  var context = arguments.length > 1 ? arguments[1] : undefined;
33
28
  var frame = arguments.length > 2 ? arguments[2] : undefined;
34
29
  (0, _classCallCheck2.default)(this, Window);
35
30
  var externals = [].concat(defaultExternals, (0, _toConsumableArray2.default)(options.externals || []));
36
- var cache = {};
31
+ var __CONSOLE_OS_GLOBAL_VARS_ = {};
32
+ globalFnName.forEach(function (name) {
33
+ if (externals.includes(name)) {
34
+ return;
35
+ }
37
36
 
38
- var __CONSOLE_OS_GLOBAL_VARS_ = new Proxy(frame.contentWindow, {
37
+ __CONSOLE_OS_GLOBAL_VARS_[name] = frame.contentWindow[name].bind(frame.contentWindow);
38
+ });
39
+ return new Proxy(frame.contentWindow, {
39
40
  set: function set(target, name, value) {
40
- cache[name] = value;
41
+ target[name] = value;
42
+ __CONSOLE_OS_GLOBAL_VARS_[name] = value;
41
43
  return true;
42
44
  },
43
- // eval will lose it context in with
44
- has: function has(target, name) {
45
- if (name === 'eval') return false;
46
- return name in target;
47
- },
48
45
  get: function get(target, name) {
49
46
  if (externals.includes(name)) {
50
- if (name in cache) return cache[name];
51
47
  var windowValue = window[name];
52
48
 
53
49
  if (typeof windowValue === 'function' && !(0, _common.isBoundedFunction)(windowValue) && !(0, _common.isConstructable)(windowValue)) {
@@ -61,13 +57,9 @@ var Window = /*#__PURE__*/(0, _createClass2.default)(function Window() {
61
57
  } else {
62
58
  return windowValue;
63
59
  }
64
- } // hack
65
-
60
+ }
66
61
 
67
62
  switch (name) {
68
- case 'window':
69
- return __CONSOLE_OS_GLOBAL_VARS_;
70
-
71
63
  case 'document':
72
64
  return context.document;
73
65
 
@@ -87,33 +79,19 @@ var Window = /*#__PURE__*/(0, _createClass2.default)(function Window() {
87
79
  return (0, _events.removeEventListener)(context);
88
80
  }
89
81
 
90
- if (name in cache) {
91
- return cache[name];
92
- } // target has it when it is native
93
-
94
-
95
- if (name in target) {
96
- var value = window[name];
82
+ if (__CONSOLE_OS_GLOBAL_VARS_[name]) {
83
+ return __CONSOLE_OS_GLOBAL_VARS_[name];
84
+ }
97
85
 
98
- if (typeof value === 'function' && !(0, _common.isBoundedFunction)(value) && !(0, _common.isConstructable)(value)) {
99
- return value.bind && value.bind(window);
100
- }
86
+ var value = target[name];
101
87
 
88
+ if (typeof value === 'function' && !(0, _common.isBoundedFunction)(value) && !(0, _common.isConstructable)(value)) {
89
+ return value.bind && value.bind(target);
90
+ } else {
102
91
  return value;
103
92
  }
104
-
105
- return undefined;
106
- }
107
- });
108
-
109
- globalFnName.forEach(function (name) {
110
- if (externals.includes(name)) {
111
- return;
112
93
  }
113
-
114
- __CONSOLE_OS_GLOBAL_VARS_[name] = frame.contentWindow[name].bind(frame.contentWindow);
115
94
  });
116
- return __CONSOLE_OS_GLOBAL_VARS_;
117
95
  });
118
96
  var _default = Window;
119
97
  exports.default = _default;
package/lib/events.js CHANGED
@@ -5,30 +5,27 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.removeEventListener = exports.addEventListener = void 0;
8
+ exports.removeEventListener = exports.domEventsListeningTo = exports.addEventListener = void 0;
9
9
 
10
10
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
11
 
12
12
  var _isSSR = require("./utils/isSSR");
13
13
 
14
14
  var rawAddEventListener = !(0, _isSSR.isSSR)() ? window.addEventListener : function () {};
15
- var rawRemoveEventListener = !(0, _isSSR.isSSR)() ? window.removeEventListener : function () {}; // export const domEventsListeningTo = [
16
- // 'webkitmouseforcedown', 'webkitmouseforcewillbegin', 'visibilitychange', 'error',
17
- // 'mousemove', 'mousedown', 'mouseup', 'touchcancel', 'touchend', 'touchstart', 'auxclick',
18
- // 'dblclick', 'pointercancel', 'pointerdown', 'pointerup', 'dragend', 'dragstart', 'drop',
19
- // 'compositionend', 'compositionstart', 'keydown', 'keypress', 'keyup', 'input', 'textInput',
20
- // 'close', 'cancel', 'copy', 'cut', 'paste', 'click', 'change', 'contextmenu', 'reset', 'submit',
21
- // 'resize', 'scroll', 'foucs', 'blur',
22
- // ];
15
+ var rawRemoveEventListener = !(0, _isSSR.isSSR)() ? window.removeEventListener : function () {};
16
+ ;
17
+ 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
+ exports.domEventsListeningTo = domEventsListeningTo;
23
19
 
24
20
  var addEventListener = function addEventListener(context) {
25
21
  return function (type, listener, options) {
26
22
  var listeners = context._listenerMap.get(type) || [];
27
23
 
28
- context._listenerMap.set(type, [].concat((0, _toConsumableArray2.default)(listeners), [listener])); // if (domEventsListeningTo.indexOf(type) === -1) {
29
- // return context.baseFrame.addEventListener.apply(context.baseFrame.contentWindow, [type, listener, options]);
30
- // }
24
+ context._listenerMap.set(type, [].concat((0, _toConsumableArray2.default)(listeners), [listener]));
31
25
 
26
+ if (domEventsListeningTo.indexOf(type) === -1) {
27
+ return context.baseFrame.addEventListener.apply(context.baseFrame.contentWindow, [type, listener, options]);
28
+ }
32
29
 
33
30
  return rawAddEventListener.apply(window, [type, listener, options]);
34
31
  };
@@ -42,10 +39,11 @@ var removeEventListener = function removeEventListener(context) {
42
39
 
43
40
  if (storedTypeListeners && storedTypeListeners.length && storedTypeListeners.indexOf(listener) !== -1) {
44
41
  storedTypeListeners.splice(storedTypeListeners.indexOf(listener), 1);
45
- } // if (domEventsListeningTo.indexOf(type) === -1) {
46
- // return context.baseFrame.removeEventListener.apply(context.baseFrame.contentWindow, [type, listener, options]);
47
- // }
42
+ }
48
43
 
44
+ if (domEventsListeningTo.indexOf(type) === -1) {
45
+ return context.baseFrame.removeEventListener.apply(context.baseFrame.contentWindow, [type, listener, options]);
46
+ }
49
47
 
50
48
  return rawRemoveEventListener.apply(window, [type, listener, options]);
51
49
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alicloud/console-os-browser-vm",
3
- "version": "1.3.4-alpha.1",
3
+ "version": "1.3.4",
4
4
  "description": "browser virtual machine",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
package/es/v2/Context.js DELETED
@@ -1,10 +0,0 @@
1
- import _createClass from "@babel/runtime/helpers/esm/createClass";
2
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
- import Stage from './stage';
4
-
5
- var Context = /*#__PURE__*/_createClass(function Context() {
6
- _classCallCheck(this, Context);
7
-
8
- // this.location = '1';
9
- this.stage = new Stage();
10
- });
@@ -1,22 +0,0 @@
1
- import _createClass from "@babel/runtime/helpers/esm/createClass";
2
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
-
4
- var DocumentProxy = /*#__PURE__*/_createClass(function DocumentProxy(options, context) {
5
- _classCallCheck(this, DocumentProxy);
6
-
7
- return new Proxy(document, {
8
- set: function set(target, name, value) {
9
- switch (name) {
10
- case 'cookie':
11
- document.cookie = value;
12
- break;
13
-
14
- default:
15
- target[name] = value;
16
- }
17
- },
18
- get: function get() {}
19
- });
20
- });
21
-
22
- export default DocumentProxy;
package/es/v2/factory.js DELETED
File without changes
@@ -1,35 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
-
4
- var IframeManager = /*#__PURE__*/function () {
5
- function IframeManager() {
6
- _classCallCheck(this, IframeManager);
7
-
8
- this.map = new Map();
9
- this.baseFrame = IframeManager.createIframe();
10
- } // iframe dom 节点被删除时,会丢失上下文
11
-
12
-
13
- _createClass(IframeManager, [{
14
- key: "getIframe",
15
- value: function getIframe() {}
16
- }, {
17
- key: "remove",
18
- value: function remove() {
19
- if (!key) return false;
20
- }
21
- }], [{
22
- key: "createIframe",
23
- value: function createIframe(key, src) {
24
- var iframe = document.createElement('iframe');
25
- iframe.setAttribute('src', src || 'about:blank');
26
- iframe.style.cssText = 'position: absolute; top: -20000px; width: 1px; height: 1px;';
27
- document.body.appendChild(iframe);
28
- return iframe; // TODO: 监听 iframe 被删除的 case
29
- }
30
- }]);
31
-
32
- return IframeManager;
33
- }();
34
-
35
- export default new IframeManager();
@@ -1,46 +0,0 @@
1
- import _createClass from "@babel/runtime/helpers/esm/createClass";
2
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
-
4
- var HistoryProxy = /*#__PURE__*/_createClass(function HistoryProxy(id, win) {
5
- _classCallCheck(this, HistoryProxy);
6
-
7
- var originalHistory = win.history;
8
-
9
- if (!id) {
10
- return originalHistory;
11
- }
12
-
13
- var postMessage = function postMessage() {
14
- win.postMessage({
15
- type: "".concat(id, ":history-change"),
16
- data: JSON.parse(JSON.stringify(win.location))
17
- }, '*');
18
- };
19
-
20
- var originalPushState = originalHistory.pushState.bind(originalHistory);
21
- var originalReplaceState = originalHistory.replaceState.bind(originalHistory);
22
-
23
- originalHistory.pushState = function () {
24
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
25
- args[_key] = arguments[_key];
26
- }
27
-
28
- var returnValue = originalPushState.apply(originalHistory, [].concat(args));
29
- postMessage();
30
- return returnValue;
31
- };
32
-
33
- originalHistory.replaceState = function () {
34
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
35
- args[_key2] = arguments[_key2];
36
- }
37
-
38
- var returnValue = originalReplaceState.apply(originalHistory, [].concat(args));
39
- postMessage();
40
- return returnValue;
41
- };
42
-
43
- return originalHistory;
44
- });
45
-
46
- export default HistoryProxy;
package/es/v2/index.js DELETED
@@ -1,36 +0,0 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
- import _regeneratorRuntime from "@babel/runtime/regenerator";
3
- export var createContext = /*#__PURE__*/function () {
4
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
5
- return _regeneratorRuntime.wrap(function _callee$(_context) {
6
- while (1) {
7
- switch (_context.prev = _context.next) {
8
- case 0:
9
- case "end":
10
- return _context.stop();
11
- }
12
- }
13
- }, _callee);
14
- }));
15
-
16
- return function createContext() {
17
- return _ref.apply(this, arguments);
18
- };
19
- }();
20
- export var removeContext = /*#__PURE__*/function () {
21
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
22
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
23
- while (1) {
24
- switch (_context2.prev = _context2.next) {
25
- case 0:
26
- case "end":
27
- return _context2.stop();
28
- }
29
- }
30
- }, _callee2);
31
- }));
32
-
33
- return function removeContext() {
34
- return _ref2.apply(this, arguments);
35
- };
36
- }();
@@ -1,52 +0,0 @@
1
- import _createClass from "@babel/runtime/helpers/esm/createClass";
2
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
-
4
- var LocationProxy = /*#__PURE__*/_createClass(function LocationProxy(location) {
5
- _classCallCheck(this, LocationProxy);
6
-
7
- return new Proxy({}, {
8
- set: function set(target, name, value) {
9
- switch (name) {
10
- case 'href':
11
- break;
12
-
13
- default:
14
- // eslint-disable-next-line no-param-reassign
15
- location[name] = value;
16
- }
17
-
18
- return true;
19
- },
20
- get: function get(target, name) {
21
- switch (name) {
22
- case 'reload':
23
- return function () {};
24
-
25
- case 'replace':
26
- return function () {};
27
-
28
- case 'toString':
29
- return function () {
30
- try {
31
- return location.toString();
32
- } catch (e) {
33
- return location.href;
34
- }
35
- };
36
-
37
- default:
38
- break;
39
- }
40
-
41
- var locProperty = location[name];
42
-
43
- if (typeof locProperty === 'function') {
44
- return locProperty.bind && locProperty.bind(target);
45
- }
46
-
47
- return locProperty;
48
- }
49
- });
50
- });
51
-
52
- export default LocationProxy;
package/es/v2/stage.js DELETED
@@ -1,17 +0,0 @@
1
- import _createClass from "@babel/runtime/helpers/esm/createClass";
2
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
-
4
- var Stage = /*#__PURE__*/_createClass(function Stage() {
5
- _classCallCheck(this, Stage);
6
-
7
- return new Proxy({}, {
8
- set: function set(target, key, value) {
9
- target[key] = value;
10
- },
11
- get: function get(target, key) {
12
- return target[key];
13
- }
14
- });
15
- });
16
-
17
- export { Stage as default };
@@ -1,49 +0,0 @@
1
- import _createClass from "@babel/runtime/helpers/esm/createClass";
2
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
- import DocumentProxy from './documentProxy';
4
- import HistoryProxy from './historyProxy';
5
- import LocationProxy from './locationProxy';
6
- a = 100;
7
-
8
- var WindowProxy = /*#__PURE__*/_createClass(function WindowProxy(options, context, win) {
9
- _classCallCheck(this, WindowProxy);
10
-
11
- var _options$externals = options.externals,
12
- externals = _options$externals === void 0 ? [] : _options$externals;
13
- var document = new DocumentProxy();
14
- var history = new HistoryProxy();
15
- var location = new LocationProxy();
16
- return new Proxy(win, {
17
- set: function set(target, name, value) {
18
- target[name] = value;
19
- return true;
20
- },
21
- get: function get(target, name) {
22
- if (externals.includes(name)) {
23
- return window[name];
24
- }
25
-
26
- switch (name) {
27
- case 'document':
28
- return document;
29
-
30
- case 'location':
31
- return location;
32
-
33
- case 'history':
34
- return history;
35
-
36
- default:
37
- break;
38
- // case 'addEventListener':
39
- // return addEventListener(context);
40
- // case 'removeEventListener':
41
- // return removeEventListener(context);
42
- }
43
-
44
- return target[name];
45
- }
46
- });
47
- });
48
-
49
- export default WindowProxy;
package/lib/v2/Context.js DELETED
@@ -1,15 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
6
-
7
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
8
-
9
- var _stage = _interopRequireDefault(require("./stage"));
10
-
11
- var Context = /*#__PURE__*/(0, _createClass2.default)(function Context() {
12
- (0, _classCallCheck2.default)(this, Context);
13
- // this.location = '1';
14
- this.stage = new _stage.default();
15
- });
@@ -1,31 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
-
10
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
-
12
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
-
14
- var DocumentProxy = /*#__PURE__*/(0, _createClass2.default)(function DocumentProxy(options, context) {
15
- (0, _classCallCheck2.default)(this, DocumentProxy);
16
- return new Proxy(document, {
17
- set: function set(target, name, value) {
18
- switch (name) {
19
- case 'cookie':
20
- document.cookie = value;
21
- break;
22
-
23
- default:
24
- target[name] = value;
25
- }
26
- },
27
- get: function get() {}
28
- });
29
- });
30
- var _default = DocumentProxy;
31
- exports.default = _default;
package/lib/v2/factory.js DELETED
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,45 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
-
10
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
-
12
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
-
14
- var IframeManager = /*#__PURE__*/function () {
15
- function IframeManager() {
16
- (0, _classCallCheck2.default)(this, IframeManager);
17
- this.map = new Map();
18
- this.baseFrame = IframeManager.createIframe();
19
- } // iframe dom 节点被删除时,会丢失上下文
20
-
21
-
22
- (0, _createClass2.default)(IframeManager, [{
23
- key: "getIframe",
24
- value: function getIframe() {}
25
- }, {
26
- key: "remove",
27
- value: function remove() {
28
- if (!key) return false;
29
- }
30
- }], [{
31
- key: "createIframe",
32
- value: function createIframe(key, src) {
33
- var iframe = document.createElement('iframe');
34
- iframe.setAttribute('src', src || 'about:blank');
35
- iframe.style.cssText = 'position: absolute; top: -20000px; width: 1px; height: 1px;';
36
- document.body.appendChild(iframe);
37
- return iframe; // TODO: 监听 iframe 被删除的 case
38
- }
39
- }]);
40
- return IframeManager;
41
- }();
42
-
43
- var _default = new IframeManager();
44
-
45
- exports.default = _default;
@@ -1,55 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
-
10
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
-
12
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
-
14
- var HistoryProxy = /*#__PURE__*/(0, _createClass2.default)(function HistoryProxy(id, win) {
15
- (0, _classCallCheck2.default)(this, HistoryProxy);
16
- var originalHistory = win.history;
17
-
18
- if (!id) {
19
- return originalHistory;
20
- }
21
-
22
- var postMessage = function postMessage() {
23
- win.postMessage({
24
- type: "".concat(id, ":history-change"),
25
- data: JSON.parse(JSON.stringify(win.location))
26
- }, '*');
27
- };
28
-
29
- var originalPushState = originalHistory.pushState.bind(originalHistory);
30
- var originalReplaceState = originalHistory.replaceState.bind(originalHistory);
31
-
32
- originalHistory.pushState = function () {
33
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
34
- args[_key] = arguments[_key];
35
- }
36
-
37
- var returnValue = originalPushState.apply(originalHistory, [].concat(args));
38
- postMessage();
39
- return returnValue;
40
- };
41
-
42
- originalHistory.replaceState = function () {
43
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
44
- args[_key2] = arguments[_key2];
45
- }
46
-
47
- var returnValue = originalReplaceState.apply(originalHistory, [].concat(args));
48
- postMessage();
49
- return returnValue;
50
- };
51
-
52
- return originalHistory;
53
- });
54
- var _default = HistoryProxy;
55
- exports.default = _default;
package/lib/v2/index.js DELETED
@@ -1,52 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.removeContext = exports.createContext = void 0;
9
-
10
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
-
12
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
-
14
- var createContext = /*#__PURE__*/function () {
15
- var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
16
- return _regenerator.default.wrap(function _callee$(_context) {
17
- while (1) {
18
- switch (_context.prev = _context.next) {
19
- case 0:
20
- case "end":
21
- return _context.stop();
22
- }
23
- }
24
- }, _callee);
25
- }));
26
-
27
- return function createContext() {
28
- return _ref.apply(this, arguments);
29
- };
30
- }();
31
-
32
- exports.createContext = createContext;
33
-
34
- var removeContext = /*#__PURE__*/function () {
35
- var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
36
- return _regenerator.default.wrap(function _callee2$(_context2) {
37
- while (1) {
38
- switch (_context2.prev = _context2.next) {
39
- case 0:
40
- case "end":
41
- return _context2.stop();
42
- }
43
- }
44
- }, _callee2);
45
- }));
46
-
47
- return function removeContext() {
48
- return _ref2.apply(this, arguments);
49
- };
50
- }();
51
-
52
- exports.removeContext = removeContext;
@@ -1,61 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
-
10
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
-
12
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
-
14
- var LocationProxy = /*#__PURE__*/(0, _createClass2.default)(function LocationProxy(location) {
15
- (0, _classCallCheck2.default)(this, LocationProxy);
16
- return new Proxy({}, {
17
- set: function set(target, name, value) {
18
- switch (name) {
19
- case 'href':
20
- break;
21
-
22
- default:
23
- // eslint-disable-next-line no-param-reassign
24
- location[name] = value;
25
- }
26
-
27
- return true;
28
- },
29
- get: function get(target, name) {
30
- switch (name) {
31
- case 'reload':
32
- return function () {};
33
-
34
- case 'replace':
35
- return function () {};
36
-
37
- case 'toString':
38
- return function () {
39
- try {
40
- return location.toString();
41
- } catch (e) {
42
- return location.href;
43
- }
44
- };
45
-
46
- default:
47
- break;
48
- }
49
-
50
- var locProperty = location[name];
51
-
52
- if (typeof locProperty === 'function') {
53
- return locProperty.bind && locProperty.bind(target);
54
- }
55
-
56
- return locProperty;
57
- }
58
- });
59
- });
60
- var _default = LocationProxy;
61
- exports.default = _default;
package/lib/v2/stage.js DELETED
@@ -1,25 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
-
10
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
-
12
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
-
14
- var Stage = /*#__PURE__*/(0, _createClass2.default)(function Stage() {
15
- (0, _classCallCheck2.default)(this, Stage);
16
- return new Proxy({}, {
17
- set: function set(target, key, value) {
18
- target[key] = value;
19
- },
20
- get: function get(target, key) {
21
- return target[key];
22
- }
23
- });
24
- });
25
- exports.default = Stage;
@@ -1,61 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
-
10
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
-
12
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
-
14
- var _documentProxy = _interopRequireDefault(require("./documentProxy"));
15
-
16
- var _historyProxy = _interopRequireDefault(require("./historyProxy"));
17
-
18
- var _locationProxy = _interopRequireDefault(require("./locationProxy"));
19
-
20
- a = 100;
21
- var WindowProxy = /*#__PURE__*/(0, _createClass2.default)(function WindowProxy(options, context, win) {
22
- (0, _classCallCheck2.default)(this, WindowProxy);
23
- var _options$externals = options.externals,
24
- externals = _options$externals === void 0 ? [] : _options$externals;
25
- var document = new _documentProxy.default();
26
- var history = new _historyProxy.default();
27
- var location = new _locationProxy.default();
28
- return new Proxy(win, {
29
- set: function set(target, name, value) {
30
- target[name] = value;
31
- return true;
32
- },
33
- get: function get(target, name) {
34
- if (externals.includes(name)) {
35
- return window[name];
36
- }
37
-
38
- switch (name) {
39
- case 'document':
40
- return document;
41
-
42
- case 'location':
43
- return location;
44
-
45
- case 'history':
46
- return history;
47
-
48
- default:
49
- break;
50
- // case 'addEventListener':
51
- // return addEventListener(context);
52
- // case 'removeEventListener':
53
- // return removeEventListener(context);
54
- }
55
-
56
- return target[name];
57
- }
58
- });
59
- });
60
- var _default = WindowProxy;
61
- exports.default = _default;