xpe 0.0.0-alpha.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +627 -71
- package/dist/child/app-client.d.ts +44 -0
- package/dist/child/app-client.js +151 -0
- package/dist/child/index.d.ts +3 -0
- package/dist/child/index.js +3 -0
- package/dist/child/lifecycle.d.ts +12 -0
- package/dist/child/lifecycle.js +47 -0
- package/dist/child/mock-host.d.ts +8 -0
- package/dist/child/mock-host.js +41 -0
- package/dist/core/bridge.d.ts +28 -0
- package/dist/core/bridge.js +19 -0
- package/dist/core/events.d.ts +13 -0
- package/dist/core/events.js +56 -0
- package/dist/core/index.d.ts +3 -0
- package/dist/core/index.js +3 -0
- package/dist/core/types.d.ts +102 -0
- package/dist/core/types.js +20 -0
- package/dist/dev-shell/index.d.ts +26 -0
- package/dist/dev-shell/index.js +56 -0
- package/dist/host/app-path-router.d.ts +33 -0
- package/dist/host/app-path-router.js +183 -0
- package/dist/host/host-runtime.d.ts +29 -0
- package/dist/host/host-runtime.js +176 -0
- package/dist/host/index.d.ts +1 -0
- package/dist/host/index.js +1 -0
- package/dist/host/xpe-host.d.ts +41 -0
- package/dist/host/xpe-host.js +61 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/kernel/common.d.ts +62 -0
- package/dist/kernel/common.js +207 -0
- package/dist/kernel/constant.d.ts +26 -0
- package/dist/kernel/constant.js +42 -0
- package/dist/kernel/effect.d.ts +32 -0
- package/dist/kernel/effect.js +529 -0
- package/dist/kernel/entry.d.ts +43 -0
- package/dist/kernel/entry.js +224 -0
- package/dist/kernel/event.d.ts +22 -0
- package/dist/kernel/event.js +120 -0
- package/dist/kernel/iframe.d.ts +141 -0
- package/dist/kernel/iframe.js +1104 -0
- package/dist/kernel/index.d.ts +25 -0
- package/dist/kernel/index.js +86 -0
- package/dist/kernel/plugin.d.ts +36 -0
- package/dist/kernel/plugin.js +68 -0
- package/dist/kernel/proxy.d.ts +17 -0
- package/dist/kernel/proxy.js +440 -0
- package/dist/kernel/runtime-engine.d.ts +154 -0
- package/dist/kernel/runtime-engine.js +209 -0
- package/dist/kernel/sandbox.d.ts +235 -0
- package/dist/kernel/sandbox.js +879 -0
- package/dist/kernel/shadow.d.ts +64 -0
- package/dist/kernel/shadow.js +385 -0
- package/dist/kernel/sync.d.ts +21 -0
- package/dist/kernel/sync.js +185 -0
- package/dist/kernel/template.d.ts +67 -0
- package/dist/kernel/template.js +226 -0
- package/dist/kernel/tracker.d.ts +44 -0
- package/dist/kernel/tracker.js +92 -0
- package/dist/kernel/utils.d.ts +100 -0
- package/dist/kernel/utils.js +325 -0
- package/dist/kernel/xpe-bridge.d.ts +27 -0
- package/dist/kernel/xpe-bridge.js +205 -0
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/index.js +3 -0
- package/package.json +79 -57
- package/LICENSE +0 -21
- package/framework/es/core/Application.d.ts +0 -126
- package/framework/es/core/Command/Command.d.ts +0 -7
- package/framework/es/core/Container/Container.d.ts +0 -80
- package/framework/es/core/Contracts/AxiosAdapter.d.ts +0 -12
- package/framework/es/core/Helper/Helper.d.ts +0 -43
- package/framework/es/core/Helper/Storage/WebStorage.d.ts +0 -71
- package/framework/es/core/Libs/Exception.d.ts +0 -24
- package/framework/es/core/Libs/Lib.d.ts +0 -72
- package/framework/es/core/Provider/CommandProvider.d.ts +0 -4
- package/framework/es/core/Provider/HelperProvider.d.ts +0 -4
- package/framework/es/core/Provider/HttpProvider.d.ts +0 -13
- package/framework/es/core/Provider/ServiceProvider.d.ts +0 -15
- package/framework/es/core/Service/HttpService.d.ts +0 -133
- package/framework/es/core/Service/Service.d.ts +0 -6
- package/framework/es/core/Spanner/RESTful.d.ts +0 -30
- package/framework/es/core/Transformer/Transformer.d.ts +0 -46
- package/framework/es/core/Type/adapters.d.ts +0 -25
- package/framework/es/core/Type/types.d.ts +0 -161
- package/framework/es/core/TypeFunc/index.d.ts +0 -6
- package/framework/es/core/Wrenches/EventBus.d.ts +0 -56
- package/framework/es/core/Wrenches/is.d.ts +0 -19
- package/framework/es/ege.js +0 -4
- package/framework/es/ege.js.map +0 -1
- package/framework/es/index.d.ts +0 -13
- package/framework/es/pdd.js +0 -4
- package/framework/es/pdd.js.map +0 -1
- package/framework/es/src/core/Application.d.ts +0 -127
- package/framework/es/src/core/Application.d.ts.map +0 -1
- package/framework/es/src/core/Command/Command.d.ts +0 -8
- package/framework/es/src/core/Command/Command.d.ts.map +0 -1
- package/framework/es/src/core/Container/Container.d.ts +0 -81
- package/framework/es/src/core/Container/Container.d.ts.map +0 -1
- package/framework/es/src/core/Contracts/AxiosAdapter.d.ts +0 -13
- package/framework/es/src/core/Contracts/AxiosAdapter.d.ts.map +0 -1
- package/framework/es/src/core/Helper/Helper.d.ts +0 -45
- package/framework/es/src/core/Helper/Helper.d.ts.map +0 -1
- package/framework/es/src/core/Helper/Storage/WebStorage.d.ts +0 -72
- package/framework/es/src/core/Helper/Storage/WebStorage.d.ts.map +0 -1
- package/framework/es/src/core/Libs/Exception.d.ts +0 -25
- package/framework/es/src/core/Libs/Exception.d.ts.map +0 -1
- package/framework/es/src/core/Libs/Lib.d.ts +0 -73
- package/framework/es/src/core/Libs/Lib.d.ts.map +0 -1
- package/framework/es/src/core/Provider/CommandProvider.d.ts +0 -5
- package/framework/es/src/core/Provider/CommandProvider.d.ts.map +0 -1
- package/framework/es/src/core/Provider/HelperProvider.d.ts +0 -5
- package/framework/es/src/core/Provider/HelperProvider.d.ts.map +0 -1
- package/framework/es/src/core/Provider/HttpProvider.d.ts +0 -14
- package/framework/es/src/core/Provider/HttpProvider.d.ts.map +0 -1
- package/framework/es/src/core/Provider/ServiceProvider.d.ts +0 -16
- package/framework/es/src/core/Provider/ServiceProvider.d.ts.map +0 -1
- package/framework/es/src/core/Service/HttpService.d.ts +0 -128
- package/framework/es/src/core/Service/HttpService.d.ts.map +0 -1
- package/framework/es/src/core/Service/Service.d.ts +0 -7
- package/framework/es/src/core/Service/Service.d.ts.map +0 -1
- package/framework/es/src/core/Spanner/RESTful.d.ts +0 -32
- package/framework/es/src/core/Spanner/RESTful.d.ts.map +0 -1
- package/framework/es/src/core/Transformer/Transformer.d.ts +0 -47
- package/framework/es/src/core/Transformer/Transformer.d.ts.map +0 -1
- package/framework/es/src/core/Type/adapters.d.ts +0 -26
- package/framework/es/src/core/Type/adapters.d.ts.map +0 -1
- package/framework/es/src/core/Type/types.d.ts +0 -186
- package/framework/es/src/core/Type/types.d.ts.map +0 -1
- package/framework/es/src/core/TypeFunc/index.d.ts +0 -8
- package/framework/es/src/core/TypeFunc/index.d.ts.map +0 -1
- package/framework/es/src/core/Wrenches/EventBus.d.ts +0 -57
- package/framework/es/src/core/Wrenches/EventBus.d.ts.map +0 -1
- package/framework/es/src/core/Wrenches/is.d.ts +0 -20
- package/framework/es/src/core/Wrenches/is.d.ts.map +0 -1
- package/framework/es/src/index.d.ts +0 -14
- package/framework/es/src/index.d.ts.map +0 -1
- package/framework/es/src/utils.d.ts +0 -17
- package/framework/es/src/utils.d.ts.map +0 -1
- package/framework/es/utils.d.ts +0 -16
- package/framework/umd/core/Application.d.ts +0 -126
- package/framework/umd/core/Command/Command.d.ts +0 -7
- package/framework/umd/core/Container/Container.d.ts +0 -80
- package/framework/umd/core/Contracts/AxiosAdapter.d.ts +0 -12
- package/framework/umd/core/Helper/Helper.d.ts +0 -43
- package/framework/umd/core/Helper/Storage/WebStorage.d.ts +0 -71
- package/framework/umd/core/Libs/Exception.d.ts +0 -24
- package/framework/umd/core/Libs/Lib.d.ts +0 -72
- package/framework/umd/core/Provider/CommandProvider.d.ts +0 -4
- package/framework/umd/core/Provider/HelperProvider.d.ts +0 -4
- package/framework/umd/core/Provider/HttpProvider.d.ts +0 -13
- package/framework/umd/core/Provider/ServiceProvider.d.ts +0 -15
- package/framework/umd/core/Service/HttpService.d.ts +0 -133
- package/framework/umd/core/Service/Service.d.ts +0 -6
- package/framework/umd/core/Spanner/RESTful.d.ts +0 -30
- package/framework/umd/core/Transformer/Transformer.d.ts +0 -46
- package/framework/umd/core/Type/adapters.d.ts +0 -25
- package/framework/umd/core/Type/types.d.ts +0 -161
- package/framework/umd/core/TypeFunc/index.d.ts +0 -6
- package/framework/umd/core/Wrenches/EventBus.d.ts +0 -56
- package/framework/umd/core/Wrenches/is.d.ts +0 -19
- package/framework/umd/ege.js +0 -4
- package/framework/umd/ege.js.map +0 -1
- package/framework/umd/index.d.ts +0 -13
- package/framework/umd/pdd.js +0 -4
- package/framework/umd/pdd.js.map +0 -1
- package/framework/umd/src/core/Application.d.ts +0 -127
- package/framework/umd/src/core/Application.d.ts.map +0 -1
- package/framework/umd/src/core/Command/Command.d.ts +0 -8
- package/framework/umd/src/core/Command/Command.d.ts.map +0 -1
- package/framework/umd/src/core/Container/Container.d.ts +0 -81
- package/framework/umd/src/core/Container/Container.d.ts.map +0 -1
- package/framework/umd/src/core/Contracts/AxiosAdapter.d.ts +0 -13
- package/framework/umd/src/core/Contracts/AxiosAdapter.d.ts.map +0 -1
- package/framework/umd/src/core/Helper/Helper.d.ts +0 -45
- package/framework/umd/src/core/Helper/Helper.d.ts.map +0 -1
- package/framework/umd/src/core/Helper/Storage/WebStorage.d.ts +0 -72
- package/framework/umd/src/core/Helper/Storage/WebStorage.d.ts.map +0 -1
- package/framework/umd/src/core/Libs/Exception.d.ts +0 -25
- package/framework/umd/src/core/Libs/Exception.d.ts.map +0 -1
- package/framework/umd/src/core/Libs/Lib.d.ts +0 -73
- package/framework/umd/src/core/Libs/Lib.d.ts.map +0 -1
- package/framework/umd/src/core/Provider/CommandProvider.d.ts +0 -5
- package/framework/umd/src/core/Provider/CommandProvider.d.ts.map +0 -1
- package/framework/umd/src/core/Provider/HelperProvider.d.ts +0 -5
- package/framework/umd/src/core/Provider/HelperProvider.d.ts.map +0 -1
- package/framework/umd/src/core/Provider/HttpProvider.d.ts +0 -14
- package/framework/umd/src/core/Provider/HttpProvider.d.ts.map +0 -1
- package/framework/umd/src/core/Provider/ServiceProvider.d.ts +0 -16
- package/framework/umd/src/core/Provider/ServiceProvider.d.ts.map +0 -1
- package/framework/umd/src/core/Service/HttpService.d.ts +0 -128
- package/framework/umd/src/core/Service/HttpService.d.ts.map +0 -1
- package/framework/umd/src/core/Service/Service.d.ts +0 -7
- package/framework/umd/src/core/Service/Service.d.ts.map +0 -1
- package/framework/umd/src/core/Spanner/RESTful.d.ts +0 -32
- package/framework/umd/src/core/Spanner/RESTful.d.ts.map +0 -1
- package/framework/umd/src/core/Transformer/Transformer.d.ts +0 -47
- package/framework/umd/src/core/Transformer/Transformer.d.ts.map +0 -1
- package/framework/umd/src/core/Type/adapters.d.ts +0 -26
- package/framework/umd/src/core/Type/adapters.d.ts.map +0 -1
- package/framework/umd/src/core/Type/types.d.ts +0 -186
- package/framework/umd/src/core/Type/types.d.ts.map +0 -1
- package/framework/umd/src/core/TypeFunc/index.d.ts +0 -8
- package/framework/umd/src/core/TypeFunc/index.d.ts.map +0 -1
- package/framework/umd/src/core/Wrenches/EventBus.d.ts +0 -57
- package/framework/umd/src/core/Wrenches/EventBus.d.ts.map +0 -1
- package/framework/umd/src/core/Wrenches/is.d.ts +0 -20
- package/framework/umd/src/core/Wrenches/is.d.ts.map +0 -1
- package/framework/umd/src/index.d.ts +0 -14
- package/framework/umd/src/index.d.ts.map +0 -1
- package/framework/umd/src/utils.d.ts +0 -17
- package/framework/umd/src/utils.d.ts.map +0 -1
- package/framework/umd/utils.d.ts +0 -16
- package/index.d.ts +0 -724
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { getXpeInject, getXpeInternalSandbox, getXpeRawDocumentQuerySelector, isPoweredByXpe, setXpeInject, } from "./xpe-bridge.js";
|
|
2
|
+
// 全部沙盒实例和配置存储 map
|
|
3
|
+
// 除了挂载到 sandbox 实例上,还挂载到 XPE inject 全局上,防止重复创建
|
|
4
|
+
export const idToSandboxCacheMap = (() => {
|
|
5
|
+
const inject = getXpeInject(window);
|
|
6
|
+
if (inject?.idToSandboxMap)
|
|
7
|
+
return inject.idToSandboxMap;
|
|
8
|
+
else {
|
|
9
|
+
const cacheMap = (isPoweredByXpe(window) ? getXpeInternalSandbox(window)?.inject?.idToSandboxMap : undefined) ??
|
|
10
|
+
new Map();
|
|
11
|
+
setXpeInject(window, { idToSandboxMap: cacheMap });
|
|
12
|
+
return cacheMap;
|
|
13
|
+
}
|
|
14
|
+
})();
|
|
15
|
+
export function getSandboxById(id) {
|
|
16
|
+
return idToSandboxCacheMap.get(id)?.sandbox || null;
|
|
17
|
+
}
|
|
18
|
+
export function getOptionsById(id) {
|
|
19
|
+
return idToSandboxCacheMap.get(id)?.options || null;
|
|
20
|
+
}
|
|
21
|
+
export function addSandboxCacheWithSandbox(id, sandbox) {
|
|
22
|
+
const sandboxCache = idToSandboxCacheMap.get(id);
|
|
23
|
+
if (sandboxCache)
|
|
24
|
+
idToSandboxCacheMap.set(id, { ...sandboxCache, sandbox });
|
|
25
|
+
else
|
|
26
|
+
idToSandboxCacheMap.set(id, { sandbox });
|
|
27
|
+
}
|
|
28
|
+
export function deleteSandboxById(id) {
|
|
29
|
+
const sandboxCache = idToSandboxCacheMap.get(id);
|
|
30
|
+
// 有 setupApp 缓存时只移除 sandbox 实例,保留 options 供下次快速启动
|
|
31
|
+
// 无 setupApp 缓存时整体删除 entry,避免泄漏
|
|
32
|
+
if (sandboxCache?.options) {
|
|
33
|
+
idToSandboxCacheMap.set(id, { options: sandboxCache.options });
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
idToSandboxCacheMap.delete(id);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export function addSandboxCacheWithOptions(id, options) {
|
|
40
|
+
const sandboxCache = idToSandboxCacheMap.get(id);
|
|
41
|
+
if (sandboxCache)
|
|
42
|
+
idToSandboxCacheMap.set(id, { ...sandboxCache, options });
|
|
43
|
+
else
|
|
44
|
+
idToSandboxCacheMap.set(id, { options });
|
|
45
|
+
}
|
|
46
|
+
// 分类document上需要处理的属性,不同类型会进入不同的处理逻辑
|
|
47
|
+
export const documentProxyProperties = {
|
|
48
|
+
// 降级场景下需要本地特殊处理的属性
|
|
49
|
+
modifyLocalProperties: [
|
|
50
|
+
"createElement",
|
|
51
|
+
"createTextNode",
|
|
52
|
+
"documentURI",
|
|
53
|
+
"URL",
|
|
54
|
+
"getElementsByTagName",
|
|
55
|
+
"getElementById",
|
|
56
|
+
],
|
|
57
|
+
// 子应用需要手动修正的属性方法
|
|
58
|
+
modifyProperties: [
|
|
59
|
+
"createElement",
|
|
60
|
+
"createTextNode",
|
|
61
|
+
"documentURI",
|
|
62
|
+
"URL",
|
|
63
|
+
"getElementsByTagName",
|
|
64
|
+
"getElementsByClassName",
|
|
65
|
+
"getElementsByName",
|
|
66
|
+
"getElementById",
|
|
67
|
+
"querySelector",
|
|
68
|
+
"querySelectorAll",
|
|
69
|
+
"documentElement",
|
|
70
|
+
"scrollingElement",
|
|
71
|
+
"forms",
|
|
72
|
+
"images",
|
|
73
|
+
"links",
|
|
74
|
+
],
|
|
75
|
+
// 需要从shadowRoot中获取的属性
|
|
76
|
+
shadowProperties: [
|
|
77
|
+
"activeElement",
|
|
78
|
+
"childElementCount",
|
|
79
|
+
"children",
|
|
80
|
+
"firstElementChild",
|
|
81
|
+
"firstChild",
|
|
82
|
+
"fullscreenElement",
|
|
83
|
+
"lastElementChild",
|
|
84
|
+
"pictureInPictureElement",
|
|
85
|
+
"pointerLockElement",
|
|
86
|
+
"styleSheets",
|
|
87
|
+
],
|
|
88
|
+
// 需要从shadowRoot中获取的方法
|
|
89
|
+
shadowMethods: [
|
|
90
|
+
"append",
|
|
91
|
+
"contains",
|
|
92
|
+
"getSelection",
|
|
93
|
+
"elementFromPoint",
|
|
94
|
+
"elementsFromPoint",
|
|
95
|
+
"getAnimations",
|
|
96
|
+
"replaceChildren",
|
|
97
|
+
],
|
|
98
|
+
// 需要从主应用document中获取的属性
|
|
99
|
+
documentProperties: [
|
|
100
|
+
"characterSet",
|
|
101
|
+
"compatMode",
|
|
102
|
+
"contentType",
|
|
103
|
+
"designMode",
|
|
104
|
+
"dir",
|
|
105
|
+
"doctype",
|
|
106
|
+
"embeds",
|
|
107
|
+
"fullscreenEnabled",
|
|
108
|
+
"hidden",
|
|
109
|
+
"implementation",
|
|
110
|
+
"lastModified",
|
|
111
|
+
"pictureInPictureEnabled",
|
|
112
|
+
"plugins",
|
|
113
|
+
"readyState",
|
|
114
|
+
"referrer",
|
|
115
|
+
"visibilityState",
|
|
116
|
+
"fonts",
|
|
117
|
+
],
|
|
118
|
+
// 需要从主应用document中获取的方法
|
|
119
|
+
documentMethods: [
|
|
120
|
+
"execCommand",
|
|
121
|
+
"caretPositionFromPoint",
|
|
122
|
+
"createRange",
|
|
123
|
+
"exitFullscreen",
|
|
124
|
+
"exitPictureInPicture",
|
|
125
|
+
"getElementsByTagNameNS",
|
|
126
|
+
"hasFocus",
|
|
127
|
+
"prepend",
|
|
128
|
+
],
|
|
129
|
+
// 需要从主应用document中获取的事件
|
|
130
|
+
documentEvents: [
|
|
131
|
+
"onpointerlockchange",
|
|
132
|
+
"onpointerlockerror",
|
|
133
|
+
"onbeforecopy",
|
|
134
|
+
"onbeforecut",
|
|
135
|
+
"onbeforepaste",
|
|
136
|
+
"onfreeze",
|
|
137
|
+
"onresume",
|
|
138
|
+
"onsearch",
|
|
139
|
+
"onfullscreenchange",
|
|
140
|
+
"onfullscreenerror",
|
|
141
|
+
"onsecuritypolicyviolation",
|
|
142
|
+
"onvisibilitychange",
|
|
143
|
+
],
|
|
144
|
+
// 无需修改原型的属性
|
|
145
|
+
ownerProperties: ["head", "body"],
|
|
146
|
+
};
|
|
147
|
+
// 需要挂载到子应用iframe document上的事件
|
|
148
|
+
export const appDocumentAddEventListenerEvents = ["DOMContentLoaded", "readystatechange"];
|
|
149
|
+
export const appDocumentOnEvents = ["onreadystatechange"];
|
|
150
|
+
// 需要挂载到主应用document上的事件
|
|
151
|
+
export const mainDocumentAddEventListenerEvents = [
|
|
152
|
+
"fullscreenchange",
|
|
153
|
+
"fullscreenerror",
|
|
154
|
+
"selectionchange",
|
|
155
|
+
"visibilitychange",
|
|
156
|
+
"wheel",
|
|
157
|
+
"keydown",
|
|
158
|
+
"keypress",
|
|
159
|
+
"keyup",
|
|
160
|
+
];
|
|
161
|
+
// 需要同时挂载到主应用document和shadow上的事件(互斥)
|
|
162
|
+
export const mainAndAppAddEventListenerEvents = ["gotpointercapture", "lostpointercapture"];
|
|
163
|
+
// 子应用window监听需要挂载到iframe沙箱上的事件
|
|
164
|
+
export const appWindowAddEventListenerEvents = [
|
|
165
|
+
"hashchange",
|
|
166
|
+
"popstate",
|
|
167
|
+
"DOMContentLoaded",
|
|
168
|
+
"load",
|
|
169
|
+
"beforeunload",
|
|
170
|
+
"unload",
|
|
171
|
+
"message",
|
|
172
|
+
"error",
|
|
173
|
+
"unhandledrejection",
|
|
174
|
+
];
|
|
175
|
+
// 子应用window.onXXX需要挂载到iframe沙箱上的事件
|
|
176
|
+
export const appWindowOnEvent = ["onload", "onbeforeunload", "onunload", "onerror", "onunhandledrejection"];
|
|
177
|
+
// 相对路径问题元素的tag和attr的map
|
|
178
|
+
export const relativeElementTagAttrMap = {
|
|
179
|
+
IMG: "src",
|
|
180
|
+
A: "href",
|
|
181
|
+
SOURCE: "src",
|
|
182
|
+
};
|
|
183
|
+
// 需要单独处理的window属性
|
|
184
|
+
export const windowProxyProperties = ["getComputedStyle", "visualViewport", "matchMedia", "DOMParser"];
|
|
185
|
+
// window白名单
|
|
186
|
+
export const windowRegWhiteList = [
|
|
187
|
+
/animationFrame$/i,
|
|
188
|
+
/resizeObserver$|mutationObserver$|intersectionObserver$/i,
|
|
189
|
+
/height$|width$|left$/i,
|
|
190
|
+
/^screen/i,
|
|
191
|
+
/CSSStyleSheet$/i,
|
|
192
|
+
/X$|Y$/,
|
|
193
|
+
];
|
|
194
|
+
// 保存原型方法
|
|
195
|
+
// 子应用的Document.prototype已经被改写了
|
|
196
|
+
export const rawElementAppendChild = HTMLElement.prototype.appendChild;
|
|
197
|
+
export const rawElementRemoveChild = HTMLElement.prototype.removeChild;
|
|
198
|
+
export const rawElementContains = HTMLElement.prototype.contains;
|
|
199
|
+
export const rawHeadInsertBefore = HTMLHeadElement.prototype.insertBefore;
|
|
200
|
+
export const rawBodyInsertBefore = HTMLBodyElement.prototype.insertBefore;
|
|
201
|
+
export const rawInsertAdjacentElement = HTMLStyleElement.prototype.insertAdjacentElement;
|
|
202
|
+
export const rawAddEventListener = Node.prototype.addEventListener;
|
|
203
|
+
export const rawRemoveEventListener = Node.prototype.removeEventListener;
|
|
204
|
+
export const rawWindowAddEventListener = window.addEventListener;
|
|
205
|
+
export const rawWindowRemoveEventListener = window.removeEventListener;
|
|
206
|
+
export const rawAppendChild = Node.prototype.appendChild;
|
|
207
|
+
export const rawDocumentQuerySelector = (isPoweredByXpe(window) ? getXpeRawDocumentQuerySelector(window) : undefined) ?? Document.prototype.querySelector;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const XPE_APP_ID = "data-xpe-id";
|
|
2
|
+
export declare const XPE_SCRIPT_ID = "data-xpe-script-id";
|
|
3
|
+
export declare const XPE_DATA_FLAG = "data-xpe-flag";
|
|
4
|
+
export declare const CONTAINER_POSITION_DATA_FLAG = "data-container-position-flag";
|
|
5
|
+
export declare const CONTAINER_OVERFLOW_DATA_FLAG = "data-container-overflow-flag";
|
|
6
|
+
export declare const LOADING_DATA_FLAG = "data-loading-flag";
|
|
7
|
+
export declare const XPE_DATA_ATTACH_CSS_FLAG = "data-xpe-attach-css-flag";
|
|
8
|
+
export declare const XPE_APP_ELEMENT_TAG = "xpe-app";
|
|
9
|
+
export declare const XPE_IFRAME_CLASS = "xpe_iframe";
|
|
10
|
+
export declare const XPE_ALL_EVENT = "_xpe_all_event";
|
|
11
|
+
export declare const XPE_SHADE_STYLE = "position: fixed; z-index: 2147483647; visibility: hidden; inset: 0px; backface-visibility: hidden;";
|
|
12
|
+
export declare const XPE_LOADING_STYLE = "position: absolute; width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; z-index:1;";
|
|
13
|
+
export declare const XPE_LOADING_SVG = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24px\" height=\"30px\" viewBox=\"0 0 24 30\">\n<rect x=\"0\" y=\"13\" width=\"4\" height=\"5\" fill=\"#909090\">\n <animate attributeName=\"height\" attributeType=\"XML\" values=\"5;21;5\" begin=\"0s\" dur=\"0.6s\" repeatCount=\"indefinite\"></animate>\n <animate attributeName=\"y\" attributeType=\"XML\" values=\"13; 5; 13\" begin=\"0s\" dur=\"0.6s\" repeatCount=\"indefinite\"></animate>\n</rect>\n<rect x=\"10\" y=\"13\" width=\"4\" height=\"5\" fill=\"#909090\">\n <animate attributeName=\"height\" attributeType=\"XML\" values=\"5;21;5\" begin=\"0.15s\" dur=\"0.6s\" repeatCount=\"indefinite\"></animate>\n <animate attributeName=\"y\" attributeType=\"XML\" values=\"13; 5; 13\" begin=\"0.15s\" dur=\"0.6s\" repeatCount=\"indefinite\"></animate>\n</rect>\n<rect x=\"20\" y=\"13\" width=\"4\" height=\"5\" fill=\"#909090\">\n <animate attributeName=\"height\" attributeType=\"XML\" values=\"5;21;5\" begin=\"0.3s\" dur=\"0.6s\" repeatCount=\"indefinite\"></animate>\n <animate attributeName=\"y\" attributeType=\"XML\" values=\"13; 5; 13\" begin=\"0.3s\" dur=\"0.6s\" repeatCount=\"indefinite\"></animate>\n</rect>\n</svg>";
|
|
14
|
+
export declare const XPE_TIPS_NO_URL = "url\u53C2\u6570\u4E3A\u7A7A";
|
|
15
|
+
export declare const XPE_TIPS_RELOAD_DISABLED = "\u5B50\u5E94\u7528\u8C03\u7528reload\u65E0\u6CD5\u751F\u6548";
|
|
16
|
+
export declare const XPE_TIPS_STOP_APP = "\u6B64\u62A5\u9519\u53EF\u4EE5\u5FFD\u7565\uFF0Ciframe\u4E3B\u52A8\u4E2D\u65AD\u4E3B\u5E94\u7528\u4EE3\u7801\u5728\u5B50\u5E94\u7528\u8FD0\u884C";
|
|
17
|
+
export declare const XPE_TIPS_STOP_APP_DETAIL: string;
|
|
18
|
+
export declare const XPE_TIPS_NO_SUBJECT = "\u4E8B\u4EF6\u8BA2\u9605\u6570\u91CF\u4E3A\u7A7A";
|
|
19
|
+
export declare const XPE_TIPS_NO_FETCH = "window\u4E0A\u4E0D\u5B58\u5728fetch\u5C5E\u6027\uFF0C\u9700\u8981\u81EA\u884Cpolyfill";
|
|
20
|
+
export declare const XPE_TIPS_NOT_SUPPORTED = "\u5F53\u524D\u6D4F\u89C8\u5668\u4E0D\u652F\u6301 XPE Web Component \u6E32\u67D3\uFF0C\u5B50\u5E94\u7528\u5C06\u91C7\u7528 iframe \u65B9\u5F0F\u6E32\u67D3";
|
|
21
|
+
export declare const XPE_TIPS_SCRIPT_ERROR_REQUESTED = "\u811A\u672C\u8BF7\u6C42\u51FA\u73B0\u9519\u8BEF";
|
|
22
|
+
export declare const XPE_TIPS_CSS_ERROR_REQUESTED = "\u6837\u5F0F\u8BF7\u6C42\u51FA\u73B0\u9519\u8BEF";
|
|
23
|
+
export declare const XPE_TIPS_HTML_ERROR_REQUESTED = "html\u8BF7\u6C42\u51FA\u73B0\u9519\u8BEF";
|
|
24
|
+
export declare const XPE_TIPS_REPEAT_RENDER = "XPE runtime \u77ED\u65F6\u95F4\u91CD\u590D\u6E32\u67D3\u4E86\u4E24\u6B21\uFF0C\u53EF\u80FD\u5B58\u5728\u6027\u80FD\u95EE\u9898\u8BF7\u68C0\u67E5\u4EE3\u7801";
|
|
25
|
+
export declare const XPE_TIPS_NO_SCRIPT = "\u76EE\u6807Script\u5C1A\u672A\u51C6\u5907\u597D\u6216\u5DF2\u7ECF\u88AB\u79FB\u9664";
|
|
26
|
+
export declare const XPE_TIPS_GET_ELEMENT_BY_ID = "\u4E0D\u652F\u6301document.getElementById()\u4F20\u5165\u7279\u6B8A\u5B57\u7B26\uFF0C\u8BF7\u53C2\u8003document.querySelector\u6587\u6863";
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// 私有元素属性
|
|
2
|
+
export const XPE_APP_ID = "data-xpe-id";
|
|
3
|
+
export const XPE_SCRIPT_ID = "data-xpe-script-id";
|
|
4
|
+
export const XPE_DATA_FLAG = "data-xpe-flag";
|
|
5
|
+
export const CONTAINER_POSITION_DATA_FLAG = "data-container-position-flag";
|
|
6
|
+
export const CONTAINER_OVERFLOW_DATA_FLAG = "data-container-overflow-flag";
|
|
7
|
+
export const LOADING_DATA_FLAG = "data-loading-flag";
|
|
8
|
+
export const XPE_DATA_ATTACH_CSS_FLAG = "data-xpe-attach-css-flag";
|
|
9
|
+
export const XPE_APP_ELEMENT_TAG = "xpe-app";
|
|
10
|
+
// 需要使用的某些固定变量
|
|
11
|
+
export const XPE_IFRAME_CLASS = "xpe_iframe";
|
|
12
|
+
export const XPE_ALL_EVENT = "_xpe_all_event";
|
|
13
|
+
export const XPE_SHADE_STYLE = "position: fixed; z-index: 2147483647; visibility: hidden; inset: 0px; backface-visibility: hidden;";
|
|
14
|
+
export const XPE_LOADING_STYLE = "position: absolute; width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; z-index:1;";
|
|
15
|
+
export const XPE_LOADING_SVG = `<svg xmlns="http://www.w3.org/2000/svg" width="24px" height="30px" viewBox="0 0 24 30">
|
|
16
|
+
<rect x="0" y="13" width="4" height="5" fill="#909090">
|
|
17
|
+
<animate attributeName="height" attributeType="XML" values="5;21;5" begin="0s" dur="0.6s" repeatCount="indefinite"></animate>
|
|
18
|
+
<animate attributeName="y" attributeType="XML" values="13; 5; 13" begin="0s" dur="0.6s" repeatCount="indefinite"></animate>
|
|
19
|
+
</rect>
|
|
20
|
+
<rect x="10" y="13" width="4" height="5" fill="#909090">
|
|
21
|
+
<animate attributeName="height" attributeType="XML" values="5;21;5" begin="0.15s" dur="0.6s" repeatCount="indefinite"></animate>
|
|
22
|
+
<animate attributeName="y" attributeType="XML" values="13; 5; 13" begin="0.15s" dur="0.6s" repeatCount="indefinite"></animate>
|
|
23
|
+
</rect>
|
|
24
|
+
<rect x="20" y="13" width="4" height="5" fill="#909090">
|
|
25
|
+
<animate attributeName="height" attributeType="XML" values="5;21;5" begin="0.3s" dur="0.6s" repeatCount="indefinite"></animate>
|
|
26
|
+
<animate attributeName="y" attributeType="XML" values="13; 5; 13" begin="0.3s" dur="0.6s" repeatCount="indefinite"></animate>
|
|
27
|
+
</rect>
|
|
28
|
+
</svg>`;
|
|
29
|
+
// 提醒类
|
|
30
|
+
export const XPE_TIPS_NO_URL = "url参数为空";
|
|
31
|
+
export const XPE_TIPS_RELOAD_DISABLED = "子应用调用reload无法生效";
|
|
32
|
+
export const XPE_TIPS_STOP_APP = "此报错可以忽略,iframe主动中断主应用代码在子应用运行";
|
|
33
|
+
export const XPE_TIPS_STOP_APP_DETAIL = XPE_TIPS_STOP_APP + ",XPE runtime 已主动拦截该执行路径";
|
|
34
|
+
export const XPE_TIPS_NO_SUBJECT = "事件订阅数量为空";
|
|
35
|
+
export const XPE_TIPS_NO_FETCH = "window上不存在fetch属性,需要自行polyfill";
|
|
36
|
+
export const XPE_TIPS_NOT_SUPPORTED = "当前浏览器不支持 XPE Web Component 渲染,子应用将采用 iframe 方式渲染";
|
|
37
|
+
export const XPE_TIPS_SCRIPT_ERROR_REQUESTED = "脚本请求出现错误";
|
|
38
|
+
export const XPE_TIPS_CSS_ERROR_REQUESTED = "样式请求出现错误";
|
|
39
|
+
export const XPE_TIPS_HTML_ERROR_REQUESTED = "html请求出现错误";
|
|
40
|
+
export const XPE_TIPS_REPEAT_RENDER = "XPE runtime 短时间重复渲染了两次,可能存在性能问题请检查代码";
|
|
41
|
+
export const XPE_TIPS_NO_SCRIPT = "目标Script尚未准备好或已经被移除";
|
|
42
|
+
export const XPE_TIPS_GET_ELEMENT_BY_ID = "不支持document.getElementById()传入特殊字符,请参考document.querySelector文档";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import RuntimeSandbox from "./sandbox.js";
|
|
2
|
+
/**
|
|
3
|
+
* 劫持处理样式元素的属性
|
|
4
|
+
* @internal 仅出于可测性导出,外部不应直接调用
|
|
5
|
+
*/
|
|
6
|
+
export declare function patchStylesheetElement(stylesheetElement: HTMLStyleElement & {
|
|
7
|
+
_hasPatchStyle?: boolean;
|
|
8
|
+
}, cssLoader: (code: string, url: string, base: string) => string, sandbox: RuntimeSandbox, curUrl: string): void;
|
|
9
|
+
/**
|
|
10
|
+
* 处理「先 appendChild(link) 后 setAttribute('href')」的延迟 href 场景。
|
|
11
|
+
*
|
|
12
|
+
* 通过 MutationObserver 监听 href 属性赋值,命中后走传入的 loadStyleSheet 完成加载。
|
|
13
|
+
* 生命周期管理(避免内存泄漏):
|
|
14
|
+
* 1. 命中 / 超时 / 子应用已销毁 时立即 disconnect 并从 sandbox 出队;
|
|
15
|
+
* 2. observer 登记到 sandbox.deferredStyleObservers,destroy 阶段统一兜底 disconnect;
|
|
16
|
+
* 3. 回调内通过 sandboxId 动态获取 sandbox,不捕获 sandbox/iframe,子应用销毁后闭包不再 pin 上下文。
|
|
17
|
+
*/
|
|
18
|
+
export declare function deferStyleSheetByHref(opts: {
|
|
19
|
+
element: HTMLLinkElement;
|
|
20
|
+
sandboxId: string;
|
|
21
|
+
iframeWindow: Window;
|
|
22
|
+
loadStyleSheet: (href: string, element: HTMLLinkElement) => void;
|
|
23
|
+
}): void;
|
|
24
|
+
/**
|
|
25
|
+
* 清空head和body的绑定的事件
|
|
26
|
+
*/
|
|
27
|
+
export declare function removeEventListener(element: HTMLHeadElement | HTMLBodyElement): void;
|
|
28
|
+
/**
|
|
29
|
+
* patch head and body in render
|
|
30
|
+
* intercept appendChild and insertBefore
|
|
31
|
+
*/
|
|
32
|
+
export declare function patchRenderEffect(render: ShadowRoot | Document, id: string, degrade: boolean): void;
|