soma-kit 0.1.17 → 0.1.19
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/package.json +1 -1
- package/spec/generated/kit-page.schema.json +11 -1
- package/spec/kit-grammar.json +174 -13
- package/spec/kit-grammar.schema.json +4 -0
- package/src/app/component-gate.ts +668 -55
- package/src/app/define-kit-app.ts +75 -6
- package/src/app/index.ts +4 -1
- package/src/app/internal-lab.ts +90 -0
- package/src/app/kit-view-context.ts +44 -2
- package/src/app/server.ts +51 -9
- package/src/biz/compose.ts +66 -0
- package/src/biz/define.ts +38 -1
- package/src/biz/index.ts +1 -0
- package/src/biz/layout-contracts.ts +119 -4
- package/src/biz/link/hub.ts +31 -0
- package/src/biz/master-sub/compile.ts +45 -3
- package/src/biz/master-sub/index.ts +3 -1
- package/src/biz/record-detail/compile.ts +120 -10
- package/src/biz/shared/coordinator.ts +245 -48
- package/src/biz/shared/index.ts +5 -1
- package/src/biz/shared/object-aliases.ts +14 -3
- package/src/biz/shared/overlay-compile.ts +56 -5
- package/src/biz/shared/overlay-shell.ts +5 -2
- package/src/biz/shared/page-form.ts +9 -5
- package/src/biz/shared/page-overlay-host.ts +126 -0
- package/src/biz/shared/page-overlay-names.ts +27 -0
- package/src/biz/shared/runtime-hub.ts +37 -2
- package/src/biz/single-form/compile.ts +60 -5
- package/src/biz/single-form/index.ts +2 -1
- package/src/biz/standard-crud/compile.ts +9 -2
- package/src/biz/types.ts +26 -0
- package/src/cli/kit-cli.ts +1 -0
- package/src/cli/view-writes.ts +130 -3
- package/src/compile/compile-page.ts +49 -4
- package/src/compile/page-pipeline.ts +4 -0
- package/src/compile/parse.ts +14 -0
- package/src/compile/stages.ts +5 -4
- package/src/compile/types.ts +1 -1
- package/src/compile/view-check.ts +49 -17
- package/src/data/comment-thread.ts +78 -18
- package/src/data/navbar.ts +4 -0
- package/src/data/object-form.ts +17 -3
- package/src/data/prompt-dialog.ts +102 -15
- package/src/frames/page-header.ts +11 -2
- package/src/frames/shared.ts +6 -0
- package/src/frames/types.ts +2 -0
- package/src/generated/kit-grammar-runtime.ts +47 -5
- package/src/i18n/kit-text.ts +1 -0
- package/src/object-renderer/request-actions.ts +145 -17
- package/src/object-renderer/types.ts +7 -0
- package/src/shared/dom-attrs-registry.ts +5 -3
- package/src/shared/dom-attrs.ts +2 -0
- package/src/spatial/declared-actions.ts +6 -3
- package/src/spatial/emit.ts +1 -1
- package/src/spatial/expand.ts +7 -2
package/src/biz/types.ts
CHANGED
|
@@ -4,10 +4,12 @@
|
|
|
4
4
|
// 它不是组件层:编译器按 `product.kind` 查 `KIT_BIZ_COMPONENTS`,把页面传入的各对象交给 `compile`,
|
|
5
5
|
// 得到一个 KitFragment(HTML + `_ui.yaml` 片段 + `_event.yaml` 片段 + 候选类 + 诊断),再交页面框装入。
|
|
6
6
|
|
|
7
|
+
import type { SomaComponentDefinition } from 'soma-core';
|
|
7
8
|
import type { ArrangePageEnvelopeSurfaceKind, ArrangePageEnvelopeTier } from 'soma-foundation/arrange';
|
|
8
9
|
import type { KitObject } from '../object-renderer/types';
|
|
9
10
|
import type { KitListLayout } from '../recipes/page-width';
|
|
10
11
|
import type { KitFragment } from '../object-renderer/fragment';
|
|
12
|
+
import type { KitBizLayoutContract } from './layout-contracts';
|
|
11
13
|
|
|
12
14
|
/**
|
|
13
15
|
* 业务组件的声明式版心契约特征(Tier 2:高于 kit.app.yaml 全局默认,低于页面 *.kit.yaml 显式 max_width)。
|
|
@@ -57,6 +59,11 @@ export interface KitOverlayDecl {
|
|
|
57
59
|
* 以当前行打开本浮层——通常是只读详情(view 是 summary)。行上的「查看」之类行动作照常可用。
|
|
58
60
|
*/
|
|
59
61
|
rowClick?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* 浮层里表单草稿的去留(kit-grammar.json#objectLayer.properties.draft):discard(缺省)= 关窗先问、同意后还原;
|
|
64
|
+
* keep = 关窗不问、不还原,再次打开同一浮层沿用草稿,提交成功或显式放弃才清空。只对含表单的窗口有效(其余报 KIT-OVL-005 告警)
|
|
65
|
+
*/
|
|
66
|
+
draft?: 'discard' | 'keep';
|
|
60
67
|
behavior?: KitObject['behavior'];
|
|
61
68
|
view?: KitObject['view'];
|
|
62
69
|
schema?: KitObject['schema'];
|
|
@@ -95,6 +102,12 @@ export interface KitBizContext {
|
|
|
95
102
|
staticComponents: Record<string, { accept: 'single' | 'list'; emits?: readonly string[]; props?: readonly string[]; propTypes?: Readonly<Record<string, string>>; composition?: 'summary' | 'subject' | 'control' | 'note' }>;
|
|
96
103
|
/** 页面语言(`page.locale`,缺省应用 defaultLocale;未声明为空串):业务组件写进产物的内置文案按它取(`kitText(key, params, ctx.locale)`) */
|
|
97
104
|
locale?: string;
|
|
105
|
+
/**
|
|
106
|
+
* 页面声明的路径参数名与查询参数名(page.params / page.query 的键,由 compile-page.ts 带入):
|
|
107
|
+
* 业务组件校验 $page.params.<名> / $page.query.<名> 引用(selectedFrom、modeFrom 等)用;未传 = 不校验
|
|
108
|
+
*/
|
|
109
|
+
readonly pageParams?: readonly string[];
|
|
110
|
+
readonly pageQuery?: readonly string[];
|
|
98
111
|
/** 告警通道(不挡编译、随编译结果的 deprecations 带出):过渡期的新规则先以告警落地,应用改完再升为错误 */
|
|
99
112
|
advise?: (a: { code: string; path: string; message: string; hint: string }) => void;
|
|
100
113
|
/** 界面规则(look)解出的面板标题图标(面板声明名 → { icon, tone? });页面没写规则时不给 */
|
|
@@ -141,5 +154,18 @@ export interface KitBizDefinition {
|
|
|
141
154
|
* 页面模式推导的版心(兼容自定义业务组件旧口;内置组件优先使用声明式 envelope 特征)。
|
|
142
155
|
*/
|
|
143
156
|
pageMaxWidth?: string;
|
|
157
|
+
/**
|
|
158
|
+
* 业务组件私有的协作数据组件(浏览器运行期交互内核,如批注画布、泳道图等):
|
|
159
|
+
* 装配时自动实例化并并入浏览器组件表,但**不**暴露到页面 `*.kit.yaml` 的 `staticComponent` 选用表中。
|
|
160
|
+
*/
|
|
161
|
+
dataComponents?: Readonly<Record<string, SomaComponentDefinition | (() => SomaComponentDefinition)>>;
|
|
162
|
+
/** 业务组件及其私有协作数据组件用到的 Tailwind 候选类(装配时自动合并入应用候选类) */
|
|
163
|
+
candidates?: readonly string[];
|
|
164
|
+
/**
|
|
165
|
+
* 版式契约(只有展开事件读它):声明本组件各角色的对象身份、呈现、排法与产物锚点拼法,页面线据此给出动作落点(不声明时每个动作报 KIT-PAGE-GATE-006)。
|
|
166
|
+
* 内置组件的契约在 layout-contracts.ts 冻结表里;应用组件写这里(用 kitLayoutContract 简写帮手补缺省)。null = 显式不声明(取 FREE)。
|
|
167
|
+
* 定义期按 kitLayoutContractProblems 校验,不合法报 KIT-COMP-007。wrapKitBizComponent 缺省继承 inner 的契约,composeKitBizComponents 单子部件时缺省合成
|
|
168
|
+
*/
|
|
169
|
+
layoutContract?: KitBizLayoutContract | null;
|
|
144
170
|
compile(input: KitBizInput, ctx: KitBizContext): KitFragment;
|
|
145
171
|
}
|
package/src/cli/kit-cli.ts
CHANGED
|
@@ -49,6 +49,7 @@ export const KIT_CLI_USAGE = [
|
|
|
49
49
|
' --score:打印每页质量分(0–100,只度量已知违例)与中位数;--json 里新增 advisories / score 字段',
|
|
50
50
|
' 弃用提示(仍生效但应迁移的旧拼写,如 KIT-LOCALE-002 的 @row.字段)单独成段(--json 为 deprecations),不影响 ok,--strict 时算失败',
|
|
51
51
|
' 页面属性报告(主题流水线):warn 级页面门禁(KIT-PAGE-GATE-006 动作落点、legacy 旁路里的 -900)与 next 下属性写进产物时没落上的计数单独成段(--json 为 pageGates / pageWrites),不影响 ok 与退出码,--strict 也不算',
|
|
52
|
+
' 应用业务组件可在 defineKitBizComponent({ layoutContract: kitLayoutContract({...}) }) 声明版式契约,消除「没有版式契约」类 KIT-PAGE-GATE-006',
|
|
52
53
|
' soma kit explain look <页面文件> [--stage 3|4|5|6]',
|
|
53
54
|
' 按工序(空间布局 / 形状与状态 / 配色落位 / 产物生成)列出该页每个部件属性的生效取值与来源(L1 应用 / L2 页面 / L3 就地),附零命中与遮蔽告警',
|
|
54
55
|
' soma kit explain-layout <页面文件> [--profile ai|human]',
|
package/src/cli/view-writes.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// KIT-VIEW-008 数组成员原地变异(push / splice / sort …)、下标赋值、元素字段赋值、length 赋值——core 不代理数组,不会触发刷新
|
|
5
5
|
// KIT-VIEW-009 把对象成员赋给另一个成员(view.a = view.b)——同一对象挂多路径,刷新错位(state 初值引用同一对象在定义期同码拒绝)
|
|
6
6
|
// KIT-VIEW-012 ctx.http.post / put / patch / delete 或 ctx.http(…) 的 method 字面量非 GET / HEAD——ctx.http 只读(J1)
|
|
7
|
+
// KIT-VIEW-013 ctx.openOverlay / ctx.closeOverlay 的名字不是本页声明的浮层(product.objects.overlays / page.overlays)
|
|
7
8
|
// 判据(变异方法名单、接收者、形状推导、扫描)只在 soma-foundation/view-state 一份(名单真源 soma-design/spec/pipeline/view-state-rules.json),
|
|
8
9
|
// 与类型层(ReadonlyArray)、运行时 dev 层(core 代理抛 CORE-REACTIVE-WRITE)同判据。
|
|
9
10
|
// 局限:词法扫描,不做数据流(经局部变量转手后的写入不识别),详见 scanViewMethodWrites 注释;漏的由类型层与 dev 层兜底。
|
|
@@ -35,6 +36,15 @@ export interface KitPageTargetSummary {
|
|
|
35
36
|
readonly actionsByObject: ReadonlyMap<string, ReadonlySet<string>>;
|
|
36
37
|
/** 整页有多个对象同名的声明名 -> 限定名候选(必须写限定名) */
|
|
37
38
|
readonly ambiguous?: ReadonlyMap<string, readonly string[]>;
|
|
39
|
+
/**
|
|
40
|
+
* 本页声明的浮层名(product.objects.overlays 与 page.overlays;整页唯一的声明名、限定名、运行期名):ctx.openOverlay / closeOverlay 只认这些(KIT-VIEW-013)。
|
|
41
|
+
* 可选:旧调用方手拼的摘要没有它时按「没有浮层」处理
|
|
42
|
+
*/
|
|
43
|
+
readonly overlays?: ReadonlySet<string>;
|
|
44
|
+
/** 浮层声明名在本页存在同名冲突(多个同名浮层或与普通对象同名)时的合法浮层限定名候选 */
|
|
45
|
+
readonly overlayAmbiguous?: ReadonlyMap<string, readonly string[]>;
|
|
46
|
+
/** 本页已声明浮层的展示名列表(优先保留原声明名含 snake_case,有冲突时展示限定名;去重排序) */
|
|
47
|
+
readonly overlayDisplayNames?: readonly string[];
|
|
38
48
|
}
|
|
39
49
|
|
|
40
50
|
const isRec = (v: unknown): v is Record<string, unknown> => v !== null && typeof v === 'object' && !Array.isArray(v);
|
|
@@ -67,15 +77,44 @@ export function extractPageTargetFromParsed(raw: unknown, pageFile: string): Kit
|
|
|
67
77
|
const declared = kitObjectPlansOfRawPage(raw).flatMap((plan) => declaredObjectsOfPlan(plan));
|
|
68
78
|
const countOf = new Map<string, number>();
|
|
69
79
|
for (const o of declared) countOf.set(o.declared, (countOf.get(o.declared) ?? 0) + 1);
|
|
80
|
+
const overlays = new Set<string>();
|
|
81
|
+
const overlayQualifiedByDeclared = new Map<string, string[]>();
|
|
82
|
+
const overlayDisplaySet = new Set<string>();
|
|
70
83
|
for (const o of declared) {
|
|
71
84
|
const ids = actionIdsOf(o.decl);
|
|
72
85
|
const qualified = `${o.pageId}.${o.declared}`;
|
|
73
86
|
register([qualified, o.runtime], ids);
|
|
74
|
-
|
|
87
|
+
const unique = (countOf.get(o.declared) ?? 0) === 1;
|
|
88
|
+
if (unique) register([o.declared], ids);
|
|
75
89
|
else ambiguous.set(o.declared, [...(ambiguous.get(o.declared) ?? []), qualified]);
|
|
90
|
+
if (o.overlay === true) {
|
|
91
|
+
overlays.add(qualified);
|
|
92
|
+
overlays.add(o.runtime);
|
|
93
|
+
if (unique) {
|
|
94
|
+
overlays.add(o.declared);
|
|
95
|
+
overlayDisplaySet.add(o.declared);
|
|
96
|
+
} else {
|
|
97
|
+
overlayDisplaySet.add(qualified);
|
|
98
|
+
}
|
|
99
|
+
overlayQualifiedByDeclared.set(o.declared, [...(overlayQualifiedByDeclared.get(o.declared) ?? []), qualified]);
|
|
100
|
+
}
|
|
76
101
|
}
|
|
77
|
-
|
|
78
|
-
|
|
102
|
+
const overlayAmbiguous = new Map<string, string[]>();
|
|
103
|
+
for (const [name, qList] of overlayQualifiedByDeclared) {
|
|
104
|
+
if ((countOf.get(name) ?? 0) > 1) overlayAmbiguous.set(name, qList);
|
|
105
|
+
}
|
|
106
|
+
const overlayDisplayNames = [...overlayDisplaySet].sort();
|
|
107
|
+
|
|
108
|
+
return {
|
|
109
|
+
viewName,
|
|
110
|
+
pageFile,
|
|
111
|
+
objects,
|
|
112
|
+
actionsByObject,
|
|
113
|
+
...(ambiguous.size > 0 ? { ambiguous } : {}),
|
|
114
|
+
...(overlays.size > 0 ? { overlays } : {}),
|
|
115
|
+
...(overlayAmbiguous.size > 0 ? { overlayAmbiguous } : {}),
|
|
116
|
+
...(overlayDisplayNames.length > 0 ? { overlayDisplayNames } : {}),
|
|
117
|
+
};
|
|
79
118
|
}
|
|
80
119
|
|
|
81
120
|
/** 抹除单行与多行注释,但完整保留字符串字面量与换行符(字符下标、行号、列号与原文本 100% 对齐) */
|
|
@@ -141,6 +180,36 @@ function lineColAt(source: string, index: number): { line: number; column: numbe
|
|
|
141
180
|
return { line, column: index - lastNewline };
|
|
142
181
|
}
|
|
143
182
|
|
|
183
|
+
/** 在源码 quoteIdx 处读取单/双/反引号字符串字面量(支持转义;遇到模板插值 `${` 标记 dynamic: true) */
|
|
184
|
+
function readStringLiteralAt(
|
|
185
|
+
source: string,
|
|
186
|
+
quoteIdx: number,
|
|
187
|
+
): { value: string; endIndex: number; dynamic: boolean } | undefined {
|
|
188
|
+
const quote = source[quoteIdx];
|
|
189
|
+
if (quote !== "'" && quote !== '"' && quote !== '`') return undefined;
|
|
190
|
+
let value = '';
|
|
191
|
+
let i = quoteIdx + 1;
|
|
192
|
+
while (i < source.length) {
|
|
193
|
+
const ch = source[i]!;
|
|
194
|
+
if (ch === '\\') {
|
|
195
|
+
if (i + 1 >= source.length) return undefined;
|
|
196
|
+
const esc = source[i + 1]!;
|
|
197
|
+
value += esc === 'n' ? '\n' : esc === 'r' ? '\r' : esc === 't' ? '\t' : esc;
|
|
198
|
+
i += 2;
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
if (quote === '`' && ch === '$' && source[i + 1] === '{') {
|
|
202
|
+
return { value: '', endIndex: i, dynamic: true };
|
|
203
|
+
}
|
|
204
|
+
if (ch === quote) {
|
|
205
|
+
return { value, endIndex: i + 1, dynamic: false };
|
|
206
|
+
}
|
|
207
|
+
value += ch;
|
|
208
|
+
i++;
|
|
209
|
+
}
|
|
210
|
+
return undefined;
|
|
211
|
+
}
|
|
212
|
+
|
|
144
213
|
/** 在已抹除注释和字符串的文本中配对括号,返回匹配的右括号下标(未找到返回 -1) */
|
|
145
214
|
function findMatchingBracket(clean: string, openIndex: number, openChar: string, closeChar: string): number {
|
|
146
215
|
let depth = 0;
|
|
@@ -205,6 +274,24 @@ export function checkKitViewTargetRefs(
|
|
|
205
274
|
return [...list, ...amb].join(' / ') || '无';
|
|
206
275
|
};
|
|
207
276
|
|
|
277
|
+
const displayOverlays = (target: KitPageTargetSummary): string => {
|
|
278
|
+
if (target.overlayDisplayNames !== undefined) {
|
|
279
|
+
return target.overlayDisplayNames.length > 0 ? target.overlayDisplayNames.join(' / ') : '无';
|
|
280
|
+
}
|
|
281
|
+
const known = target.overlays ?? new Set<string>();
|
|
282
|
+
if (known.size === 0) return '无';
|
|
283
|
+
const qualified = [...known].filter((k) => k.includes('.'));
|
|
284
|
+
const runtimeFromQualified = new Set(qualified.map((k) => k.replace('.', '_')));
|
|
285
|
+
const bare = [...known].filter((k) => !k.includes('.') && !runtimeFromQualified.has(k));
|
|
286
|
+
const bareSet = new Set(bare);
|
|
287
|
+
const names = new Set<string>(bare);
|
|
288
|
+
for (const q of qualified) {
|
|
289
|
+
const short = q.slice(q.indexOf('.') + 1);
|
|
290
|
+
if (!bareSet.has(short)) names.add(q);
|
|
291
|
+
}
|
|
292
|
+
return [...names].sort().join(' / ') || '无';
|
|
293
|
+
};
|
|
294
|
+
|
|
208
295
|
const reportBadObject = (target: KitPageTargetSummary, method: string, objName: string, absIndex: number): void => {
|
|
209
296
|
const pos = lineColAt(source, absIndex);
|
|
210
297
|
const avail = displayObjects(target);
|
|
@@ -240,6 +327,46 @@ export function checkKitViewTargetRefs(
|
|
|
240
327
|
}
|
|
241
328
|
}
|
|
242
329
|
|
|
330
|
+
// 1b. ctx.openOverlay('名') / ctx.closeOverlay('名')(含可选链):必须是本页声明的浮层(KIT-VIEW-013;普通对象名也报)
|
|
331
|
+
// 在已抹除注释与字符串的 clean 切片上定位真实调用,避免字符串字面量里的示例代码误报
|
|
332
|
+
const cleanSegment = clean.slice(block.start, block.end);
|
|
333
|
+
const overlayRe = /(?<![.\w$])ctx\s*\??\.\s*(openOverlay|closeOverlay)\s*(?:\?\.\s*)?\(\s*(['"`])/g;
|
|
334
|
+
for (const m of cleanSegment.matchAll(overlayRe)) {
|
|
335
|
+
const method = m[1]!;
|
|
336
|
+
const absCallIdx = block.start + (m.index ?? 0);
|
|
337
|
+
const absQuoteIdx = absCallIdx + m[0].length - 1;
|
|
338
|
+
const lit = readStringLiteralAt(source, absQuoteIdx);
|
|
339
|
+
if (lit === undefined || lit.dynamic) continue;
|
|
340
|
+
let after = lit.endIndex;
|
|
341
|
+
while (after < clean.length && /\s/.test(clean[after]!)) after++;
|
|
342
|
+
if (clean[after] !== ')' && clean[after] !== ',') continue;
|
|
343
|
+
const ovName = lit.value;
|
|
344
|
+
const known = target.overlays ?? new Set<string>();
|
|
345
|
+
if (known.has(ovName)) continue;
|
|
346
|
+
const pos = lineColAt(source, absCallIdx);
|
|
347
|
+
// 仅浮层自身存在同名(或与其它对象同名导致须限定名)才提示歧义,避免普通同名对象(tab1.entity / tab2.entity)误报浮层歧义
|
|
348
|
+
const rawCandidates = target.overlayAmbiguous !== undefined
|
|
349
|
+
? target.overlayAmbiguous.get(ovName)
|
|
350
|
+
: target.ambiguous?.get(ovName)?.filter((q) => known.has(q));
|
|
351
|
+
const candidates = rawCandidates !== undefined && rawCandidates.length > 0 ? rawCandidates : undefined;
|
|
352
|
+
const avail = displayOverlays(target);
|
|
353
|
+
diagnostics.push({
|
|
354
|
+
code: 'KIT-VIEW-013',
|
|
355
|
+
path: `${file}:${pos.line}`,
|
|
356
|
+
file,
|
|
357
|
+
line: pos.line,
|
|
358
|
+
column: pos.column,
|
|
359
|
+
message: candidates !== undefined
|
|
360
|
+
? (candidates.length > 1
|
|
361
|
+
? `展示对象 ${target.viewName} 中 ctx.${method}("${ovName}") 的浮层名在本页(${target.pageFile})有多个同名,歧义`
|
|
362
|
+
: `展示对象 ${target.viewName} 中 ctx.${method}("${ovName}") 的浮层名在本页(${target.pageFile})与其它对象同名,须写限定名`)
|
|
363
|
+
: `展示对象 ${target.viewName} 中 ctx.${method}("${ovName}") 不是本页(${target.pageFile})声明的浮层(已声明:${avail})`,
|
|
364
|
+
hint: candidates !== undefined
|
|
365
|
+
? `改写成限定名 <页签 id 或槽名>.${ovName}:${candidates.join(' / ')}`
|
|
366
|
+
: '在 product.objects.overlays 或 page.overlays 下声明该浮层,或改成已声明的浮层名',
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
|
|
243
370
|
// 2. ctx.reload('obj') 或 ctx.reload(['obj1', 'obj2'])
|
|
244
371
|
const reloadRe = /\bctx\s*\.\s*reload\s*\(\s*(\[[^\]]*\]|(['"`])[^'"`\\]*\2)/g;
|
|
245
372
|
for (const m of segment.matchAll(reloadRe)) {
|
|
@@ -19,7 +19,8 @@ import { attachAccessGate } from './access-gate-attach';
|
|
|
19
19
|
import { applyEnvelopeToData, setCompileEnvelope } from '../shared/envelope';
|
|
20
20
|
import { setKitActionOverrides } from '../recipes/emphasis';
|
|
21
21
|
import { setKitCompilePipeline } from '../object-renderer/pipeline-mode';
|
|
22
|
-
import { buildKitObjectNameMap, buildKitObjectNamesElement } from '../biz/shared/object-aliases';
|
|
22
|
+
import { buildKitObjectNameMap, buildKitObjectNamesElement, KIT_PAGE_OVERLAYS_KIND } from '../biz/shared/object-aliases';
|
|
23
|
+
import { emitKitOverlayHost, KIT_PAGE_OVERLAY_PAGE_ID } from '../biz/shared/page-overlay-host';
|
|
23
24
|
import { buildKitThemeBootDataElement, toKitRuntimeTheme } from '../shared/theme-runtime-shared';
|
|
24
25
|
import { withHints } from './hints';
|
|
25
26
|
import { KitDiagnosticError } from '../shared/kit-error';
|
|
@@ -46,7 +47,7 @@ import { kitCategoricalIndex, kitLookCarrierCss } from '../theme/look-carrier';
|
|
|
46
47
|
import { KIT_PAGE_PIPELINE_BROKEN, kitPipelineCrashReport, runPagePipeline, type KitPipelineMode, type KitPipelineResult } from './page-pipeline';
|
|
47
48
|
import { kitLookRulesForPipeline, kitLookThemeFactsOf, type KitLookPipelinePlan } from './page-pipeline-look';
|
|
48
49
|
import { KIT_PAGE_GATE, applyAttrsToArtifact, kitSelfReportOfDecl, kitSelfReportTable, walk, type KitExpandShell, type KitGateFinding, type KitSelfReportTable } from '../spatial';
|
|
49
|
-
import { KIT_OBJECT_CORE_KEYS, KIT_PAGE_ROOT_ANCHOR, isKitObjectDecl } from '../biz/layout-contracts';
|
|
50
|
+
import { KIT_OBJECT_CORE_KEYS, KIT_PAGE_ROOT_ANCHOR, isKitObjectDecl, type KitBizLayoutContract } from '../biz/layout-contracts';
|
|
50
51
|
import type {
|
|
51
52
|
KitAppContext,
|
|
52
53
|
KitCompileResult,
|
|
@@ -477,6 +478,9 @@ async function compileKitPageBody(page: unknown, app: KitAppContext, options?: K
|
|
|
477
478
|
registeredComponents: app.registeredComponents,
|
|
478
479
|
staticComponents: app.staticComponents,
|
|
479
480
|
locale: pageLocale,
|
|
481
|
+
// 页面声明的路径 / 查询参数名:业务组件校验 $page.params.<名> / $page.query.<名> 引用用(KitBizContext.pageParams / pageQuery)
|
|
482
|
+
pageParams: Object.keys(decl.page.params ?? {}),
|
|
483
|
+
pageQuery: Object.keys(decl.page.query ?? {}),
|
|
480
484
|
advise: (a) => { deprecations.push({ ...a, severity: 'warn' }); },
|
|
481
485
|
...(lookPlan !== undefined ? { lookPanelIcon: (panel: string) => lookPlan.panelIcon(plan.tabId ?? plan.slot, panel) } : {}),
|
|
482
486
|
// 主题流水线新模式才带模式键:旧版上下文与改动前逐键相同,模板走原表达式(biz/shared/pipeline.ts)
|
|
@@ -512,7 +516,34 @@ async function compileKitPageBody(page: unknown, app: KitAppContext, options?: K
|
|
|
512
516
|
slotFragments.main = rf;
|
|
513
517
|
allFragments.push(rf);
|
|
514
518
|
}
|
|
515
|
-
|
|
519
|
+
// 页面级浮层(page.overlays):编进一个无界面的宿主片段(biz/shared/page-overlay-host),页面框装完后并进产物;
|
|
520
|
+
// 页头动作 openOverlay 点名的浮层必须声明在 page.overlays 里(KIT-PAGE-007)。没写这两样时本段什么都不做
|
|
521
|
+
let overlayHostFrag: KitFragment | undefined;
|
|
522
|
+
const pageOverlayRefDiagnostics: KitDiagnostic[] = [];
|
|
523
|
+
(decl.page.actions ?? []).forEach((a, i) => {
|
|
524
|
+
if (a.openOverlay !== undefined && !(decl.page.overlays !== undefined && Object.hasOwn(decl.page.overlays, a.openOverlay))) {
|
|
525
|
+
const names = Object.keys(decl.page.overlays ?? {});
|
|
526
|
+
pageOverlayRefDiagnostics.push({ code: 'KIT-PAGE-007', path: `page.actions[${i}].openOverlay`, message: `页头动作 ${a.id} 的 openOverlay "${a.openOverlay}" 不是 page.overlays 里声明的浮层(已声明:${names.length > 0 ? names.join(' / ') : '无'})` });
|
|
527
|
+
}
|
|
528
|
+
});
|
|
529
|
+
if (decl.page.overlays !== undefined) {
|
|
530
|
+
overlayHostFrag = emitKitOverlayHost({
|
|
531
|
+
ctx: {
|
|
532
|
+
pageId: KIT_PAGE_OVERLAY_PAGE_ID,
|
|
533
|
+
registeredActions: app.registeredActions,
|
|
534
|
+
registeredComponents: app.registeredComponents,
|
|
535
|
+
staticComponents: app.staticComponents,
|
|
536
|
+
locale: pageLocale,
|
|
537
|
+
pageParams: Object.keys(decl.page.params ?? {}),
|
|
538
|
+
pageQuery: Object.keys(decl.page.query ?? {}),
|
|
539
|
+
advise: (a) => { deprecations.push({ ...a, severity: 'warn' }); },
|
|
540
|
+
...(app.pipeline === 'next' ? { pipeline: 'next' as const } : {}),
|
|
541
|
+
},
|
|
542
|
+
overlays: decl.page.overlays,
|
|
543
|
+
});
|
|
544
|
+
allFragments.push(overlayHostFrag);
|
|
545
|
+
}
|
|
546
|
+
const bizDiagnostics = [...allFragments.flatMap((f) => f.diagnostics), ...pageOverlayRefDiagnostics];
|
|
516
547
|
if (bizDiagnostics.length > 0) return { diagnostics: bizDiagnostics };
|
|
517
548
|
// 跨产品重键(两个产品落在同一页,ui 键或事件键不能相撞)
|
|
518
549
|
const crossDiagnostics = mergeFragments(...allFragments).diagnostics;
|
|
@@ -586,6 +617,12 @@ async function compileKitPageBody(page: unknown, app: KitAppContext, options?: K
|
|
|
586
617
|
const requestSpecs = endRequestCollect();
|
|
587
618
|
const filterWatches = endFilterReloadCollect();
|
|
588
619
|
if (framed.diagnostics.length > 0) return { diagnostics: framed.diagnostics };
|
|
620
|
+
// 页面级浮层宿主并进页面框产物(宿主 HTML 接在页面体之后,与动作宿主 / 无权访问宿主同一做法;键已在上面的跨产品重键检查里核过)
|
|
621
|
+
if (overlayHostFrag !== undefined && overlayHostFrag.html !== '') {
|
|
622
|
+
const merged = mergeFragments(framed, overlayHostFrag);
|
|
623
|
+
if (merged.diagnostics.length > 0) return { diagnostics: merged.diagnostics };
|
|
624
|
+
Object.assign(framed, { html: merged.html, ui: merged.ui, events: merged.events, components: merged.components, candidates: merged.candidates });
|
|
625
|
+
}
|
|
589
626
|
// 页头状态行 page.status.follow:必须有 request 动作可听;点名的动作 id 须是本页某 request 动作
|
|
590
627
|
if (decl.page.statusFollow !== undefined) {
|
|
591
628
|
const requestIds = new Set([...requestSpecs.values()].filter((s) => s.kind === 'request').map((s) => s.actionId));
|
|
@@ -721,7 +758,11 @@ async function compileKitPageBody(page: unknown, app: KitAppContext, options?: K
|
|
|
721
758
|
const themeBoot = themeFree ? '' : buildKitThemeBootDataElement(app.appName, appBaseTheme);
|
|
722
759
|
// 展示对象的对象名契约(biz/shared/object-aliases.ts):声明名 / 限定名 -> 运行期名,写成惰性数据元素供 ctx.form / data / request … 解析
|
|
723
760
|
const objectNames = decl.page.view !== undefined
|
|
724
|
-
? buildKitObjectNamesElement(buildKitObjectNameMap(
|
|
761
|
+
? buildKitObjectNamesElement(buildKitObjectNameMap([
|
|
762
|
+
...plans.map((p) => ({ pageId: p.tabId ?? p.slot, kind: p.product.kind, objects: p.product.objects })),
|
|
763
|
+
// 页面级浮层(page.overlays):ctx.openOverlay('名') / ctx.form('名') 据此解析到 kit_page_<名>;没写时不加,产物不变
|
|
764
|
+
...(decl.page.overlays !== undefined ? [{ pageId: KIT_PAGE_OVERLAY_PAGE_ID, kind: KIT_PAGE_OVERLAYS_KIND, objects: { overlays: decl.page.overlays } }] : []),
|
|
765
|
+
]))
|
|
725
766
|
: '';
|
|
726
767
|
// 层级角色是否出现(§3.9 KT-HB-A):页面声明的事实(对象个数、单个还是集合、分组、嵌套、依附、主从、有无外壳)交 foundation 的 arrangeHierarchy 求解,
|
|
727
768
|
// 出现的角色写在页面根上(体检与静态断言对照用;出现规则只在参考实现,这里不判)
|
|
@@ -984,6 +1025,9 @@ function pagePipelineSidecar(
|
|
|
984
1025
|
const selfReports = selfReportTableOf(app);
|
|
985
1026
|
const staticEmits: Record<string, readonly string[]> = {};
|
|
986
1027
|
for (const [name, c] of Object.entries(app.staticComponents)) if (c.emits !== undefined) staticEmits[name] = c.emits;
|
|
1028
|
+
// 应用业务组件声明的版式契约(defineKitBizComponent({ layoutContract })):交给展开,查表顺序内置冻结表 → 这里 → FREE
|
|
1029
|
+
const layoutContracts: Record<string, KitBizLayoutContract> = {};
|
|
1030
|
+
for (const [kind, def] of Object.entries(app.bizComponents ?? {})) if (def.layoutContract) layoutContracts[kind] = def.layoutContract;
|
|
987
1031
|
const result = runPagePipeline(decl, {
|
|
988
1032
|
frameKind: decl.frame.kind,
|
|
989
1033
|
shell: pipelineShellOf(app, structure),
|
|
@@ -991,6 +1035,7 @@ function pagePipelineSidecar(
|
|
|
991
1035
|
look: look.rules,
|
|
992
1036
|
...(lookTones.staticTones.length > 0 || lookTones.hasDynamicTone || lookTones.hasCategoricalTone ? { lookTones } : {}),
|
|
993
1037
|
compositionRoles: appRolesOf(app.staticComponents),
|
|
1038
|
+
...(Object.keys(layoutContracts).length > 0 ? { layoutContracts } : {}),
|
|
994
1039
|
staticEmits,
|
|
995
1040
|
envelopeFacts,
|
|
996
1041
|
});
|
|
@@ -29,6 +29,7 @@ import type { ArrangePageEnvelopeInput } from 'soma-foundation/arrange';
|
|
|
29
29
|
import type { KitComponentPart, KitTone } from '../shared/page-attrs';
|
|
30
30
|
import type { KitThemeUsage } from '../shared/theme-usage';
|
|
31
31
|
import type { KitPageDecl } from './types';
|
|
32
|
+
import type { KitBizLayoutContract } from '../biz/layout-contracts';
|
|
32
33
|
|
|
33
34
|
/** 新旧开关的两个取值(kit.app.yaml 的 layout.pipeline):legacy = 旁路运行,产物不变;next = 属性写进产物 */
|
|
34
35
|
export type KitPipelineMode = 'legacy' | 'next';
|
|
@@ -54,6 +55,8 @@ export interface KitPipelineOptions {
|
|
|
54
55
|
readonly selfReports?: KitSelfReportTable;
|
|
55
56
|
/** 应用组件登记的构成角色(组件名 → 角色;看板模板取的同一张表),看板面板的构成输入与模板同源(SCON-151);缺省没有 */
|
|
56
57
|
readonly compositionRoles?: Readonly<Record<string, string>>;
|
|
58
|
+
/** 应用业务组件声明的版式契约(组件名 → 契约,编排层从 app.bizComponents 的 layoutContract 收集):内置冻结表之后、FREE 之前查;缺省没有 */
|
|
59
|
+
readonly layoutContracts?: Readonly<Record<string, KitBizLayoutContract>>;
|
|
57
60
|
/** 写死形状组件声明的事件(组件名 → emits):附加浮层没写 kind 时判窗口 / 抽屉与模板同口径(A-07);缺省没有 */
|
|
58
61
|
readonly staticEmits?: Readonly<Record<string, readonly string[]>>;
|
|
59
62
|
/** 编排层按页面声明求出的版心包络事实(compile/stages.ts#derivePageEnvelopeFacts,与旧流水线同一份,SCON-153);缺省时布局按组件树自己数 */
|
|
@@ -168,6 +171,7 @@ export function runPagePipeline(decl: KitPageDecl, options: KitPipelineOptions):
|
|
|
168
171
|
...(options.shell !== undefined ? { shell: options.shell } : {}),
|
|
169
172
|
...(options.selfReports !== undefined ? { selfReports: options.selfReports } : {}),
|
|
170
173
|
...(options.compositionRoles !== undefined ? { compositionRoles: options.compositionRoles } : {}),
|
|
174
|
+
...(options.layoutContracts !== undefined ? { layoutContracts: options.layoutContracts } : {}),
|
|
171
175
|
...(options.staticEmits !== undefined ? { staticEmits: options.staticEmits } : {}),
|
|
172
176
|
...(options.envelopeFacts !== undefined ? { envelopeFacts: options.envelopeFacts as unknown as Readonly<Record<string, unknown>> } : {}),
|
|
173
177
|
});
|
package/src/compile/parse.ts
CHANGED
|
@@ -583,6 +583,19 @@ export function parsePageDecl(raw: unknown, diagnostics: KitDiagnostic[], defaul
|
|
|
583
583
|
if (page.view !== undefined && !isViewName(page.view)) {
|
|
584
584
|
diagnostics.push({ code: 'KIT-VIEW-001', path: 'page.view', message: `page.view 须是展示对象类名(大写字母开头、以 View 结尾,如 RefG3View),收到 ${JSON.stringify(page.view)}` });
|
|
585
585
|
}
|
|
586
|
+
// 页面级浮层(page.overlays):形状与闭集同 product.objects.overlays.<名>;rowClick / kind: expand 与页头 openOverlay 引用由 compile-page / 宿主编译核对(KIT-PAGE-007)
|
|
587
|
+
let pageOverlays: Record<string, Record<string, unknown>> | undefined;
|
|
588
|
+
if (page.overlays !== undefined) {
|
|
589
|
+
if (!isRecord(page.overlays) || Object.keys(page.overlays).length === 0) {
|
|
590
|
+
diagnostics.push({ code: 'KIT-PAGE-007', path: 'page.overlays', message: 'page.overlays 必须是非空的 { 浮层名: 声明 }(声明形状同 product.objects.overlays.<名>)' });
|
|
591
|
+
} else {
|
|
592
|
+
for (const [name, decl] of Object.entries(page.overlays)) {
|
|
593
|
+
checkObjectName(name, `page.overlays.${name}`, diagnostics);
|
|
594
|
+
checkObjectDecl(decl, `page.overlays.${name}`, diagnostics, OVERLAY_KEYS);
|
|
595
|
+
}
|
|
596
|
+
pageOverlays = page.overlays as Record<string, Record<string, unknown>>;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
586
599
|
if (raw.locales !== undefined) {
|
|
587
600
|
const lc = raw.locales;
|
|
588
601
|
const ok = isRecord(lc) && Object.values(lc).every((t) => isRecord(t) && Object.values(t).every((s) => typeof s === 'string'));
|
|
@@ -600,6 +613,7 @@ export function parsePageDecl(raw: unknown, diagnostics: KitDiagnostic[], defaul
|
|
|
600
613
|
if (isViewName(page.view)) meta.view = page.view;
|
|
601
614
|
// 页面规则(界面规则 L2):原样保留,形状与选择器由 compile/look-page.ts 校验(KIT-LOOK-*)
|
|
602
615
|
if (page.look !== undefined) meta.look = page.look;
|
|
616
|
+
if (pageOverlays !== undefined) meta.overlays = pageOverlays as unknown as NonNullable<KitPageDecl['page']['overlays']>;
|
|
603
617
|
if (redirectDecl !== undefined) meta.redirect = redirectDecl;
|
|
604
618
|
Object.assign(meta, header);
|
|
605
619
|
Object.assign(meta, parsePageParams(page, url, diagnostics));
|
package/src/compile/stages.ts
CHANGED
|
@@ -109,9 +109,10 @@ const VALID_ENVELOPE_TIERS: ReadonlySet<string> = new Set(['narrow', 'medium', '
|
|
|
109
109
|
|
|
110
110
|
/**
|
|
111
111
|
* 业务组件版式契约里的版面事实(biz/layout-contracts.ts#frameFacts):侧导航、阅读、详情等判断读它,不按业务组件名判断。
|
|
112
|
-
*
|
|
112
|
+
* 未登记的业务组件取缺省契约(各项皆否),与原先「名字不在名单里」的结论相同;应用业务组件声明了 layoutContract 的取它(内置冻结表仍优先)。
|
|
113
113
|
*/
|
|
114
|
-
const frameFactsOf = (kind: string): KitBizLayoutContract['frameFacts'] =>
|
|
114
|
+
const frameFactsOf = (kind: string, def?: KitBizDefinition): KitBizLayoutContract['frameFacts'] =>
|
|
115
|
+
kitBizLayoutContract(kind, def?.layoutContract ? { [kind]: def.layoutContract } : undefined).frameFacts;
|
|
115
116
|
|
|
116
117
|
interface ExtractedTableFacts {
|
|
117
118
|
readonly count: number;
|
|
@@ -391,7 +392,7 @@ export function derivePageEnvelopeFacts(
|
|
|
391
392
|
|
|
392
393
|
const mainBizDef = productKind !== undefined ? getBizDef(productKind) : undefined;
|
|
393
394
|
const mainTrait = mainBizDef?.envelope;
|
|
394
|
-
const mainFacts = productKind !== undefined ? frameFactsOf(productKind) : undefined;
|
|
395
|
+
const mainFacts = productKind !== undefined ? frameFactsOf(productKind, mainBizDef) : undefined;
|
|
395
396
|
|
|
396
397
|
let surfaceKind: ArrangePageEnvelopeSurfaceKind | undefined = mainTrait?.surface;
|
|
397
398
|
let readingMode: boolean | undefined = mainTrait?.readingMode;
|
|
@@ -516,7 +517,7 @@ export function derivePageEnvelopeFacts(
|
|
|
516
517
|
railWidthRem = trait.railWidthRem;
|
|
517
518
|
}
|
|
518
519
|
const overlayRoles = new Set<string>(trait?.overlayFormRoles ?? []);
|
|
519
|
-
const productFacts = frameFactsOf(product.kind);
|
|
520
|
+
const productFacts = frameFactsOf(product.kind, bizDef);
|
|
520
521
|
|
|
521
522
|
const objs = product.objects;
|
|
522
523
|
if ('master' in objs && ('detail' in objs || 'sub' in objs || 'subs' in objs)) {
|
package/src/compile/types.ts
CHANGED
|
@@ -50,7 +50,7 @@ export interface KitTabDecl {
|
|
|
50
50
|
|
|
51
51
|
/** 解析后的页面声明 */
|
|
52
52
|
export interface KitPageDecl {
|
|
53
|
-
page: { url: string; title: string; subtitle?: string; eyebrow?: string; roles?: string[]; breadcrumbs?: Array<{ label: string; href?: string }>; redirect?: KitRedirectDecl; params?: Record<string, Record<string, unknown>>; query?: Record<string, Record<string, unknown>>; locale?: string; dir?: 'ltr' | 'rtl'; envelope?: import('../shared/envelope').KitEnvelope; inheritLayout?: boolean; view?: string; /** 版心档(maxWidth)是编排层从应用缺省 layout.maxWidth 补上的,不是页面自己写的(compile/stages.ts#planSize 写;页面线版心据此区分页面声明与应用缺省) */ maxWidthFromApp?: boolean; /** 页面规则(page.look,界面规则 L2,原样保留,由 compile/look-page.ts 解析) */ look?: unknown } & Pick<import('../frames/types').KitPageMeta, 'actions' | 'back' | 'status' | 'statusFollow' | 'maxWidth' | 'sticky'>;
|
|
53
|
+
page: { url: string; title: string; subtitle?: string; eyebrow?: string; roles?: string[]; breadcrumbs?: Array<{ label: string; href?: string }>; redirect?: KitRedirectDecl; params?: Record<string, Record<string, unknown>>; query?: Record<string, Record<string, unknown>>; locale?: string; dir?: 'ltr' | 'rtl'; envelope?: import('../shared/envelope').KitEnvelope; inheritLayout?: boolean; view?: string; /** 版心档(maxWidth)是编排层从应用缺省 layout.maxWidth 补上的,不是页面自己写的(compile/stages.ts#planSize 写;页面线版心据此区分页面声明与应用缺省) */ maxWidthFromApp?: boolean; /** 页面规则(page.look,界面规则 L2,原样保留,由 compile/look-page.ts 解析) */ look?: unknown; /** 页面级浮层(page.overlays,形状同 product.objects.overlays.<名>;由 compile-page 交 biz/shared/page-overlay-host#emitKitOverlayHost 编) */ overlays?: Record<string, import('../biz/types').KitOverlayDecl> } & Pick<import('../frames/types').KitPageMeta, 'actions' | 'back' | 'status' | 'statusFollow' | 'maxWidth' | 'sticky'>;
|
|
54
54
|
frame: {
|
|
55
55
|
kind: string;
|
|
56
56
|
/** 页面是否显式声明了 frame.kind(未显式声明时可继承 kit.app.yaml#layout.frame) */
|
|
@@ -99,33 +99,49 @@ function fieldRefsOfSlot(slotView: Rec, at: string): Array<{ ref: Rec; at: strin
|
|
|
99
99
|
return out;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
/** 写死形状组件位置(视图槽,或整视图简写的 view 本身)的 props / on 绑定:props 的 view.<成员> 核成员与契约形状,on 的 view.<方法> 核方法 */
|
|
103
|
+
function usageOfStaticHolder(holder: Rec, base: string, out: Usage, staticComponents: KitAppContext['staticComponents']): void {
|
|
104
|
+
const component = typeof holder.staticComponent === 'string' ? holder.staticComponent : undefined;
|
|
105
|
+
if (component === undefined) return;
|
|
106
|
+
const propTypes = staticComponents?.[component]?.propTypes;
|
|
107
|
+
if (isRec(holder.props)) {
|
|
108
|
+
for (const [k, v] of Object.entries(holder.props)) {
|
|
109
|
+
const b = classifyBindingValue(v, k);
|
|
110
|
+
if (b.kind === 'view') {
|
|
111
|
+
const expect = expectOfPropType(propTypes?.[k], `${component} 的 prop ${k}`);
|
|
112
|
+
out.members.push({ name: viewPathMember(b.path), at: `${base}.props.${k}`, sub: b.path.slice('view.'.length), ...(expect !== undefined ? { expect } : {}) });
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (isRec(holder.on)) {
|
|
117
|
+
for (const [ev, v] of Object.entries(holder.on)) {
|
|
118
|
+
const e = classifyEventBinding(v, ev);
|
|
119
|
+
if (e.kind === 'method') out.methods.push({ name: e.name, at: `${base}.on.${ev}` });
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* 整视图简写:view 下直接写 staticComponent / props / on,不套视图槽(业务组件展开时按 accept 放进 list / summary 槽,
|
|
126
|
+
* 与 biz/shared/overlay-compile#normalizeOverlayView、compile/stages#staticComponentNamesOf 同口径)。写了任一视图槽就不是简写。
|
|
127
|
+
*/
|
|
128
|
+
function isWholeStaticView(view: Rec): boolean {
|
|
129
|
+
return !VIEW_SLOTS.some((s) => s in view) && typeof view.staticComponent === 'string' && view.staticComponent !== '';
|
|
130
|
+
}
|
|
131
|
+
|
|
102
132
|
/**
|
|
103
133
|
* 组件 props / 字段项 props / 请求参数 / 组件事件 / 浮层事件上的展示对象绑定(RV-1119):只收合法的 view.<成员> 与 view.<方法>,
|
|
104
134
|
* 非法写法(取反、表达式、原始运行期路径、row. 位置不对)由渲染层在编译对象时报,这里不重复。
|
|
105
135
|
*/
|
|
106
136
|
function usageOfBindings(obj: Rec, at: string, out: Usage, staticComponents: KitAppContext['staticComponents']): void {
|
|
107
137
|
const view = isRec(obj.view) ? obj.view : {};
|
|
138
|
+
// 整视图简写的 props / on(MultiObjectBoard 面板、浮层等常见写法):与视图槽里的写死形状组件同口径核
|
|
139
|
+
if (isWholeStaticView(view)) usageOfStaticHolder(view, `${at}.view`, out, staticComponents);
|
|
108
140
|
for (const slot of VIEW_SLOTS) {
|
|
109
141
|
const slotView = view[slot];
|
|
110
142
|
if (!isRec(slotView)) continue;
|
|
111
143
|
const base = `${at}.view.${slot}`;
|
|
112
|
-
|
|
113
|
-
const propTypes = component !== undefined ? staticComponents?.[component]?.propTypes : undefined;
|
|
114
|
-
if (component !== undefined && isRec(slotView.props)) {
|
|
115
|
-
for (const [k, v] of Object.entries(slotView.props)) {
|
|
116
|
-
const b = classifyBindingValue(v, k);
|
|
117
|
-
if (b.kind === 'view') {
|
|
118
|
-
const expect = expectOfPropType(propTypes?.[k], `${component} 的 prop ${k}`);
|
|
119
|
-
out.members.push({ name: viewPathMember(b.path), at: `${base}.props.${k}`, sub: b.path.slice('view.'.length), ...(expect !== undefined ? { expect } : {}) });
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
if (component !== undefined && isRec(slotView.on)) {
|
|
124
|
-
for (const [ev, v] of Object.entries(slotView.on)) {
|
|
125
|
-
const e = classifyEventBinding(v, ev);
|
|
126
|
-
if (e.kind === 'method') out.methods.push({ name: e.name, at: `${base}.on.${ev}` });
|
|
127
|
-
}
|
|
128
|
-
}
|
|
144
|
+
usageOfStaticHolder(slotView, base, out, staticComponents);
|
|
129
145
|
// 字段项 props(只读单元):view.<成员> 与 form 的字段状态键同口径核成员存在
|
|
130
146
|
for (const { ref, at: refAt } of fieldRefsOfSlot(slotView, base)) {
|
|
131
147
|
if (!isRec(ref.props)) continue;
|
|
@@ -156,6 +172,13 @@ function usageOfBindings(obj: Rec, at: string, out: Usage, staticComponents: Kit
|
|
|
156
172
|
function usageOfObject(obj: unknown, at: string, out: Usage, staticComponents?: KitAppContext['staticComponents']): void {
|
|
157
173
|
if (!isRec(obj)) return;
|
|
158
174
|
usageOfBindings(obj, at, out, staticComponents ?? {});
|
|
175
|
+
// 运行期模式与初值来源(SingleObjectForm 的 target.modeFrom / target.initialFrom 等):写成 view.<成员> 时核成员存在与形状
|
|
176
|
+
if (isViewPath(obj.modeFrom)) {
|
|
177
|
+
out.members.push({ name: viewPathMember(obj.modeFrom), at: `${at}.modeFrom`, sub: obj.modeFrom.slice('view.'.length), expect: { kinds: ['scalar'], label: 'modeFrom' } });
|
|
178
|
+
}
|
|
179
|
+
if (isViewPath(obj.initialFrom)) {
|
|
180
|
+
out.members.push({ name: viewPathMember(obj.initialFrom), at: `${at}.initialFrom`, sub: obj.initialFrom.slice('view.'.length), expect: { kinds: ['object'], label: 'initialFrom' } });
|
|
181
|
+
}
|
|
159
182
|
// 动态面板标题:list / summary 的 title 写成 view.<成员> 时绑定展示对象的只读成员,成员必须已声明(KIT-VIEW-003,同口径)
|
|
160
183
|
for (const slot of ['list', 'summary'] as const) {
|
|
161
184
|
const slotRec = isRec(obj.view) && isRec(obj.view[slot]) ? obj.view[slot] : undefined;
|
|
@@ -209,6 +232,10 @@ function usageOfObject(obj: unknown, at: string, out: Usage, staticComponents?:
|
|
|
209
232
|
out.members.push({ name: viewPathMember(reason), at: `${at}.behavior.actions[${i}].disabledReason`, sub: reason.slice('view.'.length), site: 'actionDisabled' });
|
|
210
233
|
}
|
|
211
234
|
});
|
|
235
|
+
// 从属对象(decl.subs.<名>,业务组件自行展开的内层对象):与产品对象表里的对象同口径核(与 patchSourceObjectDecl 走 subs 同一走法)
|
|
236
|
+
if (isRec(obj.subs)) {
|
|
237
|
+
for (const [name, sub] of Object.entries(obj.subs)) usageOfObject(sub, `${at}.subs.${name}`, out, staticComponents);
|
|
238
|
+
}
|
|
212
239
|
}
|
|
213
240
|
|
|
214
241
|
function usageOfProduct(product: KitProductDecl, at: string, out: Usage, staticComponents?: KitAppContext['staticComponents']): void {
|
|
@@ -229,6 +256,11 @@ export function viewUsageOf(decl: KitPageDecl, staticComponents?: KitAppContext[
|
|
|
229
256
|
if (Array.isArray(val)) (val as KitTabDecl[]).forEach((tab, i) => usageOfProduct(tab.product, `frame.slots.${slot}[${i}].product`, out, staticComponents));
|
|
230
257
|
else usageOfProduct(val as KitProductDecl, slot === 'main' ? 'product' : `frame.slots.${slot}`, out, staticComponents);
|
|
231
258
|
}
|
|
259
|
+
if (isRec(decl.page.overlays)) {
|
|
260
|
+
for (const [name, ov] of Object.entries(decl.page.overlays)) {
|
|
261
|
+
usageOfObject(ov, `page.overlays.${name}`, out, staticComponents);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
232
264
|
return out;
|
|
233
265
|
}
|
|
234
266
|
|