@epxing/core 5.3.0-beta.2 → 5.3.0-beta.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.
- package/API.md +26 -25
- package/README.md +3 -1
- package/dist/.cache/route-chart-release/frontend/frame/public/js/ecStat.min.js +4 -0
- package/dist/.cache/route-chart-release/frontend/frame/public/js/echarts-wordcloud.min.js +4 -0
- package/dist/.cache/route-chart-release/frontend/frame/public/js/echarts.min.js +4 -0
- package/dist/_virtual/_plugin-vue_export-helper.js +10 -0
- package/dist/_virtual/jsencrypt.min.js +1 -1
- package/dist/assets/ecStat.min-BrTYPOXX.js +1 -0
- package/dist/assets/echarts-wordcloud.min-nWR4Hzny.js +3 -0
- package/dist/assets/echarts.min-DROS9E5X.js +45 -0
- package/dist/assets/role_select-DTqRlFNz.webp +0 -0
- package/dist/{_vendor → frontend/frame/_vendor}/.pnpm/jsencrypt@3.5.4/_vendor/jsencrypt/bin/jsencrypt.min.js +1 -1
- package/dist/src/RootApp.js +54 -0
- package/dist/src/api/createHttp.js +6 -0
- package/dist/src/app-ui-settings.js +49 -0
- package/dist/src/axios.js +10 -15
- package/dist/src/chart-runtime-assets.js +9 -0
- package/dist/src/create-app.js +3 -6
- package/dist/src/index.js +2 -0
- package/dist/src/loadComponent.js +2 -2
- package/dist/src/menu-route.js +11 -0
- package/dist/src/mixins/component.js +3 -0
- package/dist/src/navigation-context.js +47 -0
- package/dist/src/navigation.js +43 -12
- package/dist/src/package-install.js +3 -2
- package/dist/src/plugins/element-plus.js +8 -8
- package/dist/src/public-api.js +4 -2
- package/dist/src/route-components.js +9 -0
- package/dist/src/router/config.js +7 -8
- package/dist/src/runtime-services.js +1 -1
- package/dist/src/runtime-utils/meta.js +3 -0
- package/dist/src/runtime-utils/pdf.viewer.js +31 -15
- package/dist/src/runtime-utils/util.js +29 -5
- package/dist/src/shared-packages.js +1 -3
- package/dist/src/store/modules/list.js +25 -3
- package/dist/src/store/modules/meta.js +49 -7
- package/dist/src/style-presets.js +4 -4
- package/dist/src/ui-settings.js +90 -18
- package/dist/src/views/App.js +48 -0
- package/dist/src/views/AppRoleSelect.js +233 -0
- package/dist/src/views/Error.js +210 -0
- package/dist/src/views/Module.js +173 -0
- package/dist/style.css +251 -0
- package/package.json +4 -4
- package/src/RootApp.vue +75 -0
- package/src/api/createHttp.js +7 -0
- package/src/api/index.js +47 -47
- package/src/app-ui-settings.js +31 -0
- package/src/axios.js +311 -318
- package/src/chart-runtime-assets.js +7 -0
- package/src/create-app.js +3 -7
- package/src/index.js +28 -28
- package/src/install.js +157 -157
- package/src/loadComponent.js +187 -187
- package/src/loadLibrary.js +99 -99
- package/src/menu-route.js +12 -1
- package/src/mixins/component.js +1464 -1461
- package/src/navigation-context.js +49 -0
- package/src/navigation.js +208 -176
- package/src/package-install.js +2 -1
- package/src/plugins/element-plus.js +302 -302
- package/src/plugins/frame.js +178 -178
- package/src/public-api.js +1 -0
- package/src/route-components.js +7 -0
- package/src/router/config.js +861 -864
- package/src/router/public.js +1 -1
- package/src/runtime-services.js +1 -1
- package/src/runtime-utils/fieldFactory.js +179 -179
- package/src/runtime-utils/meta.js +399 -378
- package/src/runtime-utils/pdf.viewer.js +672 -644
- package/src/runtime-utils/util.js +1357 -1330
- package/src/shared-packages.js +1 -3
- package/src/store/modules/config.js +351 -351
- package/src/store/modules/list.js +30 -3
- package/src/store/modules/locale.js +236 -236
- package/src/store/modules/meta.js +314 -265
- package/src/style-presets.js +4 -4
- package/src/ui-settings.js +84 -23
- package/src/views/App.vue +53 -0
- package/src/views/AppRoleSelect.vue +334 -0
- package/src/views/Error.vue +63 -0
- package/src/views/Module.vue +210 -0
- package/src/xss.js +26 -26
- package/types/app.d.ts +10 -10
- package/types/axios.d.ts +1 -1
- package/types/component-mixin.d.ts +1 -1
- package/types/field-factory.d.ts +1 -1
- package/types/global-mixin.d.ts +1 -1
- package/types/http.d.ts +1 -1
- package/types/index.d.ts +3 -0
- package/types/meta.d.ts +1 -1
- package/types/navigation.d.ts +21 -21
- package/types/pdf-viewer.d.ts +1 -1
- package/types/runtime.d.ts +13 -13
- package/types/store.d.ts +1 -1
- package/types/util.d.ts +2 -2
- /package/dist/{build → .cache/route-chart-release/frontend/frame/build}/stubs/empty-components.js +0 -0
- /package/dist/{src → .cache/route-chart-release/frontend/frame/src}/element-icons.names.js +0 -0
- /package/dist/{src → .cache/route-chart-release/frontend/frame/src}/element-plus.lazy.js +0 -0
- /package/dist/{_vendor → frontend/frame/_vendor}/.pnpm/element-plus@2.14.3_vue@3.5.39_typescript@5.9.3_/_vendor/element-plus/dist/locale/en.js +0 -0
- /package/dist/{_vendor → frontend/frame/_vendor}/.pnpm/element-plus@2.14.3_vue@3.5.39_typescript@5.9.3_/_vendor/element-plus/dist/locale/zh-cn.js +0 -0
package/src/plugins/frame.js
CHANGED
|
@@ -1,178 +1,178 @@
|
|
|
1
|
-
import { publishSharedPackage } from '../shared-packages'
|
|
2
|
-
import * as Vue from 'vue'
|
|
3
|
-
import vuex from 'vuex'
|
|
4
|
-
import router from '@epxing/core/src/router'
|
|
5
|
-
import http from '@epxing/core/src/api'
|
|
6
|
-
import { util, axios } from '@epxing/utils/src'
|
|
7
|
-
import mixins from '@epxing/core/src/mixins'
|
|
8
|
-
import { registerLazyLibrary } from '@epxing/core/src/lazy-library'
|
|
9
|
-
import { isEmpty, isObject, isNil, cloneDeep, isEqual, isMatch, debounce, throttle, assignWith, findLastIndex } from 'lodash-es'
|
|
10
|
-
import cookie from '@epxing/utils/src/storage' // Web Storage 兼容层(js-cookie 同形 API,不读写浏览器 Cookie)
|
|
11
|
-
// window.frame.moment(冻结 ABI)现在是基于 dayjs 的兼容层。远程库拿到的用法面不变,
|
|
12
|
-
// 覆盖不到的 API 会抛自解释错误而不是静默 undefined。
|
|
13
|
-
import moment from '@epxing/utils/src/moment-compat'
|
|
14
|
-
const lodash = {
|
|
15
|
-
isEmpty,
|
|
16
|
-
isObject,
|
|
17
|
-
isNil,
|
|
18
|
-
isEqual,
|
|
19
|
-
isMatch,
|
|
20
|
-
cloneDeep,
|
|
21
|
-
debounce,
|
|
22
|
-
throttle,
|
|
23
|
-
assignWith,
|
|
24
|
-
findLastIndex
|
|
25
|
-
}
|
|
26
|
-
if (!window.componentLibrary) window.componentLibrary = {}
|
|
27
|
-
// T30b:popup 已 app 化,改在 installFrame 里 app.use(PopupInstall)(不再 module-level Vue.use)
|
|
28
|
-
// T33(关 compat):原为 **module-level** —— 在 import 期就把 113 个组件注册到
|
|
29
|
-
// compat 的全局 Vue 上。Vue3 没有全局注册,且此刻 app 还没建(setApp 在 installFrame 里才跑)
|
|
30
|
-
// → 改成**导出安装函数**,由 installFrame(app) 显式调用。
|
|
31
|
-
//
|
|
32
|
-
// 注:Frame.Vue 是给外部消费方(window.frame.Vue)的。Vue3 无 default 导出 →
|
|
33
|
-
// 换成整个 vue 模块命名空间,消费方拿到 { createApp, h, ref, ... }。
|
|
34
|
-
//
|
|
35
|
-
// 按需拆包(epx-frame/core 等六入口)后,本模块只装**工具面**——组件清单不再静态聚合进 core:
|
|
36
|
-
// 聚合壳(src/component.js)与各按需入口在 import 期调 attachFrameComponents() 把各自的组件
|
|
37
|
-
// 表挂进 Frame。聚合流(平台 main.js / createApp / epx-frame ".")语义不变:component.js 的
|
|
38
|
-
// module init 就 attach,晚于工具面、先于任何远程库加载。
|
|
39
|
-
const Frame = { axios, http, util, lodash, moment, cookie, mixins, router, Vue, vuex }
|
|
40
|
-
// window.frame 是远程模块的【冻结 ABI】(ADR-010):remote bundle / FM_SYSTEM_WEBPACK 远程库
|
|
41
|
-
// 的 vue/vuex/http/util 等运行时依赖全从这里取。契约面与兼容规则见 docs/WINDOW-FRAME-ABI.md。
|
|
42
|
-
// __ABI__ 供远程模块启动时校验(不匹配可提示而非静默错乱);破坏性变更必须 +1 并走迁移。
|
|
43
|
-
Frame.__ABI__ = 1
|
|
44
|
-
window.frame = Frame
|
|
45
|
-
window['epx-frame'] = Frame
|
|
46
|
-
// rollup/vite 把外置的 'epx-frame' 猜成驼峰全局 epxFrame(连字符包名规则)——补同体别名,
|
|
47
|
-
// 让 Vite 形态的产品远程库(PROJECT-GUIDE.md)免配 globals 直接落位。与上面两个键同一对象。
|
|
48
|
-
window.epxFrame = Frame
|
|
49
|
-
|
|
50
|
-
// 某个键当前是不是「懒加载自解释 shim」(见下方 attachFrameLazyStubs)。
|
|
51
|
-
// Frame 上除了 shim 不会有别的 accessor 属性,故判有没有 getter 即可。
|
|
52
|
-
function isLazyStub (key) {
|
|
53
|
-
const d = Object.getOwnPropertyDescriptor(Frame, key)
|
|
54
|
-
return !!(d && d.get)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// 读某个键的**真身**,不触发 shim 的 getter(不想让内部逻辑自己打出那条给使用者看的 console.error)。
|
|
58
|
-
// shim 表示「还没加载」,所以返回 undefined。
|
|
59
|
-
function peek (key) {
|
|
60
|
-
const d = Object.getOwnPropertyDescriptor(Frame, key)
|
|
61
|
-
if (!d || d.get) return undefined
|
|
62
|
-
return d.value
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// 组件表挂载(聚合壳/按需入口在 import 期调用):已有键不覆盖——工具面与 __ABI__ 优先,
|
|
66
|
-
// 聚合表内部的覆盖序(components 先、工具后)由此保持不变。
|
|
67
|
-
// 例外:懒加载 shim 只是个占位,不算「已有」——整表回退(frame.lazy.js 的 loadFull())会
|
|
68
|
-
// import 完整的 src/component.js,它在 module init 再 attach 一次全部真身,必须允许它把
|
|
69
|
-
// shim 换成真身,否则「最坏 = 改造前行为」这条兜底会被 shim 自己破坏。
|
|
70
|
-
export function attachFrameComponents (map) {
|
|
71
|
-
publishSharedPackage('@epxing/
|
|
72
|
-
for (const key in map) {
|
|
73
|
-
if (!(key in Frame) || isLazyStub(key)) Frame[key] = map[key]
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// —— 转懒导出名的自解释 shim ——
|
|
78
|
-
// 组件转为按需加载后,window.frame.<Name> 从「首屏真身」变成 undefined。远程模块若仍写
|
|
79
|
-
// `export default { extends: window.frame.Chart }`,得到的只是一句莫名其妙的
|
|
80
|
-
// `extends: undefined` 报错,看不出跟按需加载有关。给这些名字装个 accessor:读到就打一条
|
|
81
|
-
// 带修复指引的 console.error 并返回 undefined。
|
|
82
|
-
//
|
|
83
|
-
// 两个必须项:
|
|
84
|
-
// ① configurable: true —— 否则下面 setter 里的 defineProperty(换回数据属性)会抛,
|
|
85
|
-
// loadComponent() 写回真身的路径直接断掉。
|
|
86
|
-
// ② 必须同时给 setter —— 本文件是 ESM(严格模式),对「只有 getter」的属性做
|
|
87
|
-
// Frame[name] = comp 赋值会 TypeError,而 loadComponent()/attachFrameComponents()
|
|
88
|
-
// 写回真身走的正是普通赋值。setter 把自己换成普通数据属性,之后一切如常。
|
|
89
|
-
// 懒加载组件名单(壳层 component.lazy.js 传入)。remote-deps 的「无清单兜底」要用它,
|
|
90
|
-
// 但那边不能 import 本文件(会成环 frame→router→router/config→loadLibrary→remote-deps),
|
|
91
|
-
// 所以经下面的 Frame.ensureAll() 走 window.frame 暴露出去。
|
|
92
|
-
let _lazyNames = []
|
|
93
|
-
|
|
94
|
-
export function attachFrameLazyStubs (names) {
|
|
95
|
-
// 合并而非覆盖:目前只有一个调用点,但下面的 for 循环本身是幂等累加的,
|
|
96
|
-
// 若未来第二个入口再调一次,覆盖会让 ensureAll()/ensureLazy() 静默只剩最后一批。
|
|
97
|
-
_lazyNames = [...new Set([..._lazyNames, ...(names || [])])]
|
|
98
|
-
for (const name of names || []) {
|
|
99
|
-
if (name in Frame) continue // 已是真身(白名单内/已加载过/工具面同名)就别去挡
|
|
100
|
-
Object.defineProperty(Frame, name, {
|
|
101
|
-
configurable: true,
|
|
102
|
-
enumerable: false, // 不进 Object.keys(window.frame):它还不是能用的东西,别看着像"已经有了"
|
|
103
|
-
get () {
|
|
104
|
-
console.error(`[frame] ${name} 已转为按需加载,请先 await window.frame.ensure(['${name}'])`)
|
|
105
|
-
return undefined
|
|
106
|
-
},
|
|
107
|
-
set (value) {
|
|
108
|
-
Object.defineProperty(Frame, name, { value, writable: true, enumerable: true, configurable: true })
|
|
109
|
-
}
|
|
110
|
-
})
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// 通用组件懒加载 resolver 注入点(依赖方向:core 不 import src/,由壳层 component.lazy.js 注入)。
|
|
115
|
-
let _lazyResolver = null
|
|
116
|
-
export function attachFrameLazyResolver (fn) {
|
|
117
|
-
_lazyResolver = fn
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// The designer group is loaded by registration name when a platform page opens.
|
|
121
|
-
// Old remote products can instead synchronously extend the named Frame export
|
|
122
|
-
// while their bundle is evaluated. Make that export available to the remote
|
|
123
|
-
// dependency preloader before it evaluates the bundle.
|
|
124
|
-
const remoteOptionalExports = {
|
|
125
|
-
PageDesigner: () => import('@platform-optional/designer-lazy').then(m => m.default?.PageDesigner)
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// —— ABI 新增键(兼容规则:新增键随时允许、不升 __ABI__)——
|
|
129
|
-
// 远程模块把需要 extends 的组件先 await 出来,之后 window.frame.<Name> 同步可用:
|
|
130
|
-
// await window.frame.ensure(['Chart'])
|
|
131
|
-
// export default { extends: window.frame.Chart }
|
|
132
|
-
// 读 Frame[name] 一律走 peek():直接读会触发懒 shim 的 getter,把那条「请先 ensure()」的
|
|
133
|
-
// 提示打给正在**正确地**调用 ensure() 的人,属噪音。
|
|
134
|
-
Frame.loadComponent = function loadComponent (name) {
|
|
135
|
-
const current = peek(name)
|
|
136
|
-
if (current && !current.__asyncLoader) return Promise.resolve(current)
|
|
137
|
-
if (remoteOptionalExports[name]) {
|
|
138
|
-
return remoteOptionalExports[name]().then(comp => {
|
|
139
|
-
if (comp) Frame[name] = comp
|
|
140
|
-
return comp || null
|
|
141
|
-
})
|
|
142
|
-
}
|
|
143
|
-
if (!_lazyResolver) return Promise.resolve(current)
|
|
144
|
-
return Promise.resolve(_lazyResolver(name)).then(comp => {
|
|
145
|
-
if (comp) Frame[name] = comp // 写回 ABI(命中 shim 的 setter → 换成数据属性):此后同步访问持续有效
|
|
146
|
-
return comp || peek(name)
|
|
147
|
-
})
|
|
148
|
-
}
|
|
149
|
-
Frame.ensure = function ensure (names) {
|
|
150
|
-
const list = Array.isArray(names) ? names : [names]
|
|
151
|
-
return Promise.all(list.map(n => Frame.loadComponent(n))).then(() => undefined)
|
|
152
|
-
}
|
|
153
|
-
// 备好全部懒加载组件。供 remote-deps 在「远程包没有依赖清单」时兜底用(正确优先于流量)。
|
|
154
|
-
Frame.ensureAll = function ensureAll () {
|
|
155
|
-
return Frame.ensure([..._lazyNames, ...Object.keys(remoteOptionalExports)])
|
|
156
|
-
}
|
|
157
|
-
// 只 ensure names 里「确实是懒加载」的那些。remote-deps 的精确路径用它——
|
|
158
|
-
// 清单里可能含 epx-frame/utils 等**不在 Frame 上**的导出名(FieldFactory/Config/Meta…),
|
|
159
|
-
// 直接喂给 ensure() 会走 loadComponent → peek() 落空 → 回退整表,把整张聚合组件表拉下来,
|
|
160
|
-
// 反而比不做清单更糟(详见评审 Important-1)。
|
|
161
|
-
Frame.ensureLazy = function ensureLazy (names) {
|
|
162
|
-
const want = new Set(Array.isArray(names) ? names : [names])
|
|
163
|
-
return Frame.ensure([..._lazyNames, ...Object.keys(remoteOptionalExports)].filter(n => want.has(n)))
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// —— ABI 新增键(同上:新增键随时允许、不升 __ABI__)——
|
|
167
|
-
// 产品/项目远程库的「清单 + 组件按需加载」形态:入口壳求值时把纯数据清单交过来,
|
|
168
|
-
// 平台建 wrapper、发起 import()、统一预取与降级。详见 packages/core/src/lazy-library.js。
|
|
169
|
-
Frame.registerLazyLibrary = function (pkgName, opts) {
|
|
170
|
-
return registerLazyLibrary(pkgName, opts)
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
export default Frame
|
|
174
|
-
export function installFrameComponents (app) {
|
|
175
|
-
// Frame.install 来自 src/component.js 的 attach(聚合流);纯按需流没有它——
|
|
176
|
-
// 消费方自行 app.use(epx-frame/components 等入口),这里安全跳过。
|
|
177
|
-
if (Frame.install) app.use(Frame)
|
|
178
|
-
}
|
|
1
|
+
import { publishSharedPackage } from '../shared-packages'
|
|
2
|
+
import * as Vue from 'vue'
|
|
3
|
+
import vuex from 'vuex'
|
|
4
|
+
import router from '@epxing/core/src/router'
|
|
5
|
+
import http from '@epxing/core/src/api'
|
|
6
|
+
import { util, axios } from '@epxing/utils/src'
|
|
7
|
+
import mixins from '@epxing/core/src/mixins'
|
|
8
|
+
import { registerLazyLibrary } from '@epxing/core/src/lazy-library'
|
|
9
|
+
import { isEmpty, isObject, isNil, cloneDeep, isEqual, isMatch, debounce, throttle, assignWith, findLastIndex } from 'lodash-es'
|
|
10
|
+
import cookie from '@epxing/utils/src/storage' // Web Storage 兼容层(js-cookie 同形 API,不读写浏览器 Cookie)
|
|
11
|
+
// window.frame.moment(冻结 ABI)现在是基于 dayjs 的兼容层。远程库拿到的用法面不变,
|
|
12
|
+
// 覆盖不到的 API 会抛自解释错误而不是静默 undefined。
|
|
13
|
+
import moment from '@epxing/utils/src/moment-compat'
|
|
14
|
+
const lodash = {
|
|
15
|
+
isEmpty,
|
|
16
|
+
isObject,
|
|
17
|
+
isNil,
|
|
18
|
+
isEqual,
|
|
19
|
+
isMatch,
|
|
20
|
+
cloneDeep,
|
|
21
|
+
debounce,
|
|
22
|
+
throttle,
|
|
23
|
+
assignWith,
|
|
24
|
+
findLastIndex
|
|
25
|
+
}
|
|
26
|
+
if (!window.componentLibrary) window.componentLibrary = {}
|
|
27
|
+
// T30b:popup 已 app 化,改在 installFrame 里 app.use(PopupInstall)(不再 module-level Vue.use)
|
|
28
|
+
// T33(关 compat):原为 **module-level** —— 在 import 期就把 113 个组件注册到
|
|
29
|
+
// compat 的全局 Vue 上。Vue3 没有全局注册,且此刻 app 还没建(setApp 在 installFrame 里才跑)
|
|
30
|
+
// → 改成**导出安装函数**,由 installFrame(app) 显式调用。
|
|
31
|
+
//
|
|
32
|
+
// 注:Frame.Vue 是给外部消费方(window.frame.Vue)的。Vue3 无 default 导出 →
|
|
33
|
+
// 换成整个 vue 模块命名空间,消费方拿到 { createApp, h, ref, ... }。
|
|
34
|
+
//
|
|
35
|
+
// 按需拆包(epx-frame/core 等六入口)后,本模块只装**工具面**——组件清单不再静态聚合进 core:
|
|
36
|
+
// 聚合壳(src/component.js)与各按需入口在 import 期调 attachFrameComponents() 把各自的组件
|
|
37
|
+
// 表挂进 Frame。聚合流(平台 main.js / createApp / epx-frame ".")语义不变:component.js 的
|
|
38
|
+
// module init 就 attach,晚于工具面、先于任何远程库加载。
|
|
39
|
+
const Frame = { axios, http, util, lodash, moment, cookie, mixins, router, Vue, vuex }
|
|
40
|
+
// window.frame 是远程模块的【冻结 ABI】(ADR-010):remote bundle / FM_SYSTEM_WEBPACK 远程库
|
|
41
|
+
// 的 vue/vuex/http/util 等运行时依赖全从这里取。契约面与兼容规则见 docs/WINDOW-FRAME-ABI.md。
|
|
42
|
+
// __ABI__ 供远程模块启动时校验(不匹配可提示而非静默错乱);破坏性变更必须 +1 并走迁移。
|
|
43
|
+
Frame.__ABI__ = 1
|
|
44
|
+
window.frame = Frame
|
|
45
|
+
window['epx-frame'] = Frame
|
|
46
|
+
// rollup/vite 把外置的 'epx-frame' 猜成驼峰全局 epxFrame(连字符包名规则)——补同体别名,
|
|
47
|
+
// 让 Vite 形态的产品远程库(PROJECT-GUIDE.md)免配 globals 直接落位。与上面两个键同一对象。
|
|
48
|
+
window.epxFrame = Frame
|
|
49
|
+
|
|
50
|
+
// 某个键当前是不是「懒加载自解释 shim」(见下方 attachFrameLazyStubs)。
|
|
51
|
+
// Frame 上除了 shim 不会有别的 accessor 属性,故判有没有 getter 即可。
|
|
52
|
+
function isLazyStub (key) {
|
|
53
|
+
const d = Object.getOwnPropertyDescriptor(Frame, key)
|
|
54
|
+
return !!(d && d.get)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// 读某个键的**真身**,不触发 shim 的 getter(不想让内部逻辑自己打出那条给使用者看的 console.error)。
|
|
58
|
+
// shim 表示「还没加载」,所以返回 undefined。
|
|
59
|
+
function peek (key) {
|
|
60
|
+
const d = Object.getOwnPropertyDescriptor(Frame, key)
|
|
61
|
+
if (!d || d.get) return undefined
|
|
62
|
+
return d.value
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// 组件表挂载(聚合壳/按需入口在 import 期调用):已有键不覆盖——工具面与 __ABI__ 优先,
|
|
66
|
+
// 聚合表内部的覆盖序(components 先、工具后)由此保持不变。
|
|
67
|
+
// 例外:懒加载 shim 只是个占位,不算「已有」——整表回退(frame.lazy.js 的 loadFull())会
|
|
68
|
+
// import 完整的 src/component.js,它在 module init 再 attach 一次全部真身,必须允许它把
|
|
69
|
+
// shim 换成真身,否则「最坏 = 改造前行为」这条兜底会被 shim 自己破坏。
|
|
70
|
+
export function attachFrameComponents (map) {
|
|
71
|
+
publishSharedPackage('@epxing/components', map)
|
|
72
|
+
for (const key in map) {
|
|
73
|
+
if (!(key in Frame) || isLazyStub(key)) Frame[key] = map[key]
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// —— 转懒导出名的自解释 shim ——
|
|
78
|
+
// 组件转为按需加载后,window.frame.<Name> 从「首屏真身」变成 undefined。远程模块若仍写
|
|
79
|
+
// `export default { extends: window.frame.Chart }`,得到的只是一句莫名其妙的
|
|
80
|
+
// `extends: undefined` 报错,看不出跟按需加载有关。给这些名字装个 accessor:读到就打一条
|
|
81
|
+
// 带修复指引的 console.error 并返回 undefined。
|
|
82
|
+
//
|
|
83
|
+
// 两个必须项:
|
|
84
|
+
// ① configurable: true —— 否则下面 setter 里的 defineProperty(换回数据属性)会抛,
|
|
85
|
+
// loadComponent() 写回真身的路径直接断掉。
|
|
86
|
+
// ② 必须同时给 setter —— 本文件是 ESM(严格模式),对「只有 getter」的属性做
|
|
87
|
+
// Frame[name] = comp 赋值会 TypeError,而 loadComponent()/attachFrameComponents()
|
|
88
|
+
// 写回真身走的正是普通赋值。setter 把自己换成普通数据属性,之后一切如常。
|
|
89
|
+
// 懒加载组件名单(壳层 component.lazy.js 传入)。remote-deps 的「无清单兜底」要用它,
|
|
90
|
+
// 但那边不能 import 本文件(会成环 frame→router→router/config→loadLibrary→remote-deps),
|
|
91
|
+
// 所以经下面的 Frame.ensureAll() 走 window.frame 暴露出去。
|
|
92
|
+
let _lazyNames = []
|
|
93
|
+
|
|
94
|
+
export function attachFrameLazyStubs (names) {
|
|
95
|
+
// 合并而非覆盖:目前只有一个调用点,但下面的 for 循环本身是幂等累加的,
|
|
96
|
+
// 若未来第二个入口再调一次,覆盖会让 ensureAll()/ensureLazy() 静默只剩最后一批。
|
|
97
|
+
_lazyNames = [...new Set([..._lazyNames, ...(names || [])])]
|
|
98
|
+
for (const name of names || []) {
|
|
99
|
+
if (name in Frame) continue // 已是真身(白名单内/已加载过/工具面同名)就别去挡
|
|
100
|
+
Object.defineProperty(Frame, name, {
|
|
101
|
+
configurable: true,
|
|
102
|
+
enumerable: false, // 不进 Object.keys(window.frame):它还不是能用的东西,别看着像"已经有了"
|
|
103
|
+
get () {
|
|
104
|
+
console.error(`[frame] ${name} 已转为按需加载,请先 await window.frame.ensure(['${name}'])`)
|
|
105
|
+
return undefined
|
|
106
|
+
},
|
|
107
|
+
set (value) {
|
|
108
|
+
Object.defineProperty(Frame, name, { value, writable: true, enumerable: true, configurable: true })
|
|
109
|
+
}
|
|
110
|
+
})
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// 通用组件懒加载 resolver 注入点(依赖方向:core 不 import src/,由壳层 component.lazy.js 注入)。
|
|
115
|
+
let _lazyResolver = null
|
|
116
|
+
export function attachFrameLazyResolver (fn) {
|
|
117
|
+
_lazyResolver = fn
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// The designer group is loaded by registration name when a platform page opens.
|
|
121
|
+
// Old remote products can instead synchronously extend the named Frame export
|
|
122
|
+
// while their bundle is evaluated. Make that export available to the remote
|
|
123
|
+
// dependency preloader before it evaluates the bundle.
|
|
124
|
+
const remoteOptionalExports = {
|
|
125
|
+
PageDesigner: () => import('@platform-optional/designer-lazy').then(m => m.default?.PageDesigner)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// —— ABI 新增键(兼容规则:新增键随时允许、不升 __ABI__)——
|
|
129
|
+
// 远程模块把需要 extends 的组件先 await 出来,之后 window.frame.<Name> 同步可用:
|
|
130
|
+
// await window.frame.ensure(['Chart'])
|
|
131
|
+
// export default { extends: window.frame.Chart }
|
|
132
|
+
// 读 Frame[name] 一律走 peek():直接读会触发懒 shim 的 getter,把那条「请先 ensure()」的
|
|
133
|
+
// 提示打给正在**正确地**调用 ensure() 的人,属噪音。
|
|
134
|
+
Frame.loadComponent = function loadComponent (name) {
|
|
135
|
+
const current = peek(name)
|
|
136
|
+
if (current && !current.__asyncLoader) return Promise.resolve(current)
|
|
137
|
+
if (remoteOptionalExports[name]) {
|
|
138
|
+
return remoteOptionalExports[name]().then(comp => {
|
|
139
|
+
if (comp) Frame[name] = comp
|
|
140
|
+
return comp || null
|
|
141
|
+
})
|
|
142
|
+
}
|
|
143
|
+
if (!_lazyResolver) return Promise.resolve(current)
|
|
144
|
+
return Promise.resolve(_lazyResolver(name)).then(comp => {
|
|
145
|
+
if (comp) Frame[name] = comp // 写回 ABI(命中 shim 的 setter → 换成数据属性):此后同步访问持续有效
|
|
146
|
+
return comp || peek(name)
|
|
147
|
+
})
|
|
148
|
+
}
|
|
149
|
+
Frame.ensure = function ensure (names) {
|
|
150
|
+
const list = Array.isArray(names) ? names : [names]
|
|
151
|
+
return Promise.all(list.map(n => Frame.loadComponent(n))).then(() => undefined)
|
|
152
|
+
}
|
|
153
|
+
// 备好全部懒加载组件。供 remote-deps 在「远程包没有依赖清单」时兜底用(正确优先于流量)。
|
|
154
|
+
Frame.ensureAll = function ensureAll () {
|
|
155
|
+
return Frame.ensure([..._lazyNames, ...Object.keys(remoteOptionalExports)])
|
|
156
|
+
}
|
|
157
|
+
// 只 ensure names 里「确实是懒加载」的那些。remote-deps 的精确路径用它——
|
|
158
|
+
// 清单里可能含 epx-frame/utils 等**不在 Frame 上**的导出名(FieldFactory/Config/Meta…),
|
|
159
|
+
// 直接喂给 ensure() 会走 loadComponent → peek() 落空 → 回退整表,把整张聚合组件表拉下来,
|
|
160
|
+
// 反而比不做清单更糟(详见评审 Important-1)。
|
|
161
|
+
Frame.ensureLazy = function ensureLazy (names) {
|
|
162
|
+
const want = new Set(Array.isArray(names) ? names : [names])
|
|
163
|
+
return Frame.ensure([..._lazyNames, ...Object.keys(remoteOptionalExports)].filter(n => want.has(n)))
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// —— ABI 新增键(同上:新增键随时允许、不升 __ABI__)——
|
|
167
|
+
// 产品/项目远程库的「清单 + 组件按需加载」形态:入口壳求值时把纯数据清单交过来,
|
|
168
|
+
// 平台建 wrapper、发起 import()、统一预取与降级。详见 packages/core/src/lazy-library.js。
|
|
169
|
+
Frame.registerLazyLibrary = function (pkgName, opts) {
|
|
170
|
+
return registerLazyLibrary(pkgName, opts)
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export default Frame
|
|
174
|
+
export function installFrameComponents (app) {
|
|
175
|
+
// Frame.install 来自 src/component.js 的 attach(聚合流);纯按需流没有它——
|
|
176
|
+
// 消费方自行 app.use(epx-frame/components 等入口),这里安全跳过。
|
|
177
|
+
if (Frame.install) app.use(Frame)
|
|
178
|
+
}
|
package/src/public-api.js
CHANGED
|
@@ -14,4 +14,5 @@ export { createFrameRouter, routerConfig } from './router/public'
|
|
|
14
14
|
export { createEventBus, getEventBus } from './vue.bus'
|
|
15
15
|
export { getApp, setApp, registerComponent, resolveComponent } from './app'
|
|
16
16
|
export { configureRuntime, registerRouteComponents } from './runtime-services'
|
|
17
|
+
export { default as routeComponents } from './route-components'
|
|
17
18
|
export { nav } from './navigation'
|