Socket
Socket
Sign inDemoInstall

@micro-zoe/micro-app

Package Overview
Dependencies
2
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.4 to 0.2.5

11

lib/index.d.ts

@@ -81,7 +81,12 @@ /// <reference path="../typings/global.d.ts" />

/**
* Format log msg
* @param msg log msg
* format error log
* @param msg message
*/
export function formatLogMessage(msg: string): string;
export function logError(msg: unknown, ...rest: any[]): void;
/**
* format warn log
* @param msg message
*/
export function logWarn(msg: unknown, ...rest: any[]): void;
/**
* async execution

@@ -88,0 +93,0 @@ * @param fn callback

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=new Function("return window")(),t=new Function("return document")();function n(e){return"string"==typeof e?`[micro-app] ${e}`:e}function o(e,...t){Promise.resolve().then(e.bind(null,...t))}function r(e){return e.startsWith("//")?`${location.protocol}${e}`:e}function i(e){if("string"!=typeof e||!e)return"";try{const{origin:t,pathname:n}=new URL(r(e));if(/\.html$/.test(n))return`${t}${n}`;const o=`${t}${n}/`.replace(/\/\/$/,"/");return/^https?:\/\//.test(o)?o:""}catch(e){return console.error("[micro-app]",e),""}}function s(e){if(/\.html$/.test(e)){const t=e.split("/");return t.pop(),t.join("/")+"/"}return e}function c(e,t){return/^((((ht|f)tps?)|file):)?\/\//.test(e)?e:(t=r(t),new URL(e,s(t)).toString())}function a(e,t,n,o){let r=0;function i(){++r===e.length&&o&&o()}e.forEach(((e,o)=>{"[object Promise]"===toString.call(e)?e.then((e=>{t({data:e,index:o}),i()})).catch((e=>{n({error:e,index:o}),i()})):(t({data:e,index:o}),i())}))}const l=window.requestIdleCallback||function(e){const t=Date.now();return setTimeout((function(){e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-t))})}),1)};let u=null;function p(e){u=e}function d(){return u}function h(){p(null)}function m(){return/Safari/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)}function f(e){return"function"==typeof e}function y(e,n){const o=t.createElement(e,n);return o.__MICRO_APP_NAME__&&delete o.__MICRO_APP_NAME__,o}var b,g,E,w;function _(e,t){const{selectorText:n,cssText:o}=e;if(/^((html[\s>~,]+body)|(html|body|:root))$/.test(n))return o.replace(/^((html[\s>~,]+body)|(html|body|:root))/,t);if("*"===n)return o.replace("*",`${t} *`);const r=/(^|\s+)((html[\s>~]+body)|(html|body|:root))(?=[\s>~]+|$)/;return o.replace(/^[\s\S]+{/,(e=>e.replace(/(^|,)([^,]+)/g,((e,n,o)=>r.test(o)?e.replace(r,t):`${n} ${t} ${o.replace(/^\s*/,"")}`))))}function v(e,t,n,o){return e.replace(/url\(["']?([^)"']+)["']?\)/gm,((e,i)=>{if(/^data:/.test(i))return e;if(/^(https?:)?\/\//.test(i)){if(!m())return e;{const t=i.replace(/^https?:/,"");if(-1!==n.indexOf(t))return e;i=i.replace(window.location.origin,"")}}return/^((\.\.?\/)|[^/])/.test(i)&&o&&(t=function(e){const t=e.split("/");return t.pop(),r(t.join("/")+"/")}(o)),`url("${c(i,t)}")`}))}function A(e,t,n){const o=O(Array.from(e.cssRules),t);return`@${n} ${e.conditionText} {${o}}`}function O(e,t){let n="";for(const o of e)switch(o.type){case w.STYLE_RULE:n+=_(o,t);break;case w.MEDIA_RULE:n+=A(o,t,"media");break;case w.SUPPORTS_RULE:n+=A(o,t,"supports");break;default:n+=o.cssText}return n.replace(/^\s+/,"")}function N(e,t,n,o,r,i){var s,c;let a=v(O(Array.from(null!==(c=null===(s=e.sheet)||void 0===s?void 0:s.cssRules)&&void 0!==c?c:[]),o),r,n,i);m()&&(a=a.replace(/([;{]\s*content:\s*)([^\s"][^";}]*)/gm,((e,t,n)=>"none"===n||/^(url\()|(counter\()|(attr\()|(open-quote)|(close-quote)/.test(n)?e:`${t}"${n}"`))),t.textContent=a}!function(e){e.NAME="name",e.URL="url"}(b||(b={})),function(e){e.NOT_LOADED="NOT_LOADED",e.LOADING_SOURCE_CODE="LOADING_SOURCE_CODE",e.LOAD_SOURCE_FINISHED="LOAD_SOURCE_FINISHED",e.LOAD_SOURCE_ERROR="LOAD_SOURCE_ERROR",e.MOUNTING="MOUNTING",e.MOUNTED="MOUNTED",e.UNMOUNT="UNMOUNT"}(g||(g={})),function(e){e.CREATED="created",e.BEFOREMOUNT="beforemount",e.MOUNTED="mounted",e.UNMOUNT="unmount",e.ERROR="error"}(E||(E={})),function(e){e[e.STYLE_RULE=1]="STYLE_RULE",e[e.MEDIA_RULE=4]="MEDIA_RULE",e[e.SUPPORTS_RULE=12]="SUPPORTS_RULE"}(w||(w={}));let C=t.body.querySelector("#micro-app-template-style");function S(e,n){const o=Fe.get(n);if(null==o?void 0:o.scopecss){const r=`${Ee.tagName}[name=${n}]`;if(C||(C=y("style"),C.setAttribute("id","micro-app-template-style"),t.body.appendChild(C),C.sheet.disabled=!0),e.textContent)C.textContent=e.textContent,N(C,e,e.textContent,r,o.url,e.linkpath),C.textContent="";else{const t=new MutationObserver((function(){var n,i;t.disconnect(),!e.textContent&&(null===(i=null===(n=e.sheet)||void 0===n?void 0:n.cssRules)||void 0===i?void 0:i.length)||e.hasAttribute("data-styled")||N(e,e,e.textContent,r,o.url,e.linkpath)}));t.observe(e,{childList:!0})}}return e}function D(e,t){Object.defineProperties(e,{currentTarget:{get:()=>t},srcElement:{get:()=>t},target:{get:()=>t}})}function P(e){const t=new CustomEvent("load");D(t,e),"function"==typeof e.onload?e.onload(t):e.dispatchEvent(t)}function R(e){const t=new CustomEvent("error");D(t,e),"function"==typeof e.onerror?e.onerror(t):e.dispatchEvent(t)}const M=new Map;function L(e,t,n,o,r=!1){const i=e.getAttribute("rel");let s=e.getAttribute("href"),a=null;if("stylesheet"===i&&s){if(s=c(s,n.url),r)return{url:s,info:{code:"",isGlobal:e.hasAttribute("global")}};{a=document.createComment(`the link with href=${s} move to micro-app-head as style element`);const t=document.createComment(`placeholder for link with href=${s}`);o.appendChild(t),n.source.links.set(s,{code:"",placeholder:t,isGlobal:e.hasAttribute("global")})}}else s&&e.setAttribute("href",c(s,n.url));return r?{replaceComment:a}:a?t.replaceChild(a,e):void 0}function x(e,t,n){const o=Array.from(t.source.links.entries()),r=[];for(const[e]of o){const n=M.get(e);n?r.push(n):r.push(we(e,t.name))}a(r,(e=>{!function(e,t,n,o,r){t.isGlobal&&!M.has(e)&&M.set(e,n);const i=y("style");i.textContent=n,i.linkpath=e,o.replaceChild(S(i,r.name),t.placeholder),t.placeholder=null,t.code=n}(o[e.index][0],o[e.index][1],e.data,n,t)}),(e=>{console.error("[micro-app]",e)}),(()=>{t.onLoad(e)}))}const T=new Map,U="noModule"in document.createElement("script");function j(e,t,n,o=!1){let r=null,i=e.getAttribute("src");if(e.hasAttribute("exclude"))r=document.createComment("script element with exclude attribute ignored by micro-app");else if(U&&e.noModule||!U&&"module"===e.type)r=document.createComment((e.noModule?"noModule":"module")+" script ignored by micro-app");else if(i){i=c(i,n.url);const t={code:"",isExternal:!0,isDynamic:o,async:e.hasAttribute("async"),defer:e.defer||"module"===e.type,module:"module"===e.type,isGlobal:e.hasAttribute("global")};if(o)return{url:i,info:t};n.source.scripts.set(i,t),r=document.createComment(`script with src='${i}' extract by micro-app`)}else if(e.textContent){const t=Math.random().toString(36).substr(2,15),i={code:e.textContent,isExternal:!1,isDynamic:o,async:!1,defer:"module"===e.type,module:"module"===e.type};if(o)return{url:t,info:i};n.source.scripts.set(t,i),r=document.createComment("inline script extract by micro-app")}else r=document.createComment("script ignored by micro-app");return o?{replaceComment:r}:t.replaceChild(r,e)}function $(e,t){const n=Array.from(t.source.scripts.entries()),o=[],r=[];for(const[e,i]of n)if(i.isExternal){const n=T.get(e);n?i.code=n:i.defer||i.async||(o.push(we(e,t.name)),r.push([e,i]))}o.length?a(o,(e=>{!function(e,t,n){t.isGlobal&&!T.has(e)&&T.set(e,n);t.code=n}(r[e.index][0],r[e.index][1],e.data)}),(e=>{console.error("[micro-app]",e)}),(()=>{t.onLoad(e)})):t.onLoad(e)}function I(e,t,n,o,r){var i;try{if(t=k(e,t,n),n.inline){const e=y("script");if(o&&e.setAttribute("type","module"),e.textContent=t,r)return e;null===(i=n.container)||void 0===i||i.querySelector("micro-app-body").appendChild(e)}else if((0,eval)(t),r)return document.createComment("dynamic script extract by micro-app")}catch(e){console.error("[micro-app from runScript]",e)}}function k(t,n,o){return"object"==typeof Ee.plugins&&(n=function(e,t,n,o){var r;if("[object Array]"===toString.call(o.global))for(const n of o.global)"object"==typeof n&&"function"==typeof n.loader&&(t=n.loader(t,e,n.options));if("[object Array]"===toString.call(null===(r=o.modules)||void 0===r?void 0:r[n]))for(const r of o.modules[n])"object"==typeof r&&"function"==typeof r.loader&&(t=r.loader(t,e,r.options));return t}(t,n,o.name,Ee.plugins)),o.sandBox?(e.proxyWindow=o.sandBox.proxyWindow,`;(function(window, self){with(window){;${n}\n}}).call(window.proxyWindow, window.proxyWindow, window.proxyWindow);`):n}const B=Element.prototype.setAttribute,W=Node.prototype.appendChild,H=Node.prototype.insertBefore,q=Node.prototype.replaceChild,G=Node.prototype.removeChild,F=Element.prototype.append,K=Element.prototype.prepend,z=Document.prototype.createElement,V=Document.prototype.createElementNS,Y=Document.prototype.createDocumentFragment,J=Document.prototype.querySelector,Z=Document.prototype.querySelectorAll,Q=Document.prototype.getElementById,X=Document.prototype.getElementsByClassName,ee=Document.prototype.getElementsByTagName,te=Document.prototype.getElementsByName,ne=new WeakMap;function oe(e,t,n){if(t instanceof HTMLStyleElement){if(t.hasAttribute("exclude")){const e=document.createComment("style element with exclude attribute ignored by micro-app");return ne.set(t,e),e}return n.scopecss?S(t,n.name):t}if(t instanceof HTMLLinkElement){if(t.hasAttribute("exclude")){const e=document.createComment("link element with exclude attribute ignored by micro-app");return ne.set(t,e),e}if(!n.scopecss)return t;const{url:r,info:i}=L(t,e,n,null,!0);if(r&&i){const e=y("style");return e.linkpath=r,function(e,t,n,r,i){if(n.source.links.has(e))return i.textContent=n.source.links.get(e).code,S(i,n.name),void o((()=>P(r)));if(M.has(e)){const s=M.get(e);return t.code=s,n.source.links.set(e,t),i.textContent=s,S(i,n.name),void o((()=>P(r)))}we(e,n.name).then((o=>{t.code=o,n.source.links.set(e,t),t.isGlobal&&M.set(e,o),i.textContent=o,S(i,n.name),P(r)})).catch((e=>{console.error("[micro-app]",e),R(r)}))}(r,i,n,t,e),ne.set(t,e),e}return t}if(t instanceof HTMLScriptElement){const{replaceComment:r,url:i,info:s}=j(t,e,n,!0);if(i&&s){if(s.code){const e=I(i,s.code,n,s.module,!0);return ne.set(t,e),e}{const e=function(e,t,n,r){if(n.source.scripts.has(e)){const i=n.source.scripts.get(e);return o((()=>P(r))),I(e,i.code,n,t.module,!0)}if(T.has(e)){const i=T.get(e);return t.code=i,n.source.scripts.set(e,t),o((()=>P(r))),I(e,i,n,t.module,!0)}let i;return i=n.inline?y("script"):document.createComment(`dynamic script with src='${e}' extract by micro-app`),we(e,n.name).then((o=>{t.code=o,n.source.scripts.set(e,t),t.isGlobal&&T.set(e,o);try{o=k(e,o,n),n.inline?(t.module&&i.setAttribute("type","module"),i.textContent=o):(0,eval)(o)}catch(t){console.error("[micro-app from runDynamicScript]",t,e)}P(r)})).catch((e=>{console.error("[micro-app]",e),R(r)})),i}(i,s,n,t);return ne.set(t,e),e}}return ne.set(t,r),r}return t}function re(e,t,n,o,r){if(n instanceof HTMLHeadElement){const i=e.container.querySelector("micro-app-head");return r&&!i.contains(r)?W.call(i,o):t!==G||i.contains(o)?t===F||t===K?t.call(i,o):t.call(i,o,r):n.contains(o)?t.call(n,o):o}if(n instanceof HTMLBodyElement){const i=e.container.querySelector("micro-app-body");return r&&!i.contains(r)?W.call(i,o):t!==G||i.contains(o)?t===F||t===K?t.call(i,o):t.call(i,o,r):n.contains(o)?t.call(n,o):o}return t===F||t===K?t.call(n,o):t.call(n,o,r)}function ie(e){var t;return null!==(t=ne.get(e))&&void 0!==t?t:e}function se(e,t,n,o){if(null==t?void 0:t.__MICRO_APP_NAME__){const r=Fe.get(t.__MICRO_APP_NAME__);return(null==r?void 0:r.container)?re(r,o,e,oe(e,t,r),n&&ie(n)):o===F||o===K?o.call(e,t):o.call(e,t,n)}if(o===F||o===K){const n=d();if(!(t instanceof Node)&&n){const r=Fe.get(n);if(null==r?void 0:r.container){if(e instanceof HTMLHeadElement)return o.call(r.container.querySelector("micro-app-head"),t);if(e instanceof HTMLBodyElement)return o.call(r.container.querySelector("micro-app-body"),t)}}return o.call(e,t)}return o.call(e,t,n)}function ce(){!function(){function e(e){var n,o,r;const i=d();return i&&"head"!==e&&"body"!==e&&"html"!==e?null!==(r=null===(o=null===(n=Fe.get(i))||void 0===n?void 0:n.container)||void 0===o?void 0:o.querySelector(e))&&void 0!==r?r:null:J.call(t,e)}function n(e){var n,o,r;const i=d();return i&&"head"!==e&&"body"!==e&&"html"!==e?null!==(r=null===(o=null===(n=Fe.get(i))||void 0===n?void 0:n.container)||void 0===o?void 0:o.querySelectorAll(e))&&void 0!==r?r:[]:Z.call(t,e)}Document.prototype.createElement=function(e,n){return ae(z.call(t,e,n))},Document.prototype.createElementNS=function(e,n,o){return ae(V.call(t,e,n,o))},Document.prototype.createDocumentFragment=function(){return ae(Y.call(t))},Document.prototype.querySelector=e,Document.prototype.querySelectorAll=n,Document.prototype.getElementById=function(n){return!d()||/^\d/.test(n)?Q.call(t,n):e(`#${n}`)},Document.prototype.getElementsByClassName=function(e){return!d()||/^\d/.test(e)?X.call(t,e):n(`.${e}`)},Document.prototype.getElementsByTagName=function(e){var o;const r=d();return!r||/^body$/i.test(e)||/^head$/i.test(e)||/^html$/i.test(e)||!(null===(o=Fe.get(r))||void 0===o?void 0:o.inline)&&/^script$/i.test(e)?ee.call(t,e):n(e)},Document.prototype.getElementsByName=function(e){return!d()||/^\d/.test(e)?te.call(t,e):n(`[name=${e}]`)}}(),Element.prototype.setAttribute=function(e,t){if(/^micro-app(-\S+)?/i.test(this.tagName)&&"data"===e)if("[object Object]"===toString.call(t)){const e={};Object.getOwnPropertyNames(t).forEach((n=>{"string"==typeof n&&0===n.indexOf("__")||(e[n]=t[n])})),this.data=e}else"[object Object]"!==t&&console.warn(n("property data must be an object"));else if(("src"===e&&/^(img|iframe|script)$/i.test(this.tagName)||"href"===e&&/^link$/i.test(this.tagName))&&this.__MICRO_APP_NAME__&&Fe.has(this.__MICRO_APP_NAME__)){const n=Fe.get(this.__MICRO_APP_NAME__);B.call(this,e,c(t,n.url))}else B.call(this,e,t)},Node.prototype.appendChild=function(e){return se(this,e,null,W)},Node.prototype.insertBefore=function(e,t){return se(this,e,t,H)},Node.prototype.replaceChild=function(e,t){return se(this,e,t,q)},Element.prototype.append=function(...e){let t=0;const n=e.length;for(;t<n;)se(this,e[t],null,F),t++},Element.prototype.prepend=function(...e){let t=e.length;for(;t>0;)se(this,e[t-1],null,K),t--},Node.prototype.removeChild=function(e){if(null==e?void 0:e.__MICRO_APP_NAME__){const t=Fe.get(e.__MICRO_APP_NAME__);return(null==t?void 0:t.container)?re(t,G,this,ie(e)):G.call(this,e)}return G.call(this,e)}}function ae(e){const t=d();return t&&(e.__MICRO_APP_NAME__=t),e}function le(){p(null),Document.prototype.createElement=z,Document.prototype.createElementNS=V,Document.prototype.createDocumentFragment=Y,Document.prototype.querySelector=J,Document.prototype.querySelectorAll=Z,Document.prototype.getElementById=Q,Document.prototype.getElementsByClassName=X,Document.prototype.getElementsByTagName=ee,Document.prototype.getElementsByName=te,Element.prototype.setAttribute=B,Node.prototype.appendChild=W,Node.prototype.insertBefore=H,Node.prototype.replaceChild=q,Node.prototype.removeChild=G,Element.prototype.append=F,Element.prototype.prepend=K}let ue=!1;function pe(e,t,o,r){var i;if(!e)return console.error(n(`element does not exist in lifecycle ${o},it seems the app has unmounted`));e instanceof ShadowRoot&&(e=e.host);const s=Object.assign({name:t,container:e},r&&{error:r}),c=new CustomEvent(o,{detail:s});!function(e,t){Object.defineProperties(e,{currentTarget:{get:()=>t},target:{get:()=>t}})}(c,e),"function"==typeof(null===(i=Ee.lifeCycles)||void 0===i?void 0:i[o])&&Ee.lifeCycles[o](c),e.dispatchEvent(c)}function de(){Fe.forEach((e=>{let t=e.container;t&&(t instanceof ShadowRoot&&(t=t.host),t.disconnectedCallback())})),Fe.clear()}class he extends HTMLElement{constructor(){super(...arguments),this.name="",this.url="",this.version="0.2.4",this.isWating=!1,this.cacheData=null,this.handleAttributeUpdate=()=>{var e;this.isWating=!1;const t=this.getAttribute("name"),o=i(this.getAttribute("url"));if(this.legalAttribute("name",t)&&this.legalAttribute("url",o)){const r=Fe.get(t);if(t!==this.name&&r&&r.getAppStatus()!==g.UNMOUNT&&!r.isPrefetch)return this.setAttribute("name",this.name),console.error(n(`an app named ${t} already exists`));t===this.name&&o===this.url||(this.handleUnmount(!0),this.name=t,this.url=o,(null!==(e=this.shadowRoot)&&void 0!==e?e:this).innerHTML="",r&&r.url===o?this.handleAppMount(r):this.handleCreate())}else t!==this.name&&this.setAttribute("name",this.name)}}static get observedAttributes(){return["name","url"]}connectedCallback(){if(1==++he.microAppCount&&(ce(),function(){if(!ue){ue=!0;const e=y("style");e.setAttribute("type","text/css"),e.textContent=`\n${Ee.tagName}, micro-app-body { display: block; } \nmicro-app-head { display: none; }`,t.head.appendChild(e)}}(),window.__MICRO_APP_ENVIRONMENT__&&window.addEventListener("unmount",de,!1)),o((()=>pe(this,this.name,E.CREATED))),!this.name||!this.url)return;this.getDisposeResult("shadowDOM")&&!this.shadowRoot&&this.attachShadow({mode:"open"});const e=Fe.get(this.name);e?e.url!==this.url||!e.isPrefetch&&e.getAppStatus()!==g.UNMOUNT?e.isPrefetch?console.error(n(`the url: ${this.url} is different from prefetch url: ${e.url}`)):console.error(n(`an app named ${this.name} already exists`)):this.handleAppMount(e):this.handleCreate()}disconnectedCallback(){he.microAppCount>0&&(this.handleUnmount(this.getDisposeResult("destory")),0==--he.microAppCount&&(le(),window.__MICRO_APP_ENVIRONMENT__&&window.removeEventListener("unmount",de,!1)))}attributeChangedCallback(e,t,r){if(this.legalAttribute(e,r)&&this[e]!==r)if(e!==b.URL||this.url)e!==b.NAME||this.name?this.isWating||(this.isWating=!0,o(this.handleAttributeUpdate)):(this.cacheData&&(Ee.setData(r,this.cacheData),this.cacheData=null),this.name=r);else{if(!(r=i(r)))return console.error(n("Invalid attribute url"));this.url=r}}legalAttribute(e,t){return!("string"!=typeof t||!t)||(console.error(n(`unexpected attribute ${e}, please check again`)),!1)}handleAppMount(e){e.isPrefetch=!1,o((()=>{var t,n;return e.mount(null!==(t=this.shadowRoot)&&void 0!==t?t:this,this.getDisposeResult("inline"),null!==(n=this.getAttribute("baseurl"))&&void 0!==n?n:"")}))}handleCreate(){var e,t;const n=new Ke({name:this.name,url:this.url,container:null!==(e=this.shadowRoot)&&void 0!==e?e:this,inline:this.getDisposeResult("inline"),scopecss:!(this.getDisposeResult("disableScopecss")||this.getDisposeResult("shadowDOM")),useSandbox:!this.getDisposeResult("disableSandbox"),macro:this.getDisposeResult("macro"),baseurl:null!==(t=this.getAttribute("baseurl"))&&void 0!==t?t:""});Fe.set(this.name,n)}handleUnmount(e){const t=Fe.get(this.name);t&&t.getAppStatus()!==g.UNMOUNT&&t.unmount(e)}getDisposeResult(e){return(this.hasAttribute(e)||Ee[e])&&"false"!==this.getAttribute(e)}set data(e){this.name?Ee.setData(this.name,e):this.cacheData=e}get data(){return this.name?Ee.getData(this.name,!0):this.cacheData?this.cacheData:null}}he.microAppCount=0;const me=new class{constructor(){this.eventList=new Map}isLegalName(e){return!!e||(console.error(n("event-center: Invalid name")),!1)}on(e,t,o=!1){if(this.isLegalName(e)){if("function"!=typeof t)return console.error(n("event-center: Invalid callback function"));let r=this.eventList.get(e);r?o&&Object.getOwnPropertyNames(r.data).length&&t(r.data):(r={data:{},callbacks:new Set},this.eventList.set(e,r)),r.callbacks.add(t)}}off(e,t){if(this.isLegalName(e)){const n=this.eventList.get(e);n&&("function"==typeof t?n.callbacks.delete(t):n.callbacks.clear())}}dispatch(e,t){if(this.isLegalName(e)){if("[object Object]"!==toString.call(t))return console.error(n("event-center: data must be object"));let o=this.eventList.get(e);if(o){if(o.data!==t){o.data=t;for(const e of o.callbacks)e(t)}}else o={data:t,callbacks:new Set},this.eventList.set(e,o)}}getData(e){var t;const n=this.eventList.get(e);return null!==(t=null==n?void 0:n.data)&&void 0!==t?t:null}};function fe(e,t){return"string"==typeof e&&e?t?`__from_base_app_${e}__`:`__from_micro_app_${e}__`:""}class ye{addGlobalDataListener(e,t){me.on("global",e,t)}removeGlobalDataListener(e){"function"==typeof e&&me.off("global",e)}setGlobalData(e){me.dispatch("global",e)}clearGlobalDataListener(){me.off("global")}}class be extends ye{addDataListener(e,t,n){me.on(fe(e,!1),t,n)}removeDataListener(e,t){"function"==typeof t&&me.off(fe(e,!1),t)}getData(e,t=!1){return me.getData(fe(e,t))}setData(e,t){me.dispatch(fe(e,!0),t)}clearDataListener(e){me.off(fe(e,!1))}}class ge extends ye{constructor(e){super(),this.appName=e}addDataListener(e,t){me.on(fe(this.appName,!0),e,t)}removeDataListener(e){"function"==typeof e&&me.off(fe(this.appName,!0),e)}getData(){return me.getData(fe(this.appName,!0))}dispatch(e){h(),me.dispatch(fe(this.appName,!1),e);const t=Fe.get(this.appName);if((null==t?void 0:t.container)&&"[object Object]"===toString.call(e)){const n=new CustomEvent("datachange",{detail:{data:e}});let o=t.container;o instanceof ShadowRoot&&(o=o.host),o.dispatchEvent(n)}}clearDataListener(){me.off(fe(this.appName,!0))}}var Ee=new class extends be{constructor(){super(...arguments),this.tagName="micro-app",this.preFetch=ze}start(e){if(!(null===window||void 0===window?void 0:window.customElements))return console.error(n("customElements is not supported in this environment"));if(null==e?void 0:e.tagName){if(!/^micro-app(-\S+)?/.test(e.tagName))return console.error(n(`${e.tagName} is invalid tagName`));this.tagName=e.tagName}var t,o;o=this.tagName,(window.customElements.get(o)?(console.warn(n(`element ${o} is already defined`)),0):(window.customElements.define(o,he),1))&&e&&"[object Object]"===toString.call(e)&&(this.shadowDOM=e.shadowDOM,this.destory=e.destory,this.inline=e.inline,this.disableScopecss=e.disableScopecss,this.disableSandbox=e.disableSandbox,this.macro=e.macro,f(e.fetch)&&(this.fetch=e.fetch),"[object Object]"===toString.call(e.lifeCycles)&&(this.lifeCycles=e.lifeCycles),"[object Object]"===toString.call(e.plugins)&&(this.plugins=e.plugins),e.preFetchApps&&ze(e.preFetchApps),e.globalAssets&&(t=e.globalAssets,"[object Object]"===toString.call(t)&&l((()=>{if("[object Array]"===toString.call(t.js)){const e=t.js.filter((e=>"string"==typeof e&&e.includes(".js")&&!T.has(e))),n=[];e.forEach((e=>{n.push(we(e))})),a(n,(t=>{const n=e[t.index];T.has(n)||T.set(n,t.data)}),(e=>{console.error("[micro-app]",e)}))}if("[object Array]"===toString.call(t.css)){const e=t.css.filter((e=>"string"==typeof e&&e.includes(".css")&&!M.has(e))),n=[];e.forEach((e=>{n.push(we(e))})),a(n,(t=>{const n=e[t.index];M.has(n)||M.set(n,t.data)}),(e=>{console.error("[micro-app]",e)}))}}))))}};function we(e,t=null,n={}){return f(Ee.fetch)?Ee.fetch(e,n,t):fetch(e,n).then((e=>e.text()))}function _e(e,t,n){const o=Array.from(e.children);o.length&&o.forEach((e=>{_e(e,t,n)}));for(const r of o)r instanceof HTMLLinkElement?r.hasAttribute("exclude")?e.replaceChild(document.createComment("link element with exclude attribute ignored by micro-app"),r):t.scopecss?L(r,e,t,n):r.hasAttribute("href")&&r.setAttribute("href",c(r.getAttribute("href"),t.url)):r instanceof HTMLStyleElement?r.hasAttribute("exclude")?e.replaceChild(document.createComment("style element with exclude attribute ignored by micro-app"),r):t.scopecss&&n.appendChild(S(r,t.name)):r instanceof HTMLScriptElement?j(r,e,t):r instanceof HTMLMetaElement||r instanceof HTMLTitleElement?e.removeChild(r):/^(img|iframe)$/i.test(r.tagName)&&r.hasAttribute("src")&&r.setAttribute("src",c(r.getAttribute("src"),t.url))}function ve(e,t){const o=function(e){const t=y("div");return t.innerHTML=e,t}(e),r=o.querySelector("micro-app-head"),i=o.querySelector("micro-app-body");if(!r||!i){const e=`element ${r?"body":"head"} is missing`;return t.onerror(new Error(e)),console.error(n(e))}_e(o,t,r),t.source.links.size?x(o,t,r):t.onLoad(o),t.source.scripts.size?$(o,t):t.onLoad(o)}const Ae=new WeakMap;const Oe=new WeakMap;function Ne(e,t){if(Oe.has(t))return Oe.get(t);if(f(t)&&!function(e){if(Ae.has(e))return Ae.get(e);const t=e.toString(),n=e.prototype&&e.prototype.constructor===e&&Object.getOwnPropertyNames(e.prototype).length>1||/^function\s+[A-Z]/.test(t)||/^class\s+/.test(t);return Ae.set(e,n),n}(t)){const n=t.bind(e);for(const e in t)n[e]=t[e];return t.hasOwnProperty("prototype")&&!n.hasOwnProperty("prototype")&&(n.prototype=t.prototype),Oe.set(t,n),n}return t}const Ce=window.addEventListener,Se=window.removeEventListener,De=window.setInterval,Pe=window.setTimeout,Re=window.clearInterval,Me=window.clearTimeout,Le=document.addEventListener,xe=document.removeEventListener,Te=new Map;let Ue=!1;const je=new Map;function $e(){Ue||function(){Ue=!0;const e=Object.getOwnPropertyDescriptor(document,"onclick");if(!1===(null==e?void 0:e.configurable))return console.warn(n("Cannot redefine document property onclick"));const t=document.onclick;document.onclick=null;let o=!1;function r(e){Te.forEach((t=>{"function"==typeof t&&t.call(document,e)}))}Object.defineProperty(document,"onclick",{configurable:!1,enumerable:!0,get(){const e=d();return e?Te.get(e):Te.get("base")},set(e){const t=d();t?Te.set(t,e):Te.set("base",e),o||"function"!=typeof e||(o=!0,Le.call(document,"click",r,!1))}}),t&&(document.onclick=t)}(),document.addEventListener=function(e,t,n){const o=d();if(o){const n=je.get(o);if(n){const o=n.get(e);o?o.add(t):n.set(e,new Set([t]))}else je.set(o,new Map([[e,new Set([t])]]))}return Le.call(document,e,t,n)},document.removeEventListener=function(e,t,n){const o=d();if(o){const n=je.get(o);if(n){const o=n.get(e);(null==o?void 0:o.size)&&o.has(t)&&o.delete(t)}}return xe.call(document,e,t,n)}}function Ie(e,t){return"unmount"===e?`unmount-${t.__MICRO_APP_NAME__}`:e}const ke=["System","__cjsWrapper","__REACT_ERROR_OVERLAY_GLOBAL_HOOK__"],Be=["location"],We={undefined:!0,Array:!0,Object:!0,String:!0,Boolean:!0,Math:!0,Number:!0,Symbol:!0,parseFloat:!0,Float32Array:!0};let He;function qe(e){He&&clearTimeout(He),He=setTimeout(e,0)}class Ge{constructor(n,r,i){this.active=!1,this.scopeProperties=["webpackJsonp"],this.escapeProperties=[],this.microWindow={},this.injectedKeys=new Set,this.escapeKeys=new Set;const s=new Map,c=t=>this.microWindow.hasOwnProperty(t)||e.hasOwnProperty(t);this.getScopeProperties(n),this.inject(this.microWindow,n,r),this.releaseEffect=function(e){const t=new Map,n=new Set,o=new Set;return e.addEventListener=function(n,o,r){n=Ie(n,e);const i=t.get(n);return i?i.add(o):t.set(n,new Set([o])),Ce.call(window,n,o,r)},e.removeEventListener=function(n,o,r){n=Ie(n,e);const i=t.get(n);return(null==i?void 0:i.size)&&i.has(o)&&i.delete(o),Se.call(window,n,o,r)},e.setInterval=function(e,t,...o){const r=De(e,t,...o);return n.add(r),r},e.setTimeout=function(e,t,...n){const r=Pe(e,t,...n);return o.add(r),r},e.clearInterval=function(e){n.delete(e),Re(e)},e.clearTimeout=function(e){o.delete(e),Me(e)},()=>{t.size&&(t.forEach(((e,t)=>{if(e.size)for(const n of e)Se.call(window,t,n)})),t.clear()),n.size&&(n.forEach((e=>{Re(e)})),n.clear()),o.size&&(o.forEach((e=>{Me(e)})),o.clear());const r=e.__MICRO_APP_NAME__;Te.delete(r);const i=je.get(r);i&&(i.forEach(((e,t)=>{if(e.size)for(const n of e)xe.call(document,t,n)})),i.clear())}}(this.microWindow),this.proxyWindow=new Proxy(this.microWindow,{get:(r,s)=>{if(s===Symbol.unscopables)return We;if(["window","self","globalThis"].includes(s))return this.proxyWindow;if("top"===s||"parent"===s)return e===e.parent?this.proxyWindow:Reflect.get(e,s);if("hasOwnProperty"===s)return c;if("document"===s||"eval"===s)switch(p(n),(i?qe:o)((()=>p(null))),s){case"document":return t;case"eval":return eval}if(this.scopeProperties.includes(s))return Reflect.get(r,s);if(Reflect.has(r,s))return Reflect.get(r,s);const a=Reflect.get(e,s);return Ne(e,a)},set:(t,n,o)=>{if(this.active){if(Be.includes(n))Reflect.set(e,n,o);else if(t.hasOwnProperty(n)||!e.hasOwnProperty(n)||this.scopeProperties.includes(n))Reflect.set(t,n,o),this.injectedKeys.add(n);else{const r=Object.getOwnPropertyDescriptor(e,n),{writable:i,configurable:s,enumerable:c}=r;i&&(Object.defineProperty(t,n,{configurable:s,enumerable:c,writable:i,value:o}),this.injectedKeys.add(n))}(this.escapeProperties.includes(n)||ke.includes(n)&&!Reflect.has(e,n))&&!this.scopeProperties.includes(n)&&(Reflect.set(e,n,o),this.escapeKeys.add(n))}return!0},has:(t,n)=>this.scopeProperties.includes(n)?n in t:n in We||n in t||n in e,getOwnPropertyDescriptor:(t,n)=>{if(t.hasOwnProperty(n))return s.set(n,"target"),Object.getOwnPropertyDescriptor(t,n);if(e.hasOwnProperty(n)){s.set(n,"rawWindow");const t=Object.getOwnPropertyDescriptor(e,n);return t&&!t.configurable&&(t.configurable=!0),t}},defineProperty:(t,n,o)=>"rawWindow"===s.get(n)?Reflect.defineProperty(e,n,o):Reflect.defineProperty(t,n,o),ownKeys:t=>Reflect.ownKeys(e).concat(Reflect.ownKeys(t)).filter((function(e){return!(e in this)&&(this[e]=!0)}),Object.create(null)),deleteProperty:(t,n)=>!t.hasOwnProperty(n)||(this.escapeKeys.has(n)&&Reflect.deleteProperty(e,n),Reflect.deleteProperty(t,n))})}start(t){this.active||(this.active=!0,this.microWindow.__MICRO_APP_BASE_URL__=t,e._babelPolyfill&&(e._babelPolyfill=!1),1==++Ge.activeCount&&$e())}stop(){this.active&&(this.active=!1,this.releaseEffect(),this.microWindow.microApp.clearDataListener(),this.injectedKeys.forEach((e=>{Reflect.deleteProperty(this.microWindow,e)})),this.injectedKeys.clear(),this.escapeKeys.forEach((t=>{Reflect.deleteProperty(e,t)})),this.escapeKeys.clear(),0==--Ge.activeCount&&(document.addEventListener=Le,document.removeEventListener=xe))}getScopeProperties(e){var t;if("object"==typeof Ee.plugins){if("[object Array]"===toString.call(Ee.plugins.global))for(const e of Ee.plugins.global)"object"==typeof e&&("[object Array]"===toString.call(e.scopeProperties)&&(this.scopeProperties=this.scopeProperties.concat(e.scopeProperties)),"[object Array]"===toString.call(e.escapeProperties)&&(this.escapeProperties=this.escapeProperties.concat(e.escapeProperties)));if("[object Array]"===toString.call(null===(t=Ee.plugins.modules)||void 0===t?void 0:t[e]))for(const t of Ee.plugins.modules[e])"object"==typeof t&&("[object Array]"===toString.call(t.scopeProperties)&&(this.scopeProperties=this.scopeProperties.concat(t.scopeProperties)),"[object Array]"===toString.call(t.escapeProperties)&&(this.escapeProperties=this.escapeProperties.concat(t.escapeProperties)))}}inject(n,o,r){n.__MICRO_APP_ENVIRONMENT__=!0,n.__MICRO_APP_NAME__=o,n.__MICRO_APP_PUBLIC_PATH__=s(r),n.microApp=new ge(o),n.rawWindow=e,n.rawDocument=t}}Ge.activeCount=0;const Fe=new Map;class Ke{constructor({name:e,url:t,container:n,inline:o,scopecss:r,useSandbox:i,macro:s,baseurl:c}){this.status=g.NOT_LOADED,this.loadSourceLevel=0,this.isPrefetch=!1,this.container=null,this.macro=!1,this.baseurl="",this.sandBox=null,this.container=null!=n?n:null,this.inline=null!=o&&o,this.baseurl=null!=c?c:"",this.name=e,this.url=t,this.useSandbox=i,this.scopecss=this.useSandbox&&r,this.macro=null!=s&&s,this.source={links:new Map,scripts:new Map},this.loadSourceCode(),this.useSandbox&&(this.sandBox=new Ge(e,t,this.macro))}loadSourceCode(){var e;this.status=g.LOADING_SOURCE_CODE,we((e=this).url,e.name,{cache:"no-cache"}).then((t=>{if(!t){const t="html is empty, please check in detail";return e.onerror(new Error(t)),console.error(n(t))}ve(t=t.replace(/<head[^>]*>[\s\S]*?<\/head>/i,(e=>e.replace(/<head/i,"<micro-app-head").replace(/<\/head>/i,"</micro-app-head>"))).replace(/<body[^>]*>[\s\S]*?<\/body>/i,(e=>e.replace(/<body/i,"<micro-app-body").replace(/<\/body>/i,"</micro-app-body>"))),e)})).catch((t=>{console.error(n(`Failed to fetch data from ${e.url}, micro-app stop rendering`),t),e.onLoadError(t)}))}onLoad(e){if(2==++this.loadSourceLevel){if(this.source.html=e,this.isPrefetch||this.status===g.UNMOUNT)return;this.status=g.LOAD_SOURCE_FINISHED,this.mount()}}onLoadError(e){this.loadSourceLevel=-1,this.status!==g.UNMOUNT&&(this.onerror(e),this.status=g.LOAD_SOURCE_ERROR)}mount(e,t,n){var r;if(!this.container&&e&&(this.container=e),"boolean"==typeof t&&t!==this.inline&&(this.inline=t),this.baseurl=null!=n?n:this.baseurl,2!==this.loadSourceLevel)return void(this.status=g.LOADING_SOURCE_CODE);pe(this.container,this.name,E.BEFOREMOUNT),this.status=g.MOUNTING;const i=this.source.html.cloneNode(!0),s=document.createDocumentFragment();Array.from(i.childNodes).forEach((e=>{s.appendChild(e)})),this.container.appendChild(s),null===(r=this.sandBox)||void 0===r||r.start(this.baseurl),function(e,t){const n=Array.from(e.entries()),o=[],r=[];for(const[e,i]of n)i.isDynamic||(i.defer||i.async?(i.isExternal?o.push(we(e,t.name)):o.push(i.code),r.push([e,i])):I(e,i.code,t,i.module,!1));o.length&&Promise.all(o).then((e=>{e.forEach(((e,n)=>{I(r[n][0],e,t,r[n][1].module,!1)}))})).catch((e=>{console.error("[micro-app]",e)}))}(this.source.scripts,this),this.status!==g.UNMOUNT&&(this.status=g.MOUNTED,o((()=>{this.status!==g.UNMOUNT&&pe(this.container,this.name,E.MOUNTED)})))}unmount(e){var t;this.status===g.LOAD_SOURCE_ERROR&&(e=!0),this.status=g.UNMOUNT,pe(this.container,this.name,E.UNMOUNT),function(e){const t=new CustomEvent(`unmount-${e}`);window.dispatchEvent(t)}(this.name),null===(t=this.sandBox)||void 0===t||t.stop(),this.container=null,e&&Fe.delete(this.name)}onerror(e){pe(this.container,this.name,E.ERROR,e)}getAppStatus(){return this.status}}function ze(e){l((()=>{"function"==typeof e&&(e=e()),function(e){const t=[];return"[object Array]"===toString.call(e)&&e.forEach((e=>{e.url=i(e.url),"[object Object]"===toString.call(e)&&e.name&&"string"==typeof e.name&&e.url&&!Fe.has(e.name)&&t.push(e)})),t}(e).forEach((e=>{var t,n,o;const r=new Ke({name:e.name,url:e.url,scopecss:!(null!==(t=e.disableScopecss)&&void 0!==t?t:Ee.disableScopecss),useSandbox:!(null!==(n=e.disableSandbox)&&void 0!==n?n:Ee.disableSandbox),macro:null!==(o=e.macro)&&void 0!==o?o:Ee.macro});r.isPrefetch=!0,Fe.set(e.name,r)}))}))}exports.default=Ee,exports.preFetch=ze,exports.pureCreateElement=y,exports.removeDomScope=h,exports.version="0.2.4";
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=new Function("return window")(),t=new Function("return document")();function n(e,...t){"string"==typeof e?console.error(`[micro-app] ${e}`,...t):console.error("[micro-app]",e,...t)}function o(e,...t){"string"==typeof e?console.warn(`[micro-app] ${e}`,...t):console.warn("[micro-app]",e,...t)}function r(e,...t){Promise.resolve().then(e.bind(null,...t))}function i(e){return e.startsWith("//")?`${location.protocol}${e}`:e}function s(e){if("string"!=typeof e||!e)return"";try{const{origin:t,pathname:n,search:o}=new URL(i(e));if(/\.(\w+)$/.test(n))return`${t}${n}${o}`;const r=`${t}${n}/`.replace(/\/\/$/,"/");return/^https?:\/\//.test(r)?`${r}${o}`:""}catch(e){return n(e),""}}function c(e){const{origin:t,pathname:n}=new URL(e);if(/\.(\w+)$/.test(n)){const e=`${t}${n}`.split("/");return e.pop(),e.join("/")+"/"}return`${t}${n}/`.replace(/\/\/$/,"/")}function a(e,t){return/^((((ht|f)tps?)|file):)?\/\//.test(e)?e:new URL(e,c(i(t))).toString()}function l(e,t,n,o){let r=0;function i(){++r===e.length&&o&&o()}e.forEach(((e,o)=>{"[object Promise]"===toString.call(e)?e.then((e=>{t({data:e,index:o}),i()})).catch((e=>{n({error:e,index:o}),i()})):(t({data:e,index:o}),i())}))}const u=window.requestIdleCallback||function(e){const t=Date.now();return setTimeout((function(){e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-t))})}),1)};let p=null;function d(e){p=e}function h(){return p}function m(){d(null)}function f(){return/Safari/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)}function y(e){return"function"==typeof e}function b(e,n){const o=t.createElement(e,n);return o.__MICRO_APP_NAME__&&delete o.__MICRO_APP_NAME__,o}var g,E,w,_;function v(e,t){const{selectorText:n,cssText:o}=e;if(/^((html[\s>~,]+body)|(html|body|:root))$/.test(n))return o.replace(/^((html[\s>~,]+body)|(html|body|:root))/,t);if("*"===n)return o.replace("*",`${t} *`);const r=/(^|\s+)((html[\s>~]+body)|(html|body|:root))(?=[\s>~]+|$)/;return o.replace(/^[\s\S]+{/,(e=>e.replace(/(^|,)([^,]+)/g,((e,n,o)=>r.test(o)?e.replace(r,t):`${n} ${t} ${o.replace(/^\s*/,"")}`))))}function N(e,t,n,o){return e.replace(/url\(["']?([^)"']+)["']?\)/gm,((e,r)=>{if(/^data:/.test(r))return e;if(/^(https?:)?\/\//.test(r)){if(!f())return e;{const t=r.replace(/^https?:/,"");if(-1!==n.indexOf(t))return e;r=r.replace(window.location.origin,"")}}return/^((\.\.?\/)|[^/])/.test(r)&&o&&(t=function(e){const t=e.split("/");return t.pop(),i(t.join("/")+"/")}(o)),`url("${a(r,t)}")`}))}function A(e,t,n){const o=O(Array.from(e.cssRules),t);return`@${n} ${e.conditionText} {${o}}`}function O(e,t){let n="";for(const o of e)switch(o.type){case _.STYLE_RULE:n+=v(o,t);break;case _.MEDIA_RULE:n+=A(o,t,"media");break;case _.SUPPORTS_RULE:n+=A(o,t,"supports");break;default:n+=o.cssText}return n.replace(/^\s+/,"")}function C(e,t,n,o,r,i){var s,c;let a=N(O(Array.from(null!==(c=null===(s=e.sheet)||void 0===s?void 0:s.cssRules)&&void 0!==c?c:[]),o),r,n,i);f()&&(a=a.replace(/([;{]\s*content:\s*)([^\s"][^";}]*)/gm,((e,t,n)=>"none"===n||/^(url\()|(counter\()|(attr\()|(open-quote)|(close-quote)/.test(n)?e:`${t}"${n}"`))),t.textContent=a}!function(e){e.NAME="name",e.URL="url"}(g||(g={})),function(e){e.NOT_LOADED="NOT_LOADED",e.LOADING_SOURCE_CODE="LOADING_SOURCE_CODE",e.LOAD_SOURCE_FINISHED="LOAD_SOURCE_FINISHED",e.LOAD_SOURCE_ERROR="LOAD_SOURCE_ERROR",e.MOUNTING="MOUNTING",e.MOUNTED="MOUNTED",e.UNMOUNT="UNMOUNT"}(E||(E={})),function(e){e.CREATED="created",e.BEFOREMOUNT="beforemount",e.MOUNTED="mounted",e.UNMOUNT="unmount",e.ERROR="error"}(w||(w={})),function(e){e[e.STYLE_RULE=1]="STYLE_RULE",e[e.MEDIA_RULE=4]="MEDIA_RULE",e[e.SUPPORTS_RULE=12]="SUPPORTS_RULE"}(_||(_={}));let S=t.body.querySelector("#micro-app-template-style");function D(e,n){const o=Ke.get(n);if(null==o?void 0:o.scopecss){const r=`${we.tagName}[name=${n}]`;if(S||(S=b("style"),S.setAttribute("id","micro-app-template-style"),t.body.appendChild(S),S.sheet.disabled=!0),e.textContent)S.textContent=e.textContent,C(S,e,e.textContent,r,o.url,e.linkpath),S.textContent="";else{const t=new MutationObserver((function(){var n,i;t.disconnect(),!e.textContent&&(null===(i=null===(n=e.sheet)||void 0===n?void 0:n.cssRules)||void 0===i?void 0:i.length)||e.hasAttribute("data-styled")||C(e,e,e.textContent,r,o.url,e.linkpath)}));t.observe(e,{childList:!0})}}return e}function R(e,t){Object.defineProperties(e,{currentTarget:{get:()=>t},srcElement:{get:()=>t},target:{get:()=>t}})}function P(e){const t=new CustomEvent("load");R(t,e),"function"==typeof e.onload?e.onload(t):e.dispatchEvent(t)}function M(e){const t=new CustomEvent("error");R(t,e),"function"==typeof e.onerror?e.onerror(t):e.dispatchEvent(t)}const L=new Map;function x(e,t,n,o,r=!1){const i=e.getAttribute("rel");let s=e.getAttribute("href"),c=null;if("stylesheet"===i&&s){if(s=a(s,n.url),r)return{url:s,info:{code:"",isGlobal:e.hasAttribute("global")}};{c=document.createComment(`the link with href=${s} move to micro-app-head as style element`);const t=document.createComment(`placeholder for link with href=${s}`);o.appendChild(t),n.source.links.set(s,{code:"",placeholder:t,isGlobal:e.hasAttribute("global")})}}else s&&e.setAttribute("href",a(s,n.url));return r?{replaceComment:c}:c?t.replaceChild(c,e):void 0}function U(e,t,o){const r=Array.from(t.source.links.entries()),i=[];for(const[e]of r){const n=L.get(e);n?i.push(n):i.push(_e(e,t.name))}l(i,(e=>{!function(e,t,n,o,r){t.isGlobal&&!L.has(e)&&L.set(e,n);const i=b("style");i.textContent=n,i.linkpath=e,o.replaceChild(D(i,r.name),t.placeholder),t.placeholder=null,t.code=n}(r[e.index][0],r[e.index][1],e.data,o,t)}),(e=>{n(e)}),(()=>{t.onLoad(e)}))}const T=new Map,j="noModule"in document.createElement("script");function $(e,t,n,o=!1){let r=null,i=e.getAttribute("src");if(e.hasAttribute("exclude"))r=document.createComment("script element with exclude attribute ignored by micro-app");else if(j&&e.noModule||!j&&"module"===e.type)r=document.createComment((e.noModule?"noModule":"module")+" script ignored by micro-app");else if(i){i=a(i,n.url);const t={code:"",isExternal:!0,isDynamic:o,async:e.hasAttribute("async"),defer:e.defer||"module"===e.type,module:"module"===e.type,isGlobal:e.hasAttribute("global")};if(o)return{url:i,info:t};n.source.scripts.set(i,t),r=document.createComment(`script with src='${i}' extract by micro-app`)}else if(e.textContent){const t=Math.random().toString(36).substr(2,15),i={code:e.textContent,isExternal:!1,isDynamic:o,async:!1,defer:"module"===e.type,module:"module"===e.type};if(o)return{url:t,info:i};n.source.scripts.set(t,i),r=document.createComment("inline script extract by micro-app")}else r=document.createComment("script ignored by micro-app");return o?{replaceComment:r}:t.replaceChild(r,e)}function I(e,t){const o=Array.from(t.source.scripts.entries()),r=[],i=[];for(const[e,n]of o)if(n.isExternal){const o=T.get(e);o?n.code=o:n.defer||n.async||(r.push(_e(e,t.name)),i.push([e,n]))}r.length?l(r,(e=>{!function(e,t,n){t.isGlobal&&!T.has(e)&&T.set(e,n);t.code=n}(i[e.index][0],i[e.index][1],e.data)}),(e=>{n(e)}),(()=>{t.onLoad(e)})):t.onLoad(e)}function k(e,t,n,o,r){var i;try{if(t=B(e,t,n),n.inline){const e=b("script");if(o&&e.setAttribute("type","module"),e.textContent=t,r)return e;null===(i=n.container)||void 0===i||i.querySelector("micro-app-body").appendChild(e)}else if((0,eval)(t),r)return document.createComment("dynamic script extract by micro-app")}catch(e){console.error("[micro-app from runScript]",e)}}function B(t,n,o){return"object"==typeof we.plugins&&(n=function(e,t,n,o){var r;if("[object Array]"===toString.call(o.global))for(const n of o.global)"object"==typeof n&&"function"==typeof n.loader&&(t=n.loader(t,e,n.options));if("[object Array]"===toString.call(null===(r=o.modules)||void 0===r?void 0:r[n]))for(const r of o.modules[n])"object"==typeof r&&"function"==typeof r.loader&&(t=r.loader(t,e,r.options));return t}(t,n,o.name,we.plugins)),o.sandBox?(e.proxyWindow=o.sandBox.proxyWindow,`;(function(window, self){with(window){;${n}\n}}).call(window.proxyWindow, window.proxyWindow, window.proxyWindow);`):n}const W=Element.prototype.setAttribute,H=Node.prototype.appendChild,q=Node.prototype.insertBefore,G=Node.prototype.replaceChild,F=Node.prototype.removeChild,K=Element.prototype.append,z=Element.prototype.prepend,V=Document.prototype.createElement,Y=Document.prototype.createElementNS,J=Document.prototype.createDocumentFragment,Z=Document.prototype.querySelector,Q=Document.prototype.querySelectorAll,X=Document.prototype.getElementById,ee=Document.prototype.getElementsByClassName,te=Document.prototype.getElementsByTagName,ne=Document.prototype.getElementsByName,oe=new WeakMap;function re(e,t,o){if(t instanceof HTMLStyleElement){if(t.hasAttribute("exclude")){const e=document.createComment("style element with exclude attribute ignored by micro-app");return oe.set(t,e),e}return o.scopecss?D(t,o.name):t}if(t instanceof HTMLLinkElement){if(t.hasAttribute("exclude")){const e=document.createComment("link element with exclude attribute ignored by micro-app");return oe.set(t,e),e}if(!o.scopecss)return t;const{url:i,info:s}=x(t,e,o,null,!0);if(i&&s){const e=b("style");return e.linkpath=i,function(e,t,o,i,s){if(o.source.links.has(e))return s.textContent=o.source.links.get(e).code,D(s,o.name),void r((()=>P(i)));if(L.has(e)){const n=L.get(e);return t.code=n,o.source.links.set(e,t),s.textContent=n,D(s,o.name),void r((()=>P(i)))}_e(e,o.name).then((n=>{t.code=n,o.source.links.set(e,t),t.isGlobal&&L.set(e,n),s.textContent=n,D(s,o.name),P(i)})).catch((e=>{n(e),M(i)}))}(i,s,o,t,e),oe.set(t,e),e}return t}if(t instanceof HTMLScriptElement){const{replaceComment:i,url:s,info:c}=$(t,e,o,!0);if(s&&c){if(c.code){const e=k(s,c.code,o,c.module,!0);return oe.set(t,e),e}{const e=function(e,t,o,i){if(o.source.scripts.has(e)){const n=o.source.scripts.get(e);return r((()=>P(i))),k(e,n.code,o,t.module,!0)}if(T.has(e)){const n=T.get(e);return t.code=n,o.source.scripts.set(e,t),r((()=>P(i))),k(e,n,o,t.module,!0)}let s;return s=o.inline?b("script"):document.createComment(`dynamic script with src='${e}' extract by micro-app`),_e(e,o.name).then((n=>{t.code=n,o.source.scripts.set(e,t),t.isGlobal&&T.set(e,n);try{n=B(e,n,o),o.inline?(t.module&&s.setAttribute("type","module"),s.textContent=n):(0,eval)(n)}catch(t){console.error("[micro-app from runDynamicScript]",t,e)}P(i)})).catch((e=>{n(e),M(i)})),s}(s,c,o,t);return oe.set(t,e),e}}return oe.set(t,i),i}return t}function ie(e,t,n,o,r){if(n instanceof HTMLHeadElement){const i=e.container.querySelector("micro-app-head");return r&&!i.contains(r)?H.call(i,o):t!==F||i.contains(o)?t===K||t===z?t.call(i,o):t.call(i,o,r):n.contains(o)?t.call(n,o):o}if(n instanceof HTMLBodyElement){const i=e.container.querySelector("micro-app-body");return r&&!i.contains(r)?H.call(i,o):t!==F||i.contains(o)?t===K||t===z?t.call(i,o):t.call(i,o,r):n.contains(o)?t.call(n,o):o}return t===K||t===z?t.call(n,o):t.call(n,o,r)}function se(e){var t;return null!==(t=oe.get(e))&&void 0!==t?t:e}function ce(e,t,n,o){if(null==t?void 0:t.__MICRO_APP_NAME__){const r=Ke.get(t.__MICRO_APP_NAME__);return(null==r?void 0:r.container)?ie(r,o,e,re(e,t,r),n&&se(n)):o===K||o===z?o.call(e,t):o.call(e,t,n)}if(o===K||o===z){const n=h();if(!(t instanceof Node)&&n){const r=Ke.get(n);if(null==r?void 0:r.container){if(e instanceof HTMLHeadElement)return o.call(r.container.querySelector("micro-app-head"),t);if(e instanceof HTMLBodyElement)return o.call(r.container.querySelector("micro-app-body"),t)}}return o.call(e,t)}return o.call(e,t,n)}function ae(){!function(){function e(e){var n,o,r;const i=h();return i&&"head"!==e&&"body"!==e&&"html"!==e?null!==(r=null===(o=null===(n=Ke.get(i))||void 0===n?void 0:n.container)||void 0===o?void 0:o.querySelector(e))&&void 0!==r?r:null:Z.call(t,e)}function n(e){var n,o,r;const i=h();return i&&"head"!==e&&"body"!==e&&"html"!==e?null!==(r=null===(o=null===(n=Ke.get(i))||void 0===n?void 0:n.container)||void 0===o?void 0:o.querySelectorAll(e))&&void 0!==r?r:[]:Q.call(t,e)}Document.prototype.createElement=function(e,n){return le(V.call(t,e,n))},Document.prototype.createElementNS=function(e,n,o){return le(Y.call(t,e,n,o))},Document.prototype.createDocumentFragment=function(){return le(J.call(t))},Document.prototype.querySelector=e,Document.prototype.querySelectorAll=n,Document.prototype.getElementById=function(n){return!h()||/^\d/.test(n)?X.call(t,n):e(`#${n}`)},Document.prototype.getElementsByClassName=function(e){return!h()||/^\d/.test(e)?ee.call(t,e):n(`.${e}`)},Document.prototype.getElementsByTagName=function(e){var o;const r=h();return!r||/^body$/i.test(e)||/^head$/i.test(e)||/^html$/i.test(e)||!(null===(o=Ke.get(r))||void 0===o?void 0:o.inline)&&/^script$/i.test(e)?te.call(t,e):n(e)},Document.prototype.getElementsByName=function(e){return!h()||/^\d/.test(e)?ne.call(t,e):n(`[name=${e}]`)}}(),Element.prototype.setAttribute=function(e,t){if(/^micro-app(-\S+)?/i.test(this.tagName)&&"data"===e)if("[object Object]"===toString.call(t)){const e={};Object.getOwnPropertyNames(t).forEach((n=>{"string"==typeof n&&0===n.indexOf("__")||(e[n]=t[n])})),this.data=e}else"[object Object]"!==t&&o("property data must be an object");else if(("src"===e&&/^(img|iframe|script)$/i.test(this.tagName)||"href"===e&&/^link$/i.test(this.tagName))&&this.__MICRO_APP_NAME__&&Ke.has(this.__MICRO_APP_NAME__)){const n=Ke.get(this.__MICRO_APP_NAME__);W.call(this,e,a(t,n.url))}else W.call(this,e,t)},Node.prototype.appendChild=function(e){return ce(this,e,null,H)},Node.prototype.insertBefore=function(e,t){return ce(this,e,t,q)},Node.prototype.replaceChild=function(e,t){return ce(this,e,t,G)},Element.prototype.append=function(...e){let t=0;const n=e.length;for(;t<n;)ce(this,e[t],null,K),t++},Element.prototype.prepend=function(...e){let t=e.length;for(;t>0;)ce(this,e[t-1],null,z),t--},Node.prototype.removeChild=function(e){if(null==e?void 0:e.__MICRO_APP_NAME__){const t=Ke.get(e.__MICRO_APP_NAME__);return(null==t?void 0:t.container)?ie(t,F,this,se(e)):F.call(this,e)}return F.call(this,e)}}function le(e){const t=h();return t&&(e.__MICRO_APP_NAME__=t),e}function ue(){d(null),Document.prototype.createElement=V,Document.prototype.createElementNS=Y,Document.prototype.createDocumentFragment=J,Document.prototype.querySelector=Z,Document.prototype.querySelectorAll=Q,Document.prototype.getElementById=X,Document.prototype.getElementsByClassName=ee,Document.prototype.getElementsByTagName=te,Document.prototype.getElementsByName=ne,Element.prototype.setAttribute=W,Node.prototype.appendChild=H,Node.prototype.insertBefore=q,Node.prototype.replaceChild=G,Node.prototype.removeChild=F,Element.prototype.append=K,Element.prototype.prepend=z}let pe=!1;function de(e,t,o,r){var i;if(!e)return n(`element does not exist in lifecycle ${o},it seems the app has unmounted`);e instanceof ShadowRoot&&(e=e.host);const s=Object.assign({name:t,container:e},r&&{error:r}),c=new CustomEvent(o,{detail:s});!function(e,t){Object.defineProperties(e,{currentTarget:{get:()=>t},target:{get:()=>t}})}(c,e),"function"==typeof(null===(i=we.lifeCycles)||void 0===i?void 0:i[o])&&we.lifeCycles[o](c),e.dispatchEvent(c)}function he(){Ke.forEach((e=>{let t=e.container;t&&(t instanceof ShadowRoot&&(t=t.host),t.disconnectedCallback())})),Ke.clear()}class me extends HTMLElement{constructor(){super(...arguments),this.appName="",this.appUrl="",this.version="0.2.5",this.isWating=!1,this.cacheData=null,this.handleAttributeUpdate=()=>{var e;this.isWating=!1;const t=this.getAttribute("name"),o=s(this.getAttribute("url"));if(this.legalAttribute("name",t)&&this.legalAttribute("url",o)){const r=Ke.get(t);if(t!==this.appName&&r&&r.getAppStatus()!==E.UNMOUNT&&!r.isPrefetch)return this.setAttribute("name",this.appName),n(`an app named ${t} already exists`);t===this.appName&&o===this.appUrl||(this.handleUnmount(!0),this.appName=t,this.appUrl=o,(null!==(e=this.shadowRoot)&&void 0!==e?e:this).innerHTML="",r&&r.url===o?this.handleAppMount(r):this.handleCreate())}else t!==this.appName&&this.setAttribute("name",this.appName)}}static get observedAttributes(){return["name","url"]}connectedCallback(){if(1==++me.microAppCount&&(ae(),function(){if(!pe){pe=!0;const e=b("style");e.setAttribute("type","text/css"),e.textContent=`\n${we.tagName}, micro-app-body { display: block; } \nmicro-app-head { display: none; }`,t.head.appendChild(e)}}(),window.__MICRO_APP_ENVIRONMENT__&&window.addEventListener("unmount",he,!1)),r((()=>de(this,this.appName,w.CREATED))),!this.appName||!this.appUrl)return;this.getDisposeResult("shadowDOM")&&!this.shadowRoot&&this.attachShadow({mode:"open"});const e=Ke.get(this.appName);e?e.url!==this.appUrl||!e.isPrefetch&&e.getAppStatus()!==E.UNMOUNT?e.isPrefetch?n(`the url: ${this.appUrl} is different from prefetch url: ${e.url}`):n(`an app named ${this.appName} already exists`):this.handleAppMount(e):this.handleCreate()}disconnectedCallback(){me.microAppCount>0&&(this.handleUnmount(this.getDisposeResult("destory")),0==--me.microAppCount&&(ue(),window.__MICRO_APP_ENVIRONMENT__&&window.removeEventListener("unmount",he,!1)))}attributeChangedCallback(e,t,o){if(this.legalAttribute(e,o)&&this[e===g.NAME?"appName":"appUrl"]!==o)if(e!==g.URL||this.appUrl)e!==g.NAME||this.appName?this.isWating||(this.isWating=!0,r(this.handleAttributeUpdate)):(this.cacheData&&(we.setData(o,this.cacheData),this.cacheData=null),this.appName=o);else{if(!(o=s(o)))return n("Invalid attribute url");this.appUrl=o}}legalAttribute(e,t){return!("string"!=typeof t||!t)||(n(`unexpected attribute ${e}, please check again`),!1)}handleAppMount(e){e.isPrefetch=!1,r((()=>{var t,n;return e.mount(null!==(t=this.shadowRoot)&&void 0!==t?t:this,this.getDisposeResult("inline"),null!==(n=this.getAttribute("baseurl"))&&void 0!==n?n:"")}))}handleCreate(){var e,t;const n=new ze({name:this.appName,url:this.appUrl,container:null!==(e=this.shadowRoot)&&void 0!==e?e:this,inline:this.getDisposeResult("inline"),scopecss:!(this.getDisposeResult("disableScopecss")||this.getDisposeResult("shadowDOM")),useSandbox:!this.getDisposeResult("disableSandbox"),macro:this.getDisposeResult("macro"),baseurl:null!==(t=this.getAttribute("baseurl"))&&void 0!==t?t:""});Ke.set(this.appName,n)}handleUnmount(e){const t=Ke.get(this.appName);t&&t.getAppStatus()!==E.UNMOUNT&&t.unmount(e)}getDisposeResult(e){return(this.hasAttribute(e)||we[e])&&"false"!==this.getAttribute(e)}set data(e){this.appName?we.setData(this.appName,e):this.cacheData=e}get data(){return this.appName?we.getData(this.appName,!0):this.cacheData?this.cacheData:null}}me.microAppCount=0;const fe=new class{constructor(){this.eventList=new Map}isLegalName(e){return!!e||(n("event-center: Invalid name"),!1)}on(e,t,o=!1){if(this.isLegalName(e)){if("function"!=typeof t)return n("event-center: Invalid callback function");let r=this.eventList.get(e);r?o&&Object.getOwnPropertyNames(r.data).length&&t(r.data):(r={data:{},callbacks:new Set},this.eventList.set(e,r)),r.callbacks.add(t)}}off(e,t){if(this.isLegalName(e)){const n=this.eventList.get(e);n&&("function"==typeof t?n.callbacks.delete(t):n.callbacks.clear())}}dispatch(e,t){if(this.isLegalName(e)){if("[object Object]"!==toString.call(t))return n("event-center: data must be object");let o=this.eventList.get(e);if(o){if(o.data!==t){o.data=t;for(const e of o.callbacks)e(t)}}else o={data:t,callbacks:new Set},this.eventList.set(e,o)}}getData(e){var t;const n=this.eventList.get(e);return null!==(t=null==n?void 0:n.data)&&void 0!==t?t:null}};function ye(e,t){return"string"==typeof e&&e?t?`__from_base_app_${e}__`:`__from_micro_app_${e}__`:""}class be{addGlobalDataListener(e,t){fe.on("global",e,t)}removeGlobalDataListener(e){"function"==typeof e&&fe.off("global",e)}setGlobalData(e){fe.dispatch("global",e)}clearGlobalDataListener(){fe.off("global")}}class ge extends be{addDataListener(e,t,n){fe.on(ye(e,!1),t,n)}removeDataListener(e,t){"function"==typeof t&&fe.off(ye(e,!1),t)}getData(e,t=!1){return fe.getData(ye(e,t))}setData(e,t){fe.dispatch(ye(e,!0),t)}clearDataListener(e){fe.off(ye(e,!1))}}class Ee extends be{constructor(e){super(),this.appName=e}addDataListener(e,t){fe.on(ye(this.appName,!0),e,t)}removeDataListener(e){"function"==typeof e&&fe.off(ye(this.appName,!0),e)}getData(){return fe.getData(ye(this.appName,!0))}dispatch(e){m(),fe.dispatch(ye(this.appName,!1),e);const t=Ke.get(this.appName);if((null==t?void 0:t.container)&&"[object Object]"===toString.call(e)){const n=new CustomEvent("datachange",{detail:{data:e}});let o=t.container;o instanceof ShadowRoot&&(o=o.host),o.dispatchEvent(n)}}clearDataListener(){fe.off(ye(this.appName,!0))}}var we=new class extends ge{constructor(){super(...arguments),this.tagName="micro-app",this.preFetch=Ve}start(e){if(!(null===window||void 0===window?void 0:window.customElements))return n("customElements is not supported in this environment");if(null==e?void 0:e.tagName){if(!/^micro-app(-\S+)?/.test(e.tagName))return n(`${e.tagName} is invalid tagName`);this.tagName=e.tagName}var t,r;r=this.tagName,(window.customElements.get(r)?(o(`element ${r} is already defined`),0):(window.customElements.define(r,me),1))&&e&&"[object Object]"===toString.call(e)&&(this.shadowDOM=e.shadowDOM,this.destory=e.destory,this.inline=e.inline,this.disableScopecss=e.disableScopecss,this.disableSandbox=e.disableSandbox,this.macro=e.macro,y(e.fetch)&&(this.fetch=e.fetch),"[object Object]"===toString.call(e.lifeCycles)&&(this.lifeCycles=e.lifeCycles),"[object Object]"===toString.call(e.plugins)&&(this.plugins=e.plugins),e.preFetchApps&&Ve(e.preFetchApps),e.globalAssets&&(t=e.globalAssets,"[object Object]"===toString.call(t)&&u((()=>{if("[object Array]"===toString.call(t.js)){const e=t.js.filter((e=>"string"==typeof e&&e.includes(".js")&&!T.has(e))),o=[];e.forEach((e=>{o.push(_e(e))})),l(o,(t=>{const n=e[t.index];T.has(n)||T.set(n,t.data)}),(e=>{n(e)}))}if("[object Array]"===toString.call(t.css)){const e=t.css.filter((e=>"string"==typeof e&&e.includes(".css")&&!L.has(e))),o=[];e.forEach((e=>{o.push(_e(e))})),l(o,(t=>{const n=e[t.index];L.has(n)||L.set(n,t.data)}),(e=>{n(e)}))}}))))}};function _e(e,t=null,n={}){return y(we.fetch)?we.fetch(e,n,t):fetch(e,n).then((e=>e.text()))}function ve(e,t,n){const o=Array.from(e.children);o.length&&o.forEach((e=>{ve(e,t,n)}));for(const r of o)r instanceof HTMLLinkElement?r.hasAttribute("exclude")?e.replaceChild(document.createComment("link element with exclude attribute ignored by micro-app"),r):t.scopecss?x(r,e,t,n):r.hasAttribute("href")&&r.setAttribute("href",a(r.getAttribute("href"),t.url)):r instanceof HTMLStyleElement?r.hasAttribute("exclude")?e.replaceChild(document.createComment("style element with exclude attribute ignored by micro-app"),r):t.scopecss&&n.appendChild(D(r,t.name)):r instanceof HTMLScriptElement?$(r,e,t):r instanceof HTMLMetaElement||r instanceof HTMLTitleElement?e.removeChild(r):/^(img|iframe)$/i.test(r.tagName)&&r.hasAttribute("src")&&r.setAttribute("src",a(r.getAttribute("src"),t.url))}function Ne(e,t){const o=function(e){const t=b("div");return t.innerHTML=e,t}(e),r=o.querySelector("micro-app-head"),i=o.querySelector("micro-app-body");if(!r||!i){const e=`element ${r?"body":"head"} is missing`;return t.onerror(new Error(e)),n(e)}ve(o,t,r),t.source.links.size?U(o,t,r):t.onLoad(o),t.source.scripts.size?I(o,t):t.onLoad(o)}const Ae=new WeakMap;const Oe=new WeakMap;function Ce(e,t){if(Oe.has(t))return Oe.get(t);if(y(t)&&!function(e){if(Ae.has(e))return Ae.get(e);const t=e.toString(),n=e.prototype&&e.prototype.constructor===e&&Object.getOwnPropertyNames(e.prototype).length>1||/^function\s+[A-Z]/.test(t)||/^class\s+/.test(t);return Ae.set(e,n),n}(t)){const n=t.bind(e);for(const e in t)n[e]=t[e];return t.hasOwnProperty("prototype")&&!n.hasOwnProperty("prototype")&&(n.prototype=t.prototype),Oe.set(t,n),n}return t}const Se=window.addEventListener,De=window.removeEventListener,Re=window.setInterval,Pe=window.setTimeout,Me=window.clearInterval,Le=window.clearTimeout,xe=document.addEventListener,Ue=document.removeEventListener,Te=new Map;let je=!1;const $e=new Map;function Ie(){je||function(){je=!0;const e=Object.getOwnPropertyDescriptor(document,"onclick");if(!1===(null==e?void 0:e.configurable))return n("Cannot redefine document property onclick");const t=document.onclick;document.onclick=null;let o=!1;function r(e){Te.forEach((t=>{"function"==typeof t&&t.call(document,e)}))}Object.defineProperty(document,"onclick",{configurable:!1,enumerable:!0,get(){const e=h();return e?Te.get(e):Te.get("base")},set(e){const t=h();t?Te.set(t,e):Te.set("base",e),o||"function"!=typeof e||(o=!0,xe.call(document,"click",r,!1))}}),t&&(document.onclick=t)}(),document.addEventListener=function(e,t,n){const o=h();if(o){const n=$e.get(o);if(n){const o=n.get(e);o?o.add(t):n.set(e,new Set([t]))}else $e.set(o,new Map([[e,new Set([t])]]))}return xe.call(document,e,t,n)},document.removeEventListener=function(e,t,n){const o=h();if(o){const n=$e.get(o);if(n){const o=n.get(e);(null==o?void 0:o.size)&&o.has(t)&&o.delete(t)}}return Ue.call(document,e,t,n)}}function ke(e,t){return"unmount"===e?`unmount-${t.__MICRO_APP_NAME__}`:e}const Be=["System","__cjsWrapper","__REACT_ERROR_OVERLAY_GLOBAL_HOOK__"],We=["location"],He={undefined:!0,Array:!0,Object:!0,String:!0,Boolean:!0,Math:!0,Number:!0,Symbol:!0,parseFloat:!0,Float32Array:!0};let qe;function Ge(e){qe&&clearTimeout(qe),qe=setTimeout(e,0)}class Fe{constructor(n,o,i){this.active=!1,this.scopeProperties=["webpackJsonp"],this.escapeProperties=[],this.microWindow={},this.injectedKeys=new Set,this.escapeKeys=new Set;const s=new Map,c=t=>this.microWindow.hasOwnProperty(t)||e.hasOwnProperty(t);this.getScopeProperties(n),this.inject(this.microWindow,n,o),this.releaseEffect=function(e){const t=new Map,n=new Set,o=new Set;return e.addEventListener=function(n,o,r){n=ke(n,e);const i=t.get(n);return i?i.add(o):t.set(n,new Set([o])),Se.call(window,n,o,r)},e.removeEventListener=function(n,o,r){n=ke(n,e);const i=t.get(n);return(null==i?void 0:i.size)&&i.has(o)&&i.delete(o),De.call(window,n,o,r)},e.setInterval=function(e,t,...o){const r=Re(e,t,...o);return n.add(r),r},e.setTimeout=function(e,t,...n){const r=Pe(e,t,...n);return o.add(r),r},e.clearInterval=function(e){n.delete(e),Me(e)},e.clearTimeout=function(e){o.delete(e),Le(e)},()=>{t.size&&(t.forEach(((e,t)=>{if(e.size)for(const n of e)De.call(window,t,n)})),t.clear()),n.size&&(n.forEach((e=>{Me(e)})),n.clear()),o.size&&(o.forEach((e=>{Le(e)})),o.clear());const r=e.__MICRO_APP_NAME__;Te.delete(r);const i=$e.get(r);i&&(i.forEach(((e,t)=>{if(e.size)for(const n of e)Ue.call(document,t,n)})),i.clear())}}(this.microWindow),this.proxyWindow=new Proxy(this.microWindow,{get:(o,s)=>{if(s===Symbol.unscopables)return He;if(["window","self","globalThis"].includes(s))return this.proxyWindow;if("top"===s||"parent"===s)return e===e.parent?this.proxyWindow:Reflect.get(e,s);if("hasOwnProperty"===s)return c;if("document"===s||"eval"===s)switch(this.active&&(d(n),(i?Ge:r)((()=>d(null)))),s){case"document":return t;case"eval":return eval}if(this.scopeProperties.includes(s))return Reflect.get(o,s);if(Reflect.has(o,s))return Reflect.get(o,s);const a=Reflect.get(e,s);return Ce(e,a)},set:(t,n,o)=>{if(this.active){if(We.includes(n))Reflect.set(e,n,o);else if(t.hasOwnProperty(n)||!e.hasOwnProperty(n)||this.scopeProperties.includes(n))Reflect.set(t,n,o),this.injectedKeys.add(n);else{const r=Object.getOwnPropertyDescriptor(e,n),{writable:i,configurable:s,enumerable:c}=r;i&&(Object.defineProperty(t,n,{configurable:s,enumerable:c,writable:i,value:o}),this.injectedKeys.add(n))}(this.escapeProperties.includes(n)||Be.includes(n)&&!Reflect.has(e,n))&&!this.scopeProperties.includes(n)&&(Reflect.set(e,n,o),this.escapeKeys.add(n))}return!0},has:(t,n)=>this.scopeProperties.includes(n)?n in t:n in He||n in t||n in e,getOwnPropertyDescriptor:(t,n)=>{if(t.hasOwnProperty(n))return s.set(n,"target"),Object.getOwnPropertyDescriptor(t,n);if(e.hasOwnProperty(n)){s.set(n,"rawWindow");const t=Object.getOwnPropertyDescriptor(e,n);return t&&!t.configurable&&(t.configurable=!0),t}},defineProperty:(t,n,o)=>"rawWindow"===s.get(n)?Reflect.defineProperty(e,n,o):Reflect.defineProperty(t,n,o),ownKeys:t=>Reflect.ownKeys(e).concat(Reflect.ownKeys(t)).filter((function(e){return!(e in this)&&(this[e]=!0)}),Object.create(null)),deleteProperty:(t,n)=>!t.hasOwnProperty(n)||(this.escapeKeys.has(n)&&Reflect.deleteProperty(e,n),Reflect.deleteProperty(t,n))})}start(t){this.active||(this.active=!0,this.microWindow.__MICRO_APP_BASE_URL__=t,e._babelPolyfill&&(e._babelPolyfill=!1),1==++Fe.activeCount&&Ie())}stop(){this.active&&(this.active=!1,this.releaseEffect(),this.microWindow.microApp.clearDataListener(),this.injectedKeys.forEach((e=>{Reflect.deleteProperty(this.microWindow,e)})),this.injectedKeys.clear(),this.escapeKeys.forEach((t=>{Reflect.deleteProperty(e,t)})),this.escapeKeys.clear(),0==--Fe.activeCount&&(document.addEventListener=xe,document.removeEventListener=Ue))}getScopeProperties(e){var t;if("object"==typeof we.plugins){if("[object Array]"===toString.call(we.plugins.global))for(const e of we.plugins.global)"object"==typeof e&&("[object Array]"===toString.call(e.scopeProperties)&&(this.scopeProperties=this.scopeProperties.concat(e.scopeProperties)),"[object Array]"===toString.call(e.escapeProperties)&&(this.escapeProperties=this.escapeProperties.concat(e.escapeProperties)));if("[object Array]"===toString.call(null===(t=we.plugins.modules)||void 0===t?void 0:t[e]))for(const t of we.plugins.modules[e])"object"==typeof t&&("[object Array]"===toString.call(t.scopeProperties)&&(this.scopeProperties=this.scopeProperties.concat(t.scopeProperties)),"[object Array]"===toString.call(t.escapeProperties)&&(this.escapeProperties=this.escapeProperties.concat(t.escapeProperties)))}}inject(n,o,r){n.__MICRO_APP_ENVIRONMENT__=!0,n.__MICRO_APP_NAME__=o,n.__MICRO_APP_PUBLIC_PATH__=c(r),n.microApp=new Ee(o),n.rawWindow=e,n.rawDocument=t}}Fe.activeCount=0;const Ke=new Map;class ze{constructor({name:e,url:t,container:n,inline:o,scopecss:r,useSandbox:i,macro:s,baseurl:c}){this.status=E.NOT_LOADED,this.loadSourceLevel=0,this.isPrefetch=!1,this.container=null,this.macro=!1,this.baseurl="",this.sandBox=null,this.container=null!=n?n:null,this.inline=null!=o&&o,this.baseurl=null!=c?c:"",this.name=e,this.url=t,this.useSandbox=i,this.scopecss=this.useSandbox&&r,this.macro=null!=s&&s,this.source={links:new Map,scripts:new Map},this.loadSourceCode(),this.useSandbox&&(this.sandBox=new Fe(e,t,this.macro))}loadSourceCode(){var e;this.status=E.LOADING_SOURCE_CODE,_e((e=this).url,e.name,{cache:"no-cache"}).then((t=>{if(!t){const t="html is empty, please check in detail";return e.onerror(new Error(t)),n(t)}Ne(t=t.replace(/<head[^>]*>[\s\S]*?<\/head>/i,(e=>e.replace(/<head/i,"<micro-app-head").replace(/<\/head>/i,"</micro-app-head>"))).replace(/<body[^>]*>[\s\S]*?<\/body>/i,(e=>e.replace(/<body/i,"<micro-app-body").replace(/<\/body>/i,"</micro-app-body>"))),e)})).catch((t=>{n(`Failed to fetch data from ${e.url}, micro-app stop rendering`,t),e.onLoadError(t)}))}onLoad(e){if(2==++this.loadSourceLevel){if(this.source.html=e,this.isPrefetch||this.status===E.UNMOUNT)return;this.status=E.LOAD_SOURCE_FINISHED,this.mount()}}onLoadError(e){this.loadSourceLevel=-1,this.status!==E.UNMOUNT&&(this.onerror(e),this.status=E.LOAD_SOURCE_ERROR)}mount(e,t,o){var i;if(!this.container&&e&&(this.container=e),"boolean"==typeof t&&t!==this.inline&&(this.inline=t),this.baseurl=null!=o?o:this.baseurl,2!==this.loadSourceLevel)return void(this.status=E.LOADING_SOURCE_CODE);de(this.container,this.name,w.BEFOREMOUNT),this.status=E.MOUNTING;const s=this.source.html.cloneNode(!0),c=document.createDocumentFragment();Array.from(s.childNodes).forEach((e=>{c.appendChild(e)})),this.container.appendChild(c),null===(i=this.sandBox)||void 0===i||i.start(this.baseurl),function(e,t){const o=Array.from(e.entries()),r=[],i=[];for(const[e,n]of o)n.isDynamic||(n.defer||n.async?(n.isExternal?r.push(_e(e,t.name)):r.push(n.code),i.push([e,n])):k(e,n.code,t,n.module,!1));r.length&&Promise.all(r).then((e=>{e.forEach(((e,n)=>{k(i[n][0],e,t,i[n][1].module,!1)}))})).catch((e=>{n(e)}))}(this.source.scripts,this),this.status!==E.UNMOUNT&&(this.status=E.MOUNTED,r((()=>{this.status!==E.UNMOUNT&&de(this.container,this.name,w.MOUNTED)})))}unmount(e){var t;this.status===E.LOAD_SOURCE_ERROR&&(e=!0),this.status=E.UNMOUNT,de(this.container,this.name,w.UNMOUNT),function(e){const t=new CustomEvent(`unmount-${e}`);window.dispatchEvent(t)}(this.name),null===(t=this.sandBox)||void 0===t||t.stop(),this.container=null,e&&Ke.delete(this.name)}onerror(e){de(this.container,this.name,w.ERROR,e)}getAppStatus(){return this.status}}function Ve(e){u((()=>{"function"==typeof e&&(e=e()),function(e){const t=[];return"[object Array]"===toString.call(e)&&e.forEach((e=>{e.url=s(e.url),"[object Object]"===toString.call(e)&&e.name&&"string"==typeof e.name&&e.url&&!Ke.has(e.name)&&t.push(e)})),t}(e).forEach((e=>{var t,n,o;const r=new ze({name:e.name,url:e.url,scopecss:!(null!==(t=e.disableScopecss)&&void 0!==t?t:we.disableScopecss),useSandbox:!(null!==(n=e.disableSandbox)&&void 0!==n?n:we.disableSandbox),macro:null!==(o=e.macro)&&void 0!==o?o:we.macro});r.isPrefetch=!0,Ke.set(e.name,r)}))}))}exports.default=we,exports.preFetch=Ve,exports.pureCreateElement=b,exports.removeDomScope=m,exports.version="0.2.5";
//# sourceMappingURL=index.min.js.map

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).microApp={})}(this,(function(e){"use strict";const t=new Function("return window")(),n=new Function("return document")(),o="0.2.4";function r(e){return"string"==typeof e?`[micro-app] ${e}`:e}function i(e,...t){Promise.resolve().then(e.bind(null,...t))}function s(e){return e.startsWith("//")?`${location.protocol}${e}`:e}function c(e){if("string"!=typeof e||!e)return"";try{const{origin:t,pathname:n}=new URL(s(e));if(/\.html$/.test(n))return`${t}${n}`;const o=`${t}${n}/`.replace(/\/\/$/,"/");return/^https?:\/\//.test(o)?o:""}catch(e){return console.error("[micro-app]",e),""}}function a(e){if(/\.html$/.test(e)){const t=e.split("/");return t.pop(),t.join("/")+"/"}return e}function l(e,t){return/^((((ht|f)tps?)|file):)?\/\//.test(e)?e:(t=s(t),new URL(e,a(t)).toString())}function u(e,t,n,o){let r=0;function i(){++r===e.length&&o&&o()}e.forEach(((e,o)=>{"[object Promise]"===toString.call(e)?e.then((e=>{t({data:e,index:o}),i()})).catch((e=>{n({error:e,index:o}),i()})):(t({data:e,index:o}),i())}))}const p=window.requestIdleCallback||function(e){const t=Date.now();return setTimeout((function(){e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-t))})}),1)};let d=null;function h(e){d=e}function m(){return d}function f(){h(null)}function y(){return/Safari/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)}function b(e){return"function"==typeof e}function g(e,t){const o=n.createElement(e,t);return o.__MICRO_APP_NAME__&&delete o.__MICRO_APP_NAME__,o}var E,w,_,v;function A(e,t){const{selectorText:n,cssText:o}=e;if(/^((html[\s>~,]+body)|(html|body|:root))$/.test(n))return o.replace(/^((html[\s>~,]+body)|(html|body|:root))/,t);if("*"===n)return o.replace("*",`${t} *`);const r=/(^|\s+)((html[\s>~]+body)|(html|body|:root))(?=[\s>~]+|$)/;return o.replace(/^[\s\S]+{/,(e=>e.replace(/(^|,)([^,]+)/g,((e,n,o)=>r.test(o)?e.replace(r,t):`${n} ${t} ${o.replace(/^\s*/,"")}`))))}function O(e,t,n,o){return e.replace(/url\(["']?([^)"']+)["']?\)/gm,((e,r)=>{if(/^data:/.test(r))return e;if(/^(https?:)?\/\//.test(r)){if(!y())return e;{const t=r.replace(/^https?:/,"");if(-1!==n.indexOf(t))return e;r=r.replace(window.location.origin,"")}}return/^((\.\.?\/)|[^/])/.test(r)&&o&&(t=function(e){const t=e.split("/");return t.pop(),s(t.join("/")+"/")}(o)),`url("${l(r,t)}")`}))}function N(e,t,n){const o=C(Array.from(e.cssRules),t);return`@${n} ${e.conditionText} {${o}}`}function C(e,t){let n="";for(const o of e)switch(o.type){case v.STYLE_RULE:n+=A(o,t);break;case v.MEDIA_RULE:n+=N(o,t,"media");break;case v.SUPPORTS_RULE:n+=N(o,t,"supports");break;default:n+=o.cssText}return n.replace(/^\s+/,"")}function S(e,t,n,o,r,i){var s,c;let a=O(C(Array.from(null!==(c=null===(s=e.sheet)||void 0===s?void 0:s.cssRules)&&void 0!==c?c:[]),o),r,n,i);y()&&(a=a.replace(/([;{]\s*content:\s*)([^\s"][^";}]*)/gm,((e,t,n)=>"none"===n||/^(url\()|(counter\()|(attr\()|(open-quote)|(close-quote)/.test(n)?e:`${t}"${n}"`))),t.textContent=a}!function(e){e.NAME="name",e.URL="url"}(E||(E={})),function(e){e.NOT_LOADED="NOT_LOADED",e.LOADING_SOURCE_CODE="LOADING_SOURCE_CODE",e.LOAD_SOURCE_FINISHED="LOAD_SOURCE_FINISHED",e.LOAD_SOURCE_ERROR="LOAD_SOURCE_ERROR",e.MOUNTING="MOUNTING",e.MOUNTED="MOUNTED",e.UNMOUNT="UNMOUNT"}(w||(w={})),function(e){e.CREATED="created",e.BEFOREMOUNT="beforemount",e.MOUNTED="mounted",e.UNMOUNT="unmount",e.ERROR="error"}(_||(_={})),function(e){e[e.STYLE_RULE=1]="STYLE_RULE",e[e.MEDIA_RULE=4]="MEDIA_RULE",e[e.SUPPORTS_RULE=12]="SUPPORTS_RULE"}(v||(v={}));let D=n.body.querySelector("#micro-app-template-style");function P(e,t){const o=ze.get(t);if(null==o?void 0:o.scopecss){const r=`${_e.tagName}[name=${t}]`;if(D||(D=g("style"),D.setAttribute("id","micro-app-template-style"),n.body.appendChild(D),D.sheet.disabled=!0),e.textContent)D.textContent=e.textContent,S(D,e,e.textContent,r,o.url,e.linkpath),D.textContent="";else{const t=new MutationObserver((function(){var n,i;t.disconnect(),!e.textContent&&(null===(i=null===(n=e.sheet)||void 0===n?void 0:n.cssRules)||void 0===i?void 0:i.length)||e.hasAttribute("data-styled")||S(e,e,e.textContent,r,o.url,e.linkpath)}));t.observe(e,{childList:!0})}}return e}function R(e,t){Object.defineProperties(e,{currentTarget:{get:()=>t},srcElement:{get:()=>t},target:{get:()=>t}})}function M(e){const t=new CustomEvent("load");R(t,e),"function"==typeof e.onload?e.onload(t):e.dispatchEvent(t)}function L(e){const t=new CustomEvent("error");R(t,e),"function"==typeof e.onerror?e.onerror(t):e.dispatchEvent(t)}const x=new Map;function T(e,t,n,o,r=!1){const i=e.getAttribute("rel");let s=e.getAttribute("href"),c=null;if("stylesheet"===i&&s){if(s=l(s,n.url),r)return{url:s,info:{code:"",isGlobal:e.hasAttribute("global")}};{c=document.createComment(`the link with href=${s} move to micro-app-head as style element`);const t=document.createComment(`placeholder for link with href=${s}`);o.appendChild(t),n.source.links.set(s,{code:"",placeholder:t,isGlobal:e.hasAttribute("global")})}}else s&&e.setAttribute("href",l(s,n.url));return r?{replaceComment:c}:c?t.replaceChild(c,e):void 0}function U(e,t,n){const o=Array.from(t.source.links.entries()),r=[];for(const[e]of o){const n=x.get(e);n?r.push(n):r.push(ve(e,t.name))}u(r,(e=>{!function(e,t,n,o,r){t.isGlobal&&!x.has(e)&&x.set(e,n);const i=g("style");i.textContent=n,i.linkpath=e,o.replaceChild(P(i,r.name),t.placeholder),t.placeholder=null,t.code=n}(o[e.index][0],o[e.index][1],e.data,n,t)}),(e=>{console.error("[micro-app]",e)}),(()=>{t.onLoad(e)}))}const j=new Map,$="noModule"in document.createElement("script");function I(e,t,n,o=!1){let r=null,i=e.getAttribute("src");if(e.hasAttribute("exclude"))r=document.createComment("script element with exclude attribute ignored by micro-app");else if($&&e.noModule||!$&&"module"===e.type)r=document.createComment((e.noModule?"noModule":"module")+" script ignored by micro-app");else if(i){i=l(i,n.url);const t={code:"",isExternal:!0,isDynamic:o,async:e.hasAttribute("async"),defer:e.defer||"module"===e.type,module:"module"===e.type,isGlobal:e.hasAttribute("global")};if(o)return{url:i,info:t};n.source.scripts.set(i,t),r=document.createComment(`script with src='${i}' extract by micro-app`)}else if(e.textContent){const t=Math.random().toString(36).substr(2,15),i={code:e.textContent,isExternal:!1,isDynamic:o,async:!1,defer:"module"===e.type,module:"module"===e.type};if(o)return{url:t,info:i};n.source.scripts.set(t,i),r=document.createComment("inline script extract by micro-app")}else r=document.createComment("script ignored by micro-app");return o?{replaceComment:r}:t.replaceChild(r,e)}function k(e,t){const n=Array.from(t.source.scripts.entries()),o=[],r=[];for(const[e,i]of n)if(i.isExternal){const n=j.get(e);n?i.code=n:i.defer||i.async||(o.push(ve(e,t.name)),r.push([e,i]))}o.length?u(o,(e=>{!function(e,t,n){t.isGlobal&&!j.has(e)&&j.set(e,n);t.code=n}(r[e.index][0],r[e.index][1],e.data)}),(e=>{console.error("[micro-app]",e)}),(()=>{t.onLoad(e)})):t.onLoad(e)}function B(e,t,n,o,r){var i;try{if(t=W(e,t,n),n.inline){const e=g("script");if(o&&e.setAttribute("type","module"),e.textContent=t,r)return e;null===(i=n.container)||void 0===i||i.querySelector("micro-app-body").appendChild(e)}else if((0,eval)(t),r)return document.createComment("dynamic script extract by micro-app")}catch(e){console.error("[micro-app from runScript]",e)}}function W(e,n,o){return"object"==typeof _e.plugins&&(n=function(e,t,n,o){var r;if("[object Array]"===toString.call(o.global))for(const n of o.global)"object"==typeof n&&"function"==typeof n.loader&&(t=n.loader(t,e,n.options));if("[object Array]"===toString.call(null===(r=o.modules)||void 0===r?void 0:r[n]))for(const r of o.modules[n])"object"==typeof r&&"function"==typeof r.loader&&(t=r.loader(t,e,r.options));return t}(e,n,o.name,_e.plugins)),o.sandBox?(t.proxyWindow=o.sandBox.proxyWindow,`;(function(window, self){with(window){;${n}\n}}).call(window.proxyWindow, window.proxyWindow, window.proxyWindow);`):n}const H=Element.prototype.setAttribute,q=Node.prototype.appendChild,G=Node.prototype.insertBefore,F=Node.prototype.replaceChild,K=Node.prototype.removeChild,z=Element.prototype.append,V=Element.prototype.prepend,Y=Document.prototype.createElement,J=Document.prototype.createElementNS,Z=Document.prototype.createDocumentFragment,Q=Document.prototype.querySelector,X=Document.prototype.querySelectorAll,ee=Document.prototype.getElementById,te=Document.prototype.getElementsByClassName,ne=Document.prototype.getElementsByTagName,oe=Document.prototype.getElementsByName,re=new WeakMap;function ie(e,t,n){if(t instanceof HTMLStyleElement){if(t.hasAttribute("exclude")){const e=document.createComment("style element with exclude attribute ignored by micro-app");return re.set(t,e),e}return n.scopecss?P(t,n.name):t}if(t instanceof HTMLLinkElement){if(t.hasAttribute("exclude")){const e=document.createComment("link element with exclude attribute ignored by micro-app");return re.set(t,e),e}if(!n.scopecss)return t;const{url:o,info:r}=T(t,e,n,null,!0);if(o&&r){const e=g("style");return e.linkpath=o,function(e,t,n,o,r){if(n.source.links.has(e))return r.textContent=n.source.links.get(e).code,P(r,n.name),void i((()=>M(o)));if(x.has(e)){const s=x.get(e);return t.code=s,n.source.links.set(e,t),r.textContent=s,P(r,n.name),void i((()=>M(o)))}ve(e,n.name).then((i=>{t.code=i,n.source.links.set(e,t),t.isGlobal&&x.set(e,i),r.textContent=i,P(r,n.name),M(o)})).catch((e=>{console.error("[micro-app]",e),L(o)}))}(o,r,n,t,e),re.set(t,e),e}return t}if(t instanceof HTMLScriptElement){const{replaceComment:o,url:r,info:s}=I(t,e,n,!0);if(r&&s){if(s.code){const e=B(r,s.code,n,s.module,!0);return re.set(t,e),e}{const e=function(e,t,n,o){if(n.source.scripts.has(e)){const r=n.source.scripts.get(e);return i((()=>M(o))),B(e,r.code,n,t.module,!0)}if(j.has(e)){const r=j.get(e);return t.code=r,n.source.scripts.set(e,t),i((()=>M(o))),B(e,r,n,t.module,!0)}let r;return r=n.inline?g("script"):document.createComment(`dynamic script with src='${e}' extract by micro-app`),ve(e,n.name).then((i=>{t.code=i,n.source.scripts.set(e,t),t.isGlobal&&j.set(e,i);try{i=W(e,i,n),n.inline?(t.module&&r.setAttribute("type","module"),r.textContent=i):(0,eval)(i)}catch(t){console.error("[micro-app from runDynamicScript]",t,e)}M(o)})).catch((e=>{console.error("[micro-app]",e),L(o)})),r}(r,s,n,t);return re.set(t,e),e}}return re.set(t,o),o}return t}function se(e,t,n,o,r){if(n instanceof HTMLHeadElement){const i=e.container.querySelector("micro-app-head");return r&&!i.contains(r)?q.call(i,o):t!==K||i.contains(o)?t===z||t===V?t.call(i,o):t.call(i,o,r):n.contains(o)?t.call(n,o):o}if(n instanceof HTMLBodyElement){const i=e.container.querySelector("micro-app-body");return r&&!i.contains(r)?q.call(i,o):t!==K||i.contains(o)?t===z||t===V?t.call(i,o):t.call(i,o,r):n.contains(o)?t.call(n,o):o}return t===z||t===V?t.call(n,o):t.call(n,o,r)}function ce(e){var t;return null!==(t=re.get(e))&&void 0!==t?t:e}function ae(e,t,n,o){if(null==t?void 0:t.__MICRO_APP_NAME__){const r=ze.get(t.__MICRO_APP_NAME__);return(null==r?void 0:r.container)?se(r,o,e,ie(e,t,r),n&&ce(n)):o===z||o===V?o.call(e,t):o.call(e,t,n)}if(o===z||o===V){const n=m();if(!(t instanceof Node)&&n){const r=ze.get(n);if(null==r?void 0:r.container){if(e instanceof HTMLHeadElement)return o.call(r.container.querySelector("micro-app-head"),t);if(e instanceof HTMLBodyElement)return o.call(r.container.querySelector("micro-app-body"),t)}}return o.call(e,t)}return o.call(e,t,n)}function le(){!function(){function e(e){var t,o,r;const i=m();return i&&"head"!==e&&"body"!==e&&"html"!==e?null!==(r=null===(o=null===(t=ze.get(i))||void 0===t?void 0:t.container)||void 0===o?void 0:o.querySelector(e))&&void 0!==r?r:null:Q.call(n,e)}function t(e){var t,o,r;const i=m();return i&&"head"!==e&&"body"!==e&&"html"!==e?null!==(r=null===(o=null===(t=ze.get(i))||void 0===t?void 0:t.container)||void 0===o?void 0:o.querySelectorAll(e))&&void 0!==r?r:[]:X.call(n,e)}Document.prototype.createElement=function(e,t){return ue(Y.call(n,e,t))},Document.prototype.createElementNS=function(e,t,o){return ue(J.call(n,e,t,o))},Document.prototype.createDocumentFragment=function(){return ue(Z.call(n))},Document.prototype.querySelector=e,Document.prototype.querySelectorAll=t,Document.prototype.getElementById=function(t){return!m()||/^\d/.test(t)?ee.call(n,t):e(`#${t}`)},Document.prototype.getElementsByClassName=function(e){return!m()||/^\d/.test(e)?te.call(n,e):t(`.${e}`)},Document.prototype.getElementsByTagName=function(e){var o;const r=m();return!r||/^body$/i.test(e)||/^head$/i.test(e)||/^html$/i.test(e)||!(null===(o=ze.get(r))||void 0===o?void 0:o.inline)&&/^script$/i.test(e)?ne.call(n,e):t(e)},Document.prototype.getElementsByName=function(e){return!m()||/^\d/.test(e)?oe.call(n,e):t(`[name=${e}]`)}}(),Element.prototype.setAttribute=function(e,t){if(/^micro-app(-\S+)?/i.test(this.tagName)&&"data"===e)if("[object Object]"===toString.call(t)){const e={};Object.getOwnPropertyNames(t).forEach((n=>{"string"==typeof n&&0===n.indexOf("__")||(e[n]=t[n])})),this.data=e}else"[object Object]"!==t&&console.warn(r("property data must be an object"));else if(("src"===e&&/^(img|iframe|script)$/i.test(this.tagName)||"href"===e&&/^link$/i.test(this.tagName))&&this.__MICRO_APP_NAME__&&ze.has(this.__MICRO_APP_NAME__)){const n=ze.get(this.__MICRO_APP_NAME__);H.call(this,e,l(t,n.url))}else H.call(this,e,t)},Node.prototype.appendChild=function(e){return ae(this,e,null,q)},Node.prototype.insertBefore=function(e,t){return ae(this,e,t,G)},Node.prototype.replaceChild=function(e,t){return ae(this,e,t,F)},Element.prototype.append=function(...e){let t=0;const n=e.length;for(;t<n;)ae(this,e[t],null,z),t++},Element.prototype.prepend=function(...e){let t=e.length;for(;t>0;)ae(this,e[t-1],null,V),t--},Node.prototype.removeChild=function(e){if(null==e?void 0:e.__MICRO_APP_NAME__){const t=ze.get(e.__MICRO_APP_NAME__);return(null==t?void 0:t.container)?se(t,K,this,ce(e)):K.call(this,e)}return K.call(this,e)}}function ue(e){const t=m();return t&&(e.__MICRO_APP_NAME__=t),e}function pe(){h(null),Document.prototype.createElement=Y,Document.prototype.createElementNS=J,Document.prototype.createDocumentFragment=Z,Document.prototype.querySelector=Q,Document.prototype.querySelectorAll=X,Document.prototype.getElementById=ee,Document.prototype.getElementsByClassName=te,Document.prototype.getElementsByTagName=ne,Document.prototype.getElementsByName=oe,Element.prototype.setAttribute=H,Node.prototype.appendChild=q,Node.prototype.insertBefore=G,Node.prototype.replaceChild=F,Node.prototype.removeChild=K,Element.prototype.append=z,Element.prototype.prepend=V}let de=!1;function he(e,t,n,o){var i;if(!e)return console.error(r(`element does not exist in lifecycle ${n},it seems the app has unmounted`));e instanceof ShadowRoot&&(e=e.host);const s=Object.assign({name:t,container:e},o&&{error:o}),c=new CustomEvent(n,{detail:s});!function(e,t){Object.defineProperties(e,{currentTarget:{get:()=>t},target:{get:()=>t}})}(c,e),"function"==typeof(null===(i=_e.lifeCycles)||void 0===i?void 0:i[n])&&_e.lifeCycles[n](c),e.dispatchEvent(c)}function me(){ze.forEach((e=>{let t=e.container;t&&(t instanceof ShadowRoot&&(t=t.host),t.disconnectedCallback())})),ze.clear()}class fe extends HTMLElement{constructor(){super(...arguments),this.name="",this.url="",this.version=o,this.isWating=!1,this.cacheData=null,this.handleAttributeUpdate=()=>{var e;this.isWating=!1;const t=this.getAttribute("name"),n=c(this.getAttribute("url"));if(this.legalAttribute("name",t)&&this.legalAttribute("url",n)){const o=ze.get(t);if(t!==this.name&&o&&o.getAppStatus()!==w.UNMOUNT&&!o.isPrefetch)return this.setAttribute("name",this.name),console.error(r(`an app named ${t} already exists`));t===this.name&&n===this.url||(this.handleUnmount(!0),this.name=t,this.url=n,(null!==(e=this.shadowRoot)&&void 0!==e?e:this).innerHTML="",o&&o.url===n?this.handleAppMount(o):this.handleCreate())}else t!==this.name&&this.setAttribute("name",this.name)}}static get observedAttributes(){return["name","url"]}connectedCallback(){if(1==++fe.microAppCount&&(le(),function(){if(!de){de=!0;const e=g("style");e.setAttribute("type","text/css"),e.textContent=`\n${_e.tagName}, micro-app-body { display: block; } \nmicro-app-head { display: none; }`,n.head.appendChild(e)}}(),window.__MICRO_APP_ENVIRONMENT__&&window.addEventListener("unmount",me,!1)),i((()=>he(this,this.name,_.CREATED))),!this.name||!this.url)return;this.getDisposeResult("shadowDOM")&&!this.shadowRoot&&this.attachShadow({mode:"open"});const e=ze.get(this.name);e?e.url!==this.url||!e.isPrefetch&&e.getAppStatus()!==w.UNMOUNT?e.isPrefetch?console.error(r(`the url: ${this.url} is different from prefetch url: ${e.url}`)):console.error(r(`an app named ${this.name} already exists`)):this.handleAppMount(e):this.handleCreate()}disconnectedCallback(){fe.microAppCount>0&&(this.handleUnmount(this.getDisposeResult("destory")),0==--fe.microAppCount&&(pe(),window.__MICRO_APP_ENVIRONMENT__&&window.removeEventListener("unmount",me,!1)))}attributeChangedCallback(e,t,n){if(this.legalAttribute(e,n)&&this[e]!==n)if(e!==E.URL||this.url)e!==E.NAME||this.name?this.isWating||(this.isWating=!0,i(this.handleAttributeUpdate)):(this.cacheData&&(_e.setData(n,this.cacheData),this.cacheData=null),this.name=n);else{if(!(n=c(n)))return console.error(r("Invalid attribute url"));this.url=n}}legalAttribute(e,t){return!("string"!=typeof t||!t)||(console.error(r(`unexpected attribute ${e}, please check again`)),!1)}handleAppMount(e){e.isPrefetch=!1,i((()=>{var t,n;return e.mount(null!==(t=this.shadowRoot)&&void 0!==t?t:this,this.getDisposeResult("inline"),null!==(n=this.getAttribute("baseurl"))&&void 0!==n?n:"")}))}handleCreate(){var e,t;const n=new Ve({name:this.name,url:this.url,container:null!==(e=this.shadowRoot)&&void 0!==e?e:this,inline:this.getDisposeResult("inline"),scopecss:!(this.getDisposeResult("disableScopecss")||this.getDisposeResult("shadowDOM")),useSandbox:!this.getDisposeResult("disableSandbox"),macro:this.getDisposeResult("macro"),baseurl:null!==(t=this.getAttribute("baseurl"))&&void 0!==t?t:""});ze.set(this.name,n)}handleUnmount(e){const t=ze.get(this.name);t&&t.getAppStatus()!==w.UNMOUNT&&t.unmount(e)}getDisposeResult(e){return(this.hasAttribute(e)||_e[e])&&"false"!==this.getAttribute(e)}set data(e){this.name?_e.setData(this.name,e):this.cacheData=e}get data(){return this.name?_e.getData(this.name,!0):this.cacheData?this.cacheData:null}}fe.microAppCount=0;const ye=new class{constructor(){this.eventList=new Map}isLegalName(e){return!!e||(console.error(r("event-center: Invalid name")),!1)}on(e,t,n=!1){if(this.isLegalName(e)){if("function"!=typeof t)return console.error(r("event-center: Invalid callback function"));let o=this.eventList.get(e);o?n&&Object.getOwnPropertyNames(o.data).length&&t(o.data):(o={data:{},callbacks:new Set},this.eventList.set(e,o)),o.callbacks.add(t)}}off(e,t){if(this.isLegalName(e)){const n=this.eventList.get(e);n&&("function"==typeof t?n.callbacks.delete(t):n.callbacks.clear())}}dispatch(e,t){if(this.isLegalName(e)){if("[object Object]"!==toString.call(t))return console.error(r("event-center: data must be object"));let n=this.eventList.get(e);if(n){if(n.data!==t){n.data=t;for(const e of n.callbacks)e(t)}}else n={data:t,callbacks:new Set},this.eventList.set(e,n)}}getData(e){var t;const n=this.eventList.get(e);return null!==(t=null==n?void 0:n.data)&&void 0!==t?t:null}};function be(e,t){return"string"==typeof e&&e?t?`__from_base_app_${e}__`:`__from_micro_app_${e}__`:""}class ge{addGlobalDataListener(e,t){ye.on("global",e,t)}removeGlobalDataListener(e){"function"==typeof e&&ye.off("global",e)}setGlobalData(e){ye.dispatch("global",e)}clearGlobalDataListener(){ye.off("global")}}class Ee extends ge{addDataListener(e,t,n){ye.on(be(e,!1),t,n)}removeDataListener(e,t){"function"==typeof t&&ye.off(be(e,!1),t)}getData(e,t=!1){return ye.getData(be(e,t))}setData(e,t){ye.dispatch(be(e,!0),t)}clearDataListener(e){ye.off(be(e,!1))}}class we extends ge{constructor(e){super(),this.appName=e}addDataListener(e,t){ye.on(be(this.appName,!0),e,t)}removeDataListener(e){"function"==typeof e&&ye.off(be(this.appName,!0),e)}getData(){return ye.getData(be(this.appName,!0))}dispatch(e){f(),ye.dispatch(be(this.appName,!1),e);const t=ze.get(this.appName);if((null==t?void 0:t.container)&&"[object Object]"===toString.call(e)){const n=new CustomEvent("datachange",{detail:{data:e}});let o=t.container;o instanceof ShadowRoot&&(o=o.host),o.dispatchEvent(n)}}clearDataListener(){ye.off(be(this.appName,!0))}}var _e=new class extends Ee{constructor(){super(...arguments),this.tagName="micro-app",this.preFetch=Ye}start(e){if(!(null===window||void 0===window?void 0:window.customElements))return console.error(r("customElements is not supported in this environment"));if(null==e?void 0:e.tagName){if(!/^micro-app(-\S+)?/.test(e.tagName))return console.error(r(`${e.tagName} is invalid tagName`));this.tagName=e.tagName}var t,n;n=this.tagName,(window.customElements.get(n)?(console.warn(r(`element ${n} is already defined`)),0):(window.customElements.define(n,fe),1))&&e&&"[object Object]"===toString.call(e)&&(this.shadowDOM=e.shadowDOM,this.destory=e.destory,this.inline=e.inline,this.disableScopecss=e.disableScopecss,this.disableSandbox=e.disableSandbox,this.macro=e.macro,b(e.fetch)&&(this.fetch=e.fetch),"[object Object]"===toString.call(e.lifeCycles)&&(this.lifeCycles=e.lifeCycles),"[object Object]"===toString.call(e.plugins)&&(this.plugins=e.plugins),e.preFetchApps&&Ye(e.preFetchApps),e.globalAssets&&(t=e.globalAssets,"[object Object]"===toString.call(t)&&p((()=>{if("[object Array]"===toString.call(t.js)){const e=t.js.filter((e=>"string"==typeof e&&e.includes(".js")&&!j.has(e))),n=[];e.forEach((e=>{n.push(ve(e))})),u(n,(t=>{const n=e[t.index];j.has(n)||j.set(n,t.data)}),(e=>{console.error("[micro-app]",e)}))}if("[object Array]"===toString.call(t.css)){const e=t.css.filter((e=>"string"==typeof e&&e.includes(".css")&&!x.has(e))),n=[];e.forEach((e=>{n.push(ve(e))})),u(n,(t=>{const n=e[t.index];x.has(n)||x.set(n,t.data)}),(e=>{console.error("[micro-app]",e)}))}}))))}};function ve(e,t=null,n={}){return b(_e.fetch)?_e.fetch(e,n,t):fetch(e,n).then((e=>e.text()))}function Ae(e,t,n){const o=Array.from(e.children);o.length&&o.forEach((e=>{Ae(e,t,n)}));for(const r of o)r instanceof HTMLLinkElement?r.hasAttribute("exclude")?e.replaceChild(document.createComment("link element with exclude attribute ignored by micro-app"),r):t.scopecss?T(r,e,t,n):r.hasAttribute("href")&&r.setAttribute("href",l(r.getAttribute("href"),t.url)):r instanceof HTMLStyleElement?r.hasAttribute("exclude")?e.replaceChild(document.createComment("style element with exclude attribute ignored by micro-app"),r):t.scopecss&&n.appendChild(P(r,t.name)):r instanceof HTMLScriptElement?I(r,e,t):r instanceof HTMLMetaElement||r instanceof HTMLTitleElement?e.removeChild(r):/^(img|iframe)$/i.test(r.tagName)&&r.hasAttribute("src")&&r.setAttribute("src",l(r.getAttribute("src"),t.url))}function Oe(e,t){const n=function(e){const t=g("div");return t.innerHTML=e,t}(e),o=n.querySelector("micro-app-head"),i=n.querySelector("micro-app-body");if(!o||!i){const e=`element ${o?"body":"head"} is missing`;return t.onerror(new Error(e)),console.error(r(e))}Ae(n,t,o),t.source.links.size?U(n,t,o):t.onLoad(n),t.source.scripts.size?k(n,t):t.onLoad(n)}const Ne=new WeakMap;const Ce=new WeakMap;function Se(e,t){if(Ce.has(t))return Ce.get(t);if(b(t)&&!function(e){if(Ne.has(e))return Ne.get(e);const t=e.toString(),n=e.prototype&&e.prototype.constructor===e&&Object.getOwnPropertyNames(e.prototype).length>1||/^function\s+[A-Z]/.test(t)||/^class\s+/.test(t);return Ne.set(e,n),n}(t)){const n=t.bind(e);for(const e in t)n[e]=t[e];return t.hasOwnProperty("prototype")&&!n.hasOwnProperty("prototype")&&(n.prototype=t.prototype),Ce.set(t,n),n}return t}const De=window.addEventListener,Pe=window.removeEventListener,Re=window.setInterval,Me=window.setTimeout,Le=window.clearInterval,xe=window.clearTimeout,Te=document.addEventListener,Ue=document.removeEventListener,je=new Map;let $e=!1;const Ie=new Map;function ke(){$e||function(){$e=!0;const e=Object.getOwnPropertyDescriptor(document,"onclick");if(!1===(null==e?void 0:e.configurable))return console.warn(r("Cannot redefine document property onclick"));const t=document.onclick;document.onclick=null;let n=!1;function o(e){je.forEach((t=>{"function"==typeof t&&t.call(document,e)}))}Object.defineProperty(document,"onclick",{configurable:!1,enumerable:!0,get(){const e=m();return e?je.get(e):je.get("base")},set(e){const t=m();t?je.set(t,e):je.set("base",e),n||"function"!=typeof e||(n=!0,Te.call(document,"click",o,!1))}}),t&&(document.onclick=t)}(),document.addEventListener=function(e,t,n){const o=m();if(o){const n=Ie.get(o);if(n){const o=n.get(e);o?o.add(t):n.set(e,new Set([t]))}else Ie.set(o,new Map([[e,new Set([t])]]))}return Te.call(document,e,t,n)},document.removeEventListener=function(e,t,n){const o=m();if(o){const n=Ie.get(o);if(n){const o=n.get(e);(null==o?void 0:o.size)&&o.has(t)&&o.delete(t)}}return Ue.call(document,e,t,n)}}function Be(e,t){return"unmount"===e?`unmount-${t.__MICRO_APP_NAME__}`:e}const We=["System","__cjsWrapper","__REACT_ERROR_OVERLAY_GLOBAL_HOOK__"],He=["location"],qe={undefined:!0,Array:!0,Object:!0,String:!0,Boolean:!0,Math:!0,Number:!0,Symbol:!0,parseFloat:!0,Float32Array:!0};let Ge;function Fe(e){Ge&&clearTimeout(Ge),Ge=setTimeout(e,0)}class Ke{constructor(e,o,r){this.active=!1,this.scopeProperties=["webpackJsonp"],this.escapeProperties=[],this.microWindow={},this.injectedKeys=new Set,this.escapeKeys=new Set;const s=new Map,c=e=>this.microWindow.hasOwnProperty(e)||t.hasOwnProperty(e);this.getScopeProperties(e),this.inject(this.microWindow,e,o),this.releaseEffect=function(e){const t=new Map,n=new Set,o=new Set;return e.addEventListener=function(n,o,r){n=Be(n,e);const i=t.get(n);return i?i.add(o):t.set(n,new Set([o])),De.call(window,n,o,r)},e.removeEventListener=function(n,o,r){n=Be(n,e);const i=t.get(n);return(null==i?void 0:i.size)&&i.has(o)&&i.delete(o),Pe.call(window,n,o,r)},e.setInterval=function(e,t,...o){const r=Re(e,t,...o);return n.add(r),r},e.setTimeout=function(e,t,...n){const r=Me(e,t,...n);return o.add(r),r},e.clearInterval=function(e){n.delete(e),Le(e)},e.clearTimeout=function(e){o.delete(e),xe(e)},()=>{t.size&&(t.forEach(((e,t)=>{if(e.size)for(const n of e)Pe.call(window,t,n)})),t.clear()),n.size&&(n.forEach((e=>{Le(e)})),n.clear()),o.size&&(o.forEach((e=>{xe(e)})),o.clear());const r=e.__MICRO_APP_NAME__;je.delete(r);const i=Ie.get(r);i&&(i.forEach(((e,t)=>{if(e.size)for(const n of e)Ue.call(document,t,n)})),i.clear())}}(this.microWindow),this.proxyWindow=new Proxy(this.microWindow,{get:(o,s)=>{if(s===Symbol.unscopables)return qe;if(["window","self","globalThis"].includes(s))return this.proxyWindow;if("top"===s||"parent"===s)return t===t.parent?this.proxyWindow:Reflect.get(t,s);if("hasOwnProperty"===s)return c;if("document"===s||"eval"===s)switch(h(e),(r?Fe:i)((()=>h(null))),s){case"document":return n;case"eval":return eval}if(this.scopeProperties.includes(s))return Reflect.get(o,s);if(Reflect.has(o,s))return Reflect.get(o,s);const a=Reflect.get(t,s);return Se(t,a)},set:(e,n,o)=>{if(this.active){if(He.includes(n))Reflect.set(t,n,o);else if(e.hasOwnProperty(n)||!t.hasOwnProperty(n)||this.scopeProperties.includes(n))Reflect.set(e,n,o),this.injectedKeys.add(n);else{const r=Object.getOwnPropertyDescriptor(t,n),{writable:i,configurable:s,enumerable:c}=r;i&&(Object.defineProperty(e,n,{configurable:s,enumerable:c,writable:i,value:o}),this.injectedKeys.add(n))}(this.escapeProperties.includes(n)||We.includes(n)&&!Reflect.has(t,n))&&!this.scopeProperties.includes(n)&&(Reflect.set(t,n,o),this.escapeKeys.add(n))}return!0},has:(e,n)=>this.scopeProperties.includes(n)?n in e:n in qe||n in e||n in t,getOwnPropertyDescriptor:(e,n)=>{if(e.hasOwnProperty(n))return s.set(n,"target"),Object.getOwnPropertyDescriptor(e,n);if(t.hasOwnProperty(n)){s.set(n,"rawWindow");const e=Object.getOwnPropertyDescriptor(t,n);return e&&!e.configurable&&(e.configurable=!0),e}},defineProperty:(e,n,o)=>"rawWindow"===s.get(n)?Reflect.defineProperty(t,n,o):Reflect.defineProperty(e,n,o),ownKeys:e=>Reflect.ownKeys(t).concat(Reflect.ownKeys(e)).filter((function(e){return!(e in this)&&(this[e]=!0)}),Object.create(null)),deleteProperty:(e,n)=>!e.hasOwnProperty(n)||(this.escapeKeys.has(n)&&Reflect.deleteProperty(t,n),Reflect.deleteProperty(e,n))})}start(e){this.active||(this.active=!0,this.microWindow.__MICRO_APP_BASE_URL__=e,t._babelPolyfill&&(t._babelPolyfill=!1),1==++Ke.activeCount&&ke())}stop(){this.active&&(this.active=!1,this.releaseEffect(),this.microWindow.microApp.clearDataListener(),this.injectedKeys.forEach((e=>{Reflect.deleteProperty(this.microWindow,e)})),this.injectedKeys.clear(),this.escapeKeys.forEach((e=>{Reflect.deleteProperty(t,e)})),this.escapeKeys.clear(),0==--Ke.activeCount&&(document.addEventListener=Te,document.removeEventListener=Ue))}getScopeProperties(e){var t;if("object"==typeof _e.plugins){if("[object Array]"===toString.call(_e.plugins.global))for(const e of _e.plugins.global)"object"==typeof e&&("[object Array]"===toString.call(e.scopeProperties)&&(this.scopeProperties=this.scopeProperties.concat(e.scopeProperties)),"[object Array]"===toString.call(e.escapeProperties)&&(this.escapeProperties=this.escapeProperties.concat(e.escapeProperties)));if("[object Array]"===toString.call(null===(t=_e.plugins.modules)||void 0===t?void 0:t[e]))for(const t of _e.plugins.modules[e])"object"==typeof t&&("[object Array]"===toString.call(t.scopeProperties)&&(this.scopeProperties=this.scopeProperties.concat(t.scopeProperties)),"[object Array]"===toString.call(t.escapeProperties)&&(this.escapeProperties=this.escapeProperties.concat(t.escapeProperties)))}}inject(e,o,r){e.__MICRO_APP_ENVIRONMENT__=!0,e.__MICRO_APP_NAME__=o,e.__MICRO_APP_PUBLIC_PATH__=a(r),e.microApp=new we(o),e.rawWindow=t,e.rawDocument=n}}Ke.activeCount=0;const ze=new Map;class Ve{constructor({name:e,url:t,container:n,inline:o,scopecss:r,useSandbox:i,macro:s,baseurl:c}){this.status=w.NOT_LOADED,this.loadSourceLevel=0,this.isPrefetch=!1,this.container=null,this.macro=!1,this.baseurl="",this.sandBox=null,this.container=null!=n?n:null,this.inline=null!=o&&o,this.baseurl=null!=c?c:"",this.name=e,this.url=t,this.useSandbox=i,this.scopecss=this.useSandbox&&r,this.macro=null!=s&&s,this.source={links:new Map,scripts:new Map},this.loadSourceCode(),this.useSandbox&&(this.sandBox=new Ke(e,t,this.macro))}loadSourceCode(){var e;this.status=w.LOADING_SOURCE_CODE,ve((e=this).url,e.name,{cache:"no-cache"}).then((t=>{if(!t){const t="html is empty, please check in detail";return e.onerror(new Error(t)),console.error(r(t))}Oe(t=t.replace(/<head[^>]*>[\s\S]*?<\/head>/i,(e=>e.replace(/<head/i,"<micro-app-head").replace(/<\/head>/i,"</micro-app-head>"))).replace(/<body[^>]*>[\s\S]*?<\/body>/i,(e=>e.replace(/<body/i,"<micro-app-body").replace(/<\/body>/i,"</micro-app-body>"))),e)})).catch((t=>{console.error(r(`Failed to fetch data from ${e.url}, micro-app stop rendering`),t),e.onLoadError(t)}))}onLoad(e){if(2==++this.loadSourceLevel){if(this.source.html=e,this.isPrefetch||this.status===w.UNMOUNT)return;this.status=w.LOAD_SOURCE_FINISHED,this.mount()}}onLoadError(e){this.loadSourceLevel=-1,this.status!==w.UNMOUNT&&(this.onerror(e),this.status=w.LOAD_SOURCE_ERROR)}mount(e,t,n){var o;if(!this.container&&e&&(this.container=e),"boolean"==typeof t&&t!==this.inline&&(this.inline=t),this.baseurl=null!=n?n:this.baseurl,2!==this.loadSourceLevel)return void(this.status=w.LOADING_SOURCE_CODE);he(this.container,this.name,_.BEFOREMOUNT),this.status=w.MOUNTING;const r=this.source.html.cloneNode(!0),s=document.createDocumentFragment();Array.from(r.childNodes).forEach((e=>{s.appendChild(e)})),this.container.appendChild(s),null===(o=this.sandBox)||void 0===o||o.start(this.baseurl),function(e,t){const n=Array.from(e.entries()),o=[],r=[];for(const[e,i]of n)i.isDynamic||(i.defer||i.async?(i.isExternal?o.push(ve(e,t.name)):o.push(i.code),r.push([e,i])):B(e,i.code,t,i.module,!1));o.length&&Promise.all(o).then((e=>{e.forEach(((e,n)=>{B(r[n][0],e,t,r[n][1].module,!1)}))})).catch((e=>{console.error("[micro-app]",e)}))}(this.source.scripts,this),this.status!==w.UNMOUNT&&(this.status=w.MOUNTED,i((()=>{this.status!==w.UNMOUNT&&he(this.container,this.name,_.MOUNTED)})))}unmount(e){var t;this.status===w.LOAD_SOURCE_ERROR&&(e=!0),this.status=w.UNMOUNT,he(this.container,this.name,_.UNMOUNT),function(e){const t=new CustomEvent(`unmount-${e}`);window.dispatchEvent(t)}(this.name),null===(t=this.sandBox)||void 0===t||t.stop(),this.container=null,e&&ze.delete(this.name)}onerror(e){he(this.container,this.name,_.ERROR,e)}getAppStatus(){return this.status}}function Ye(e){p((()=>{"function"==typeof e&&(e=e()),function(e){const t=[];return"[object Array]"===toString.call(e)&&e.forEach((e=>{e.url=c(e.url),"[object Object]"===toString.call(e)&&e.name&&"string"==typeof e.name&&e.url&&!ze.has(e.name)&&t.push(e)})),t}(e).forEach((e=>{var t,n,o;const r=new Ve({name:e.name,url:e.url,scopecss:!(null!==(t=e.disableScopecss)&&void 0!==t?t:_e.disableScopecss),useSandbox:!(null!==(n=e.disableSandbox)&&void 0!==n?n:_e.disableSandbox),macro:null!==(o=e.macro)&&void 0!==o?o:_e.macro});r.isPrefetch=!0,ze.set(e.name,r)}))}))}e.default=_e,e.preFetch=Ye,e.pureCreateElement=g,e.removeDomScope=f,e.version=o,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).microApp={})}(this,(function(e){"use strict";const t=new Function("return window")(),n=new Function("return document")(),o="0.2.5";function r(e,...t){"string"==typeof e?console.error(`[micro-app] ${e}`,...t):console.error("[micro-app]",e,...t)}function i(e,...t){"string"==typeof e?console.warn(`[micro-app] ${e}`,...t):console.warn("[micro-app]",e,...t)}function s(e,...t){Promise.resolve().then(e.bind(null,...t))}function c(e){return e.startsWith("//")?`${location.protocol}${e}`:e}function a(e){if("string"!=typeof e||!e)return"";try{const{origin:t,pathname:n,search:o}=new URL(c(e));if(/\.(\w+)$/.test(n))return`${t}${n}${o}`;const r=`${t}${n}/`.replace(/\/\/$/,"/");return/^https?:\/\//.test(r)?`${r}${o}`:""}catch(e){return r(e),""}}function l(e){const{origin:t,pathname:n}=new URL(e);if(/\.(\w+)$/.test(n)){const e=`${t}${n}`.split("/");return e.pop(),e.join("/")+"/"}return`${t}${n}/`.replace(/\/\/$/,"/")}function u(e,t){return/^((((ht|f)tps?)|file):)?\/\//.test(e)?e:new URL(e,l(c(t))).toString()}function p(e,t,n,o){let r=0;function i(){++r===e.length&&o&&o()}e.forEach(((e,o)=>{"[object Promise]"===toString.call(e)?e.then((e=>{t({data:e,index:o}),i()})).catch((e=>{n({error:e,index:o}),i()})):(t({data:e,index:o}),i())}))}const d=window.requestIdleCallback||function(e){const t=Date.now();return setTimeout((function(){e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-t))})}),1)};let h=null;function m(e){h=e}function f(){return h}function y(){m(null)}function b(){return/Safari/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)}function g(e){return"function"==typeof e}function E(e,t){const o=n.createElement(e,t);return o.__MICRO_APP_NAME__&&delete o.__MICRO_APP_NAME__,o}var w,_,v,N;function A(e,t){const{selectorText:n,cssText:o}=e;if(/^((html[\s>~,]+body)|(html|body|:root))$/.test(n))return o.replace(/^((html[\s>~,]+body)|(html|body|:root))/,t);if("*"===n)return o.replace("*",`${t} *`);const r=/(^|\s+)((html[\s>~]+body)|(html|body|:root))(?=[\s>~]+|$)/;return o.replace(/^[\s\S]+{/,(e=>e.replace(/(^|,)([^,]+)/g,((e,n,o)=>r.test(o)?e.replace(r,t):`${n} ${t} ${o.replace(/^\s*/,"")}`))))}function O(e,t,n,o){return e.replace(/url\(["']?([^)"']+)["']?\)/gm,((e,r)=>{if(/^data:/.test(r))return e;if(/^(https?:)?\/\//.test(r)){if(!b())return e;{const t=r.replace(/^https?:/,"");if(-1!==n.indexOf(t))return e;r=r.replace(window.location.origin,"")}}return/^((\.\.?\/)|[^/])/.test(r)&&o&&(t=function(e){const t=e.split("/");return t.pop(),c(t.join("/")+"/")}(o)),`url("${u(r,t)}")`}))}function C(e,t,n){const o=S(Array.from(e.cssRules),t);return`@${n} ${e.conditionText} {${o}}`}function S(e,t){let n="";for(const o of e)switch(o.type){case N.STYLE_RULE:n+=A(o,t);break;case N.MEDIA_RULE:n+=C(o,t,"media");break;case N.SUPPORTS_RULE:n+=C(o,t,"supports");break;default:n+=o.cssText}return n.replace(/^\s+/,"")}function D(e,t,n,o,r,i){var s,c;let a=O(S(Array.from(null!==(c=null===(s=e.sheet)||void 0===s?void 0:s.cssRules)&&void 0!==c?c:[]),o),r,n,i);b()&&(a=a.replace(/([;{]\s*content:\s*)([^\s"][^";}]*)/gm,((e,t,n)=>"none"===n||/^(url\()|(counter\()|(attr\()|(open-quote)|(close-quote)/.test(n)?e:`${t}"${n}"`))),t.textContent=a}!function(e){e.NAME="name",e.URL="url"}(w||(w={})),function(e){e.NOT_LOADED="NOT_LOADED",e.LOADING_SOURCE_CODE="LOADING_SOURCE_CODE",e.LOAD_SOURCE_FINISHED="LOAD_SOURCE_FINISHED",e.LOAD_SOURCE_ERROR="LOAD_SOURCE_ERROR",e.MOUNTING="MOUNTING",e.MOUNTED="MOUNTED",e.UNMOUNT="UNMOUNT"}(_||(_={})),function(e){e.CREATED="created",e.BEFOREMOUNT="beforemount",e.MOUNTED="mounted",e.UNMOUNT="unmount",e.ERROR="error"}(v||(v={})),function(e){e[e.STYLE_RULE=1]="STYLE_RULE",e[e.MEDIA_RULE=4]="MEDIA_RULE",e[e.SUPPORTS_RULE=12]="SUPPORTS_RULE"}(N||(N={}));let R=n.body.querySelector("#micro-app-template-style");function P(e,t){const o=Ve.get(t);if(null==o?void 0:o.scopecss){const r=`${ve.tagName}[name=${t}]`;if(R||(R=E("style"),R.setAttribute("id","micro-app-template-style"),n.body.appendChild(R),R.sheet.disabled=!0),e.textContent)R.textContent=e.textContent,D(R,e,e.textContent,r,o.url,e.linkpath),R.textContent="";else{const t=new MutationObserver((function(){var n,i;t.disconnect(),!e.textContent&&(null===(i=null===(n=e.sheet)||void 0===n?void 0:n.cssRules)||void 0===i?void 0:i.length)||e.hasAttribute("data-styled")||D(e,e,e.textContent,r,o.url,e.linkpath)}));t.observe(e,{childList:!0})}}return e}function M(e,t){Object.defineProperties(e,{currentTarget:{get:()=>t},srcElement:{get:()=>t},target:{get:()=>t}})}function L(e){const t=new CustomEvent("load");M(t,e),"function"==typeof e.onload?e.onload(t):e.dispatchEvent(t)}function x(e){const t=new CustomEvent("error");M(t,e),"function"==typeof e.onerror?e.onerror(t):e.dispatchEvent(t)}const U=new Map;function T(e,t,n,o,r=!1){const i=e.getAttribute("rel");let s=e.getAttribute("href"),c=null;if("stylesheet"===i&&s){if(s=u(s,n.url),r)return{url:s,info:{code:"",isGlobal:e.hasAttribute("global")}};{c=document.createComment(`the link with href=${s} move to micro-app-head as style element`);const t=document.createComment(`placeholder for link with href=${s}`);o.appendChild(t),n.source.links.set(s,{code:"",placeholder:t,isGlobal:e.hasAttribute("global")})}}else s&&e.setAttribute("href",u(s,n.url));return r?{replaceComment:c}:c?t.replaceChild(c,e):void 0}function j(e,t,n){const o=Array.from(t.source.links.entries()),i=[];for(const[e]of o){const n=U.get(e);n?i.push(n):i.push(Ne(e,t.name))}p(i,(e=>{!function(e,t,n,o,r){t.isGlobal&&!U.has(e)&&U.set(e,n);const i=E("style");i.textContent=n,i.linkpath=e,o.replaceChild(P(i,r.name),t.placeholder),t.placeholder=null,t.code=n}(o[e.index][0],o[e.index][1],e.data,n,t)}),(e=>{r(e)}),(()=>{t.onLoad(e)}))}const $=new Map,I="noModule"in document.createElement("script");function k(e,t,n,o=!1){let r=null,i=e.getAttribute("src");if(e.hasAttribute("exclude"))r=document.createComment("script element with exclude attribute ignored by micro-app");else if(I&&e.noModule||!I&&"module"===e.type)r=document.createComment((e.noModule?"noModule":"module")+" script ignored by micro-app");else if(i){i=u(i,n.url);const t={code:"",isExternal:!0,isDynamic:o,async:e.hasAttribute("async"),defer:e.defer||"module"===e.type,module:"module"===e.type,isGlobal:e.hasAttribute("global")};if(o)return{url:i,info:t};n.source.scripts.set(i,t),r=document.createComment(`script with src='${i}' extract by micro-app`)}else if(e.textContent){const t=Math.random().toString(36).substr(2,15),i={code:e.textContent,isExternal:!1,isDynamic:o,async:!1,defer:"module"===e.type,module:"module"===e.type};if(o)return{url:t,info:i};n.source.scripts.set(t,i),r=document.createComment("inline script extract by micro-app")}else r=document.createComment("script ignored by micro-app");return o?{replaceComment:r}:t.replaceChild(r,e)}function B(e,t){const n=Array.from(t.source.scripts.entries()),o=[],i=[];for(const[e,r]of n)if(r.isExternal){const n=$.get(e);n?r.code=n:r.defer||r.async||(o.push(Ne(e,t.name)),i.push([e,r]))}o.length?p(o,(e=>{!function(e,t,n){t.isGlobal&&!$.has(e)&&$.set(e,n);t.code=n}(i[e.index][0],i[e.index][1],e.data)}),(e=>{r(e)}),(()=>{t.onLoad(e)})):t.onLoad(e)}function W(e,t,n,o,r){var i;try{if(t=H(e,t,n),n.inline){const e=E("script");if(o&&e.setAttribute("type","module"),e.textContent=t,r)return e;null===(i=n.container)||void 0===i||i.querySelector("micro-app-body").appendChild(e)}else if((0,eval)(t),r)return document.createComment("dynamic script extract by micro-app")}catch(e){console.error("[micro-app from runScript]",e)}}function H(e,n,o){return"object"==typeof ve.plugins&&(n=function(e,t,n,o){var r;if("[object Array]"===toString.call(o.global))for(const n of o.global)"object"==typeof n&&"function"==typeof n.loader&&(t=n.loader(t,e,n.options));if("[object Array]"===toString.call(null===(r=o.modules)||void 0===r?void 0:r[n]))for(const r of o.modules[n])"object"==typeof r&&"function"==typeof r.loader&&(t=r.loader(t,e,r.options));return t}(e,n,o.name,ve.plugins)),o.sandBox?(t.proxyWindow=o.sandBox.proxyWindow,`;(function(window, self){with(window){;${n}\n}}).call(window.proxyWindow, window.proxyWindow, window.proxyWindow);`):n}const q=Element.prototype.setAttribute,G=Node.prototype.appendChild,F=Node.prototype.insertBefore,K=Node.prototype.replaceChild,z=Node.prototype.removeChild,V=Element.prototype.append,Y=Element.prototype.prepend,J=Document.prototype.createElement,Z=Document.prototype.createElementNS,Q=Document.prototype.createDocumentFragment,X=Document.prototype.querySelector,ee=Document.prototype.querySelectorAll,te=Document.prototype.getElementById,ne=Document.prototype.getElementsByClassName,oe=Document.prototype.getElementsByTagName,re=Document.prototype.getElementsByName,ie=new WeakMap;function se(e,t,n){if(t instanceof HTMLStyleElement){if(t.hasAttribute("exclude")){const e=document.createComment("style element with exclude attribute ignored by micro-app");return ie.set(t,e),e}return n.scopecss?P(t,n.name):t}if(t instanceof HTMLLinkElement){if(t.hasAttribute("exclude")){const e=document.createComment("link element with exclude attribute ignored by micro-app");return ie.set(t,e),e}if(!n.scopecss)return t;const{url:o,info:i}=T(t,e,n,null,!0);if(o&&i){const e=E("style");return e.linkpath=o,function(e,t,n,o,i){if(n.source.links.has(e))return i.textContent=n.source.links.get(e).code,P(i,n.name),void s((()=>L(o)));if(U.has(e)){const r=U.get(e);return t.code=r,n.source.links.set(e,t),i.textContent=r,P(i,n.name),void s((()=>L(o)))}Ne(e,n.name).then((r=>{t.code=r,n.source.links.set(e,t),t.isGlobal&&U.set(e,r),i.textContent=r,P(i,n.name),L(o)})).catch((e=>{r(e),x(o)}))}(o,i,n,t,e),ie.set(t,e),e}return t}if(t instanceof HTMLScriptElement){const{replaceComment:o,url:i,info:c}=k(t,e,n,!0);if(i&&c){if(c.code){const e=W(i,c.code,n,c.module,!0);return ie.set(t,e),e}{const e=function(e,t,n,o){if(n.source.scripts.has(e)){const r=n.source.scripts.get(e);return s((()=>L(o))),W(e,r.code,n,t.module,!0)}if($.has(e)){const r=$.get(e);return t.code=r,n.source.scripts.set(e,t),s((()=>L(o))),W(e,r,n,t.module,!0)}let i;return i=n.inline?E("script"):document.createComment(`dynamic script with src='${e}' extract by micro-app`),Ne(e,n.name).then((r=>{t.code=r,n.source.scripts.set(e,t),t.isGlobal&&$.set(e,r);try{r=H(e,r,n),n.inline?(t.module&&i.setAttribute("type","module"),i.textContent=r):(0,eval)(r)}catch(t){console.error("[micro-app from runDynamicScript]",t,e)}L(o)})).catch((e=>{r(e),x(o)})),i}(i,c,n,t);return ie.set(t,e),e}}return ie.set(t,o),o}return t}function ce(e,t,n,o,r){if(n instanceof HTMLHeadElement){const i=e.container.querySelector("micro-app-head");return r&&!i.contains(r)?G.call(i,o):t!==z||i.contains(o)?t===V||t===Y?t.call(i,o):t.call(i,o,r):n.contains(o)?t.call(n,o):o}if(n instanceof HTMLBodyElement){const i=e.container.querySelector("micro-app-body");return r&&!i.contains(r)?G.call(i,o):t!==z||i.contains(o)?t===V||t===Y?t.call(i,o):t.call(i,o,r):n.contains(o)?t.call(n,o):o}return t===V||t===Y?t.call(n,o):t.call(n,o,r)}function ae(e){var t;return null!==(t=ie.get(e))&&void 0!==t?t:e}function le(e,t,n,o){if(null==t?void 0:t.__MICRO_APP_NAME__){const r=Ve.get(t.__MICRO_APP_NAME__);return(null==r?void 0:r.container)?ce(r,o,e,se(e,t,r),n&&ae(n)):o===V||o===Y?o.call(e,t):o.call(e,t,n)}if(o===V||o===Y){const n=f();if(!(t instanceof Node)&&n){const r=Ve.get(n);if(null==r?void 0:r.container){if(e instanceof HTMLHeadElement)return o.call(r.container.querySelector("micro-app-head"),t);if(e instanceof HTMLBodyElement)return o.call(r.container.querySelector("micro-app-body"),t)}}return o.call(e,t)}return o.call(e,t,n)}function ue(){!function(){function e(e){var t,o,r;const i=f();return i&&"head"!==e&&"body"!==e&&"html"!==e?null!==(r=null===(o=null===(t=Ve.get(i))||void 0===t?void 0:t.container)||void 0===o?void 0:o.querySelector(e))&&void 0!==r?r:null:X.call(n,e)}function t(e){var t,o,r;const i=f();return i&&"head"!==e&&"body"!==e&&"html"!==e?null!==(r=null===(o=null===(t=Ve.get(i))||void 0===t?void 0:t.container)||void 0===o?void 0:o.querySelectorAll(e))&&void 0!==r?r:[]:ee.call(n,e)}Document.prototype.createElement=function(e,t){return pe(J.call(n,e,t))},Document.prototype.createElementNS=function(e,t,o){return pe(Z.call(n,e,t,o))},Document.prototype.createDocumentFragment=function(){return pe(Q.call(n))},Document.prototype.querySelector=e,Document.prototype.querySelectorAll=t,Document.prototype.getElementById=function(t){return!f()||/^\d/.test(t)?te.call(n,t):e(`#${t}`)},Document.prototype.getElementsByClassName=function(e){return!f()||/^\d/.test(e)?ne.call(n,e):t(`.${e}`)},Document.prototype.getElementsByTagName=function(e){var o;const r=f();return!r||/^body$/i.test(e)||/^head$/i.test(e)||/^html$/i.test(e)||!(null===(o=Ve.get(r))||void 0===o?void 0:o.inline)&&/^script$/i.test(e)?oe.call(n,e):t(e)},Document.prototype.getElementsByName=function(e){return!f()||/^\d/.test(e)?re.call(n,e):t(`[name=${e}]`)}}(),Element.prototype.setAttribute=function(e,t){if(/^micro-app(-\S+)?/i.test(this.tagName)&&"data"===e)if("[object Object]"===toString.call(t)){const e={};Object.getOwnPropertyNames(t).forEach((n=>{"string"==typeof n&&0===n.indexOf("__")||(e[n]=t[n])})),this.data=e}else"[object Object]"!==t&&i("property data must be an object");else if(("src"===e&&/^(img|iframe|script)$/i.test(this.tagName)||"href"===e&&/^link$/i.test(this.tagName))&&this.__MICRO_APP_NAME__&&Ve.has(this.__MICRO_APP_NAME__)){const n=Ve.get(this.__MICRO_APP_NAME__);q.call(this,e,u(t,n.url))}else q.call(this,e,t)},Node.prototype.appendChild=function(e){return le(this,e,null,G)},Node.prototype.insertBefore=function(e,t){return le(this,e,t,F)},Node.prototype.replaceChild=function(e,t){return le(this,e,t,K)},Element.prototype.append=function(...e){let t=0;const n=e.length;for(;t<n;)le(this,e[t],null,V),t++},Element.prototype.prepend=function(...e){let t=e.length;for(;t>0;)le(this,e[t-1],null,Y),t--},Node.prototype.removeChild=function(e){if(null==e?void 0:e.__MICRO_APP_NAME__){const t=Ve.get(e.__MICRO_APP_NAME__);return(null==t?void 0:t.container)?ce(t,z,this,ae(e)):z.call(this,e)}return z.call(this,e)}}function pe(e){const t=f();return t&&(e.__MICRO_APP_NAME__=t),e}function de(){m(null),Document.prototype.createElement=J,Document.prototype.createElementNS=Z,Document.prototype.createDocumentFragment=Q,Document.prototype.querySelector=X,Document.prototype.querySelectorAll=ee,Document.prototype.getElementById=te,Document.prototype.getElementsByClassName=ne,Document.prototype.getElementsByTagName=oe,Document.prototype.getElementsByName=re,Element.prototype.setAttribute=q,Node.prototype.appendChild=G,Node.prototype.insertBefore=F,Node.prototype.replaceChild=K,Node.prototype.removeChild=z,Element.prototype.append=V,Element.prototype.prepend=Y}let he=!1;function me(e,t,n,o){var i;if(!e)return r(`element does not exist in lifecycle ${n},it seems the app has unmounted`);e instanceof ShadowRoot&&(e=e.host);const s=Object.assign({name:t,container:e},o&&{error:o}),c=new CustomEvent(n,{detail:s});!function(e,t){Object.defineProperties(e,{currentTarget:{get:()=>t},target:{get:()=>t}})}(c,e),"function"==typeof(null===(i=ve.lifeCycles)||void 0===i?void 0:i[n])&&ve.lifeCycles[n](c),e.dispatchEvent(c)}function fe(){Ve.forEach((e=>{let t=e.container;t&&(t instanceof ShadowRoot&&(t=t.host),t.disconnectedCallback())})),Ve.clear()}class ye extends HTMLElement{constructor(){super(...arguments),this.appName="",this.appUrl="",this.version=o,this.isWating=!1,this.cacheData=null,this.handleAttributeUpdate=()=>{var e;this.isWating=!1;const t=this.getAttribute("name"),n=a(this.getAttribute("url"));if(this.legalAttribute("name",t)&&this.legalAttribute("url",n)){const o=Ve.get(t);if(t!==this.appName&&o&&o.getAppStatus()!==_.UNMOUNT&&!o.isPrefetch)return this.setAttribute("name",this.appName),r(`an app named ${t} already exists`);t===this.appName&&n===this.appUrl||(this.handleUnmount(!0),this.appName=t,this.appUrl=n,(null!==(e=this.shadowRoot)&&void 0!==e?e:this).innerHTML="",o&&o.url===n?this.handleAppMount(o):this.handleCreate())}else t!==this.appName&&this.setAttribute("name",this.appName)}}static get observedAttributes(){return["name","url"]}connectedCallback(){if(1==++ye.microAppCount&&(ue(),function(){if(!he){he=!0;const e=E("style");e.setAttribute("type","text/css"),e.textContent=`\n${ve.tagName}, micro-app-body { display: block; } \nmicro-app-head { display: none; }`,n.head.appendChild(e)}}(),window.__MICRO_APP_ENVIRONMENT__&&window.addEventListener("unmount",fe,!1)),s((()=>me(this,this.appName,v.CREATED))),!this.appName||!this.appUrl)return;this.getDisposeResult("shadowDOM")&&!this.shadowRoot&&this.attachShadow({mode:"open"});const e=Ve.get(this.appName);e?e.url!==this.appUrl||!e.isPrefetch&&e.getAppStatus()!==_.UNMOUNT?e.isPrefetch?r(`the url: ${this.appUrl} is different from prefetch url: ${e.url}`):r(`an app named ${this.appName} already exists`):this.handleAppMount(e):this.handleCreate()}disconnectedCallback(){ye.microAppCount>0&&(this.handleUnmount(this.getDisposeResult("destory")),0==--ye.microAppCount&&(de(),window.__MICRO_APP_ENVIRONMENT__&&window.removeEventListener("unmount",fe,!1)))}attributeChangedCallback(e,t,n){if(this.legalAttribute(e,n)&&this[e===w.NAME?"appName":"appUrl"]!==n)if(e!==w.URL||this.appUrl)e!==w.NAME||this.appName?this.isWating||(this.isWating=!0,s(this.handleAttributeUpdate)):(this.cacheData&&(ve.setData(n,this.cacheData),this.cacheData=null),this.appName=n);else{if(!(n=a(n)))return r("Invalid attribute url");this.appUrl=n}}legalAttribute(e,t){return!("string"!=typeof t||!t)||(r(`unexpected attribute ${e}, please check again`),!1)}handleAppMount(e){e.isPrefetch=!1,s((()=>{var t,n;return e.mount(null!==(t=this.shadowRoot)&&void 0!==t?t:this,this.getDisposeResult("inline"),null!==(n=this.getAttribute("baseurl"))&&void 0!==n?n:"")}))}handleCreate(){var e,t;const n=new Ye({name:this.appName,url:this.appUrl,container:null!==(e=this.shadowRoot)&&void 0!==e?e:this,inline:this.getDisposeResult("inline"),scopecss:!(this.getDisposeResult("disableScopecss")||this.getDisposeResult("shadowDOM")),useSandbox:!this.getDisposeResult("disableSandbox"),macro:this.getDisposeResult("macro"),baseurl:null!==(t=this.getAttribute("baseurl"))&&void 0!==t?t:""});Ve.set(this.appName,n)}handleUnmount(e){const t=Ve.get(this.appName);t&&t.getAppStatus()!==_.UNMOUNT&&t.unmount(e)}getDisposeResult(e){return(this.hasAttribute(e)||ve[e])&&"false"!==this.getAttribute(e)}set data(e){this.appName?ve.setData(this.appName,e):this.cacheData=e}get data(){return this.appName?ve.getData(this.appName,!0):this.cacheData?this.cacheData:null}}ye.microAppCount=0;const be=new class{constructor(){this.eventList=new Map}isLegalName(e){return!!e||(r("event-center: Invalid name"),!1)}on(e,t,n=!1){if(this.isLegalName(e)){if("function"!=typeof t)return r("event-center: Invalid callback function");let o=this.eventList.get(e);o?n&&Object.getOwnPropertyNames(o.data).length&&t(o.data):(o={data:{},callbacks:new Set},this.eventList.set(e,o)),o.callbacks.add(t)}}off(e,t){if(this.isLegalName(e)){const n=this.eventList.get(e);n&&("function"==typeof t?n.callbacks.delete(t):n.callbacks.clear())}}dispatch(e,t){if(this.isLegalName(e)){if("[object Object]"!==toString.call(t))return r("event-center: data must be object");let n=this.eventList.get(e);if(n){if(n.data!==t){n.data=t;for(const e of n.callbacks)e(t)}}else n={data:t,callbacks:new Set},this.eventList.set(e,n)}}getData(e){var t;const n=this.eventList.get(e);return null!==(t=null==n?void 0:n.data)&&void 0!==t?t:null}};function ge(e,t){return"string"==typeof e&&e?t?`__from_base_app_${e}__`:`__from_micro_app_${e}__`:""}class Ee{addGlobalDataListener(e,t){be.on("global",e,t)}removeGlobalDataListener(e){"function"==typeof e&&be.off("global",e)}setGlobalData(e){be.dispatch("global",e)}clearGlobalDataListener(){be.off("global")}}class we extends Ee{addDataListener(e,t,n){be.on(ge(e,!1),t,n)}removeDataListener(e,t){"function"==typeof t&&be.off(ge(e,!1),t)}getData(e,t=!1){return be.getData(ge(e,t))}setData(e,t){be.dispatch(ge(e,!0),t)}clearDataListener(e){be.off(ge(e,!1))}}class _e extends Ee{constructor(e){super(),this.appName=e}addDataListener(e,t){be.on(ge(this.appName,!0),e,t)}removeDataListener(e){"function"==typeof e&&be.off(ge(this.appName,!0),e)}getData(){return be.getData(ge(this.appName,!0))}dispatch(e){y(),be.dispatch(ge(this.appName,!1),e);const t=Ve.get(this.appName);if((null==t?void 0:t.container)&&"[object Object]"===toString.call(e)){const n=new CustomEvent("datachange",{detail:{data:e}});let o=t.container;o instanceof ShadowRoot&&(o=o.host),o.dispatchEvent(n)}}clearDataListener(){be.off(ge(this.appName,!0))}}var ve=new class extends we{constructor(){super(...arguments),this.tagName="micro-app",this.preFetch=Je}start(e){if(!(null===window||void 0===window?void 0:window.customElements))return r("customElements is not supported in this environment");if(null==e?void 0:e.tagName){if(!/^micro-app(-\S+)?/.test(e.tagName))return r(`${e.tagName} is invalid tagName`);this.tagName=e.tagName}var t,n;n=this.tagName,(window.customElements.get(n)?(i(`element ${n} is already defined`),0):(window.customElements.define(n,ye),1))&&e&&"[object Object]"===toString.call(e)&&(this.shadowDOM=e.shadowDOM,this.destory=e.destory,this.inline=e.inline,this.disableScopecss=e.disableScopecss,this.disableSandbox=e.disableSandbox,this.macro=e.macro,g(e.fetch)&&(this.fetch=e.fetch),"[object Object]"===toString.call(e.lifeCycles)&&(this.lifeCycles=e.lifeCycles),"[object Object]"===toString.call(e.plugins)&&(this.plugins=e.plugins),e.preFetchApps&&Je(e.preFetchApps),e.globalAssets&&(t=e.globalAssets,"[object Object]"===toString.call(t)&&d((()=>{if("[object Array]"===toString.call(t.js)){const e=t.js.filter((e=>"string"==typeof e&&e.includes(".js")&&!$.has(e))),n=[];e.forEach((e=>{n.push(Ne(e))})),p(n,(t=>{const n=e[t.index];$.has(n)||$.set(n,t.data)}),(e=>{r(e)}))}if("[object Array]"===toString.call(t.css)){const e=t.css.filter((e=>"string"==typeof e&&e.includes(".css")&&!U.has(e))),n=[];e.forEach((e=>{n.push(Ne(e))})),p(n,(t=>{const n=e[t.index];U.has(n)||U.set(n,t.data)}),(e=>{r(e)}))}}))))}};function Ne(e,t=null,n={}){return g(ve.fetch)?ve.fetch(e,n,t):fetch(e,n).then((e=>e.text()))}function Ae(e,t,n){const o=Array.from(e.children);o.length&&o.forEach((e=>{Ae(e,t,n)}));for(const r of o)r instanceof HTMLLinkElement?r.hasAttribute("exclude")?e.replaceChild(document.createComment("link element with exclude attribute ignored by micro-app"),r):t.scopecss?T(r,e,t,n):r.hasAttribute("href")&&r.setAttribute("href",u(r.getAttribute("href"),t.url)):r instanceof HTMLStyleElement?r.hasAttribute("exclude")?e.replaceChild(document.createComment("style element with exclude attribute ignored by micro-app"),r):t.scopecss&&n.appendChild(P(r,t.name)):r instanceof HTMLScriptElement?k(r,e,t):r instanceof HTMLMetaElement||r instanceof HTMLTitleElement?e.removeChild(r):/^(img|iframe)$/i.test(r.tagName)&&r.hasAttribute("src")&&r.setAttribute("src",u(r.getAttribute("src"),t.url))}function Oe(e,t){const n=function(e){const t=E("div");return t.innerHTML=e,t}(e),o=n.querySelector("micro-app-head"),i=n.querySelector("micro-app-body");if(!o||!i){const e=`element ${o?"body":"head"} is missing`;return t.onerror(new Error(e)),r(e)}Ae(n,t,o),t.source.links.size?j(n,t,o):t.onLoad(n),t.source.scripts.size?B(n,t):t.onLoad(n)}const Ce=new WeakMap;const Se=new WeakMap;function De(e,t){if(Se.has(t))return Se.get(t);if(g(t)&&!function(e){if(Ce.has(e))return Ce.get(e);const t=e.toString(),n=e.prototype&&e.prototype.constructor===e&&Object.getOwnPropertyNames(e.prototype).length>1||/^function\s+[A-Z]/.test(t)||/^class\s+/.test(t);return Ce.set(e,n),n}(t)){const n=t.bind(e);for(const e in t)n[e]=t[e];return t.hasOwnProperty("prototype")&&!n.hasOwnProperty("prototype")&&(n.prototype=t.prototype),Se.set(t,n),n}return t}const Re=window.addEventListener,Pe=window.removeEventListener,Me=window.setInterval,Le=window.setTimeout,xe=window.clearInterval,Ue=window.clearTimeout,Te=document.addEventListener,je=document.removeEventListener,$e=new Map;let Ie=!1;const ke=new Map;function Be(){Ie||function(){Ie=!0;const e=Object.getOwnPropertyDescriptor(document,"onclick");if(!1===(null==e?void 0:e.configurable))return r("Cannot redefine document property onclick");const t=document.onclick;document.onclick=null;let n=!1;function o(e){$e.forEach((t=>{"function"==typeof t&&t.call(document,e)}))}Object.defineProperty(document,"onclick",{configurable:!1,enumerable:!0,get(){const e=f();return e?$e.get(e):$e.get("base")},set(e){const t=f();t?$e.set(t,e):$e.set("base",e),n||"function"!=typeof e||(n=!0,Te.call(document,"click",o,!1))}}),t&&(document.onclick=t)}(),document.addEventListener=function(e,t,n){const o=f();if(o){const n=ke.get(o);if(n){const o=n.get(e);o?o.add(t):n.set(e,new Set([t]))}else ke.set(o,new Map([[e,new Set([t])]]))}return Te.call(document,e,t,n)},document.removeEventListener=function(e,t,n){const o=f();if(o){const n=ke.get(o);if(n){const o=n.get(e);(null==o?void 0:o.size)&&o.has(t)&&o.delete(t)}}return je.call(document,e,t,n)}}function We(e,t){return"unmount"===e?`unmount-${t.__MICRO_APP_NAME__}`:e}const He=["System","__cjsWrapper","__REACT_ERROR_OVERLAY_GLOBAL_HOOK__"],qe=["location"],Ge={undefined:!0,Array:!0,Object:!0,String:!0,Boolean:!0,Math:!0,Number:!0,Symbol:!0,parseFloat:!0,Float32Array:!0};let Fe;function Ke(e){Fe&&clearTimeout(Fe),Fe=setTimeout(e,0)}class ze{constructor(e,o,r){this.active=!1,this.scopeProperties=["webpackJsonp"],this.escapeProperties=[],this.microWindow={},this.injectedKeys=new Set,this.escapeKeys=new Set;const i=new Map,c=e=>this.microWindow.hasOwnProperty(e)||t.hasOwnProperty(e);this.getScopeProperties(e),this.inject(this.microWindow,e,o),this.releaseEffect=function(e){const t=new Map,n=new Set,o=new Set;return e.addEventListener=function(n,o,r){n=We(n,e);const i=t.get(n);return i?i.add(o):t.set(n,new Set([o])),Re.call(window,n,o,r)},e.removeEventListener=function(n,o,r){n=We(n,e);const i=t.get(n);return(null==i?void 0:i.size)&&i.has(o)&&i.delete(o),Pe.call(window,n,o,r)},e.setInterval=function(e,t,...o){const r=Me(e,t,...o);return n.add(r),r},e.setTimeout=function(e,t,...n){const r=Le(e,t,...n);return o.add(r),r},e.clearInterval=function(e){n.delete(e),xe(e)},e.clearTimeout=function(e){o.delete(e),Ue(e)},()=>{t.size&&(t.forEach(((e,t)=>{if(e.size)for(const n of e)Pe.call(window,t,n)})),t.clear()),n.size&&(n.forEach((e=>{xe(e)})),n.clear()),o.size&&(o.forEach((e=>{Ue(e)})),o.clear());const r=e.__MICRO_APP_NAME__;$e.delete(r);const i=ke.get(r);i&&(i.forEach(((e,t)=>{if(e.size)for(const n of e)je.call(document,t,n)})),i.clear())}}(this.microWindow),this.proxyWindow=new Proxy(this.microWindow,{get:(o,i)=>{if(i===Symbol.unscopables)return Ge;if(["window","self","globalThis"].includes(i))return this.proxyWindow;if("top"===i||"parent"===i)return t===t.parent?this.proxyWindow:Reflect.get(t,i);if("hasOwnProperty"===i)return c;if("document"===i||"eval"===i)switch(this.active&&(m(e),(r?Ke:s)((()=>m(null)))),i){case"document":return n;case"eval":return eval}if(this.scopeProperties.includes(i))return Reflect.get(o,i);if(Reflect.has(o,i))return Reflect.get(o,i);const a=Reflect.get(t,i);return De(t,a)},set:(e,n,o)=>{if(this.active){if(qe.includes(n))Reflect.set(t,n,o);else if(e.hasOwnProperty(n)||!t.hasOwnProperty(n)||this.scopeProperties.includes(n))Reflect.set(e,n,o),this.injectedKeys.add(n);else{const r=Object.getOwnPropertyDescriptor(t,n),{writable:i,configurable:s,enumerable:c}=r;i&&(Object.defineProperty(e,n,{configurable:s,enumerable:c,writable:i,value:o}),this.injectedKeys.add(n))}(this.escapeProperties.includes(n)||He.includes(n)&&!Reflect.has(t,n))&&!this.scopeProperties.includes(n)&&(Reflect.set(t,n,o),this.escapeKeys.add(n))}return!0},has:(e,n)=>this.scopeProperties.includes(n)?n in e:n in Ge||n in e||n in t,getOwnPropertyDescriptor:(e,n)=>{if(e.hasOwnProperty(n))return i.set(n,"target"),Object.getOwnPropertyDescriptor(e,n);if(t.hasOwnProperty(n)){i.set(n,"rawWindow");const e=Object.getOwnPropertyDescriptor(t,n);return e&&!e.configurable&&(e.configurable=!0),e}},defineProperty:(e,n,o)=>"rawWindow"===i.get(n)?Reflect.defineProperty(t,n,o):Reflect.defineProperty(e,n,o),ownKeys:e=>Reflect.ownKeys(t).concat(Reflect.ownKeys(e)).filter((function(e){return!(e in this)&&(this[e]=!0)}),Object.create(null)),deleteProperty:(e,n)=>!e.hasOwnProperty(n)||(this.escapeKeys.has(n)&&Reflect.deleteProperty(t,n),Reflect.deleteProperty(e,n))})}start(e){this.active||(this.active=!0,this.microWindow.__MICRO_APP_BASE_URL__=e,t._babelPolyfill&&(t._babelPolyfill=!1),1==++ze.activeCount&&Be())}stop(){this.active&&(this.active=!1,this.releaseEffect(),this.microWindow.microApp.clearDataListener(),this.injectedKeys.forEach((e=>{Reflect.deleteProperty(this.microWindow,e)})),this.injectedKeys.clear(),this.escapeKeys.forEach((e=>{Reflect.deleteProperty(t,e)})),this.escapeKeys.clear(),0==--ze.activeCount&&(document.addEventListener=Te,document.removeEventListener=je))}getScopeProperties(e){var t;if("object"==typeof ve.plugins){if("[object Array]"===toString.call(ve.plugins.global))for(const e of ve.plugins.global)"object"==typeof e&&("[object Array]"===toString.call(e.scopeProperties)&&(this.scopeProperties=this.scopeProperties.concat(e.scopeProperties)),"[object Array]"===toString.call(e.escapeProperties)&&(this.escapeProperties=this.escapeProperties.concat(e.escapeProperties)));if("[object Array]"===toString.call(null===(t=ve.plugins.modules)||void 0===t?void 0:t[e]))for(const t of ve.plugins.modules[e])"object"==typeof t&&("[object Array]"===toString.call(t.scopeProperties)&&(this.scopeProperties=this.scopeProperties.concat(t.scopeProperties)),"[object Array]"===toString.call(t.escapeProperties)&&(this.escapeProperties=this.escapeProperties.concat(t.escapeProperties)))}}inject(e,o,r){e.__MICRO_APP_ENVIRONMENT__=!0,e.__MICRO_APP_NAME__=o,e.__MICRO_APP_PUBLIC_PATH__=l(r),e.microApp=new _e(o),e.rawWindow=t,e.rawDocument=n}}ze.activeCount=0;const Ve=new Map;class Ye{constructor({name:e,url:t,container:n,inline:o,scopecss:r,useSandbox:i,macro:s,baseurl:c}){this.status=_.NOT_LOADED,this.loadSourceLevel=0,this.isPrefetch=!1,this.container=null,this.macro=!1,this.baseurl="",this.sandBox=null,this.container=null!=n?n:null,this.inline=null!=o&&o,this.baseurl=null!=c?c:"",this.name=e,this.url=t,this.useSandbox=i,this.scopecss=this.useSandbox&&r,this.macro=null!=s&&s,this.source={links:new Map,scripts:new Map},this.loadSourceCode(),this.useSandbox&&(this.sandBox=new ze(e,t,this.macro))}loadSourceCode(){var e;this.status=_.LOADING_SOURCE_CODE,Ne((e=this).url,e.name,{cache:"no-cache"}).then((t=>{if(!t){const t="html is empty, please check in detail";return e.onerror(new Error(t)),r(t)}Oe(t=t.replace(/<head[^>]*>[\s\S]*?<\/head>/i,(e=>e.replace(/<head/i,"<micro-app-head").replace(/<\/head>/i,"</micro-app-head>"))).replace(/<body[^>]*>[\s\S]*?<\/body>/i,(e=>e.replace(/<body/i,"<micro-app-body").replace(/<\/body>/i,"</micro-app-body>"))),e)})).catch((t=>{r(`Failed to fetch data from ${e.url}, micro-app stop rendering`,t),e.onLoadError(t)}))}onLoad(e){if(2==++this.loadSourceLevel){if(this.source.html=e,this.isPrefetch||this.status===_.UNMOUNT)return;this.status=_.LOAD_SOURCE_FINISHED,this.mount()}}onLoadError(e){this.loadSourceLevel=-1,this.status!==_.UNMOUNT&&(this.onerror(e),this.status=_.LOAD_SOURCE_ERROR)}mount(e,t,n){var o;if(!this.container&&e&&(this.container=e),"boolean"==typeof t&&t!==this.inline&&(this.inline=t),this.baseurl=null!=n?n:this.baseurl,2!==this.loadSourceLevel)return void(this.status=_.LOADING_SOURCE_CODE);me(this.container,this.name,v.BEFOREMOUNT),this.status=_.MOUNTING;const i=this.source.html.cloneNode(!0),c=document.createDocumentFragment();Array.from(i.childNodes).forEach((e=>{c.appendChild(e)})),this.container.appendChild(c),null===(o=this.sandBox)||void 0===o||o.start(this.baseurl),function(e,t){const n=Array.from(e.entries()),o=[],i=[];for(const[e,r]of n)r.isDynamic||(r.defer||r.async?(r.isExternal?o.push(Ne(e,t.name)):o.push(r.code),i.push([e,r])):W(e,r.code,t,r.module,!1));o.length&&Promise.all(o).then((e=>{e.forEach(((e,n)=>{W(i[n][0],e,t,i[n][1].module,!1)}))})).catch((e=>{r(e)}))}(this.source.scripts,this),this.status!==_.UNMOUNT&&(this.status=_.MOUNTED,s((()=>{this.status!==_.UNMOUNT&&me(this.container,this.name,v.MOUNTED)})))}unmount(e){var t;this.status===_.LOAD_SOURCE_ERROR&&(e=!0),this.status=_.UNMOUNT,me(this.container,this.name,v.UNMOUNT),function(e){const t=new CustomEvent(`unmount-${e}`);window.dispatchEvent(t)}(this.name),null===(t=this.sandBox)||void 0===t||t.stop(),this.container=null,e&&Ve.delete(this.name)}onerror(e){me(this.container,this.name,v.ERROR,e)}getAppStatus(){return this.status}}function Je(e){d((()=>{"function"==typeof e&&(e=e()),function(e){const t=[];return"[object Array]"===toString.call(e)&&e.forEach((e=>{e.url=a(e.url),"[object Object]"===toString.call(e)&&e.name&&"string"==typeof e.name&&e.url&&!Ve.has(e.name)&&t.push(e)})),t}(e).forEach((e=>{var t,n,o;const r=new Ye({name:e.name,url:e.url,scopecss:!(null!==(t=e.disableScopecss)&&void 0!==t?t:ve.disableScopecss),useSandbox:!(null!==(n=e.disableSandbox)&&void 0!==n?n:ve.disableSandbox),macro:null!==(o=e.macro)&&void 0!==o?o:ve.macro});r.isPrefetch=!0,Ve.set(e.name,r)}))}))}e.default=ve,e.preFetch=Je,e.pureCreateElement=E,e.removeDomScope=y,e.version=o,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=index.umd.js.map
{
"name": "@micro-zoe/micro-app",
"version": "0.2.4",
"version": "0.2.5",
"description": "A minimalist solution for building micro front-end applications",
"private": false,
"main": "lib/index.min.js",
"module": "lib/index.esm.js",
"types": "lib/index.d.ts",
"private": false,
"directories": {

@@ -17,2 +17,3 @@ "doc": "docs"

"start:main-vue2": "npm-run-all --parallel build:watch start-child:* main-vue2",
"start:main-vue3-vite": "npm-run-all --parallel build:watch start-child:* main-vue3-vite",
"build:watch": "cross-env NODE_ENV='development' rollup -c -w",

@@ -22,2 +23,3 @@ "build": "cross-env NODE_ENV='production' rollup -c && npm run createtype && npm run afterbuild",

"install:main-vue2": "cd examples/main-vue2 && yarn",
"install:main-vue3-vite": "cd examples/main-vue3-vite && yarn",
"install:child-react16": "cd examples/children/react16 && yarn",

@@ -31,2 +33,3 @@ "install:child-react17": "cd examples/children/react17 && yarn",

"main-vue2": "cd examples/main-vue2 && yarn start",
"main-vue3-vite": "cd examples/main-vue3-vite && yarn start",
"start-child:react16": "cd examples/children/react16 && yarn start",

@@ -68,3 +71,3 @@ "start-child:react17": "cd examples/children/react17 && yarn start",

],
"author": "zero",
"author": "cangdu",
"license": "MIT",

@@ -71,0 +74,0 @@ "bugs": {

@@ -20,11 +20,11 @@ <p align="center">

</a>
<a href="https://travis-ci.com/github/bailicangdu/micro-app">
<img src="https://travis-ci.com/bailicangdu/micro-app.svg?branch=master" alt="travis"/>
<a href="https://travis-ci.com/github/micro-zoe/micro-app">
<img src="https://api.travis-ci.com/micro-zoe/micro-app.svg?branch=master" alt="travis"/>
</a>
<a href="https://coveralls.io/github/bailicangdu/micro-app?branch=master">
<img src="https://coveralls.io/repos/github/bailicangdu/micro-app/badge.svg?branch=master" alt="coveralls"/>
<a href="https://coveralls.io/github/micro-zoe/micro-app?branch=master">
<img src="https://coveralls.io/repos/github/micro-zoe/micro-app/badge.svg?branch=master" alt="coveralls"/>
</a>
</p>
English|[简体中文](https://github.com/micro-zoe/micro-app/blob/master/README.zh-cn.md)|[Discussions](https://github.com/micro-zoe/micro-app/discussions)|[Gitter](https://gitter.im/microzoe/micro-app)
English|[简体中文](https://github.com/micro-zoe/micro-app/blob/master/README.zh-cn.md)|[Documentation](https://zeroing.jd.com/micro-app/)|[Discussions](https://github.com/micro-zoe/micro-app/discussions)|[Gitter](https://gitter.im/microzoe/micro-app)

@@ -128,3 +128,3 @@ # 📖Introduction

More detailed configuration can be viewed [Official website document](https://zeroing.jd.com/micro-app/docs.html#/zh-cn/start).
More detailed configuration can be viewed [Documentation](https://zeroing.jd.com/micro-app/docs.html#/zh-cn/start).

@@ -134,3 +134,3 @@ # 🤝 Contribution

If you or your team are using it, please [tell us](https://github.com/micro-zoe/micro-app/issues/35)
If you are using it, please [tell us](https://github.com/micro-zoe/micro-app/issues/35)

@@ -143,3 +143,3 @@ ### development

2、Installation dependencies
2、Install dependencies
```

@@ -154,3 +154,3 @@ yarn bootstrap

The react base application is started by default. If you want to start the vue base application, you can run: `yarn start:main-vue2`
For more commands, see [DEVELP](https://github.com/micro-zoe/micro-app/blob/master/DEVELOP.md)

@@ -203,3 +203,7 @@ # FAQ

# Contributors
<a href="https://github.com/micro-zoe/micro-app/graphs/contributors"><img src="https://opencollective.com/micro-app/contributors.svg?width=890&button=false" /></a>
# License
[MIT License](https://github.com/micro-zoe/micro-app/blob/master/LICENSE)

@@ -20,11 +20,11 @@ <p align="center">

</a>
<a href="https://travis-ci.com/github/bailicangdu/micro-app">
<img src="https://travis-ci.com/bailicangdu/micro-app.svg?branch=master" alt="travis"/>
<a href="https://travis-ci.com/github/micro-zoe/micro-app">
<img src="https://api.travis-ci.com/micro-zoe/micro-app.svg?branch=master" alt="travis"/>
</a>
<a href="https://coveralls.io/github/bailicangdu/micro-app?branch=master">
<img src="https://coveralls.io/repos/github/bailicangdu/micro-app/badge.svg?branch=master" alt="coveralls"/>
<a href="https://coveralls.io/github/micro-zoe/micro-app?branch=master">
<img src="https://coveralls.io/repos/github/micro-zoe/micro-app/badge.svg?branch=master" alt="coveralls"/>
</a>
</p>
[English](https://github.com/micro-zoe/micro-app)|简体中文|[讨论组](https://github.com/micro-zoe/micro-app/discussions)|[Gitter群聊](https://gitter.im/microzoe/micro-app)
[English](https://github.com/micro-zoe/micro-app)|简体中文|[官网文档](https://zeroing.jd.com/micro-app/)|[讨论组](https://github.com/micro-zoe/micro-app/discussions)|[Gitter群聊](https://gitter.im/microzoe/micro-app)

@@ -37,3 +37,5 @@ # 📖简介

#### 概念图
![image](https://img10.360buyimg.com/imagetools/jfs/t1/168885/23/20790/54203/6084d445E0c9ec00e/d879637b4bb34253.png ':size=750')
<p>
<img src="https://img10.360buyimg.com/imagetools/jfs/t1/168885/23/20790/54203/6084d445E0c9ec00e/d879637b4bb34253.png" alt="概念图" width='850'/>
</p>

@@ -126,3 +128,3 @@ # 🔧开始使用

![image](https://img12.360buyimg.com/imagetools/jfs/t1/196940/34/1541/38365/610a14fcE46c21374/c321b9f8fa50a8fc.png)
<img src="https://img12.360buyimg.com/imagetools/jfs/t1/196940/34/1541/38365/610a14fcE46c21374/c321b9f8fa50a8fc.png" alt="result" width='900'/>

@@ -136,3 +138,3 @@ 上面列出了react和vue框架的使用方式,它们是可以自由组合的,比如基座应用是react,子应用是vue,或者基座应用是vue,子应用是react,或者基座应用和子应用都是react、vue。 micro-app对前端框架没有限制,任何框架都可以作为基座应用嵌入任何类型框架的子应用。

如果您或您的团队正在使用,请务必[告诉我们](https://github.com/micro-zoe/micro-app/issues/35)
如果您正在使用,请务必[告诉我们](https://github.com/micro-zoe/micro-app/issues/35)

@@ -155,3 +157,3 @@ ### 本地运行

默认启动react基座应用,如果想启动vue基座应用,可以运行`yarn start:main-vue2`
更多命令请查看[DEVELP](https://github.com/micro-zoe/micro-app/blob/master/DEVELOP.zh-cn.md)

@@ -205,3 +207,7 @@ # FAQ

# 贡献者们
<a href="https://github.com/micro-zoe/micro-app/graphs/contributors"><img src="https://opencollective.com/micro-app/contributors.svg?width=890&button=false" /></a>
# License
[MIT License](https://github.com/micro-zoe/micro-app/blob/master/LICENSE)

@@ -73,4 +73,4 @@ declare module '@micro-app/types' {

interface MicroAppElementType {
name: AttrType // app name
url: AttrType // app url
appName: AttrType // app name
appUrl: AttrType // app url
isWating: boolean // combine action of set attribute name, url

@@ -77,0 +77,0 @@ cacheData: Record<PropertyKey, unknown> | null // Cache data

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc