@micro-zoe/micro-app 0.4.3 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.umd.js","sources":["../src/libs/utils.ts","../src/constants.ts","../src/source/fetch.ts","../src/libs/global_env.ts","../src/source/scoped_css.ts","../src/source/load_event.ts","../src/source/links.ts","../src/source/scripts.ts","../src/source/index.ts","../src/sandbox/bind_function.ts","../src/sandbox/effect.ts","../src/interact/index.ts","../src/interact/event_center.ts","../src/sandbox/index.ts","../src/interact/lifecycles_event.ts","../src/create_app.ts","../src/source/patch.ts","../src/libs/additional.ts","../src/micro_app_element.ts","../src/prefetch.ts","../src/micro_app.ts"],"sourcesContent":["/* eslint-disable no-new-func, indent, @typescript-eslint/explicit-module-boundary-types */\nimport type { Func } from '@micro-app/types'\n\nexport const version = '__VERSION__'\n\n// do not use isUndefined\nexport const isBrowser = typeof window !== 'undefined'\n\n// do not use isUndefined\nexport const globalThis = (typeof global !== 'undefined')\n ? global\n : (\n (typeof window !== 'undefined')\n ? window\n : (\n (typeof self !== 'undefined') ? self : Function('return this')()\n )\n )\n\n// is Undefined\nexport function isUndefined (target: unknown): target is undefined {\n return target === undefined\n}\n\n// is Null\nexport function isNull (target: unknown): target is null {\n return target === null\n}\n\n// is String\nexport function isString (target: unknown): target is string {\n return typeof target === 'string'\n}\n\n// is Boolean\nexport function isBoolean (target: unknown): target is boolean {\n return typeof target === 'boolean'\n}\n\n// is function\nexport function isFunction (target: unknown): boolean {\n return typeof target === 'function'\n}\n\n// is Array\nexport const isArray = Array.isArray\n\n// is PlainObject\nexport function isPlainObject (target: unknown): boolean {\n return toString.call(target) === '[object Object]'\n}\n\n// is Promise\nexport function isPromise (target: unknown): boolean {\n return toString.call(target) === '[object Promise]'\n}\n\n// is bind function\nexport function isBoundFunction (target: any): boolean {\n return isFunction(target) && target.name.indexOf('bound ') === 0 && !target.hasOwnProperty('prototype')\n}\n\n// is ShadowRoot\nexport function isShadowRoot (target: unknown): boolean {\n return typeof ShadowRoot !== 'undefined' && target instanceof ShadowRoot\n}\n\n/**\n * format error log\n * @param msg message\n * @param appName app name, default is null\n */\nexport function logError (\n msg: unknown,\n appName: string | null = null,\n ...rest: any[]\n): void {\n const appNameTip = appName && isString(appName) ? ` app ${appName}:` : ''\n if (isString(msg)) {\n console.error(`[micro-app]${appNameTip} ${msg}`, ...rest)\n } else {\n console.error(`[micro-app]${appNameTip}`, msg, ...rest)\n }\n}\n\n/**\n * format warn log\n * @param msg message\n * @param appName app name, default is null\n */\nexport function logWarn (\n msg: unknown,\n appName: string | null = null,\n ...rest: any[]\n): void {\n const appNameTip = appName && isString(appName) ? ` app ${appName}:` : ''\n if (isString(msg)) {\n console.warn(`[micro-app]${appNameTip} ${msg}`, ...rest)\n } else {\n console.warn(`[micro-app]${appNameTip}`, msg, ...rest)\n }\n}\n\n/**\n * async execution\n * @param fn callback\n * @param args params\n */\nexport function defer (fn: Func, ...args: any[]): void {\n Promise.resolve().then(fn.bind(null, ...args))\n}\n\n/**\n * Add address protocol\n * @param url address\n */\nexport function addProtocol (url: string): string {\n return url.startsWith('//') ? `${location.protocol}${url}` : url\n}\n\n/**\n * Format URL address\n * @param url address\n */\nexport function formatURL (url: string | null, appName: string | null = null): string {\n if (!isString(url) || !url) return ''\n\n try {\n const { origin, pathname, search } = new URL(addProtocol(url))\n // If it ends with .html/.node/.php/.net/.etc, don’t need to add /\n if (/\\.(\\w+)$/.test(pathname)) {\n return `${origin}${pathname}${search}`\n }\n const fullPath = `${origin}${pathname}/`.replace(/\\/\\/$/, '/')\n return /^https?:\\/\\//.test(fullPath) ? `${fullPath}${search}` : ''\n } catch (e) {\n logError(e, appName)\n return ''\n }\n}\n\n// export function formatName (name: string): string {\n// if (!isString(name) || !name) return ''\n// return name.replace(/(^\\d+)|([^\\w\\d-_])/gi, '')\n// }\n\n/**\n * Get valid address, such as https://xxx/xx/xx.html to https://xxx/xx/\n * @param url app.url\n */\nexport function getEffectivePath (url: string): string {\n const { origin, pathname } = new URL(url)\n if (/\\.(\\w+)$/.test(pathname)) {\n const fullPath = `${origin}${pathname}`\n const pathArr = fullPath.split('/')\n pathArr.pop()\n return pathArr.join('/') + '/'\n }\n\n return `${origin}${pathname}/`.replace(/\\/\\/$/, '/')\n}\n\n/**\n * Complete address\n * @param path address\n * @param baseURI base url(app.url)\n */\nexport function CompletionPath (path: string, baseURI: string): string {\n if (\n !path ||\n /^((((ht|f)tps?)|file):)?\\/\\//.test(path) ||\n /^(data|blob):/.test(path)\n ) return path\n\n return new URL(path, getEffectivePath(addProtocol(baseURI))).toString()\n}\n\n/**\n * Get the folder where the link resource is located,\n * which is used to complete the relative address in the css\n * @param linkpath full link address\n */\nexport function getLinkFileDir (linkpath: string): string {\n const pathArr = linkpath.split('/')\n pathArr.pop()\n return addProtocol(pathArr.join('/') + '/')\n}\n\n/**\n * promise stream\n * @param promiseList promise list\n * @param successCb success callback\n * @param errorCb failed callback\n * @param finallyCb finally callback\n */\nexport function promiseStream <T> (\n promiseList: Array<Promise<T> | T>,\n successCb: CallableFunction,\n errorCb: CallableFunction,\n finallyCb?: CallableFunction,\n): void {\n let finishedNum = 0\n\n function isFinished () {\n if (++finishedNum === promiseList.length && finallyCb) finallyCb()\n }\n\n promiseList.forEach((p, i) => {\n if (isPromise(p)) {\n (p as Promise<T>).then((res: T) => {\n successCb({\n data: res,\n index: i,\n })\n isFinished()\n }).catch((err: Error) => {\n errorCb({\n error: err,\n index: i,\n })\n isFinished()\n })\n } else {\n successCb({\n data: p,\n index: i,\n })\n isFinished()\n }\n })\n}\n\n// Check whether the browser supports module script\nexport function isSupportModuleScript (): boolean {\n const s = document.createElement('script')\n return 'noModule' in s\n}\n\n// Create a random symbol string\nexport function createNonceSrc (): string {\n return 'inline-' + Math.random().toString(36).substr(2, 15)\n}\n\n// Array deduplication\nexport function unique (array: any[]): any[] {\n return array.filter(function (this: Record<PropertyKey, boolean>, item) {\n return item in this ? false : (this[item] = true)\n }, Object.create(null))\n}\n\n// requestIdleCallback polyfill\nexport const requestIdleCallback = globalThis.requestIdleCallback ||\n function (fn: CallableFunction) {\n const lastTime = Date.now()\n return setTimeout(function () {\n fn({\n didTimeout: false,\n timeRemaining () {\n return Math.max(0, 50 - (Date.now() - lastTime))\n },\n })\n }, 1)\n }\n\n/**\n * Record the currently running app.name\n */\nlet currentMicroAppName: string | null = null\nexport function setCurrentAppName (appName: string | null): void {\n currentMicroAppName = appName\n}\n\n// get the currently running app.name\nexport function getCurrentAppName (): string | null {\n return currentMicroAppName\n}\n\n// Clear appName\nexport function removeDomScope (): void {\n setCurrentAppName(null)\n}\n\n// is safari browser\nexport function isSafari (): boolean {\n return /Safari/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent)\n}\n\n/**\n * Create pure elements\n */\nexport function pureCreateElement<K extends keyof HTMLElementTagNameMap> (tagName: K, options?: ElementCreationOptions): HTMLElementTagNameMap[K] {\n const element = document.createElement(tagName, options)\n if (element.__MICRO_APP_NAME__) delete element.__MICRO_APP_NAME__\n return element\n}\n\n/**\n * clone origin elements to target\n * @param origin Cloned element\n * @param target Accept cloned elements\n * @param deep deep clone or transfer dom\n */\nexport function cloneNode <T extends Element, Q extends Element> (\n origin: T,\n target: Q,\n deep: boolean,\n): void {\n target.innerHTML = ''\n if (deep) {\n const clonedNode = origin.cloneNode(true)\n const fragment = document.createDocumentFragment()\n Array.from(clonedNode.childNodes).forEach((node: Node | Element) => {\n fragment.appendChild(node)\n })\n target.appendChild(fragment)\n } else {\n Array.from(origin.childNodes).forEach((node: Node | Element) => {\n target.appendChild(node)\n })\n }\n}\n\n// is invalid key of querySelector\nexport function isInvalidQuerySelectorKey (key: string): boolean {\n if (__TEST__) return !key || /(^\\d)|([^\\w\\d-_$])/gi.test(key)\n return !key || /(^\\d)|([^\\w\\d-_\\u4e00-\\u9fa5])/gi.test(key)\n}\n\n// unique element\nexport function isUniqueElement (key: string): boolean {\n return (\n /^body$/i.test(key) ||\n /^head$/i.test(key) ||\n /^html$/i.test(key)\n )\n}\n","export enum ObservedAttrName {\n NAME = 'name',\n URL = 'url',\n}\n\n// app status\nexport enum appStatus {\n NOT_LOADED = 'NOT_LOADED',\n LOADING_SOURCE_CODE = 'LOADING_SOURCE_CODE',\n LOAD_SOURCE_FINISHED = 'LOAD_SOURCE_FINISHED',\n LOAD_SOURCE_ERROR = 'LOAD_SOURCE_ERROR',\n MOUNTING = 'MOUNTING',\n MOUNTED = 'MOUNTED',\n UNMOUNT = 'UNMOUNT',\n}\n\n// lifecycles\nexport enum lifeCycles {\n CREATED = 'created',\n BEFOREMOUNT = 'beforemount',\n MOUNTED = 'mounted',\n UNMOUNT = 'unmount',\n ERROR = 'error',\n}\n","import { isFunction } from '../libs/utils'\nimport microApp from '../micro_app'\n\n/**\n * fetch source of html, js, css\n * @param url source path\n * @param appName app name\n * @param config config of fetch\n */\nexport function fetchSource (url: string, appName: string | null = null, options = {}): Promise<string> {\n if (isFunction(microApp.fetch)) {\n return microApp.fetch!(url, options, appName)\n }\n return fetch(url, options).then((res) => {\n return res.text()\n })\n}\n","import { isSupportModuleScript, isBrowser } from './utils'\n\ntype RequestIdleCallbackOptions = {\n timeout: number\n}\n\ntype RequestIdleCallbackInfo = {\n readonly didTimeout: boolean\n timeRemaining: () => number\n}\n\ndeclare global {\n interface Window {\n requestIdleCallback (\n callback: (info: RequestIdleCallbackInfo) => void,\n opts?: RequestIdleCallbackOptions,\n ): number\n _babelPolyfill: boolean\n proxyWindow?: WindowProxy\n __MICRO_APP_ENVIRONMENT__?: boolean\n __MICRO_APP_UMD_MODE__?: boolean\n __MICRO_APP_BASE_APPLICATION__?: boolean\n }\n interface Element {\n __MICRO_APP_NAME__?: string\n data?: any\n }\n interface Node {\n __MICRO_APP_NAME__?: string\n }\n interface HTMLStyleElement {\n linkpath?: string\n }\n}\n\nconst globalEnv: Record<string, any> = {}\n\nexport function initGlobalEnv (): void {\n if (isBrowser) {\n /**\n * save patch raw methods\n * pay attention to this binding\n */\n const rawSetAttribute = Element.prototype.setAttribute\n const rawAppendChild = Node.prototype.appendChild\n const rawInsertBefore = Node.prototype.insertBefore\n const rawReplaceChild = Node.prototype.replaceChild\n const rawRemoveChild = Node.prototype.removeChild\n const rawAppend = Element.prototype.append\n const rawPrepend = Element.prototype.prepend\n\n const rawCreateElement = Document.prototype.createElement\n const rawCreateElementNS = Document.prototype.createElementNS\n const rawCreateDocumentFragment = Document.prototype.createDocumentFragment\n const rawQuerySelector = Document.prototype.querySelector\n const rawQuerySelectorAll = Document.prototype.querySelectorAll\n const rawGetElementById = Document.prototype.getElementById\n const rawGetElementsByClassName = Document.prototype.getElementsByClassName\n const rawGetElementsByTagName = Document.prototype.getElementsByTagName\n const rawGetElementsByName = Document.prototype.getElementsByName\n\n const rawWindow = Function('return window')()\n const rawDocument = Function('return document')()\n const supportModuleScript = isSupportModuleScript()\n const templateStyle: HTMLStyleElement = rawDocument.body.querySelector('#micro-app-template-style')\n\n /**\n * save effect raw methods\n * pay attention to this binding, especially setInterval, setTimeout, clearInterval, clearTimeout\n */\n const rawWindowAddEventListener = rawWindow.addEventListener\n const rawWindowRemoveEventListener = rawWindow.removeEventListener\n const rawSetInterval = rawWindow.setInterval\n const rawSetTimeout = rawWindow.setTimeout\n const rawClearInterval = rawWindow.clearInterval\n const rawClearTimeout = rawWindow.clearTimeout\n\n const rawDocumentAddEventListener = rawDocument.addEventListener\n const rawDocumentRemoveEventListener = rawDocument.removeEventListener\n\n // mark current application as base application\n window.__MICRO_APP_BASE_APPLICATION__ = true\n\n Object.assign(globalEnv, {\n // source/patch\n rawSetAttribute,\n rawAppendChild,\n rawInsertBefore,\n rawReplaceChild,\n rawRemoveChild,\n rawAppend,\n rawPrepend,\n rawCreateElement,\n rawCreateElementNS,\n rawCreateDocumentFragment,\n rawQuerySelector,\n rawQuerySelectorAll,\n rawGetElementById,\n rawGetElementsByClassName,\n rawGetElementsByTagName,\n rawGetElementsByName,\n\n // common global vars\n rawWindow,\n rawDocument,\n supportModuleScript,\n templateStyle,\n\n // sandbox/effect\n rawWindowAddEventListener,\n rawWindowRemoveEventListener,\n rawSetInterval,\n rawSetTimeout,\n rawClearInterval,\n rawClearTimeout,\n rawDocumentAddEventListener,\n rawDocumentRemoveEventListener,\n })\n }\n}\n\nexport default globalEnv\n","import { appInstanceMap } from '../create_app'\nimport { CompletionPath, isSafari, pureCreateElement, getLinkFileDir } from '../libs/utils'\nimport microApp from '../micro_app'\nimport globalEnv from '../libs/global_env'\n\n// https://developer.mozilla.org/zh-CN/docs/Web/API/CSSRule\nenum CSSRuleType {\n STYLE_RULE = 1,\n MEDIA_RULE = 4,\n SUPPORTS_RULE = 12,\n}\n\n/**\n * Bind css scope\n * Special case:\n * 1. html-abc | abc-html\n * 2. html body.abc\n * 3. abchtml | htmlabc | abcbody | bodyabc\n * 4. html + body | html > body | html.body | html[name=xx] | body[name=xx]\n * 5. xxx, html xxx, body xxx\n *\n * TODO: BUG\n .test-b {\n border: 1px solid var(--color-a);\n border-bottom-color: var(--color-b);\n }\n */\nfunction scopedStyleRule (rule: CSSStyleRule, prefix: string): string {\n const { selectorText, cssText } = rule\n if (/^((html[\\s>~,]+body)|(html|body|:root))$/.test(selectorText)) {\n return cssText.replace(/^((html[\\s>~,]+body)|(html|body|:root))/, prefix)\n } else if (selectorText === '*') {\n return cssText.replace('*', `${prefix} *`)\n }\n\n const builtInRootSelectorRE = /(^|\\s+)((html[\\s>~]+body)|(html|body|:root))(?=[\\s>~]+|$)/\n\n return cssText.replace(/^[\\s\\S]+{/, (selectors) => {\n return selectors.replace(/(^|,)([^,]+)/g, (all, $1, $2) => {\n if (builtInRootSelectorRE.test($2)) {\n // body[name=xx]|body.xx|body#xx etc. do not need to handle\n return all.replace(builtInRootSelectorRE, prefix)\n }\n return `${$1} ${prefix} ${$2.replace(/^\\s*/, '')}`\n })\n })\n}\n\n/**\n * Complete static resource address\n * @param cssText css content\n * @param baseURI domain name\n * @param textContent origin content\n * @param linkpath link resource address, if it is the style converted from link, it will have linkpath\n */\nfunction scopedHost (\n cssText: string,\n baseURI: string,\n textContent: string,\n linkpath?: string,\n) {\n return cssText.replace(/url\\([\"']?([^)\"']+)[\"']?\\)/gm, (all, $1) => {\n if (/^(data|blob):/.test($1)) {\n return all\n } else if (/^(https?:)?\\/\\//.test($1)) {\n if (isSafari()) {\n const purePath = $1.replace(/^https?:/, '')\n if (textContent.indexOf(purePath) === -1) {\n $1 = $1.replace(window.location.origin, '')\n } else {\n return all\n }\n } else {\n return all\n }\n }\n\n // ./a/b.png ../a/b.png a/b.png\n if (/^((\\.\\.?\\/)|[^/])/.test($1) && linkpath) {\n baseURI = getLinkFileDir(linkpath)\n }\n\n return `url(\"${CompletionPath($1, baseURI)}\")`\n })\n}\n\n// handle media and supports\nfunction scopedPackRule (\n rule: CSSMediaRule | CSSSupportsRule,\n prefix: string,\n packName: string,\n): string {\n const result = scopedRule(Array.from(rule.cssRules), prefix)\n return `@${packName} ${rule.conditionText} {${result}}`\n}\n\n/**\n * Process each cssrule\n * @param rules cssRule\n * @param prefix prefix as micro-app[name=xxx]\n */\nfunction scopedRule (rules: CSSRule[], prefix: string): string {\n let result = ''\n for (const rule of rules) {\n switch (rule.type) {\n case CSSRuleType.STYLE_RULE:\n result += scopedStyleRule(rule as CSSStyleRule, prefix)\n break\n case CSSRuleType.MEDIA_RULE:\n result += scopedPackRule(rule as CSSMediaRule, prefix, 'media')\n break\n case CSSRuleType.SUPPORTS_RULE:\n result += scopedPackRule(rule as CSSSupportsRule, prefix, 'supports')\n break\n default:\n result += rule.cssText\n break\n }\n }\n\n return result.replace(/^\\s+/, '')\n}\n\n/**\n * common method of bind CSS\n */\nfunction commonAction (\n templateStyle: HTMLStyleElement,\n styleElement: HTMLStyleElement,\n originContent: string,\n prefix: string,\n baseURI: string,\n linkpath?: string,\n) {\n const rules: CSSRule[] = Array.from(templateStyle.sheet?.cssRules ?? [])\n let result = scopedHost(\n scopedRule(rules, prefix),\n baseURI,\n originContent,\n linkpath,\n )\n /**\n * Solve the problem of missing content quotes in some Safari browsers\n * docs: https://developer.mozilla.org/zh-CN/docs/Web/CSS/content\n * If there are still problems, it is recommended to use the attr()\n */\n if (isSafari()) {\n result = result.replace(/([;{]\\s*content:\\s*)([^\\s\"][^\";}]*)/gm, (all, $1, $2) => {\n if (\n $2 === 'none' ||\n /^(url\\()|(counter\\()|(attr\\()|(open-quote)|(close-quote)/.test($2)\n ) {\n return all\n }\n return `${$1}\"${$2}\"`\n })\n }\n styleElement.textContent = result\n}\n\n/**\n * scopedCSS\n * @param styleElement target style element\n * @param appName app name\n */\nexport default function scopedCSS (styleElement: HTMLStyleElement, appName: string): HTMLStyleElement {\n const app = appInstanceMap.get(appName)\n if (app?.scopecss) {\n const prefix = `${microApp.tagName}[name=${appName}]`\n let templateStyle = globalEnv.templateStyle\n if (!templateStyle) {\n globalEnv.templateStyle = templateStyle = pureCreateElement('style')\n templateStyle.setAttribute('id', 'micro-app-template-style')\n globalEnv.rawDocument.body.appendChild(templateStyle)\n templateStyle.sheet!.disabled = true\n }\n\n if (styleElement.textContent) {\n templateStyle.textContent = styleElement.textContent\n commonAction(templateStyle, styleElement, styleElement.textContent, prefix, app.url, styleElement.linkpath)\n templateStyle.textContent = ''\n } else {\n const observer = new MutationObserver(function () {\n observer.disconnect()\n // styled-component will not be processed temporarily\n if (\n (!styleElement.textContent && styleElement.sheet?.cssRules?.length) ||\n styleElement.hasAttribute('data-styled')\n ) return\n commonAction(styleElement, styleElement, styleElement.textContent!, prefix, app.url, styleElement.linkpath)\n })\n\n observer.observe(styleElement, { childList: true })\n }\n }\n\n return styleElement\n}\n","import { isFunction } from '../libs/utils'\n\nfunction eventHandler (event: Event, element: HTMLLinkElement | HTMLScriptElement): void {\n Object.defineProperties(event, {\n currentTarget: {\n get () {\n return element\n }\n },\n srcElement: {\n get () {\n return element\n }\n },\n target: {\n get () {\n return element\n }\n },\n })\n}\n\nexport function dispatchOnLoadEvent (element: HTMLLinkElement | HTMLScriptElement): void {\n const event = new CustomEvent('load')\n eventHandler(event, element)\n if (isFunction(element.onload)) {\n element.onload!(event)\n } else {\n element.dispatchEvent(event)\n }\n}\n\nexport function dispatchOnErrorEvent (element: HTMLLinkElement | HTMLScriptElement): void {\n const event = new CustomEvent('error')\n eventHandler(event, element)\n if (isFunction(element.onerror)) {\n element.onerror!(event)\n } else {\n element.dispatchEvent(event)\n }\n}\n","import type {\n AppInterface,\n sourceLinkInfo,\n} from '@micro-app/types'\nimport { fetchSource } from './fetch'\nimport {\n CompletionPath,\n promiseStream,\n pureCreateElement,\n defer,\n logError,\n} from '../libs/utils'\nimport scopedCSS from './scoped_css'\nimport {\n dispatchOnLoadEvent,\n dispatchOnErrorEvent,\n} from './load_event'\n\n// Global links, reuse across apps\nexport const globalLinks = new Map<string, string>()\n\n/**\n * Extract link elements\n * @param link link element\n * @param parent parent element of link\n * @param app app\n * @param microAppHead micro-app-head element\n * @param isDynamic dynamic insert\n */\nexport function extractLinkFromHtml (\n link: HTMLLinkElement,\n parent: Node,\n app: AppInterface,\n microAppHead: Element | null,\n isDynamic = false,\n): any {\n const rel = link.getAttribute('rel')\n let href = link.getAttribute('href')\n let replaceComment: Comment | null = null\n if (rel === 'stylesheet' && href) {\n href = CompletionPath(href, app.url)\n if (!isDynamic) {\n replaceComment = document.createComment(`link element with href=${href} move to micro-app-head as style element`)\n const placeholderComment = document.createComment(`placeholder for link with href=${href}`)\n // all style elements insert into microAppHead\n microAppHead!.appendChild(placeholderComment)\n app.source.links.set(href, {\n code: '',\n placeholder: placeholderComment,\n isGlobal: link.hasAttribute('global'),\n })\n } else {\n return {\n url: href,\n info: {\n code: '',\n isGlobal: link.hasAttribute('global'),\n }\n }\n }\n } else if (rel && ['prefetch', 'preload', 'prerender', 'icon', 'apple-touch-icon'].includes(rel)) {\n // preload prefetch icon ....\n if (isDynamic) {\n replaceComment = document.createComment(`link element with rel=${rel}${href ? ' & href=' + href : ''} removed by micro-app`)\n } else {\n parent.removeChild(link)\n }\n } else if (href) {\n // dns-prefetch preconnect modulepreload search ....\n link.setAttribute('href', CompletionPath(href, app.url))\n }\n\n if (isDynamic) {\n return { replaceComment }\n } else if (replaceComment) {\n return parent.replaceChild(replaceComment, link)\n }\n}\n\n/**\n * Get link remote resources\n * @param wrapElement htmlDom\n * @param app app\n * @param microAppHead micro-app-head\n */\nexport function fetchLinksFromHtml (\n wrapElement: HTMLElement,\n app: AppInterface,\n microAppHead: Element,\n): void {\n const linkEntries: Array<[string, sourceLinkInfo]> = Array.from(app.source.links.entries())\n const fetchLinkPromise: Array<Promise<string>|string> = []\n for (const [url] of linkEntries) {\n const globalLinkCode = globalLinks.get(url)\n globalLinkCode ? fetchLinkPromise.push(globalLinkCode) : fetchLinkPromise.push(fetchSource(url, app.name))\n }\n\n promiseStream<string>(fetchLinkPromise, (res: {data: string, index: number}) => {\n fetchLinkSuccess(\n linkEntries[res.index][0],\n linkEntries[res.index][1],\n res.data,\n microAppHead,\n app,\n )\n }, (err: {error: Error, index: number}) => {\n logError(err, app.name)\n }, () => {\n app.onLoad(wrapElement)\n })\n}\n\n/**\n * fetch link succeeded, replace placeholder with style tag\n * @param url resource address\n * @param info resource link info\n * @param data code\n * @param microAppHead micro-app-head\n * @param app app\n */\nexport function fetchLinkSuccess (\n url: string,\n info: sourceLinkInfo,\n data: string,\n microAppHead: Element,\n app: AppInterface,\n): void {\n if (info.isGlobal && !globalLinks.has(url)) {\n globalLinks.set(url, data)\n }\n\n const styleLink = pureCreateElement('style')\n styleLink.textContent = data\n styleLink.linkpath = url\n\n microAppHead.replaceChild(scopedCSS(styleLink, app.name), info.placeholder!)\n\n info.placeholder = null\n info.code = data\n}\n\n/**\n * get css from dynamic link\n * @param url link address\n * @param info info\n * @param app app\n * @param originLink origin link element\n * @param replaceStyle style element which replaced origin link\n */\nexport function foramtDynamicLink (\n url: string,\n info: sourceLinkInfo,\n app: AppInterface,\n originLink: HTMLLinkElement,\n replaceStyle: HTMLStyleElement,\n): void {\n if (app.source.links.has(url)) {\n replaceStyle.textContent = app.source.links.get(url)!.code\n scopedCSS(replaceStyle, app.name)\n defer(() => dispatchOnLoadEvent(originLink))\n return\n }\n\n if (globalLinks.has(url)) {\n const code = globalLinks.get(url)!\n info.code = code\n app.source.links.set(url, info)\n replaceStyle.textContent = code\n scopedCSS(replaceStyle, app.name)\n defer(() => dispatchOnLoadEvent(originLink))\n return\n }\n\n fetchSource(url, app.name).then((data: string) => {\n info.code = data\n app.source.links.set(url, info)\n if (info.isGlobal) globalLinks.set(url, data)\n replaceStyle.textContent = data\n scopedCSS(replaceStyle, app.name)\n dispatchOnLoadEvent(originLink)\n }).catch((err) => {\n logError(err, app.name)\n dispatchOnErrorEvent(originLink)\n })\n}\n","/* eslint-disable node/no-callback-literal */\nimport type {\n AppInterface,\n sourceScriptInfo,\n plugins,\n Func,\n} from '@micro-app/types'\nimport { fetchSource } from './fetch'\nimport {\n CompletionPath,\n promiseStream,\n createNonceSrc,\n pureCreateElement,\n defer,\n logError,\n isUndefined,\n isPlainObject,\n isArray,\n isFunction,\n} from '../libs/utils'\nimport {\n dispatchOnLoadEvent,\n dispatchOnErrorEvent,\n} from './load_event'\nimport microApp from '../micro_app'\nimport globalEnv from '../libs/global_env'\n\ntype moduleCallBack = Func & { moduleCount?: number }\n\n// Global scripts, reuse across apps\nexport const globalScripts = new Map<string, string>()\n\n/**\n * Extract script elements\n * @param script script element\n * @param parent parent element of script\n * @param app app\n * @param isDynamic dynamic insert\n */\nexport function extractScriptElement (\n script: HTMLScriptElement,\n parent: Node,\n app: AppInterface,\n isDynamic = false,\n): any {\n let replaceComment: Comment | null = null\n let src: string | null = script.getAttribute('src')\n if (script.hasAttribute('exclude')) {\n replaceComment = document.createComment('script element with exclude attribute removed by micro-app')\n } else if (\n (script.type && !['text/javascript', 'text/ecmascript', 'application/javascript', 'application/ecmascript', 'module'].includes(script.type)) ||\n script.hasAttribute('ignore')\n ) {\n return null\n } else if (\n (globalEnv.supportModuleScript && script.noModule) ||\n (!globalEnv.supportModuleScript && script.type === 'module')\n ) {\n replaceComment = document.createComment(`${script.noModule ? 'noModule' : 'module'} script ignored by micro-app`)\n } else if (src) { // remote script\n src = CompletionPath(src, app.url)\n const info = {\n code: '',\n isExternal: true,\n isDynamic: isDynamic,\n async: script.hasAttribute('async'),\n defer: script.defer || script.type === 'module',\n module: script.type === 'module',\n isGlobal: script.hasAttribute('global'),\n }\n if (!isDynamic) {\n app.source.scripts.set(src, info)\n replaceComment = document.createComment(`script with src='${src}' extract by micro-app`)\n } else {\n return { url: src, info }\n }\n } else if (script.textContent) { // inline script\n const nonceStr: string = createNonceSrc()\n const info = {\n code: script.textContent,\n isExternal: false,\n isDynamic: isDynamic,\n async: false,\n defer: script.type === 'module',\n module: script.type === 'module',\n }\n if (!isDynamic) {\n app.source.scripts.set(nonceStr, info)\n replaceComment = document.createComment('inline script extract by micro-app')\n } else {\n return { url: nonceStr, info }\n }\n } else if (!isDynamic) {\n /**\n * script with empty src or empty script.textContent remove in static html\n * & not removed if it created by dynamic\n */\n replaceComment = document.createComment('script element removed by micro-app')\n }\n\n if (isDynamic) {\n return { replaceComment }\n } else {\n return parent.replaceChild(replaceComment!, script)\n }\n}\n\n/**\n * Get remote resources of script\n * @param wrapElement htmlDom\n * @param app app\n */\nexport function fetchScriptsFromHtml (\n wrapElement: HTMLElement,\n app: AppInterface,\n): void {\n const scriptEntries: Array<[string, sourceScriptInfo]> = Array.from(app.source.scripts.entries())\n const fetchScriptPromise: Promise<string>[] = []\n const fetchScriptPromiseInfo: Array<[string, sourceScriptInfo]> = []\n for (const [url, info] of scriptEntries) {\n if (info.isExternal) {\n const globalScriptText = globalScripts.get(url)\n if (globalScriptText) {\n info.code = globalScriptText\n } else if (!info.defer && !info.async) {\n fetchScriptPromise.push(fetchSource(url, app.name))\n fetchScriptPromiseInfo.push([url, info])\n }\n }\n }\n\n if (fetchScriptPromise.length) {\n promiseStream<string>(fetchScriptPromise, (res: {data: string, index: number}) => {\n fetchScriptSuccess(\n fetchScriptPromiseInfo[res.index][0],\n fetchScriptPromiseInfo[res.index][1],\n res.data,\n )\n }, (err: {error: Error, index: number}) => {\n logError(err, app.name)\n }, () => {\n app.onLoad(wrapElement)\n })\n } else {\n app.onLoad(wrapElement)\n }\n}\n\n/**\n * fetch js succeeded, record the code value\n * @param url script address\n * @param info resource script info\n * @param data code\n */\nexport function fetchScriptSuccess (\n url: string,\n info: sourceScriptInfo,\n data: string,\n): void {\n if (info.isGlobal && !globalScripts.has(url)) {\n globalScripts.set(url, data)\n }\n\n info.code = data\n}\n\n/**\n * Execute js in the mount lifecycle\n * @param scriptList script list\n * @param app app\n * @param initedHook callback for umd mode\n */\nexport function execScripts (\n scriptList: Map<string, sourceScriptInfo>,\n app: AppInterface,\n initedHook: moduleCallBack,\n): void {\n const scriptListEntries: Array<[string, sourceScriptInfo]> = Array.from(scriptList.entries())\n const deferScriptPromise: Array<Promise<string>|string> = []\n const deferScriptInfo: Array<[string, sourceScriptInfo]> = []\n for (const [url, info] of scriptListEntries) {\n if (!info.isDynamic) {\n if (info.defer || info.async) {\n if (info.isExternal && !info.code) {\n deferScriptPromise.push(fetchSource(url, app.name))\n } else {\n deferScriptPromise.push(info.code)\n }\n deferScriptInfo.push([url, info])\n\n if (info.module) initedHook.moduleCount = initedHook.moduleCount ? ++initedHook.moduleCount : 1\n } else {\n runScript(url, info.code, app, info.module, false)\n initedHook(false)\n }\n }\n }\n\n if (deferScriptPromise.length) {\n Promise.all(deferScriptPromise).then((res: string[]) => {\n res.forEach((code, index) => {\n const [url, info] = deferScriptInfo[index]\n runScript(url, info.code = info.code || code, app, info.module, false, initedHook)\n if (!info.module) initedHook(false)\n })\n initedHook(isUndefined(initedHook.moduleCount))\n }).catch((err) => {\n logError(err, app.name)\n initedHook(true)\n })\n } else {\n initedHook(true)\n }\n}\n\n/**\n * run code\n * @param url script address\n * @param code js code\n * @param app app\n * @param module type='module' of script\n * @param isDynamic dynamically created script\n * @param callback callback of module script\n */\nexport function runScript (\n url: string,\n code: string,\n app: AppInterface,\n module: boolean,\n isDynamic: boolean,\n callback?: moduleCallBack,\n): any {\n try {\n code = bindScope(url, code, app, module)\n if (app.inline || module) {\n const scriptElement = pureCreateElement('script')\n setInlinScriptContent(url, code, module, scriptElement, callback)\n if (isDynamic) return scriptElement\n // TEST IGNORE\n app.container?.querySelector('micro-app-body')!.appendChild(scriptElement)\n } else {\n Function(code)()\n if (isDynamic) return document.createComment('dynamic script extract by micro-app')\n }\n } catch (e) {\n console.error(`[micro-app from runScript] app ${app.name}: `, e)\n }\n}\n\n/**\n * Get dynamically created remote script\n * @param url script address\n * @param info info\n * @param app app\n * @param originScript origin script element\n */\nexport function runDynamicRemoteScript (\n url: string,\n info: sourceScriptInfo,\n app: AppInterface,\n originScript: HTMLScriptElement,\n): HTMLScriptElement | Comment {\n const dispatchScriptOnLoadEvent = () => dispatchOnLoadEvent(originScript)\n\n if (app.source.scripts.has(url)) {\n const existInfo: sourceScriptInfo = app.source.scripts.get(url)!\n if (!info.module) defer(dispatchScriptOnLoadEvent)\n return runScript(url, existInfo.code, app, info.module, true, dispatchScriptOnLoadEvent)\n }\n\n if (globalScripts.has(url)) {\n const code = globalScripts.get(url)!\n info.code = code\n app.source.scripts.set(url, info)\n if (!info.module) defer(dispatchScriptOnLoadEvent)\n return runScript(url, code, app, info.module, true, dispatchScriptOnLoadEvent)\n }\n\n let replaceElement: Comment | HTMLScriptElement\n if (app.inline || info.module) {\n replaceElement = pureCreateElement('script')\n } else {\n replaceElement = document.createComment(`dynamic script with src='${url}' extract by micro-app`)\n }\n\n fetchSource(url, app.name).then((code: string) => {\n info.code = code\n app.source.scripts.set(url, info)\n if (info.isGlobal) globalScripts.set(url, code)\n try {\n code = bindScope(url, code, app, info.module)\n if (app.inline || info.module) {\n setInlinScriptContent(url, code, info.module, replaceElement as HTMLScriptElement, dispatchScriptOnLoadEvent)\n } else {\n Function(code)()\n }\n } catch (e) {\n console.error(`[micro-app from runDynamicScript] app ${app.name}: `, e, url)\n }\n if (!info.module) dispatchOnLoadEvent(originScript)\n }).catch((err) => {\n logError(err, app.name)\n dispatchOnErrorEvent(originScript)\n })\n\n return replaceElement\n}\n\n/**\n * common handle for inline script\n * @param url script address\n * @param code js code\n * @param module type='module' of script\n * @param scriptElement target script element\n * @param callback callback of module script\n */\nfunction setInlinScriptContent (\n url: string,\n code: string,\n module: boolean,\n scriptElement: HTMLScriptElement,\n callback?: moduleCallBack,\n): void {\n if (module) {\n // module script is async, transform it to a blob for subsequent operations\n const blob = new Blob([code], { type: 'text/javascript' })\n scriptElement.src = URL.createObjectURL(blob)\n scriptElement.setAttribute('type', 'module')\n if (!url.startsWith('inline-')) {\n scriptElement.setAttribute('originSrc', url)\n }\n if (callback) {\n callback.moduleCount && callback.moduleCount--\n scriptElement.onload = callback.bind(scriptElement, callback.moduleCount === 0)\n }\n } else {\n scriptElement.textContent = code\n }\n}\n\n/**\n * bind js scope\n * @param url script address\n * @param code code\n * @param app app\n * @param module type='module' of script\n */\nfunction bindScope (\n url: string,\n code: string,\n app: AppInterface,\n module: boolean,\n): string {\n if (isPlainObject(microApp.plugins)) {\n code = usePlugins(url, code, app.name, microApp.plugins!)\n }\n if (app.sandBox && !module) {\n globalEnv.rawWindow.__MICRO_APP_PROXY_WINDOW__ = app.sandBox.proxyWindow\n return `;(function(window, self){with(window){;${code}\\n}}).call(window.__MICRO_APP_PROXY_WINDOW__, window.__MICRO_APP_PROXY_WINDOW__, window.__MICRO_APP_PROXY_WINDOW__);`\n }\n return code\n}\n\n/**\n * Call the plugin to process the file\n * @param url script address\n * @param code code\n * @param appName app name\n * @param plugins plugin list\n */\nfunction usePlugins (url: string, code: string, appName: string, plugins: plugins): string {\n if (isArray(plugins.global)) {\n for (const plugin of plugins.global) {\n if (isPlainObject(plugin) && isFunction(plugin.loader)) {\n code = plugin.loader!(code, url, plugin.options)\n }\n }\n }\n\n if (isArray(plugins.modules?.[appName])) {\n for (const plugin of plugins.modules![appName]) {\n if (isPlainObject(plugin) && isFunction(plugin.loader)) {\n code = plugin.loader!(code, url, plugin.options)\n }\n }\n }\n\n return code\n}\n","import type { AppInterface } from '@micro-app/types'\nimport { fetchSource } from './fetch'\nimport { logError, CompletionPath, pureCreateElement } from '../libs/utils'\nimport { extractLinkFromHtml, fetchLinksFromHtml } from './links'\nimport { extractScriptElement, fetchScriptsFromHtml } from './scripts'\nimport scopedCSS from './scoped_css'\n\n/**\n * transform html string to dom\n * @param str string dom\n */\nfunction getWrapElement (str: string): HTMLElement {\n const wrapDiv = pureCreateElement('div')\n\n wrapDiv.innerHTML = str\n\n return wrapDiv\n}\n\n/**\n * Recursively process each child element\n * @param parent parent element\n * @param app app\n * @param microAppHead micro-app-head element\n */\nfunction flatChildren (\n parent: HTMLElement,\n app: AppInterface,\n microAppHead: Element,\n): void {\n const children = Array.from(parent.children)\n\n children.length && children.forEach((child) => {\n flatChildren(child as HTMLElement, app, microAppHead)\n })\n\n for (const dom of children) {\n if (dom instanceof HTMLLinkElement) {\n if (dom.hasAttribute('exclude')) {\n parent.replaceChild(document.createComment('link element with exclude attribute ignored by micro-app'), dom)\n } else if (app.scopecss && !dom.hasAttribute('ignore')) {\n extractLinkFromHtml(dom, parent, app, microAppHead)\n } else if (dom.hasAttribute('href')) {\n dom.setAttribute('href', CompletionPath(dom.getAttribute('href')!, app.url))\n }\n } else if (dom instanceof HTMLStyleElement) {\n if (dom.hasAttribute('exclude')) {\n parent.replaceChild(document.createComment('style element with exclude attribute ignored by micro-app'), dom)\n } else if (app.scopecss && !dom.hasAttribute('ignore')) {\n microAppHead.appendChild(scopedCSS(dom, app.name))\n }\n } else if (dom instanceof HTMLScriptElement) {\n extractScriptElement(dom, parent, app)\n } else if (dom instanceof HTMLMetaElement || dom instanceof HTMLTitleElement) {\n parent.removeChild(dom)\n } else if (dom instanceof HTMLImageElement && dom.hasAttribute('src')) {\n dom.setAttribute('src', CompletionPath(dom.getAttribute('src')!, app.url))\n }\n }\n}\n\n/**\n * Extract link and script, bind style scope\n * @param htmlStr html string\n * @param app app\n */\nfunction extractSourceDom (htmlStr: string, app: AppInterface) {\n const wrapElement = getWrapElement(htmlStr)\n const microAppHead = wrapElement.querySelector('micro-app-head')\n const microAppBody = wrapElement.querySelector('micro-app-body')\n\n if (!microAppHead || !microAppBody) {\n const msg = `element ${microAppHead ? 'body' : 'head'} is missing`\n app.onerror(new Error(msg))\n return logError(msg, app.name)\n }\n\n flatChildren(wrapElement, app, microAppHead)\n\n if (app.source.links.size) {\n fetchLinksFromHtml(wrapElement, app, microAppHead)\n } else {\n app.onLoad(wrapElement)\n }\n\n if (app.source.scripts.size) {\n fetchScriptsFromHtml(wrapElement, app)\n } else {\n app.onLoad(wrapElement)\n }\n}\n\n/**\n * Get and format html\n * @param app app\n */\nexport default function extractHtml (app: AppInterface): void {\n fetchSource(app.url, app.name, { cache: 'no-cache' }).then((htmlStr: string) => {\n if (!htmlStr) {\n const msg = 'html is empty, please check in detail'\n app.onerror(new Error(msg))\n return logError(msg, app.name)\n }\n htmlStr = htmlStr\n .replace(/<head[^>]*>[\\s\\S]*?<\\/head>/i, (match) => {\n return match\n .replace(/<head/i, '<micro-app-head')\n .replace(/<\\/head>/i, '</micro-app-head>')\n })\n .replace(/<body[^>]*>[\\s\\S]*?<\\/body>/i, (match) => {\n return match\n .replace(/<body/i, '<micro-app-body')\n .replace(/<\\/body>/i, '</micro-app-body>')\n })\n\n extractSourceDom(htmlStr, app)\n }).catch((e) => {\n logError(`Failed to fetch data from ${app.url}, micro-app stop rendering`, app.name, e)\n app.onLoadError(e)\n })\n}\n","import type { Func } from '@micro-app/types'\nimport { isFunction, isBoundFunction } from '../libs/utils'\n\nconst boundedMap = new WeakMap<CallableFunction, boolean>()\nexport function isBoundedFunction (value: CallableFunction): boolean {\n if (boundedMap.has(value)) {\n return boundedMap.get(value)!\n }\n\n // bind function\n const boundFunction = isBoundFunction(value)\n\n boundedMap.set(value, boundFunction)\n\n return boundFunction\n}\n\nconst constructorMap = new WeakMap<Func | FunctionConstructor, boolean>()\nfunction isConstructor (value: Func | FunctionConstructor) {\n if (constructorMap.has(value)) {\n return constructorMap.get(value)\n }\n\n const valueStr = value.toString()\n\n const result = (\n value.prototype &&\n value.prototype.constructor === value &&\n Object.getOwnPropertyNames(value.prototype).length > 1\n ) ||\n /^function\\s+[A-Z]/.test(valueStr) ||\n /^class\\s+/.test(valueStr)\n\n constructorMap.set(value, result)\n\n return result\n}\n\nconst rawWindowMethodMap = new WeakMap<CallableFunction, CallableFunction>()\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\nexport default function bindFunctionToRawWidow (rawWindow: Window, value: any): unknown {\n if (rawWindowMethodMap.has(value)) {\n return rawWindowMethodMap.get(value)\n }\n\n if (isFunction(value) && !isConstructor(value) && !isBoundedFunction(value)) {\n const bindRawWindowValue = value.bind(rawWindow)\n\n for (const key in value) {\n bindRawWindowValue[key] = value[key]\n }\n\n if (value.hasOwnProperty('prototype') && !bindRawWindowValue.hasOwnProperty('prototype')) {\n bindRawWindowValue.prototype = value.prototype\n }\n\n rawWindowMethodMap.set(value, bindRawWindowValue)\n return bindRawWindowValue\n }\n\n return value\n}\n","import type { microWindowType } from '@micro-app/types'\nimport { getCurrentAppName, setCurrentAppName, logWarn, isFunction, isBoundFunction } from '../libs/utils'\nimport { appInstanceMap } from '../create_app'\nimport globalEnv from '../libs/global_env'\n\ntype MicroEventListener = EventListenerOrEventListenerObject & Record<string, any>\ntype timeInfo = {\n handler: TimerHandler,\n timeout?: number,\n args: any[],\n}\n\n// document.onclick binding list, the binding function of each application is unique\nconst documentClickListMap = new Map<string, unknown>()\nlet hasRewriteDocumentOnClick = false\n/**\n * Rewrite document.onclick and execute it only once\n */\nfunction overwriteDocumentOnClick (): void {\n hasRewriteDocumentOnClick = true\n if (Object.getOwnPropertyDescriptor(document, 'onclick')) {\n return logWarn('Cannot redefine document property onclick')\n }\n const rawOnClick = document.onclick\n document.onclick = null\n let hasDocumentClickInited = false\n\n function onClickHandler (e: MouseEvent) {\n documentClickListMap.forEach((f) => {\n isFunction(f) && (f as Function).call(document, e)\n })\n }\n\n Object.defineProperty(document, 'onclick', {\n configurable: true,\n enumerable: true,\n get () {\n const appName = getCurrentAppName()\n return appName ? documentClickListMap.get(appName) : documentClickListMap.get('base')\n },\n set (f: GlobalEventHandlers['onclick']) {\n const appName = getCurrentAppName()\n if (appName) {\n documentClickListMap.set(appName, f)\n } else {\n documentClickListMap.set('base', f)\n }\n\n if (!hasDocumentClickInited && isFunction(f)) {\n hasDocumentClickInited = true\n globalEnv.rawDocumentAddEventListener.call(globalEnv.rawDocument, 'click', onClickHandler, false)\n }\n }\n })\n\n if (rawOnClick) {\n document.onclick = rawOnClick\n }\n}\n\n/**\n * The document event is globally, we need to clear these event bindings when micro application unmounted\n */\nconst documentEventListenerMap = new Map<string, Map<string, Set<MicroEventListener>>>()\nexport function effectDocumentEvent (): void {\n const {\n rawDocument,\n rawDocumentAddEventListener,\n rawDocumentRemoveEventListener,\n } = globalEnv\n\n if (!hasRewriteDocumentOnClick) {\n overwriteDocumentOnClick()\n }\n\n document.addEventListener = function (\n type: string,\n listener: MicroEventListener,\n options?: boolean | AddEventListenerOptions\n ): void {\n const appName = getCurrentAppName()\n /**\n * ignore bound function of document event in umd mode, used to solve problem of react global events\n */\n if (appName && !(appInstanceMap.get(appName)?.umdMode && isBoundFunction(listener))) {\n const appListenersMap = documentEventListenerMap.get(appName)\n if (appListenersMap) {\n const appListenerList = appListenersMap.get(type)\n if (appListenerList) {\n appListenerList.add(listener)\n } else {\n appListenersMap.set(type, new Set([listener]))\n }\n } else {\n documentEventListenerMap.set(appName, new Map([[type, new Set([listener])]]))\n }\n listener && (listener.__MICRO_MARK_OPTIONS__ = options)\n }\n rawDocumentAddEventListener.call(rawDocument, type, listener, options)\n }\n\n document.removeEventListener = function (\n type: string,\n listener: MicroEventListener,\n options?: boolean | AddEventListenerOptions,\n ): void {\n const appName = getCurrentAppName()\n if (appName) {\n const appListenersMap = documentEventListenerMap.get(appName)\n if (appListenersMap) {\n const appListenerList = appListenersMap.get(type)\n if (appListenerList?.size && appListenerList.has(listener)) {\n appListenerList.delete(listener)\n }\n }\n }\n rawDocumentRemoveEventListener.call(rawDocument, type, listener, options)\n }\n}\n\n// Clear the document event agent\nexport function releaseEffectDocumentEvent (): void {\n document.addEventListener = globalEnv.rawDocumentAddEventListener\n document.removeEventListener = globalEnv.rawDocumentRemoveEventListener\n}\n\n/**\n * Format event name\n * @param type event name\n * @param microWindow micro window\n */\nfunction formatEventType (type: string, microWindow: microWindowType): string {\n if (type === 'unmount') {\n return `unmount-${microWindow.__MICRO_APP_NAME__}`\n }\n return type\n}\n\n/**\n * Rewrite side-effect events\n * @param microWindow micro window\n */\nexport default function effect (microWindow: microWindowType): Record<string, CallableFunction> {\n const appName = microWindow.__MICRO_APP_NAME__\n const eventListenerMap = new Map<string, Set<MicroEventListener>>()\n const intervalIdMap = new Map<number, timeInfo>()\n const timeoutIdMap = new Map<number, timeInfo>()\n const {\n rawWindow,\n rawDocument,\n rawWindowAddEventListener,\n rawWindowRemoveEventListener,\n rawSetInterval,\n rawSetTimeout,\n rawClearInterval,\n rawClearTimeout,\n rawDocumentRemoveEventListener,\n } = globalEnv\n\n // listener may be null, e.g test-passive\n microWindow.addEventListener = function (\n type: string,\n listener: MicroEventListener,\n options?: boolean | AddEventListenerOptions,\n ): void {\n type = formatEventType(type, microWindow)\n const listenerList = eventListenerMap.get(type)\n if (listenerList) {\n listenerList.add(listener)\n } else {\n eventListenerMap.set(type, new Set([listener]))\n }\n listener && (listener.__MICRO_MARK_OPTIONS__ = options)\n rawWindowAddEventListener.call(rawWindow, type, listener, options)\n }\n\n microWindow.removeEventListener = function (\n type: string,\n listener: MicroEventListener,\n options?: boolean | AddEventListenerOptions,\n ): void {\n type = formatEventType(type, microWindow)\n const listenerList = eventListenerMap.get(type)\n if (listenerList?.size && listenerList.has(listener)) {\n listenerList.delete(listener)\n }\n rawWindowRemoveEventListener.call(rawWindow, type, listener, options)\n }\n\n microWindow.setInterval = function (\n handler: TimerHandler,\n timeout?: number,\n ...args: any[]\n ): number {\n const intervalId = rawSetInterval.call(rawWindow, handler, timeout, ...args)\n intervalIdMap.set(intervalId, { handler, timeout, args })\n return intervalId\n }\n\n microWindow.setTimeout = function (\n handler: TimerHandler,\n timeout?: number,\n ...args: any[]\n ): number {\n const timeoutId = rawSetTimeout.call(rawWindow, handler, timeout, ...args)\n timeoutIdMap.set(timeoutId, { handler, timeout, args })\n return timeoutId\n }\n\n microWindow.clearInterval = function (intervalId: number) {\n intervalIdMap.delete(intervalId)\n rawClearInterval.call(rawWindow, intervalId)\n }\n\n microWindow.clearTimeout = function (timeoutId: number) {\n timeoutIdMap.delete(timeoutId)\n rawClearTimeout.call(rawWindow, timeoutId)\n }\n\n const umdWindowListenerMap = new Map<string, Set<MicroEventListener>>()\n const umdDocumentListenerMap = new Map<string, Set<MicroEventListener>>()\n let umdIntervalIdMap = new Map<number, timeInfo>()\n let umdTimeoutIdMap = new Map<number, timeInfo>()\n let umdOnClickHandler: unknown\n\n // record event and timer before exec umdMountHook\n const recordUmdEffect = () => {\n // record window event\n eventListenerMap.forEach((listenerList, type) => {\n if (listenerList.size) {\n umdWindowListenerMap.set(type, new Set(listenerList))\n }\n })\n\n // record timers\n if (intervalIdMap.size) {\n umdIntervalIdMap = new Map(intervalIdMap)\n }\n\n if (timeoutIdMap.size) {\n umdTimeoutIdMap = new Map(timeoutIdMap)\n }\n\n // record onclick handler\n umdOnClickHandler = documentClickListMap.get(appName)\n\n // record document event\n const documentAppListenersMap = documentEventListenerMap.get(appName)\n if (documentAppListenersMap) {\n documentAppListenersMap.forEach((listenerList, type) => {\n if (listenerList.size) {\n umdDocumentListenerMap.set(type, new Set(listenerList))\n }\n })\n }\n }\n\n // rebuild event and timer before remount umd app\n const rebuildUmdEffect = () => {\n // rebuild window event\n umdWindowListenerMap.forEach((listenerList, type) => {\n for (const listener of listenerList) {\n microWindow.addEventListener(type, listener, listener?.__MICRO_MARK_OPTIONS__)\n }\n })\n\n // rebuild timer\n umdIntervalIdMap.forEach((info: timeInfo) => {\n microWindow.setInterval(info.handler, info.timeout, ...info.args)\n })\n\n umdTimeoutIdMap.forEach((info: timeInfo) => {\n microWindow.setTimeout(info.handler, info.timeout, ...info.args)\n })\n\n // rebuild onclick event\n umdOnClickHandler && documentClickListMap.set(appName, umdOnClickHandler)\n\n // rebuild document event\n setCurrentAppName(appName)\n umdDocumentListenerMap.forEach((listenerList, type) => {\n for (const listener of listenerList) {\n document.addEventListener(type, listener, listener?.__MICRO_MARK_OPTIONS__)\n }\n })\n setCurrentAppName(null)\n }\n\n // release all event listener & interval & timeout when unmount app\n const releaseEffect = () => {\n // Clear window binding events\n if (eventListenerMap.size) {\n eventListenerMap.forEach((listenerList, type) => {\n for (const listener of listenerList) {\n rawWindowRemoveEventListener.call(rawWindow, type, listener)\n }\n })\n eventListenerMap.clear()\n }\n\n // Clear timers\n if (intervalIdMap.size) {\n intervalIdMap.forEach((_, intervalId: number) => {\n rawClearInterval.call(rawWindow, intervalId)\n })\n intervalIdMap.clear()\n }\n\n if (timeoutIdMap.size) {\n timeoutIdMap.forEach((_, timeoutId: number) => {\n rawClearTimeout.call(rawWindow, timeoutId)\n })\n timeoutIdMap.clear()\n }\n\n // Clear the function bound by micro application through document.onclick\n documentClickListMap.delete(appName)\n\n // Clear document binding event\n const documentAppListenersMap = documentEventListenerMap.get(appName)\n if (documentAppListenersMap) {\n documentAppListenersMap.forEach((listenerList, type) => {\n for (const listener of listenerList) {\n rawDocumentRemoveEventListener.call(rawDocument, type, listener)\n }\n })\n documentAppListenersMap.clear()\n }\n }\n\n return {\n recordUmdEffect,\n rebuildUmdEffect,\n releaseEffect,\n }\n}\n","import { CallableFunctionForInteract } from '@micro-app/types'\nimport EventCenter from './event_center'\nimport { appInstanceMap } from '../create_app'\nimport { removeDomScope, isString, isFunction, isPlainObject, isShadowRoot } from '../libs/utils'\n\nconst eventCenter = new EventCenter()\n\n/**\n * Format event name\n * @param appName app.name\n * @param fromBaseApp is from base app\n */\nfunction formatEventName (appName: string, fromBaseApp: boolean): string {\n if (!isString(appName) || !appName) return ''\n return fromBaseApp ? `__from_base_app_${appName}__` : `__from_micro_app_${appName}__`\n}\n\n// Global data\nclass EventCenterForGlobal {\n /**\n * add listener of global data\n * @param cb listener\n * @param autoTrigger If there is cached data when first bind listener, whether it needs to trigger, default is false\n */\n addGlobalDataListener (cb: CallableFunctionForInteract, autoTrigger?: boolean): void {\n const appName = (this as any).appName\n // if appName exists, this is in sub app\n if (appName) {\n cb.__APP_NAME__ = appName\n cb.__AUTO_TRIGGER__ = autoTrigger\n }\n eventCenter.on('global', cb, autoTrigger)\n }\n\n /**\n * remove listener of global data\n * @param cb listener\n */\n removeGlobalDataListener (cb: CallableFunctionForInteract): void {\n if (isFunction(cb)) {\n eventCenter.off('global', cb)\n }\n }\n\n /**\n * dispatch global data\n * @param data data\n */\n setGlobalData (data: Record<PropertyKey, unknown>): void {\n // clear dom scope before dispatch global data, apply to micro app\n removeDomScope()\n\n eventCenter.dispatch('global', data)\n }\n\n /**\n * get global data\n */\n getGlobalData (): Record<PropertyKey, unknown> | null {\n return eventCenter.getData('global')\n }\n\n /**\n * clear all listener of global data\n * if appName exists, only the specified functions is cleared\n * if appName not exists, only clear the base app functions\n */\n clearGlobalDataListener (): void {\n const appName = (this as any).appName\n const eventInfo = eventCenter.eventList.get('global')\n if (eventInfo) {\n for (const cb of eventInfo.callbacks) {\n if (\n (appName && appName === cb.__APP_NAME__) ||\n !(appName || cb.__APP_NAME__)\n ) {\n eventInfo.callbacks.delete(cb)\n }\n }\n }\n }\n}\n\n// Event center for base app\nexport class EventCenterForBaseApp extends EventCenterForGlobal {\n /**\n * add listener\n * @param appName app.name\n * @param cb listener\n * @param autoTrigger If there is cached data when first bind listener, whether it needs to trigger, default is false\n */\n addDataListener (appName: string, cb: CallableFunction, autoTrigger?: boolean): void {\n eventCenter.on(formatEventName(appName, false), cb, autoTrigger)\n }\n\n /**\n * remove listener\n * @param appName app.name\n * @param cb listener\n */\n removeDataListener (appName: string, cb: CallableFunction): void {\n if (isFunction(cb)) {\n eventCenter.off(formatEventName(appName, false), cb)\n }\n }\n\n /**\n * get data from micro app or base app\n * @param appName app.name\n * @param fromBaseApp whether get data from base app, default is false\n */\n getData (appName: string, fromBaseApp = false): Record<PropertyKey, unknown> | null {\n return eventCenter.getData(formatEventName(appName, fromBaseApp))\n }\n\n /**\n * Dispatch data to the specified micro app\n * @param appName app.name\n * @param data data\n */\n setData (appName: string, data: Record<PropertyKey, unknown>): void {\n eventCenter.dispatch(formatEventName(appName, true), data)\n }\n\n /**\n * clear all listener for specified micro app\n * @param appName app.name\n */\n clearDataListener (appName: string): void {\n eventCenter.off(formatEventName(appName, false))\n }\n}\n\n// Event center for sub app\nexport class EventCenterForMicroApp extends EventCenterForGlobal {\n appName: string\n umdDataListeners?: {\n global: Set<CallableFunctionForInteract>,\n normal: Set<CallableFunctionForInteract>,\n }\n\n constructor (appName: string) {\n super()\n this.appName = appName\n }\n\n /**\n * add listener, monitor the data sent by the base app\n * @param cb listener\n * @param autoTrigger If there is cached data when first bind listener, whether it needs to trigger, default is false\n */\n addDataListener (cb: CallableFunctionForInteract, autoTrigger?: boolean): void {\n cb.__AUTO_TRIGGER__ = autoTrigger\n eventCenter.on(formatEventName(this.appName, true), cb, autoTrigger)\n }\n\n /**\n * remove listener\n * @param cb listener\n */\n removeDataListener (cb: CallableFunctionForInteract): void {\n if (isFunction(cb)) {\n eventCenter.off(formatEventName(this.appName, true), cb)\n }\n }\n\n /**\n * get data from base app\n */\n getData (): Record<PropertyKey, unknown> | null {\n return eventCenter.getData(formatEventName(this.appName, true))\n }\n\n /**\n * dispatch data to base app\n * @param data data\n */\n dispatch (data: Record<PropertyKey, unknown>): void {\n removeDomScope()\n\n eventCenter.dispatch(formatEventName(this.appName, false), data)\n\n const app = appInstanceMap.get(this.appName)\n if (app?.container && isPlainObject(data)) {\n const event = new CustomEvent('datachange', {\n detail: {\n data,\n }\n })\n\n let element = app.container\n if (isShadowRoot(element)) {\n element = (element as ShadowRoot).host as HTMLElement\n }\n element.dispatchEvent(event)\n }\n }\n\n /**\n * clear all listeners\n */\n clearDataListener (): void {\n eventCenter.off(formatEventName(this.appName, true))\n }\n}\n\n/**\n * Record UMD function before exec umdHookMount\n * @param microAppEventCneter\n */\nexport function recordDataCenterSnapshot (microAppEventCneter: EventCenterForMicroApp): void {\n const appName = microAppEventCneter.appName\n microAppEventCneter.umdDataListeners = { global: new Set(), normal: new Set() }\n\n const globalEventInfo = eventCenter.eventList.get('global')\n if (globalEventInfo) {\n for (const cb of globalEventInfo.callbacks) {\n if (appName === cb.__APP_NAME__) {\n microAppEventCneter.umdDataListeners.global.add(cb)\n }\n }\n }\n\n const subAppEventInfo = eventCenter.eventList.get(formatEventName(appName, true))\n if (subAppEventInfo) {\n microAppEventCneter.umdDataListeners.normal = new Set(subAppEventInfo.callbacks)\n }\n}\n\n/**\n * Rebind the UMD function of the record before remount\n * @param microAppEventCneter instance of EventCenterForMicroApp\n */\nexport function rebuildDataCenterSnapshot (microAppEventCneter: EventCenterForMicroApp): void {\n for (const cb of microAppEventCneter.umdDataListeners!.global) {\n microAppEventCneter.addGlobalDataListener(cb, cb.__AUTO_TRIGGER__)\n }\n\n for (const cb of microAppEventCneter.umdDataListeners!.normal) {\n microAppEventCneter.addDataListener(cb, cb.__AUTO_TRIGGER__)\n }\n}\n","import { CallableFunctionForInteract } from '@micro-app/types'\nimport { logError, isFunction, isPlainObject } from '../libs/utils'\n\nexport default class EventCenter {\n eventList = new Map<string, {\n data: Record<PropertyKey, unknown>,\n callbacks: Set<CallableFunctionForInteract>,\n }>()\n\n // whether the name is legal\n isLegalName (name: string): boolean {\n if (!name) {\n logError('event-center: Invalid name')\n return false\n }\n\n return true\n }\n\n /**\n * add listener\n * @param name event name\n * @param f listener\n * @param autoTrigger If there is cached data when first bind listener, whether it needs to trigger, default is false\n */\n on (name: string, f: CallableFunctionForInteract, autoTrigger = false): void {\n if (this.isLegalName(name)) {\n if (!isFunction(f)) {\n return logError('event-center: Invalid callback function')\n }\n\n let eventInfo = this.eventList.get(name)\n if (!eventInfo) {\n eventInfo = {\n data: {},\n callbacks: new Set(),\n }\n this.eventList.set(name, eventInfo)\n } else if (autoTrigger && Object.getOwnPropertyNames(eventInfo.data).length) {\n // auto trigger when data not null\n f(eventInfo.data)\n }\n\n eventInfo.callbacks.add(f)\n }\n }\n\n // remove listener, but the data is not cleared\n off (name: string, f?: CallableFunctionForInteract): void {\n if (this.isLegalName(name)) {\n const eventInfo = this.eventList.get(name)\n if (eventInfo) {\n if (isFunction(f)) {\n eventInfo.callbacks.delete(f!)\n } else {\n eventInfo.callbacks.clear()\n }\n }\n }\n }\n\n // dispatch data\n dispatch (name: string, data: Record<PropertyKey, unknown>): void {\n if (this.isLegalName(name)) {\n if (!isPlainObject(data)) {\n return logError('event-center: data must be object')\n }\n let eventInfo = this.eventList.get(name)\n if (eventInfo) {\n // Update when the data is not equal\n if (eventInfo.data !== data) {\n eventInfo.data = data\n for (const f of eventInfo.callbacks) {\n f(data)\n }\n }\n } else {\n eventInfo = {\n data: data,\n callbacks: new Set(),\n }\n this.eventList.set(name, eventInfo)\n }\n }\n }\n\n // get data\n getData (name: string): Record<PropertyKey, unknown> | null {\n const eventInfo = this.eventList.get(name)\n return eventInfo?.data ?? null\n }\n}\n","import type { SandBoxInterface, microWindowType } from '@micro-app/types'\nimport bindFunctionToRawWidow from './bind_function'\nimport {\n unique,\n setCurrentAppName,\n defer,\n getEffectivePath,\n removeDomScope,\n isString,\n isPlainObject,\n isArray,\n} from '../libs/utils'\nimport effect, { effectDocumentEvent, releaseEffectDocumentEvent } from './effect'\nimport {\n EventCenterForMicroApp,\n recordDataCenterSnapshot,\n rebuildDataCenterSnapshot,\n} from '../interact'\nimport microApp from '../micro_app'\nimport globalEnv from '../libs/global_env'\n\n/* eslint-disable camelcase */\ntype injectDataType = {\n __MICRO_APP_ENVIRONMENT__: boolean\n __MICRO_APP_NAME__: string\n __MICRO_APP_PUBLIC_PATH__: string\n __MICRO_APP_BASE_URL__: string\n __MICRO_APP_BASE_ROUTE__: string\n __MICRO_APP_UMDMODE__: boolean\n microApp: EventCenterForMicroApp\n rawWindow: Window\n rawDocument: Document\n removeDomScope: () => void\n}\n\n// Variables that can escape to rawWindow\nconst staticEscapeProperties: PropertyKey[] = [\n 'System',\n '__cjsWrapper',\n '__REACT_ERROR_OVERLAY_GLOBAL_HOOK__',\n]\n\n// Variables that can only assigned to rawWindow\nconst escapeSetterKeyList: PropertyKey[] = [\n 'location',\n]\n\nconst unscopables = {\n undefined: true,\n Array: true,\n Object: true,\n String: true,\n Boolean: true,\n Math: true,\n Number: true,\n Symbol: true,\n parseFloat: true,\n Float32Array: true,\n}\n\n/**\n * macro task to solve the rendering problem of vue3\n */\nlet macroTimer: number\nfunction macroTask (fn: TimerHandler): void {\n if (macroTimer) clearTimeout(macroTimer)\n macroTimer = setTimeout(fn, 0)\n}\n\nexport default class SandBox implements SandBoxInterface {\n static activeCount = 0 // number of active sandbox\n // @ts-ignore\n private recordUmdEffect: CallableFunction\n // @ts-ignore\n private rebuildUmdEffect: CallableFunction\n // @ts-ignore\n private releaseEffect: CallableFunction\n // Scoped global Properties(Properties that can only get and set in microWindow, will not escape to rawWindow)\n private scopeProperties: PropertyKey[] = ['webpackJsonp']\n // Properties that can be escape to rawWindow\n private escapeProperties: PropertyKey[] = []\n // Properties newly added to microWindow\n private injectedKeys = new Set<PropertyKey>()\n // Properties escape to rawWindow, cleared when unmount\n private escapeKeys = new Set<PropertyKey>()\n // record injected values before the first execution of umdHookMount and rebuild before remount umd app\n private recordUmdinjectedValues?: Map<PropertyKey, unknown>\n // sandbox state\n private active = false\n proxyWindow: WindowProxy & injectDataType // Proxy\n microWindow = {} as Window & injectDataType // Proxy target\n\n constructor (appName: string, url: string, macro: boolean) {\n const rawWindow = globalEnv.rawWindow\n const rawDocument = globalEnv.rawDocument\n const descriptorTargetMap = new Map<PropertyKey, 'target' | 'rawWindow'>()\n const hasOwnProperty = (key: PropertyKey) => this.microWindow.hasOwnProperty(key) || rawWindow.hasOwnProperty(key)\n // get scopeProperties and escapeProperties from plugins\n this.getScopeProperties(appName)\n // inject global properties\n this.inject(this.microWindow, appName, url)\n // Rewrite global event listener & timeout\n Object.assign(this, effect(this.microWindow))\n\n this.proxyWindow = new Proxy(this.microWindow, {\n get: (target: microWindowType, key: PropertyKey): unknown => {\n if (key === Symbol.unscopables) return unscopables\n\n if (['window', 'self', 'globalThis'].includes(key as string)) {\n return this.proxyWindow\n }\n\n if (key === 'top' || key === 'parent') {\n if (rawWindow === rawWindow.parent) { // not in iframe\n return this.proxyWindow\n }\n return Reflect.get(rawWindow, key) // iframe\n }\n\n if (key === 'hasOwnProperty') return hasOwnProperty\n\n if (key === 'document' || key === 'eval') {\n if (this.active) {\n setCurrentAppName(appName)\n ;(macro ? macroTask : defer)(() => setCurrentAppName(null))\n }\n switch (key) {\n case 'document':\n return rawDocument\n case 'eval':\n return eval\n }\n }\n\n if (Reflect.has(target, key)) {\n return Reflect.get(target, key)\n }\n\n if (\n this.scopeProperties.includes(key) ||\n (isString(key) && /^__MICRO_APP_/.test(key))\n ) {\n return Reflect.get(target, key)\n }\n\n const rawValue = Reflect.get(rawWindow, key)\n\n return bindFunctionToRawWidow(rawWindow, rawValue)\n },\n set: (target: microWindowType, key: PropertyKey, value: unknown): boolean => {\n if (this.active) {\n if (escapeSetterKeyList.includes(key)) {\n Reflect.set(rawWindow, key, value)\n } else if (\n !target.hasOwnProperty(key) &&\n rawWindow.hasOwnProperty(key) &&\n !this.scopeProperties.includes(key)\n ) {\n const descriptor = Object.getOwnPropertyDescriptor(rawWindow, key)\n const { writable, configurable, enumerable } = descriptor!\n if (writable) {\n Object.defineProperty(target, key, {\n configurable,\n enumerable,\n writable,\n value,\n })\n this.injectedKeys.add(key)\n }\n } else {\n Reflect.set(target, key, value)\n this.injectedKeys.add(key)\n }\n\n if (\n (\n this.escapeProperties.includes(key) ||\n (staticEscapeProperties.includes(key) && !Reflect.has(rawWindow, key))\n ) &&\n !this.scopeProperties.includes(key)\n ) {\n Reflect.set(rawWindow, key, value)\n this.escapeKeys.add(key)\n }\n }\n\n return true\n },\n has: (target: microWindowType, key: PropertyKey): boolean => {\n if (this.scopeProperties.includes(key)) return key in target\n return key in unscopables || key in target || key in rawWindow\n },\n getOwnPropertyDescriptor: (target: microWindowType, key: PropertyKey): PropertyDescriptor|undefined => {\n if (target.hasOwnProperty(key)) {\n descriptorTargetMap.set(key, 'target')\n return Object.getOwnPropertyDescriptor(target, key)\n }\n\n if (rawWindow.hasOwnProperty(key)) {\n descriptorTargetMap.set(key, 'rawWindow')\n const descriptor = Object.getOwnPropertyDescriptor(rawWindow, key)\n if (descriptor && !descriptor.configurable) {\n descriptor.configurable = true\n }\n return descriptor\n }\n\n return undefined\n },\n defineProperty: (target: microWindowType, key: PropertyKey, value: PropertyDescriptor): boolean => {\n const from = descriptorTargetMap.get(key)\n if (from === 'rawWindow') {\n return Reflect.defineProperty(rawWindow, key, value)\n }\n return Reflect.defineProperty(target, key, value)\n },\n ownKeys: (target: microWindowType): Array<string | symbol> => {\n return unique(Reflect.ownKeys(rawWindow).concat(Reflect.ownKeys(target)))\n },\n deleteProperty: (target: microWindowType, key: PropertyKey): boolean => {\n if (target.hasOwnProperty(key)) {\n if (this.escapeKeys.has(key)) {\n Reflect.deleteProperty(rawWindow, key)\n }\n return Reflect.deleteProperty(target, key)\n }\n return true\n },\n })\n }\n\n start (baseroute: string): void {\n if (!this.active) {\n this.active = true\n this.microWindow.__MICRO_APP_BASE_ROUTE__ = this.microWindow.__MICRO_APP_BASE_URL__ = baseroute\n if (globalEnv.rawWindow._babelPolyfill) globalEnv.rawWindow._babelPolyfill = false\n if (++SandBox.activeCount === 1) {\n effectDocumentEvent()\n }\n }\n }\n\n stop (): void {\n if (this.active) {\n this.active = false\n this.releaseEffect()\n this.microWindow.microApp.clearDataListener()\n this.microWindow.microApp.clearGlobalDataListener()\n\n this.injectedKeys.forEach((key: PropertyKey) => {\n Reflect.deleteProperty(this.microWindow, key)\n })\n this.injectedKeys.clear()\n\n this.escapeKeys.forEach((key: PropertyKey) => {\n Reflect.deleteProperty(globalEnv.rawWindow, key)\n })\n this.escapeKeys.clear()\n\n if (--SandBox.activeCount === 0) {\n releaseEffectDocumentEvent()\n }\n }\n }\n\n // record umd snapshot before the first execution of umdHookMount\n recordUmdSnapshot (): void {\n this.microWindow.__MICRO_APP_UMD_MODE__ = true\n this.recordUmdEffect()\n recordDataCenterSnapshot(this.microWindow.microApp)\n\n this.recordUmdinjectedValues = new Map<PropertyKey, unknown>()\n this.injectedKeys.forEach((key: PropertyKey) => {\n this.recordUmdinjectedValues!.set(key, Reflect.get(this.microWindow, key))\n })\n }\n\n // rebuild umd snapshot before remount umd app\n rebuildUmdSnapshot (): void {\n this.recordUmdinjectedValues!.forEach((value: unknown, key: PropertyKey) => {\n Reflect.set(this.proxyWindow, key, value)\n })\n this.rebuildUmdEffect()\n rebuildDataCenterSnapshot(this.microWindow.microApp)\n }\n\n /**\n * get scopeProperties and escapeProperties from plugins\n * @param appName app name\n */\n private getScopeProperties (appName: string): void {\n if (!isPlainObject(microApp.plugins)) return\n\n if (isArray(microApp.plugins!.global)) {\n for (const plugin of microApp.plugins!.global) {\n if (isPlainObject(plugin)) {\n if (isArray(plugin.scopeProperties)) {\n this.scopeProperties = this.scopeProperties.concat(plugin.scopeProperties!)\n }\n if (isArray(plugin.escapeProperties)) {\n this.escapeProperties = this.escapeProperties.concat(plugin.escapeProperties!)\n }\n }\n }\n }\n\n if (isArray(microApp.plugins!.modules?.[appName])) {\n for (const plugin of microApp.plugins!.modules![appName]) {\n if (isPlainObject(plugin)) {\n if (isArray(plugin.scopeProperties)) {\n this.scopeProperties = this.scopeProperties.concat(plugin.scopeProperties!)\n }\n if (isArray(plugin.escapeProperties)) {\n this.escapeProperties = this.escapeProperties.concat(plugin.escapeProperties!)\n }\n }\n }\n }\n }\n\n /**\n * inject global properties to microWindow\n * @param microWindow micro window\n * @param appName app name\n * @param url app url\n */\n private inject (microWindow: microWindowType, appName: string, url: string): void {\n microWindow.__MICRO_APP_ENVIRONMENT__ = true\n microWindow.__MICRO_APP_NAME__ = appName\n microWindow.__MICRO_APP_PUBLIC_PATH__ = getEffectivePath(url)\n microWindow.microApp = new EventCenterForMicroApp(appName)\n microWindow.rawWindow = globalEnv.rawWindow\n microWindow.rawDocument = globalEnv.rawDocument\n microWindow.removeDomScope = removeDomScope\n }\n}\n","import microApp from '../micro_app'\nimport { logError, isFunction, removeDomScope, isShadowRoot } from '../libs/utils'\n\nfunction eventHandler (event: CustomEvent, element: HTMLElement): void {\n Object.defineProperties(event, {\n currentTarget: {\n get () {\n return element\n }\n },\n target: {\n get () {\n return element\n }\n },\n })\n}\n\n/**\n * dispatch lifeCycles event to base app\n * created, beforemount, mounted, unmount, error\n * @param element container\n * @param appName app.name\n * @param lifecycleName lifeCycle name\n * @param error param from error hook\n */\nexport default function dispatchLifecyclesEvent (\n element: HTMLElement | ShadowRoot,\n appName: string,\n lifecycleName: string,\n error?: Error,\n): void {\n if (!element) {\n return logError(`element does not exist in lifecycle ${lifecycleName}`, appName)\n } else if (isShadowRoot(element)) {\n element = (element as ShadowRoot).host as HTMLElement\n }\n\n // clear dom scope before dispatch lifeCycles event to base app, especially mounted & unmount\n removeDomScope()\n\n const detail = Object.assign({\n name: appName,\n container: element,\n }, error && {\n error\n })\n\n const event = new CustomEvent(lifecycleName, {\n detail,\n })\n\n eventHandler(event, element as HTMLElement)\n // global hooks\n // @ts-ignore\n if (isFunction(microApp.lifeCycles?.[lifecycleName])) {\n // @ts-ignore\n microApp.lifeCycles[lifecycleName](event)\n }\n\n element.dispatchEvent(event)\n}\n\n/**\n * Dispatch unmount event to micro app\n * @param appName app.name\n */\nexport function dispatchUnmountToMicroApp (appName: string): void {\n const event = new CustomEvent(`unmount-${appName}`)\n window.dispatchEvent(event)\n}\n","import type {\n AppInterface,\n sourceType,\n SandBoxInterface,\n sourceLinkInfo,\n sourceScriptInfo,\n Func,\n} from '@micro-app/types'\nimport extractHtml from './source'\nimport { execScripts } from './source/scripts'\nimport { appStatus, lifeCycles } from './constants'\nimport SandBox from './sandbox'\nimport {\n isFunction,\n cloneNode,\n isBoolean,\n isPromise,\n logError,\n isShadowRoot,\n} from './libs/utils'\nimport dispatchLifecyclesEvent, { dispatchUnmountToMicroApp } from './interact/lifecycles_event'\nimport globalEnv from './libs/global_env'\n\n// micro app instances\nexport const appInstanceMap = new Map<string, AppInterface>()\n\n// params of CreateApp\nexport interface CreateAppParam {\n name: string\n url: string\n scopecss: boolean\n useSandbox: boolean\n macro?: boolean\n inline?: boolean\n baseroute?: string\n container?: HTMLElement | ShadowRoot\n}\n\nexport default class CreateApp implements AppInterface {\n private status: string = appStatus.NOT_LOADED\n private loadSourceLevel: -1|0|1|2 = 0\n private umdHookMount: Func | null = null\n private umdHookUnmount: Func | null = null\n private libraryName: string | null = null\n umdMode = false\n isPrefetch = false\n name: string\n url: string\n container: HTMLElement | ShadowRoot | null = null\n inline: boolean\n scopecss: boolean\n useSandbox: boolean\n macro = false\n baseroute = ''\n source: sourceType\n sandBox: SandBoxInterface | null = null\n\n constructor ({ name, url, container, inline, scopecss, useSandbox, macro, baseroute }: CreateAppParam) {\n this.container = container ?? null\n this.inline = inline ?? false\n this.baseroute = baseroute ?? ''\n // optional during init👆\n this.name = name\n this.url = url\n this.useSandbox = useSandbox\n this.scopecss = this.useSandbox && scopecss\n this.macro = macro ?? false\n this.source = {\n links: new Map<string, sourceLinkInfo>(),\n scripts: new Map<string, sourceScriptInfo>(),\n }\n this.loadSourceCode()\n if (this.useSandbox) {\n this.sandBox = new SandBox(name, url, this.macro)\n }\n }\n\n // Load resources\n loadSourceCode (): void {\n this.status = appStatus.LOADING_SOURCE_CODE\n extractHtml(this)\n }\n\n /**\n * When resource is loaded, mount app if it is not prefetch or unmount\n */\n onLoad (html: HTMLElement): void {\n if (++this.loadSourceLevel === 2) {\n this.source.html = html\n\n if (this.isPrefetch || appStatus.UNMOUNT === this.status) return\n\n this.status = appStatus.LOAD_SOURCE_FINISHED\n\n this.mount()\n }\n }\n\n /**\n * Error loading HTML\n * @param e Error\n */\n onLoadError (e: Error): void {\n this.loadSourceLevel = -1\n if (appStatus.UNMOUNT !== this.status) {\n this.onerror(e)\n this.status = appStatus.LOAD_SOURCE_ERROR\n }\n }\n\n /**\n * mount app\n * @param container app container\n * @param inline js runs in inline mode\n * @param baseroute route prefix, default is ''\n */\n mount (\n container?: HTMLElement | ShadowRoot,\n inline?: boolean,\n baseroute?: string,\n ): void {\n if (isBoolean(inline) && inline !== this.inline) {\n this.inline = inline\n }\n\n this.container = this.container ?? container!\n this.baseroute = baseroute ?? this.baseroute\n\n if (this.loadSourceLevel !== 2) {\n this.status = appStatus.LOADING_SOURCE_CODE\n return\n }\n\n dispatchLifecyclesEvent(\n this.container as HTMLElement,\n this.name,\n lifeCycles.BEFOREMOUNT,\n )\n\n this.status = appStatus.MOUNTING\n\n cloneNode(this.source.html as Element, this.container as Element, !this.umdMode)\n\n this.sandBox?.start(this.baseroute)\n\n let umdHookMountResult: any // result of mount function\n\n if (!this.umdMode) {\n let hasDispatchMountedEvent = false\n // if all js are executed, param isFinished will be true\n execScripts(this.source.scripts, this, (isFinished: boolean) => {\n if (!this.umdMode) {\n const { mount, unmount } = this.getUmdLibraryHooks()\n // if mount & unmount is function, the sub app is umd mode\n if (isFunction(mount) && isFunction(unmount)) {\n this.umdHookMount = mount as Func\n this.umdHookUnmount = unmount as Func\n this.umdMode = true\n this.sandBox?.recordUmdSnapshot()\n try {\n umdHookMountResult = this.umdHookMount()\n } catch (e) {\n logError('an error occurred in the mount function \\n', this.name, e)\n }\n }\n }\n\n if (!hasDispatchMountedEvent && (isFinished === true || this.umdMode)) {\n hasDispatchMountedEvent = true\n this.handleMounted(umdHookMountResult)\n }\n })\n } else {\n this.sandBox?.rebuildUmdSnapshot()\n try {\n umdHookMountResult = this.umdHookMount!()\n } catch (e) {\n logError('an error occurred in the mount function \\n', this.name, e)\n }\n this.handleMounted(umdHookMountResult)\n }\n }\n\n /**\n * handle for promise umdHookMount\n * @param umdHookMountResult result of umdHookMount\n */\n private handleMounted (umdHookMountResult: any): void {\n if (isPromise(umdHookMountResult)) {\n umdHookMountResult\n .then(() => this.dispatchMountedEvent())\n .catch((e: Error) => this.onerror(e))\n } else {\n this.dispatchMountedEvent()\n }\n }\n\n /**\n * dispatch mounted event when app run finished\n */\n private dispatchMountedEvent (): void {\n if (appStatus.UNMOUNT !== this.status) {\n this.status = appStatus.MOUNTED\n // remove defer in v0.4.2\n // defer(() => {\n // if (appStatus.UNMOUNT !== this.status) {\n dispatchLifecyclesEvent(\n this.container as HTMLElement,\n this.name,\n lifeCycles.MOUNTED,\n )\n // }\n // })\n }\n }\n\n /**\n * unmount app\n * @param destroy completely destroy, delete cache resources\n */\n unmount (destroy: boolean): void {\n if (this.status === appStatus.LOAD_SOURCE_ERROR) {\n destroy = true\n }\n\n this.status = appStatus.UNMOUNT\n\n // result of unmount function\n let umdHookUnmountResult: any\n /**\n * send an unmount event to the micro app or call umd unmount hook\n * before the sandbox is cleared\n */\n if (this.umdHookUnmount) {\n try {\n umdHookUnmountResult = this.umdHookUnmount()\n } catch (e) {\n logError('an error occurred in the unmount function \\n', this.name, e)\n }\n }\n\n // dispatch unmount event to micro app\n dispatchUnmountToMicroApp(this.name)\n\n this.handleUnmounted(destroy, umdHookUnmountResult)\n }\n\n /**\n * handle for promise umdHookUnmount\n * @param umdHookUnmountResult result of umdHookUnmount\n */\n private handleUnmounted (destroy: boolean, umdHookUnmountResult: any): void {\n if (isPromise(umdHookUnmountResult)) {\n umdHookUnmountResult\n .then(() => this.actionsForUnmount(destroy))\n .catch(() => this.actionsForUnmount(destroy))\n } else {\n this.actionsForUnmount(destroy)\n }\n }\n\n /**\n * actions for unmount app\n * @param destroy completely destroy, delete cache resources\n */\n private actionsForUnmount (destroy: boolean): void {\n // dispatch unmount event to base app\n dispatchLifecyclesEvent(\n this.container as HTMLElement,\n this.name,\n lifeCycles.UNMOUNT,\n )\n\n this.sandBox?.stop()\n\n // actions for completely destroy\n if (destroy) {\n if (!this.useSandbox && this.umdMode) {\n delete window[this.libraryName as any]\n }\n appInstanceMap.delete(this.name)\n } else if (this.umdMode && (this.container as Element).childElementCount) {\n /**\n * In umd mode, ui frameworks will no longer create style elements to head in lazy load page when render again, so we should save container to keep these elements\n */\n cloneNode(this.container as Element, this.source.html as Element, false)\n }\n\n this.container = null\n }\n\n /**\n * app rendering error\n * @param e Error\n */\n onerror (e: Error): void {\n dispatchLifecyclesEvent(\n this.container as HTMLElement,\n this.name,\n lifeCycles.ERROR,\n e,\n )\n }\n\n // get app status\n getAppStatus (): string {\n return this.status\n }\n\n // get umd library, if it not exist, return empty object\n private getUmdLibraryHooks (): Record<string, unknown> {\n // after execScripts, the app maybe unmounted\n if (appStatus.UNMOUNT !== this.status) {\n const global = (this.sandBox?.proxyWindow ?? globalEnv.rawWindow) as any\n this.libraryName = (isShadowRoot(this.container) ? (this.container as ShadowRoot).host : this.container as Element).getAttribute('library') || `micro-app-${this.name}`\n // do not use isObject\n return typeof global[this.libraryName] === 'object' ? global[this.libraryName] : {}\n }\n\n return {}\n }\n}\n","import type { Func, AppInterface } from '@micro-app/types'\nimport { appInstanceMap } from '../create_app'\nimport {\n CompletionPath,\n getCurrentAppName,\n pureCreateElement,\n setCurrentAppName,\n logWarn,\n isPlainObject,\n isString,\n isInvalidQuerySelectorKey,\n isUniqueElement,\n} from '../libs/utils'\nimport scopedCSS from './scoped_css'\nimport { extractLinkFromHtml, foramtDynamicLink } from './links'\nimport { extractScriptElement, runScript, runDynamicRemoteScript } from './scripts'\nimport microApp from '../micro_app'\nimport globalEnv from '../libs/global_env'\n\n// Record element and map element\nconst dynamicElementInMicroAppMap = new WeakMap<Node, Element | Comment>()\n\n/**\n * Process the new node and format the style, link and script element\n * @param parent parent node\n * @param child new node\n * @param app app\n */\nfunction handleNewNode (parent: Node, child: Node, app: AppInterface): Node {\n if (child instanceof HTMLStyleElement) {\n if (child.hasAttribute('exclude')) {\n const replaceComment = document.createComment('style element with exclude attribute ignored by micro-app')\n dynamicElementInMicroAppMap.set(child, replaceComment)\n return replaceComment\n } else if (app.scopecss && !child.hasAttribute('ignore')) {\n return scopedCSS(child, app.name)\n }\n return child\n } else if (child instanceof HTMLLinkElement) {\n if (child.hasAttribute('exclude')) {\n const linkReplaceComment = document.createComment('link element with exclude attribute ignored by micro-app')\n dynamicElementInMicroAppMap.set(child, linkReplaceComment)\n return linkReplaceComment\n } else if (!app.scopecss || child.hasAttribute('ignore')) {\n return child\n }\n\n const { url, info, replaceComment } = extractLinkFromHtml(\n child,\n parent,\n app,\n null,\n true,\n )\n\n if (url && info) {\n const replaceStyle = pureCreateElement('style')\n replaceStyle.linkpath = url\n foramtDynamicLink(url, info, app, child, replaceStyle)\n dynamicElementInMicroAppMap.set(child, replaceStyle)\n return replaceStyle\n } else if (replaceComment) {\n dynamicElementInMicroAppMap.set(child, replaceComment)\n return replaceComment\n }\n\n return child\n } else if (child instanceof HTMLScriptElement) {\n const { replaceComment, url, info } = extractScriptElement(\n child,\n parent,\n app,\n true,\n ) || {}\n\n if (url && info) {\n if (info.code) { // inline script\n const replaceElement = runScript(url, info.code, app, info.module, true)\n dynamicElementInMicroAppMap.set(child, replaceElement)\n return replaceElement\n } else { // remote script\n const replaceElement = runDynamicRemoteScript(url, info, app, child)\n dynamicElementInMicroAppMap.set(child, replaceElement)\n return replaceElement\n }\n } else if (replaceComment) {\n dynamicElementInMicroAppMap.set(child, replaceComment)\n return replaceComment\n }\n\n return child\n }\n\n return child\n}\n\n/**\n * Handle the elements inserted into head and body, and execute normally in other cases\n * @param app app\n * @param method raw method\n * @param parent parent node\n * @param targetChild target node\n * @param passiveChild second param of insertBefore and replaceChild\n */\nfunction invokePrototypeMethod (\n app: AppInterface,\n rawMethod: Func,\n parent: Node,\n targetChild: Node,\n passiveChild?: Node | null,\n): any {\n /**\n * If passiveChild is not the child node, insertBefore replaceChild will have a problem, at this time, it will be degraded to appendChild\n * E.g: document.head.insertBefore(targetChild, document.head.childNodes[0])\n */\n if (parent === document.head) {\n const microAppHead = app.container!.querySelector('micro-app-head')!\n /**\n * 1. If passivechild exists, it must be insertBefore or replacechild\n * 2. When removeChild, targetChild may not be in microAppHead or head\n */\n if (passiveChild && !microAppHead.contains(passiveChild)) {\n return globalEnv.rawAppendChild.call(microAppHead, targetChild)\n } else if (rawMethod === globalEnv.rawRemoveChild && !microAppHead.contains(targetChild)) {\n if (parent.contains(targetChild)) {\n return rawMethod.call(parent, targetChild)\n }\n return targetChild\n } else if (rawMethod === globalEnv.rawAppend || rawMethod === globalEnv.rawPrepend) {\n return rawMethod.call(microAppHead, targetChild)\n }\n return rawMethod.call(microAppHead, targetChild, passiveChild)\n } else if (parent === document.body) {\n const microAppBody = app.container!.querySelector('micro-app-body')!\n if (passiveChild && !microAppBody.contains(passiveChild)) {\n return globalEnv.rawAppendChild.call(microAppBody, targetChild)\n } else if (rawMethod === globalEnv.rawRemoveChild && !microAppBody.contains(targetChild)) {\n if (parent.contains(targetChild)) {\n return rawMethod.call(parent, targetChild)\n }\n return targetChild\n } else if (rawMethod === globalEnv.rawAppend || rawMethod === globalEnv.rawPrepend) {\n return rawMethod.call(microAppBody, targetChild)\n }\n return rawMethod.call(microAppBody, targetChild, passiveChild)\n } else if (rawMethod === globalEnv.rawAppend || rawMethod === globalEnv.rawPrepend) {\n return rawMethod.call(parent, targetChild)\n }\n\n return rawMethod.call(parent, targetChild, passiveChild)\n}\n\n// Get the map element\nfunction getMappingNode (node: Node): Node {\n return dynamicElementInMicroAppMap.get(node) ?? node\n}\n\n/**\n * method of handle new node\n * @param parent parent node\n * @param newChild new node\n * @param passiveChild passive node\n * @param rawMethodraw method\n */\nfunction commonElementHander (\n parent: Node,\n newChild: Node,\n passiveChild: Node | null,\n rawMethod: Func,\n) {\n if (newChild?.__MICRO_APP_NAME__) {\n const app = appInstanceMap.get(newChild.__MICRO_APP_NAME__)\n if (app?.container) {\n return invokePrototypeMethod(\n app,\n rawMethod,\n parent,\n handleNewNode(parent, newChild, app),\n passiveChild && getMappingNode(passiveChild),\n )\n } else if (rawMethod === globalEnv.rawAppend || rawMethod === globalEnv.rawPrepend) {\n return rawMethod.call(parent, newChild)\n }\n return rawMethod.call(parent, newChild, passiveChild)\n } else if (rawMethod === globalEnv.rawAppend || rawMethod === globalEnv.rawPrepend) {\n const appName = getCurrentAppName()\n if (!(newChild instanceof Node) && appName) {\n const app = appInstanceMap.get(appName)\n if (app?.container) {\n if (parent === document.head) {\n return rawMethod.call(app.container.querySelector('micro-app-head'), newChild)\n } else if (parent === document.body) {\n return rawMethod.call(app.container.querySelector('micro-app-body'), newChild)\n }\n }\n }\n return rawMethod.call(parent, newChild)\n }\n\n return rawMethod.call(parent, newChild, passiveChild)\n}\n\n/**\n * Rewrite element prototype method\n */\nexport function patchElementPrototypeMethods (): void {\n patchDocument()\n\n // Rewrite setAttribute\n Element.prototype.setAttribute = function setAttribute (key: string, value: string): void {\n if (/^micro-app(-\\S+)?/i.test(this.tagName) && key === 'data') {\n if (isPlainObject(value)) {\n const cloneValue: Record<PropertyKey, unknown> = {}\n Object.getOwnPropertyNames(value).forEach((propertyKey: PropertyKey) => {\n if (!(isString(propertyKey) && propertyKey.indexOf('__') === 0)) {\n // @ts-ignore\n cloneValue[propertyKey] = value[propertyKey]\n }\n })\n this.data = cloneValue\n } else if (value !== '[object Object]') {\n logWarn('property data must be an object', this.getAttribute('name'))\n }\n } else if (\n (\n (key === 'src' && /^(img|script)$/i.test(this.tagName)) ||\n (key === 'href' && /^link$/i.test(this.tagName))\n ) &&\n this.__MICRO_APP_NAME__ &&\n appInstanceMap.has(this.__MICRO_APP_NAME__)\n ) {\n const app = appInstanceMap.get(this.__MICRO_APP_NAME__)\n globalEnv.rawSetAttribute.call(this, key, CompletionPath(value, app!.url))\n } else {\n globalEnv.rawSetAttribute.call(this, key, value)\n }\n }\n\n // prototype methods of add element👇\n Node.prototype.appendChild = function appendChild<T extends Node> (newChild: T): T {\n return commonElementHander(this, newChild, null, globalEnv.rawAppendChild)\n }\n\n Node.prototype.insertBefore = function insertBefore<T extends Node> (newChild: T, refChild: Node | null): T {\n return commonElementHander(this, newChild, refChild, globalEnv.rawInsertBefore)\n }\n\n Node.prototype.replaceChild = function replaceChild<T extends Node> (newChild: Node, oldChild: T): T {\n return commonElementHander(this, newChild, oldChild, globalEnv.rawReplaceChild)\n }\n\n Element.prototype.append = function append (...nodes: (Node | string)[]): void {\n let i = 0\n const length = nodes.length\n while (i < length) {\n commonElementHander(this, nodes[i] as Node, null, globalEnv.rawAppend)\n i++\n }\n }\n\n Element.prototype.prepend = function prepend (...nodes: (Node | string)[]): void {\n let i = nodes.length\n while (i > 0) {\n commonElementHander(this, nodes[i - 1] as Node, null, globalEnv.rawPrepend)\n i--\n }\n }\n\n // prototype methods of delete element👇\n Node.prototype.removeChild = function removeChild<T extends Node> (oldChild: T): T {\n if (oldChild?.__MICRO_APP_NAME__) {\n const app = appInstanceMap.get(oldChild.__MICRO_APP_NAME__)\n if (app?.container) {\n return invokePrototypeMethod(\n app,\n globalEnv.rawRemoveChild,\n this,\n getMappingNode(oldChild),\n )\n }\n return globalEnv.rawRemoveChild.call(this, oldChild) as T\n }\n\n return globalEnv.rawRemoveChild.call(this, oldChild) as T\n }\n}\n\n/**\n * Mark the newly created element in the micro application\n * @param element new element\n */\nfunction markElement <T extends { __MICRO_APP_NAME__: string }> (element: T): T {\n const appName = getCurrentAppName()\n appName && (element.__MICRO_APP_NAME__ = appName)\n return element\n}\n\n// methods of document\nfunction patchDocument () {\n const rawDocument = globalEnv.rawDocument\n\n // create element 👇\n Document.prototype.createElement = function createElement (\n tagName: string,\n options?: ElementCreationOptions,\n ): HTMLElement {\n const element = globalEnv.rawCreateElement.call(this, tagName, options)\n return markElement(element)\n }\n\n Document.prototype.createElementNS = function createElementNS (\n namespaceURI: string,\n name: string,\n options?: string | ElementCreationOptions,\n ): any {\n const element = globalEnv.rawCreateElementNS.call(this, namespaceURI, name, options)\n return markElement(element)\n }\n\n Document.prototype.createDocumentFragment = function createDocumentFragment (): DocumentFragment {\n const element = globalEnv.rawCreateDocumentFragment.call(this)\n return markElement(element)\n }\n\n // query element👇\n function querySelector (this: Document, selectors: string): any {\n const appName = getCurrentAppName()\n if (\n !appName ||\n !selectors ||\n isUniqueElement(selectors) ||\n // see https://github.com/micro-zoe/micro-app/issues/56\n rawDocument !== this\n ) {\n return globalEnv.rawQuerySelector.call(this, selectors)\n }\n return appInstanceMap.get(appName)?.container?.querySelector(selectors) ?? null\n }\n\n function querySelectorAll (this: Document, selectors: string): any {\n const appName = getCurrentAppName()\n if (\n !appName ||\n !selectors ||\n isUniqueElement(selectors) ||\n rawDocument !== this\n ) {\n return globalEnv.rawQuerySelectorAll.call(this, selectors)\n }\n return appInstanceMap.get(appName)?.container?.querySelectorAll(selectors) ?? []\n }\n\n Document.prototype.querySelector = querySelector\n Document.prototype.querySelectorAll = querySelectorAll\n\n Document.prototype.getElementById = function getElementById (key: string): HTMLElement | null {\n if (!getCurrentAppName() || isInvalidQuerySelectorKey(key)) {\n return globalEnv.rawGetElementById.call(this, key)\n }\n\n try {\n return querySelector.call(this, `#${key}`)\n } catch {\n return globalEnv.rawGetElementById.call(this, key)\n }\n }\n\n Document.prototype.getElementsByClassName = function getElementsByClassName (key: string): HTMLCollectionOf<Element> {\n if (!getCurrentAppName() || isInvalidQuerySelectorKey(key)) {\n return globalEnv.rawGetElementsByClassName.call(this, key)\n }\n\n try {\n return querySelectorAll.call(this, `.${key}`)\n } catch {\n return globalEnv.rawGetElementsByClassName.call(this, key)\n }\n }\n\n Document.prototype.getElementsByTagName = function getElementsByTagName (key: string): HTMLCollectionOf<Element> {\n const appName = getCurrentAppName()\n if (\n !appName ||\n isUniqueElement(key) ||\n isInvalidQuerySelectorKey(key) ||\n (!appInstanceMap.get(appName)?.inline && /^script$/i.test(key))\n ) {\n return globalEnv.rawGetElementsByTagName.call(this, key)\n }\n\n try {\n return querySelectorAll.call(this, key)\n } catch {\n return globalEnv.rawGetElementsByTagName.call(this, key)\n }\n }\n\n Document.prototype.getElementsByName = function getElementsByName (key: string): NodeListOf<HTMLElement> {\n if (!getCurrentAppName() || isInvalidQuerySelectorKey(key)) {\n return globalEnv.rawGetElementsByName.call(this, key)\n }\n\n try {\n return querySelectorAll.call(this, `[name=${key}]`)\n } catch {\n return globalEnv.rawGetElementsByName.call(this, key)\n }\n }\n}\n\nfunction releasePatchDocument (): void {\n Document.prototype.createElement = globalEnv.rawCreateElement\n Document.prototype.createElementNS = globalEnv.rawCreateElementNS\n Document.prototype.createDocumentFragment = globalEnv.rawCreateDocumentFragment\n Document.prototype.querySelector = globalEnv.rawQuerySelector\n Document.prototype.querySelectorAll = globalEnv.rawQuerySelectorAll\n Document.prototype.getElementById = globalEnv.rawGetElementById\n Document.prototype.getElementsByClassName = globalEnv.rawGetElementsByClassName\n Document.prototype.getElementsByTagName = globalEnv.rawGetElementsByTagName\n Document.prototype.getElementsByName = globalEnv.rawGetElementsByName\n}\n\n// release patch\nexport function releasePatches (): void {\n setCurrentAppName(null)\n releasePatchDocument()\n Element.prototype.setAttribute = globalEnv.rawSetAttribute\n Node.prototype.appendChild = globalEnv.rawAppendChild\n Node.prototype.insertBefore = globalEnv.rawInsertBefore\n Node.prototype.replaceChild = globalEnv.rawReplaceChild\n Node.prototype.removeChild = globalEnv.rawRemoveChild\n Element.prototype.append = globalEnv.rawAppend\n Element.prototype.prepend = globalEnv.rawPrepend\n}\n\n// Set the style of micro-app-head and micro-app-body\nlet hasRejectMicroAppStyle = false\nexport function rejectMicroAppStyle (): void {\n if (!hasRejectMicroAppStyle) {\n hasRejectMicroAppStyle = true\n const style = pureCreateElement('style')\n style.setAttribute('type', 'text/css')\n style.textContent = `\\n${microApp.tagName}, micro-app-body { display: block; } \\nmicro-app-head { display: none; }`\n globalEnv.rawDocument.head.appendChild(style)\n }\n}\n","import { appInstanceMap } from '../create_app'\nimport { elementInstanceMap } from '../micro_app_element'\nimport { releasePatches } from '../source/patch'\nimport { isShadowRoot } from '../libs/utils'\n\nfunction unmountNestedApp (): void {\n replaseUnmountOfNestedApp()\n\n appInstanceMap.forEach(app => {\n let element = app.container\n if (element) {\n if (isShadowRoot(element)) {\n element = (element as ShadowRoot).host as HTMLElement\n }\n // @ts-ignore\n element.disconnectedCallback()\n }\n })\n\n if (!window.__MICRO_APP_UMD_MODE__) appInstanceMap.clear()\n\n if (elementInstanceMap.size) {\n elementInstanceMap.clear()\n releasePatches()\n }\n}\n\n// if micro-app run in micro application, delete all next generation application when unmount event received\nexport function listenUmountOfNestedApp (): void {\n if (window.__MICRO_APP_ENVIRONMENT__) {\n window.addEventListener('unmount', unmountNestedApp, false)\n }\n}\n\n// release listener\nexport function replaseUnmountOfNestedApp (): void {\n if (window.__MICRO_APP_ENVIRONMENT__) {\n window.removeEventListener('unmount', unmountNestedApp, false)\n }\n}\n","import type { AttrType, MicroAppElementType, AppInterface } from '@micro-app/types'\nimport { defer, formatURL, version, logError, isString, isFunction } from './libs/utils'\nimport { ObservedAttrName, appStatus, lifeCycles } from './constants'\nimport CreateApp, { appInstanceMap } from './create_app'\nimport {\n patchElementPrototypeMethods,\n releasePatches,\n rejectMicroAppStyle,\n} from './source/patch'\nimport {\n listenUmountOfNestedApp,\n replaseUnmountOfNestedApp,\n} from './libs/additional'\nimport microApp from './micro_app'\nimport dispatchLifecyclesEvent from './interact/lifecycles_event'\n\n// record all micro-app elements\nexport const elementInstanceMap = new Map<Element, boolean>()\n\n/**\n * define element\n * @param tagName element name\n */\nexport function defineElement (tagName: string): void {\n class MicroAppElement extends HTMLElement implements MicroAppElementType {\n static get observedAttributes (): string[] {\n return ['name', 'url']\n }\n\n constructor () {\n super()\n // cloned node of umd container also trigger constructor, we should skip\n if (!this.querySelector('micro-app-head')) {\n this.performWhenFirstCreated()\n }\n }\n\n private isWating = false\n private cacheData: Record<PropertyKey, unknown> | null = null\n private hasConnected = false\n appName = ''\n appUrl = ''\n version = version\n\n // 👇 Configuration\n // name: app name\n // url: html address\n // shadowDom: use shadowDOM, default is false\n // destroy: whether delete cache resources when unmount, default is false\n // inline: whether js runs in inline script mode, default is false\n // disableScopecss: whether disable css scoped, default is false\n // disableSandbox: whether disable sandbox, default is false\n // macro: used to solve the async render problem of vue3, default is false\n // baseRoute: route prefix, default is ''\n\n connectedCallback (): void {\n this.hasConnected = true\n if (!elementInstanceMap.has(this)) {\n this.performWhenFirstCreated()\n }\n\n defer(() => dispatchLifecyclesEvent(\n this,\n this.appName,\n lifeCycles.CREATED,\n ))\n\n this.initialMount()\n }\n\n disconnectedCallback (): void {\n this.hasConnected = false\n elementInstanceMap.delete(this)\n this.handleUnmount(this.getDisposeResult('destroy') || this.getDisposeResult('destory'))\n if (elementInstanceMap.size === 0) {\n releasePatches()\n }\n }\n\n attributeChangedCallback (attr: ObservedAttrName, _oldVal: string, newVal: string): void {\n if (\n this.legalAttribute(attr, newVal) &&\n this[attr === ObservedAttrName.NAME ? 'appName' : 'appUrl'] !== newVal\n ) {\n if (attr === ObservedAttrName.URL && !this.appUrl) {\n newVal = formatURL(newVal, this.appName)\n if (!newVal) {\n return logError('Invalid attribute url', this.appName)\n }\n this.appUrl = newVal\n this.handleInitialNameAndUrl()\n } else if (attr === ObservedAttrName.NAME && !this.appName) {\n if (this.cacheData) {\n microApp.setData(newVal, this.cacheData)\n this.cacheData = null\n }\n this.appName = newVal\n this.handleInitialNameAndUrl()\n } else if (!this.isWating) {\n this.isWating = true\n defer(this.handleAttributeUpdate)\n }\n }\n }\n\n // handle for connectedCallback run before attributeChangedCallback\n private handleInitialNameAndUrl (): void {\n if (this.hasConnected) {\n this.initialMount()\n }\n }\n\n // Perform global initialization when the element count is 1\n private performWhenFirstCreated (): void {\n if (elementInstanceMap.set(this, true).size === 1) {\n patchElementPrototypeMethods()\n rejectMicroAppStyle()\n replaseUnmountOfNestedApp()\n listenUmountOfNestedApp()\n }\n }\n\n /**\n * first mount of this app\n */\n private initialMount (): void {\n if (!this.appName || !this.appUrl) return\n\n if (this.getDisposeResult('shadowDOM') && !this.shadowRoot && isFunction(this.attachShadow)) {\n this.attachShadow({ mode: 'open' })\n }\n\n const app = appInstanceMap.get(this.appName)\n if (app) {\n if (\n app.url === this.appUrl && (\n app.isPrefetch ||\n app.getAppStatus() === appStatus.UNMOUNT\n )\n ) {\n this.handleAppMount(app)\n } else if (app.isPrefetch) {\n logError(`the url ${this.appUrl} is different from prefetch url ${app.url}`, this.appName)\n } else if (app.getAppStatus() === appStatus.UNMOUNT) {\n /**\n * add this logic for SSR\n * if old app has unmounted and url is different, create new app to replace old one\n */\n this.handleCreateApp()\n } else {\n logError(`an app named ${this.appName} already exists`, this.appName)\n }\n } else {\n this.handleCreateApp()\n }\n }\n\n /**\n * handle for change of name an url after element inited\n */\n private handleAttributeUpdate = (): void => {\n this.isWating = false\n const attrName = this.getAttribute('name')\n const attrUrl = formatURL(this.getAttribute('url'), this.appName)\n if (this.legalAttribute('name', attrName) && this.legalAttribute('url', attrUrl)) {\n const existApp = appInstanceMap.get(attrName!)\n if (attrName !== this.appName && existApp) {\n // handling of cached and non-prefetch apps\n if (appStatus.UNMOUNT !== existApp.getAppStatus() && !existApp.isPrefetch) {\n this.setAttribute('name', this.appName)\n return logError(`an app named ${attrName} already exists`, this.appName)\n }\n }\n\n if (attrName !== this.appName || attrUrl !== this.appUrl) {\n this.handleUnmount(attrName === this.appName)\n this.appName = attrName as string\n this.appUrl = attrUrl\n ;(this.shadowRoot ?? this).innerHTML = ''\n /**\n * when existApp not undefined\n * if attrName and this.appName are equal, existApp has been unmounted\n * if attrName and this.appName are not equal, existApp is prefetch or unmounted\n */\n if (existApp && existApp.url === attrUrl) {\n // mount app\n this.handleAppMount(existApp)\n } else {\n this.handleCreateApp()\n }\n }\n } else if (attrName !== this.appName) {\n this.setAttribute('name', this.appName)\n }\n }\n\n /**\n * judge the attribute is legal\n * @param name attribute name\n * @param val attribute value\n */\n private legalAttribute (name: string, val: AttrType): boolean {\n if (!isString(val) || !val) {\n logError(`unexpected attribute ${name}, please check again`, this.appName)\n\n return false\n }\n\n return true\n }\n\n /**\n * mount app\n * some serious note before mount:\n * 1. is prefetch ?\n * 2. is remount in another container ?\n * 3. is remount with change properties of the container ?\n */\n private handleAppMount (app: AppInterface): void {\n app.isPrefetch = false\n defer(() => app.mount(\n this.shadowRoot ?? this,\n this.getDisposeResult('inline'),\n this.getBaseRouteCompatible(),\n ))\n }\n\n // create app instance\n private handleCreateApp (): void {\n const instance: AppInterface = new CreateApp({\n name: this.appName!,\n url: this.appUrl!,\n container: this.shadowRoot ?? this,\n inline: this.getDisposeResult('inline'),\n scopecss: !(this.getDisposeResult('disableScopecss') || this.getDisposeResult('shadowDOM')),\n useSandbox: !this.getDisposeResult('disableSandbox'),\n macro: this.getDisposeResult('macro'),\n baseroute: this.getBaseRouteCompatible(),\n })\n\n appInstanceMap.set(this.appName!, instance)\n }\n\n /**\n * unmount app\n * @param destroy delete cache resources when unmount\n */\n private handleUnmount (destroy: boolean): void {\n const app = appInstanceMap.get(this.appName!)\n if (app && appStatus.UNMOUNT !== app.getAppStatus()) app.unmount(destroy)\n }\n\n /**\n * Get configuration\n * Global setting is lowest priority\n * @param name Configuration item name\n */\n private getDisposeResult (name: string): boolean {\n // @ts-ignore\n return (this.hasAttribute(name) || microApp[name]) && this.getAttribute(name) !== 'false'\n }\n\n /**\n * 2021-09-08\n * get baseRoute\n * getAttribute('baseurl') is compatible writing of versions below 0.3.1\n */\n private getBaseRouteCompatible (): string {\n return this.getAttribute('baseroute') ?? this.getAttribute('baseurl') ?? ''\n }\n\n /**\n * Data from the base application\n */\n set data (value: Record<PropertyKey, unknown> | null) {\n if (this.appName) {\n microApp.setData(this.appName, value!)\n } else {\n this.cacheData = value\n }\n }\n\n /**\n * get data only used in jsx-custom-event once\n */\n get data (): Record<PropertyKey, unknown> | null {\n if (this.appName) {\n return microApp.getData(this.appName, true)\n } else if (this.cacheData) {\n return this.cacheData\n }\n return null\n }\n }\n\n window.customElements.define(tagName, MicroAppElement)\n}\n","import type { prefetchParamList, prefetchParam, globalAssetsType } from '@micro-app/types'\nimport CreateApp, { appInstanceMap } from './create_app'\nimport { requestIdleCallback, formatURL, promiseStream, logError, isBrowser, isArray, isPlainObject, isString, isFunction } from './libs/utils'\nimport { fetchSource } from './source/fetch'\nimport { globalLinks } from './source/links'\nimport { globalScripts } from './source/scripts'\nimport microApp from './micro_app'\n\nfunction filterPreFetchTarget<T extends prefetchParam> (apps: T[]): T[] {\n const validApps: T[] = []\n\n if (isArray(apps)) {\n apps.forEach((item) => {\n item.url = formatURL(item.url, item.name)\n if (\n isPlainObject(item) &&\n isString(item.name) &&\n item.url &&\n !appInstanceMap.has(item.name)\n ) {\n validApps.push(item)\n }\n })\n }\n\n return validApps\n}\n\n/**\n * preFetch([\n * {\n * name: string,\n * url: string,\n * disableScopecss?: boolean,\n * disableSandbox?: boolean,\n * macro?: boolean,\n * },\n * ...\n * ])\n * Note:\n * 1: preFetch is asynchronous and is performed only when the browser is idle\n * 2: disableScopecss, disableSandbox, macro must be same with micro-app element, if conflict, the one who executes first shall prevail\n * @param apps micro apps\n */\nexport default function preFetch (apps: prefetchParamList): void {\n if (!isBrowser) {\n return logError('preFetch is only supported in browser environment')\n }\n requestIdleCallback(() => {\n if (isFunction(apps)) apps = (apps as Function)()\n\n filterPreFetchTarget(apps as prefetchParam[]).forEach((item) => {\n const app = new CreateApp({\n name: item.name,\n url: item.url,\n scopecss: !(item.disableScopecss ?? microApp.disableScopecss),\n useSandbox: !(item.disableSandbox ?? microApp.disableSandbox),\n macro: item.macro ?? microApp.macro,\n })\n\n app.isPrefetch = true\n appInstanceMap.set(item.name, app)\n })\n })\n}\n\n/**\n * load global assets into cache\n * @param assets global assets of js, css\n */\nexport function getGlobalAssets (assets: globalAssetsType): void {\n if (isPlainObject(assets)) {\n requestIdleCallback(() => {\n if (isArray(assets.js)) {\n const effectiveJs = assets.js!.filter((path) => isString(path) && path.includes('.js') && !globalScripts.has(path))\n\n const fetchJSPromise: Array<Promise<string>> = []\n effectiveJs.forEach((path) => {\n fetchJSPromise.push(fetchSource(path))\n })\n\n // fetch js with stream\n promiseStream<string>(fetchJSPromise, (res: {data: string, index: number}) => {\n const path = effectiveJs[res.index]\n if (!globalScripts.has(path)) {\n globalScripts.set(path, res.data)\n }\n }, (err: {error: Error, index: number}) => {\n logError(err)\n })\n }\n\n if (isArray(assets.css)) {\n const effectiveCss = assets.css!.filter((path) => isString(path) && path.includes('.css') && !globalLinks.has(path))\n\n const fetchCssPromise: Array<Promise<string>> = []\n effectiveCss.forEach((path) => {\n fetchCssPromise.push(fetchSource(path))\n })\n\n // fetch css with stream\n promiseStream<string>(fetchCssPromise, (res: {data: string, index: number}) => {\n const path = effectiveCss[res.index]\n if (!globalLinks.has(path)) {\n globalLinks.set(path, res.data)\n }\n }, (err: {error: Error, index: number}) => {\n logError(err)\n })\n }\n })\n }\n}\n","import type { OptionsType, MicroAppConfigType, lifeCyclesType, plugins, fetchType } from '@micro-app/types'\nimport { defineElement } from './micro_app_element'\nimport preFetch, { getGlobalAssets } from './prefetch'\nimport { logError, logWarn, isFunction, isBrowser, isPlainObject } from './libs/utils'\nimport { EventCenterForBaseApp } from './interact'\nimport { initGlobalEnv } from './libs/global_env'\n\nclass MicroApp extends EventCenterForBaseApp implements MicroAppConfigType {\n tagName = 'micro-app'\n shadowDOM?: boolean\n destroy?: boolean\n inline?: boolean\n disableScopecss?: boolean\n disableSandbox?: boolean\n macro?: boolean\n lifeCycles?: lifeCyclesType\n plugins?: plugins\n fetch?: fetchType\n preFetch = preFetch\n start (options?: OptionsType) {\n if (!isBrowser || !window.customElements) {\n return logError('micro-app is not supported in this environment')\n }\n\n if (options?.tagName) {\n if (/^micro-app(-\\S+)?/.test(options.tagName)) {\n this.tagName = options.tagName\n } else {\n return logError(`${options.tagName} is invalid tagName`)\n }\n }\n\n if (window.customElements.get(this.tagName)) {\n return logWarn(`element ${this.tagName} is already defined`)\n }\n\n initGlobalEnv()\n\n if (options && isPlainObject(options)) {\n this.shadowDOM = options.shadowDOM\n this.destroy = options.destroy\n /**\n * compatible with versions below 0.4.2 of destroy\n * Do not merge with the previous line of code\n */\n // @ts-ignore\n this.destory = options.destory\n this.inline = options.inline\n this.disableScopecss = options.disableScopecss\n this.disableSandbox = options.disableSandbox\n this.macro = options.macro\n if (isFunction(options.fetch)) this.fetch = options.fetch\n\n if (isPlainObject(options.lifeCycles)) {\n this.lifeCycles = options.lifeCycles\n }\n\n if (isPlainObject(options.plugins)) {\n this.plugins = options.plugins\n }\n\n // load app assets when browser is idle\n if (options.preFetchApps) {\n preFetch(options.preFetchApps)\n }\n\n // load global assets when browser is idle\n if (options.globalAssets) {\n getGlobalAssets(options.globalAssets)\n }\n }\n\n defineElement(this.tagName)\n }\n}\n\nexport default new MicroApp()\n"],"names":["version","isBrowser","window","globalThis","global","self","Function","isString","target","isFunction","isArray","Array","isPlainObject","toString","call","isPromise","isBoundFunction","name","indexOf","hasOwnProperty","isShadowRoot","ShadowRoot","logError","msg","appName","rest","appNameTip","console","error","logWarn","warn","defer","fn","args","Promise","resolve","then","bind","addProtocol","url","startsWith","location","protocol","formatURL","origin","pathname","search","URL","test","fullPath","replace","e","getEffectivePath","pathArr","split","pop","join","CompletionPath","path","baseURI","promiseStream","promiseList","successCb","errorCb","finallyCb","finishedNum","isFinished","length","forEach","p","i","res","data","index","catch","err","requestIdleCallback","lastTime","Date","now","setTimeout","didTimeout","timeRemaining","Math","max","currentMicroAppName","setCurrentAppName","getCurrentAppName","removeDomScope","isSafari","navigator","userAgent","pureCreateElement","tagName","options","element","document","createElement","__MICRO_APP_NAME__","cloneNode","deep","innerHTML","clonedNode","fragment","createDocumentFragment","from","childNodes","node","appendChild","isInvalidQuerySelectorKey","key","isUniqueElement","ObservedAttrName","appStatus","lifeCycles","fetchSource","microApp","fetch","text","globalEnv","initGlobalEnv","rawSetAttribute","Element","prototype","setAttribute","rawAppendChild","Node","rawInsertBefore","insertBefore","rawReplaceChild","replaceChild","rawRemoveChild","removeChild","rawAppend","append","rawPrepend","prepend","rawCreateElement","Document","rawCreateElementNS","createElementNS","rawCreateDocumentFragment","rawQuerySelector","querySelector","rawQuerySelectorAll","querySelectorAll","rawGetElementById","getElementById","rawGetElementsByClassName","getElementsByClassName","rawGetElementsByTagName","getElementsByTagName","rawGetElementsByName","getElementsByName","rawWindow","rawDocument","supportModuleScript","templateStyle","body","rawWindowAddEventListener","addEventListener","rawWindowRemoveEventListener","removeEventListener","rawSetInterval","setInterval","rawSetTimeout","rawClearInterval","clearInterval","rawClearTimeout","clearTimeout","rawDocumentAddEventListener","rawDocumentRemoveEventListener","__MICRO_APP_BASE_APPLICATION__","Object","assign","CSSRuleType","scopedStyleRule","rule","prefix","selectorText","cssText","builtInRootSelectorRE","selectors","all","$1","$2","scopedHost","textContent","linkpath","purePath","getLinkFileDir","scopedPackRule","packName","result","scopedRule","cssRules","conditionText","rules","type","STYLE_RULE","MEDIA_RULE","SUPPORTS_RULE","commonAction","styleElement","originContent","sheet","scopedCSS","app","appInstanceMap","get","scopecss","disabled","observer","MutationObserver","disconnect","hasAttribute","observe","childList","eventHandler","event","defineProperties","currentTarget","srcElement","dispatchOnLoadEvent","CustomEvent","onload","dispatchEvent","dispatchOnErrorEvent","onerror","globalLinks","Map","extractLinkFromHtml","link","parent","microAppHead","isDynamic","rel","getAttribute","href","replaceComment","info","code","isGlobal","createComment","placeholderComment","source","links","set","placeholder","includes","fetchLinksFromHtml","wrapElement","linkEntries","entries","fetchLinkPromise","globalLinkCode","push","has","styleLink","fetchLinkSuccess","onLoad","globalScripts","extractScriptElement","script","src","noModule","isExternal","async","module","scripts","nonceStr","random","substr","fetchScriptsFromHtml","scriptEntries","fetchScriptPromise","fetchScriptPromiseInfo","globalScriptText","fetchScriptSuccess","runScript","callback","bindScope","inline","scriptElement","setInlinScriptContent","container","blob","Blob","createObjectURL","moduleCount","plugins","plugin","loader","modules","usePlugins","sandBox","__MICRO_APP_PROXY_WINDOW__","proxyWindow","flatChildren","children","child","dom","HTMLLinkElement","HTMLStyleElement","HTMLScriptElement","HTMLMetaElement","HTMLTitleElement","HTMLImageElement","extractSourceDom","htmlStr","str","wrapDiv","getWrapElement","microAppBody","Error","size","boundedMap","WeakMap","constructorMap","rawWindowMethodMap","bindFunctionToRawWidow","value","valueStr","constructor","getOwnPropertyNames","isConstructor","boundFunction","isBoundedFunction","bindRawWindowValue","documentClickListMap","hasRewriteDocumentOnClick","documentEventListenerMap","effectDocumentEvent","getOwnPropertyDescriptor","rawOnClick","onclick","hasDocumentClickInited","onClickHandler","f","defineProperty","configurable","enumerable","overwriteDocumentOnClick","listener","umdMode","appListenersMap","appListenerList","add","Set","__MICRO_MARK_OPTIONS__","delete","formatEventType","microWindow","eventCenter","this","isLegalName","on","autoTrigger","eventInfo","eventList","callbacks","off","clear","dispatch","getData","formatEventName","fromBaseApp","EventCenterForGlobal","addGlobalDataListener","cb","__APP_NAME__","__AUTO_TRIGGER__","removeGlobalDataListener","setGlobalData","getGlobalData","clearGlobalDataListener","EventCenterForBaseApp","addDataListener","removeDataListener","setData","clearDataListener","EventCenterForMicroApp","super","detail","host","staticEscapeProperties","escapeSetterKeyList","unscopables","undefined","String","Boolean","Number","Symbol","parseFloat","Float32Array","macroTimer","macroTask","SandBox","macro","descriptorTargetMap","getScopeProperties","inject","eventListenerMap","intervalIdMap","timeoutIdMap","listenerList","handler","timeout","intervalId","timeoutId","umdWindowListenerMap","umdDocumentListenerMap","umdOnClickHandler","umdIntervalIdMap","umdTimeoutIdMap","recordUmdEffect","documentAppListenersMap","rebuildUmdEffect","releaseEffect","_","effect","Proxy","Reflect","active","eval","scopeProperties","rawValue","injectedKeys","descriptor","writable","escapeProperties","escapeKeys","ownKeys","concat","filter","item","create","deleteProperty","start","baseroute","__MICRO_APP_BASE_ROUTE__","__MICRO_APP_BASE_URL__","_babelPolyfill","activeCount","stop","recordUmdSnapshot","__MICRO_APP_UMD_MODE__","microAppEventCneter","umdDataListeners","normal","globalEventInfo","subAppEventInfo","recordDataCenterSnapshot","recordUmdinjectedValues","rebuildUmdSnapshot","rebuildDataCenterSnapshot","__MICRO_APP_ENVIRONMENT__","__MICRO_APP_PUBLIC_PATH__","dispatchLifecyclesEvent","lifecycleName","CreateApp","useSandbox","NOT_LOADED","loadSourceCode","status","LOADING_SOURCE_CODE","cache","match","onLoadError","html","loadSourceLevel","isPrefetch","UNMOUNT","LOAD_SOURCE_FINISHED","mount","LOAD_SOURCE_ERROR","umdHookMountResult","BEFOREMOUNT","MOUNTING","umdHookMount","handleMounted","hasDispatchMountedEvent","scriptList","initedHook","scriptListEntries","deferScriptPromise","deferScriptInfo","execScripts","unmount","getUmdLibraryHooks","umdHookUnmount","dispatchMountedEvent","MOUNTED","destroy","umdHookUnmountResult","dispatchUnmountToMicroApp","handleUnmounted","actionsForUnmount","libraryName","childElementCount","ERROR","getAppStatus","dynamicElementInMicroAppMap","handleNewNode","linkReplaceComment","replaceStyle","originLink","foramtDynamicLink","replaceElement","originScript","dispatchScriptOnLoadEvent","existInfo","runDynamicRemoteScript","invokePrototypeMethod","rawMethod","targetChild","passiveChild","head","contains","getMappingNode","commonElementHander","newChild","patchElementPrototypeMethods","markElement","namespaceURI","patchDocument","cloneValue","propertyKey","refChild","oldChild","nodes","releasePatches","hasRejectMicroAppStyle","unmountNestedApp","replaseUnmountOfNestedApp","disconnectedCallback","elementInstanceMap","defineElement","MicroAppElement","HTMLElement","isWating","attrName","attrUrl","legalAttribute","existApp","appUrl","handleUnmount","shadowRoot","handleAppMount","handleCreateApp","performWhenFirstCreated","observedAttributes","connectedCallback","hasConnected","CREATED","initialMount","getDisposeResult","attributeChangedCallback","attr","_oldVal","newVal","NAME","handleAttributeUpdate","cacheData","handleInitialNameAndUrl","style","rejectMicroAppStyle","attachShadow","mode","val","getBaseRouteCompatible","instance","customElements","define","preFetch","apps","validApps","filterPreFetchTarget","disableScopecss","disableSandbox","assets","shadowDOM","destory","preFetchApps","globalAssets","js","effectiveJs","fetchJSPromise","css","effectiveCss","fetchCssPromise"],"mappings":"sPAGaA,EAAU,QAGVC,EAA8B,oBAAXC,OAGnBC,EAAgC,oBAAXC,OAC9BA,OAEmB,oBAAXF,OACJA,OAEiB,oBAATG,KAAwBA,KAAOC,SAAS,cAATA,YAe/BC,EAAUC,GACxB,MAAyB,iBAAXA,WASAC,EAAYD,GAC1B,MAAyB,mBAAXA,EAIT,MAAME,EAAUC,MAAMD,iBAGbE,EAAeJ,GAC7B,MAAiC,oBAA1BK,SAASC,KAAKN,YAIPO,EAAWP,GACzB,MAAiC,qBAA1BK,SAASC,KAAKN,YAIPQ,EAAiBR,GAC/B,OAAOC,EAAWD,IAA6C,IAAlCA,EAAOS,KAAKC,QAAQ,YAAoBV,EAAOW,eAAe,sBAI7EC,EAAcZ,GAC5B,MAA6B,oBAAfa,YAA8Bb,aAAkBa,oBAQhDC,EACdC,EACAC,EAAyB,QACtBC,GAEH,MAAMC,EAAaF,GAAWjB,EAASiB,GAAW,QAAQA,KAAa,GACnEjB,EAASgB,GACXI,QAAQC,MAAM,cAAcF,KAAcH,OAAUE,GAEpDE,QAAQC,MAAM,cAAcF,IAAcH,KAAQE,YAStCI,EACdN,EACAC,EAAyB,QACtBC,GAEH,MAAMC,EAAaF,GAAWjB,EAASiB,GAAW,QAAQA,KAAa,GACnEjB,EAASgB,GACXI,QAAQG,KAAK,cAAcJ,KAAcH,OAAUE,GAEnDE,QAAQG,KAAK,cAAcJ,IAAcH,KAAQE,YASrCM,EAAOC,KAAaC,GAClCC,QAAQC,UAAUC,KAAKJ,EAAGK,KAAK,QAASJ,aAO1BK,EAAaC,GAC3B,OAAOA,EAAIC,WAAW,MAAQ,GAAGC,SAASC,WAAWH,IAAQA,WAO/CI,EAAWJ,EAAoBf,EAAyB,MACtE,IAAKjB,EAASgC,KAASA,EAAK,MAAO,GAEnC,I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T,GAAShe,EAAQye,cAIfze,EAAQ0e,cDIZ5jB,EAD2BwjB,ECFTte,EAAQ0e,eDI5B5f,GAAoB,KAClB,GAAIlE,EAAQ0jB,EAAOK,IAAK,CACtB,MAAMC,EAAcN,EAAOK,GAAIvJ,QAAQxX,GAASnD,EAASmD,IAASA,EAAK+L,SAAS,SAAWY,EAAcJ,IAAIvM,KAEvGihB,EAAyC,GAC/CD,EAAYtgB,SAASV,IACnBihB,EAAe3U,KAAK7I,EAAYzD,OAIlCE,EAAsB+gB,GAAiBpgB,IACrC,MAAMb,EAAOghB,EAAYngB,EAAIE,OACxB4L,EAAcJ,IAAIvM,IACrB2M,EAAcd,IAAI7L,EAAMa,EAAIC,SAE5BG,IACFrD,EAASqD,MAIb,GAAIjE,EAAQ0jB,EAAOQ,KAAM,CACvB,MAAMC,EAAeT,EAAOQ,IAAK1J,QAAQxX,GAASnD,EAASmD,IAASA,EAAK+L,SAAS,UAAYpB,EAAY4B,IAAIvM,KAExGohB,EAA0C,GAChDD,EAAazgB,SAASV,IACpBohB,EAAgB9U,KAAK7I,EAAYzD,OAInCE,EAAsBkhB,GAAkBvgB,IACtC,MAAMb,EAAOmhB,EAAatgB,EAAIE,OACzB4J,EAAY4B,IAAIvM,IACnB2K,EAAYkB,IAAI7L,EAAMa,EAAIC,SAE1BG,IACFrD,EAASqD,WCnCf8c,GAAcvL,KAAKrQ"}
1
+ {"version":3,"file":"index.umd.js","sources":["../src/libs/utils.ts","../src/constants.ts","../src/source/fetch.ts","../src/libs/global_env.ts","../src/source/scoped_css.ts","../src/source/load_event.ts","../src/source/links.ts","../src/source/scripts.ts","../src/source/index.ts","../src/sandbox/bind_function.ts","../src/sandbox/effect.ts","../src/interact/index.ts","../src/interact/event_center.ts","../src/sandbox/index.ts","../src/interact/lifecycles_event.ts","../src/create_app.ts","../src/source/patch.ts","../src/libs/additional.ts","../src/micro_app_element.ts","../src/prefetch.ts","../src/micro_app.ts"],"sourcesContent":["/* eslint-disable no-new-func, indent, @typescript-eslint/explicit-module-boundary-types */\nimport type { Func } from '@micro-app/types'\n\nexport const version = '__VERSION__'\n\n// do not use isUndefined\nexport const isBrowser = typeof window !== 'undefined'\n\n// do not use isUndefined\nexport const globalThis = (typeof global !== 'undefined')\n ? global\n : (\n (typeof window !== 'undefined')\n ? window\n : (\n (typeof self !== 'undefined') ? self : Function('return this')()\n )\n )\n\n// is Undefined\nexport function isUndefined (target: unknown): target is undefined {\n return target === undefined\n}\n\n// is Null\nexport function isNull (target: unknown): target is null {\n return target === null\n}\n\n// is String\nexport function isString (target: unknown): target is string {\n return typeof target === 'string'\n}\n\n// is Boolean\nexport function isBoolean (target: unknown): target is boolean {\n return typeof target === 'boolean'\n}\n\n// is function\nexport function isFunction (target: unknown): boolean {\n return typeof target === 'function'\n}\n\n// is Array\nexport const isArray = Array.isArray\n\n// is PlainObject\nexport function isPlainObject (target: unknown): boolean {\n return toString.call(target) === '[object Object]'\n}\n\n// is Promise\nexport function isPromise (target: unknown): boolean {\n return toString.call(target) === '[object Promise]'\n}\n\n// is bind function\nexport function isBoundFunction (target: any): boolean {\n return isFunction(target) && target.name.indexOf('bound ') === 0 && !target.hasOwnProperty('prototype')\n}\n\n// is ShadowRoot\nexport function isShadowRoot (target: unknown): boolean {\n return typeof ShadowRoot !== 'undefined' && target instanceof ShadowRoot\n}\n\n/**\n * format error log\n * @param msg message\n * @param appName app name, default is null\n */\nexport function logError (\n msg: unknown,\n appName: string | null = null,\n ...rest: any[]\n): void {\n const appNameTip = appName && isString(appName) ? ` app ${appName}:` : ''\n if (isString(msg)) {\n console.error(`[micro-app]${appNameTip} ${msg}`, ...rest)\n } else {\n console.error(`[micro-app]${appNameTip}`, msg, ...rest)\n }\n}\n\n/**\n * format warn log\n * @param msg message\n * @param appName app name, default is null\n */\nexport function logWarn (\n msg: unknown,\n appName: string | null = null,\n ...rest: any[]\n): void {\n const appNameTip = appName && isString(appName) ? ` app ${appName}:` : ''\n if (isString(msg)) {\n console.warn(`[micro-app]${appNameTip} ${msg}`, ...rest)\n } else {\n console.warn(`[micro-app]${appNameTip}`, msg, ...rest)\n }\n}\n\n/**\n * async execution\n * @param fn callback\n * @param args params\n */\nexport function defer (fn: Func, ...args: any[]): void {\n Promise.resolve().then(fn.bind(null, ...args))\n}\n\n/**\n * Add address protocol\n * @param url address\n */\nexport function addProtocol (url: string): string {\n return url.startsWith('//') ? `${location.protocol}${url}` : url\n}\n\n/**\n * format URL address\n * note the scenes:\n * 1. micro-app -> attributeChangedCallback\n * 2. preFetch\n */\nexport function formatAppURL (url: string | null, appName: string | null = null): string {\n if (!isString(url) || !url) return ''\n\n try {\n const { origin, pathname, search } = new URL(addProtocol(url))\n // If it ends with .html/.node/.php/.net/.etc, don’t need to add /\n if (/\\.(\\w+)$/.test(pathname)) {\n return `${origin}${pathname}${search}`\n }\n const fullPath = `${origin}${pathname}/`.replace(/\\/\\/$/, '/')\n return /^https?:\\/\\//.test(fullPath) ? `${fullPath}${search}` : ''\n } catch (e) {\n logError(e, appName)\n return ''\n }\n}\n\n/**\n * format name\n * note the scenes:\n * 1. micro-app -> attributeChangedCallback\n * 2. event_center -> EventCenterForMicroApp -> constructor\n * 3. event_center -> EventCenterForBaseApp -> all methods\n * 4. preFetch\n * 5. plugins\n */\nexport function formatAppName (name: string | null): string {\n if (!isString(name) || !name) return ''\n return name.replace(/(^\\d+)|([^\\w\\d-_])/gi, '')\n}\n\n/**\n * Get valid address, such as https://xxx/xx/xx.html to https://xxx/xx/\n * @param url app.url\n */\nexport function getEffectivePath (url: string): string {\n const { origin, pathname } = new URL(url)\n if (/\\.(\\w+)$/.test(pathname)) {\n const fullPath = `${origin}${pathname}`\n const pathArr = fullPath.split('/')\n pathArr.pop()\n return pathArr.join('/') + '/'\n }\n\n return `${origin}${pathname}/`.replace(/\\/\\/$/, '/')\n}\n\n/**\n * Complete address\n * @param path address\n * @param baseURI base url(app.url)\n */\nexport function CompletionPath (path: string, baseURI: string): string {\n if (\n !path ||\n /^((((ht|f)tps?)|file):)?\\/\\//.test(path) ||\n /^(data|blob):/.test(path)\n ) return path\n\n return new URL(path, getEffectivePath(addProtocol(baseURI))).toString()\n}\n\n/**\n * Get the folder where the link resource is located,\n * which is used to complete the relative address in the css\n * @param linkpath full link address\n */\nexport function getLinkFileDir (linkpath: string): string {\n const pathArr = linkpath.split('/')\n pathArr.pop()\n return addProtocol(pathArr.join('/') + '/')\n}\n\n/**\n * promise stream\n * @param promiseList promise list\n * @param successCb success callback\n * @param errorCb failed callback\n * @param finallyCb finally callback\n */\nexport function promiseStream <T> (\n promiseList: Array<Promise<T> | T>,\n successCb: CallableFunction,\n errorCb: CallableFunction,\n finallyCb?: CallableFunction,\n): void {\n let finishedNum = 0\n\n function isFinished () {\n if (++finishedNum === promiseList.length && finallyCb) finallyCb()\n }\n\n promiseList.forEach((p, i) => {\n if (isPromise(p)) {\n (p as Promise<T>).then((res: T) => {\n successCb({\n data: res,\n index: i,\n })\n isFinished()\n }).catch((err: Error) => {\n errorCb({\n error: err,\n index: i,\n })\n isFinished()\n })\n } else {\n successCb({\n data: p,\n index: i,\n })\n isFinished()\n }\n })\n}\n\n// Check whether the browser supports module script\nexport function isSupportModuleScript (): boolean {\n const s = document.createElement('script')\n return 'noModule' in s\n}\n\n// Create a random symbol string\nexport function createNonceSrc (): string {\n return 'inline-' + Math.random().toString(36).substr(2, 15)\n}\n\n// Array deduplication\nexport function unique (array: any[]): any[] {\n return array.filter(function (this: Record<PropertyKey, boolean>, item) {\n return item in this ? false : (this[item] = true)\n }, Object.create(null))\n}\n\n// requestIdleCallback polyfill\nexport const requestIdleCallback = globalThis.requestIdleCallback ||\n function (fn: CallableFunction) {\n const lastTime = Date.now()\n return setTimeout(function () {\n fn({\n didTimeout: false,\n timeRemaining () {\n return Math.max(0, 50 - (Date.now() - lastTime))\n },\n })\n }, 1)\n }\n\n/**\n * Record the currently running app.name\n */\nlet currentMicroAppName: string | null = null\nexport function setCurrentAppName (appName: string | null): void {\n currentMicroAppName = appName\n}\n\n// get the currently running app.name\nexport function getCurrentAppName (): string | null {\n return currentMicroAppName\n}\n\n// Clear appName\nexport function removeDomScope (): void {\n setCurrentAppName(null)\n}\n\n// is safari browser\nexport function isSafari (): boolean {\n return /Safari/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent)\n}\n\n/**\n * Create pure elements\n */\nexport function pureCreateElement<K extends keyof HTMLElementTagNameMap> (tagName: K, options?: ElementCreationOptions): HTMLElementTagNameMap[K] {\n const element = document.createElement(tagName, options)\n if (element.__MICRO_APP_NAME__) delete element.__MICRO_APP_NAME__\n return element\n}\n\n/**\n * clone origin elements to target\n * @param origin Cloned element\n * @param target Accept cloned elements\n * @param deep deep clone or transfer dom\n */\nexport function cloneContainer <T extends Element, Q extends Element> (\n origin: T,\n target: Q,\n deep: boolean,\n): void {\n target.innerHTML = ''\n if (deep) {\n const clonedNode = origin.cloneNode(true)\n const fragment = document.createDocumentFragment()\n Array.from(clonedNode.childNodes).forEach((node: Node | Element) => {\n fragment.appendChild(node)\n })\n target.appendChild(fragment)\n } else {\n Array.from(origin.childNodes).forEach((node: Node | Element) => {\n target.appendChild(node)\n })\n }\n}\n\n// is invalid key of querySelector\nexport function isInvalidQuerySelectorKey (key: string): boolean {\n if (__TEST__) return !key || /(^\\d)|([^\\w\\d-_$])/gi.test(key)\n return !key || /(^\\d)|([^\\w\\d-_\\u4e00-\\u9fa5])/gi.test(key)\n}\n\n// unique element\nexport function isUniqueElement (key: string): boolean {\n return (\n /^body$/i.test(key) ||\n /^head$/i.test(key) ||\n /^html$/i.test(key)\n )\n}\n\n/**\n * get micro-app element\n * @param target app container\n */\nexport function getRootContainer (target: HTMLElement | ShadowRoot): HTMLElement {\n return (isShadowRoot(target) ? (target as ShadowRoot).host : target) as HTMLElement\n}\n","export enum ObservedAttrName {\n NAME = 'name',\n URL = 'url',\n}\n\n// app status\nexport enum appStatus {\n NOT_LOADED = 'NOT_LOADED',\n LOADING_SOURCE_CODE = 'LOADING_SOURCE_CODE',\n LOAD_SOURCE_FINISHED = 'LOAD_SOURCE_FINISHED',\n LOAD_SOURCE_ERROR = 'LOAD_SOURCE_ERROR',\n MOUNTING = 'MOUNTING',\n MOUNTED = 'MOUNTED',\n UNMOUNT = 'UNMOUNT',\n}\n\n// lifecycles\nexport enum lifeCycles {\n CREATED = 'created',\n BEFOREMOUNT = 'beforemount',\n MOUNTED = 'mounted',\n UNMOUNT = 'unmount',\n ERROR = 'error',\n}\n","import { isFunction } from '../libs/utils'\nimport microApp from '../micro_app'\n\n/**\n * fetch source of html, js, css\n * @param url source path\n * @param appName app name\n * @param config config of fetch\n */\nexport function fetchSource (url: string, appName: string | null = null, options = {}): Promise<string> {\n if (isFunction(microApp.fetch)) {\n return microApp.fetch!(url, options, appName)\n }\n return fetch(url, options).then((res) => {\n return res.text()\n })\n}\n","import { isSupportModuleScript, isBrowser } from './utils'\n\ntype RequestIdleCallbackOptions = {\n timeout: number\n}\n\ntype RequestIdleCallbackInfo = {\n readonly didTimeout: boolean\n timeRemaining: () => number\n}\n\ndeclare global {\n interface Window {\n requestIdleCallback (\n callback: (info: RequestIdleCallbackInfo) => void,\n opts?: RequestIdleCallbackOptions,\n ): number\n _babelPolyfill: boolean\n __MICRO_APP_ENVIRONMENT__?: boolean\n __MICRO_APP_UMD_MODE__?: boolean\n __MICRO_APP_BASE_APPLICATION__?: boolean\n }\n\n interface Element {\n __MICRO_APP_NAME__?: string\n data?: any\n }\n\n interface Node {\n __MICRO_APP_NAME__?: string\n }\n\n interface HTMLStyleElement {\n __MICRO_APP_LINK_PATH__?: string\n __MICRO_APP_HAS_SCOPED__?: boolean\n }\n}\n\nconst globalEnv: Record<string, any> = {}\n\nexport function initGlobalEnv (): void {\n if (isBrowser) {\n /**\n * save patch raw methods\n * pay attention to this binding\n */\n const rawSetAttribute = Element.prototype.setAttribute\n const rawAppendChild = Node.prototype.appendChild\n const rawInsertBefore = Node.prototype.insertBefore\n const rawReplaceChild = Node.prototype.replaceChild\n const rawRemoveChild = Node.prototype.removeChild\n const rawAppend = Element.prototype.append\n const rawPrepend = Element.prototype.prepend\n\n const rawCreateElement = Document.prototype.createElement\n const rawCreateElementNS = Document.prototype.createElementNS\n const rawCreateDocumentFragment = Document.prototype.createDocumentFragment\n const rawQuerySelector = Document.prototype.querySelector\n const rawQuerySelectorAll = Document.prototype.querySelectorAll\n const rawGetElementById = Document.prototype.getElementById\n const rawGetElementsByClassName = Document.prototype.getElementsByClassName\n const rawGetElementsByTagName = Document.prototype.getElementsByTagName\n const rawGetElementsByName = Document.prototype.getElementsByName\n\n const rawWindow = Function('return window')()\n const rawDocument = Function('return document')()\n const supportModuleScript = isSupportModuleScript()\n const templateStyle: HTMLStyleElement = rawDocument.body.querySelector('#micro-app-template-style')\n\n /**\n * save effect raw methods\n * pay attention to this binding, especially setInterval, setTimeout, clearInterval, clearTimeout\n */\n const rawWindowAddEventListener = rawWindow.addEventListener\n const rawWindowRemoveEventListener = rawWindow.removeEventListener\n const rawSetInterval = rawWindow.setInterval\n const rawSetTimeout = rawWindow.setTimeout\n const rawClearInterval = rawWindow.clearInterval\n const rawClearTimeout = rawWindow.clearTimeout\n\n const rawDocumentAddEventListener = rawDocument.addEventListener\n const rawDocumentRemoveEventListener = rawDocument.removeEventListener\n\n // mark current application as base application\n window.__MICRO_APP_BASE_APPLICATION__ = true\n\n Object.assign(globalEnv, {\n // source/patch\n rawSetAttribute,\n rawAppendChild,\n rawInsertBefore,\n rawReplaceChild,\n rawRemoveChild,\n rawAppend,\n rawPrepend,\n rawCreateElement,\n rawCreateElementNS,\n rawCreateDocumentFragment,\n rawQuerySelector,\n rawQuerySelectorAll,\n rawGetElementById,\n rawGetElementsByClassName,\n rawGetElementsByTagName,\n rawGetElementsByName,\n\n // common global vars\n rawWindow,\n rawDocument,\n supportModuleScript,\n templateStyle,\n\n // sandbox/effect\n rawWindowAddEventListener,\n rawWindowRemoveEventListener,\n rawSetInterval,\n rawSetTimeout,\n rawClearInterval,\n rawClearTimeout,\n rawDocumentAddEventListener,\n rawDocumentRemoveEventListener,\n })\n }\n}\n\nexport default globalEnv\n","import type { AppInterface } from '@micro-app/types'\nimport { CompletionPath, isSafari, pureCreateElement, getLinkFileDir } from '../libs/utils'\nimport microApp from '../micro_app'\nimport globalEnv from '../libs/global_env'\n\n// https://developer.mozilla.org/zh-CN/docs/Web/API/CSSRule\nenum CSSRuleType {\n STYLE_RULE = 1,\n MEDIA_RULE = 4,\n SUPPORTS_RULE = 12,\n}\n\n/**\n * Bind css scope\n * Special case:\n * 1. html-abc | abc-html\n * 2. html body.abc\n * 3. abchtml | htmlabc | abcbody | bodyabc\n * 4. html + body | html > body | html.body | html[name=xx] | body[name=xx]\n * 5. xxx, html xxx, body xxx\n *\n * TODO: BUG\n .test-b {\n border: 1px solid var(--color-a);\n border-bottom-color: var(--color-b);\n }\n */\nfunction scopedStyleRule (rule: CSSStyleRule, prefix: string): string {\n const { selectorText, cssText } = rule\n if (/^((html[\\s>~,]+body)|(html|body|:root))$/.test(selectorText)) {\n return cssText.replace(/^((html[\\s>~,]+body)|(html|body|:root))/, prefix)\n } else if (selectorText === '*') {\n return cssText.replace('*', `${prefix} *`)\n }\n\n const builtInRootSelectorRE = /(^|\\s+)((html[\\s>~]+body)|(html|body|:root))(?=[\\s>~]+|$)/\n\n return cssText.replace(/^[\\s\\S]+{/, (selectors) => {\n return selectors.replace(/(^|,)([^,]+)/g, (all, $1, $2) => {\n if (builtInRootSelectorRE.test($2)) {\n // body[name=xx]|body.xx|body#xx etc. do not need to handle\n return all.replace(builtInRootSelectorRE, prefix)\n }\n return `${$1} ${prefix} ${$2.replace(/^\\s*/, '')}`\n })\n })\n}\n\n/**\n * Complete static resource address\n * @param cssText css content\n * @param baseURI domain name\n * @param textContent origin content\n * @param linkpath link resource address, if it is the style converted from link, it will have linkpath\n */\nfunction scopedHost (\n cssText: string,\n baseURI: string,\n textContent: string,\n linkpath?: string,\n) {\n return cssText.replace(/url\\([\"']?([^)\"']+)[\"']?\\)/gm, (all, $1) => {\n if (/^(data|blob):/.test($1)) {\n return all\n } else if (/^(https?:)?\\/\\//.test($1)) {\n if (isSafari()) {\n const purePath = $1.replace(/^https?:/, '')\n if (textContent.indexOf(purePath) === -1) {\n $1 = $1.replace(window.location.origin, '')\n } else {\n return all\n }\n } else {\n return all\n }\n }\n\n // ./a/b.png ../a/b.png a/b.png\n if (/^((\\.\\.?\\/)|[^/])/.test($1) && linkpath) {\n baseURI = getLinkFileDir(linkpath)\n }\n\n return `url(\"${CompletionPath($1, baseURI)}\")`\n })\n}\n\n// handle media and supports\nfunction scopedPackRule (\n rule: CSSMediaRule | CSSSupportsRule,\n prefix: string,\n packName: string,\n): string {\n const result = scopedRule(Array.from(rule.cssRules), prefix)\n return `@${packName} ${rule.conditionText} {${result}}`\n}\n\n/**\n * Process each cssrule\n * @param rules cssRule\n * @param prefix prefix as micro-app[name=xxx]\n */\nfunction scopedRule (rules: CSSRule[], prefix: string): string {\n let result = ''\n for (const rule of rules) {\n switch (rule.type) {\n case CSSRuleType.STYLE_RULE:\n result += scopedStyleRule(rule as CSSStyleRule, prefix)\n break\n case CSSRuleType.MEDIA_RULE:\n result += scopedPackRule(rule as CSSMediaRule, prefix, 'media')\n break\n case CSSRuleType.SUPPORTS_RULE:\n result += scopedPackRule(rule as CSSSupportsRule, prefix, 'supports')\n break\n default:\n result += rule.cssText\n break\n }\n }\n\n return result.replace(/^\\s+/, '')\n}\n\n/**\n * common method of bind CSS\n */\nfunction commonAction (\n templateStyle: HTMLStyleElement,\n styleElement: HTMLStyleElement,\n originContent: string,\n prefix: string,\n baseURI: string,\n linkpath?: string,\n) {\n if (!styleElement.__MICRO_APP_HAS_SCOPED__) {\n const rules: CSSRule[] = Array.from(templateStyle.sheet?.cssRules ?? [])\n let result = scopedHost(\n scopedRule(rules, prefix),\n baseURI,\n originContent,\n linkpath,\n )\n /**\n * Solve the problem of missing content quotes in some Safari browsers\n * docs: https://developer.mozilla.org/zh-CN/docs/Web/CSS/content\n * If there are still problems, it is recommended to use the attr()\n */\n if (isSafari()) {\n result = result.replace(/([;{]\\s*content:\\s*)([^\\s\"][^\";}]*)/gm, (all, $1, $2) => {\n if (\n $2 === 'none' ||\n /^(url\\()|(counter\\()|(attr\\()|(open-quote)|(close-quote)/.test($2)\n ) {\n return all\n }\n return `${$1}\"${$2}\"`\n })\n }\n styleElement.textContent = result\n styleElement.__MICRO_APP_HAS_SCOPED__ = true\n }\n}\n\n/**\n * scopedCSS\n * @param styleElement target style element\n * @param appName app name\n */\nexport default function scopedCSS (\n styleElement: HTMLStyleElement,\n app: AppInterface,\n): HTMLStyleElement {\n if (app.scopecss) {\n const prefix = `${microApp.tagName}[name=${app.name}]`\n let templateStyle = globalEnv.templateStyle\n if (!templateStyle) {\n globalEnv.templateStyle = templateStyle = pureCreateElement('style')\n templateStyle.setAttribute('id', 'micro-app-template-style')\n globalEnv.rawDocument.body.appendChild(templateStyle)\n templateStyle.sheet!.disabled = true\n }\n\n if (styleElement.textContent) {\n templateStyle.textContent = styleElement.textContent\n commonAction(\n templateStyle,\n styleElement,\n styleElement.textContent,\n prefix,\n app.url,\n styleElement.__MICRO_APP_LINK_PATH__,\n )\n templateStyle.textContent = ''\n } else {\n const observer = new MutationObserver(function () {\n observer.disconnect()\n // styled-component will not be processed temporarily\n if (\n (!styleElement.textContent && styleElement.sheet?.cssRules?.length) ||\n styleElement.hasAttribute('data-styled')\n ) return\n commonAction(\n styleElement,\n styleElement,\n styleElement.textContent!,\n prefix,\n app.url,\n styleElement.__MICRO_APP_LINK_PATH__,\n )\n })\n\n observer.observe(styleElement, { childList: true })\n }\n }\n\n return styleElement\n}\n","import { isFunction } from '../libs/utils'\n\nfunction eventHandler (event: Event, element: HTMLLinkElement | HTMLScriptElement): void {\n Object.defineProperties(event, {\n currentTarget: {\n get () {\n return element\n }\n },\n srcElement: {\n get () {\n return element\n }\n },\n target: {\n get () {\n return element\n }\n },\n })\n}\n\nexport function dispatchOnLoadEvent (element: HTMLLinkElement | HTMLScriptElement): void {\n const event = new CustomEvent('load')\n eventHandler(event, element)\n if (isFunction(element.onload)) {\n element.onload!(event)\n } else {\n element.dispatchEvent(event)\n }\n}\n\nexport function dispatchOnErrorEvent (element: HTMLLinkElement | HTMLScriptElement): void {\n const event = new CustomEvent('error')\n eventHandler(event, element)\n if (isFunction(element.onerror)) {\n element.onerror!(event)\n } else {\n element.dispatchEvent(event)\n }\n}\n","import type {\n AppInterface,\n sourceLinkInfo,\n} from '@micro-app/types'\nimport { fetchSource } from './fetch'\nimport {\n CompletionPath,\n promiseStream,\n pureCreateElement,\n defer,\n logError,\n} from '../libs/utils'\nimport scopedCSS from './scoped_css'\nimport {\n dispatchOnLoadEvent,\n dispatchOnErrorEvent,\n} from './load_event'\n\n// Global links, reuse across apps\nexport const globalLinks = new Map<string, string>()\n\n/**\n * Extract link elements\n * @param link link element\n * @param parent parent element of link\n * @param app app\n * @param microAppHead micro-app-head element\n * @param isDynamic dynamic insert\n */\nexport function extractLinkFromHtml (\n link: HTMLLinkElement,\n parent: Node,\n app: AppInterface,\n isDynamic = false,\n): any {\n const rel = link.getAttribute('rel')\n let href = link.getAttribute('href')\n let replaceComment: Comment | null = null\n if (rel === 'stylesheet' && href) {\n href = CompletionPath(href, app.url)\n if (!isDynamic) {\n replaceComment = document.createComment(`link element with href=${href} move to micro-app-head as style element`)\n app.source.links.set(href, {\n code: '',\n placeholder: replaceComment,\n isGlobal: link.hasAttribute('global'),\n })\n } else {\n return {\n url: href,\n info: {\n code: '',\n isGlobal: link.hasAttribute('global'),\n }\n }\n }\n } else if (rel && ['prefetch', 'preload', 'prerender', 'icon', 'apple-touch-icon'].includes(rel)) {\n // preload prefetch icon ....\n if (isDynamic) {\n replaceComment = document.createComment(`link element with rel=${rel}${href ? ' & href=' + href : ''} removed by micro-app`)\n } else {\n parent.removeChild(link)\n }\n } else if (href) {\n // dns-prefetch preconnect modulepreload search ....\n link.setAttribute('href', CompletionPath(href, app.url))\n }\n\n if (isDynamic) {\n return { replaceComment }\n } else if (replaceComment) {\n return parent.replaceChild(replaceComment, link)\n }\n}\n\n/**\n * Get link remote resources\n * @param wrapElement htmlDom\n * @param app app\n * @param microAppHead micro-app-head\n */\nexport function fetchLinksFromHtml (\n wrapElement: HTMLElement,\n app: AppInterface,\n microAppHead: Element,\n): void {\n const linkEntries: Array<[string, sourceLinkInfo]> = Array.from(app.source.links.entries())\n const fetchLinkPromise: Array<Promise<string>|string> = []\n for (const [url] of linkEntries) {\n const globalLinkCode = globalLinks.get(url)\n globalLinkCode ? fetchLinkPromise.push(globalLinkCode) : fetchLinkPromise.push(fetchSource(url, app.name))\n }\n\n promiseStream<string>(fetchLinkPromise, (res: {data: string, index: number}) => {\n fetchLinkSuccess(\n linkEntries[res.index][0],\n linkEntries[res.index][1],\n res.data,\n microAppHead,\n app,\n )\n }, (err: {error: Error, index: number}) => {\n logError(err, app.name)\n }, () => {\n app.onLoad(wrapElement)\n })\n}\n\n/**\n * fetch link succeeded, replace placeholder with style tag\n * @param url resource address\n * @param info resource link info\n * @param data code\n * @param microAppHead micro-app-head\n * @param app app\n */\nexport function fetchLinkSuccess (\n url: string,\n info: sourceLinkInfo,\n data: string,\n microAppHead: Element,\n app: AppInterface,\n): void {\n if (info.isGlobal && !globalLinks.has(url)) {\n globalLinks.set(url, data)\n }\n\n const styleLink = pureCreateElement('style')\n styleLink.textContent = data\n styleLink.__MICRO_APP_LINK_PATH__ = url\n styleLink.setAttribute('data-origin-href', url)\n\n microAppHead.replaceChild(scopedCSS(styleLink, app), info.placeholder!)\n\n info.placeholder = null\n info.code = data\n}\n\n/**\n * get css from dynamic link\n * @param url link address\n * @param info info\n * @param app app\n * @param originLink origin link element\n * @param replaceStyle style element which replaced origin link\n */\nexport function foramtDynamicLink (\n url: string,\n info: sourceLinkInfo,\n app: AppInterface,\n originLink: HTMLLinkElement,\n replaceStyle: HTMLStyleElement,\n): void {\n if (app.source.links.has(url)) {\n replaceStyle.textContent = app.source.links.get(url)!.code\n scopedCSS(replaceStyle, app)\n defer(() => dispatchOnLoadEvent(originLink))\n return\n }\n\n if (globalLinks.has(url)) {\n const code = globalLinks.get(url)!\n info.code = code\n app.source.links.set(url, info)\n replaceStyle.textContent = code\n scopedCSS(replaceStyle, app)\n defer(() => dispatchOnLoadEvent(originLink))\n return\n }\n\n fetchSource(url, app.name).then((data: string) => {\n info.code = data\n app.source.links.set(url, info)\n info.isGlobal && globalLinks.set(url, data)\n replaceStyle.textContent = data\n scopedCSS(replaceStyle, app)\n dispatchOnLoadEvent(originLink)\n }).catch((err) => {\n logError(err, app.name)\n dispatchOnErrorEvent(originLink)\n })\n}\n","/* eslint-disable node/no-callback-literal */\nimport type {\n AppInterface,\n sourceScriptInfo,\n plugins,\n Func,\n} from '@micro-app/types'\nimport { fetchSource } from './fetch'\nimport {\n CompletionPath,\n promiseStream,\n createNonceSrc,\n pureCreateElement,\n defer,\n logError,\n isUndefined,\n isPlainObject,\n isArray,\n isFunction,\n} from '../libs/utils'\nimport {\n dispatchOnLoadEvent,\n dispatchOnErrorEvent,\n} from './load_event'\nimport microApp from '../micro_app'\nimport globalEnv from '../libs/global_env'\n\ntype moduleCallBack = Func & { moduleCount?: number }\n\n// Global scripts, reuse across apps\nexport const globalScripts = new Map<string, string>()\n\n/**\n * Extract script elements\n * @param script script element\n * @param parent parent element of script\n * @param app app\n * @param isDynamic dynamic insert\n */\nexport function extractScriptElement (\n script: HTMLScriptElement,\n parent: Node,\n app: AppInterface,\n isDynamic = false,\n): any {\n let replaceComment: Comment | null = null\n let src: string | null = script.getAttribute('src')\n if (script.hasAttribute('exclude')) {\n replaceComment = document.createComment('script element with exclude attribute removed by micro-app')\n } else if (\n (script.type && !['text/javascript', 'text/ecmascript', 'application/javascript', 'application/ecmascript', 'module'].includes(script.type)) ||\n script.hasAttribute('ignore')\n ) {\n return null\n } else if (\n (globalEnv.supportModuleScript && script.noModule) ||\n (!globalEnv.supportModuleScript && script.type === 'module')\n ) {\n replaceComment = document.createComment(`${script.noModule ? 'noModule' : 'module'} script ignored by micro-app`)\n } else if (src) { // remote script\n src = CompletionPath(src, app.url)\n const info = {\n code: '',\n isExternal: true,\n isDynamic: isDynamic,\n async: script.hasAttribute('async'),\n defer: script.defer || script.type === 'module',\n module: script.type === 'module',\n isGlobal: script.hasAttribute('global'),\n }\n if (!isDynamic) {\n app.source.scripts.set(src, info)\n replaceComment = document.createComment(`script with src='${src}' extract by micro-app`)\n } else {\n return { url: src, info }\n }\n } else if (script.textContent) { // inline script\n const nonceStr: string = createNonceSrc()\n const info = {\n code: script.textContent,\n isExternal: false,\n isDynamic: isDynamic,\n async: false,\n defer: script.type === 'module',\n module: script.type === 'module',\n }\n if (!isDynamic) {\n app.source.scripts.set(nonceStr, info)\n replaceComment = document.createComment('inline script extract by micro-app')\n } else {\n return { url: nonceStr, info }\n }\n } else if (!isDynamic) {\n /**\n * script with empty src or empty script.textContent remove in static html\n * & not removed if it created by dynamic\n */\n replaceComment = document.createComment('script element removed by micro-app')\n }\n\n if (isDynamic) {\n return { replaceComment }\n } else {\n return parent.replaceChild(replaceComment!, script)\n }\n}\n\n/**\n * Get remote resources of script\n * @param wrapElement htmlDom\n * @param app app\n */\nexport function fetchScriptsFromHtml (\n wrapElement: HTMLElement,\n app: AppInterface,\n): void {\n const scriptEntries: Array<[string, sourceScriptInfo]> = Array.from(app.source.scripts.entries())\n const fetchScriptPromise: Promise<string>[] = []\n const fetchScriptPromiseInfo: Array<[string, sourceScriptInfo]> = []\n for (const [url, info] of scriptEntries) {\n if (info.isExternal) {\n const globalScriptText = globalScripts.get(url)\n if (globalScriptText) {\n info.code = globalScriptText\n } else if (!info.defer && !info.async) {\n fetchScriptPromise.push(fetchSource(url, app.name))\n fetchScriptPromiseInfo.push([url, info])\n }\n }\n }\n\n if (fetchScriptPromise.length) {\n promiseStream<string>(fetchScriptPromise, (res: {data: string, index: number}) => {\n fetchScriptSuccess(\n fetchScriptPromiseInfo[res.index][0],\n fetchScriptPromiseInfo[res.index][1],\n res.data,\n )\n }, (err: {error: Error, index: number}) => {\n logError(err, app.name)\n }, () => {\n app.onLoad(wrapElement)\n })\n } else {\n app.onLoad(wrapElement)\n }\n}\n\n/**\n * fetch js succeeded, record the code value\n * @param url script address\n * @param info resource script info\n * @param data code\n */\nexport function fetchScriptSuccess (\n url: string,\n info: sourceScriptInfo,\n data: string,\n): void {\n if (info.isGlobal && !globalScripts.has(url)) {\n globalScripts.set(url, data)\n }\n\n info.code = data\n}\n\n/**\n * Execute js in the mount lifecycle\n * @param scriptList script list\n * @param app app\n * @param initedHook callback for umd mode\n */\nexport function execScripts (\n scriptList: Map<string, sourceScriptInfo>,\n app: AppInterface,\n initedHook: moduleCallBack,\n): void {\n const scriptListEntries: Array<[string, sourceScriptInfo]> = Array.from(scriptList.entries())\n const deferScriptPromise: Array<Promise<string>|string> = []\n const deferScriptInfo: Array<[string, sourceScriptInfo]> = []\n for (const [url, info] of scriptListEntries) {\n if (!info.isDynamic) {\n // Notice the second render\n if (info.defer || info.async) {\n if (info.isExternal && !info.code) {\n deferScriptPromise.push(fetchSource(url, app.name))\n } else {\n deferScriptPromise.push(info.code)\n }\n deferScriptInfo.push([url, info])\n\n info.module && (initedHook.moduleCount = initedHook.moduleCount ? ++initedHook.moduleCount : 1)\n } else {\n runScript(url, app, info, false)\n initedHook(false)\n }\n }\n }\n\n if (deferScriptPromise.length) {\n Promise.all(deferScriptPromise).then((res: string[]) => {\n res.forEach((code, index) => {\n const [url, info] = deferScriptInfo[index]\n info.code = info.code || code\n runScript(url, app, info, false, initedHook)\n !info.module && initedHook(false)\n })\n initedHook(isUndefined(initedHook.moduleCount))\n }).catch((err) => {\n logError(err, app.name)\n initedHook(true)\n })\n } else {\n initedHook(true)\n }\n}\n\n/**\n * run code\n * @param url script address\n * @param app app\n * @param info script info\n * @param isDynamic dynamically created script\n * @param callback callback of module script\n */\nexport function runScript (\n url: string,\n app: AppInterface,\n info: sourceScriptInfo,\n isDynamic: boolean,\n callback?: moduleCallBack,\n): any {\n try {\n const code = bindScope(url, app, info.code, info.module)\n if (app.inline || info.module) {\n const scriptElement = pureCreateElement('script')\n runCode2InlineScript(url, code, info.module, scriptElement, callback)\n if (isDynamic) return scriptElement\n // TEST IGNORE\n app.container?.querySelector('micro-app-body')!.appendChild(scriptElement)\n } else {\n runCode2Function(code, info)\n if (isDynamic) return document.createComment('dynamic script extract by micro-app')\n }\n } catch (e) {\n console.error(`[micro-app from runScript] app ${app.name}: `, e)\n }\n}\n\n/**\n * Get dynamically created remote script\n * @param url script address\n * @param info info\n * @param app app\n * @param originScript origin script element\n */\nexport function runDynamicRemoteScript (\n url: string,\n info: sourceScriptInfo,\n app: AppInterface,\n originScript: HTMLScriptElement,\n): HTMLScriptElement | Comment {\n const dispatchScriptOnLoadEvent = () => dispatchOnLoadEvent(originScript)\n\n // url is unique\n if (app.source.scripts.has(url)) {\n const existInfo: sourceScriptInfo = app.source.scripts.get(url)!\n !existInfo.module && defer(dispatchScriptOnLoadEvent)\n return runScript(url, app, existInfo, true, dispatchScriptOnLoadEvent)\n }\n\n if (globalScripts.has(url)) {\n const code = globalScripts.get(url)!\n info.code = code\n app.source.scripts.set(url, info)\n !info.module && defer(dispatchScriptOnLoadEvent)\n return runScript(url, app, info, true, dispatchScriptOnLoadEvent)\n }\n\n let replaceElement: Comment | HTMLScriptElement\n if (app.inline || info.module) {\n replaceElement = pureCreateElement('script')\n } else {\n replaceElement = document.createComment(`dynamic script with src='${url}' extract by micro-app`)\n }\n\n fetchSource(url, app.name).then((code: string) => {\n info.code = code\n app.source.scripts.set(url, info)\n info.isGlobal && globalScripts.set(url, code)\n try {\n code = bindScope(url, app, code, info.module)\n if (app.inline || info.module) {\n runCode2InlineScript(url, code, info.module, replaceElement as HTMLScriptElement, dispatchScriptOnLoadEvent)\n } else {\n runCode2Function(code, info)\n }\n } catch (e) {\n console.error(`[micro-app from runDynamicScript] app ${app.name}: `, e, url)\n }\n !info.module && dispatchOnLoadEvent(originScript)\n }).catch((err) => {\n logError(err, app.name)\n dispatchOnErrorEvent(originScript)\n })\n\n return replaceElement\n}\n\n/**\n * common handle for inline script\n * @param url script address\n * @param code bound code\n * @param module type='module' of script\n * @param scriptElement target script element\n * @param callback callback of module script\n */\nfunction runCode2InlineScript (\n url: string,\n code: string,\n module: boolean,\n scriptElement: HTMLScriptElement,\n callback?: moduleCallBack,\n): void {\n if (module) {\n // module script is async, transform it to a blob for subsequent operations\n const blob = new Blob([code], { type: 'text/javascript' })\n scriptElement.src = URL.createObjectURL(blob)\n scriptElement.setAttribute('type', 'module')\n if (callback) {\n callback.moduleCount && callback.moduleCount--\n scriptElement.onload = callback.bind(scriptElement, callback.moduleCount === 0)\n }\n } else {\n scriptElement.textContent = code\n }\n\n if (!url.startsWith('inline-')) {\n scriptElement.setAttribute('data-origin-src', url)\n }\n}\n\n// init & run code2Function\nfunction runCode2Function (code: string, info: sourceScriptInfo) {\n if (!info.code2Function) {\n info.code2Function = new Function(code)\n }\n info.code2Function.call(window)\n}\n\n/**\n * bind js scope\n * @param url script address\n * @param app app\n * @param code code\n * @param module type='module' of script\n */\nfunction bindScope (\n url: string,\n app: AppInterface,\n code: string,\n module: boolean,\n): string {\n if (isPlainObject(microApp.plugins)) {\n code = usePlugins(url, code, app.name, microApp.plugins!)\n }\n if (app.sandBox && !module) {\n globalEnv.rawWindow.__MICRO_APP_PROXY_WINDOW__ = app.sandBox.proxyWindow\n return `;(function(window, self){with(window){;${code}\\n}}).call(window.__MICRO_APP_PROXY_WINDOW__, window.__MICRO_APP_PROXY_WINDOW__, window.__MICRO_APP_PROXY_WINDOW__);`\n }\n return code\n}\n\n/**\n * Call the plugin to process the file\n * @param url script address\n * @param code code\n * @param appName app name\n * @param plugins plugin list\n */\nfunction usePlugins (url: string, code: string, appName: string, plugins: plugins): string {\n if (isArray(plugins.global)) {\n for (const plugin of plugins.global) {\n if (isPlainObject(plugin) && isFunction(plugin.loader)) {\n code = plugin.loader!(code, url, plugin.options)\n }\n }\n }\n\n if (isArray(plugins.modules?.[appName])) {\n for (const plugin of plugins.modules![appName]) {\n if (isPlainObject(plugin) && isFunction(plugin.loader)) {\n code = plugin.loader!(code, url, plugin.options)\n }\n }\n }\n\n return code\n}\n","import type { AppInterface } from '@micro-app/types'\nimport { fetchSource } from './fetch'\nimport { logError, CompletionPath, pureCreateElement } from '../libs/utils'\nimport { extractLinkFromHtml, fetchLinksFromHtml } from './links'\nimport { extractScriptElement, fetchScriptsFromHtml } from './scripts'\nimport scopedCSS from './scoped_css'\n\n/**\n * transform html string to dom\n * @param str string dom\n */\nfunction getWrapElement (str: string): HTMLElement {\n const wrapDiv = pureCreateElement('div')\n\n wrapDiv.innerHTML = str\n\n return wrapDiv\n}\n\n/**\n * Recursively process each child element\n * @param parent parent element\n * @param app app\n * @param microAppHead micro-app-head element\n */\nfunction flatChildren (\n parent: HTMLElement,\n app: AppInterface,\n microAppHead: Element,\n): void {\n const children = Array.from(parent.children)\n\n children.length && children.forEach((child) => {\n flatChildren(child as HTMLElement, app, microAppHead)\n })\n\n for (const dom of children) {\n if (dom instanceof HTMLLinkElement) {\n if (dom.hasAttribute('exclude')) {\n parent.replaceChild(document.createComment('link element with exclude attribute ignored by micro-app'), dom)\n } else if (!dom.hasAttribute('ignore')) {\n extractLinkFromHtml(dom, parent, app)\n } else if (dom.hasAttribute('href')) {\n dom.setAttribute('href', CompletionPath(dom.getAttribute('href')!, app.url))\n }\n } else if (dom instanceof HTMLStyleElement) {\n if (dom.hasAttribute('exclude')) {\n parent.replaceChild(document.createComment('style element with exclude attribute ignored by micro-app'), dom)\n } else if (app.scopecss && !dom.hasAttribute('ignore')) {\n scopedCSS(dom, app)\n }\n } else if (dom instanceof HTMLScriptElement) {\n extractScriptElement(dom, parent, app)\n } else if (dom instanceof HTMLMetaElement || dom instanceof HTMLTitleElement) {\n parent.removeChild(dom)\n } else if (dom instanceof HTMLImageElement && dom.hasAttribute('src')) {\n dom.setAttribute('src', CompletionPath(dom.getAttribute('src')!, app.url))\n }\n }\n}\n\n/**\n * Extract link and script, bind style scope\n * @param htmlStr html string\n * @param app app\n */\nfunction extractSourceDom (htmlStr: string, app: AppInterface) {\n const wrapElement = getWrapElement(htmlStr)\n const microAppHead = wrapElement.querySelector('micro-app-head')\n const microAppBody = wrapElement.querySelector('micro-app-body')\n\n if (!microAppHead || !microAppBody) {\n const msg = `element ${microAppHead ? 'body' : 'head'} is missing`\n app.onerror(new Error(msg))\n return logError(msg, app.name)\n }\n\n flatChildren(wrapElement, app, microAppHead)\n\n if (app.source.links.size) {\n fetchLinksFromHtml(wrapElement, app, microAppHead)\n } else {\n app.onLoad(wrapElement)\n }\n\n if (app.source.scripts.size) {\n fetchScriptsFromHtml(wrapElement, app)\n } else {\n app.onLoad(wrapElement)\n }\n}\n\n/**\n * Get and format html\n * @param app app\n */\nexport default function extractHtml (app: AppInterface): void {\n fetchSource(app.ssrUrl || app.url, app.name, { cache: 'no-cache' }).then((htmlStr: string) => {\n if (!htmlStr) {\n const msg = 'html is empty, please check in detail'\n app.onerror(new Error(msg))\n return logError(msg, app.name)\n }\n htmlStr = htmlStr\n .replace(/<head[^>]*>[\\s\\S]*?<\\/head>/i, (match) => {\n return match\n .replace(/<head/i, '<micro-app-head')\n .replace(/<\\/head>/i, '</micro-app-head>')\n })\n .replace(/<body[^>]*>[\\s\\S]*?<\\/body>/i, (match) => {\n return match\n .replace(/<body/i, '<micro-app-body')\n .replace(/<\\/body>/i, '</micro-app-body>')\n })\n\n extractSourceDom(htmlStr, app)\n }).catch((e) => {\n logError(`Failed to fetch data from ${app.url}, micro-app stop rendering`, app.name, e)\n app.onLoadError(e)\n })\n}\n","import type { Func } from '@micro-app/types'\nimport { isFunction, isBoundFunction } from '../libs/utils'\n\nconst boundedMap = new WeakMap<CallableFunction, boolean>()\nexport function isBoundedFunction (value: CallableFunction): boolean {\n if (boundedMap.has(value)) {\n return boundedMap.get(value)!\n }\n\n // bind function\n const boundFunction = isBoundFunction(value)\n\n boundedMap.set(value, boundFunction)\n\n return boundFunction\n}\n\nconst constructorMap = new WeakMap<Func | FunctionConstructor, boolean>()\nfunction isConstructor (value: Func | FunctionConstructor) {\n if (constructorMap.has(value)) {\n return constructorMap.get(value)\n }\n\n const valueStr = value.toString()\n\n const result = (\n value.prototype &&\n value.prototype.constructor === value &&\n Object.getOwnPropertyNames(value.prototype).length > 1\n ) ||\n /^function\\s+[A-Z]/.test(valueStr) ||\n /^class\\s+/.test(valueStr)\n\n constructorMap.set(value, result)\n\n return result\n}\n\nconst rawWindowMethodMap = new WeakMap<CallableFunction, CallableFunction>()\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\nexport default function bindFunctionToRawWidow (rawWindow: Window, value: any): unknown {\n if (rawWindowMethodMap.has(value)) {\n return rawWindowMethodMap.get(value)\n }\n\n if (isFunction(value) && !isConstructor(value) && !isBoundedFunction(value)) {\n const bindRawWindowValue = value.bind(rawWindow)\n\n for (const key in value) {\n bindRawWindowValue[key] = value[key]\n }\n\n if (value.hasOwnProperty('prototype') && !bindRawWindowValue.hasOwnProperty('prototype')) {\n bindRawWindowValue.prototype = value.prototype\n }\n\n rawWindowMethodMap.set(value, bindRawWindowValue)\n return bindRawWindowValue\n }\n\n return value\n}\n","import type { microWindowType } from '@micro-app/types'\nimport { getCurrentAppName, setCurrentAppName, logWarn, isFunction, isBoundFunction } from '../libs/utils'\nimport { appInstanceMap } from '../create_app'\nimport globalEnv from '../libs/global_env'\n\ntype MicroEventListener = EventListenerOrEventListenerObject & Record<string, any>\ntype timeInfo = {\n handler: TimerHandler,\n timeout?: number,\n args: any[],\n}\n\n// document.onclick binding list, the binding function of each application is unique\nconst documentClickListMap = new Map<string, unknown>()\nlet hasRewriteDocumentOnClick = false\n/**\n * Rewrite document.onclick and execute it only once\n */\nfunction overwriteDocumentOnClick (): void {\n hasRewriteDocumentOnClick = true\n if (Object.getOwnPropertyDescriptor(document, 'onclick')) {\n return logWarn('Cannot redefine document property onclick')\n }\n const rawOnClick = document.onclick\n document.onclick = null\n let hasDocumentClickInited = false\n\n function onClickHandler (e: MouseEvent) {\n documentClickListMap.forEach((f) => {\n isFunction(f) && (f as Function).call(document, e)\n })\n }\n\n Object.defineProperty(document, 'onclick', {\n configurable: true,\n enumerable: true,\n get () {\n const appName = getCurrentAppName()\n return appName ? documentClickListMap.get(appName) : documentClickListMap.get('base')\n },\n set (f: GlobalEventHandlers['onclick']) {\n const appName = getCurrentAppName()\n if (appName) {\n documentClickListMap.set(appName, f)\n } else {\n documentClickListMap.set('base', f)\n }\n\n if (!hasDocumentClickInited && isFunction(f)) {\n hasDocumentClickInited = true\n globalEnv.rawDocumentAddEventListener.call(globalEnv.rawDocument, 'click', onClickHandler, false)\n }\n }\n })\n\n rawOnClick && (document.onclick = rawOnClick)\n}\n\n/**\n * The document event is globally, we need to clear these event bindings when micro application unmounted\n */\nconst documentEventListenerMap = new Map<string, Map<string, Set<MicroEventListener>>>()\nexport function effectDocumentEvent (): void {\n const {\n rawDocument,\n rawDocumentAddEventListener,\n rawDocumentRemoveEventListener,\n } = globalEnv\n\n !hasRewriteDocumentOnClick && overwriteDocumentOnClick()\n\n document.addEventListener = function (\n type: string,\n listener: MicroEventListener,\n options?: boolean | AddEventListenerOptions\n ): void {\n const appName = getCurrentAppName()\n /**\n * ignore bound function of document event in umd mode, used to solve problem of react global events\n */\n if (appName && !(appInstanceMap.get(appName)?.umdMode && isBoundFunction(listener))) {\n const appListenersMap = documentEventListenerMap.get(appName)\n if (appListenersMap) {\n const appListenerList = appListenersMap.get(type)\n if (appListenerList) {\n appListenerList.add(listener)\n } else {\n appListenersMap.set(type, new Set([listener]))\n }\n } else {\n documentEventListenerMap.set(appName, new Map([[type, new Set([listener])]]))\n }\n listener && (listener.__MICRO_MARK_OPTIONS__ = options)\n }\n rawDocumentAddEventListener.call(rawDocument, type, listener, options)\n }\n\n document.removeEventListener = function (\n type: string,\n listener: MicroEventListener,\n options?: boolean | AddEventListenerOptions,\n ): void {\n const appName = getCurrentAppName()\n if (appName && !(appInstanceMap.get(appName)?.umdMode && isBoundFunction(listener))) {\n const appListenersMap = documentEventListenerMap.get(appName)\n if (appListenersMap) {\n const appListenerList = appListenersMap.get(type)\n if (appListenerList?.size && appListenerList.has(listener)) {\n appListenerList.delete(listener)\n }\n }\n }\n rawDocumentRemoveEventListener.call(rawDocument, type, listener, options)\n }\n}\n\n// Clear the document event agent\nexport function releaseEffectDocumentEvent (): void {\n document.addEventListener = globalEnv.rawDocumentAddEventListener\n document.removeEventListener = globalEnv.rawDocumentRemoveEventListener\n}\n\n/**\n * Format event name\n * @param type event name\n * @param microWindow micro window\n */\nfunction formatEventType (type: string, microWindow: microWindowType): string {\n if (type === 'unmount') {\n return `unmount-${microWindow.__MICRO_APP_NAME__}`\n }\n return type\n}\n\n/**\n * Rewrite side-effect events\n * @param microWindow micro window\n */\nexport default function effect (microWindow: microWindowType): Record<string, CallableFunction> {\n const appName = microWindow.__MICRO_APP_NAME__\n const eventListenerMap = new Map<string, Set<MicroEventListener>>()\n const intervalIdMap = new Map<number, timeInfo>()\n const timeoutIdMap = new Map<number, timeInfo>()\n const {\n rawWindow,\n rawDocument,\n rawWindowAddEventListener,\n rawWindowRemoveEventListener,\n rawSetInterval,\n rawSetTimeout,\n rawClearInterval,\n rawClearTimeout,\n rawDocumentRemoveEventListener,\n } = globalEnv\n\n // listener may be null, e.g test-passive\n microWindow.addEventListener = function (\n type: string,\n listener: MicroEventListener,\n options?: boolean | AddEventListenerOptions,\n ): void {\n type = formatEventType(type, microWindow)\n const listenerList = eventListenerMap.get(type)\n if (listenerList) {\n listenerList.add(listener)\n } else {\n eventListenerMap.set(type, new Set([listener]))\n }\n listener && (listener.__MICRO_MARK_OPTIONS__ = options)\n rawWindowAddEventListener.call(rawWindow, type, listener, options)\n }\n\n microWindow.removeEventListener = function (\n type: string,\n listener: MicroEventListener,\n options?: boolean | AddEventListenerOptions,\n ): void {\n type = formatEventType(type, microWindow)\n const listenerList = eventListenerMap.get(type)\n if (listenerList?.size && listenerList.has(listener)) {\n listenerList.delete(listener)\n }\n rawWindowRemoveEventListener.call(rawWindow, type, listener, options)\n }\n\n microWindow.setInterval = function (\n handler: TimerHandler,\n timeout?: number,\n ...args: any[]\n ): number {\n const intervalId = rawSetInterval.call(rawWindow, handler, timeout, ...args)\n intervalIdMap.set(intervalId, { handler, timeout, args })\n return intervalId\n }\n\n microWindow.setTimeout = function (\n handler: TimerHandler,\n timeout?: number,\n ...args: any[]\n ): number {\n const timeoutId = rawSetTimeout.call(rawWindow, handler, timeout, ...args)\n timeoutIdMap.set(timeoutId, { handler, timeout, args })\n return timeoutId\n }\n\n microWindow.clearInterval = function (intervalId: number) {\n intervalIdMap.delete(intervalId)\n rawClearInterval.call(rawWindow, intervalId)\n }\n\n microWindow.clearTimeout = function (timeoutId: number) {\n timeoutIdMap.delete(timeoutId)\n rawClearTimeout.call(rawWindow, timeoutId)\n }\n\n const umdWindowListenerMap = new Map<string, Set<MicroEventListener>>()\n const umdDocumentListenerMap = new Map<string, Set<MicroEventListener>>()\n let umdIntervalIdMap = new Map<number, timeInfo>()\n let umdTimeoutIdMap = new Map<number, timeInfo>()\n let umdOnClickHandler: unknown\n\n // record event and timer before exec umdMountHook\n const recordUmdEffect = () => {\n // record window event\n eventListenerMap.forEach((listenerList, type) => {\n if (listenerList.size) {\n umdWindowListenerMap.set(type, new Set(listenerList))\n }\n })\n\n // record timers\n if (intervalIdMap.size) {\n umdIntervalIdMap = new Map(intervalIdMap)\n }\n\n if (timeoutIdMap.size) {\n umdTimeoutIdMap = new Map(timeoutIdMap)\n }\n\n // record onclick handler\n umdOnClickHandler = documentClickListMap.get(appName)\n\n // record document event\n const documentAppListenersMap = documentEventListenerMap.get(appName)\n if (documentAppListenersMap) {\n documentAppListenersMap.forEach((listenerList, type) => {\n if (listenerList.size) {\n umdDocumentListenerMap.set(type, new Set(listenerList))\n }\n })\n }\n }\n\n // rebuild event and timer before remount umd app\n const rebuildUmdEffect = () => {\n // rebuild window event\n umdWindowListenerMap.forEach((listenerList, type) => {\n for (const listener of listenerList) {\n microWindow.addEventListener(type, listener, listener?.__MICRO_MARK_OPTIONS__)\n }\n })\n\n // rebuild timer\n umdIntervalIdMap.forEach((info: timeInfo) => {\n microWindow.setInterval(info.handler, info.timeout, ...info.args)\n })\n\n umdTimeoutIdMap.forEach((info: timeInfo) => {\n microWindow.setTimeout(info.handler, info.timeout, ...info.args)\n })\n\n // rebuild onclick event\n umdOnClickHandler && documentClickListMap.set(appName, umdOnClickHandler)\n\n // rebuild document event\n setCurrentAppName(appName)\n umdDocumentListenerMap.forEach((listenerList, type) => {\n for (const listener of listenerList) {\n document.addEventListener(type, listener, listener?.__MICRO_MARK_OPTIONS__)\n }\n })\n setCurrentAppName(null)\n }\n\n // release all event listener & interval & timeout when unmount app\n const releaseEffect = () => {\n // Clear window binding events\n if (eventListenerMap.size) {\n eventListenerMap.forEach((listenerList, type) => {\n for (const listener of listenerList) {\n rawWindowRemoveEventListener.call(rawWindow, type, listener)\n }\n })\n eventListenerMap.clear()\n }\n\n // Clear timers\n if (intervalIdMap.size) {\n intervalIdMap.forEach((_, intervalId: number) => {\n rawClearInterval.call(rawWindow, intervalId)\n })\n intervalIdMap.clear()\n }\n\n if (timeoutIdMap.size) {\n timeoutIdMap.forEach((_, timeoutId: number) => {\n rawClearTimeout.call(rawWindow, timeoutId)\n })\n timeoutIdMap.clear()\n }\n\n // Clear the function bound by micro application through document.onclick\n documentClickListMap.delete(appName)\n\n // Clear document binding event\n const documentAppListenersMap = documentEventListenerMap.get(appName)\n if (documentAppListenersMap) {\n documentAppListenersMap.forEach((listenerList, type) => {\n for (const listener of listenerList) {\n rawDocumentRemoveEventListener.call(rawDocument, type, listener)\n }\n })\n documentAppListenersMap.clear()\n }\n }\n\n return {\n recordUmdEffect,\n rebuildUmdEffect,\n releaseEffect,\n }\n}\n","import { CallableFunctionForInteract } from '@micro-app/types'\nimport EventCenter from './event_center'\nimport { appInstanceMap } from '../create_app'\nimport {\n removeDomScope,\n isString,\n isFunction,\n isPlainObject,\n formatAppName,\n logError,\n getRootContainer,\n} from '../libs/utils'\n\nconst eventCenter = new EventCenter()\n\n/**\n * Format event name\n * @param appName app.name\n * @param fromBaseApp is from base app\n */\nfunction formatEventName (appName: string, fromBaseApp: boolean): string {\n if (!isString(appName) || !appName) return ''\n return fromBaseApp ? `__from_base_app_${appName}__` : `__from_micro_app_${appName}__`\n}\n\n// Global data\nclass EventCenterForGlobal {\n /**\n * add listener of global data\n * @param cb listener\n * @param autoTrigger If there is cached data when first bind listener, whether it needs to trigger, default is false\n */\n addGlobalDataListener (cb: CallableFunctionForInteract, autoTrigger?: boolean): void {\n const appName = (this as any).appName\n // if appName exists, this is in sub app\n if (appName) {\n cb.__APP_NAME__ = appName\n cb.__AUTO_TRIGGER__ = autoTrigger\n }\n eventCenter.on('global', cb, autoTrigger)\n }\n\n /**\n * remove listener of global data\n * @param cb listener\n */\n removeGlobalDataListener (cb: CallableFunctionForInteract): void {\n isFunction(cb) && eventCenter.off('global', cb)\n }\n\n /**\n * dispatch global data\n * @param data data\n */\n setGlobalData (data: Record<PropertyKey, unknown>): void {\n // clear dom scope before dispatch global data, apply to micro app\n removeDomScope()\n\n eventCenter.dispatch('global', data)\n }\n\n /**\n * get global data\n */\n getGlobalData (): Record<PropertyKey, unknown> | null {\n return eventCenter.getData('global')\n }\n\n /**\n * clear all listener of global data\n * if appName exists, only the specified functions is cleared\n * if appName not exists, only clear the base app functions\n */\n clearGlobalDataListener (): void {\n const appName = (this as any).appName\n const eventInfo = eventCenter.eventList.get('global')\n if (eventInfo) {\n for (const cb of eventInfo.callbacks) {\n if (\n (appName && appName === cb.__APP_NAME__) ||\n !(appName || cb.__APP_NAME__)\n ) {\n eventInfo.callbacks.delete(cb)\n }\n }\n }\n }\n}\n\n// Event center for base app\nexport class EventCenterForBaseApp extends EventCenterForGlobal {\n /**\n * add listener\n * @param appName app.name\n * @param cb listener\n * @param autoTrigger If there is cached data when first bind listener, whether it needs to trigger, default is false\n */\n addDataListener (appName: string, cb: CallableFunction, autoTrigger?: boolean): void {\n eventCenter.on(formatEventName(formatAppName(appName), false), cb, autoTrigger)\n }\n\n /**\n * remove listener\n * @param appName app.name\n * @param cb listener\n */\n removeDataListener (appName: string, cb: CallableFunction): void {\n isFunction(cb) && eventCenter.off(formatEventName(formatAppName(appName), false), cb)\n }\n\n /**\n * get data from micro app or base app\n * @param appName app.name\n * @param fromBaseApp whether get data from base app, default is false\n */\n getData (appName: string, fromBaseApp = false): Record<PropertyKey, unknown> | null {\n return eventCenter.getData(formatEventName(formatAppName(appName), fromBaseApp))\n }\n\n /**\n * Dispatch data to the specified micro app\n * @param appName app.name\n * @param data data\n */\n setData (appName: string, data: Record<PropertyKey, unknown>): void {\n eventCenter.dispatch(formatEventName(formatAppName(appName), true), data)\n }\n\n /**\n * clear all listener for specified micro app\n * @param appName app.name\n */\n clearDataListener (appName: string): void {\n eventCenter.off(formatEventName(formatAppName(appName), false))\n }\n}\n\n// Event center for sub app\nexport class EventCenterForMicroApp extends EventCenterForGlobal {\n appName: string\n umdDataListeners?: {\n global: Set<CallableFunctionForInteract>,\n normal: Set<CallableFunctionForInteract>,\n }\n\n constructor (appName: string) {\n super()\n this.appName = formatAppName(appName)\n !this.appName && logError(`Invalid appName ${appName}`)\n }\n\n /**\n * add listener, monitor the data sent by the base app\n * @param cb listener\n * @param autoTrigger If there is cached data when first bind listener, whether it needs to trigger, default is false\n */\n addDataListener (cb: CallableFunctionForInteract, autoTrigger?: boolean): void {\n cb.__AUTO_TRIGGER__ = autoTrigger\n eventCenter.on(formatEventName(this.appName, true), cb, autoTrigger)\n }\n\n /**\n * remove listener\n * @param cb listener\n */\n removeDataListener (cb: CallableFunctionForInteract): void {\n isFunction(cb) && eventCenter.off(formatEventName(this.appName, true), cb)\n }\n\n /**\n * get data from base app\n */\n getData (): Record<PropertyKey, unknown> | null {\n return eventCenter.getData(formatEventName(this.appName, true))\n }\n\n /**\n * dispatch data to base app\n * @param data data\n */\n dispatch (data: Record<PropertyKey, unknown>): void {\n removeDomScope()\n\n eventCenter.dispatch(formatEventName(this.appName, false), data)\n\n const app = appInstanceMap.get(this.appName)\n if (app?.container && isPlainObject(data)) {\n const event = new CustomEvent('datachange', {\n detail: {\n data,\n }\n })\n\n getRootContainer(app.container).dispatchEvent(event)\n }\n }\n\n /**\n * clear all listeners\n */\n clearDataListener (): void {\n eventCenter.off(formatEventName(this.appName, true))\n }\n}\n\n/**\n * Record UMD function before exec umdHookMount\n * @param microAppEventCneter\n */\nexport function recordDataCenterSnapshot (microAppEventCneter: EventCenterForMicroApp): void {\n const appName = microAppEventCneter.appName\n microAppEventCneter.umdDataListeners = { global: new Set(), normal: new Set() }\n\n const globalEventInfo = eventCenter.eventList.get('global')\n if (globalEventInfo) {\n for (const cb of globalEventInfo.callbacks) {\n if (appName === cb.__APP_NAME__) {\n microAppEventCneter.umdDataListeners.global.add(cb)\n }\n }\n }\n\n const subAppEventInfo = eventCenter.eventList.get(formatEventName(appName, true))\n if (subAppEventInfo) {\n microAppEventCneter.umdDataListeners.normal = new Set(subAppEventInfo.callbacks)\n }\n}\n\n/**\n * Rebind the UMD function of the record before remount\n * @param microAppEventCneter instance of EventCenterForMicroApp\n */\nexport function rebuildDataCenterSnapshot (microAppEventCneter: EventCenterForMicroApp): void {\n for (const cb of microAppEventCneter.umdDataListeners!.global) {\n microAppEventCneter.addGlobalDataListener(cb, cb.__AUTO_TRIGGER__)\n }\n\n for (const cb of microAppEventCneter.umdDataListeners!.normal) {\n microAppEventCneter.addDataListener(cb, cb.__AUTO_TRIGGER__)\n }\n}\n","import { CallableFunctionForInteract } from '@micro-app/types'\nimport { logError, isFunction, isPlainObject } from '../libs/utils'\n\nexport default class EventCenter {\n eventList = new Map<string, {\n data: Record<PropertyKey, unknown>,\n callbacks: Set<CallableFunctionForInteract>,\n }>()\n\n // whether the name is legal\n isLegalName (name: string): boolean {\n if (!name) {\n logError('event-center: Invalid name')\n return false\n }\n\n return true\n }\n\n /**\n * add listener\n * @param name event name\n * @param f listener\n * @param autoTrigger If there is cached data when first bind listener, whether it needs to trigger, default is false\n */\n on (name: string, f: CallableFunctionForInteract, autoTrigger = false): void {\n if (this.isLegalName(name)) {\n if (!isFunction(f)) {\n return logError('event-center: Invalid callback function')\n }\n\n let eventInfo = this.eventList.get(name)\n if (!eventInfo) {\n eventInfo = {\n data: {},\n callbacks: new Set(),\n }\n this.eventList.set(name, eventInfo)\n } else if (autoTrigger && Object.getOwnPropertyNames(eventInfo.data).length) {\n // auto trigger when data not null\n f(eventInfo.data)\n }\n\n eventInfo.callbacks.add(f)\n }\n }\n\n // remove listener, but the data is not cleared\n off (name: string, f?: CallableFunctionForInteract): void {\n if (this.isLegalName(name)) {\n const eventInfo = this.eventList.get(name)\n if (eventInfo) {\n if (isFunction(f)) {\n eventInfo.callbacks.delete(f!)\n } else {\n eventInfo.callbacks.clear()\n }\n }\n }\n }\n\n // dispatch data\n dispatch (name: string, data: Record<PropertyKey, unknown>): void {\n if (this.isLegalName(name)) {\n if (!isPlainObject(data)) {\n return logError('event-center: data must be object')\n }\n let eventInfo = this.eventList.get(name)\n if (eventInfo) {\n // Update when the data is not equal\n if (eventInfo.data !== data) {\n eventInfo.data = data\n for (const f of eventInfo.callbacks) {\n f(data)\n }\n }\n } else {\n eventInfo = {\n data: data,\n callbacks: new Set(),\n }\n this.eventList.set(name, eventInfo)\n }\n }\n }\n\n // get data\n getData (name: string): Record<PropertyKey, unknown> | null {\n const eventInfo = this.eventList.get(name)\n return eventInfo?.data ?? null\n }\n}\n","import type { SandBoxInterface, microWindowType } from '@micro-app/types'\nimport bindFunctionToRawWidow from './bind_function'\nimport {\n unique,\n setCurrentAppName,\n defer,\n getEffectivePath,\n removeDomScope,\n isString,\n isPlainObject,\n isArray,\n} from '../libs/utils'\nimport effect, { effectDocumentEvent, releaseEffectDocumentEvent } from './effect'\nimport {\n EventCenterForMicroApp,\n recordDataCenterSnapshot,\n rebuildDataCenterSnapshot,\n} from '../interact'\nimport microApp from '../micro_app'\nimport globalEnv from '../libs/global_env'\n\n/* eslint-disable camelcase */\ntype injectDataType = {\n __MICRO_APP_ENVIRONMENT__: boolean\n __MICRO_APP_NAME__: string\n __MICRO_APP_PUBLIC_PATH__: string\n __MICRO_APP_BASE_URL__: string\n __MICRO_APP_BASE_ROUTE__: string\n __MICRO_APP_UMDMODE__: boolean\n microApp: EventCenterForMicroApp\n rawWindow: Window\n rawDocument: Document\n removeDomScope: () => void\n}\n\n// Variables that can escape to rawWindow\nconst staticEscapeProperties: PropertyKey[] = [\n 'System',\n '__cjsWrapper',\n '__REACT_ERROR_OVERLAY_GLOBAL_HOOK__',\n]\n\n// Variables that can only assigned to rawWindow\nconst escapeSetterKeyList: PropertyKey[] = [\n 'location',\n]\n\nconst unscopables = {\n undefined: true,\n Array: true,\n Object: true,\n String: true,\n Boolean: true,\n Math: true,\n Number: true,\n Symbol: true,\n parseFloat: true,\n Float32Array: true,\n}\n\n/**\n * macro task to solve the rendering problem of vue3\n */\nlet macroTimer: number\nfunction macroTask (fn: TimerHandler): void {\n macroTimer && clearTimeout(macroTimer)\n macroTimer = setTimeout(fn, 0)\n}\n\nexport default class SandBox implements SandBoxInterface {\n static activeCount = 0 // number of active sandbox\n // @ts-ignore\n private recordUmdEffect: CallableFunction\n // @ts-ignore\n private rebuildUmdEffect: CallableFunction\n // @ts-ignore\n private releaseEffect: CallableFunction\n // Scoped global Properties(Properties that can only get and set in microWindow, will not escape to rawWindow)\n private scopeProperties: PropertyKey[] = ['webpackJsonp']\n // Properties that can be escape to rawWindow\n private escapeProperties: PropertyKey[] = []\n // Properties newly added to microWindow\n private injectedKeys = new Set<PropertyKey>()\n // Properties escape to rawWindow, cleared when unmount\n private escapeKeys = new Set<PropertyKey>()\n // record injected values before the first execution of umdHookMount and rebuild before remount umd app\n private recordUmdinjectedValues?: Map<PropertyKey, unknown>\n // sandbox state\n private active = false\n proxyWindow: WindowProxy & injectDataType // Proxy\n microWindow = {} as Window & injectDataType // Proxy target\n\n constructor (appName: string, url: string, macro: boolean) {\n const rawWindow = globalEnv.rawWindow\n const rawDocument = globalEnv.rawDocument\n const descriptorTargetMap = new Map<PropertyKey, 'target' | 'rawWindow'>()\n const hasOwnProperty = (key: PropertyKey) => this.microWindow.hasOwnProperty(key) || rawWindow.hasOwnProperty(key)\n // get scopeProperties and escapeProperties from plugins\n this.getScopeProperties(appName)\n // inject global properties\n this.inject(this.microWindow, appName, url)\n // Rewrite global event listener & timeout\n Object.assign(this, effect(this.microWindow))\n\n this.proxyWindow = new Proxy(this.microWindow, {\n get: (target: microWindowType, key: PropertyKey): unknown => {\n if (key === Symbol.unscopables) return unscopables\n\n if (['window', 'self', 'globalThis'].includes(key as string)) {\n return this.proxyWindow\n }\n\n if (key === 'top' || key === 'parent') {\n if (rawWindow === rawWindow.parent) { // not in iframe\n return this.proxyWindow\n }\n return Reflect.get(rawWindow, key) // iframe\n }\n\n if (key === 'hasOwnProperty') return hasOwnProperty\n\n if (key === 'document' || key === 'eval') {\n if (this.active) {\n setCurrentAppName(appName)\n ;(macro ? macroTask : defer)(() => setCurrentAppName(null))\n }\n switch (key) {\n case 'document':\n return rawDocument\n case 'eval':\n return eval\n }\n }\n\n if (Reflect.has(target, key)) {\n return Reflect.get(target, key)\n }\n\n if (\n this.scopeProperties.includes(key) ||\n (isString(key) && /^__MICRO_APP_/.test(key))\n ) {\n return Reflect.get(target, key)\n }\n\n const rawValue = Reflect.get(rawWindow, key)\n\n return bindFunctionToRawWidow(rawWindow, rawValue)\n },\n set: (target: microWindowType, key: PropertyKey, value: unknown): boolean => {\n if (this.active) {\n if (escapeSetterKeyList.includes(key)) {\n Reflect.set(rawWindow, key, value)\n } else if (\n !target.hasOwnProperty(key) &&\n rawWindow.hasOwnProperty(key) &&\n !this.scopeProperties.includes(key)\n ) {\n const descriptor = Object.getOwnPropertyDescriptor(rawWindow, key)\n const { writable, configurable, enumerable } = descriptor!\n if (writable) {\n Object.defineProperty(target, key, {\n configurable,\n enumerable,\n writable,\n value,\n })\n this.injectedKeys.add(key)\n }\n } else {\n Reflect.set(target, key, value)\n this.injectedKeys.add(key)\n }\n\n if (\n (\n this.escapeProperties.includes(key) ||\n (staticEscapeProperties.includes(key) && !Reflect.has(rawWindow, key))\n ) &&\n !this.scopeProperties.includes(key)\n ) {\n Reflect.set(rawWindow, key, value)\n this.escapeKeys.add(key)\n }\n }\n\n return true\n },\n has: (target: microWindowType, key: PropertyKey): boolean => {\n if (this.scopeProperties.includes(key)) return key in target\n return key in unscopables || key in target || key in rawWindow\n },\n // Object.getOwnPropertyDescriptor(window, key)\n // TODO: use set\n getOwnPropertyDescriptor: (target: microWindowType, key: PropertyKey): PropertyDescriptor|undefined => {\n if (target.hasOwnProperty(key)) {\n descriptorTargetMap.set(key, 'target')\n return Object.getOwnPropertyDescriptor(target, key)\n }\n\n if (rawWindow.hasOwnProperty(key)) {\n // like console, alert ...\n descriptorTargetMap.set(key, 'rawWindow')\n const descriptor = Object.getOwnPropertyDescriptor(rawWindow, key)\n if (descriptor && !descriptor.configurable) {\n descriptor.configurable = true\n }\n return descriptor\n }\n\n return undefined\n },\n // Object.defineProperty(window, key, Descriptor)\n defineProperty: (target: microWindowType, key: PropertyKey, value: PropertyDescriptor): boolean => {\n const from = descriptorTargetMap.get(key)\n if (from === 'rawWindow') {\n return Reflect.defineProperty(rawWindow, key, value)\n }\n return Reflect.defineProperty(target, key, value)\n },\n // Object.getOwnPropertyNames(window)\n ownKeys: (target: microWindowType): Array<string | symbol> => {\n return unique(Reflect.ownKeys(rawWindow).concat(Reflect.ownKeys(target)))\n },\n deleteProperty: (target: microWindowType, key: PropertyKey): boolean => {\n if (target.hasOwnProperty(key)) {\n this.injectedKeys.has(key) && this.injectedKeys.delete(key)\n this.escapeKeys.has(key) && Reflect.deleteProperty(rawWindow, key)\n return Reflect.deleteProperty(target, key)\n }\n return true\n },\n })\n }\n\n start (baseroute: string): void {\n if (!this.active) {\n this.active = true\n this.microWindow.__MICRO_APP_BASE_ROUTE__ = this.microWindow.__MICRO_APP_BASE_URL__ = baseroute\n // BUG FIX: bable-polyfill@6.x\n globalEnv.rawWindow._babelPolyfill && (globalEnv.rawWindow._babelPolyfill = false)\n if (++SandBox.activeCount === 1) {\n effectDocumentEvent()\n }\n }\n }\n\n stop (): void {\n if (this.active) {\n this.active = false\n this.releaseEffect()\n this.microWindow.microApp.clearDataListener()\n this.microWindow.microApp.clearGlobalDataListener()\n\n this.injectedKeys.forEach((key: PropertyKey) => {\n Reflect.deleteProperty(this.microWindow, key)\n })\n this.injectedKeys.clear()\n\n this.escapeKeys.forEach((key: PropertyKey) => {\n Reflect.deleteProperty(globalEnv.rawWindow, key)\n })\n this.escapeKeys.clear()\n\n if (--SandBox.activeCount === 0) {\n releaseEffectDocumentEvent()\n }\n }\n }\n\n // record umd snapshot before the first execution of umdHookMount\n recordUmdSnapshot (): void {\n this.microWindow.__MICRO_APP_UMD_MODE__ = true\n this.recordUmdEffect()\n recordDataCenterSnapshot(this.microWindow.microApp)\n\n this.recordUmdinjectedValues = new Map<PropertyKey, unknown>()\n this.injectedKeys.forEach((key: PropertyKey) => {\n this.recordUmdinjectedValues!.set(key, Reflect.get(this.microWindow, key))\n })\n }\n\n // rebuild umd snapshot before remount umd app\n rebuildUmdSnapshot (): void {\n this.recordUmdinjectedValues!.forEach((value: unknown, key: PropertyKey) => {\n Reflect.set(this.proxyWindow, key, value)\n })\n this.rebuildUmdEffect()\n rebuildDataCenterSnapshot(this.microWindow.microApp)\n }\n\n /**\n * get scopeProperties and escapeProperties from plugins\n * @param appName app name\n */\n private getScopeProperties (appName: string): void {\n if (!isPlainObject(microApp.plugins)) return\n\n if (isArray(microApp.plugins!.global)) {\n for (const plugin of microApp.plugins!.global) {\n if (isPlainObject(plugin)) {\n if (isArray(plugin.scopeProperties)) {\n this.scopeProperties = this.scopeProperties.concat(plugin.scopeProperties!)\n }\n if (isArray(plugin.escapeProperties)) {\n this.escapeProperties = this.escapeProperties.concat(plugin.escapeProperties!)\n }\n }\n }\n }\n\n if (isArray(microApp.plugins!.modules?.[appName])) {\n for (const plugin of microApp.plugins!.modules![appName]) {\n if (isPlainObject(plugin)) {\n if (isArray(plugin.scopeProperties)) {\n this.scopeProperties = this.scopeProperties.concat(plugin.scopeProperties!)\n }\n if (isArray(plugin.escapeProperties)) {\n this.escapeProperties = this.escapeProperties.concat(plugin.escapeProperties!)\n }\n }\n }\n }\n }\n\n /**\n * inject global properties to microWindow\n * @param microWindow micro window\n * @param appName app name\n * @param url app url\n */\n private inject (microWindow: microWindowType, appName: string, url: string): void {\n microWindow.__MICRO_APP_ENVIRONMENT__ = true\n microWindow.__MICRO_APP_NAME__ = appName\n microWindow.__MICRO_APP_PUBLIC_PATH__ = getEffectivePath(url)\n microWindow.microApp = new EventCenterForMicroApp(appName)\n microWindow.rawWindow = globalEnv.rawWindow\n microWindow.rawDocument = globalEnv.rawDocument\n microWindow.removeDomScope = removeDomScope\n }\n}\n","import microApp from '../micro_app'\nimport { logError, isFunction, removeDomScope, getRootContainer } from '../libs/utils'\n\nfunction eventHandler (event: CustomEvent, element: HTMLElement): void {\n Object.defineProperties(event, {\n currentTarget: {\n get () {\n return element\n }\n },\n target: {\n get () {\n return element\n }\n },\n })\n}\n\n/**\n * dispatch lifeCycles event to base app\n * created, beforemount, mounted, unmount, error\n * @param element container\n * @param appName app.name\n * @param lifecycleName lifeCycle name\n * @param error param from error hook\n */\nexport default function dispatchLifecyclesEvent (\n element: HTMLElement | ShadowRoot,\n appName: string,\n lifecycleName: string,\n error?: Error,\n): void {\n if (!element) {\n return logError(`element does not exist in lifecycle ${lifecycleName}`, appName)\n }\n\n element = getRootContainer(element)\n\n // clear dom scope before dispatch lifeCycles event to base app, especially mounted & unmount\n removeDomScope()\n\n const detail = Object.assign({\n name: appName,\n container: element,\n }, error && {\n error\n })\n\n const event = new CustomEvent(lifecycleName, {\n detail,\n })\n\n eventHandler(event, element)\n // global hooks\n // @ts-ignore\n if (isFunction(microApp.lifeCycles?.[lifecycleName])) {\n // @ts-ignore\n microApp.lifeCycles[lifecycleName](event)\n }\n\n element.dispatchEvent(event)\n}\n\n/**\n * Dispatch unmount event to micro app\n * @param appName app.name\n */\nexport function dispatchUnmountToMicroApp (appName: string): void {\n const event = new CustomEvent(`unmount-${appName}`)\n window.dispatchEvent(event)\n}\n","import type {\n AppInterface,\n sourceType,\n SandBoxInterface,\n sourceLinkInfo,\n sourceScriptInfo,\n Func,\n} from '@micro-app/types'\nimport extractHtml from './source'\nimport { execScripts } from './source/scripts'\nimport { appStatus, lifeCycles } from './constants'\nimport SandBox from './sandbox'\nimport {\n isFunction,\n cloneContainer,\n isBoolean,\n isPromise,\n logError,\n getRootContainer,\n} from './libs/utils'\nimport dispatchLifecyclesEvent, { dispatchUnmountToMicroApp } from './interact/lifecycles_event'\nimport globalEnv from './libs/global_env'\n\n// micro app instances\nexport const appInstanceMap = new Map<string, AppInterface>()\n\n// params of CreateApp\nexport interface CreateAppParam {\n name: string\n url: string\n ssrUrl?: string\n scopecss: boolean\n useSandbox: boolean\n macro?: boolean\n inline?: boolean\n baseroute?: string\n container?: HTMLElement | ShadowRoot\n}\n\nexport default class CreateApp implements AppInterface {\n private status: string = appStatus.NOT_LOADED\n private loadSourceLevel: -1|0|1|2 = 0\n private umdHookMount: Func | null = null\n private umdHookUnmount: Func | null = null\n private libraryName: string | null = null\n umdMode = false\n isPrefetch = false\n name: string\n url: string\n ssrUrl: string\n container: HTMLElement | ShadowRoot | null = null\n inline: boolean\n scopecss: boolean\n useSandbox: boolean\n macro = false\n baseroute = ''\n source: sourceType\n sandBox: SandBoxInterface | null = null\n\n constructor ({\n name,\n url,\n ssrUrl,\n container,\n inline,\n scopecss,\n useSandbox,\n macro,\n baseroute,\n }: CreateAppParam) {\n this.container = container ?? null\n this.inline = inline ?? false\n this.baseroute = baseroute ?? ''\n this.ssrUrl = ssrUrl ?? ''\n // optional during init👆\n this.name = name\n this.url = url\n this.useSandbox = useSandbox\n this.scopecss = this.useSandbox && scopecss\n this.macro = macro ?? false\n this.source = {\n links: new Map<string, sourceLinkInfo>(),\n scripts: new Map<string, sourceScriptInfo>(),\n }\n this.loadSourceCode()\n this.useSandbox && (this.sandBox = new SandBox(name, url, this.macro))\n }\n\n // Load resources\n loadSourceCode (): void {\n this.status = appStatus.LOADING_SOURCE_CODE\n extractHtml(this)\n }\n\n /**\n * When resource is loaded, mount app if it is not prefetch or unmount\n */\n onLoad (html: HTMLElement): void {\n if (++this.loadSourceLevel === 2) {\n this.source.html = html\n\n if (this.isPrefetch || appStatus.UNMOUNT === this.status) return\n\n this.status = appStatus.LOAD_SOURCE_FINISHED\n\n this.mount()\n }\n }\n\n /**\n * Error loading HTML\n * @param e Error\n */\n onLoadError (e: Error): void {\n this.loadSourceLevel = -1\n if (appStatus.UNMOUNT !== this.status) {\n this.onerror(e)\n this.status = appStatus.LOAD_SOURCE_ERROR\n }\n }\n\n /**\n * mount app\n * @param container app container\n * @param inline js runs in inline mode\n * @param baseroute route prefix, default is ''\n */\n mount (\n container?: HTMLElement | ShadowRoot,\n inline?: boolean,\n baseroute?: string,\n ): void {\n if (isBoolean(inline) && inline !== this.inline) {\n this.inline = inline\n }\n\n this.container = this.container ?? container!\n this.baseroute = baseroute ?? this.baseroute\n\n if (this.loadSourceLevel !== 2) {\n this.status = appStatus.LOADING_SOURCE_CODE\n return\n }\n\n dispatchLifecyclesEvent(\n this.container as HTMLElement,\n this.name,\n lifeCycles.BEFOREMOUNT,\n )\n\n this.status = appStatus.MOUNTING\n\n cloneContainer(this.source.html as Element, this.container as Element, !this.umdMode)\n\n this.sandBox?.start(this.baseroute)\n\n let umdHookMountResult: any // result of mount function\n\n if (!this.umdMode) {\n let hasDispatchMountedEvent = false\n // if all js are executed, param isFinished will be true\n execScripts(this.source.scripts, this, (isFinished: boolean) => {\n if (!this.umdMode) {\n const { mount, unmount } = this.getUmdLibraryHooks()\n // if mount & unmount is function, the sub app is umd mode\n if (isFunction(mount) && isFunction(unmount)) {\n this.umdHookMount = mount as Func\n this.umdHookUnmount = unmount as Func\n this.umdMode = true\n this.sandBox?.recordUmdSnapshot()\n try {\n umdHookMountResult = this.umdHookMount()\n } catch (e) {\n logError('an error occurred in the mount function \\n', this.name, e)\n }\n }\n }\n\n if (!hasDispatchMountedEvent && (isFinished === true || this.umdMode)) {\n hasDispatchMountedEvent = true\n this.handleMounted(umdHookMountResult)\n }\n })\n } else {\n this.sandBox?.rebuildUmdSnapshot()\n try {\n umdHookMountResult = this.umdHookMount!()\n } catch (e) {\n logError('an error occurred in the mount function \\n', this.name, e)\n }\n this.handleMounted(umdHookMountResult)\n }\n }\n\n /**\n * handle for promise umdHookMount\n * @param umdHookMountResult result of umdHookMount\n */\n private handleMounted (umdHookMountResult: any): void {\n if (isPromise(umdHookMountResult)) {\n umdHookMountResult\n .then(() => this.dispatchMountedEvent())\n .catch((e: Error) => this.onerror(e))\n } else {\n this.dispatchMountedEvent()\n }\n }\n\n /**\n * dispatch mounted event when app run finished\n */\n private dispatchMountedEvent (): void {\n if (appStatus.UNMOUNT !== this.status) {\n this.status = appStatus.MOUNTED\n dispatchLifecyclesEvent(\n this.container as HTMLElement,\n this.name,\n lifeCycles.MOUNTED,\n )\n }\n }\n\n /**\n * unmount app\n * @param destroy completely destroy, delete cache resources\n */\n unmount (destroy: boolean): void {\n if (this.status === appStatus.LOAD_SOURCE_ERROR) {\n destroy = true\n }\n\n this.status = appStatus.UNMOUNT\n\n // result of unmount function\n let umdHookUnmountResult: any\n /**\n * send an unmount event to the micro app or call umd unmount hook\n * before the sandbox is cleared\n */\n if (this.umdHookUnmount) {\n try {\n umdHookUnmountResult = this.umdHookUnmount()\n } catch (e) {\n logError('an error occurred in the unmount function \\n', this.name, e)\n }\n }\n\n // dispatch unmount event to micro app\n dispatchUnmountToMicroApp(this.name)\n\n this.handleUnmounted(destroy, umdHookUnmountResult)\n }\n\n /**\n * handle for promise umdHookUnmount\n * @param umdHookUnmountResult result of umdHookUnmount\n */\n private handleUnmounted (destroy: boolean, umdHookUnmountResult: any): void {\n if (isPromise(umdHookUnmountResult)) {\n umdHookUnmountResult\n .then(() => this.actionsForUnmount(destroy))\n .catch(() => this.actionsForUnmount(destroy))\n } else {\n this.actionsForUnmount(destroy)\n }\n }\n\n /**\n * actions for unmount app\n * @param destroy completely destroy, delete cache resources\n */\n private actionsForUnmount (destroy: boolean): void {\n // dispatch unmount event to base app\n dispatchLifecyclesEvent(\n this.container as HTMLElement,\n this.name,\n lifeCycles.UNMOUNT,\n )\n\n this.sandBox?.stop()\n\n if (destroy) {\n this.actionsForCompletelyDestory()\n } else if (this.umdMode && (this.container as Element).childElementCount) {\n /**\n * In umd mode, ui frameworks will no longer create style elements to head in lazy load page when render again, so we should save container to keep these elements\n */\n cloneContainer(this.container as Element, this.source.html as Element, false)\n }\n\n this.container = null\n }\n\n // actions for completely destroy\n actionsForCompletelyDestory (): void {\n if (!this.useSandbox && this.umdMode) {\n delete window[this.libraryName as any]\n }\n appInstanceMap.delete(this.name)\n }\n\n /**\n * app rendering error\n * @param e Error\n */\n onerror (e: Error): void {\n dispatchLifecyclesEvent(\n this.container as HTMLElement,\n this.name,\n lifeCycles.ERROR,\n e,\n )\n }\n\n // get app status\n getAppStatus (): string {\n return this.status\n }\n\n // get umd library, if it not exist, return empty object\n private getUmdLibraryHooks (): Record<string, unknown> {\n // after execScripts, the app maybe unmounted\n if (appStatus.UNMOUNT !== this.status) {\n const global = (this.sandBox?.proxyWindow ?? globalEnv.rawWindow) as any\n this.libraryName = getRootContainer(this.container!).getAttribute('library') || `micro-app-${this.name}`\n // do not use isObject\n return typeof global[this.libraryName] === 'object' ? global[this.libraryName] : {}\n }\n\n return {}\n }\n}\n\n// if app not prefetch & not unmount, then app is active\nexport function getActiveApps (): string[] {\n const activeApps: string[] = []\n appInstanceMap.forEach((app: AppInterface, appName: string) => {\n if (appStatus.UNMOUNT !== app.getAppStatus() && !app.isPrefetch) {\n activeApps.push(appName)\n }\n })\n\n return activeApps\n}\n\n// get all registered apps\nexport function getAllApps (): string[] {\n return Array.from(appInstanceMap.keys())\n}\n","import type { Func, AppInterface } from '@micro-app/types'\nimport { appInstanceMap } from '../create_app'\nimport {\n CompletionPath,\n getCurrentAppName,\n pureCreateElement,\n setCurrentAppName,\n logWarn,\n isPlainObject,\n isString,\n isInvalidQuerySelectorKey,\n isUniqueElement,\n} from '../libs/utils'\nimport scopedCSS from './scoped_css'\nimport { extractLinkFromHtml, foramtDynamicLink } from './links'\nimport { extractScriptElement, runScript, runDynamicRemoteScript } from './scripts'\nimport microApp from '../micro_app'\nimport globalEnv from '../libs/global_env'\n\n// Record element and map element\nconst dynamicElementInMicroAppMap = new WeakMap<Node, Element | Comment>()\n\n/**\n * Process the new node and format the style, link and script element\n * @param parent parent node\n * @param child new node\n * @param app app\n */\nfunction handleNewNode (parent: Node, child: Node, app: AppInterface): Node {\n if (child instanceof HTMLStyleElement) {\n if (child.hasAttribute('exclude')) {\n const replaceComment = document.createComment('style element with exclude attribute ignored by micro-app')\n dynamicElementInMicroAppMap.set(child, replaceComment)\n return replaceComment\n } else if (app.scopecss && !child.hasAttribute('ignore')) {\n return scopedCSS(child, app)\n }\n return child\n } else if (child instanceof HTMLLinkElement) {\n if (child.hasAttribute('exclude')) {\n const linkReplaceComment = document.createComment('link element with exclude attribute ignored by micro-app')\n dynamicElementInMicroAppMap.set(child, linkReplaceComment)\n return linkReplaceComment\n } else if (child.hasAttribute('ignore')) {\n return child\n }\n\n const { url, info, replaceComment } = extractLinkFromHtml(\n child,\n parent,\n app,\n true,\n )\n\n if (url && info) {\n const replaceStyle = pureCreateElement('style')\n replaceStyle.__MICRO_APP_LINK_PATH__ = url\n foramtDynamicLink(url, info, app, child, replaceStyle)\n dynamicElementInMicroAppMap.set(child, replaceStyle)\n return replaceStyle\n } else if (replaceComment) {\n dynamicElementInMicroAppMap.set(child, replaceComment)\n return replaceComment\n }\n\n return child\n } else if (child instanceof HTMLScriptElement) {\n const { replaceComment, url, info } = extractScriptElement(\n child,\n parent,\n app,\n true,\n ) || {}\n\n if (url && info) {\n if (!info.isExternal) { // inline script\n const replaceElement = runScript(url, app, info, true)\n dynamicElementInMicroAppMap.set(child, replaceElement)\n return replaceElement\n } else { // remote script\n const replaceElement = runDynamicRemoteScript(url, info, app, child)\n dynamicElementInMicroAppMap.set(child, replaceElement)\n return replaceElement\n }\n } else if (replaceComment) {\n dynamicElementInMicroAppMap.set(child, replaceComment)\n return replaceComment\n }\n\n return child\n }\n\n return child\n}\n\n/**\n * Handle the elements inserted into head and body, and execute normally in other cases\n * @param app app\n * @param method raw method\n * @param parent parent node\n * @param targetChild target node\n * @param passiveChild second param of insertBefore and replaceChild\n */\nfunction invokePrototypeMethod (\n app: AppInterface,\n rawMethod: Func,\n parent: Node,\n targetChild: Node,\n passiveChild?: Node | null,\n): any {\n /**\n * If passiveChild is not the child node, insertBefore replaceChild will have a problem, at this time, it will be degraded to appendChild\n * E.g: document.head.insertBefore(targetChild, document.head.childNodes[0])\n */\n if (parent === document.head) {\n const microAppHead = app.container!.querySelector('micro-app-head')!\n /**\n * 1. If passivechild exists, it must be insertBefore or replacechild\n * 2. When removeChild, targetChild may not be in microAppHead or head\n */\n if (passiveChild && !microAppHead.contains(passiveChild)) {\n return globalEnv.rawAppendChild.call(microAppHead, targetChild)\n } else if (rawMethod === globalEnv.rawRemoveChild && !microAppHead.contains(targetChild)) {\n if (parent.contains(targetChild)) {\n return rawMethod.call(parent, targetChild)\n }\n return targetChild\n } else if (rawMethod === globalEnv.rawAppend || rawMethod === globalEnv.rawPrepend) {\n return rawMethod.call(microAppHead, targetChild)\n }\n return rawMethod.call(microAppHead, targetChild, passiveChild)\n } else if (parent === document.body) {\n const microAppBody = app.container!.querySelector('micro-app-body')!\n if (passiveChild && !microAppBody.contains(passiveChild)) {\n return globalEnv.rawAppendChild.call(microAppBody, targetChild)\n } else if (rawMethod === globalEnv.rawRemoveChild && !microAppBody.contains(targetChild)) {\n if (parent.contains(targetChild)) {\n return rawMethod.call(parent, targetChild)\n }\n return targetChild\n } else if (rawMethod === globalEnv.rawAppend || rawMethod === globalEnv.rawPrepend) {\n return rawMethod.call(microAppBody, targetChild)\n }\n return rawMethod.call(microAppBody, targetChild, passiveChild)\n } else if (rawMethod === globalEnv.rawAppend || rawMethod === globalEnv.rawPrepend) {\n return rawMethod.call(parent, targetChild)\n }\n\n return rawMethod.call(parent, targetChild, passiveChild)\n}\n\n// Get the map element\nfunction getMappingNode (node: Node): Node {\n return dynamicElementInMicroAppMap.get(node) ?? node\n}\n\n/**\n * method of handle new node\n * @param parent parent node\n * @param newChild new node\n * @param passiveChild passive node\n * @param rawMethodraw method\n */\nfunction commonElementHander (\n parent: Node,\n newChild: Node,\n passiveChild: Node | null,\n rawMethod: Func,\n) {\n if (newChild?.__MICRO_APP_NAME__) {\n const app = appInstanceMap.get(newChild.__MICRO_APP_NAME__)\n if (app?.container) {\n return invokePrototypeMethod(\n app,\n rawMethod,\n parent,\n handleNewNode(parent, newChild, app),\n passiveChild && getMappingNode(passiveChild),\n )\n } else if (rawMethod === globalEnv.rawAppend || rawMethod === globalEnv.rawPrepend) {\n return rawMethod.call(parent, newChild)\n }\n return rawMethod.call(parent, newChild, passiveChild)\n } else if (rawMethod === globalEnv.rawAppend || rawMethod === globalEnv.rawPrepend) {\n const appName = getCurrentAppName()\n if (!(newChild instanceof Node) && appName) {\n const app = appInstanceMap.get(appName)\n if (app?.container) {\n if (parent === document.head) {\n return rawMethod.call(app.container.querySelector('micro-app-head'), newChild)\n } else if (parent === document.body) {\n return rawMethod.call(app.container.querySelector('micro-app-body'), newChild)\n }\n }\n }\n return rawMethod.call(parent, newChild)\n }\n\n return rawMethod.call(parent, newChild, passiveChild)\n}\n\n/**\n * Rewrite element prototype method\n */\nexport function patchElementPrototypeMethods (): void {\n patchDocument()\n\n // Rewrite setAttribute\n Element.prototype.setAttribute = function setAttribute (key: string, value: string): void {\n if (/^micro-app(-\\S+)?/i.test(this.tagName) && key === 'data') {\n if (isPlainObject(value)) {\n const cloneValue: Record<PropertyKey, unknown> = {}\n Object.getOwnPropertyNames(value).forEach((propertyKey: PropertyKey) => {\n if (!(isString(propertyKey) && propertyKey.indexOf('__') === 0)) {\n // @ts-ignore\n cloneValue[propertyKey] = value[propertyKey]\n }\n })\n this.data = cloneValue\n } else if (value !== '[object Object]') {\n logWarn('property data must be an object', this.getAttribute('name'))\n }\n } else if (\n (\n ((key === 'src' || key === 'srcset') && /^(img|script)$/i.test(this.tagName)) ||\n (key === 'href' && /^link$/i.test(this.tagName))\n ) &&\n this.__MICRO_APP_NAME__ &&\n appInstanceMap.has(this.__MICRO_APP_NAME__)\n ) {\n const app = appInstanceMap.get(this.__MICRO_APP_NAME__)\n globalEnv.rawSetAttribute.call(this, key, CompletionPath(value, app!.url))\n } else {\n globalEnv.rawSetAttribute.call(this, key, value)\n }\n }\n\n // prototype methods of add element👇\n Node.prototype.appendChild = function appendChild<T extends Node> (newChild: T): T {\n return commonElementHander(this, newChild, null, globalEnv.rawAppendChild)\n }\n\n Node.prototype.insertBefore = function insertBefore<T extends Node> (newChild: T, refChild: Node | null): T {\n return commonElementHander(this, newChild, refChild, globalEnv.rawInsertBefore)\n }\n\n Node.prototype.replaceChild = function replaceChild<T extends Node> (newChild: Node, oldChild: T): T {\n return commonElementHander(this, newChild, oldChild, globalEnv.rawReplaceChild)\n }\n\n Element.prototype.append = function append (...nodes: (Node | string)[]): void {\n let i = 0\n const length = nodes.length\n while (i < length) {\n commonElementHander(this, nodes[i] as Node, null, globalEnv.rawAppend)\n i++\n }\n }\n\n Element.prototype.prepend = function prepend (...nodes: (Node | string)[]): void {\n let i = nodes.length\n while (i > 0) {\n commonElementHander(this, nodes[i - 1] as Node, null, globalEnv.rawPrepend)\n i--\n }\n }\n\n // prototype methods of delete element👇\n Node.prototype.removeChild = function removeChild<T extends Node> (oldChild: T): T {\n if (oldChild?.__MICRO_APP_NAME__) {\n const app = appInstanceMap.get(oldChild.__MICRO_APP_NAME__)\n if (app?.container) {\n return invokePrototypeMethod(\n app,\n globalEnv.rawRemoveChild,\n this,\n getMappingNode(oldChild),\n )\n }\n return globalEnv.rawRemoveChild.call(this, oldChild) as T\n }\n\n return globalEnv.rawRemoveChild.call(this, oldChild) as T\n }\n}\n\n/**\n * Mark the newly created element in the micro application\n * @param element new element\n */\nfunction markElement <T extends { __MICRO_APP_NAME__: string }> (element: T): T {\n const appName = getCurrentAppName()\n appName && (element.__MICRO_APP_NAME__ = appName)\n return element\n}\n\n// methods of document\nfunction patchDocument () {\n const rawDocument = globalEnv.rawDocument\n\n // create element 👇\n Document.prototype.createElement = function createElement (\n tagName: string,\n options?: ElementCreationOptions,\n ): HTMLElement {\n const element = globalEnv.rawCreateElement.call(this, tagName, options)\n return markElement(element)\n }\n\n Document.prototype.createElementNS = function createElementNS (\n namespaceURI: string,\n name: string,\n options?: string | ElementCreationOptions,\n ): any {\n const element = globalEnv.rawCreateElementNS.call(this, namespaceURI, name, options)\n return markElement(element)\n }\n\n Document.prototype.createDocumentFragment = function createDocumentFragment (): DocumentFragment {\n const element = globalEnv.rawCreateDocumentFragment.call(this)\n return markElement(element)\n }\n\n // query element👇\n function querySelector (this: Document, selectors: string): any {\n const appName = getCurrentAppName()\n if (\n !appName ||\n !selectors ||\n isUniqueElement(selectors) ||\n // see https://github.com/micro-zoe/micro-app/issues/56\n rawDocument !== this\n ) {\n return globalEnv.rawQuerySelector.call(this, selectors)\n }\n return appInstanceMap.get(appName)?.container?.querySelector(selectors) ?? null\n }\n\n function querySelectorAll (this: Document, selectors: string): any {\n const appName = getCurrentAppName()\n if (\n !appName ||\n !selectors ||\n isUniqueElement(selectors) ||\n rawDocument !== this\n ) {\n return globalEnv.rawQuerySelectorAll.call(this, selectors)\n }\n return appInstanceMap.get(appName)?.container?.querySelectorAll(selectors) ?? []\n }\n\n Document.prototype.querySelector = querySelector\n Document.prototype.querySelectorAll = querySelectorAll\n\n Document.prototype.getElementById = function getElementById (key: string): HTMLElement | null {\n if (!getCurrentAppName() || isInvalidQuerySelectorKey(key)) {\n return globalEnv.rawGetElementById.call(this, key)\n }\n\n try {\n return querySelector.call(this, `#${key}`)\n } catch {\n return globalEnv.rawGetElementById.call(this, key)\n }\n }\n\n Document.prototype.getElementsByClassName = function getElementsByClassName (key: string): HTMLCollectionOf<Element> {\n if (!getCurrentAppName() || isInvalidQuerySelectorKey(key)) {\n return globalEnv.rawGetElementsByClassName.call(this, key)\n }\n\n try {\n return querySelectorAll.call(this, `.${key}`)\n } catch {\n return globalEnv.rawGetElementsByClassName.call(this, key)\n }\n }\n\n Document.prototype.getElementsByTagName = function getElementsByTagName (key: string): HTMLCollectionOf<Element> {\n const appName = getCurrentAppName()\n if (\n !appName ||\n isUniqueElement(key) ||\n isInvalidQuerySelectorKey(key) ||\n (!appInstanceMap.get(appName)?.inline && /^script$/i.test(key))\n ) {\n return globalEnv.rawGetElementsByTagName.call(this, key)\n }\n\n try {\n return querySelectorAll.call(this, key)\n } catch {\n return globalEnv.rawGetElementsByTagName.call(this, key)\n }\n }\n\n Document.prototype.getElementsByName = function getElementsByName (key: string): NodeListOf<HTMLElement> {\n if (!getCurrentAppName() || isInvalidQuerySelectorKey(key)) {\n return globalEnv.rawGetElementsByName.call(this, key)\n }\n\n try {\n return querySelectorAll.call(this, `[name=${key}]`)\n } catch {\n return globalEnv.rawGetElementsByName.call(this, key)\n }\n }\n}\n\nfunction releasePatchDocument (): void {\n Document.prototype.createElement = globalEnv.rawCreateElement\n Document.prototype.createElementNS = globalEnv.rawCreateElementNS\n Document.prototype.createDocumentFragment = globalEnv.rawCreateDocumentFragment\n Document.prototype.querySelector = globalEnv.rawQuerySelector\n Document.prototype.querySelectorAll = globalEnv.rawQuerySelectorAll\n Document.prototype.getElementById = globalEnv.rawGetElementById\n Document.prototype.getElementsByClassName = globalEnv.rawGetElementsByClassName\n Document.prototype.getElementsByTagName = globalEnv.rawGetElementsByTagName\n Document.prototype.getElementsByName = globalEnv.rawGetElementsByName\n}\n\n// release patch\nexport function releasePatches (): void {\n setCurrentAppName(null)\n releasePatchDocument()\n Element.prototype.setAttribute = globalEnv.rawSetAttribute\n Node.prototype.appendChild = globalEnv.rawAppendChild\n Node.prototype.insertBefore = globalEnv.rawInsertBefore\n Node.prototype.replaceChild = globalEnv.rawReplaceChild\n Node.prototype.removeChild = globalEnv.rawRemoveChild\n Element.prototype.append = globalEnv.rawAppend\n Element.prototype.prepend = globalEnv.rawPrepend\n}\n\n// Set the style of micro-app-head and micro-app-body\nlet hasRejectMicroAppStyle = false\nexport function rejectMicroAppStyle (): void {\n if (!hasRejectMicroAppStyle) {\n hasRejectMicroAppStyle = true\n const style = pureCreateElement('style')\n style.setAttribute('type', 'text/css')\n style.textContent = `\\n${microApp.tagName}, micro-app-body { display: block; } \\nmicro-app-head { display: none; }`\n globalEnv.rawDocument.head.appendChild(style)\n }\n}\n","import { appInstanceMap } from '../create_app'\nimport { elementInstanceMap } from '../micro_app_element'\nimport { releasePatches } from '../source/patch'\nimport { getRootContainer } from '../libs/utils'\n\nfunction unmountNestedApp (): void {\n replaseUnmountOfNestedApp()\n\n appInstanceMap.forEach(app => {\n // @ts-ignore\n app.container && getRootContainer(app.container).disconnectedCallback()\n })\n\n !window.__MICRO_APP_UMD_MODE__ && appInstanceMap.clear()\n\n if (elementInstanceMap.size) {\n elementInstanceMap.clear()\n releasePatches()\n }\n}\n\n// if micro-app run in micro application, delete all next generation application when unmount event received\nexport function listenUmountOfNestedApp (): void {\n if (window.__MICRO_APP_ENVIRONMENT__) {\n window.addEventListener('unmount', unmountNestedApp, false)\n }\n}\n\n// release listener\nexport function replaseUnmountOfNestedApp (): void {\n if (window.__MICRO_APP_ENVIRONMENT__) {\n window.removeEventListener('unmount', unmountNestedApp, false)\n }\n}\n","import type { AttrType, MicroAppElementType, AppInterface } from '@micro-app/types'\nimport {\n defer,\n formatAppName,\n formatAppURL,\n version,\n logError,\n logWarn,\n isString,\n isFunction,\n CompletionPath,\n} from './libs/utils'\nimport { ObservedAttrName, appStatus, lifeCycles } from './constants'\nimport CreateApp, { appInstanceMap } from './create_app'\nimport {\n patchElementPrototypeMethods,\n releasePatches,\n rejectMicroAppStyle,\n} from './source/patch'\nimport {\n listenUmountOfNestedApp,\n replaseUnmountOfNestedApp,\n} from './libs/additional'\nimport microApp from './micro_app'\nimport dispatchLifecyclesEvent from './interact/lifecycles_event'\nimport globalEnv from './libs/global_env'\n\n// record all micro-app elements\nexport const elementInstanceMap = new Map<Element, boolean>()\n\n/**\n * define element\n * @param tagName element name\n */\nexport function defineElement (tagName: string): void {\n class MicroAppElement extends HTMLElement implements MicroAppElementType {\n static get observedAttributes (): string[] {\n return ['name', 'url']\n }\n\n constructor () {\n super()\n // cloned node of umd container also trigger constructor, we should skip\n if (!this.querySelector('micro-app-head')) {\n this.performWhenFirstCreated()\n }\n }\n\n private isWating = false\n private cacheData: Record<PropertyKey, unknown> | null = null\n private hasConnected = false\n appName = '' // app name\n appUrl = '' // app url\n ssrUrl = '' // html path in ssr mode\n version = version\n\n // 👇 Configuration\n // name: app name\n // url: html address\n // shadowDom: use shadowDOM, default is false\n // destroy: whether delete cache resources when unmount, default is false\n // inline: whether js runs in inline script mode, default is false\n // disableScopecss: whether disable css scoped, default is false\n // disableSandbox: whether disable sandbox, default is false\n // macro: used to solve the async render problem of vue3, default is false\n // baseRoute: route prefix, default is ''\n\n connectedCallback (): void {\n this.hasConnected = true\n if (!elementInstanceMap.has(this)) {\n this.performWhenFirstCreated()\n }\n\n defer(() => dispatchLifecyclesEvent(\n this,\n this.appName,\n lifeCycles.CREATED,\n ))\n\n this.initialMount()\n }\n\n disconnectedCallback (): void {\n this.hasConnected = false\n elementInstanceMap.delete(this)\n this.handleUnmount(this.getDisposeResult('destroy') || this.getDisposeResult('destory'))\n if (elementInstanceMap.size === 0) {\n releasePatches()\n }\n }\n\n attributeChangedCallback (attr: ObservedAttrName, _oldVal: string, newVal: string): void {\n if (\n this.legalAttribute(attr, newVal) &&\n this[attr === ObservedAttrName.NAME ? 'appName' : 'appUrl'] !== newVal\n ) {\n if (attr === ObservedAttrName.URL && !this.appUrl) {\n newVal = formatAppURL(newVal, this.appName)\n if (!newVal) {\n return logError(`Invalid attribute url ${newVal}`, this.appName)\n }\n this.appUrl = newVal\n this.handleInitialNameAndUrl()\n } else if (attr === ObservedAttrName.NAME && !this.appName) {\n const formatNewName = formatAppName(newVal)\n\n if (!formatNewName) {\n return logError(`Invalid attribute name ${newVal}`, this.appName)\n }\n\n if (this.cacheData) {\n microApp.setData(formatNewName, this.cacheData)\n this.cacheData = null\n }\n\n this.appName = formatNewName\n if (formatNewName !== newVal) {\n this.setAttribute('name', this.appName)\n }\n this.handleInitialNameAndUrl()\n } else if (!this.isWating) {\n this.isWating = true\n defer(this.handleAttributeUpdate)\n }\n }\n }\n\n // handle for connectedCallback run before attributeChangedCallback\n private handleInitialNameAndUrl (): void {\n this.hasConnected && this.initialMount()\n }\n\n // Perform global initialization when the element count is 1\n private performWhenFirstCreated (): void {\n if (elementInstanceMap.set(this, true).size === 1) {\n patchElementPrototypeMethods()\n rejectMicroAppStyle()\n replaseUnmountOfNestedApp()\n listenUmountOfNestedApp()\n }\n }\n\n /**\n * first mount of this app\n */\n private initialMount (): void {\n if (!this.appName || !this.appUrl) return\n\n if (this.getDisposeResult('shadowDOM') && !this.shadowRoot && isFunction(this.attachShadow)) {\n this.attachShadow({ mode: 'open' })\n }\n\n if (this.getDisposeResult('ssr')) {\n this.ssrUrl = CompletionPath(globalEnv.rawWindow.location.pathname, this.appUrl)\n } else if (this.ssrUrl) {\n this.ssrUrl = ''\n }\n\n const app = appInstanceMap.get(this.appName)\n if (app) {\n const existAppUrl = app.ssrUrl || app.url\n const activeAppUrl = this.ssrUrl || this.appUrl\n if (\n existAppUrl === activeAppUrl && (\n app.isPrefetch ||\n app.getAppStatus() === appStatus.UNMOUNT\n )\n ) {\n this.handleAppMount(app)\n } else if (app.isPrefetch || app.getAppStatus() === appStatus.UNMOUNT) {\n /**\n * url is different & old app is unmounted or prefetch, create new app to replace old one\n */\n logWarn(`the ${app.isPrefetch ? 'prefetch' : 'unmounted'} app with url: ${existAppUrl} is replaced by a new app`, this.appName)\n this.handleCreateApp()\n } else {\n logError(`an app named ${this.appName} already exists`, this.appName)\n }\n } else {\n this.handleCreateApp()\n }\n }\n\n /**\n * handle for change of name an url after element inited\n */\n private handleAttributeUpdate = (): void => {\n this.isWating = false\n const formatAttrName = formatAppName(this.getAttribute('name'))\n const formatAttrUrl = formatAppURL(this.getAttribute('url'), this.appName)\n if (this.legalAttribute('name', formatAttrName) && this.legalAttribute('url', formatAttrUrl)) {\n const existApp = appInstanceMap.get(formatAttrName)\n if (formatAttrName !== this.appName && existApp) {\n // handling of cached and non-prefetch apps\n if (appStatus.UNMOUNT !== existApp.getAppStatus() && !existApp.isPrefetch) {\n this.setAttribute('name', this.appName)\n return logError(`an app named ${formatAttrName} already exists`, this.appName)\n }\n }\n\n if (formatAttrName !== this.appName || formatAttrUrl !== this.appUrl) {\n this.handleUnmount(formatAttrName === this.appName)\n\n /**\n * change ssrUrl in ssr mode\n * do not add judgment of formatAttrUrl === this.appUrl\n */\n if (this.getDisposeResult('ssr')) {\n this.ssrUrl = CompletionPath(globalEnv.rawWindow.location.pathname, formatAttrUrl)\n } else if (this.ssrUrl) {\n this.ssrUrl = ''\n }\n\n this.appName = formatAttrName as string\n this.appUrl = formatAttrUrl\n ;(this.shadowRoot ?? this).innerHTML = ''\n if (formatAttrName !== this.getAttribute('name')) {\n this.setAttribute('name', this.appName)\n }\n\n /**\n * when existApp not null:\n * scene1: if formatAttrName and this.appName are equal: exitApp is the current app, the url must be different, existApp has been unmounted\n * scene2: if formatAttrName and this.appName are different: existApp must be prefetch or unmounted, if url is equal, then just mount, if url is different, then create new app to replace existApp\n * scene3: url is different but ssrUrl is equal\n * scene4: url is equal but ssrUrl is different, if url is equal, name must different\n */\n if (\n existApp &&\n existApp.url === this.appUrl &&\n existApp.ssrUrl === this.ssrUrl\n ) {\n // mount app\n this.handleAppMount(existApp)\n } else {\n this.handleCreateApp()\n }\n }\n } else if (formatAttrName !== this.appName) {\n this.setAttribute('name', this.appName)\n }\n }\n\n /**\n * judge the attribute is legal\n * @param name attribute name\n * @param val attribute value\n */\n private legalAttribute (name: string, val: AttrType): boolean {\n if (!isString(val) || !val) {\n logError(`unexpected attribute ${name}, please check again`, this.appName)\n\n return false\n }\n\n return true\n }\n\n /**\n * mount app\n * some serious note before mount:\n * 1. is prefetch ?\n * 2. is remount in another container ?\n * 3. is remount with change properties of the container ?\n */\n private handleAppMount (app: AppInterface): void {\n app.isPrefetch = false\n defer(() => app.mount(\n this.shadowRoot ?? this,\n this.getDisposeResult('inline'),\n this.getBaseRouteCompatible(),\n ))\n }\n\n // create app instance\n private handleCreateApp (): void {\n /**\n * actions for destory old app\n * fix of unmounted umd app with disableSandbox\n */\n if (appInstanceMap.has(this.appName)) {\n appInstanceMap.get(this.appName)!.actionsForCompletelyDestory()\n }\n\n const instance: AppInterface = new CreateApp({\n name: this.appName,\n url: this.appUrl,\n ssrUrl: this.ssrUrl,\n container: this.shadowRoot ?? this,\n inline: this.getDisposeResult('inline'),\n scopecss: !(this.getDisposeResult('disableScopecss') || this.getDisposeResult('shadowDOM')),\n useSandbox: !this.getDisposeResult('disableSandbox'),\n macro: this.getDisposeResult('macro'),\n baseroute: this.getBaseRouteCompatible(),\n })\n\n appInstanceMap.set(this.appName, instance)\n }\n\n /**\n * unmount app\n * @param destroy delete cache resources when unmount\n */\n private handleUnmount (destroy: boolean): void {\n const app = appInstanceMap.get(this.appName)\n if (app && appStatus.UNMOUNT !== app.getAppStatus()) app.unmount(destroy)\n }\n\n /**\n * Get configuration\n * Global setting is lowest priority\n * @param name Configuration item name\n */\n private getDisposeResult (name: string): boolean {\n // @ts-ignore\n return (this.hasAttribute(name) || microApp[name]) && this.getAttribute(name) !== 'false'\n }\n\n /**\n * 2021-09-08\n * get baseRoute\n * getAttribute('baseurl') is compatible writing of versions below 0.3.1\n */\n private getBaseRouteCompatible (): string {\n return this.getAttribute('baseroute') ?? this.getAttribute('baseurl') ?? ''\n }\n\n /**\n * Data from the base application\n */\n set data (value: Record<PropertyKey, unknown> | null) {\n if (this.appName) {\n microApp.setData(this.appName, value!)\n } else {\n this.cacheData = value\n }\n }\n\n /**\n * get data only used in jsx-custom-event once\n */\n get data (): Record<PropertyKey, unknown> | null {\n if (this.appName) {\n return microApp.getData(this.appName, true)\n } else if (this.cacheData) {\n return this.cacheData\n }\n return null\n }\n }\n\n window.customElements.define(tagName, MicroAppElement)\n}\n","import type { prefetchParamList, prefetchParam, globalAssetsType } from '@micro-app/types'\nimport CreateApp, { appInstanceMap } from './create_app'\nimport {\n requestIdleCallback,\n formatAppURL,\n formatAppName,\n promiseStream,\n logError,\n isBrowser,\n isArray,\n isPlainObject,\n isString,\n isFunction,\n} from './libs/utils'\nimport { fetchSource } from './source/fetch'\nimport { globalLinks } from './source/links'\nimport { globalScripts } from './source/scripts'\nimport microApp from './micro_app'\n\nfunction filterPreFetchTarget<T extends prefetchParam> (apps: T[]): T[] {\n const validApps: T[] = []\n\n if (isArray(apps)) {\n apps.forEach((item) => {\n if (isPlainObject(item)) {\n item.name = formatAppName(item.name)\n item.url = formatAppURL(item.url, item.name)\n if (item.name && item.url && !appInstanceMap.has(item.name)) {\n validApps.push(item)\n }\n }\n })\n }\n\n return validApps\n}\n\n/**\n * preFetch([\n * {\n * name: string,\n * url: string,\n * disableScopecss?: boolean,\n * disableSandbox?: boolean,\n * macro?: boolean,\n * },\n * ...\n * ])\n * Note:\n * 1: preFetch is asynchronous and is performed only when the browser is idle\n * 2: disableScopecss, disableSandbox, macro must be same with micro-app element, if conflict, the one who executes first shall prevail\n * @param apps micro apps\n */\nexport default function preFetch (apps: prefetchParamList): void {\n if (!isBrowser) {\n return logError('preFetch is only supported in browser environment')\n }\n requestIdleCallback(() => {\n isFunction(apps) && (apps = (apps as Function)())\n\n filterPreFetchTarget(apps as prefetchParam[]).forEach((item) => {\n const app = new CreateApp({\n name: item.name,\n url: item.url,\n scopecss: !(item.disableScopecss ?? microApp.disableScopecss),\n useSandbox: !(item.disableSandbox ?? microApp.disableSandbox),\n macro: item.macro ?? microApp.macro,\n })\n\n app.isPrefetch = true\n appInstanceMap.set(item.name, app)\n })\n })\n}\n\n/**\n * load global assets into cache\n * @param assets global assets of js, css\n */\nexport function getGlobalAssets (assets: globalAssetsType): void {\n if (isPlainObject(assets)) {\n requestIdleCallback(() => {\n if (isArray(assets.js)) {\n const effectiveJs = assets.js!.filter((path) => isString(path) && path.includes('.js') && !globalScripts.has(path))\n\n const fetchJSPromise: Array<Promise<string>> = []\n effectiveJs.forEach((path) => {\n fetchJSPromise.push(fetchSource(path))\n })\n\n // fetch js with stream\n promiseStream<string>(fetchJSPromise, (res: {data: string, index: number}) => {\n const path = effectiveJs[res.index]\n if (!globalScripts.has(path)) {\n globalScripts.set(path, res.data)\n }\n }, (err: {error: Error, index: number}) => {\n logError(err)\n })\n }\n\n if (isArray(assets.css)) {\n const effectiveCss = assets.css!.filter((path) => isString(path) && path.includes('.css') && !globalLinks.has(path))\n\n const fetchCssPromise: Array<Promise<string>> = []\n effectiveCss.forEach((path) => {\n fetchCssPromise.push(fetchSource(path))\n })\n\n // fetch css with stream\n promiseStream<string>(fetchCssPromise, (res: {data: string, index: number}) => {\n const path = effectiveCss[res.index]\n if (!globalLinks.has(path)) {\n globalLinks.set(path, res.data)\n }\n }, (err: {error: Error, index: number}) => {\n logError(err)\n })\n }\n })\n }\n}\n","import type { OptionsType, MicroAppConfigType, lifeCyclesType, plugins, fetchType } from '@micro-app/types'\nimport { defineElement } from './micro_app_element'\nimport preFetch, { getGlobalAssets } from './prefetch'\nimport { logError, logWarn, isFunction, isBrowser, isPlainObject, formatAppName } from './libs/utils'\nimport { EventCenterForBaseApp } from './interact'\nimport { initGlobalEnv } from './libs/global_env'\n\nclass MicroApp extends EventCenterForBaseApp implements MicroAppConfigType {\n tagName = 'micro-app'\n shadowDOM?: boolean\n destroy?: boolean\n inline?: boolean\n disableScopecss?: boolean\n disableSandbox?: boolean\n macro?: boolean\n ssr?: boolean\n lifeCycles?: lifeCyclesType\n plugins?: plugins\n fetch?: fetchType\n preFetch = preFetch\n start (options?: OptionsType) {\n if (!isBrowser || !window.customElements) {\n return logError('micro-app is not supported in this environment')\n }\n\n if (options?.tagName) {\n if (/^micro-app(-\\S+)?/.test(options.tagName)) {\n this.tagName = options.tagName\n } else {\n return logError(`${options.tagName} is invalid tagName`)\n }\n }\n\n if (window.customElements.get(this.tagName)) {\n return logWarn(`element ${this.tagName} is already defined`)\n }\n\n initGlobalEnv()\n\n if (options && isPlainObject(options)) {\n this.shadowDOM = options.shadowDOM\n this.destroy = options.destroy\n /**\n * compatible with versions below 0.4.2 of destroy\n * do not merge with the previous line\n */\n // @ts-ignore\n this.destory = options.destory\n this.inline = options.inline\n this.disableScopecss = options.disableScopecss\n this.disableSandbox = options.disableSandbox\n this.macro = options.macro\n this.ssr = options.ssr\n isFunction(options.fetch) && (this.fetch = options.fetch)\n\n isPlainObject(options.lifeCycles) && (this.lifeCycles = options.lifeCycles)\n\n // load app assets when browser is idle\n options.preFetchApps && preFetch(options.preFetchApps)\n\n // load global assets when browser is idle\n options.globalAssets && getGlobalAssets(options.globalAssets)\n\n if (isPlainObject(options.plugins)) {\n const modules = options.plugins!.modules\n if (isPlainObject(modules)) {\n for (const appName in modules) {\n const formattedAppName = formatAppName(appName)\n if (formattedAppName && appName !== formattedAppName) {\n modules[formattedAppName] = modules[appName]\n delete modules[appName]\n }\n }\n }\n\n this.plugins = options.plugins\n }\n }\n\n // define customElement after init\n defineElement(this.tagName)\n }\n}\n\nexport default new MicroApp()\n"],"names":["version","isBrowser","window","globalThis","global","self","Function","isString","target","isFunction","isArray","Array","isPlainObject","toString","call","isPromise","isBoundFunction","name","indexOf","hasOwnProperty","logError","msg","appName","rest","appNameTip","console","error","logWarn","warn","defer","fn","args","Promise","resolve","then","bind","addProtocol","url","startsWith","location","protocol","formatAppURL","origin","pathname","search","URL","test","fullPath","replace","e","formatAppName","getEffectivePath","pathArr","split","pop","join","CompletionPath","path","baseURI","promiseStream","promiseList","successCb","errorCb","finallyCb","finishedNum","isFinished","length","forEach","p","i","res","data","index","catch","err","requestIdleCallback","lastTime","Date","now","setTimeout","didTimeout","timeRemaining","Math","max","currentMicroAppName","setCurrentAppName","getCurrentAppName","removeDomScope","isSafari","navigator","userAgent","pureCreateElement","tagName","options","element","document","createElement","__MICRO_APP_NAME__","cloneContainer","deep","innerHTML","clonedNode","cloneNode","fragment","createDocumentFragment","from","childNodes","node","appendChild","isInvalidQuerySelectorKey","key","isUniqueElement","getRootContainer","ShadowRoot","isShadowRoot","host","ObservedAttrName","appStatus","lifeCycles","fetchSource","microApp","fetch","text","globalEnv","initGlobalEnv","rawSetAttribute","Element","prototype","setAttribute","rawAppendChild","Node","rawInsertBefore","insertBefore","rawReplaceChild","replaceChild","rawRemoveChild","removeChild","rawAppend","append","rawPrepend","prepend","rawCreateElement","Document","rawCreateElementNS","createElementNS","rawCreateDocumentFragment","rawQuerySelector","querySelector","rawQuerySelectorAll","querySelectorAll","rawGetElementById","getElementById","rawGetElementsByClassName","getElementsByClassName","rawGetElementsByTagName","getElementsByTagName","rawGetElementsByName","getElementsByName","rawWindow","rawDocument","supportModuleScript","templateStyle","body","rawWindowAddEventListener","addEventListener","rawWindowRemoveEventListener","removeEventListener","rawSetInterval","setInterval","rawSetTimeout","rawClearInterval","clearInterval","rawClearTimeout","clearTimeout","rawDocumentAddEventListener","rawDocumentRemoveEventListener","__MICRO_APP_BASE_APPLICATION__","Object","assign","CSSRuleType","scopedStyleRule","rule","prefix","selectorText","cssText","builtInRootSelectorRE","selectors","all","$1","$2","scopedHost","textContent","linkpath","purePath","getLinkFileDir","scopedPackRule","packName","result","scopedRule","cssRules","conditionText","rules","type","STYLE_RULE","MEDIA_RULE","SUPPORTS_RULE","commonAction","styleElement","originContent","__MICRO_APP_HAS_SCOPED__","sheet","scopedCSS","app","scopecss","disabled","__MICRO_APP_LINK_PATH__","observer","MutationObserver","disconnect","hasAttribute","observe","childList","eventHandler","event","defineProperties","currentTarget","get","srcElement","dispatchOnLoadEvent","CustomEvent","onload","dispatchEvent","dispatchOnErrorEvent","onerror","globalLinks","Map","extractLinkFromHtml","link","parent","isDynamic","rel","getAttribute","href","replaceComment","info","code","isGlobal","createComment","source","links","set","placeholder","includes","fetchLinksFromHtml","wrapElement","microAppHead","linkEntries","entries","fetchLinkPromise","globalLinkCode","push","has","styleLink","fetchLinkSuccess","onLoad","globalScripts","extractScriptElement","script","src","noModule","isExternal","async","module","scripts","nonceStr","random","substr","fetchScriptsFromHtml","scriptEntries","fetchScriptPromise","fetchScriptPromiseInfo","globalScriptText","fetchScriptSuccess","runScript","callback","bindScope","inline","scriptElement","runCode2InlineScript","container","runCode2Function","blob","Blob","createObjectURL","moduleCount","code2Function","plugins","plugin","loader","modules","usePlugins","sandBox","__MICRO_APP_PROXY_WINDOW__","proxyWindow","flatChildren","children","child","dom","HTMLLinkElement","HTMLStyleElement","HTMLScriptElement","HTMLMetaElement","HTMLTitleElement","HTMLImageElement","extractSourceDom","htmlStr","str","wrapDiv","getWrapElement","microAppBody","Error","size","boundedMap","WeakMap","constructorMap","rawWindowMethodMap","bindFunctionToRawWidow","value","valueStr","constructor","getOwnPropertyNames","isConstructor","boundFunction","isBoundedFunction","bindRawWindowValue","documentClickListMap","hasRewriteDocumentOnClick","documentEventListenerMap","effectDocumentEvent","getOwnPropertyDescriptor","rawOnClick","onclick","hasDocumentClickInited","onClickHandler","f","defineProperty","configurable","enumerable","overwriteDocumentOnClick","listener","appInstanceMap","umdMode","appListenersMap","appListenerList","add","Set","__MICRO_MARK_OPTIONS__","delete","formatEventType","microWindow","eventCenter","this","isLegalName","on","autoTrigger","eventInfo","eventList","callbacks","off","clear","dispatch","getData","formatEventName","fromBaseApp","EventCenterForGlobal","addGlobalDataListener","cb","__APP_NAME__","__AUTO_TRIGGER__","removeGlobalDataListener","setGlobalData","getGlobalData","clearGlobalDataListener","EventCenterForBaseApp","addDataListener","removeDataListener","setData","clearDataListener","EventCenterForMicroApp","super","detail","staticEscapeProperties","escapeSetterKeyList","unscopables","undefined","String","Boolean","Number","Symbol","parseFloat","Float32Array","macroTimer","macroTask","SandBox","macro","descriptorTargetMap","getScopeProperties","inject","eventListenerMap","intervalIdMap","timeoutIdMap","listenerList","handler","timeout","intervalId","timeoutId","umdWindowListenerMap","umdDocumentListenerMap","umdOnClickHandler","umdIntervalIdMap","umdTimeoutIdMap","recordUmdEffect","documentAppListenersMap","rebuildUmdEffect","releaseEffect","_","effect","Proxy","Reflect","active","eval","scopeProperties","rawValue","injectedKeys","descriptor","writable","escapeProperties","escapeKeys","ownKeys","concat","filter","item","create","deleteProperty","start","baseroute","__MICRO_APP_BASE_ROUTE__","__MICRO_APP_BASE_URL__","_babelPolyfill","activeCount","stop","recordUmdSnapshot","__MICRO_APP_UMD_MODE__","microAppEventCneter","umdDataListeners","normal","globalEventInfo","subAppEventInfo","recordDataCenterSnapshot","recordUmdinjectedValues","rebuildUmdSnapshot","rebuildDataCenterSnapshot","__MICRO_APP_ENVIRONMENT__","__MICRO_APP_PUBLIC_PATH__","dispatchLifecyclesEvent","lifecycleName","CreateApp","ssrUrl","useSandbox","NOT_LOADED","loadSourceCode","status","LOADING_SOURCE_CODE","cache","match","onLoadError","html","loadSourceLevel","isPrefetch","UNMOUNT","LOAD_SOURCE_FINISHED","mount","LOAD_SOURCE_ERROR","umdHookMountResult","BEFOREMOUNT","MOUNTING","umdHookMount","handleMounted","hasDispatchMountedEvent","scriptList","initedHook","scriptListEntries","deferScriptPromise","deferScriptInfo","execScripts","unmount","getUmdLibraryHooks","umdHookUnmount","dispatchMountedEvent","MOUNTED","destroy","umdHookUnmountResult","dispatchUnmountToMicroApp","handleUnmounted","actionsForUnmount","actionsForCompletelyDestory","childElementCount","libraryName","ERROR","getAppStatus","dynamicElementInMicroAppMap","handleNewNode","linkReplaceComment","replaceStyle","originLink","foramtDynamicLink","replaceElement","originScript","dispatchScriptOnLoadEvent","existInfo","runDynamicRemoteScript","invokePrototypeMethod","rawMethod","targetChild","passiveChild","head","contains","getMappingNode","commonElementHander","newChild","patchElementPrototypeMethods","markElement","namespaceURI","patchDocument","cloneValue","propertyKey","refChild","oldChild","nodes","releasePatches","hasRejectMicroAppStyle","unmountNestedApp","replaseUnmountOfNestedApp","disconnectedCallback","elementInstanceMap","defineElement","MicroAppElement","HTMLElement","isWating","formatAttrName","formatAttrUrl","legalAttribute","existApp","appUrl","handleUnmount","getDisposeResult","shadowRoot","handleAppMount","handleCreateApp","performWhenFirstCreated","observedAttributes","connectedCallback","hasConnected","CREATED","initialMount","attributeChangedCallback","attr","_oldVal","newVal","NAME","handleAttributeUpdate","formatNewName","cacheData","handleInitialNameAndUrl","style","rejectMicroAppStyle","attachShadow","mode","existAppUrl","val","getBaseRouteCompatible","instance","customElements","define","preFetch","apps","validApps","filterPreFetchTarget","disableScopecss","disableSandbox","shadowDOM","destory","ssr","preFetchApps","globalAssets","assets","js","effectiveJs","fetchJSPromise","css","effectiveCss","fetchCssPromise","formattedAppName","activeApps","keys"],"mappings":"sPAGaA,EAAU,QAGVC,EAA8B,oBAAXC,OAGnBC,EAAgC,oBAAXC,OAC9BA,OAEmB,oBAAXF,OACJA,OAEiB,oBAATG,KAAwBA,KAAOC,SAAS,cAATA,YAe/BC,EAAUC,GACxB,MAAyB,iBAAXA,WASAC,EAAYD,GAC1B,MAAyB,mBAAXA,EAIT,MAAME,EAAUC,MAAMD,iBAGbE,EAAeJ,GAC7B,MAAiC,oBAA1BK,SAASC,KAAKN,YAIPO,EAAWP,GACzB,MAAiC,qBAA1BK,SAASC,KAAKN,YAIPQ,EAAiBR,GAC/B,OAAOC,EAAWD,IAA6C,IAAlCA,EAAOS,KAAKC,QAAQ,YAAoBV,EAAOW,eAAe,sBAa7EC,EACdC,EACAC,EAAyB,QACtBC,GAEH,MAAMC,EAAaF,GAAWf,EAASe,GAAW,QAAQA,KAAa,GACnEf,EAASc,GACXI,QAAQC,MAAM,cAAcF,KAAcH,OAAUE,GA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