@blueking/bk-weweb 0.0.2 → 0.0.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":["../context/memory.ts","../common/state.ts","../utils/common.ts","../utils/fetch.ts","../typings/source.ts","../typings/sandbox.ts","../context/function.ts","../context/sandbox.ts","../context/window.ts","../utils/element-event.ts","../utils/element.ts","../entry/style.ts","../mode/instance.ts","../entry/script.ts","../mode/app.ts","../utils/load-source.ts","../entry/entry.ts","../cache/app-cache.ts","../context/document.ts","../context/element.ts","../lifecircle/before-load.ts","../lifecircle/load.ts","../lifecircle/unmount.ts","../lifecircle/activated.ts","../lifecircle/deactivated.ts","../component/web-compnent.ts","../index.ts","../lifecircle/mount.ts","../preload/preload.ts","../lifecircle/unload.ts"],"sourcesContent":["import { BaseModel } from '../typings';\n\nlet currentRunningApp: BaseModel | null = null;\nexport function getCurrentRunningApp() {\n return currentRunningApp;\n}\nexport function setCurrentRunningApp(appInstance: BaseModel | null) {\n currentRunningApp = appInstance;\n}\n\n\nexport const documentClickListMap = new Map<string, unknown>();\nexport type DocumentEventType = keyof DocumentEventMap;\nexport type DocumentEventListener =(this: Document, ev: DocumentEventMap[DocumentEventType]) => any;\nexport const documentEventListenerMap = new Map<string, Map<keyof DocumentEventMap, Set<DocumentEventListener>>>();\n\nconst script = document.createElement('script');\nexport const isSupportModuleScript = 'noModule' in script;\n\nexport const SCOPED_CSS_STYLE_ID = 'SCOPED_CSS_STYLE_ID';\n\nconst templateStyle: HTMLStyleElement = document.createElement('style');\ntemplateStyle.setAttribute('id', SCOPED_CSS_STYLE_ID);\ndocument.body.appendChild(templateStyle);\ntemplateStyle.sheet!.disabled = true;\nexport const disabledStyleDom = templateStyle;\n","// app status\nexport enum AppState {\n UNSET = 'UNSET',\n LOADING = 'LOADING',\n LOADED = 'LOADED',\n ERROR = 'ERROR',\n MOUNTING = 'MOUNTING',\n MOUNTED = 'MOUNTED',\n ACTIVATED = 'ACTIVATED',\n DEACTIVATED = 'DEACTIVATED',\n UNMOUNT = 'UNMOUNT'\n}\n","// is function\nexport function isFunction(target: unknown): boolean {\n return typeof target === 'function';\n}\n// Promise.then might be synchronized in Zone.js context, we need to use setTimeout instead to mock next tick.\nexport const nextTask: (cb: () => void) => any = typeof window.Zone === 'function' ? setTimeout : cb => Promise.resolve().then(cb);\n\nlet globalTaskPending = false;\nexport function nextTick(cb: () => void): void {\n if (!globalTaskPending) {\n globalTaskPending = true;\n nextTask(() => {\n cb();\n globalTaskPending = false;\n });\n }\n}\n\nexport function addUrlProtocol(url: string): string {\n return url.startsWith('//') ? `${location.protocol}${url}` : url;\n}\n\n// Get valid address, such as https://xxx/xx/xx.html to https://xxx/xx/\nexport function getUrlDir(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 return `${origin}${pathname}/`.replace(/\\/\\/$/, '/');\n}\n// 补齐url地址\nexport function fillUpPath(path: string, baseURI: string): string {\n if (!path || /^((((ht|f)tps?)|file):)?\\/\\//.test(path) || /^(data|blob):/.test(path)) return path;\n\n return new URL(path, getUrlDir(addUrlProtocol(baseURI))).toString();\n}\n// 获取url目录\nexport function getFileDir(linkpath: string): string {\n const pathArr = linkpath.split('/');\n pathArr.pop();\n return addUrlProtocol(`${pathArr.join('/')}/`);\n}\n// is ie11\nexport const isIE11 = typeof navigator !== 'undefined' && navigator.userAgent.indexOf('Trident') !== -1;\n\n// 随机url\nexport function randomUrl(): string {\n return `inline-${random(16)}`;\n}\n\n// Array deduplication\nexport function arrayUnique(array: any[]): any[] {\n return Array.from(new Set(array));\n}\n\n// requestIdleCallback polyfill\nexport const requestIdleCallback = window.requestIdleCallback\n || function (fn: CallableFunction) {\n const lastTime = Date.now();\n return setTimeout(() => {\n fn({\n didTimeout: false,\n handle() {\n return Math.max(0, 50 - (Date.now() - lastTime));\n },\n });\n }, 1);\n };\n\n// is safari browser\nexport function isSafari(): boolean {\n return /Safari/.test(navigator.userAgent);\n}\n\n// Create pure elements\nexport function createElement<K extends keyof HTMLElementTagNameMap>(\n tagName: K,\n options?: ElementCreationOptions,\n): HTMLElementTagNameMap[K] {\n const element = document.createElement(tagName, options);\n if (element.__BK_WEWEB_APP_KEY__) delete element.__BK_WEWEB_APP_KEY__;\n return element;\n}\n\n// bodyle element\nexport function isBodyElement(key: string): boolean {\n return /^(body|head|html)$/i.test(key);\n}\n// create random string\nexport const random = (n: number, str = 'abcdefghijklmnopqrstuvwxyz0123456789') => {\n // 生成n位长度的字符串\n let result = '';\n for (let i = 0; i < n; i++) {\n result += str[parseInt((Math.random() * str.length).toString(), 10)];\n }\n return result;\n};\n","import weWeb from '..';\n\nexport function fetchSource(url: string, options = {}): Promise<string> {\n if (weWeb.fetchSource) {\n return weWeb.fetchSource(url, options);\n }\n return window.fetch(url, options).then(res => res.text());\n}\n","export interface IStyleOption {\n code: string;\n prefetch?: boolean;\n preload?: boolean;\n url?: string;\n fromHtml: boolean\n initial?: boolean\n}\n\nexport interface IScriptOption {\n code: string; // code\n async: boolean; // async script\n defer: boolean; // defer script\n isModule: boolean; // module type script\n url?: string;\n fromHtml: boolean;\n initial?: boolean;\n};\n\nexport const CSS_ATTRIBUTE_KEY = 'id';\n\nexport enum CSS_RULE_TYPE {\n STYLE_RULE = 1,\n MEDIA_RULE = 4,\n SUPPORTS_RULE = 12\n}\n","export interface IInjectWindowAttrs {\n __POWERED_BY_BK_WEWEB__: boolean;\n __BK_WEWEB_APP_KEY__: string;\n __BK_WEWEB_DATA__: Record<string, unknown>;\n rawWindow: Window;\n rawDocument: Document;\n}\n\n\nexport const commonEScapeKeyList: PropertyKey[] = ['System', '__cjsWrapper', '__REACT_ERROR_OVERLAY_GLOBAL_HOOK__'];\n// 共享主应用上下文属性名\nexport const escapeSetterKeyList: PropertyKey[] = ['location'];\n// 一定需要在子应用自身上下文获取的属性名\nexport const scopeWindowKeyList: PropertyKey[] = ['webpackJsonp', '__POWERED_BY_BK_WEWEB__', '__BK_WEWEB_APP_KEY__', '__BK_WEWEB_DATA__'];\n// 设置了scopedLocation 后需要监听属性名\nexport const scopedLocationKeyList: PropertyKey[] = ['location', 'history'];\n\nexport enum DescriptorMapValue {\n 'TARGET' = 'TARGET',\n 'WINDOW' = 'WINDOW'\n};\n\nexport const commonRawWindowKeyMap: any = {\n undefined: true,\n Array: true,\n Object: true,\n String: true,\n Boolean: true,\n Math: true,\n Reflect: true,\n Function: true,\n Number: true,\n Symbol: true,\n parseFloat: true,\n parseInt: true,\n Float32Array: true,\n Set: true,\n Infinity: true,\n navigator: true,\n devicePixelRatio: true,\n Promise: true,\n HTMLElement: true,\n Map: true,\n Element: true,\n performance: true,\n console: true,\n isFinite: true,\n RegExp: true,\n JSON: true,\n Date: true,\n Proxy: true,\n isNaN: true,\n WeakMap: true,\n WeakSet: true,\n Uint8Array: true,\n // btoa: true,\n // unescape: true,\n // WebSocket: true,\n // encodeURIComponent: true,\n // decodeURIComponent: true,\n // ArrayBuffer: true,\n // XMLHttpRequest: true,\n // SVGElement: true,\n // URLSearchParams: true,\n // URL: true,\n // RangeError: true,\n // TypeError: true,\n // Uint16Array: true,\n // Uint32Array: true,\n // Float64Array: true,\n // Int32Array: true,\n // requestAnimationFrame: true,\n // SVGRect: true,\n // Error: true,\n // Buffer: true,\n // SyntaxError: true,\n // DataView: true,\n // Worker: true,\n // localStorage: true,\n // Text: true,\n // FormData: true,\n // ShadowRoot: true,\n // encodeURI: true,\n // crypto: true,\n // HTMLAnchorElement: true,\n // Int8Array: true,\n // FinalizationRegistry: true,\n // BigInt: true,\n // Atomics: true,\n // Uint8ClampedArray: true,\n // WeakRef: true,\n // getComputedStyle,\n // innerHeight: true,\n // innerWidth: true,\n // getComputedStyle: true,\n};\nexport const commonFakeWindowKeyMap: any = {\n __VUE_OPTIONS_API__: true,\n __VUE_I18N_LEGACY_API__: true,\n __VUE_I18N_FULL_INSTALL__: true,\n __VUE_DEVTOOLS_GLOBAL_HOOK__: true,\n __VUE_DEVTOOLS_HOOK_REPLAY__: true,\n __VUE_DEVTOOLS_PLUGINS__: true,\n __DEV__: true,\n webpackChunktrace: true,\n i18n: true,\n '__core-js_shared__': true,\n};\nexport const commonWindowNameMap: any = {\n window: true,\n self: true,\n globalThis: true,\n};\n","import { isFunction } from '../utils/common';\n\nconst constructorMap = new WeakMap<Function | FunctionConstructor, boolean>();\nfunction isConstructor(value: Function | FunctionConstructor) {\n if (constructorMap.has(value)) {\n return constructorMap.get(value);\n }\n\n const valueStr = value.toString();\n\n const result = (value.prototype\n && value.prototype.constructor === value\n && Object.getOwnPropertyNames(value.prototype).length > 1)\n || /^function\\s+[A-Z]/.test(valueStr)\n || /^class\\s+/.test(valueStr);\n\n constructorMap.set(value, result);\n\n return result;\n}\nconst rawWindowMethodMap = new WeakMap<CallableFunction, CallableFunction>();\nexport default function bindFunctionToRawWindow(rawWindow: Window, value: any): unknown {\n if (rawWindowMethodMap.has(value)) {\n return rawWindowMethodMap.get(value);\n }\n\n if (isFunction(value) && !isConstructor(value)) {\n const bindRawWindowValue = value.bind(rawWindow);\n Object.keys(value).forEach(key => (bindRawWindowValue[key] = value[key]));\n // eslint-disable-next-line no-prototype-builtins\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","/* eslint-disable no-new-func */\n/* eslint-disable no-param-reassign */\n/* eslint-disable no-prototype-builtins */\nimport {\n BaseModel,\n escapeSetterKeyList,\n IInjectWindowAttrs,\n scopedLocationKeyList,\n scopeWindowKeyList,\n commonEScapeKeyList,\n commonFakeWindowKeyMap,\n commonRawWindowKeyMap,\n DescriptorMapValue,\n} from '../typings';\nimport { arrayUnique, random } from '../utils/common';\nimport { MicroAppModel } from '../mode/app';\nimport bindFunctionToRawWindow from './function';\nimport { rewriteWindowFunction, rewriteDocumentAndBodyEvent } from './window';\nexport default class SandBox {\n private resetWindowFunction: CallableFunction;\n private resetDocumentAndBodyEvent?: CallableFunction;\n private injectedKeySet = new Set<PropertyKey>();\n private escapedKeySet = new Set<PropertyKey>();\n private active = false;\n\n public rawWindow: Window;\n public rawDocument: Document;\n public proxyWindow: WindowProxy & IInjectWindowAttrs;\n public fakeWindow: Window & IInjectWindowAttrs = {} as any;\n public windowSymbolKey: keyof Window;\n constructor(public app: BaseModel) {\n const descriptorMap = new Map<PropertyKey, DescriptorMapValue>();\n const rawWindow = window;\n const rawDocument = window.document;\n this.fakeWindow.__POWERED_BY_BK_WEWEB__ = true;\n this.fakeWindow.__BK_WEWEB_APP_KEY__ = app.appCacheKey;\n this.rawWindow = rawWindow;\n this.rawDocument = rawDocument;\n this.fakeWindow.rawWindow = rawWindow;\n this.fakeWindow.rawDocument = rawDocument;\n const { resetWindowFunction } = rewriteWindowFunction(this.fakeWindow);\n this.resetWindowFunction = resetWindowFunction;\n this.windowSymbolKey = `__${(app.name || app.appCacheKey).replace(/(-|,|:|~|'|\")/gmi, '_')}_${random(10)}__` as keyof Window;\n this.proxyWindow = new Proxy(this.fakeWindow, {\n get: (target: Window & any, key: PropertyKey): unknown => {\n if (commonRawWindowKeyMap[key] || key === Symbol.unscopables) return rawWindow[key as any];\n if (commonFakeWindowKeyMap[key]) return this.fakeWindow[key as any];\n if (['window', 'self', 'globalThis'].includes(key as string)) return this.proxyWindow;\n if (key === 'document' || key === 'eval') {\n app.registerRunningApp();\n // eslint-disable-next-line no-eval\n return key === 'document' ? rawDocument : eval;\n }\n if (\n scopedLocationKeyList.includes(key)\n && this.app instanceof MicroAppModel\n && this.app.iframe\n && this.app.scopeLocation\n ) {\n return this.app.iframe.contentWindow?.[key as any];\n }\n // if (key === Symbol.unscopables) return com;\n if (key === 'hasOwnProperty') return (key: PropertyKey) => this.fakeWindow.hasOwnProperty(key) || rawWindow.hasOwnProperty(key);\n if (key === 'top' || key === 'parent') {\n if (rawWindow === rawWindow.parent) {\n return this.proxyWindow;\n }\n return Reflect.get(rawWindow, key); // iframe\n }\n if (\n Reflect.has(target, key)\n || scopeWindowKeyList.includes(key)\n ) return Reflect.get(target, key);\n const rawValue = Reflect.get(rawWindow, key);\n return bindFunctionToRawWindow(rawWindow, rawValue);\n },\n set: (target: any, key: PropertyKey, value: unknown): boolean => {\n if (this.active) {\n if (\n scopedLocationKeyList.includes(key)\n && this.app instanceof MicroAppModel\n && this.app.iframe\n && this.app.scopeLocation\n ) {\n return Reflect.set(this.app.iframe.contentWindow!, key, value);\n }\n if (escapeSetterKeyList.includes(key)) {\n Reflect.set(rawWindow, key, value);\n } else if (\n !target.hasOwnProperty(key)\n && rawWindow.hasOwnProperty(key)\n && !scopeWindowKeyList.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.injectedKeySet.add(key);\n }\n } else {\n Reflect.set(target, key, value);\n this.injectedKeySet.add(key);\n }\n if ((commonEScapeKeyList.includes(key) && !Reflect.has(rawWindow, key))\n && !scopeWindowKeyList.includes(key)) {\n Reflect.set(rawWindow, key, value);\n this.escapedKeySet.add(key);\n }\n }\n return true;\n },\n has: (target: Window & any, key: PropertyKey): boolean => (commonRawWindowKeyMap as any)[key]\n || key in target\n || key in rawWindow,\n getOwnPropertyDescriptor: (target: any, key: PropertyKey): PropertyDescriptor | undefined => {\n if (target.hasOwnProperty(key)) {\n return Object.getOwnPropertyDescriptor(target, key);\n }\n if (rawWindow.hasOwnProperty(key)) {\n descriptorMap.set(key, DescriptorMapValue.WINDOW);\n const descriptor = Object.getOwnPropertyDescriptor(rawWindow, key);\n if (descriptor && !descriptor.configurable) {\n descriptor.configurable = true;\n }\n return descriptor;\n }\n return undefined;\n },\n // Object.defineProperty(window, key, Descriptor)\n defineProperty: (target: Window & any, key: PropertyKey, value: PropertyDescriptor): boolean => {\n const from = descriptorMap.get(key);\n if (from === DescriptorMapValue.WINDOW) {\n return Reflect.defineProperty(rawWindow, key, value);\n }\n return Reflect.defineProperty(target, key, value);\n },\n // Object.getOwnPropertyNames(window)\n ownKeys: (target: Window & any): Array<string | symbol> => arrayUnique(Reflect.ownKeys(rawWindow)\n .concat(Reflect.ownKeys(target))),\n deleteProperty: (target: Window & any, key: PropertyKey): boolean => {\n if (target.hasOwnProperty(key)) {\n this.injectedKeySet.has(key) && this.injectedKeySet.delete(key);\n this.escapedKeySet.has(key) && Reflect.deleteProperty(rawWindow, key);\n return Reflect.deleteProperty(target, key);\n }\n return true;\n },\n });\n if (app.showSourceCode) {\n rawWindow[this.windowSymbolKey as any] = this.proxyWindow;\n }\n }\n activeated(data?: Record<string, unknown>): void {\n if (!this.active) {\n this.active = true;\n this.fakeWindow.__BK_WEWEB_DATA__ = data ?? {};\n const { resetDocumentAndBodyEvent } = rewriteDocumentAndBodyEvent();\n this.resetDocumentAndBodyEvent = resetDocumentAndBodyEvent;\n }\n }\n deactivated(): void {\n if (this.active) {\n this.active = false;\n this.resetWindowFunction();\n // this.injectedKeySet.forEach((key: PropertyKey) => Reflect.deleteProperty(this.fakeWindow, key));\n this.injectedKeySet.clear();\n this.escapedKeySet.forEach((key: PropertyKey) => Reflect.deleteProperty(window, key));\n this.escapedKeySet.clear();\n this.resetDocumentAndBodyEvent?.();\n }\n }\n}\n","/* eslint-disable no-param-reassign */\nimport { documentClickListMap, documentEventListenerMap, DocumentEventListener, getCurrentRunningApp } from './memory';\n\nexport type IntervalOrTimeout = {\n handler: TimerHandler;\n timeout?: number;\n args: unknown[];\n};\n// rewrite document and body event listener\nexport function rewriteDocumentAndBodyEvent(): {resetDocumentAndBodyEvent: () => void} {\n const { addEventListener, removeEventListener } = window.document;\n const { addEventListener: bodyAddEventListener, removeEventListener: bodyRemoveEventListener } = window.document.body;\n document.addEventListener = function<K extends keyof DocumentEventMap>(\n type: K,\n listener: DocumentEventListener,\n options?: boolean | AddEventListenerOptions | undefined,\n ): void {\n const app = getCurrentRunningApp();\n if (app) {\n const appListenersMap = documentEventListenerMap.get(app.appCacheKey);\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(app.appCacheKey, new Map([[type, new Set([listener])]]));\n }\n }\n addEventListener.call(app?.container instanceof ShadowRoot ? app.container : this, type, listener, options);\n };\n document.body.addEventListener = document.addEventListener;\n\n document.removeEventListener = function<K extends keyof DocumentEventMap>(\n type: K,\n listener: DocumentEventListener,\n options?: boolean | AddEventListenerOptions,\n ): void {\n const app = getCurrentRunningApp();\n if (app) {\n const appListenersMap = documentEventListenerMap.get(app.appCacheKey);\n if (appListenersMap) {\n const appListenerList = appListenersMap.get(type);\n if (appListenerList?.size && appListenerList.has(listener)) {\n appListenerList.delete(listener);\n }\n }\n }\n removeEventListener.call(app?.container instanceof ShadowRoot ? app.container : this, type, listener, options);\n };\n document.body.removeEventListener = document.removeEventListener;\n\n function resetDocumentAndBodyEvent(): void {\n document.addEventListener = addEventListener;\n document.body.addEventListener = bodyAddEventListener;\n document.removeEventListener = removeEventListener;\n document.body.removeEventListener = bodyRemoveEventListener;\n }\n return {\n resetDocumentAndBodyEvent,\n };\n}\n\n// rewrite window funtion like settimeout setinterval ...\nexport function rewriteWindowFunction(fakeWindow: Window & any): Record<string, CallableFunction> {\n const app = getCurrentRunningApp();\n const eventListenerMap = new Map<string, Set<DocumentEventListener>>();\n const intervalIdMap = new Map<number, IntervalOrTimeout>();\n const timeoutIdMap = new Map<number, IntervalOrTimeout>();\n const rawWindow = window;\n const rawDocument = window.document;\n const { addEventListener, removeEventListener, setInterval, setTimeout, clearInterval, clearTimeout } = window;\n const { removeEventListener: documentRemoveEventListener } = window.document;\n\n // listener may be null, e.g test-passive\n fakeWindow.addEventListener = function (\n type: string,\n listener: DocumentEventListener,\n options?: boolean | AddEventListenerOptions,\n ): void {\n const listenerList = eventListenerMap.get(type);\n if (listenerList) {\n listenerList.add(listener);\n } else {\n eventListenerMap.set(type, new Set([listener]));\n }\n addEventListener.call(rawWindow, type, listener, options);\n };\n\n fakeWindow.removeEventListener = function (\n type: string,\n listener: DocumentEventListener,\n options?: boolean | AddEventListenerOptions,\n ): void {\n const listenerList = eventListenerMap.get(type);\n if (listenerList?.size && listenerList.has(listener)) {\n listenerList.delete(listener);\n }\n removeEventListener.call(rawWindow, type, listener, options);\n };\n\n fakeWindow.setInterval = function (\n handler: TimerHandler | string,\n timeout?: number | undefined, ...args: any[]\n ): number {\n const intervalId: any = setInterval.call(rawWindow, handler as any, timeout, ...(args as []));\n intervalIdMap.set(intervalId, { handler, timeout, args });\n return intervalId;\n };\n\n fakeWindow.setTimeout = function (\n handler: TimerHandler,\n timeout?: number,\n ...args: any[]\n ): number {\n const timeoutId: any = setTimeout.call(rawWindow, handler as any, timeout, ...(args as []));\n timeoutIdMap.set(timeoutId, { handler, timeout, args });\n return timeoutId;\n };\n\n fakeWindow.clearInterval = function (intervalId: number) {\n intervalIdMap.delete(intervalId);\n clearInterval.call(rawWindow, intervalId as any);\n };\n\n fakeWindow.clearTimeout = function (timeoutId: number) {\n timeoutIdMap.delete(timeoutId);\n clearTimeout.call(rawWindow, timeoutId as any);\n };\n // reset all event listener & interval & timeout when unmount app\n const resetWindowFunction = () => {\n // clear window events listener\n if (eventListenerMap.size) {\n eventListenerMap.forEach((listenerList, type) => {\n for (const listener of listenerList) {\n removeEventListener.call(rawWindow, type, listener);\n }\n });\n eventListenerMap.clear();\n }\n\n // clear settimeout timers\n if (intervalIdMap.size) {\n intervalIdMap.forEach((_, intervalId: number) => {\n clearInterval.call(rawWindow, intervalId as any);\n });\n intervalIdMap.clear();\n }\n\n if (timeoutIdMap.size) {\n timeoutIdMap.forEach((_, timeoutId: number) => {\n clearTimeout.call(rawWindow, timeoutId as any);\n });\n timeoutIdMap.clear();\n }\n\n if (app) {\n documentClickListMap.delete(app.appCacheKey);\n const documentAppListenersMap = documentEventListenerMap.get(app.appCacheKey);\n if (documentAppListenersMap) {\n documentAppListenersMap.forEach((listenerList, type) => {\n for (const listener of listenerList) {\n documentRemoveEventListener.call(rawDocument, type, listener);\n }\n });\n documentAppListenersMap.clear();\n }\n }\n };\n\n return {\n resetWindowFunction,\n };\n}\n","import { isFunction } from './common';\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}\nexport function dispatchLinkOrScriptLoad(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 dispatchLinkOrScriptError(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 { appCache } from '../cache/app-cache';\nimport { Script } from '../entry/script';\nimport { Style } from '../entry/style';\nimport { randomUrl } from './common';\nimport { dispatchLinkOrScriptLoad } from './element-event';\nimport { BaseModel } from '../typings';\nconst { appendChild: bodyAppendChild } = HTMLBodyElement.prototype;\nexport function resetNewElement(\n parent: Node,\n child: Node,\n app: BaseModel,\n): Node {\n if (child instanceof HTMLStyleElement) {\n if (child.hasAttribute('exclude')) {\n return document.createComment('【bk-weweb】style with exclude attribute is ignored');\n }\n if (!child.hasAttribute('ignore')) {\n const styleInstance = new Style({\n code: child.textContent || '',\n url: '',\n fromHtml: false,\n });\n app.source?.setStyle(randomUrl(), styleInstance);\n styleInstance.scopedStyleCSS(app, child);\n }\n return child;\n }\n if (child instanceof HTMLLinkElement) {\n const result = app.source?.collectLink(child, parent, true);\n if (!result) return child;\n if (result.style) {\n result.style.scopedLinkCSS(app, child);\n }\n if (result.replace !== child) {\n return result.replace;\n }\n return child;\n }\n if (child instanceof HTMLScriptElement) {\n const replaceInfo = app.source!.collectScript(child, parent, true);\n if (!replaceInfo) {\n return child;\n }\n if (replaceInfo.script) {\n replaceInfo.script.excuteCode(app);\n }\n if (replaceInfo.replace !== child) {\n return replaceInfo.replace;\n }\n if (app.scopeJs && !child.getAttribute('src') && !child.textContent) {\n const observer = new MutationObserver(() => {\n if (child.getAttribute('src')) {\n observer.disconnect();\n const scriptInfo = app.source!.collectScript(child, parent, true);\n if (scriptInfo?.replace) {\n bodyAppendChild.call(app.container, scriptInfo.replace);\n }\n if (scriptInfo?.script) {\n scriptInfo.script.excuteCode(app);\n }\n child.remove();\n } else if (child.textContent) {\n observer.disconnect();\n const scriptInstance = new Script({\n code: child.textContent,\n async: false,\n defer: child.type === 'module',\n isModule: child.type === 'module',\n fromHtml: false,\n });\n app.source!.scripts.set(randomUrl(), scriptInstance);\n try {\n scriptInstance.excuteCode(app);\n } catch (e) {\n console.error(e);\n } finally {\n !scriptInstance.isModule && dispatchLinkOrScriptLoad(child);\n child.remove();\n }\n }\n });\n observer.observe(child, { attributeFilter: ['src'], childList: true, subtree: false });\n return document.createComment('【bk-weweb】dynamic script or module');\n }\n return child;\n }\n return child;\n}\nexport function isSepcailElement(node: Node) {\n return node instanceof HTMLScriptElement\n|| node instanceof HTMLStyleElement\n|| node instanceof HTMLLinkElement;\n}\nexport function elmentAppendHandler(\n parent: Node,\n newChild: Node,\n rawMethod: Function,\n) {\n if (newChild.__BK_WEWEB_APP_KEY__) {\n const app = appCache.getApp(newChild.__BK_WEWEB_APP_KEY__!);\n if (app?.container) {\n const targetChild = resetNewElement(parent, newChild, app);\n const needKeepAlive = isSepcailElement(newChild) && !!app.keepAlive && !(app.container instanceof ShadowRoot);\n const container = needKeepAlive ? document.head : app?.container;\n setMarkElement(targetChild as Element, app, needKeepAlive);\n return rawMethod.call(container, targetChild);\n }\n }\n return rawMethod.call(parent, newChild);\n}\nexport function elementInsertHandler(\n parent: Node,\n newChild: Node,\n passiveChild: Node | null,\n rawMethod: Function,\n) {\n if (newChild.__BK_WEWEB_APP_KEY__) {\n const app = appCache.getApp(newChild.__BK_WEWEB_APP_KEY__!);\n if (app?.container) {\n const needKeepAlive = isSepcailElement(newChild) && app.keepAlive && !(app.container instanceof ShadowRoot) ;\n const container = needKeepAlive ? document.head : app?.container;\n const targetChild = resetNewElement(parent, newChild, app);\n if (needKeepAlive) {\n targetChild.__KEEP_ALIVE__ = app.appCacheKey;\n (targetChild as Element).setAttribute('data-from', app.name);\n (targetChild as Element).setAttribute('data-keep-alive', 'true');\n }\n if (passiveChild && !container.contains(passiveChild)) {\n return bodyAppendChild.call(container, targetChild);\n }\n return rawMethod.call(container, targetChild, passiveChild);\n }\n }\n return rawMethod.call(parent, newChild, passiveChild);\n}\n\nexport function setMarkElement<T extends Element>(element: T, app: BaseModel, keepAlive: boolean): T {\n if (keepAlive) {\n element.__KEEP_ALIVE__ = app.appCacheKey;\n element.setAttribute('data-from', app.name);\n element.setAttribute('data-keep-alive', 'true');\n }\n element.setAttribute?.('powered-by', 'bk-weweb');\n return element;\n}\n","/* eslint-disable no-param-reassign */\nimport { appCache } from '../cache/app-cache';\nimport { disabledStyleDom } from '../context/memory';\nimport { BaseModel, CSS_RULE_TYPE, IStyleOption } from '../typings';\nimport { setMarkElement } from '../utils';\nimport { fillUpPath, getFileDir, isSafari, createElement } from '../utils/common';\nimport { dispatchLinkOrScriptError, dispatchLinkOrScriptLoad } from '../utils/element-event';\nimport { fetchSource } from '../utils/fetch';\n\nexport class Style {\n scopedCode = '';\n code ='';\n prefetch = false;\n preload = false;\n url: string | undefined;\n scoped: boolean;\n fromHtml: boolean;\n initial: boolean;\n constructor({ code, prefetch, preload, url, fromHtml, initial }: IStyleOption) {\n this.scoped = false;\n this.code = code;\n this.prefetch = prefetch ?? false;\n this.preload = preload ?? false;\n this.url = url;\n this.fromHtml = fromHtml;\n this.initial = initial ?? false;\n }\n async getCode(app?: BaseModel): Promise<string> {\n if (this.code.length || !this.url) {\n return this.code;\n }\n let code = '';\n if (app?.source?.styles?.has(this.url)) {\n code = app.source.styles.get(this.url)?.code || '';\n }\n if (!code && appCache.getCacheStyle(this.url)) {\n const style = appCache.getCacheStyle(this.url);\n code = style?.code || '';\n }\n if (!code) {\n code = await fetchSource(this.url).catch(() => '');\n }\n this.code = code;\n return code;\n }\n async excuteCode(app: BaseModel): Promise<HTMLStyleElement> {\n app.registerRunningApp();\n let styleElement = createElement('style');\n styleElement.setAttribute('type', 'text/css');\n styleElement.textContent = this.code!;\n try {\n if (!this.code) await this.getCode(app);\n styleElement = this.scopedStyleCSS(app, styleElement);\n this.scoped = true;\n } catch (e) {\n console.error('scoped style error', e);\n }\n return styleElement;\n }\n scopedStyleCSS(app: BaseModel, styleElement: HTMLStyleElement): HTMLStyleElement {\n const needKeepAlive = !!app.keepAlive && !(app.container instanceof ShadowRoot);\n setMarkElement(styleElement, app, needKeepAlive);\n if (this.code || styleElement.textContent) {\n if (styleElement.textContent) {\n styleElement.textContent = '';\n styleElement.innerHTML = '';\n }\n disabledStyleDom.textContent = this.code;\n this.commonScoped(\n disabledStyleDom,\n styleElement,\n app,\n );\n disabledStyleDom.textContent = '';\n } else {\n const observer = new MutationObserver(() => {\n if (!(styleElement.textContent || styleElement.sheet?.cssRules?.length)) return;\n observer.disconnect();\n this.commonScoped(\n styleElement,\n styleElement,\n app,\n );\n });\n observer.observe(styleElement, { attributes: false, childList: true, subtree: true, characterData: true });\n }\n this.url && styleElement.setAttribute('origin-src', this.url);\n return styleElement;\n }\n scopedLinkCSS(app: BaseModel, linkElement: HTMLLinkElement): HTMLStyleElement {\n const styleElement = createElement('style');\n styleElement.setAttribute('type', 'text/css');\n const needKeepAlive = !!app.keepAlive && !(app.container instanceof ShadowRoot);\n setMarkElement(styleElement, app, needKeepAlive);\n const container = needKeepAlive ? document.head : app.container;\n try {\n if (this.code) {\n disabledStyleDom.textContent = styleElement.textContent || this.code;\n this.commonScoped(\n disabledStyleDom,\n styleElement,\n app,\n );\n container?.prepend(styleElement);\n linkElement && dispatchLinkOrScriptLoad(linkElement);\n disabledStyleDom.textContent = '';\n } else if (linkElement.getAttribute('href')) {\n this.url = fillUpPath(linkElement.getAttribute('href')!, app.url);\n this.getCode(app).then(() => {\n this.scopedStyleCSS(app, styleElement);\n linkElement.remove();\n container?.prepend(styleElement);\n linkElement && dispatchLinkOrScriptLoad(linkElement);\n this.scoped = true;\n });\n } else {\n const observer = new MutationObserver(() => {\n if (!linkElement.href) return;\n observer.disconnect();\n this.url = fillUpPath(linkElement.getAttribute('href')!, app.url);\n this.getCode(app).then(() => {\n this.scopedStyleCSS(app, styleElement);\n linkElement.remove();\n container?.prepend(styleElement);\n linkElement && dispatchLinkOrScriptLoad(linkElement);\n this.scoped = true;\n });\n });\n observer.observe(linkElement, { attributeFilter: ['href'], subtree: false, childList: false });\n }\n } catch {\n linkElement && dispatchLinkOrScriptError(linkElement);\n }\n return styleElement;\n }\n commonScoped(\n templateStyle: HTMLStyleElement,\n styleElement: HTMLStyleElement,\n app: BaseModel,\n ) {\n if (app.scopeCss && !(app.container instanceof ShadowRoot)) {\n const rules: CSSRule[] = Array.from(templateStyle.sheet?.cssRules ?? []);\n const cssPrefix = `#${app.name}`;\n const scopedCss = this.scopeRule(rules, cssPrefix);\n let cssText = this.resetUrlHost(\n scopedCss,\n app.url,\n this.url,\n );\n if (isSafari()) {\n cssText = cssText.replace(/([;{]\\s*content:\\s*)([^\\s\"][^\";}]*)/gm, (all, $1, $2) => {\n if ($2 === 'none' || /^(url\\()|(counter\\()|(attr\\()|(open-quote)|(close-quote)/.test($2)) {\n return all;\n }\n return `${$1}\"${$2}\"`;\n });\n }\n styleElement.textContent = cssText;\n this.scopedCode = cssText;\n } else {\n const cssText = this.resetUrlHost(\n styleElement.textContent || templateStyle.textContent || '',\n app.url,\n this.url,\n );\n styleElement.textContent = cssText;\n }\n this.scoped = true;\n }\n scopeRule(rules: CSSRule[], cssPrefix: string): string {\n let result = '';\n for (const rule of rules) {\n switch (rule.type) {\n case CSS_RULE_TYPE.STYLE_RULE:\n result += this.scopeStyleRule(rule as CSSStyleRule, cssPrefix);\n break;\n case CSS_RULE_TYPE.MEDIA_RULE:\n result += this.resetPackRule(rule as CSSMediaRule, cssPrefix, 'media');\n break;\n case CSS_RULE_TYPE.SUPPORTS_RULE:\n result += this.resetPackRule(rule as CSSSupportsRule, cssPrefix, 'supports');\n break;\n default:\n result += rule.cssText;\n break;\n }\n }\n return result.replace(/^\\s+/, '');\n }\n resetPackRule(rule: CSSMediaRule | CSSSupportsRule, prefix: string, packName: string): string {\n const result = this.scopeRule(Array.from(rule.cssRules), prefix);\n return `@${packName} ${rule.conditionText} {${result}}`;\n }\n resetUrlHost(cssText: string, baseURI: string, linkpath?: string) {\n return cssText.replace(/url\\([\"']?([^)\"']+)[\"']?\\)/gm, (text, $1) => {\n if (/^(data|blob):/.test($1) || /^(https?:)?\\/\\//.test($1)) {\n return text;\n }\n if (/^((\\.\\.?\\/)|[^/])/.test($1) && linkpath) {\n baseURI = getFileDir(linkpath);\n }\n return `url(\"${fillUpPath($1, baseURI)}\")`;\n });\n }\n scopeStyleRule(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 }\n 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 => selectors.replace(/(^|,)([^,]+)/g, (all, $1, $2) => {\n if (builtInRootSelectorRE.test($2)) {\n return all.replace(builtInRootSelectorRE, prefix);\n }\n return `${$1} ${prefix} ${$2.replace(/^\\s*/, '')}`;\n }));\n }\n}\n\nexport async function excuteAppStyles(app: BaseModel, container?: Element | ShadowRoot) {\n const styleList: Style[] = Array.from(app.source!.styles.values());\n const promiseList: Promise<HTMLStyleElement>[] = [];\n styleList.forEach((style) => {\n promiseList.push(style.excuteCode(app));\n });\n await Promise.all(promiseList).then((styleElementList: HTMLStyleElement[]) => {\n const parentElemnt = container || app.container;\n if (app.keepAlive && !(parentElemnt instanceof ShadowRoot)) {\n document.head.append(...styleElementList);\n } else {\n parentElemnt?.prepend(...styleElementList);\n }\n });\n}\n","import { appCache } from '../cache/app-cache';\nimport { AppState } from '../common';\nimport { setCurrentRunningApp } from '../context/memory';\nimport SandBox from '../context/sandbox';\nimport { EntrySource } from '../entry/entry';\nimport { execAppScripts } from '../entry/script';\nimport { excuteAppStyles } from '../entry/style';\nimport { BaseModel, CSS_ATTRIBUTE_KEY, IJsModelProps } from '../typings';\nimport { random } from '../utils/common';\nimport { SourceType } from '../utils/load-source';\nexport class MicroInstanceModel implements BaseModel {\n private state: AppState = AppState.UNSET;\n isPreLoad = false;\n appCacheKey: string;\n url: string;\n container?: HTMLElement | ShadowRoot;\n scopeJs = false;\n source?: EntrySource;\n sandBox?: SandBox;\n name: string;\n showSourceCode = true;\n scopeCss = true;\n keepAlive: boolean;\n initSource: SourceType;\n public data: Record<string, unknown>;\n constructor(props: IJsModelProps) {\n this.name = props.id !== props.url ? props.id! : random(5);\n this.appCacheKey = props.id || this.name;\n this.url = props.url;\n this.container = props.container ?? undefined;\n this.scopeJs = props.scopeJs ?? true;\n this.showSourceCode = props.showSourceCode ?? true;\n this.scopeCss = props.scopeCss ?? true;\n this.keepAlive = props.keepAlive ?? false;\n this.data = props.data ?? {};\n this.initSource = props.initSource ?? [];\n // 是否启用沙盒\n if (this.scopeJs) {\n this.sandBox = new SandBox(this);\n }\n }\n get status(): AppState {\n return this.state;\n }\n set status(v: AppState) {\n this.state = v;\n }\n async start(): Promise<void> {\n if (!this.source || [AppState.UNSET, AppState.ERROR].includes(this.status)) {\n this.source = new EntrySource(this.url);\n await this.source.importEntery(this);\n }\n }\n onMount(): void {\n if (this.isPreLoad) return;\n this.state = AppState.LOADED;\n this.mount();\n }\n onError(): void {\n this.state = AppState.ERROR;\n }\n mount<T>(\n container?: HTMLElement | ShadowRoot,\n callback?: (instance: MicroInstanceModel, exportInstance: T) => void,\n ): void {\n this.isPreLoad = false;\n this.container = container ?? this.container!;\n this.state = AppState.MOUNTING;\n if (this.container instanceof HTMLElement) {\n this.container!.setAttribute(CSS_ATTRIBUTE_KEY, this.name);\n }\n this.container.innerHTML = '';\n const instanceWrap = document.createElement('div');\n const wrapId = `${this.name}-wrapper`;\n instanceWrap.setAttribute('id', wrapId);\n if (this.source?.styles.size) {\n excuteAppStyles(this, this.container);\n }\n this.container.appendChild(instanceWrap);\n this.sandBox?.activeated();\n execAppScripts(this).finally(() => {\n this.state = AppState.MOUNTED;\n const scriptInfo = this.source?.getScript(this.url);\n if (typeof scriptInfo?.exportInstance?.render === 'function') {\n scriptInfo.exportInstance.render(instanceWrap, this.data);\n }\n callback?.(this, scriptInfo?.exportInstance);\n });\n }\n activated<T>(\n container: HTMLElement | ShadowRoot,\n callback?: (instance: BaseModel, exportInstance?: T) => void,\n ): void {\n this.isPreLoad = false;\n this.state = AppState.ACTIVATED;\n if (this.container && container) {\n if (container instanceof Element) container!.setAttribute(CSS_ATTRIBUTE_KEY, this.name);\n const fragment = document.createDocumentFragment();\n Array.from(this.container.childNodes).forEach((node: Node | Element) => {\n fragment.appendChild(node);\n });\n container.appendChild(fragment);\n this.container = container;\n this.sandBox?.activeated();\n const scriptInfo = this.source?.getScript(this.url);\n callback?.(this, scriptInfo?.exportInstance);\n }\n }\n deactivated(): void {\n this.state = AppState.DEACTIVATED;\n this.sandBox?.deactivated();\n }\n unmount(needDestroy?: boolean): void {\n this.state = AppState.UNMOUNT;\n this.sandBox?.deactivated();\n needDestroy && appCache.deleteApp(this.url);\n this.container!.innerHTML = '';\n this.container = undefined;\n }\n registerRunningApp() {\n setCurrentRunningApp(this);\n Promise.resolve().then(() => setCurrentRunningApp(null));\n }\n}\n","/* eslint-disable no-restricted-syntax */\n/* eslint-disable no-prototype-builtins */\n/* eslint-disable no-param-reassign */\n/* eslint-disable max-len */\nimport { MicroAppModel } from '../mode/app';\nimport { BaseModel, IScriptOption } from '../typings';\nimport { isIE11, createElement } from '../utils/common';\nimport { fetchSource } from '../utils/fetch';\nimport { MicroInstanceModel } from '../mode/instance';\nimport { appCache } from '../cache/app-cache';\nimport { setMarkElement } from '../utils';\n\nlet firstGlobalProp: string | undefined;\nlet secondGlobalProp: string | undefined;\nlet lastGlobalProp: string | undefined;\n\n// Script脚本实例\nexport class Script {\n code = '';\n async = false;\n defer = false;\n isModule = false;\n url: string | undefined;\n exportInstance?: any;\n scoped: boolean;\n fromHtml: boolean;\n initial: boolean;\n\n constructor({ code, async, defer, isModule, url, fromHtml, initial }: IScriptOption) {\n this.code = code;\n this.async = async;\n this.defer = defer;\n this.isModule = isModule;\n this.url = url;\n this.scoped = false;\n this.fromHtml = fromHtml ?? false;\n this.initial = initial ?? false;\n }\n async getCode(app?: BaseModel): Promise<string> {\n if (this.code.length || !this.url) {\n return this.code;\n }\n let code = '';\n if (app?.source?.getScript(this.url)) {\n code = app.source.getScript(this.url)?.code || '';\n }\n if (!code && appCache.getCacheScript(this.url)) {\n code = appCache.getCacheScript(this.url)?.code || '';\n }\n if (!code) {\n code = await fetchSource(this.url).catch((e) => {\n console.error(`fetch script ${this.url} error`, e);\n return '';\n });\n }\n this.code = code;\n return code;\n }\n async excuteCode(app: BaseModel, needRelaceScriptElement = false): Promise<HTMLScriptElement | Comment | undefined> {\n try {\n if (!this.code) await this.getCode(app);\n if (app instanceof MicroInstanceModel) {\n noteGlobalProps(app.sandBox?.proxyWindow || window);\n }\n let scopedCode = this.code;\n scopedCode = this.transformCode(app);\n if (app.showSourceCode || this.isModule) {\n const scriptElement = createElement('script');\n app.registerRunningApp();\n this.executeSourceScript(scriptElement, scopedCode);\n if (needRelaceScriptElement) return scriptElement;\n const needKeepAlive = !!app.keepAlive && !(app.container instanceof ShadowRoot);\n const container = needKeepAlive ? document.head : app.container;\n setMarkElement(scriptElement, app, needKeepAlive);\n container!.appendChild(scriptElement);\n } else {\n this.executeMemoryScript(app, scopedCode);\n if (needRelaceScriptElement) return document.createComment('【bk-weweb】dynamic script');\n }\n if (app instanceof MicroInstanceModel) {\n const exportProp: any = getGlobalProp(app.sandBox?.proxyWindow || window);\n exportProp && (this.exportInstance = (app.sandBox?.proxyWindow || window)[exportProp]);\n }\n } catch (e) {\n console.error('execute script code error', e);\n }\n return;\n }\n transformCode(app: BaseModel): string {\n if (app.sandBox) {\n if (app.showSourceCode || this.isModule) {\n return `;(function(window, self){\n with(window){\n ;${this.code}\\n\n }\n }).call(window.${app.sandBox.windowSymbolKey},\n window.${app.sandBox.windowSymbolKey});`;\n }\n return `\n with(window) {\n try {\n ${this.code}\n }\n catch(e) {\n console.error(e)\n }\n }\n `;\n }\n return this.code;\n }\n executeSourceScript(\n scriptElement: HTMLScriptElement,\n scopedCode: string,\n ): void {\n if (this.isModule) {\n const blob = new Blob([scopedCode], { type: 'text/javascript' });\n scriptElement.src = URL.createObjectURL(blob);\n scriptElement.setAttribute('type', 'module');\n } else {\n scriptElement.textContent = scopedCode;\n }\n this.url && scriptElement.setAttribute('origin-src', this.url);\n }\n executeMemoryScript(app: BaseModel, scopedCode: string) {\n try {\n const isScopedLocation = app instanceof MicroAppModel && app.scopeLocation;\n app.registerRunningApp();\n // eslint-disable-next-line no-new-func\n new Function('window', 'location', 'history', scopedCode)(\n app.sandBox!.proxyWindow,\n isScopedLocation ? app.iframe?.contentWindow?.location : window.location,\n isScopedLocation ? app.iframe?.contentWindow?.history : window.history,\n );\n } catch (e) {\n console.error(e);\n }\n }\n}\n// 全局属性是否跳过标记\nexport function shouldSkipProperty(global: Window, p: any) {\n return (\n !global.hasOwnProperty(p)\n || (!isNaN(p) && p < global.length)\n || (isIE11 && global[p] && typeof window !== 'undefined' && global[p].parent === window)\n );\n}\n// 获取instance js source code 执行后 绑定的export 实例\nexport function getGlobalProp(global: Window, useFirstGlobalProp?: boolean) {\n let cnt = 0;\n let foundLastProp;\n let result;\n for (const p in global) {\n // do not check frames cause it could be removed during import\n if (shouldSkipProperty(global, p)) continue;\n if ((cnt === 0 && p !== firstGlobalProp) || (cnt === 1 && p !== secondGlobalProp)) return p;\n if (foundLastProp) {\n lastGlobalProp = p;\n result = (useFirstGlobalProp && result) || p;\n } else {\n foundLastProp = p === lastGlobalProp;\n }\n cnt += 1;\n }\n return result;\n}\n// 标记全局属性\nexport function noteGlobalProps(global: Window) {\n secondGlobalProp = undefined;\n firstGlobalProp = secondGlobalProp;\n for (const p in global) {\n if (shouldSkipProperty(global, p)) continue;\n if (!firstGlobalProp) firstGlobalProp = p;\n else if (!secondGlobalProp) secondGlobalProp = p;\n lastGlobalProp = p;\n }\n return lastGlobalProp;\n}\n// app初始化dom 脚本执行\nexport async function execAppScripts(app: BaseModel) {\n const appInitialScriptList = Array.from(app.source!.scripts.values()).filter(script => script.initial);\n // 初始化脚本最先执行\n if (appInitialScriptList.length) {\n await Promise.all(appInitialScriptList.map(script => script.excuteCode(app)));\n }\n const appScriptList = Array.from(app.source!.scripts.values()).filter(script => script.fromHtml && !script.initial);\n const commomList = appScriptList.filter(script => ((!script.async && !script.defer) || script.isModule));\n // 保证同步脚本 和 module类型 最先执行\n await Promise.all(commomList.map(script => script.excuteCode(app)));\n // 最后执行 defer 和 async 脚本\n const deferScriptList: Promise<HTMLScriptElement | Comment | undefined>[] = [];\n const asyncScriptList: Promise<HTMLScriptElement | Comment | undefined>[] = [];\n // async defer 脚本执行\n appScriptList.forEach((script) => {\n if ((script.defer || script.async)) {\n if (!script.code && script.defer) {\n deferScriptList.push(script.excuteCode(app));\n } else asyncScriptList.push(script.excuteCode(app));\n }\n });\n await Promise.all([...asyncScriptList, ...deferScriptList])\n .catch((e) => {\n console.error(e);\n });\n}\n","import { AppState } from '../common';\nimport { execAppScripts } from '../entry/script';\nimport { EntrySource } from '../entry/entry';\nimport { AppMode, BaseModel, CSS_ATTRIBUTE_KEY, IAppModleProps } from '../typings';\nimport { random } from '../utils/common';\nimport SandBox from '../context/sandbox';\nimport { appCache } from '../cache/app-cache';\nimport { setCurrentRunningApp } from '../context/memory';\nimport { SourceType } from '../utils/load-source';\n\nexport class MicroAppModel implements BaseModel {\n private state: AppState = AppState.UNSET;\n public isPreLoad = false;\n mode: AppMode = 'app';\n name: string;\n url: string;\n container?: HTMLElement | ShadowRoot;\n showSourceCode: boolean;\n scopeCss: boolean;\n scopeJs: boolean;\n source?: EntrySource;\n sandBox?: SandBox;\n scopeLocation: boolean;\n keepAlive: boolean;\n initSource: SourceType;\n iframe: HTMLIFrameElement | null = null;\n public data: Record<string, unknown>;\n constructor(props: IAppModleProps) {\n this.name = props.id !== props.url ? props.id! : random(5);\n this.mode = props.mode ?? 'app';\n this.container = props.container ?? undefined;\n this.showSourceCode = props.showSourceCode ?? false;\n this.url = props.url;\n this.data = props.data || {};\n this.scopeJs = props.scopeJs ?? true;\n this.scopeCss = props.scopeCss ?? true;\n this.scopeLocation = props.scopeLocation ?? false;\n this.isPreLoad = props.isPreLoad ?? false;\n this.keepAlive = props.keepAlive ?? false;\n this.initSource = props.initSource ?? [];\n if (this.scopeJs) {\n this.sandBox = new SandBox(this);\n }\n if (this.container instanceof HTMLElement) {\n this.container.setAttribute(CSS_ATTRIBUTE_KEY, this.name);\n }\n }\n get appCacheKey(): string {\n return this.url;\n }\n public get status() {\n return this.state;\n }\n public set status(v: AppState) {\n this.state = v;\n }\n async start() {\n if (!this.source || [AppState.UNSET, AppState.ERROR].includes(this.status)) {\n this.state = AppState.LOADING;\n if (this.scopeLocation) {\n const iframe = await this.createIframe();\n this.iframe = iframe;\n }\n this.source = new EntrySource(this.url);\n await this.source.importEntery(this);\n }\n }\n onMount(): void {\n if (this.isPreLoad) return;\n this.state = AppState.LOADED;\n this.mount();\n }\n onError(): void {\n this.state = AppState.ERROR;\n }\n mount(\n container?: HTMLElement | ShadowRoot,\n callback?: (app: BaseModel) => void,\n ): void {\n this.isPreLoad = false;\n this.container = container ?? this.container!;\n this.state = AppState.MOUNTING;\n if (this.container) {\n if (this.container instanceof Element) this.container!.setAttribute(CSS_ATTRIBUTE_KEY, this.name);\n const clonedNode = this.source!.html!.cloneNode(true);\n const fragment = document.createDocumentFragment();\n Array.from(clonedNode.childNodes).forEach((node: Node | Element) => {\n fragment.appendChild(node);\n });\n this.container!.innerHTML = '';\n this.container!.appendChild(fragment);\n this.sandBox?.activeated(this.data);\n execAppScripts(this).finally(() => {\n this.state = AppState.MOUNTED;\n callback?.(this);\n });\n }\n }\n activated(\n container: HTMLElement | ShadowRoot,\n callback?: (app: BaseModel) => void,\n ) {\n this.isPreLoad = false;\n this.state = AppState.ACTIVATED;\n if (container && this.container) {\n if (container instanceof Element) container!.setAttribute(CSS_ATTRIBUTE_KEY, this.name);\n const fragment = document.createDocumentFragment();\n Array.from(this.container.childNodes).forEach((node: Node | Element) => {\n fragment.appendChild(node);\n });\n container!.innerHTML = '';\n container!.appendChild(fragment);\n this.container = container;\n this.sandBox?.activeated(this.data);\n callback?.(this);\n }\n }\n deactivated() {\n this.state = AppState.DEACTIVATED;\n this.sandBox?.deactivated();\n }\n unmount(needDestroy = false): void {\n this.state = AppState.UNMOUNT;\n this.sandBox?.deactivated();\n needDestroy && appCache.deleteApp(this.url);\n this.container!.innerHTML = '';\n this.container = undefined;\n }\n createIframe(): Promise<HTMLIFrameElement> {\n return new Promise((resolve) => {\n const iframe = document.createElement('iframe');\n const url = new URL(this.url);\n iframe.setAttribute('src', `about:blank${url.pathname || '/'}${url.search}${url.hash}`);\n iframe.style.cssText = 'position: fixed; top: -9999px; width: 100%; height: 1px;';\n document.body.appendChild(iframe);\n setTimeout(() => resolve(iframe), 100);\n });\n }\n registerRunningApp() {\n setCurrentRunningApp(this);\n Promise.resolve().then(() => setCurrentRunningApp(null));\n }\n}\nexport const createApp = (props: IAppModleProps) => {\n appCache.deleteApp(props.url);\n const instance = new MicroAppModel(props);\n appCache.setApp(instance);\n};\n","import { appCache } from '../cache/app-cache';\nimport { Script } from '../entry/script';\nimport { Style } from '../entry/style';\n\nexport type SourceFuncType = () => Promise<string[]>;\n\nexport type SourceType = string[] | SourceFuncType;\n\n// 收集和辩证资源\nexport async function collectSource(soruceList: SourceType) {\n let source: string[] = [];\n if (typeof soruceList === 'function') {\n source = await soruceList();\n } else {\n source = soruceList || [];\n }\n if (!source.length) return {};\n const collectScript: Map<string, Script> = new Map();\n const collectStyle: Map<string, Style> = new Map();\n source.forEach((str) => {\n try {\n const url = new URL(str);\n if (url.pathname.match(/\\.js$/)) {\n const script = appCache.getCacheScript(str);\n collectScript.set(str, new Script({\n code: script?.code || '',\n async: false,\n defer: false,\n url: str,\n isModule: false,\n initial: true,\n fromHtml: false,\n }));\n } else if (url.pathname.match(/\\.css$/)) {\n const style = appCache.getCacheStyle(str);\n collectStyle.set(str, new Style({\n code: style?.code || '',\n prefetch: false,\n preload: false,\n url: str,\n fromHtml: true,\n initial: true,\n }));\n }\n } catch {\n console.error(`【bk-weweb】: ${str} is invalid URL`);\n }\n });\n return {\n collectScript,\n collectStyle,\n };\n}\n\n// 加载全局静态资源\nexport async function LoadGlobalSource(soruceList: SourceType) {\n const { collectScript, collectStyle } = await collectSource(soruceList);\n const promiseList: Promise<string>[] = [];\n collectScript && Array.from(collectScript.entries()).forEach((item) => {\n promiseList.push(item[1].getCode());\n appCache.setBaseAppScript(...item);\n });\n collectStyle && Array.from(collectStyle.entries()).forEach((item) => {\n promiseList.push(item[1].getCode());\n appCache.setBaseAppStyle(...item);\n });\n await Promise.all(promiseList).catch((e) => {\n throw e;\n });\n}\n","import { BaseModel, IScriptOption } from '../typings';\nimport { MicroAppModel } from '../mode/app';\nimport { fillUpPath, randomUrl, createElement } from '../utils/common';\nimport { fetchSource } from '../utils/fetch';\nimport { excuteAppStyles, Style } from './style';\nimport { MicroInstanceModel } from '../mode/instance';\nimport { Script } from './script';\nimport { isSupportModuleScript } from '../context/memory';\nimport { appCache } from '../cache/app-cache';\nimport { collectSource } from '../utils/load-source';\n\nexport class EntrySource {\n scripts: Map<string, Script>;\n styles: Map<string, Style>;\n html: HTMLElement | null = null;\n rawHtml?: string;\n constructor(public url: string) {\n this.scripts = new Map();\n this.styles = new Map();\n }\n async importEntery(app: BaseModel): Promise<void> {\n let importEntry: Promise<void> | undefined;\n if (app.initSource?.length) {\n // 初始化配置的公共source资源\n const { collectScript, collectStyle } = await collectSource(app.initSource);\n if (collectScript) {\n this.scripts = collectScript;\n }\n if (collectStyle) {\n this.styles = collectStyle;\n }\n }\n if (app instanceof MicroAppModel) importEntry = this.importHtmlEntry(app);\n else if (app instanceof MicroInstanceModel) importEntry = this.importInstanceEntry();\n importEntry && await importEntry;\n }\n async importHtmlEntry(app: MicroAppModel): Promise<void> {\n let htmlStr = appCache.getCacheHtml(this.url);\n if (!htmlStr) {\n htmlStr = await fetchSource(this.url, { cache: 'no-cache' });\n if (!htmlStr) {\n console.error('load app entry error, pleace check');\n return Promise.reject();\n }\n }\n this.rawHtml = htmlStr;\n const wrapElement = createElement('div');\n wrapElement.innerHTML = htmlStr.replace(/<\\/?head>/gim, '').replace(/<\\/?body>/i, '');\n this.collectScriptAndStyle(wrapElement, app);\n await excuteAppStyles(app, wrapElement);\n this.html = wrapElement;\n }\n async importInstanceEntry(): Promise<void> {\n let jsStr = appCache.getCacheScript(this.url)?.code;\n if (!jsStr) {\n jsStr = await fetchSource(this.url, { cache: 'no-cache' });\n }\n if (!jsStr) {\n console.error('load app entry error, pleace check');\n return Promise.reject();\n }\n this.scripts.set(this.url, new Script({\n code: jsStr,\n async: false,\n defer: false,\n url: this.url,\n isModule: false,\n fromHtml: true,\n }));\n }\n collectScriptAndStyle(parent: HTMLElement, app: MicroAppModel): void {\n const children = Array.from(parent.children);\n children.length\n && children.forEach((child) => {\n this.collectScriptAndStyle(child as HTMLElement, app);\n });\n for (const dom of children) {\n if (dom instanceof HTMLLinkElement) {\n this.collectLink(dom, parent);\n } else if (dom instanceof HTMLStyleElement) {\n if (dom.hasAttribute('exclude')) {\n } else if (!dom.hasAttribute('ignore')) {\n this.styles.set(randomUrl(), new Style({\n code: dom.textContent || '',\n url: '',\n fromHtml: true,\n }));\n dom.remove();\n }\n } else if (dom instanceof HTMLScriptElement) {\n this.collectScript(dom, parent);\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', fillUpPath(dom.getAttribute('src')!, this.url));\n }\n }\n }\n collectLink(\n link: HTMLLinkElement,\n parent: Node,\n needReplaceELement = false,\n ): {replace: Element | Comment, style?: Style} {\n if (link.hasAttribute('exclude')) {\n return { replace: document.createComment('【bk-weweb】style with exclude attribute is ignored') };\n }\n if (link.hasAttribute('ignore')) {\n return { replace: link };\n }\n const rel = link.getAttribute('rel');\n let href = link.getAttribute('href');\n let replaceElement;\n if (rel === 'stylesheet' && href) {\n href = fillUpPath(href, this.url);\n replaceElement = document.createComment(`【bk-weweb】style with href=${href}`);\n let styleInstance = this.getStyle(href);\n if (!styleInstance) {\n styleInstance = new Style({\n code: '',\n url: href,\n prefetch: !!link.getAttribute('prefetch'),\n preload: !!link.getAttribute('preload'),\n fromHtml: !needReplaceELement,\n });\n this.styles.set(href, styleInstance);\n }\n !needReplaceELement && parent.replaceChild(replaceElement, link);\n return { replace: replaceElement, style: styleInstance };\n } if (rel && ['prefetch', 'preload', 'prerender', 'icon', 'apple-touch-icon'].includes(rel)) {\n // preload prefetch icon ....\n replaceElement = document.createComment(`【bk-weweb】style with rel=${rel}${href ? ` & href=${href}` : ''}`);\n !needReplaceELement && parent.removeChild(link);\n return { replace: replaceElement };\n } if (href) {\n // dns-prefetch preconnect modulepreload search ....\n link.setAttribute('href', fillUpPath(href, this.url));\n }\n return { replace: link };\n }\n collectScript(\n script: HTMLScriptElement,\n parent: Node,\n needReplaceELement = false,\n ): {replace: Element | Comment, script?: Script} | undefined {\n if (script.hasAttribute('ignore')\n || (script.hasAttribute('type') && !['text/javascript', 'text/ecmascript', 'application/javascript', 'application/ecmascript', 'module'].includes(script.type))\n || (!isSupportModuleScript && script.type === 'module')) {\n return;\n }\n let replaceElement = null;\n if (script.hasAttribute('exclude')) {\n replaceElement = document.createComment('【bk-weweb】script element with exclude attribute is removed');\n !needReplaceELement && parent.replaceChild(replaceElement, script);\n return { replace: replaceElement };\n }\n let src: string | null = script.getAttribute('src');\n if (src) {\n src = fillUpPath(src, this.url);\n let scriptInstance = this.getScript(src);\n if (!scriptInstance) {\n scriptInstance = new Script({\n code: '',\n async: script.hasAttribute('async'),\n defer: script.defer || script.type === 'module',\n isModule: script.type === 'module',\n url: src,\n fromHtml: !needReplaceELement,\n });\n this.scripts.set(src, scriptInstance);\n }\n replaceElement = document.createComment(`【bk-weweb】script with src='${src}'`);\n !needReplaceELement && parent.replaceChild(replaceElement, script);\n return { replace: replaceElement, script: scriptInstance };\n }\n if (script.textContent) {\n const nonceStr: string = randomUrl();\n const scriptInstance = new Script({\n code: script.textContent,\n async: false,\n defer: script.type === 'module',\n isModule: script.type === 'module',\n url: nonceStr!,\n fromHtml: !needReplaceELement,\n });\n this.scripts.set(nonceStr, scriptInstance);\n replaceElement = document.createComment('【bk-weweb】script with texcontent');\n !needReplaceELement && parent.replaceChild(replaceElement, script);\n return { replace: replaceElement, script: scriptInstance };\n }\n return { replace: script };\n }\n setScript(url: string, script: IScriptOption) {\n this.scripts.set(url, new Script(script));\n }\n getScript(url: string) {\n return this.scripts.get(url);\n }\n setStyle(url: string, style: Style) {\n this.styles.set(url, style);\n }\n getStyle(url: string) {\n return this.styles.get(url);\n }\n}\n","import { BaseModel } from '../typings';\nimport { EntrySource } from '../entry/entry';\nimport { AppState } from '../common';\nimport { Style } from '../entry/style';\nimport { Script } from '../entry/script';\n\n// 所有应用缓存\nexport class AppCache {\n private cache: Map<string, BaseModel>;\n // todo 主应用共享资源包\n private baseSource: EntrySource;\n constructor() {\n this.cache = new Map();\n this.baseSource = new EntrySource(location.href);\n // this.baseApp = new\n }\n get hasActiveApp() {\n return Array.from(this.cache.values()).some((app: BaseModel) => app.status !== AppState.UNMOUNT);\n }\n setApp(app: BaseModel) {\n this.cache.set(app.appCacheKey, app);\n }\n getApp(name?: string | null): BaseModel | undefined {\n if (!name) return undefined;\n const app = this.cache.get(name);\n if (app) return app;\n return Array.from(this.cache.values()).find((item: BaseModel) => item.name === name);\n }\n getCacheHtml(url: string): string {\n const list = Array.from(this.cache.values());\n const app = list.find(item => item.url === url);\n if (app) return app.source?.rawHtml || '';\n return '';\n }\n getCacheStyle(url: string): Style | undefined {\n let style: Style | undefined = this.baseSource.getStyle(url);\n if (style) return;\n const list = Array.from(this.cache.values());\n list.some((app) => {\n style = app.source?.getStyle(url);\n return !!style;\n });\n return style;\n }\n getCacheScript(url: string): Script | undefined {\n let script: Script | undefined = this.baseSource.getScript(url);\n if (script) return;\n const list = Array.from(this.cache.values());\n list.some((app) => {\n script = app.source?.getScript(url);\n return !!script;\n });\n return script;\n }\n deleteApp(url: string) {\n this.cache.delete(url);\n }\n setBaseAppStyle(url: string, style: Style) {\n this.baseSource.setStyle(url, style);\n }\n setBaseAppScript(url: string, script: Script) {\n this.baseSource.setScript(url, script);\n }\n}\nconst appCache = new AppCache();\n// 注册全局获取缓存app 或者 instance\nwindow.__getAppOrInstance__ = function (id?: string) {\n if (!id) return appCache;\n return appCache.getApp(id);\n};\nexport {\n appCache,\n};\n","import { isBodyElement } from '../utils/common';\nimport { getCurrentRunningApp } from './memory';\nconst { document } = window;\nconst {\n createElement,\n querySelector,\n querySelectorAll,\n getElementById,\n getElementsByClassName,\n getElementsByTagName,\n getElementsByName,\n} = Document.prototype;\n\nexport function rewriteDocumentPrototypeMethods() {\n Document.prototype.createElement = function<K extends keyof HTMLElementTagNameMap>(\n tagName: K,\n options?: ElementCreationOptions | undefined,\n ) {\n const element = createElement.call(this, tagName, options);\n const app = getCurrentRunningApp();\n // img.src = '' iframe.src = '' 均不能在setAttributes上监听 但是这里所有的src都是 全地址 无法判断是否需要添加子应用域名\n // if (tagName.toLocaleLowerCase() === 'img') {\n // const observer = new MutationObserver((list, observer) => {\n // observer.disconnect();\n // const url = new URL((element as HTMLImageElement).src)\n // (element as HTMLImageElement).src = `${}`\n // });\n // observer.observe(element, { attributeFilter: ['src'], subtree: false, childList: false });\n // }\n if (app) element.__BK_WEWEB_APP_KEY__ = app.appCacheKey;\n return element;\n };\n function querySelectorNew(this: Document, selectors: string): any {\n const app = getCurrentRunningApp();\n if (!app || !selectors || isBodyElement(selectors) || document !== this) {\n return querySelector.call(this, selectors);\n }\n return app?.container?.querySelector(selectors) ?? null;\n }\n function querySelectorAllNew(this: Document, selectors: string): any {\n const app = getCurrentRunningApp();\n if (!app || !selectors || isBodyElement(selectors) || document !== this) {\n return querySelectorAll.call(this, selectors);\n }\n return app?.container?.querySelectorAll(selectors) ?? [];\n }\n Document.prototype.querySelector = querySelectorNew;\n Document.prototype.querySelectorAll = querySelectorAllNew;\n\n Document.prototype.getElementById = function getElementByIdNew(key: string): HTMLElement | null {\n if (!getCurrentRunningApp()) {\n return getElementById.call(this, key);\n }\n try {\n return querySelectorNew.call(this, `#${key}`);\n } catch {\n return getElementById.call(this, key);\n }\n };\n Document.prototype.getElementsByClassName = function (key: string): HTMLCollectionOf<Element> {\n if (!getCurrentRunningApp()) {\n return getElementsByClassName.call(this, key);\n }\n try {\n return querySelectorAllNew.call(this, `.${key}`);\n } catch {\n return getElementsByClassName.call(this, key);\n }\n };\n // eslint-disable-next-line max-len\n Document.prototype.getElementsByTagName = function<K extends keyof HTMLElementTagNameMap>(key: K): HTMLCollectionOf<Element> {\n const app = getCurrentRunningApp();\n if (\n !app\n || isBodyElement(key)\n || (!app?.showSourceCode && key.toLocaleLowerCase() === 'script')\n ) {\n return getElementsByTagName.call(this, key);\n }\n\n try {\n return querySelectorAllNew.call(this, key);\n } catch {\n return getElementsByTagName.call(this, key);\n }\n };\n Document.prototype.getElementsByName = function (key: string): NodeListOf<HTMLElement> {\n if (!getCurrentRunningApp()) {\n return getElementsByName.call(this, key);\n }\n try {\n return querySelectorAllNew.call(this, `[name=${key}]`);\n } catch {\n return getElementsByName.call(this, key);\n }\n };\n}\n\nexport function resetDocumentPrototypeMethods(): void {\n Document.prototype.createElement = createElement;\n Document.prototype.querySelector = querySelector;\n Document.prototype.querySelectorAll = querySelectorAll;\n Document.prototype.getElementById = getElementById;\n Document.prototype.getElementsByClassName = getElementsByClassName;\n Document.prototype.getElementsByTagName = getElementsByTagName;\n Document.prototype.getElementsByName = getElementsByName;\n}\n","import { appCache } from '../cache/app-cache';\nimport { fillUpPath } from '../utils/common';\nimport { elementInsertHandler, elmentAppendHandler, isSepcailElement } from '../utils/element';\nimport { setCurrentRunningApp } from './memory';\n\nconst { setAttribute } = Element.prototype;\nconst {\n appendChild: bodyAppendChild,\n removeChild: bodyRemoveChild,\n append,\n} = HTMLBodyElement.prototype;\nconst {\n appendChild: headAppendChild,\n removeChild: headRemoveChild,\n insertBefore: headInsertBefore,\n} = HTMLHeadElement.prototype;\nconst rawHead = document.head;\n\nexport function rewriteBodyAndHeaderMethods(): void {\n Element.prototype.setAttribute = function (key: string, value: string): void {\n const tagName = this.tagName.toLocaleUpperCase();\n if (\n ((['src', 'srcset'].includes(key) && ['SCRIPT', 'IMG'].includes(tagName))\n || (key === 'href' && ['LINK'].includes(tagName)))\n && this.__BK_WEWEB_APP_KEY__\n && appCache.getApp(this.__BK_WEWEB_APP_KEY__ || '')\n ) {\n setAttribute.call(this, key, fillUpPath(value, appCache.getApp(this.__BK_WEWEB_APP_KEY__!)!.url));\n } else {\n setAttribute.call(this, key, value);\n }\n };\n\n HTMLBodyElement.prototype.appendChild = function appendChildNew<T extends Node>(newChild: T): T {\n if (newChild.__KEEP_ALIVE__ && isSepcailElement(newChild)) return (headAppendChild as any).call(rawHead, newChild);\n return elmentAppendHandler(this, newChild, bodyAppendChild);\n };\n HTMLBodyElement.prototype.append = function <T extends Node>(...nodes: T[]): void {\n let i = 0;\n const { length } = nodes;\n while (i < length) {\n if (nodes[i].__KEEP_ALIVE__ && isSepcailElement(nodes[i])) {\n return (headAppendChild as any).call(rawHead, nodes[i]);\n };\n elmentAppendHandler(this, nodes[i] as Node, bodyAppendChild);\n i += 1;\n }\n };\n HTMLHeadElement.prototype.appendChild = HTMLBodyElement.prototype.appendChild;\n\n\n HTMLHeadElement.prototype.insertBefore = function <T extends Node>(newChild: T, refChild: Node | null): T {\n return elementInsertHandler(this, newChild, refChild, headInsertBefore);\n };\n HTMLBodyElement.prototype.removeChild = function removeChildNew<T extends Node>(oldChild: T): T {\n const app = appCache.getApp(oldChild.__BK_WEWEB_APP_KEY__!);\n if (app?.container?.contains(oldChild)) {\n const node = bodyRemoveChild.call(app.container, oldChild) as T;\n return node;\n } if (this.contains(oldChild)) {\n return bodyRemoveChild.call(this, oldChild) as T;\n }\n return oldChild;\n };\n HTMLHeadElement.prototype.removeChild = HTMLBodyElement.prototype.removeChild;\n}\n\nexport function resetBodyAndHeaderMethods(): void {\n setCurrentRunningApp(null);\n Element.prototype.setAttribute = setAttribute;\n HTMLBodyElement.prototype.appendChild = bodyAppendChild;\n HTMLBodyElement.prototype.append = append;\n HTMLBodyElement.prototype.removeChild = bodyRemoveChild;\n HTMLHeadElement.prototype.appendChild = headAppendChild;\n HTMLHeadElement.prototype.insertBefore = headInsertBefore;\n HTMLHeadElement.prototype.removeChild = headRemoveChild;\n}\n","import { rewriteDocumentPrototypeMethods } from '../context/document';\nimport { rewriteBodyAndHeaderMethods } from '../context/element';\n\nexport function beforeLoad() {\n rewriteBodyAndHeaderMethods();\n rewriteDocumentPrototypeMethods();\n}\n","import { MicroAppModel } from '../mode/app';\nimport { appCache } from '../cache/app-cache';\nimport { BaseModel, IAppModleProps, IBaseModelProps, IJsModelProps } from '../typings';\nimport { MicroInstanceModel } from '../mode/instance';\nimport { AppState } from '../common';\n\nexport async function load(props: IBaseModelProps): Promise<BaseModel> {\n if (props.mode === 'app') return await loadApp(props);\n if (props.mode === 'js') return await loadInstance(props);\n return await loadApp(props);\n}\n// 加载app\nexport async function loadApp(props: IAppModleProps): Promise<MicroAppModel> {\n let instance = appCache.getApp(props.id);\n if (!instance) {\n instance = new MicroAppModel(props);\n appCache.setApp(instance);\n }\n await instance.start();\n return instance as MicroAppModel;\n}\n// 加载instance\nexport function loadInstance(props: IJsModelProps): Promise<MicroInstanceModel> {\n return new Promise((resolve) => {\n let instance = appCache.getApp(props.id);\n if (!instance) {\n instance = new MicroInstanceModel(props);\n appCache.setApp(instance);\n instance.start().then(() => resolve(instance as MicroInstanceModel));\n } else if ([AppState.UNSET, AppState.MOUNTING].includes(instance.status)) {\n const timer = setInterval(() => {\n if ([AppState.ERROR, AppState.MOUNTED].includes(instance!.status)) {\n resolve(instance as MicroInstanceModel);\n clearInterval(timer);\n }\n }, 300);\n } else {\n resolve(instance as MicroInstanceModel);\n }\n });\n}\n","import { resetDocumentPrototypeMethods } from '../context/document';\nimport { resetBodyAndHeaderMethods } from '../context/element';\nimport { AppState } from '../common';\nimport { appCache } from '../cache/app-cache';\n\nexport function unmount(appKey: string) {\n const app = appCache.getApp(appKey);\n if (app?.status !== AppState.UNMOUNT) {\n app?.unmount();\n }\n if (!appCache.hasActiveApp) {\n resetBodyAndHeaderMethods();\n resetDocumentPrototypeMethods();\n }\n}\n","import { nextTask } from '../utils/common';\nimport { appCache } from '../cache/app-cache';\nimport { BaseModel } from '../typings';\nimport { AppState } from '../common';\n\nexport function activated<T>(\n appKey: string,\n container: HTMLElement | ShadowRoot,\n callback?: <M extends BaseModel>(instance: M, exportInstance?: T) => void,\n) {\n const app = appCache.getApp(appKey);\n if (app?.status === AppState.DEACTIVATED && app.keepAlive) {\n nextTask(() => app?.activated(container, callback));\n } else {\n nextTask(() => app?.mount(container, callback));\n }\n}\n","import { resetDocumentPrototypeMethods } from '../context/document';\nimport { resetBodyAndHeaderMethods } from '../context/element';\nimport { AppState } from '../common';\nimport { appCache } from '../cache/app-cache';\n\nexport function deactivated(appKey: string) {\n const app = appCache.getApp(appKey);\n if (app && [AppState.ACTIVATED, AppState.MOUNTED].includes(app.status)) {\n app.keepAlive ? app.deactivated() : app.unmount();\n }\n if (!appCache.hasActiveApp) {\n resetBodyAndHeaderMethods();\n resetDocumentPrototypeMethods();\n }\n}\n","import { AppState } from '../common';\nimport { IAppModleProps, IJsModelProps } from '../typings';\nimport { appCache } from '../cache/app-cache';\nimport { beforeLoad } from '../lifecircle/before-load';\nimport { load } from '../lifecircle/load';\nimport { unmount } from '../lifecircle/unmount';\n// import { mount } from '../lifecircle/mount';\nimport { activated } from '../lifecircle/activated';\nimport { deactivated } from '../lifecircle/deactivated';\n// bk-weweb支持的属性配置\nexport enum ObserveAttrs {\n URL = 'url',\n showSourceCode = 'showSourceCode',\n scopeLocation = 'scopeLocation',\n setShodowDom = 'setShodowDom',\n mode = 'mode',\n data = 'data',\n id = 'id',\n scopeJs = 'scopeJs',\n scopeCss = 'scopeCss',\n keepAlive = 'keepAlive'\n}\nexport default class BkIframeElement extends HTMLElement {\n static get observedAttributes(): string[] {\n return [ObserveAttrs.URL];\n }\n private connected = false;\n private appUrl = '';\n // 考虑到js模式下 需要js bundle的复用性 需用户设置id属性 如果单实例下则可以不用配置\n get appKey(): string | null {\n return this.getAttribute(ObserveAttrs.id) || this.getAttribute(ObserveAttrs.URL);\n }\n get appData(): Record<string, unknown> {\n if (this.hasAttribute(ObserveAttrs.data)) {\n try {\n return JSON.parse(this.getAttribute(ObserveAttrs.data)!);\n } catch {}\n }\n return {};\n }\n get appProps(): IAppModleProps | IJsModelProps {\n if (this.getAttribute('mode') === 'js') {\n return {\n url: this.getAttribute(ObserveAttrs.URL)!,\n mode: 'js',\n id: this.appKey!,\n data: this.appData,\n container: this.shadowRoot ?? this,\n showSourceCode: this.getBooleanAttr(ObserveAttrs.showSourceCode),\n scopeCss: this.getBooleanAttr(ObserveAttrs.scopeCss) && !this.getBooleanAttr(ObserveAttrs.setShodowDom),\n scopeJs: this.getBooleanAttr(ObserveAttrs.scopeJs),\n keepAlive: this.getBooleanAttr(ObserveAttrs.keepAlive),\n };\n }\n return {\n url: this.getAttribute(ObserveAttrs.URL)!,\n mode: 'app',\n id: this.appKey!,\n data: this.appData,\n container: this.shadowRoot ?? this,\n scopeLocation: this.getBooleanAttr(ObserveAttrs.scopeLocation),\n showSourceCode: this.getBooleanAttr(ObserveAttrs.showSourceCode),\n scopeCss: !this.getBooleanAttr(ObserveAttrs.setShodowDom),\n scopeJs: !this.getBooleanAttr(ObserveAttrs.scopeJs),\n keepAlive: this.getBooleanAttr(ObserveAttrs.keepAlive),\n };\n }\n async connectedCallback(): Promise<void> {\n beforeLoad();\n if (this.getBooleanAttr(ObserveAttrs.setShodowDom) && !this.shadowRoot) {\n this.attachShadow({ mode: 'open', delegatesFocus: true });\n }\n await load(this.appProps);\n activated(this.appKey!, this.shadowRoot ?? this);\n this.connected = true;\n }\n disconnectedCallback(): void {\n this.connected = false;\n if (this.appProps.keepAlive) {\n deactivated(this.appKey!);\n } else unmount(this.appKey!);\n }\n attributeChangedCallback(attr: ObserveAttrs, _oldVal: string, newVal: string): void {\n if (attr !== ObserveAttrs.URL || (this as any)[attr] === newVal) return;\n this.appUrl = newVal;\n (this.connected || appCache.getApp(this.appKey!)) && this.handleAttributeChanged();\n }\n private async handleAttributeChanged(): Promise<void> {\n if (!this.appKey) return;\n if (this.getBooleanAttr(ObserveAttrs.setShodowDom)) {\n this.attachShadow({ mode: 'open' });\n }\n const app = appCache.getApp(this.appKey!);\n if (app && app.url === this.appUrl && (app.isPreLoad || app.status === AppState.UNMOUNT)) {\n activated(this.appKey!, this.shadowRoot ?? this);\n return;\n }\n await load(this.appProps);\n }\n private getBooleanAttr(name: string): boolean | undefined {\n return this.hasAttribute(name) ? this.getAttribute(name) !== 'false' : undefined;\n }\n}\n","import './context/memory';\nimport { FetchSourceType, IStartOption } from './typings';\nimport BkIframeElement from './component/web-compnent';\n\nexport * from './lifecircle/before-load';\nexport * from './lifecircle/load';\nexport * from './lifecircle/mount';\nexport * from './lifecircle/unload';\nexport * from './lifecircle/unmount';\nexport * from './lifecircle/activated';\nexport * from './lifecircle/deactivated';\nexport * from './preload/preload';\n\nconst CUSTOM_ELEMENT_TAG = 'bk-weweb';\nexport class IframeApp {\n fetchSource?: FetchSourceType;\n webcomponentTag = CUSTOM_ELEMENT_TAG;\n constructor() {\n if (!window.customElements.get(CUSTOM_ELEMENT_TAG)) {\n window.customElements.define(CUSTOM_ELEMENT_TAG, BkIframeElement);\n }\n }\n // todo set some global start props\n start(option?: IStartOption) {\n if (typeof option?.fetchSource === 'function') {\n this.fetchSource = option.fetchSource;\n }\n this.webcomponentTag = option?.webcomponentTag || CUSTOM_ELEMENT_TAG;\n this.setWebComponentTag();\n }\n // 设置自定义dom标签名\n setWebComponentTag() {\n if (!window.customElements.get(this.webcomponentTag)) {\n window.customElements.define(this.webcomponentTag, BkIframeElement);\n }\n }\n}\nconst iframeApp = new IframeApp();\nexport default iframeApp;\n","import { nextTask } from '../utils/common';\nimport { appCache } from '../cache/app-cache';\nimport { BaseModel } from '../typings';\n\nexport function mount<T>(\n appKey: string,\n container?: HTMLElement | ShadowRoot,\n callback?: <M extends BaseModel>(instance: M, exportInstance?: T) => void,\n) {\n const app = appCache.getApp(appKey);\n nextTask(() => app?.mount(container, callback));\n}\n","/* eslint-disable @typescript-eslint/no-misused-promises */\nimport { IAppModleProps, IJsModelProps } from '../typings';\nimport { requestIdleCallback } from '../utils/common';\nimport { loadApp, loadInstance } from '../lifecircle/load';\nimport { LoadGlobalSource, SourceType } from '../utils/load-source';\n\n// 预加载微模块\nexport function preLoadInstance(options: IJsModelProps) {\n requestIdleCallback(() => loadInstance({\n ...options,\n isPreLoad: true,\n }));\n}\n// 预加载微应用\nexport function preLoadApp(options: IAppModleProps) {\n requestIdleCallback(() => loadApp({\n ...options,\n isPreLoad: true,\n }));\n}\n// 预加载资源\nexport function preLoadSource(sourceList: SourceType) {\n requestIdleCallback(() => {\n LoadGlobalSource(sourceList);\n });\n}\n","import { appCache } from '../cache/app-cache';\n\nexport function unload(url: string) {\n appCache.deleteApp(url);\n}\n"],"names":["currentRunningApp","getCurrentRunningApp","setCurrentRunningApp","appInstance","documentClickListMap","Map","documentEventListenerMap","isSupportModuleScript","document","createElement","templateStyle","setAttribute","body","appendChild","sheet","disabled","disabledStyleDom","AppState","isFunction","target","nextTask","window","Zone","setTimeout","cb","Promise","resolve","then","addUrlProtocol","url","startsWith","location","protocol","fillUpPath","path","baseURI","test","URL","origin","pathname","pathArr","split","pop","join","replace","getUrlDir","toString","isIE11","navigator","userAgent","indexOf","randomUrl","random","requestIdleCallback","fn","lastTime","Date","now","didTimeout","handle","Math","max","tagName","options","element","__BK_WEWEB_APP_KEY__","isBodyElement","key","n","str","result","i","parseInt","length","fetchSource","weWeb","fetch","res","text","CSS_ATTRIBUTE_KEY","CSS_RULE_TYPE","commonEScapeKeyList","escapeSetterKeyList","scopeWindowKeyList","scopedLocationKeyList","DescriptorMapValue","commonRawWindowKeyMap","undefined","Array","Object","String","Boolean","Reflect","Function","Number","Symbol","parseFloat","Float32Array","Set","Infinity","devicePixelRatio","HTMLElement","Element","performance","console","isFinite","RegExp","JSON","Proxy","isNaN","WeakMap","WeakSet","Uint8Array","commonFakeWindowKeyMap","__VUE_OPTIONS_API__","__VUE_I18N_LEGACY_API__","__VUE_I18N_FULL_INSTALL__","__VUE_DEVTOOLS_GLOBAL_HOOK__","__VUE_DEVTOOLS_HOOK_REPLAY__","__VUE_DEVTOOLS_PLUGINS__","__DEV__","webpackChunktrace","i18n","constructorMap","rawWindowMethodMap","bindFunctionToRawWindow","rawWindow","value","has","get","valueStr","prototype","constructor","getOwnPropertyNames","set","isConstructor","bindRawWindowValue","bind","keys","forEach","hasOwnProperty","SandBox","app","resetWindowFunction","resetDocumentAndBodyEvent","injectedKeySet","escapedKeySet","active","rawDocument","proxyWindow","fakeWindow","windowSymbolKey","this","descriptorMap","__POWERED_BY_BK_WEWEB__","appCacheKey","eventListenerMap","intervalIdMap","timeoutIdMap","addEventListener","removeEventListener","setInterval","clearInterval","clearTimeout","documentRemoveEventListener","type","listener","listenerList","add","call","size","delete","handler","timeout","args","intervalId","timeoutId","clear","_","documentAppListenersMap","rewriteWindowFunction","name","unscopables","includes","registerRunningApp","eval","MicroAppModel","iframe","scopeLocation","contentWindow","parent","rawValue","descriptor","getOwnPropertyDescriptor","writable","configurable","enumerable","defineProperty","WINDOW","ownKeys","arrayUnique","array","concat","from","deleteProperty","showSourceCode","activeated","data","__BK_WEWEB_DATA__","bodyAddEventListener","bodyRemoveEventListener","appListenersMap","appListenerList","container","ShadowRoot","rewriteDocumentAndBodyEvent","deactivated","eventHandler","event","defineProperties","currentTarget","srcElement","dispatchLinkOrScriptLoad","CustomEvent","onload","dispatchEvent","bodyAppendChild","HTMLBodyElement","resetNewElement","child","HTMLStyleElement","hasAttribute","createComment","styleInstance","Style","code","textContent","fromHtml","source","setStyle","scopedStyleCSS","HTMLLinkElement","collectLink","style","scopedLinkCSS","HTMLScriptElement","replaceInfo","collectScript","script","excuteCode","scopeJs","getAttribute","observer","MutationObserver","disconnect","scriptInfo","remove","scriptInstance","Script","async","defer","isModule","scripts","e","error","observe","attributeFilter","childList","subtree","isSepcailElement","node","elmentAppendHandler","newChild","rawMethod","appCache","getApp","targetChild","needKeepAlive","keepAlive","head","setMarkElement","__KEEP_ALIVE__","scopedCode","prefetch","preload","scoped","initial","styles","getCacheStyle","catch","styleElement","getCode","innerHTML","commonScoped","cssRules","attributes","characterData","linkElement","prepend","href","onerror","dispatchLinkOrScriptError","scopeCss","cssText","resetUrlHost","rules","cssPrefix","scopedCss","scopeRule","all","$1","$2","rule","STYLE_RULE","scopeStyleRule","MEDIA_RULE","resetPackRule","SUPPORTS_RULE","prefix","packName","conditionText","linkpath","getFileDir","selectorText","builtInRootSelectorRE","selectors","excuteAppStyles","styleList","values","promiseList","push","styleElementList","parentElemnt","append","MicroInstanceModel","state","UNSET","isPreLoad","sandBox","initSource","props","id","status","v","ERROR","EntrySource","importEntery","onMount","LOADED","mount","onError","callback","MOUNTING","instanceWrap","wrapId","execAppScripts","finally","MOUNTED","getScript","exportInstance","render","activated","ACTIVATED","fragment","createDocumentFragment","childNodes","DEACTIVATED","unmount","needDestroy","UNMOUNT","deleteApp","firstGlobalProp","secondGlobalProp","lastGlobalProp","getCacheScript","needRelaceScriptElement","global","p","shouldSkipProperty","noteGlobalProps","transformCode","scriptElement","executeSourceScript","executeMemoryScript","exportProp","useFirstGlobalProp","foundLastProp","cnt","getGlobalProp","blob","Blob","src","createObjectURL","isScopedLocation","history","appInitialScriptList","filter","map","appScriptList","commomList","deferScriptList","asyncScriptList","mode","LOADING","createIframe","clonedNode","html","cloneNode","search","hash","collectSource","soruceList","collectStyle","match","rawHtml","importEntry","importHtmlEntry","importInstanceEntry","htmlStr","getCacheHtml","cache","reject","wrapElement","collectScriptAndStyle","jsStr","children","dom","HTMLMetaElement","HTMLTitleElement","removeChild","HTMLImageElement","link","needReplaceELement","rel","replaceElement","getStyle","replaceChild","nonceStr","setScript","baseSource","hasActiveApp","some","setApp","find","item","setBaseAppStyle","setBaseAppScript","__getAppOrInstance__","querySelector","querySelectorAll","getElementById","getElementsByClassName","getElementsByTagName","getElementsByName","Document","resetDocumentPrototypeMethods","bodyRemoveChild","headAppendChild","headRemoveChild","insertBefore","headInsertBefore","HTMLHeadElement","rawHead","rewriteBodyAndHeaderMethods","toLocaleUpperCase","nodes","refChild","passiveChild","contains","elementInsertHandler","oldChild","resetBodyAndHeaderMethods","beforeLoad","querySelectorNew","querySelectorAllNew","toLocaleLowerCase","rewriteDocumentPrototypeMethods","load","loadApp","loadInstance","instance","start","timer","appKey","ObserveAttrs","BkIframeElement","observedAttributes","connected","appUrl","appData","parse","appProps","shadowRoot","getBooleanAttr","setShodowDom","attachShadow","delegatesFocus","disconnectedCallback","attributeChangedCallback","attr","_oldVal","newVal","handleAttributeChanged","CUSTOM_ELEMENT_TAG","IframeApp","webcomponentTag","customElements","define","option","setWebComponentTag","iframeApp","sourceList","entries","LoadGlobalSource"],"mappings":"gPAEA,IAAIA,EAAsC,cAC1BC,IACd,OAAOD,EAEH,SAAUE,EAAqBC,GACnCH,EAAoBG,EAIf,MAAMC,EAAuB,IAAIC,IAG3BC,EAA2B,IAAID,IAG/BE,EAAwB,aADtBC,SAASC,cAAc,UAKhCC,EAAkCF,SAASC,cAAc,SAC/DC,EAAcC,aAAa,KAHQ,uBAInCH,SAASI,KAAKC,YAAYH,GAC1BA,EAAcI,MAAOC,UAAW,EACzB,MAAMC,EAAmBN,ECxBhC,IAAYO,ECAN,SAAUC,EAAWC,GACzB,MAAyB,mBAAXA,GDDhB,SAAYF,GACVA,EAAA,MAAA,QACAA,EAAA,QAAA,UACAA,EAAA,OAAA,SACAA,EAAA,MAAA,QACAA,EAAA,SAAA,WACAA,EAAA,QAAA,UACAA,EAAA,UAAA,YACAA,EAAA,YAAA,cACAA,EAAA,QAAA,UATF,CAAYA,IAAAA,EAUX,KCNM,MAAMG,EAA2D,mBAAhBC,OAAOC,KAAsBC,WAAaC,GAAMC,QAAQC,UAAUC,KAAKH,GAazH,SAAUI,EAAeC,GAC7B,OAAOA,EAAIC,WAAW,MAAQ,GAAGC,SAASC,WAAWH,IAAQA,EAe/C,SAAAI,EAAWC,EAAcC,GACvC,OAAKD,GAAQ,+BAA+BE,KAAKF,IAAS,gBAAgBE,KAAKF,GAAcA,EAEtF,IAAIG,IAAIH,EAdX,SAAoBL,GACxB,MAAMS,OAAEA,EAAMC,SAAEA,GAAa,IAAIF,IAAIR,GACrC,GAAI,WAAWO,KAAKG,GAAW,CAC7B,MACMC,EADW,GAAGF,IAASC,IACJE,MAAM,KAE/B,OADAD,EAAQE,MACD,GAAGF,EAAQG,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zBjB,EAAS4K,oBAAoBF,MAE/BhC,GAAgBpU,MAAMmH,KAAKiN,EAAaoG,WAAWrX,SAASiT,IAC1DnH,EAAYC,KAAKkH,EAAK,GAAGzJ,WACzBjB,EAAS2K,mBAAmBD,YAExBna,QAAQ4R,IAAIoB,GAAaxC,OAAO1B,IACpC,MAAMA,Ka5CN0P,CAAiBF,gBCrBf,SAAiBle,GACrBqP,EAASgG,UAAUrV"}
1
+ {"version":3,"file":"index.umd.js","sources":["../context/memory.ts","../common/state.ts","../utils/common.ts","../utils/fetch.ts","../typings/source.ts","../typings/sandbox.ts","../context/function.ts","../context/sandbox.ts","../context/window.ts","../utils/element-event.ts","../utils/element.ts","../entry/style.ts","../mode/instance.ts","../entry/script.ts","../mode/app.ts","../utils/load-source.ts","../entry/entry.ts","../cache/app-cache.ts","../context/document.ts","../context/element.ts","../lifecircle/before-load.ts","../lifecircle/load.ts","../lifecircle/unmount.ts","../lifecircle/activated.ts","../lifecircle/deactivated.ts","../component/web-compnent.ts","../index.ts","../lifecircle/mount.ts","../preload/preload.ts","../lifecircle/unload.ts"],"sourcesContent":["import { BaseModel } from '../typings';\n\nlet currentRunningApp: BaseModel | null = null;\nexport function getCurrentRunningApp() {\n return currentRunningApp;\n}\nexport function setCurrentRunningApp(appInstance: BaseModel | null) {\n currentRunningApp = appInstance;\n}\n\n\nexport const documentClickListMap = new Map<string, unknown>();\nexport type DocumentEventType = keyof DocumentEventMap;\nexport type DocumentEventListener =(this: Document, ev: DocumentEventMap[DocumentEventType]) => any;\nexport const documentEventListenerMap = new Map<string, Map<keyof DocumentEventMap, Set<DocumentEventListener>>>();\n\nconst script = document.createElement('script');\nexport const isSupportModuleScript = 'noModule' in script;\n\nexport const SCOPED_CSS_STYLE_ID = 'SCOPED_CSS_STYLE_ID';\n\nconst templateStyle: HTMLStyleElement = document.createElement('style');\ntemplateStyle.setAttribute('id', SCOPED_CSS_STYLE_ID);\ndocument.body.appendChild(templateStyle);\ntemplateStyle.sheet!.disabled = true;\nexport const disabledStyleDom = templateStyle;\n","// app status\nexport enum AppState {\n UNSET = 'UNSET',\n LOADING = 'LOADING',\n LOADED = 'LOADED',\n ERROR = 'ERROR',\n MOUNTING = 'MOUNTING',\n MOUNTED = 'MOUNTED',\n ACTIVATED = 'ACTIVATED',\n DEACTIVATED = 'DEACTIVATED',\n UNMOUNT = 'UNMOUNT'\n}\n","// is function\nexport function isFunction(target: unknown): boolean {\n return typeof target === 'function';\n}\n// Promise.then might be synchronized in Zone.js context, we need to use setTimeout instead to mock next tick.\nexport const nextTask: (cb: () => void) => any = typeof window.Zone === 'function' ? setTimeout : cb => Promise.resolve().then(cb);\n\nlet globalTaskPending = false;\nexport function nextTick(cb: () => void): void {\n if (!globalTaskPending) {\n globalTaskPending = true;\n nextTask(() => {\n cb();\n globalTaskPending = false;\n });\n }\n}\n\nexport function addUrlProtocol(url: string): string {\n return url.startsWith('//') ? `${location.protocol}${url}` : url;\n}\n\n// Get valid address, such as https://xxx/xx/xx.html to https://xxx/xx/\nexport function getUrlDir(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 return `${origin}${pathname}/`.replace(/\\/\\/$/, '/');\n}\n// 补齐url地址\nexport function fillUpPath(path: string, baseURI: string): string {\n if (!path || /^((((ht|f)tps?)|file):)?\\/\\//.test(path) || /^(data|blob):/.test(path)) return path;\n\n return new URL(path, getUrlDir(addUrlProtocol(baseURI))).toString();\n}\n// 获取url目录\nexport function getFileDir(linkpath: string): string {\n const pathArr = linkpath.split('/');\n pathArr.pop();\n return addUrlProtocol(`${pathArr.join('/')}/`);\n}\n// is ie11\nexport const isIE11 = typeof navigator !== 'undefined' && navigator.userAgent.indexOf('Trident') !== -1;\n\n// 随机url\nexport function randomUrl(): string {\n return `inline-${random(16)}`;\n}\n\n// Array deduplication\nexport function arrayUnique(array: any[]): any[] {\n return Array.from(new Set(array));\n}\n\n// requestIdleCallback polyfill\nexport const requestIdleCallback = window.requestIdleCallback\n || function (fn: CallableFunction) {\n const lastTime = Date.now();\n return setTimeout(() => {\n fn({\n didTimeout: false,\n handle() {\n return Math.max(0, 50 - (Date.now() - lastTime));\n },\n });\n }, 1);\n };\n\n// is safari browser\nexport function isSafari(): boolean {\n return /Safari/.test(navigator.userAgent);\n}\n\n// Create pure elements\nexport function createElement<K extends keyof HTMLElementTagNameMap>(\n tagName: K,\n options?: ElementCreationOptions,\n): HTMLElementTagNameMap[K] {\n const element = document.createElement(tagName, options);\n if (element.__BK_WEWEB_APP_KEY__) delete element.__BK_WEWEB_APP_KEY__;\n return element;\n}\n\n// bodyle element\nexport function isBodyElement(key: string): boolean {\n return /^(body|head|html)$/i.test(key);\n}\n// create random string\nexport const random = (n: number, str = 'abcdefghijklmnopqrstuvwxyz0123456789') => {\n // 生成n位长度的字符串\n let result = '';\n for (let i = 0; i < n; i++) {\n result += str[parseInt((Math.random() * str.length).toString(), 10)];\n }\n return result;\n};\n","import weWeb from '..';\n\nexport function fetchSource(url: string, options = {}): Promise<string> {\n if (weWeb.fetchSource) {\n return weWeb.fetchSource(url, options);\n }\n return window.fetch(url, options).then(res => res.text());\n}\n","export interface IStyleOption {\n code: string;\n prefetch?: boolean;\n preload?: boolean;\n url?: string;\n fromHtml: boolean\n initial?: boolean\n}\n\nexport interface IScriptOption {\n code: string; // code\n async: boolean; // async script\n defer: boolean; // defer script\n isModule: boolean; // module type script\n url?: string;\n fromHtml: boolean;\n initial?: boolean;\n};\n\nexport const CSS_ATTRIBUTE_KEY = 'id';\n\nexport enum CSS_RULE_TYPE {\n STYLE_RULE = 1,\n MEDIA_RULE = 4,\n SUPPORTS_RULE = 12\n}\n","export interface IInjectWindowAttrs {\n __POWERED_BY_BK_WEWEB__: boolean;\n __BK_WEWEB_APP_KEY__: string;\n __BK_WEWEB_DATA__: Record<string, unknown>;\n rawWindow: Window;\n rawDocument: Document;\n webpackChunkpc?: any[];\n}\n\n\nexport const commonEScapeKeyList: PropertyKey[] = ['System', '__cjsWrapper', '__REACT_ERROR_OVERLAY_GLOBAL_HOOK__'];\n// 共享主应用上下文属性名\nexport const escapeSetterKeyList: PropertyKey[] = ['location'];\n// 一定需要在子应用自身上下文获取的属性名\nexport const scopeWindowKeyList: PropertyKey[] = ['webpackJsonp', '__POWERED_BY_BK_WEWEB__', '__BK_WEWEB_APP_KEY__', '__BK_WEWEB_DATA__'];\n// 设置了scopedLocation 后需要监听属性名\nexport const scopedLocationKeyList: PropertyKey[] = ['location', 'history'];\n\nexport enum DescriptorMapValue {\n 'TARGET' = 'TARGET',\n 'WINDOW' = 'WINDOW'\n};\n\nexport const commonRawWindowKeyMap: any = {\n undefined: true,\n Array: true,\n Object: true,\n String: true,\n Boolean: true,\n Math: true,\n Reflect: true,\n Function: true,\n Number: true,\n Symbol: true,\n parseFloat: true,\n parseInt: true,\n Float32Array: true,\n Set: true,\n Infinity: true,\n navigator: true,\n devicePixelRatio: true,\n Promise: true,\n HTMLElement: true,\n Map: true,\n Element: true,\n performance: true,\n console: true,\n isFinite: true,\n RegExp: true,\n JSON: true,\n Date: true,\n Proxy: true,\n isNaN: true,\n WeakMap: true,\n WeakSet: true,\n Uint8Array: true,\n // btoa: true,\n // unescape: true,\n // WebSocket: true,\n // encodeURIComponent: true,\n // decodeURIComponent: true,\n // ArrayBuffer: true,\n // XMLHttpRequest: true,\n // SVGElement: true,\n // URLSearchParams: true,\n // URL: true,\n // RangeError: true,\n // TypeError: true,\n // Uint16Array: true,\n // Uint32Array: true,\n // Float64Array: true,\n // Int32Array: true,\n // requestAnimationFrame: true,\n // SVGRect: true,\n // Error: true,\n // Buffer: true,\n // SyntaxError: true,\n // DataView: true,\n // Worker: true,\n // localStorage: true,\n // Text: true,\n // FormData: true,\n // ShadowRoot: true,\n // encodeURI: true,\n // crypto: true,\n // HTMLAnchorElement: true,\n // Int8Array: true,\n // FinalizationRegistry: true,\n // BigInt: true,\n // Atomics: true,\n // Uint8ClampedArray: true,\n // WeakRef: true,\n // getComputedStyle,\n // innerHeight: true,\n // innerWidth: true,\n // getComputedStyle: true,\n};\nexport const commonFakeWindowKeyMap: any = {\n __VUE_OPTIONS_API__: true,\n __VUE_I18N_LEGACY_API__: true,\n __VUE_I18N_FULL_INSTALL__: true,\n __VUE_DEVTOOLS_GLOBAL_HOOK__: true,\n __VUE_DEVTOOLS_HOOK_REPLAY__: true,\n __VUE_DEVTOOLS_PLUGINS__: true,\n __DEV__: true,\n webpackChunktrace: true,\n webpackChunkpc: true,\n webpackChunkapm: true,\n i18n: true,\n '__core-js_shared__': true,\n};\nexport const commonWindowNameMap: any = {\n window: true,\n self: true,\n globalThis: true,\n};\n","import { isFunction } from '../utils/common';\n\nconst constructorMap = new WeakMap<Function | FunctionConstructor, boolean>();\nfunction isConstructor(value: Function | FunctionConstructor) {\n if (constructorMap.has(value)) {\n return constructorMap.get(value);\n }\n\n const valueStr = value.toString();\n\n const result = (value.prototype\n && value.prototype.constructor === value\n && Object.getOwnPropertyNames(value.prototype).length > 1)\n || /^function\\s+[A-Z]/.test(valueStr)\n || /^class\\s+/.test(valueStr);\n\n constructorMap.set(value, result);\n\n return result;\n}\nconst rawWindowMethodMap = new WeakMap<CallableFunction, CallableFunction>();\nexport default function bindFunctionToRawWindow(rawWindow: Window, value: any): unknown {\n if (rawWindowMethodMap.has(value)) {\n return rawWindowMethodMap.get(value);\n }\n\n if (isFunction(value) && !isConstructor(value)) {\n const bindRawWindowValue = value.bind(rawWindow);\n Object.keys(value).forEach(key => (bindRawWindowValue[key] = value[key]));\n // eslint-disable-next-line no-prototype-builtins\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","/* eslint-disable no-new-func */\n/* eslint-disable no-param-reassign */\n/* eslint-disable no-prototype-builtins */\nimport {\n BaseModel,\n escapeSetterKeyList,\n IInjectWindowAttrs,\n scopedLocationKeyList,\n scopeWindowKeyList,\n commonEScapeKeyList,\n commonFakeWindowKeyMap,\n commonRawWindowKeyMap,\n DescriptorMapValue,\n} from '../typings';\nimport { arrayUnique, random } from '../utils/common';\nimport { MicroAppModel } from '../mode/app';\nimport bindFunctionToRawWindow from './function';\nimport { rewriteWindowFunction, rewriteDocumentAndBodyEvent } from './window';\nexport default class SandBox {\n private resetWindowFunction: CallableFunction;\n private resetDocumentAndBodyEvent?: CallableFunction;\n private injectedKeySet = new Set<PropertyKey>();\n private escapedKeySet = new Set<PropertyKey>();\n private active = false;\n\n public rawWindow: Window;\n public rawDocument: Document;\n public proxyWindow: WindowProxy & IInjectWindowAttrs;\n public fakeWindow: Window & IInjectWindowAttrs = {} as any;\n public windowSymbolKey: keyof Window;\n constructor(public app: BaseModel) {\n const descriptorMap = new Map<PropertyKey, DescriptorMapValue>();\n const rawWindow = window;\n const rawDocument = window.document;\n this.fakeWindow.__POWERED_BY_BK_WEWEB__ = true;\n this.fakeWindow.__BK_WEWEB_APP_KEY__ = app.appCacheKey;\n this.rawWindow = rawWindow;\n this.rawDocument = rawDocument;\n this.fakeWindow.rawWindow = rawWindow;\n this.fakeWindow.rawDocument = rawDocument;\n const { resetWindowFunction } = rewriteWindowFunction(this.fakeWindow);\n this.resetWindowFunction = resetWindowFunction;\n this.windowSymbolKey = `__${(app.name || app.appCacheKey).replace(/(-|,|:|~|'|\")/gmi, '_')}_${random(10)}__` as keyof Window;\n this.proxyWindow = new Proxy(this.fakeWindow, {\n get: (target: Window & any, key: PropertyKey): unknown => {\n if (commonRawWindowKeyMap[key] || key === Symbol.unscopables) return rawWindow[key as any];\n if (commonFakeWindowKeyMap[key]) return this.fakeWindow[key as any];\n if (['window', 'self', 'globalThis'].includes(key as string)) return this.proxyWindow;\n if (key === 'document' || key === 'eval') {\n app.registerRunningApp();\n // eslint-disable-next-line no-eval\n return key === 'document' ? rawDocument : eval;\n }\n if (\n scopedLocationKeyList.includes(key)\n && this.app instanceof MicroAppModel\n && this.app.iframe\n && this.app.scopeLocation\n ) {\n return this.app.iframe.contentWindow?.[key as any];\n }\n // if (key === Symbol.unscopables) return com;\n if (key === 'hasOwnProperty') return (key: PropertyKey) => this.fakeWindow.hasOwnProperty(key) || rawWindow.hasOwnProperty(key);\n if (key === 'top' || key === 'parent') {\n if (rawWindow === rawWindow.parent) {\n return this.proxyWindow;\n }\n return Reflect.get(rawWindow, key); // iframe\n }\n if (\n Reflect.has(target, key)\n || scopeWindowKeyList.includes(key)\n ) return Reflect.get(target, key);\n const rawValue = Reflect.get(rawWindow, key);\n return bindFunctionToRawWindow(rawWindow, rawValue);\n },\n set: (target: any, key: PropertyKey, value: unknown): boolean => {\n if (this.active) {\n if (\n scopedLocationKeyList.includes(key)\n && this.app instanceof MicroAppModel\n && this.app.iframe\n && this.app.scopeLocation\n ) {\n return Reflect.set(this.app.iframe.contentWindow!, key, value);\n }\n if (escapeSetterKeyList.includes(key)) {\n Reflect.set(rawWindow, key, value);\n } else if (\n !target.hasOwnProperty(key)\n && rawWindow.hasOwnProperty(key)\n && !scopeWindowKeyList.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.injectedKeySet.add(key);\n }\n } else {\n Reflect.set(target, key, value);\n this.injectedKeySet.add(key);\n }\n if ((commonEScapeKeyList.includes(key) && !Reflect.has(rawWindow, key))\n && !scopeWindowKeyList.includes(key)) {\n Reflect.set(rawWindow, key, value);\n this.escapedKeySet.add(key);\n }\n }\n return true;\n },\n has: (target: Window & any, key: PropertyKey): boolean => (commonRawWindowKeyMap as any)[key]\n || key in target\n || key in rawWindow,\n getOwnPropertyDescriptor: (target: any, key: PropertyKey): PropertyDescriptor | undefined => {\n if (target.hasOwnProperty(key)) {\n return Object.getOwnPropertyDescriptor(target, key);\n }\n if (rawWindow.hasOwnProperty(key)) {\n descriptorMap.set(key, DescriptorMapValue.WINDOW);\n const descriptor = Object.getOwnPropertyDescriptor(rawWindow, key);\n if (descriptor && !descriptor.configurable) {\n descriptor.configurable = true;\n }\n return descriptor;\n }\n return undefined;\n },\n // Object.defineProperty(window, key, Descriptor)\n defineProperty: (target: Window & any, key: PropertyKey, value: PropertyDescriptor): boolean => {\n const from = descriptorMap.get(key);\n if (from === DescriptorMapValue.WINDOW) {\n return Reflect.defineProperty(rawWindow, key, value);\n }\n return Reflect.defineProperty(target, key, value);\n },\n // Object.getOwnPropertyNames(window)\n ownKeys: (target: Window & any): Array<string | symbol> => arrayUnique(Reflect.ownKeys(rawWindow)\n .concat(Reflect.ownKeys(target))),\n deleteProperty: (target: Window & any, key: PropertyKey): boolean => {\n if (target.hasOwnProperty(key)) {\n this.injectedKeySet.has(key) && this.injectedKeySet.delete(key);\n this.escapedKeySet.has(key) && Reflect.deleteProperty(rawWindow, key);\n return Reflect.deleteProperty(target, key);\n }\n return true;\n },\n });\n if (app.showSourceCode) {\n rawWindow[this.windowSymbolKey as any] = this.proxyWindow;\n }\n }\n activeated(data?: Record<string, unknown>): void {\n if (!this.active) {\n this.active = true;\n this.fakeWindow.__BK_WEWEB_DATA__ = data ?? {};\n const { resetDocumentAndBodyEvent } = rewriteDocumentAndBodyEvent();\n this.resetDocumentAndBodyEvent = resetDocumentAndBodyEvent;\n }\n }\n deactivated(): void {\n if (this.active) {\n this.active = false;\n this.resetWindowFunction();\n // this.injectedKeySet.forEach((key: PropertyKey) => Reflect.deleteProperty(this.fakeWindow, key));\n this.injectedKeySet.clear();\n this.escapedKeySet.forEach((key: PropertyKey) => Reflect.deleteProperty(window, key));\n this.escapedKeySet.clear();\n this.resetDocumentAndBodyEvent?.();\n }\n }\n}\n","/* eslint-disable no-param-reassign */\nimport { documentClickListMap, documentEventListenerMap, DocumentEventListener, getCurrentRunningApp } from './memory';\n\nexport type IntervalOrTimeout = {\n handler: TimerHandler;\n timeout?: number;\n args: unknown[];\n};\n// rewrite document and body event listener\nexport function rewriteDocumentAndBodyEvent(): {resetDocumentAndBodyEvent: () => void} {\n const { addEventListener, removeEventListener } = window.document;\n const { addEventListener: bodyAddEventListener, removeEventListener: bodyRemoveEventListener } = window.document.body;\n document.addEventListener = function<K extends keyof DocumentEventMap>(\n type: K,\n listener: DocumentEventListener,\n options?: boolean | AddEventListenerOptions | undefined,\n ): void {\n const app = getCurrentRunningApp();\n if (app) {\n const appListenersMap = documentEventListenerMap.get(app.appCacheKey);\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(app.appCacheKey, new Map([[type, new Set([listener])]]));\n }\n }\n addEventListener.call(app?.container instanceof ShadowRoot ? app.container : this, type, listener, options);\n };\n document.body.addEventListener = document.addEventListener;\n\n document.removeEventListener = function<K extends keyof DocumentEventMap>(\n type: K,\n listener: DocumentEventListener,\n options?: boolean | AddEventListenerOptions,\n ): void {\n const app = getCurrentRunningApp();\n if (app) {\n const appListenersMap = documentEventListenerMap.get(app.appCacheKey);\n if (appListenersMap) {\n const appListenerList = appListenersMap.get(type);\n if (appListenerList?.size && appListenerList.has(listener)) {\n appListenerList.delete(listener);\n }\n }\n }\n removeEventListener.call(app?.container instanceof ShadowRoot ? app.container : this, type, listener, options);\n };\n document.body.removeEventListener = document.removeEventListener;\n\n function resetDocumentAndBodyEvent(): void {\n document.addEventListener = addEventListener;\n document.body.addEventListener = bodyAddEventListener;\n document.removeEventListener = removeEventListener;\n document.body.removeEventListener = bodyRemoveEventListener;\n }\n return {\n resetDocumentAndBodyEvent,\n };\n}\n\n// rewrite window funtion like settimeout setinterval ...\nexport function rewriteWindowFunction(fakeWindow: Window & any): Record<string, CallableFunction> {\n const app = getCurrentRunningApp();\n const eventListenerMap = new Map<string, Set<DocumentEventListener>>();\n const intervalIdMap = new Map<number, IntervalOrTimeout>();\n const timeoutIdMap = new Map<number, IntervalOrTimeout>();\n const rawWindow = window;\n const rawDocument = window.document;\n const { addEventListener, removeEventListener, setInterval, setTimeout, clearInterval, clearTimeout } = window;\n const { removeEventListener: documentRemoveEventListener } = window.document;\n\n // listener may be null, e.g test-passive\n fakeWindow.addEventListener = function (\n type: string,\n listener: DocumentEventListener,\n options?: boolean | AddEventListenerOptions,\n ): void {\n const listenerList = eventListenerMap.get(type);\n if (listenerList) {\n listenerList.add(listener);\n } else {\n eventListenerMap.set(type, new Set([listener]));\n }\n addEventListener.call(rawWindow, type, listener, options);\n };\n\n fakeWindow.removeEventListener = function (\n type: string,\n listener: DocumentEventListener,\n options?: boolean | AddEventListenerOptions,\n ): void {\n const listenerList = eventListenerMap.get(type);\n if (listenerList?.size && listenerList.has(listener)) {\n listenerList.delete(listener);\n }\n removeEventListener.call(rawWindow, type, listener, options);\n };\n\n fakeWindow.setInterval = function (\n handler: TimerHandler | string,\n timeout?: number | undefined, ...args: any[]\n ): number {\n const intervalId: any = setInterval.call(rawWindow, handler as any, timeout, ...(args as []));\n intervalIdMap.set(intervalId, { handler, timeout, args });\n return intervalId;\n };\n\n fakeWindow.setTimeout = function (\n handler: TimerHandler,\n timeout?: number,\n ...args: any[]\n ): number {\n const timeoutId: any = setTimeout.call(rawWindow, handler as any, timeout, ...(args as []));\n timeoutIdMap.set(timeoutId, { handler, timeout, args });\n return timeoutId;\n };\n\n fakeWindow.clearInterval = function (intervalId: number) {\n intervalIdMap.delete(intervalId);\n clearInterval.call(rawWindow, intervalId as any);\n };\n\n fakeWindow.clearTimeout = function (timeoutId: number) {\n timeoutIdMap.delete(timeoutId);\n clearTimeout.call(rawWindow, timeoutId as any);\n };\n // reset all event listener & interval & timeout when unmount app\n const resetWindowFunction = () => {\n // clear window events listener\n if (eventListenerMap.size) {\n eventListenerMap.forEach((listenerList, type) => {\n for (const listener of listenerList) {\n removeEventListener.call(rawWindow, type, listener);\n }\n });\n eventListenerMap.clear();\n }\n\n // clear settimeout timers\n if (intervalIdMap.size) {\n intervalIdMap.forEach((_, intervalId: number) => {\n clearInterval.call(rawWindow, intervalId as any);\n });\n intervalIdMap.clear();\n }\n\n if (timeoutIdMap.size) {\n timeoutIdMap.forEach((_, timeoutId: number) => {\n clearTimeout.call(rawWindow, timeoutId as any);\n });\n timeoutIdMap.clear();\n }\n\n if (app) {\n documentClickListMap.delete(app.appCacheKey);\n const documentAppListenersMap = documentEventListenerMap.get(app.appCacheKey);\n if (documentAppListenersMap) {\n documentAppListenersMap.forEach((listenerList, type) => {\n for (const listener of listenerList) {\n documentRemoveEventListener.call(rawDocument, type, listener);\n }\n });\n documentAppListenersMap.clear();\n }\n }\n };\n\n return {\n resetWindowFunction,\n };\n}\n","import { isFunction } from './common';\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}\nexport function dispatchLinkOrScriptLoad(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 dispatchLinkOrScriptError(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 { appCache } from '../cache/app-cache';\nimport { Script } from '../entry/script';\nimport { Style } from '../entry/style';\nimport { randomUrl } from './common';\nimport { dispatchLinkOrScriptLoad } from './element-event';\nimport { BaseModel } from '../typings';\nconst { appendChild: bodyAppendChild } = HTMLBodyElement.prototype;\nexport function resetNewElement(\n parent: Node,\n child: Node,\n app: BaseModel,\n): Node {\n if (child instanceof HTMLStyleElement) {\n if (child.hasAttribute('exclude')) {\n return document.createComment('【bk-weweb】style with exclude attribute is ignored');\n }\n if (!child.hasAttribute('ignore')) {\n const styleInstance = new Style({\n code: child.textContent || '',\n url: '',\n fromHtml: false,\n });\n app.source?.setStyle(randomUrl(), styleInstance);\n styleInstance.scopedStyleCSS(app, child);\n }\n return child;\n }\n if (child instanceof HTMLLinkElement) {\n const result = app.source?.collectLink(child, parent, true);\n if (!result) return child;\n if (result.style) {\n result.style.scopedLinkCSS(app, child);\n }\n if (result.replace !== child) {\n return result.replace;\n }\n return child;\n }\n if (child instanceof HTMLScriptElement) {\n const replaceInfo = app.source!.collectScript(child, parent, true);\n if (!replaceInfo) {\n return child;\n }\n if (replaceInfo.script) {\n replaceInfo.script.excuteCode(app);\n }\n if (replaceInfo.replace !== child) {\n return replaceInfo.replace;\n }\n if (app.scopeJs && !child.getAttribute('src') && !child.textContent) {\n const observer = new MutationObserver(() => {\n if (child.getAttribute('src')) {\n observer.disconnect();\n const scriptInfo = app.source!.collectScript(child, parent, true);\n if (scriptInfo?.replace) {\n bodyAppendChild.call(app.container, scriptInfo.replace);\n }\n if (scriptInfo?.script) {\n scriptInfo.script.excuteCode(app);\n }\n child.remove();\n } else if (child.textContent) {\n observer.disconnect();\n const scriptInstance = new Script({\n code: child.textContent,\n async: false,\n defer: child.type === 'module',\n isModule: child.type === 'module',\n fromHtml: false,\n });\n app.source!.scripts.set(randomUrl(), scriptInstance);\n try {\n scriptInstance.excuteCode(app);\n } catch (e) {\n console.error(e);\n } finally {\n !scriptInstance.isModule && dispatchLinkOrScriptLoad(child);\n child.remove();\n }\n }\n });\n observer.observe(child, { attributeFilter: ['src'], childList: true, subtree: false });\n return document.createComment('【bk-weweb】dynamic script or module');\n }\n return child;\n }\n return child;\n}\nexport function isSepcailElement(node: Node) {\n return node instanceof HTMLScriptElement\n|| node instanceof HTMLStyleElement\n|| node instanceof HTMLLinkElement;\n}\nexport function elmentAppendHandler(\n parent: Node,\n newChild: Node,\n rawMethod: Function,\n) {\n if (newChild.__BK_WEWEB_APP_KEY__) {\n const app = appCache.getApp(newChild.__BK_WEWEB_APP_KEY__!);\n if (app?.container) {\n const targetChild = resetNewElement(parent, newChild, app);\n const needKeepAlive = isSepcailElement(newChild) && !!app.keepAlive && !(app.container instanceof ShadowRoot);\n const container = needKeepAlive ? document.head : app?.container;\n setMarkElement(targetChild as Element, app, needKeepAlive);\n return rawMethod.call(container, targetChild);\n }\n }\n return rawMethod.call(parent, newChild);\n}\nexport function elementInsertHandler(\n parent: Node,\n newChild: Node,\n passiveChild: Node | null,\n rawMethod: Function,\n) {\n if (newChild.__BK_WEWEB_APP_KEY__) {\n const app = appCache.getApp(newChild.__BK_WEWEB_APP_KEY__!);\n if (app?.container) {\n const needKeepAlive = isSepcailElement(newChild) && app.keepAlive && !(app.container instanceof ShadowRoot) ;\n const container = needKeepAlive ? document.head : app?.container;\n const targetChild = resetNewElement(parent, newChild, app);\n if (needKeepAlive) {\n targetChild.__KEEP_ALIVE__ = app.appCacheKey;\n (targetChild as Element).setAttribute('data-from', app.name);\n (targetChild as Element).setAttribute('data-keep-alive', 'true');\n }\n if (passiveChild && !container.contains(passiveChild)) {\n return bodyAppendChild.call(container, targetChild);\n }\n return rawMethod.call(container, targetChild, passiveChild);\n }\n }\n return rawMethod.call(parent, newChild, passiveChild);\n}\n\nexport function setMarkElement<T extends Element>(element: T, app: BaseModel, keepAlive: boolean): T {\n if (keepAlive) {\n element.__KEEP_ALIVE__ = app.appCacheKey;\n element.setAttribute('data-from', app.name);\n element.setAttribute('data-keep-alive', 'true');\n }\n element.setAttribute?.('powered-by', 'bk-weweb');\n return element;\n}\n","/* eslint-disable no-param-reassign */\nimport { appCache } from '../cache/app-cache';\nimport { disabledStyleDom } from '../context/memory';\nimport { BaseModel, CSS_RULE_TYPE, IStyleOption } from '../typings';\nimport { setMarkElement } from '../utils';\nimport { fillUpPath, getFileDir, isSafari, createElement } from '../utils/common';\nimport { dispatchLinkOrScriptError, dispatchLinkOrScriptLoad } from '../utils/element-event';\nimport { fetchSource } from '../utils/fetch';\n\nexport class Style {\n scopedCode = '';\n code ='';\n prefetch = false;\n preload = false;\n url: string | undefined;\n scoped: boolean;\n fromHtml: boolean;\n initial: boolean;\n constructor({ code, prefetch, preload, url, fromHtml, initial }: IStyleOption) {\n this.scoped = false;\n this.code = code;\n this.prefetch = prefetch ?? false;\n this.preload = preload ?? false;\n this.url = url;\n this.fromHtml = fromHtml;\n this.initial = initial ?? false;\n }\n async getCode(app?: BaseModel): Promise<string> {\n if (this.code.length || !this.url) {\n return this.code;\n }\n let code = '';\n if (app?.source?.styles?.has(this.url)) {\n code = app.source.styles.get(this.url)?.code || '';\n }\n if (!code && appCache.getCacheStyle(this.url)) {\n const style = appCache.getCacheStyle(this.url);\n code = style?.code || '';\n }\n if (!code) {\n code = await fetchSource(this.url).catch(() => '');\n }\n this.code = code;\n return code;\n }\n async excuteCode(app: BaseModel): Promise<HTMLStyleElement> {\n app.registerRunningApp();\n let styleElement = createElement('style');\n styleElement.setAttribute('type', 'text/css');\n styleElement.textContent = this.code!;\n try {\n if (!this.code) await this.getCode(app);\n styleElement = this.scopedStyleCSS(app, styleElement);\n this.scoped = true;\n } catch (e) {\n console.error('scoped style error', e);\n }\n return styleElement;\n }\n scopedStyleCSS(app: BaseModel, styleElement: HTMLStyleElement): HTMLStyleElement {\n const needKeepAlive = !!app.keepAlive && !(app.container instanceof ShadowRoot);\n setMarkElement(styleElement, app, needKeepAlive);\n if (this.code || styleElement.textContent) {\n if (styleElement.textContent) {\n styleElement.textContent = '';\n styleElement.innerHTML = '';\n }\n disabledStyleDom.textContent = this.code;\n this.commonScoped(\n disabledStyleDom,\n styleElement,\n app,\n );\n disabledStyleDom.textContent = '';\n } else {\n const observer = new MutationObserver(() => {\n if (!(styleElement.textContent || styleElement.sheet?.cssRules?.length)) return;\n observer.disconnect();\n this.commonScoped(\n styleElement,\n styleElement,\n app,\n );\n });\n observer.observe(styleElement, { attributes: false, childList: true, subtree: true, characterData: true });\n }\n this.url && styleElement.setAttribute('origin-src', this.url);\n return styleElement;\n }\n scopedLinkCSS(app: BaseModel, linkElement: HTMLLinkElement): HTMLStyleElement {\n const styleElement = createElement('style');\n styleElement.setAttribute('type', 'text/css');\n const needKeepAlive = !!app.keepAlive && !(app.container instanceof ShadowRoot);\n setMarkElement(styleElement, app, needKeepAlive);\n const container = needKeepAlive ? document.head : app.container;\n try {\n if (this.code) {\n disabledStyleDom.textContent = styleElement.textContent || this.code;\n this.commonScoped(\n disabledStyleDom,\n styleElement,\n app,\n );\n container?.prepend(styleElement);\n linkElement && dispatchLinkOrScriptLoad(linkElement);\n disabledStyleDom.textContent = '';\n } else if (linkElement.getAttribute('href')) {\n this.url = fillUpPath(linkElement.getAttribute('href')!, app.url);\n this.getCode(app).then(() => {\n this.scopedStyleCSS(app, styleElement);\n linkElement.remove();\n container?.prepend(styleElement);\n linkElement && dispatchLinkOrScriptLoad(linkElement);\n this.scoped = true;\n });\n } else {\n const observer = new MutationObserver(() => {\n if (!linkElement.href) return;\n observer.disconnect();\n this.url = fillUpPath(linkElement.getAttribute('href')!, app.url);\n this.getCode(app).then(() => {\n this.scopedStyleCSS(app, styleElement);\n linkElement.remove();\n container?.prepend(styleElement);\n linkElement && dispatchLinkOrScriptLoad(linkElement);\n this.scoped = true;\n });\n });\n observer.observe(linkElement, { attributeFilter: ['href'], subtree: false, childList: false });\n }\n } catch {\n linkElement && dispatchLinkOrScriptError(linkElement);\n }\n return styleElement;\n }\n commonScoped(\n templateStyle: HTMLStyleElement,\n styleElement: HTMLStyleElement,\n app: BaseModel,\n ) {\n if (app.scopeCss && !(app.container instanceof ShadowRoot)) {\n const rules: CSSRule[] = Array.from(templateStyle.sheet?.cssRules ?? []);\n const cssPrefix = `#${app.name}`;\n const scopedCss = this.scopeRule(rules, cssPrefix);\n let cssText = this.resetUrlHost(\n scopedCss,\n app.url,\n this.url,\n );\n if (isSafari()) {\n cssText = cssText.replace(/([;{]\\s*content:\\s*)([^\\s\"][^\";}]*)/gm, (all, $1, $2) => {\n if ($2 === 'none' || /^(url\\()|(counter\\()|(attr\\()|(open-quote)|(close-quote)/.test($2)) {\n return all;\n }\n return `${$1}\"${$2}\"`;\n });\n }\n styleElement.textContent = cssText;\n this.scopedCode = cssText;\n } else {\n const cssText = this.resetUrlHost(\n styleElement.textContent || templateStyle.textContent || '',\n app.url,\n this.url,\n );\n styleElement.textContent = cssText;\n }\n this.scoped = true;\n }\n scopeRule(rules: CSSRule[], cssPrefix: string): string {\n let result = '';\n for (const rule of rules) {\n switch (rule.type) {\n case CSS_RULE_TYPE.STYLE_RULE:\n result += this.scopeStyleRule(rule as CSSStyleRule, cssPrefix);\n break;\n case CSS_RULE_TYPE.MEDIA_RULE:\n result += this.resetPackRule(rule as CSSMediaRule, cssPrefix, 'media');\n break;\n case CSS_RULE_TYPE.SUPPORTS_RULE:\n result += this.resetPackRule(rule as CSSSupportsRule, cssPrefix, 'supports');\n break;\n default:\n result += rule.cssText;\n break;\n }\n }\n return result.replace(/^\\s+/, '');\n }\n resetPackRule(rule: CSSMediaRule | CSSSupportsRule, prefix: string, packName: string): string {\n const result = this.scopeRule(Array.from(rule.cssRules), prefix);\n return `@${packName} ${rule.conditionText} {${result}}`;\n }\n resetUrlHost(cssText: string, baseURI: string, linkpath?: string) {\n return cssText.replace(/url\\([\"']?([^)\"']+)[\"']?\\)/gm, (text, $1) => {\n if (/^(data|blob):/.test($1) || /^(https?:)?\\/\\//.test($1)) {\n return text;\n }\n if (/^((\\.\\.?\\/)|[^/])/.test($1) && linkpath) {\n baseURI = getFileDir(linkpath);\n }\n return `url(\"${fillUpPath($1, baseURI)}\")`;\n });\n }\n scopeStyleRule(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 }\n 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 => selectors.replace(/(^|,)([^,]+)/g, (all, $1, $2) => {\n if (builtInRootSelectorRE.test($2)) {\n return all.replace(builtInRootSelectorRE, prefix);\n }\n return `${$1} ${prefix} ${$2.replace(/^\\s*/, '')}`;\n }));\n }\n}\n\nexport async function excuteAppStyles(app: BaseModel, container?: Element | ShadowRoot) {\n const styleList: Style[] = Array.from(app.source!.styles.values());\n const promiseList: Promise<HTMLStyleElement>[] = [];\n styleList.forEach((style) => {\n promiseList.push(style.excuteCode(app));\n });\n await Promise.all(promiseList).then((styleElementList: HTMLStyleElement[]) => {\n const parentElemnt = container || app.container;\n if (app.keepAlive && !(parentElemnt instanceof ShadowRoot)) {\n document.head.append(...styleElementList);\n } else {\n parentElemnt?.prepend(...styleElementList);\n }\n });\n}\n","import { appCache } from '../cache/app-cache';\nimport { AppState } from '../common';\nimport { setCurrentRunningApp } from '../context/memory';\nimport SandBox from '../context/sandbox';\nimport { EntrySource } from '../entry/entry';\nimport { execAppScripts } from '../entry/script';\nimport { excuteAppStyles } from '../entry/style';\nimport { BaseModel, CSS_ATTRIBUTE_KEY, IJsModelProps } from '../typings';\nimport { random } from '../utils/common';\nimport { SourceType } from '../utils/load-source';\nexport class MicroInstanceModel implements BaseModel {\n private state: AppState = AppState.UNSET;\n isPreLoad = false;\n appCacheKey: string;\n url: string;\n container?: HTMLElement | ShadowRoot;\n scopeJs = false;\n source?: EntrySource;\n sandBox?: SandBox;\n name: string;\n showSourceCode = true;\n scopeCss = true;\n keepAlive: boolean;\n initSource: SourceType;\n public data: Record<string, unknown>;\n constructor(props: IJsModelProps) {\n this.name = props.id !== props.url ? props.id! : random(5);\n this.appCacheKey = props.id || this.name;\n this.url = props.url;\n this.container = props.container ?? undefined;\n this.scopeJs = props.scopeJs ?? true;\n this.showSourceCode = props.showSourceCode ?? true;\n this.scopeCss = props.scopeCss ?? true;\n this.keepAlive = props.keepAlive ?? false;\n this.data = props.data ?? {};\n this.initSource = props.initSource ?? [];\n // 是否启用沙盒\n if (this.scopeJs) {\n this.sandBox = new SandBox(this);\n }\n }\n get status(): AppState {\n return this.state;\n }\n set status(v: AppState) {\n this.state = v;\n }\n async start(): Promise<void> {\n if (!this.source || [AppState.UNSET, AppState.ERROR].includes(this.status)) {\n this.source = new EntrySource(this.url);\n await this.source.importEntery(this);\n }\n }\n onMount(): void {\n if (this.isPreLoad) return;\n this.state = AppState.LOADED;\n this.mount();\n }\n onError(): void {\n this.state = AppState.ERROR;\n }\n mount<T>(\n container?: HTMLElement | ShadowRoot,\n callback?: (instance: MicroInstanceModel, exportInstance: T) => void,\n ): void {\n this.isPreLoad = false;\n this.container = container ?? this.container!;\n this.state = AppState.MOUNTING;\n if (this.container instanceof HTMLElement) {\n this.container!.setAttribute(CSS_ATTRIBUTE_KEY, this.name);\n }\n this.container.innerHTML = '';\n const instanceWrap = document.createElement('div');\n const wrapId = `${this.name}-wrapper`;\n instanceWrap.setAttribute('id', wrapId);\n if (this.source?.styles.size) {\n excuteAppStyles(this, this.container);\n }\n this.container.appendChild(instanceWrap);\n this.sandBox?.activeated();\n execAppScripts(this).finally(() => {\n this.state = AppState.MOUNTED;\n const scriptInfo = this.source?.getScript(this.url);\n if (typeof scriptInfo?.exportInstance?.render === 'function') {\n scriptInfo.exportInstance.render(instanceWrap, this.data);\n }\n callback?.(this, scriptInfo?.exportInstance);\n });\n }\n activated<T>(\n container: HTMLElement | ShadowRoot,\n callback?: (instance: BaseModel, exportInstance?: T) => void,\n ): void {\n this.isPreLoad = false;\n this.state = AppState.ACTIVATED;\n if (this.container && container) {\n if (container instanceof Element) container!.setAttribute(CSS_ATTRIBUTE_KEY, this.name);\n const fragment = document.createDocumentFragment();\n Array.from(this.container.childNodes).forEach((node: Node | Element) => {\n fragment.appendChild(node);\n });\n container.appendChild(fragment);\n this.container = container;\n this.sandBox?.activeated();\n const scriptInfo = this.source?.getScript(this.url);\n callback?.(this, scriptInfo?.exportInstance);\n }\n }\n deactivated(): void {\n this.state = AppState.DEACTIVATED;\n this.sandBox?.deactivated();\n }\n unmount(needDestroy?: boolean): void {\n this.state = AppState.UNMOUNT;\n this.sandBox?.deactivated();\n needDestroy && appCache.deleteApp(this.url);\n this.container!.innerHTML = '';\n this.container = undefined;\n }\n registerRunningApp() {\n setCurrentRunningApp(this);\n Promise.resolve().then(() => setCurrentRunningApp(null));\n }\n}\n","/* eslint-disable no-restricted-syntax */\n/* eslint-disable no-prototype-builtins */\n/* eslint-disable no-param-reassign */\n/* eslint-disable max-len */\nimport { MicroAppModel } from '../mode/app';\nimport { BaseModel, IScriptOption } from '../typings';\nimport { isIE11, createElement } from '../utils/common';\nimport { fetchSource } from '../utils/fetch';\nimport { MicroInstanceModel } from '../mode/instance';\nimport { appCache } from '../cache/app-cache';\nimport { setMarkElement } from '../utils';\n\nlet firstGlobalProp: string | undefined;\nlet secondGlobalProp: string | undefined;\nlet lastGlobalProp: string | undefined;\n\n// Script脚本实例\nexport class Script {\n code = '';\n async = false;\n defer = false;\n isModule = false;\n url: string | undefined;\n exportInstance?: any;\n scoped: boolean;\n fromHtml: boolean;\n initial: boolean;\n\n constructor({ code, async, defer, isModule, url, fromHtml, initial }: IScriptOption) {\n this.code = code;\n this.async = async;\n this.defer = defer;\n this.isModule = isModule;\n this.url = url;\n this.scoped = false;\n this.fromHtml = fromHtml ?? false;\n this.initial = initial ?? false;\n }\n async getCode(app?: BaseModel): Promise<string> {\n if (this.code.length || !this.url) {\n return this.code;\n }\n let code = '';\n if (app?.source?.getScript(this.url)) {\n code = app.source.getScript(this.url)?.code || '';\n }\n if (!code && appCache.getCacheScript(this.url)) {\n code = appCache.getCacheScript(this.url)?.code || '';\n }\n if (!code) {\n code = await fetchSource(this.url).catch((e) => {\n console.error(`fetch script ${this.url} error`, e);\n return '';\n });\n }\n this.code = code;\n return code;\n }\n async excuteCode(app: BaseModel, needRelaceScriptElement = false): Promise<HTMLScriptElement | Comment | undefined> {\n try {\n if (!this.code) await this.getCode(app);\n if (app instanceof MicroInstanceModel) {\n noteGlobalProps(app.sandBox?.proxyWindow || window);\n }\n let scopedCode = this.code;\n scopedCode = this.transformCode(app);\n if (app.showSourceCode || this.isModule) {\n const scriptElement = createElement('script');\n app.registerRunningApp();\n this.executeSourceScript(scriptElement, scopedCode);\n if (needRelaceScriptElement) return scriptElement;\n const needKeepAlive = !!app.keepAlive && !(app.container instanceof ShadowRoot);\n const container = needKeepAlive ? document.head : app.container;\n setMarkElement(scriptElement, app, needKeepAlive);\n container!.appendChild(scriptElement);\n } else {\n this.executeMemoryScript(app, scopedCode);\n if (needRelaceScriptElement) return document.createComment('【bk-weweb】dynamic script');\n }\n if (app instanceof MicroInstanceModel) {\n const exportProp: any = getGlobalProp(app.sandBox?.proxyWindow || window);\n exportProp && (this.exportInstance = (app.sandBox?.proxyWindow || window)[exportProp]);\n }\n } catch (e) {\n console.error('execute script code error', e);\n }\n return;\n }\n transformCode(app: BaseModel): string {\n if (app.sandBox) {\n if (app.showSourceCode || this.isModule) {\n return `;(function(window, self){\n with(window){\n ;${this.code}\\n\n }\n }).call(window.${app.sandBox.windowSymbolKey},\n window.${app.sandBox.windowSymbolKey});`;\n }\n return `\n with(window) {\n try {\n ${this.code}\n }\n catch(e) {\n console.error(e)\n }\n }\n `;\n }\n return this.code;\n }\n executeSourceScript(\n scriptElement: HTMLScriptElement,\n scopedCode: string,\n ): void {\n if (this.isModule) {\n const blob = new Blob([scopedCode], { type: 'text/javascript' });\n scriptElement.src = URL.createObjectURL(blob);\n scriptElement.setAttribute('type', 'module');\n } else {\n scriptElement.textContent = scopedCode;\n }\n this.url && scriptElement.setAttribute('origin-src', this.url);\n }\n executeMemoryScript(app: BaseModel, scopedCode: string) {\n try {\n const isScopedLocation = app instanceof MicroAppModel && app.scopeLocation;\n app.registerRunningApp();\n // eslint-disable-next-line no-new-func\n new Function('window', 'location', 'history', scopedCode)(\n app.sandBox!.proxyWindow,\n isScopedLocation ? app.iframe?.contentWindow?.location : window.location,\n isScopedLocation ? app.iframe?.contentWindow?.history : window.history,\n );\n } catch (e) {\n console.error(e);\n }\n }\n}\n// 全局属性是否跳过标记\nexport function shouldSkipProperty(global: Window, p: any) {\n return (\n !global.hasOwnProperty(p)\n || (!isNaN(p) && p < global.length)\n || (isIE11 && global[p] && typeof window !== 'undefined' && global[p].parent === window)\n );\n}\n// 获取instance js source code 执行后 绑定的export 实例\nexport function getGlobalProp(global: Window, useFirstGlobalProp?: boolean) {\n let cnt = 0;\n let foundLastProp;\n let result;\n for (const p in global) {\n // do not check frames cause it could be removed during import\n if (shouldSkipProperty(global, p)) continue;\n if ((cnt === 0 && p !== firstGlobalProp) || (cnt === 1 && p !== secondGlobalProp)) return p;\n if (foundLastProp) {\n lastGlobalProp = p;\n result = (useFirstGlobalProp && result) || p;\n } else {\n foundLastProp = p === lastGlobalProp;\n }\n cnt += 1;\n }\n return result;\n}\n// 标记全局属性\nexport function noteGlobalProps(global: Window) {\n secondGlobalProp = undefined;\n firstGlobalProp = secondGlobalProp;\n for (const p in global) {\n if (shouldSkipProperty(global, p)) continue;\n if (!firstGlobalProp) firstGlobalProp = p;\n else if (!secondGlobalProp) secondGlobalProp = p;\n lastGlobalProp = p;\n }\n return lastGlobalProp;\n}\n// app初始化dom 脚本执行\nexport async function execAppScripts(app: BaseModel) {\n const appInitialScriptList = Array.from(app.source!.scripts.values()).filter(script => script.initial);\n // 初始化脚本最先执行\n if (appInitialScriptList.length) {\n await Promise.all(appInitialScriptList.map(script => script.excuteCode(app)));\n }\n const appScriptList = Array.from(app.source!.scripts.values()).filter(script => script.fromHtml && !script.initial);\n const commomList = appScriptList.filter(script => ((!script.async && !script.defer) || script.isModule));\n // 保证同步脚本 和 module类型 最先执行\n await Promise.all(commomList.map(script => script.excuteCode(app)));\n // 最后执行 defer 和 async 脚本\n const deferScriptList: Promise<HTMLScriptElement | Comment | undefined>[] = [];\n const asyncScriptList: Promise<HTMLScriptElement | Comment | undefined>[] = [];\n // async defer 脚本执行\n appScriptList.forEach((script) => {\n if ((script.defer || script.async)) {\n if (!script.code && script.defer) {\n deferScriptList.push(script.excuteCode(app));\n } else asyncScriptList.push(script.excuteCode(app));\n }\n });\n await Promise.all([...asyncScriptList, ...deferScriptList])\n .catch((e) => {\n console.error(e);\n });\n}\n","import { AppState } from '../common';\nimport { execAppScripts } from '../entry/script';\nimport { EntrySource } from '../entry/entry';\nimport { AppMode, BaseModel, CSS_ATTRIBUTE_KEY, IAppModleProps } from '../typings';\nimport { random } from '../utils/common';\nimport SandBox from '../context/sandbox';\nimport { appCache } from '../cache/app-cache';\nimport { setCurrentRunningApp } from '../context/memory';\nimport { SourceType } from '../utils/load-source';\n\nexport class MicroAppModel implements BaseModel {\n private state: AppState = AppState.UNSET;\n public isPreLoad = false;\n mode: AppMode = 'app';\n name: string;\n url: string;\n container?: HTMLElement | ShadowRoot;\n showSourceCode: boolean;\n scopeCss: boolean;\n scopeJs: boolean;\n source?: EntrySource;\n sandBox?: SandBox;\n scopeLocation: boolean;\n keepAlive: boolean;\n initSource: SourceType;\n iframe: HTMLIFrameElement | null = null;\n public data: Record<string, unknown>;\n constructor(props: IAppModleProps) {\n this.name = props.id !== props.url ? props.id! : random(5);\n this.mode = props.mode ?? 'app';\n this.container = props.container ?? undefined;\n this.showSourceCode = props.showSourceCode ?? false;\n this.url = props.url;\n this.data = props.data || {};\n this.scopeJs = props.scopeJs ?? true;\n this.scopeCss = props.scopeCss ?? true;\n this.scopeLocation = props.scopeLocation ?? false;\n this.isPreLoad = props.isPreLoad ?? false;\n this.keepAlive = props.keepAlive ?? false;\n this.initSource = props.initSource ?? [];\n if (this.scopeJs) {\n this.sandBox = new SandBox(this);\n }\n if (this.container instanceof HTMLElement) {\n this.container.setAttribute(CSS_ATTRIBUTE_KEY, this.name);\n }\n }\n get appCacheKey(): string {\n return this.url;\n }\n public get status() {\n return this.state;\n }\n public set status(v: AppState) {\n this.state = v;\n }\n async start() {\n if (!this.source || [AppState.UNSET, AppState.ERROR].includes(this.status)) {\n this.state = AppState.LOADING;\n if (this.scopeLocation) {\n const iframe = await this.createIframe();\n this.iframe = iframe;\n }\n this.source = new EntrySource(this.url);\n await this.source.importEntery(this);\n }\n }\n onMount(): void {\n if (this.isPreLoad) return;\n this.state = AppState.LOADED;\n this.mount();\n }\n onError(): void {\n this.state = AppState.ERROR;\n }\n mount(\n container?: HTMLElement | ShadowRoot,\n callback?: (app: BaseModel) => void,\n ): void {\n this.isPreLoad = false;\n this.container = container ?? this.container!;\n this.state = AppState.MOUNTING;\n if (this.container) {\n debugger;\n if (this.container instanceof Element) this.container!.setAttribute(CSS_ATTRIBUTE_KEY, this.name);\n const clonedNode = this.source!.html!.cloneNode(true);\n const fragment = document.createDocumentFragment();\n Array.from(clonedNode.childNodes).forEach((node: Node | Element) => {\n fragment.appendChild(node);\n });\n this.container!.innerHTML = '';\n this.container!.appendChild(fragment);\n this.sandBox?.activeated(this.data);\n execAppScripts(this).finally(() => {\n this.state = AppState.MOUNTED;\n callback?.(this);\n });\n }\n }\n activated(\n container: HTMLElement | ShadowRoot,\n callback?: (app: BaseModel) => void,\n ) {\n this.isPreLoad = false;\n this.state = AppState.ACTIVATED;\n if (container && this.container) {\n if (container instanceof Element) container!.setAttribute(CSS_ATTRIBUTE_KEY, this.name);\n const fragment = document.createDocumentFragment();\n Array.from(this.container.childNodes).forEach((node: Node | Element) => {\n fragment.appendChild(node);\n });\n container!.innerHTML = '';\n container!.appendChild(fragment);\n this.container = container;\n this.sandBox?.activeated(this.data);\n callback?.(this);\n }\n }\n deactivated() {\n this.state = AppState.DEACTIVATED;\n this.sandBox?.deactivated();\n }\n unmount(needDestroy = false): void {\n this.state = AppState.UNMOUNT;\n this.sandBox?.deactivated();\n needDestroy && appCache.deleteApp(this.url);\n this.container!.innerHTML = '';\n this.container = undefined;\n }\n createIframe(): Promise<HTMLIFrameElement> {\n return new Promise((resolve) => {\n const iframe = document.createElement('iframe');\n const url = new URL(this.url);\n iframe.setAttribute('src', `about:blank${url.pathname || '/'}${url.search}${url.hash}`);\n iframe.style.cssText = 'position: fixed; top: -9999px; width: 100%; height: 1px;';\n document.body.appendChild(iframe);\n setTimeout(() => resolve(iframe), 100);\n });\n }\n registerRunningApp() {\n setCurrentRunningApp(this);\n Promise.resolve().then(() => setCurrentRunningApp(null));\n }\n}\nexport const createApp = (props: IAppModleProps) => {\n appCache.deleteApp(props.url);\n const instance = new MicroAppModel(props);\n appCache.setApp(instance);\n};\n","import { appCache } from '../cache/app-cache';\nimport { Script } from '../entry/script';\nimport { Style } from '../entry/style';\n\nexport type SourceFuncType = () => Promise<string[]>;\n\nexport type SourceType = string[] | SourceFuncType;\n\n// 收集和辩证资源\nexport async function collectSource(soruceList: SourceType) {\n let source: string[] = [];\n if (typeof soruceList === 'function') {\n source = await soruceList();\n } else {\n source = soruceList || [];\n }\n if (!source.length) return {};\n const collectScript: Map<string, Script> = new Map();\n const collectStyle: Map<string, Style> = new Map();\n source.forEach((str) => {\n try {\n const url = new URL(str);\n if (url.pathname.match(/\\.js$/)) {\n const script = appCache.getCacheScript(str);\n collectScript.set(str, new Script({\n code: script?.code || '',\n async: false,\n defer: false,\n url: str,\n isModule: false,\n initial: true,\n fromHtml: false,\n }));\n } else if (url.pathname.match(/\\.css$/)) {\n const style = appCache.getCacheStyle(str);\n collectStyle.set(str, new Style({\n code: style?.code || '',\n prefetch: false,\n preload: false,\n url: str,\n fromHtml: true,\n initial: true,\n }));\n }\n } catch {\n console.error(`【bk-weweb】: ${str} is invalid URL`);\n }\n });\n return {\n collectScript,\n collectStyle,\n };\n}\n\n// 加载全局静态资源\nexport async function LoadGlobalSource(soruceList: SourceType) {\n const { collectScript, collectStyle } = await collectSource(soruceList);\n const promiseList: Promise<string>[] = [];\n collectScript && Array.from(collectScript.entries()).forEach((item) => {\n promiseList.push(item[1].getCode());\n appCache.setBaseAppScript(...item);\n });\n collectStyle && Array.from(collectStyle.entries()).forEach((item) => {\n promiseList.push(item[1].getCode());\n appCache.setBaseAppStyle(...item);\n });\n await Promise.all(promiseList).catch((e) => {\n throw e;\n });\n}\n","import { BaseModel, IScriptOption } from '../typings';\nimport { MicroAppModel } from '../mode/app';\nimport { fillUpPath, randomUrl, createElement } from '../utils/common';\nimport { fetchSource } from '../utils/fetch';\nimport { excuteAppStyles, Style } from './style';\nimport { MicroInstanceModel } from '../mode/instance';\nimport { Script } from './script';\nimport { isSupportModuleScript } from '../context/memory';\nimport { appCache } from '../cache/app-cache';\nimport { collectSource } from '../utils/load-source';\n\nexport class EntrySource {\n scripts: Map<string, Script>;\n styles: Map<string, Style>;\n html: HTMLElement | null = null;\n rawHtml?: string;\n constructor(public url: string) {\n this.scripts = new Map();\n this.styles = new Map();\n }\n async importEntery(app: BaseModel): Promise<void> {\n let importEntry: Promise<void> | undefined;\n if (app.initSource?.length) {\n // 初始化配置的公共source资源\n const { collectScript, collectStyle } = await collectSource(app.initSource);\n if (collectScript) {\n this.scripts = collectScript;\n }\n if (collectStyle) {\n this.styles = collectStyle;\n }\n }\n if (app instanceof MicroAppModel) importEntry = this.importHtmlEntry(app);\n else if (app instanceof MicroInstanceModel) importEntry = this.importInstanceEntry();\n importEntry && await importEntry;\n }\n async importHtmlEntry(app: MicroAppModel): Promise<void> {\n let htmlStr = appCache.getCacheHtml(this.url);\n if (!htmlStr) {\n htmlStr = await fetchSource(this.url, { cache: 'no-cache' });\n if (!htmlStr) {\n console.error('load app entry error, pleace check');\n return Promise.reject();\n }\n }\n this.rawHtml = htmlStr;\n const wrapElement = createElement('div');\n wrapElement.innerHTML = htmlStr.replace(/<\\/?head>/gim, '').replace(/<\\/?body>/i, '');\n this.collectScriptAndStyle(wrapElement, app);\n await excuteAppStyles(app, wrapElement);\n this.html = wrapElement;\n }\n async importInstanceEntry(): Promise<void> {\n let jsStr = appCache.getCacheScript(this.url)?.code;\n if (!jsStr) {\n jsStr = await fetchSource(this.url, { cache: 'no-cache' });\n }\n if (!jsStr) {\n console.error('load app entry error, pleace check');\n return Promise.reject();\n }\n this.scripts.set(this.url, new Script({\n code: jsStr,\n async: false,\n defer: false,\n url: this.url,\n isModule: false,\n fromHtml: true,\n }));\n }\n collectScriptAndStyle(parent: HTMLElement, app: MicroAppModel): void {\n const children = Array.from(parent.children);\n children.length\n && children.forEach((child) => {\n this.collectScriptAndStyle(child as HTMLElement, app);\n });\n for (const dom of children) {\n if (dom instanceof HTMLLinkElement) {\n this.collectLink(dom, parent);\n } else if (dom instanceof HTMLStyleElement) {\n if (dom.hasAttribute('exclude')) {\n } else if (!dom.hasAttribute('ignore')) {\n this.styles.set(randomUrl(), new Style({\n code: dom.textContent || '',\n url: '',\n fromHtml: true,\n }));\n dom.remove();\n }\n } else if (dom instanceof HTMLScriptElement) {\n this.collectScript(dom, parent);\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', fillUpPath(dom.getAttribute('src')!, this.url));\n }\n }\n }\n collectLink(\n link: HTMLLinkElement,\n parent: Node,\n needReplaceELement = false,\n ): {replace: Element | Comment, style?: Style} {\n if (link.hasAttribute('exclude')) {\n return { replace: document.createComment('【bk-weweb】style with exclude attribute is ignored') };\n }\n if (link.hasAttribute('ignore')) {\n return { replace: link };\n }\n const rel = link.getAttribute('rel');\n let href = link.getAttribute('href');\n let replaceElement;\n if (rel === 'stylesheet' && href) {\n href = fillUpPath(href, this.url);\n replaceElement = document.createComment(`【bk-weweb】style with href=${href}`);\n let styleInstance = this.getStyle(href);\n if (!styleInstance) {\n styleInstance = new Style({\n code: '',\n url: href,\n prefetch: !!link.getAttribute('prefetch'),\n preload: !!link.getAttribute('preload'),\n fromHtml: !needReplaceELement,\n });\n this.styles.set(href, styleInstance);\n }\n !needReplaceELement && parent.replaceChild(replaceElement, link);\n return { replace: replaceElement, style: styleInstance };\n } if (rel && ['prefetch', 'preload', 'prerender', 'icon', 'apple-touch-icon'].includes(rel)) {\n // preload prefetch icon ....\n replaceElement = document.createComment(`【bk-weweb】style with rel=${rel}${href ? ` & href=${href}` : ''}`);\n !needReplaceELement && parent.removeChild(link);\n return { replace: replaceElement };\n } if (href) {\n // dns-prefetch preconnect modulepreload search ....\n link.setAttribute('href', fillUpPath(href, this.url));\n }\n return { replace: link };\n }\n collectScript(\n script: HTMLScriptElement,\n parent: Node,\n needReplaceELement = false,\n ): {replace: Element | Comment, script?: Script} | undefined {\n if (script.hasAttribute('ignore')\n || (script.hasAttribute('type') && !['text/javascript', 'text/ecmascript', 'application/javascript', 'application/ecmascript', 'module'].includes(script.type))\n || (!isSupportModuleScript && script.type === 'module')) {\n return;\n }\n let replaceElement = null;\n if (script.hasAttribute('exclude')) {\n replaceElement = document.createComment('【bk-weweb】script element with exclude attribute is removed');\n !needReplaceELement && parent.replaceChild(replaceElement, script);\n return { replace: replaceElement };\n }\n let src: string | null = script.getAttribute('src');\n if (src) {\n src = fillUpPath(src, this.url);\n let scriptInstance = this.getScript(src);\n if (!scriptInstance) {\n scriptInstance = new Script({\n code: '',\n async: script.hasAttribute('async'),\n defer: script.defer || script.type === 'module',\n isModule: script.type === 'module',\n url: src,\n fromHtml: !needReplaceELement,\n });\n this.scripts.set(src, scriptInstance);\n }\n replaceElement = document.createComment(`【bk-weweb】script with src='${src}'`);\n !needReplaceELement && parent.replaceChild(replaceElement, script);\n return { replace: replaceElement, script: scriptInstance };\n }\n if (script.textContent) {\n const nonceStr: string = randomUrl();\n const scriptInstance = new Script({\n code: script.textContent,\n async: false,\n defer: script.type === 'module',\n isModule: script.type === 'module',\n url: nonceStr!,\n fromHtml: !needReplaceELement,\n });\n this.scripts.set(nonceStr, scriptInstance);\n replaceElement = document.createComment('【bk-weweb】script with texcontent');\n !needReplaceELement && parent.replaceChild(replaceElement, script);\n return { replace: replaceElement, script: scriptInstance };\n }\n return { replace: script };\n }\n setScript(url: string, script: IScriptOption) {\n this.scripts.set(url, new Script(script));\n }\n getScript(url: string) {\n return this.scripts.get(url);\n }\n setStyle(url: string, style: Style) {\n this.styles.set(url, style);\n }\n getStyle(url: string) {\n return this.styles.get(url);\n }\n}\n","import { BaseModel } from '../typings';\nimport { EntrySource } from '../entry/entry';\nimport { AppState } from '../common';\nimport { Style } from '../entry/style';\nimport { Script } from '../entry/script';\n\n// 所有应用缓存\nexport class AppCache {\n private cache: Map<string, BaseModel>;\n // todo 主应用共享资源包\n private baseSource: EntrySource;\n constructor() {\n this.cache = new Map();\n this.baseSource = new EntrySource(location.href);\n // this.baseApp = new\n }\n get hasActiveApp() {\n return Array.from(this.cache.values()).some((app: BaseModel) => app.status !== AppState.UNMOUNT);\n }\n setApp(app: BaseModel) {\n this.cache.set(app.appCacheKey, app);\n }\n getApp(name?: string | null): BaseModel | undefined {\n if (!name) return undefined;\n const app = this.cache.get(name);\n if (app) return app;\n return Array.from(this.cache.values()).find((item: BaseModel) => item.name === name);\n }\n getCacheHtml(url: string): string {\n const list = Array.from(this.cache.values());\n const app = list.find(item => item.url === url);\n if (app) return app.source?.rawHtml || '';\n return '';\n }\n getCacheStyle(url: string): Style | undefined {\n let style: Style | undefined = this.baseSource.getStyle(url);\n if (style) return;\n const list = Array.from(this.cache.values());\n list.some((app) => {\n style = app.source?.getStyle(url);\n return !!style;\n });\n return style;\n }\n getCacheScript(url: string): Script | undefined {\n let script: Script | undefined = this.baseSource.getScript(url);\n if (script) return;\n const list = Array.from(this.cache.values());\n list.some((app) => {\n script = app.source?.getScript(url);\n return !!script;\n });\n return script;\n }\n deleteApp(url: string) {\n this.cache.delete(url);\n }\n setBaseAppStyle(url: string, style: Style) {\n this.baseSource.setStyle(url, style);\n }\n setBaseAppScript(url: string, script: Script) {\n this.baseSource.setScript(url, script);\n }\n}\nconst appCache = new AppCache();\n// 注册全局获取缓存app 或者 instance\nwindow.__getAppOrInstance__ = function (id?: string) {\n if (!id) return appCache;\n return appCache.getApp(id);\n};\nexport {\n appCache,\n};\n","import { isBodyElement } from '../utils/common';\nimport { getCurrentRunningApp } from './memory';\nconst { document } = window;\nconst {\n createElement,\n querySelector,\n querySelectorAll,\n getElementById,\n getElementsByClassName,\n getElementsByTagName,\n getElementsByName,\n} = Document.prototype;\n\nexport function rewriteDocumentPrototypeMethods() {\n Document.prototype.createElement = function<K extends keyof HTMLElementTagNameMap>(\n tagName: K,\n options?: ElementCreationOptions | undefined,\n ) {\n const element = createElement.call(this, tagName, options);\n const app = getCurrentRunningApp();\n // img.src = '' iframe.src = '' 均不能在setAttributes上监听 但是这里所有的src都是 全地址 无法判断是否需要添加子应用域名\n // if (tagName.toLocaleLowerCase() === 'img') {\n // const observer = new MutationObserver((list, observer) => {\n // observer.disconnect();\n // const url = new URL((element as HTMLImageElement).src)\n // (element as HTMLImageElement).src = `${}`\n // });\n // observer.observe(element, { attributeFilter: ['src'], subtree: false, childList: false });\n // }\n if (app) element.__BK_WEWEB_APP_KEY__ = app.appCacheKey;\n return element;\n };\n function querySelectorNew(this: Document, selectors: string): any {\n const app = getCurrentRunningApp();\n if (!app || !selectors || isBodyElement(selectors) || document !== this) {\n return querySelector.call(this, selectors);\n }\n return app?.container?.querySelector(selectors) ?? null;\n }\n function querySelectorAllNew(this: Document, selectors: string): any {\n const app = getCurrentRunningApp();\n if (!app || !selectors || isBodyElement(selectors) || document !== this) {\n return querySelectorAll.call(this, selectors);\n }\n return app?.container?.querySelectorAll(selectors) ?? [];\n }\n Document.prototype.querySelector = querySelectorNew;\n Document.prototype.querySelectorAll = querySelectorAllNew;\n\n Document.prototype.getElementById = function getElementByIdNew(key: string): HTMLElement | null {\n if (!getCurrentRunningApp()) {\n return getElementById.call(this, key);\n }\n try {\n return querySelectorNew.call(this, `#${key}`);\n } catch {\n return getElementById.call(this, key);\n }\n };\n Document.prototype.getElementsByClassName = function (key: string): HTMLCollectionOf<Element> {\n if (!getCurrentRunningApp()) {\n return getElementsByClassName.call(this, key);\n }\n try {\n return querySelectorAllNew.call(this, `.${key}`);\n } catch {\n return getElementsByClassName.call(this, key);\n }\n };\n // eslint-disable-next-line max-len\n Document.prototype.getElementsByTagName = function<K extends keyof HTMLElementTagNameMap>(key: K): HTMLCollectionOf<Element> {\n const app = getCurrentRunningApp();\n if (\n !app\n || isBodyElement(key)\n || (!app?.showSourceCode && key.toLocaleLowerCase() === 'script')\n ) {\n return getElementsByTagName.call(this, key);\n }\n\n try {\n return querySelectorAllNew.call(this, key);\n } catch {\n return getElementsByTagName.call(this, key);\n }\n };\n Document.prototype.getElementsByName = function (key: string): NodeListOf<HTMLElement> {\n if (!getCurrentRunningApp()) {\n return getElementsByName.call(this, key);\n }\n try {\n return querySelectorAllNew.call(this, `[name=${key}]`);\n } catch {\n return getElementsByName.call(this, key);\n }\n };\n}\n\nexport function resetDocumentPrototypeMethods(): void {\n Document.prototype.createElement = createElement;\n Document.prototype.querySelector = querySelector;\n Document.prototype.querySelectorAll = querySelectorAll;\n Document.prototype.getElementById = getElementById;\n Document.prototype.getElementsByClassName = getElementsByClassName;\n Document.prototype.getElementsByTagName = getElementsByTagName;\n Document.prototype.getElementsByName = getElementsByName;\n}\n","import { appCache } from '../cache/app-cache';\nimport { fillUpPath } from '../utils/common';\nimport { elementInsertHandler, elmentAppendHandler, isSepcailElement } from '../utils/element';\nimport { setCurrentRunningApp } from './memory';\n\nconst { setAttribute } = Element.prototype;\nconst {\n appendChild: bodyAppendChild,\n removeChild: bodyRemoveChild,\n append,\n} = HTMLBodyElement.prototype;\nconst {\n appendChild: headAppendChild,\n removeChild: headRemoveChild,\n insertBefore: headInsertBefore,\n} = HTMLHeadElement.prototype;\nconst rawHead = document.head;\n\nexport function rewriteBodyAndHeaderMethods(): void {\n Element.prototype.setAttribute = function (key: string, value: string): void {\n const tagName = this.tagName.toLocaleUpperCase();\n if (\n ((['src', 'srcset'].includes(key) && ['SCRIPT', 'IMG'].includes(tagName))\n || (key === 'href' && ['LINK'].includes(tagName)))\n && this.__BK_WEWEB_APP_KEY__\n && appCache.getApp(this.__BK_WEWEB_APP_KEY__ || '')\n ) {\n setAttribute.call(this, key, fillUpPath(value, appCache.getApp(this.__BK_WEWEB_APP_KEY__!)!.url));\n } else {\n setAttribute.call(this, key, value);\n }\n };\n\n HTMLBodyElement.prototype.appendChild = function appendChildNew<T extends Node>(newChild: T): T {\n if (newChild.__KEEP_ALIVE__ && isSepcailElement(newChild)) return (headAppendChild as any).call(rawHead, newChild);\n return elmentAppendHandler(this, newChild, bodyAppendChild);\n };\n HTMLBodyElement.prototype.append = function <T extends Node>(...nodes: T[]): void {\n let i = 0;\n const { length } = nodes;\n while (i < length) {\n if (nodes[i].__KEEP_ALIVE__ && isSepcailElement(nodes[i])) {\n return (headAppendChild as any).call(rawHead, nodes[i]);\n };\n elmentAppendHandler(this, nodes[i] as Node, bodyAppendChild);\n i += 1;\n }\n };\n HTMLHeadElement.prototype.appendChild = HTMLBodyElement.prototype.appendChild;\n\n\n HTMLHeadElement.prototype.insertBefore = function <T extends Node>(newChild: T, refChild: Node | null): T {\n return elementInsertHandler(this, newChild, refChild, headInsertBefore);\n };\n HTMLBodyElement.prototype.removeChild = function removeChildNew<T extends Node>(oldChild: T): T {\n const app = appCache.getApp(oldChild.__BK_WEWEB_APP_KEY__!);\n if (app?.container?.contains(oldChild)) {\n const node = bodyRemoveChild.call(app.container, oldChild) as T;\n return node;\n } if (this.contains(oldChild)) {\n return bodyRemoveChild.call(this, oldChild) as T;\n }\n return oldChild;\n };\n HTMLHeadElement.prototype.removeChild = HTMLBodyElement.prototype.removeChild;\n}\n\nexport function resetBodyAndHeaderMethods(): void {\n setCurrentRunningApp(null);\n Element.prototype.setAttribute = setAttribute;\n HTMLBodyElement.prototype.appendChild = bodyAppendChild;\n HTMLBodyElement.prototype.append = append;\n HTMLBodyElement.prototype.removeChild = bodyRemoveChild;\n HTMLHeadElement.prototype.appendChild = headAppendChild;\n HTMLHeadElement.prototype.insertBefore = headInsertBefore;\n HTMLHeadElement.prototype.removeChild = headRemoveChild;\n}\n","import { rewriteDocumentPrototypeMethods } from '../context/document';\nimport { rewriteBodyAndHeaderMethods } from '../context/element';\n\nexport function beforeLoad() {\n rewriteBodyAndHeaderMethods();\n rewriteDocumentPrototypeMethods();\n}\n","import { MicroAppModel } from '../mode/app';\nimport { appCache } from '../cache/app-cache';\nimport { BaseModel, IAppModleProps, IBaseModelProps, IJsModelProps } from '../typings';\nimport { MicroInstanceModel } from '../mode/instance';\nimport { AppState } from '../common';\n\nexport async function load(props: IBaseModelProps): Promise<BaseModel> {\n if (props.mode === 'app') return await loadApp(props);\n if (props.mode === 'js') return await loadInstance(props);\n return await loadApp(props);\n}\n// 加载app\nexport async function loadApp(props: IAppModleProps): Promise<MicroAppModel> {\n let instance = appCache.getApp(props.id);\n if (!instance) {\n instance = new MicroAppModel(props);\n appCache.setApp(instance);\n }\n await instance.start();\n return instance as MicroAppModel;\n}\n// 加载instance\nexport function loadInstance(props: IJsModelProps): Promise<MicroInstanceModel> {\n return new Promise((resolve) => {\n let instance = appCache.getApp(props.id);\n if (!instance) {\n instance = new MicroInstanceModel(props);\n appCache.setApp(instance);\n instance.start().then(() => resolve(instance as MicroInstanceModel));\n } else if ([AppState.UNSET, AppState.MOUNTING].includes(instance.status)) {\n const timer = setInterval(() => {\n if ([AppState.ERROR, AppState.MOUNTED].includes(instance!.status)) {\n resolve(instance as MicroInstanceModel);\n clearInterval(timer);\n }\n }, 300);\n } else {\n resolve(instance as MicroInstanceModel);\n }\n });\n}\n","import { resetDocumentPrototypeMethods } from '../context/document';\nimport { resetBodyAndHeaderMethods } from '../context/element';\nimport { AppState } from '../common';\nimport { appCache } from '../cache/app-cache';\n\nexport function unmount(appKey: string) {\n const app = appCache.getApp(appKey);\n if (app?.status !== AppState.UNMOUNT) {\n app?.unmount();\n }\n if (!appCache.hasActiveApp) {\n resetBodyAndHeaderMethods();\n resetDocumentPrototypeMethods();\n }\n}\n","import { nextTask } from '../utils/common';\nimport { appCache } from '../cache/app-cache';\nimport { BaseModel } from '../typings';\nimport { AppState } from '../common';\n\nexport function activated<T>(\n appKey: string,\n container: HTMLElement | ShadowRoot,\n callback?: <M extends BaseModel>(instance: M, exportInstance?: T) => void,\n) {\n const app = appCache.getApp(appKey);\n if (app?.status === AppState.DEACTIVATED && app.keepAlive) {\n nextTask(() => app?.activated(container, callback));\n } else {\n nextTask(() => app?.mount(container, callback));\n }\n}\n","import { resetDocumentPrototypeMethods } from '../context/document';\nimport { resetBodyAndHeaderMethods } from '../context/element';\nimport { AppState } from '../common';\nimport { appCache } from '../cache/app-cache';\n\nexport function deactivated(appKey: string) {\n const app = appCache.getApp(appKey);\n if (app && [AppState.ACTIVATED, AppState.MOUNTED].includes(app.status)) {\n app.keepAlive ? app.deactivated() : app.unmount();\n }\n if (!appCache.hasActiveApp) {\n resetBodyAndHeaderMethods();\n resetDocumentPrototypeMethods();\n }\n}\n","import { AppState } from '../common';\nimport { IAppModleProps, IJsModelProps } from '../typings';\nimport { appCache } from '../cache/app-cache';\nimport { beforeLoad } from '../lifecircle/before-load';\nimport { load } from '../lifecircle/load';\nimport { unmount } from '../lifecircle/unmount';\n// import { mount } from '../lifecircle/mount';\nimport { activated } from '../lifecircle/activated';\nimport { deactivated } from '../lifecircle/deactivated';\n// bk-weweb支持的属性配置\nexport enum ObserveAttrs {\n URL = 'url',\n showSourceCode = 'showSourceCode',\n scopeLocation = 'scopeLocation',\n setShodowDom = 'setShodowDom',\n mode = 'mode',\n data = 'data',\n id = 'id',\n scopeJs = 'scopeJs',\n scopeCss = 'scopeCss',\n keepAlive = 'keepAlive'\n}\nexport default class BkIframeElement extends HTMLElement {\n static get observedAttributes(): string[] {\n return [ObserveAttrs.URL];\n }\n private connected = false;\n private appUrl = '';\n // 考虑到js模式下 需要js bundle的复用性 需用户设置id属性 如果单实例下则可以不用配置\n get appKey(): string | null {\n return this.getAttribute(ObserveAttrs.id) || this.getAttribute(ObserveAttrs.URL);\n }\n get appData(): Record<string, unknown> {\n if (this.hasAttribute(ObserveAttrs.data)) {\n try {\n return JSON.parse(this.getAttribute(ObserveAttrs.data)!);\n } catch {}\n }\n return {};\n }\n get appProps(): IAppModleProps | IJsModelProps {\n if (this.getAttribute('mode') === 'js') {\n return {\n url: this.getAttribute(ObserveAttrs.URL)!,\n mode: 'js',\n id: this.appKey!,\n data: this.appData,\n container: this.shadowRoot ?? this,\n showSourceCode: this.getBooleanAttr(ObserveAttrs.showSourceCode),\n scopeCss: this.getBooleanAttr(ObserveAttrs.scopeCss) && !this.getBooleanAttr(ObserveAttrs.setShodowDom),\n scopeJs: this.getBooleanAttr(ObserveAttrs.scopeJs),\n keepAlive: this.getBooleanAttr(ObserveAttrs.keepAlive),\n };\n }\n return {\n url: this.getAttribute(ObserveAttrs.URL)!,\n mode: 'app',\n id: this.appKey!,\n data: this.appData,\n container: this.shadowRoot ?? this,\n scopeLocation: this.getBooleanAttr(ObserveAttrs.scopeLocation),\n showSourceCode: this.getBooleanAttr(ObserveAttrs.showSourceCode),\n scopeCss: !this.getBooleanAttr(ObserveAttrs.setShodowDom),\n scopeJs: !this.getBooleanAttr(ObserveAttrs.scopeJs),\n keepAlive: this.getBooleanAttr(ObserveAttrs.keepAlive),\n };\n }\n async connectedCallback(): Promise<void> {\n beforeLoad();\n if (this.getBooleanAttr(ObserveAttrs.setShodowDom) && !this.shadowRoot) {\n this.attachShadow({ mode: 'open', delegatesFocus: true });\n }\n await load(this.appProps);\n activated(this.appKey!, this.shadowRoot ?? this);\n this.connected = true;\n }\n disconnectedCallback(): void {\n this.connected = false;\n if (this.appProps.keepAlive) {\n deactivated(this.appKey!);\n } else unmount(this.appKey!);\n }\n attributeChangedCallback(attr: ObserveAttrs, _oldVal: string, newVal: string): void {\n if (attr !== ObserveAttrs.URL || (this as any)[attr] === newVal) return;\n this.appUrl = newVal;\n (this.connected || appCache.getApp(this.appKey!)) && this.handleAttributeChanged();\n }\n private async handleAttributeChanged(): Promise<void> {\n if (!this.appKey) return;\n if (this.getBooleanAttr(ObserveAttrs.setShodowDom)) {\n this.attachShadow({ mode: 'open' });\n }\n const app = appCache.getApp(this.appKey!);\n if (app && app.url === this.appUrl && (app.isPreLoad || app.status === AppState.UNMOUNT)) {\n activated(this.appKey!, this.shadowRoot ?? this);\n return;\n }\n await load(this.appProps);\n }\n private getBooleanAttr(name: string): boolean | undefined {\n return this.hasAttribute(name) ? this.getAttribute(name) !== 'false' : undefined;\n }\n}\n","import './context/memory';\nimport { FetchSourceType, IStartOption } from './typings';\nimport BkIframeElement from './component/web-compnent';\n\nexport * from './lifecircle/before-load';\nexport * from './lifecircle/load';\nexport * from './lifecircle/mount';\nexport * from './lifecircle/unload';\nexport * from './lifecircle/unmount';\nexport * from './lifecircle/activated';\nexport * from './lifecircle/deactivated';\nexport * from './preload/preload';\n\nconst CUSTOM_ELEMENT_TAG = 'bk-weweb';\nexport class IframeApp {\n fetchSource?: FetchSourceType;\n webcomponentTag = CUSTOM_ELEMENT_TAG;\n constructor() {\n if (!window.customElements.get(CUSTOM_ELEMENT_TAG)) {\n window.customElements.define(CUSTOM_ELEMENT_TAG, BkIframeElement);\n }\n }\n // todo set some global start props\n start(option?: IStartOption) {\n if (typeof option?.fetchSource === 'function') {\n this.fetchSource = option.fetchSource;\n }\n this.webcomponentTag = option?.webcomponentTag || CUSTOM_ELEMENT_TAG;\n this.setWebComponentTag();\n }\n // 设置自定义dom标签名\n setWebComponentTag() {\n if (!window.customElements.get(this.webcomponentTag)) {\n window.customElements.define(this.webcomponentTag, BkIframeElement);\n }\n }\n}\nconst iframeApp = new IframeApp();\nexport default iframeApp;\n","import { nextTask } from '../utils/common';\nimport { appCache } from '../cache/app-cache';\nimport { BaseModel } from '../typings';\n\nexport function mount<T>(\n appKey: string,\n container?: HTMLElement | ShadowRoot,\n callback?: <M extends BaseModel>(instance: M, exportInstance?: T) => void,\n) {\n const app = appCache.getApp(appKey);\n nextTask(() => app?.mount(container, callback));\n}\n","/* eslint-disable @typescript-eslint/no-misused-promises */\nimport { IAppModleProps, IJsModelProps } from '../typings';\nimport { requestIdleCallback } from '../utils/common';\nimport { loadApp, loadInstance } from '../lifecircle/load';\nimport { LoadGlobalSource, SourceType } from '../utils/load-source';\n\n// 预加载微模块\nexport function preLoadInstance(options: IJsModelProps) {\n requestIdleCallback(() => loadInstance({\n ...options,\n isPreLoad: true,\n }));\n}\n// 预加载微应用\nexport function preLoadApp(options: IAppModleProps) {\n requestIdleCallback(() => loadApp({\n ...options,\n isPreLoad: true,\n }));\n}\n// 预加载资源\nexport function preLoadSource(sourceList: SourceType) {\n requestIdleCallback(() => {\n LoadGlobalSource(sourceList);\n });\n}\n","import { appCache } from '../cache/app-cache';\n\nexport function unload(url: string) {\n appCache.deleteApp(url);\n}\n"],"names":["currentRunningApp","getCurrentRunningApp","setCurrentRunningApp","appInstance","documentClickListMap","Map","documentEventListenerMap","isSupportModuleScript","document","createElement","templateStyle","setAttribute","body","appendChild","sheet","disabled","disabledStyleDom","AppState","isFunction","target","nextTask","window","Zone","setTimeout","cb","Promise","resolve","then","addUrlProtocol","url","startsWith","location","protocol","fillUpPath","path","baseURI","test","URL","origin","pathname","pathArr","split","pop","join","replace","getUrlDir","toString","isIE11","navigator","userAgent","indexOf","randomUrl","random","requestIdleCallback","fn","lastTime","Date","now","didTimeout","handle","Math","max","tagName","options","element","__BK_WEWEB_APP_KEY__","isBodyElement","key","n","str","result","i","parseInt","length","fetchSource","weWeb","fetch","res","text","CSS_ATTRIBUTE_KEY","CSS_RULE_TYPE","commonEScapeKeyList","escapeSetterKeyList","scopeWindowKeyList","scopedLocationKeyList","DescriptorMapValue","commonRawWindowKeyMap","undefined","Array","Object","String","Boolean","Reflect","Function","Number","Symbol","parseFloat","Float32Array","Set","Infinity","devicePixelRatio","HTMLElement","Element","performance","console","isFinite","RegExp","JSON","Proxy","isNaN","WeakMap","WeakSet","Uint8Array","commonFakeWindowKeyMap","__VUE_OPTIONS_API__","__VUE_I18N_LEGACY_API__","__VUE_I18N_FULL_INSTALL__","__VUE_DEVTOOLS_GLOBAL_HOOK__","__VUE_DEVTOOLS_HOOK_REPLAY__","__VUE_DEVTOOLS_PLUGINS__","__DEV__","webpackChunktrace","webpackChunkpc","webpackChunkapm","i18n","constructorMap","rawWindowMethodMap","bindFunctionToRawWindow","rawWindow","value","has","get","valueStr","prototype","constructor","getOwnPropertyNames","set","isConstructor","bindRawWindowValue","bind","keys","forEach","hasOwnProperty","SandBox","app","resetWindowFunction","resetDocumentAndBodyEvent","injectedKeySet","escapedKeySet","active","rawDocument","proxyWindow","fakeWindow","windowSymbolKey","this","descriptorMap","__POWERED_BY_BK_WEWEB__","appCacheKey","eventListenerMap","intervalIdMap","timeoutIdMap","addEventListener","removeEventListener","setInterval","clearInterval","clearTimeout","documentRemoveEventListener","type","listener","listenerList","add","call","size","delete","handler","timeout","args","intervalId","timeoutId","clear","_","documentAppListenersMap","rewriteWindowFunction","name","unscopables","includes","registerRunningApp","eval","MicroAppModel","iframe","scopeLocation","contentWindow","parent","rawValue","descriptor","getOwnPropertyDescriptor","writable","configurable","enumerable","defineProperty","WINDOW","ownKeys","arrayUnique","array","concat","from","deleteProperty","showSourceCode","activeated","data","__BK_WEWEB_DATA__","bodyAddEventListener","bodyRemoveEventListener","appListenersMap","appListenerList","container","ShadowRoot","rewriteDocumentAndBodyEvent","deactivated","eventHandler","event","defineProperties","currentTarget","srcElement","dispatchLinkOrScriptLoad","CustomEvent","onload","dispatchEvent","bodyAppendChild","HTMLBodyElement","resetNewElement","child","HTMLStyleElement","hasAttribute","createComment","styleInstance","Style","code","textContent","fromHtml","source","setStyle","scopedStyleCSS","HTMLLinkElement","collectLink","style","scopedLinkCSS","HTMLScriptElement","replaceInfo","collectScript","script","excuteCode","scopeJs","getAttribute","observer","MutationObserver","disconnect","scriptInfo","remove","scriptInstance","Script","async","defer","isModule","scripts","e","error","observe","attributeFilter","childList","subtree","isSepcailElement","node","elmentAppendHandler","newChild","rawMethod","appCache","getApp","targetChild","needKeepAlive","keepAlive","head","setMarkElement","__KEEP_ALIVE__","scopedCode","prefetch","preload","scoped","initial","styles","getCacheStyle","catch","styleElement","getCode","innerHTML","commonScoped","cssRules","attributes","characterData","linkElement","prepend","href","onerror","dispatchLinkOrScriptError","scopeCss","cssText","resetUrlHost","rules","cssPrefix","scopedCss","scopeRule","all","$1","$2","rule","STYLE_RULE","scopeStyleRule","MEDIA_RULE","resetPackRule","SUPPORTS_RULE","prefix","packName","conditionText","linkpath","getFileDir","selectorText","builtInRootSelectorRE","selectors","excuteAppStyles","styleList","values","promiseList","push","styleElementList","parentElemnt","append","MicroInstanceModel","state","UNSET","isPreLoad","sandBox","initSource","props","id","status","v","ERROR","EntrySource","importEntery","onMount","LOADED","mount","onError","callback","MOUNTING","instanceWrap","wrapId","execAppScripts","finally","MOUNTED","getScript","exportInstance","render","activated","ACTIVATED","fragment","createDocumentFragment","childNodes","DEACTIVATED","unmount","needDestroy","UNMOUNT","deleteApp","firstGlobalProp","secondGlobalProp","lastGlobalProp","getCacheScript","needRelaceScriptElement","global","p","shouldSkipProperty","noteGlobalProps","transformCode","scriptElement","executeSourceScript","executeMemoryScript","exportProp","useFirstGlobalProp","foundLastProp","cnt","getGlobalProp","blob","Blob","src","createObjectURL","isScopedLocation","history","appInitialScriptList","filter","map","appScriptList","commomList","deferScriptList","asyncScriptList","mode","LOADING","createIframe","clonedNode","html","cloneNode","search","hash","collectSource","soruceList","collectStyle","match","rawHtml","importEntry","importHtmlEntry","importInstanceEntry","htmlStr","getCacheHtml","cache","reject","wrapElement","collectScriptAndStyle","jsStr","children","dom","HTMLMetaElement","HTMLTitleElement","removeChild","HTMLImageElement","link","needReplaceELement","rel","replaceElement","getStyle","replaceChild","nonceStr","setScript","baseSource","hasActiveApp","some","setApp","find","item","setBaseAppStyle","setBaseAppScript","__getAppOrInstance__","querySelector","querySelectorAll","getElementById","getElementsByClassName","getElementsByTagName","getElementsByName","Document","resetDocumentPrototypeMethods","bodyRemoveChild","headAppendChild","headRemoveChild","insertBefore","headInsertBefore","HTMLHeadElement","rawHead","rewriteBodyAndHeaderMethods","toLocaleUpperCase","nodes","refChild","passiveChild","contains","elementInsertHandler","oldChild","resetBodyAndHeaderMethods","beforeLoad","querySelectorNew","querySelectorAllNew","toLocaleLowerCase","rewriteDocumentPrototypeMethods","load","loadApp","loadInstance","instance","start","timer","appKey","ObserveAttrs","BkIframeElement","observedAttributes","connected","appUrl","appData","parse","appProps","shadowRoot","getBooleanAttr","setShodowDom","attachShadow","delegatesFocus","disconnectedCallback","attributeChangedCallback","attr","_oldVal","newVal","handleAttributeChanged","CUSTOM_ELEMENT_TAG","IframeApp","webcomponentTag","customElements","define","option","setWebComponentTag","iframeApp","sourceList","entries","LoadGlobalSource"],"mappings":"gPAEA,IAAIA,EAAsC,cAC1BC,IACd,OAAOD,EAEH,SAAUE,EAAqBC,GACnCH,EAAoBG,EAIf,MAAMC,EAAuB,IAAIC,IAG3BC,EAA2B,IAAID,IAG/BE,EAAwB,aADtBC,SAASC,cAAc,UAKhCC,EAAkCF,SAASC,cAAc,SAC/DC,EAAcC,aAAa,KAHQ,uBAInCH,SAASI,KAAKC,YAAYH,GAC1BA,EAAcI,MAAOC,UAAW,EACzB,MAAMC,EAAmBN,ECxBhC,IAAYO,ECAN,SAAUC,EAAWC,GACzB,MAAyB,mBAAXA,GDDhB,SAAYF,GACVA,EAAA,MAAA,QACAA,EAAA,QAAA,UACAA,EAAA,OAAA,SACAA,EAAA,MAAA,QACAA,EAAA,SAAA,WACAA,EAAA,QAAA,UACAA,EAAA,UAAA,YACAA,EAAA,YAAA,cACAA,EAAA,QAAA,UATF,CAAYA,IAAAA,EAUX,KCNM,MAAMG,EAA2D,mBAAhBC,OAAOC,KAAsBC,WAAaC,GAAMC,QAAQC,UAAUC,KAAKH,GAazH,SAAUI,EAAeC,GAC7B,OAAOA,EAAIC,WAAW,MAAQ,GAAGC,SAASC,WAAWH,IAAQA,EAe/C,SAAAI,EAAWC,EAAcC,GACvC,OAAKD,GAAQ,+BAA+BE,KAAKF,IAAS,gBAAgBE,K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