soma-core 1.4.0 → 1.4.1
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 +1 -1
- package/core/build/blocks/block-compile.ts +31 -2
- package/core/build/blocks/block-container.ts +2 -11
- package/core/build/compiler/page-declaration-compiler.ts +30 -2
- package/core/build/compiler/soma-precompile.js +2041 -19
- package/core/build/component/component-graph.ts +208 -0
- package/core/build/eject/component-eject.ts +473 -0
- package/core/build/eject/component-upgrade.ts +359 -0
- package/core/build/layout/constraint-solver.ts +235 -0
- package/core/build/layout/css-emitter.ts +116 -0
- package/core/build/layout/page-layout.ts +85 -0
- package/core/build/pack/pack-init.ts +265 -0
- package/core/client/base/SomaPageRootBase.ts +61 -0
- package/core/client/component/ai-catalog.ts +79 -4
- package/core/client/component/component-defaults.ts +100 -0
- package/core/client/component/component-definition.types.ts +39 -0
- package/core/client/component/component-manager.ts +79 -4
- package/core/client/component/component-pack.ts +126 -2
- package/core/client/component/keyboard-matrix.ts +144 -0
- package/core/client/component/pack-styles.ts +59 -1
- package/core/client/component/style-features.ts +131 -0
- package/core/client/component/theme-component-tokens.ts +83 -0
- package/core/client/data/data-object-resolver.ts +407 -4
- package/core/client/data/reaction-engine.ts +176 -0
- package/core/client/data/window-engine.ts +477 -0
- package/core/client/engine/event-engine.ts +98 -0
- package/core/client/engine/soma-bootstrap.ts +265 -5
- package/core/client/engine/step-runner.ts +134 -0
- package/core/client/parser/blocks/page-parser.ts +15 -1
- package/core/client/parser/blocks/use-parser.ts +5 -12
- package/core/client/parser/data-config-parser.ts +316 -8
- package/core/client/parser/duration.ts +16 -0
- package/core/client/parser/layout-parser.ts +157 -0
- package/core/client/parser/page-state-parser.ts +166 -0
- package/core/client/parser/pipeline-parser.ts +76 -1
- package/core/client/parser/reaction-parser.ts +459 -0
- package/core/client/parser/reaction-sugar.ts +47 -0
- package/core/client/parser/step-parser.ts +359 -0
- package/core/client/parser/ui-config-parser.ts +59 -0
- package/core/client/parser/window-parser.ts +294 -0
- package/core/client/theme/theme-engine.ts +102 -2
- package/core/index.ts +163 -0
- package/core/shared/block-errors.ts +11 -0
- package/core/shared/calc/coerce.ts +29 -0
- package/core/shared/calc/errors.ts +43 -0
- package/core/shared/calc/evaluator.ts +101 -0
- package/core/shared/calc/index.ts +12 -0
- package/core/shared/calc/lexer.ts +194 -0
- package/core/shared/calc/parser.ts +204 -0
- package/core/shared/calc/typer.ts +184 -0
- package/core/shared/path-algebra.ts +169 -0
- package/core/shared/predicates/index.ts +527 -0
- package/core/shared/types/component-contract.types.ts +128 -2
- package/core/shared/types/data-config.types.ts +120 -1
- package/core/shared/types/domain.types.ts +13 -0
- package/core/shared/types/event.types.ts +22 -2
- package/core/shared/types/layout-constraint.types.ts +73 -0
- package/core/shared/types/page-state.types.ts +60 -0
- package/core/shared/types/reaction.types.ts +144 -0
- package/core/shared/types/step.types.ts +91 -0
- package/core/shared/types/ui-config.types.ts +18 -0
- package/core/shared/types/window.types.ts +177 -0
- package/dist/cli/soma.js +13 -1
- package/dist/core/index.cjs +4684 -349
- package/dist/types/build/blocks/block-container.d.ts +1 -6
- package/dist/types/build/compiler/page-declaration-compiler.d.ts +2 -0
- package/dist/types/build/component/component-graph.d.ts +85 -0
- package/dist/types/build/eject/component-eject.d.ts +121 -0
- package/dist/types/build/eject/component-upgrade.d.ts +43 -0
- package/dist/types/build/layout/constraint-solver.d.ts +36 -0
- package/dist/types/build/layout/css-emitter.d.ts +18 -0
- package/dist/types/build/layout/page-layout.d.ts +24 -0
- package/dist/types/build/pack/pack-init.d.ts +8 -0
- package/dist/types/client/base/SomaPageRootBase.d.ts +28 -0
- package/dist/types/client/component/ai-catalog.d.ts +24 -1
- package/dist/types/client/component/component-defaults.d.ts +15 -0
- package/dist/types/client/component/component-definition.types.d.ts +38 -0
- package/dist/types/client/component/component-manager.d.ts +36 -0
- package/dist/types/client/component/component-pack.d.ts +32 -2
- package/dist/types/client/component/keyboard-matrix.d.ts +24 -0
- package/dist/types/client/component/pack-styles.d.ts +21 -0
- package/dist/types/client/component/style-features.d.ts +26 -0
- package/dist/types/client/component/theme-component-tokens.d.ts +14 -0
- package/dist/types/client/data/data-object-resolver.d.ts +106 -1
- package/dist/types/client/data/reaction-engine.d.ts +21 -0
- package/dist/types/client/data/window-engine.d.ts +27 -0
- package/dist/types/client/engine/event-engine.d.ts +15 -0
- package/dist/types/client/engine/soma-bootstrap.d.ts +70 -0
- package/dist/types/client/engine/step-runner.d.ts +24 -0
- package/dist/types/client/parser/blocks/use-parser.d.ts +2 -2
- package/dist/types/client/parser/duration.d.ts +1 -0
- package/dist/types/client/parser/layout-parser.d.ts +9 -0
- package/dist/types/client/parser/page-state-parser.d.ts +32 -0
- package/dist/types/client/parser/reaction-parser.d.ts +16 -0
- package/dist/types/client/parser/reaction-sugar.d.ts +13 -0
- package/dist/types/client/parser/step-parser.d.ts +23 -0
- package/dist/types/client/parser/ui-config-parser.d.ts +5 -0
- package/dist/types/client/parser/window-parser.d.ts +25 -0
- package/dist/types/client/theme/theme-engine.d.ts +26 -0
- package/dist/types/index.d.ts +32 -2
- package/dist/types/shared/block-errors.d.ts +5 -0
- package/dist/types/shared/calc/coerce.d.ts +4 -0
- package/dist/types/shared/calc/errors.d.ts +14 -0
- package/dist/types/shared/calc/evaluator.d.ts +2 -0
- package/dist/types/shared/calc/index.d.ts +6 -0
- package/dist/types/shared/calc/lexer.d.ts +20 -0
- package/dist/types/shared/calc/parser.d.ts +49 -0
- package/dist/types/shared/calc/typer.d.ts +16 -0
- package/dist/types/shared/path-algebra.d.ts +56 -0
- package/dist/types/shared/predicates/index.d.ts +79 -0
- package/dist/types/shared/types/component-contract.types.d.ts +112 -0
- package/dist/types/shared/types/data-config.types.d.ts +115 -1
- package/dist/types/shared/types/domain.types.d.ts +12 -0
- package/dist/types/shared/types/event.types.d.ts +8 -2
- package/dist/types/shared/types/layout-constraint.types.d.ts +52 -0
- package/dist/types/shared/types/page-state.types.d.ts +49 -0
- package/dist/types/shared/types/reaction.types.d.ts +115 -0
- package/dist/types/shared/types/step.types.d.ts +76 -0
- package/dist/types/shared/types/ui-config.types.d.ts +18 -0
- package/dist/types/shared/types/window.types.d.ts +171 -0
- package/package.json +2 -1
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
// `state:` 段解析(REQ-010 F-37)。
|
|
2
|
+
//
|
|
3
|
+
// 这一段的价值全在**校验**上:切片名要指向真实存在的数据对象与表格锚点。
|
|
4
|
+
// 不校验的话,一个拼错的窗口名会让「恢复状态」静默少恢复一块——
|
|
5
|
+
// 用户打开分享链接,看到的是一屏"差不多但不完全对"的东西,而没有任何提示。
|
|
6
|
+
|
|
7
|
+
import type { SomaPageState, SomaPageStateConfig } from '../../shared/types/page-state.types';
|
|
8
|
+
|
|
9
|
+
export interface PageStateParseInput {
|
|
10
|
+
raw: unknown;
|
|
11
|
+
/** 已声明的数据对象名(`window` 切片只能指向它们) */
|
|
12
|
+
objectNames: readonly string[];
|
|
13
|
+
/** 页面上的锚点 id(`columns` 切片只能指向它们);不给就跳过这一层校验 */
|
|
14
|
+
anchorIds?: readonly string[];
|
|
15
|
+
path: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface PageStateParseDeps {
|
|
19
|
+
fail(message: string, path: string): never;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const CONFIG_KEYS = new Set(['version', 'window', 'columns', 'density', 'expanded', 'initial_state', 'url']);
|
|
23
|
+
const DENSITIES = new Set(['sm', 'md', 'lg']);
|
|
24
|
+
|
|
25
|
+
function isPlainObject(value: unknown): value is Record<string, unknown> {
|
|
26
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function parsePageState(
|
|
30
|
+
input: PageStateParseInput,
|
|
31
|
+
deps: PageStateParseDeps,
|
|
32
|
+
): SomaPageStateConfig {
|
|
33
|
+
const { raw, objectNames, anchorIds, path } = input;
|
|
34
|
+
const fail: (message: string, at: string) => never = deps.fail;
|
|
35
|
+
|
|
36
|
+
if (!isPlainObject(raw)) fail('state 必须是映射', path);
|
|
37
|
+
for (const key of Object.keys(raw)) {
|
|
38
|
+
if (!CONFIG_KEYS.has(key)) {
|
|
39
|
+
fail(`未知的 state 字段 "${key}"(支持: ${[...CONFIG_KEYS].join(' / ')})`, `${path}.${key}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// version 必填:恢复一份旧结构的状态会让界面进入一个谁都没设计过的样子,
|
|
44
|
+
// 而那种坏法是静默的(列还在、但顺序是乱的)。没有版本就没法判断该不该丢弃。
|
|
45
|
+
const version = raw.version;
|
|
46
|
+
if (!Number.isInteger(version) || (version as number) < 1) {
|
|
47
|
+
fail('state.version 必填,且必须是 ≥ 1 的整数(它决定一份旧状态该不该被丢弃)', `${path}.version`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const names = (value: unknown, at: string, allowed: readonly string[], what: string): string[] => {
|
|
51
|
+
if (value === undefined) return [];
|
|
52
|
+
if (!Array.isArray(value)) fail(`${at} 必须是名字数组`, at);
|
|
53
|
+
return (value as unknown[]).map((entry) => {
|
|
54
|
+
const name = String(entry);
|
|
55
|
+
if (!allowed.includes(name)) {
|
|
56
|
+
fail(`${at} 里的 "${name}" 不是${what}(可选:${allowed.join(' / ') || '无'})`, at);
|
|
57
|
+
}
|
|
58
|
+
return name;
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const windows = names(raw.window, `${path}.window`, objectNames, '本页声明过的数据对象');
|
|
63
|
+
const columns = anchorIds === undefined
|
|
64
|
+
? (Array.isArray(raw.columns) ? (raw.columns as unknown[]).map(String) : [])
|
|
65
|
+
: names(raw.columns, `${path}.columns`, anchorIds, '本页的锚点');
|
|
66
|
+
|
|
67
|
+
const config: SomaPageStateConfig = { version: version as number };
|
|
68
|
+
if (windows.length > 0) config.window = windows;
|
|
69
|
+
if (columns.length > 0) config.columns = columns;
|
|
70
|
+
if (raw.density !== undefined) config.density = raw.density === true;
|
|
71
|
+
if (raw.expanded !== undefined) config.expanded = raw.expanded === true;
|
|
72
|
+
if (raw.url !== undefined) config.url = raw.url === true;
|
|
73
|
+
|
|
74
|
+
if (raw.initial_state !== undefined) {
|
|
75
|
+
config.initial_state = parseStateValue(raw.initial_state, `${path}.initial_state`, config, fail);
|
|
76
|
+
}
|
|
77
|
+
return config;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* 校验一份具体的状态值(`initial_state`、URL 还原、`setState` 入参共用)。
|
|
82
|
+
*
|
|
83
|
+
* 越界的切片**丢弃并点名**,而不是整份拒收:一份来自旧版本 URL 的状态里多半只有
|
|
84
|
+
* 一两块对不上,整份丢掉等于让分享链接彻底失效——而它本来还能恢复大半。
|
|
85
|
+
*/
|
|
86
|
+
export function parseStateValue(
|
|
87
|
+
raw: unknown,
|
|
88
|
+
path: string,
|
|
89
|
+
config: SomaPageStateConfig,
|
|
90
|
+
fail: (message: string, at: string) => never,
|
|
91
|
+
): SomaPageState {
|
|
92
|
+
if (!isPlainObject(raw)) fail(`${path} 必须是映射`, path);
|
|
93
|
+
const state: SomaPageState = { version: config.version };
|
|
94
|
+
|
|
95
|
+
if (raw.version !== undefined && raw.version !== config.version) {
|
|
96
|
+
// 版本对不上:这里不抛(`initial_state` 是作者自己写的,抛得有道理;
|
|
97
|
+
// 但同一个函数也服务于 URL 还原,那里抛就等于让一条旧链接打不开页面)。
|
|
98
|
+
// 交给调用方按来源决定,函数只负责如实标注。
|
|
99
|
+
state.version = raw.version as number;
|
|
100
|
+
return state;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (isPlainObject(raw.window)) {
|
|
104
|
+
const allowed = config.window ?? [];
|
|
105
|
+
const windows: Record<string, unknown> = {};
|
|
106
|
+
for (const [name, slice] of Object.entries(raw.window)) {
|
|
107
|
+
if (!allowed.includes(name)) continue; // 越界切片丢弃:见上文
|
|
108
|
+
windows[name] = slice;
|
|
109
|
+
}
|
|
110
|
+
if (Object.keys(windows).length > 0) {
|
|
111
|
+
state.window = windows as unknown as SomaPageState['window'];
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (isPlainObject(raw.columns)) {
|
|
116
|
+
const allowed = config.columns ?? [];
|
|
117
|
+
const columns: Record<string, unknown> = {};
|
|
118
|
+
for (const [name, slice] of Object.entries(raw.columns)) {
|
|
119
|
+
if (!allowed.includes(name)) continue;
|
|
120
|
+
columns[name] = slice;
|
|
121
|
+
}
|
|
122
|
+
if (Object.keys(columns).length > 0) {
|
|
123
|
+
state.columns = columns as unknown as SomaPageState['columns'];
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (config.density && typeof raw.density === 'string' && DENSITIES.has(raw.density)) {
|
|
128
|
+
state.density = raw.density as SomaPageState['density'];
|
|
129
|
+
}
|
|
130
|
+
if (config.expanded && Array.isArray(raw.expanded)) {
|
|
131
|
+
state.expanded = (raw.expanded as unknown[]).map(String);
|
|
132
|
+
}
|
|
133
|
+
return state;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* 页面态 ⇄ URL 的紧凑序列化。
|
|
138
|
+
*
|
|
139
|
+
* 用 base64url 包一层 JSON 而不是把每个切片摊成 query 参数:状态是树形的
|
|
140
|
+
* (`window.orders.filter` 是一棵递归 AST),摊平会得到一串 `window.orders.filter.conditions[0].op=in`
|
|
141
|
+
* 这样的东西——既难读,也会撞上 URL 长度与转义的一堆边角。
|
|
142
|
+
*
|
|
143
|
+
* 不用 `btoa`:它只吃 Latin-1,中文过滤值会直接抛。
|
|
144
|
+
*/
|
|
145
|
+
export function encodePageState(state: SomaPageState): string {
|
|
146
|
+
const json = JSON.stringify(state);
|
|
147
|
+
const bytes = new TextEncoder().encode(json);
|
|
148
|
+
let binary = '';
|
|
149
|
+
for (const byte of bytes) binary += String.fromCharCode(byte);
|
|
150
|
+
return btoa(binary).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** URL → 页面态;坏串返回 null(一条被截断的链接不该让页面打不开) */
|
|
154
|
+
export function decodePageState(encoded: string): SomaPageState | null {
|
|
155
|
+
try {
|
|
156
|
+
const padded = encoded.replace(/-/g, '+').replace(/_/g, '/');
|
|
157
|
+
const binary = atob(padded + '='.repeat((4 - (padded.length % 4)) % 4));
|
|
158
|
+
const bytes = Uint8Array.from(binary, (char) => char.charCodeAt(0));
|
|
159
|
+
const parsed = JSON.parse(new TextDecoder().decode(bytes));
|
|
160
|
+
return isPlainObject(parsed) && typeof parsed.version === 'number'
|
|
161
|
+
? (parsed as unknown as SomaPageState)
|
|
162
|
+
: null;
|
|
163
|
+
} catch {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// core/client/parser/pipeline-parser.ts — SOMA Pipeline DSL 解析器
|
|
2
2
|
// 负责解析 _event.yaml 中的 Pipeline 表达式,将其转换为类型安全的 ParsedEvent 结构
|
|
3
3
|
|
|
4
|
+
import { parseSteps } from './step-parser';
|
|
4
5
|
import type {
|
|
5
6
|
ParsedEvent,
|
|
6
7
|
EventType,
|
|
@@ -32,6 +33,7 @@ const VALID_TYPES = new Set<EventType>([
|
|
|
32
33
|
'NAV_ACTION',
|
|
33
34
|
'UI_REFRESH',
|
|
34
35
|
'UI_INTERACT',
|
|
36
|
+
'ACTION',
|
|
35
37
|
]);
|
|
36
38
|
|
|
37
39
|
/** 支持的 DOM 事件 */
|
|
@@ -42,7 +44,10 @@ const VALID_DOM_EVENTS = new Set<string>([
|
|
|
42
44
|
]);
|
|
43
45
|
|
|
44
46
|
/** 支持的 UI 交互动作 */
|
|
45
|
-
const VALID_ACTIONS = new Set<InteractAction>([
|
|
47
|
+
const VALID_ACTIONS = new Set<InteractAction>([
|
|
48
|
+
'open', 'close', 'toggle',
|
|
49
|
+
'focus', 'scroll_to', 'select',
|
|
50
|
+
]);
|
|
46
51
|
|
|
47
52
|
/** 组件契约 emit 名(两段式触发器放行;运行时由组件管理器标记路由) */
|
|
48
53
|
const EMIT_NAME_PATTERN = /^[a-z][a-z0-9_]*$/;
|
|
@@ -52,6 +57,39 @@ export function isKnownDomEvent(name: string): boolean {
|
|
|
52
57
|
return VALID_DOM_EVENTS.has(name);
|
|
53
58
|
}
|
|
54
59
|
|
|
60
|
+
/** `{ steps: [...] }` 形态识别:值是对象且恰好带一个数组型 `steps` 键 */
|
|
61
|
+
function isStepsDeclaration(value: unknown): value is { steps: unknown[] } {
|
|
62
|
+
return value !== null
|
|
63
|
+
&& typeof value === 'object'
|
|
64
|
+
&& !Array.isArray(value)
|
|
65
|
+
&& Array.isArray((value as { steps?: unknown }).steps);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* 从步骤声明里收集 `when` 引用到的根名,当作载荷字段的作用域。
|
|
70
|
+
*
|
|
71
|
+
* 事件载荷的字段在编译期不可知——它来自组件契约的 emit payload,而 `_event.yaml`
|
|
72
|
+
* 手上没有契约。给空作用域的话,每一条 `when` 都会被判成"引用了不存在的字段",
|
|
73
|
+
* 编排事实上就写不出来了。所以这里放行载荷引用,只保留**槽的前向引用**这条真正
|
|
74
|
+
* 只靠步骤本身就能判的规则;载荷字段名对不对,归组件契约那一侧管。
|
|
75
|
+
*/
|
|
76
|
+
function collectWhenRoots(steps: unknown): string[] {
|
|
77
|
+
const roots = new Set<string>();
|
|
78
|
+
const walk = (node: unknown): void => {
|
|
79
|
+
if (Array.isArray(node)) {
|
|
80
|
+
for (const item of node) walk(item);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
if (node === null || typeof node !== 'object') return;
|
|
84
|
+
for (const [key, value] of Object.entries(node)) {
|
|
85
|
+
if (key === 'field' && typeof value === 'string') roots.add(value.split('.')[0]);
|
|
86
|
+
else walk(value);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
walk(steps);
|
|
90
|
+
return [...roots];
|
|
91
|
+
}
|
|
92
|
+
|
|
55
93
|
/** Pipeline optional confirm segment prefix */
|
|
56
94
|
const CONFIRM_PREFIX = 'confirm:';
|
|
57
95
|
|
|
@@ -249,6 +287,19 @@ export function parsePipelineBody(
|
|
|
249
287
|
result.funcPath = parts[1];
|
|
250
288
|
break;
|
|
251
289
|
|
|
290
|
+
case 'ACTION':
|
|
291
|
+
// `ACTION | <名字>`:名字存不存在由 bootstrap 的注册表判(解析器手上没有注册表)。
|
|
292
|
+
// 这里只保证它是个合法标识符——空名字或带管道符的名字往下传,
|
|
293
|
+
// 报出来的会是「未注册的动作 ""」,那条信息帮不上任何忙。
|
|
294
|
+
if (!parts[1] || !/^[a-z][a-zA-Z0-9_]*$/.test(parts[1])) {
|
|
295
|
+
throw new SomaEventParseError(
|
|
296
|
+
`ACTION 缺少合法的动作名(小写字母开头的标识符),收到 "${parts[1] ?? ''}"`,
|
|
297
|
+
expression,
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
result.funcPath = parts[1];
|
|
301
|
+
break;
|
|
302
|
+
|
|
252
303
|
case 'UI_INTERACT':
|
|
253
304
|
result.targetId = parts[1] || undefined;
|
|
254
305
|
result.funcPath = parts[2] || null;
|
|
@@ -344,6 +395,30 @@ export function parseEventConfig(
|
|
|
344
395
|
}
|
|
345
396
|
throw error;
|
|
346
397
|
}
|
|
398
|
+
} else if (isStepsDeclaration(value)) {
|
|
399
|
+
// 编排事件(REQ-010 F-13):`{ steps: [...] }`。
|
|
400
|
+
// 它长得像"嵌套层级",所以必须先于递归分支判掉——否则 `steps` 会被当成
|
|
401
|
+
// 一个子锚点名递归下去,而数组值又不是字符串,于是整条声明被静默丢弃。
|
|
402
|
+
const { somaId, domEvent, keyModifier } = parseSelector(key);
|
|
403
|
+
const graph = parseSteps(
|
|
404
|
+
{
|
|
405
|
+
raw: (value as { steps: unknown }).steps,
|
|
406
|
+
// 事件载荷的字段在编译期不可知(它来自组件契约的 emit payload)。
|
|
407
|
+
// 给空作用域会把所有 `when` 都判成越界,所以这里放行载荷引用、
|
|
408
|
+
// 只校验槽的前向引用——载荷字段名的校验归组件契约那一侧。
|
|
409
|
+
payloadFields: collectWhenRoots((value as { steps: unknown }).steps),
|
|
410
|
+
path: `${[...parentPath, key].join(' > ')}.steps`,
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
fail(message: string): never {
|
|
414
|
+
throw new SomaEventParseError(message, key);
|
|
415
|
+
},
|
|
416
|
+
parsePipeline: parsePipelineBody,
|
|
417
|
+
},
|
|
418
|
+
);
|
|
419
|
+
const event: ParsedEvent = { somaId, domEvent, type: 'STEPS', steps: graph };
|
|
420
|
+
if (keyModifier) event.keyModifier = keyModifier;
|
|
421
|
+
events.push(event);
|
|
347
422
|
} else if (typeof value === 'object' && value !== null) {
|
|
348
423
|
// 嵌套层级:递归解析
|
|
349
424
|
events.push(
|