soma-core 1.4.0 → 1.4.2
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 +2053 -23
- package/core/build/component/component-graph.ts +208 -0
- package/core/build/component/package-loader.ts +32 -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 +270 -0
- package/core/client/base/SomaHttpClient.ts +34 -1
- package/core/client/base/SomaPageRootBase.ts +61 -0
- package/core/client/component/ai-catalog.ts +121 -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/component/verify-pack.ts +120 -1
- package/core/client/container/SomaContainerAdapter.ts +6 -2
- 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/infra/http/SomaHttpService.ts +2 -2
- 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 +184 -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/component/derive-sample.ts +105 -0
- package/core/shared/component/field-lines.ts +473 -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 +151 -9
- 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 +5529 -631
- 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/SomaHttpClient.d.ts +8 -0
- package/dist/types/client/base/SomaPageRootBase.d.ts +28 -0
- package/dist/types/client/component/ai-catalog.d.ts +33 -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/component/verify-pack.d.ts +10 -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 +35 -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/component/derive-sample.d.ts +23 -0
- package/dist/types/shared/component/field-lines.d.ts +19 -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 +134 -6
- 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 +3 -2
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
// `window:` 段解析(REQ-010 S2)——把「怎么取这一屏」的意图编译成可校验的请求形状。
|
|
2
|
+
//
|
|
3
|
+
// 五步(《架构设计》§6.2):过滤 AST → 字段引用 → 选择态 → 派生列 → 字典哈希。
|
|
4
|
+
// 每一步的失败都在**声明期**抛,因为窗口的错误在运行期是看不见的:
|
|
5
|
+
// 一条 `op` 与字段类型不配的过滤条件,后端多半会照着执行并返回一个空列表,
|
|
6
|
+
// 而空列表和「这个条件确实没命中」长得一模一样。
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
SOMA_AGGREGATE_FNS,
|
|
10
|
+
SOMA_SELECT_ALL_MODES,
|
|
11
|
+
type SomaAggregateFn,
|
|
12
|
+
type SomaFilterNode,
|
|
13
|
+
type SomaSelectAllMode,
|
|
14
|
+
type SomaWindowAggregate,
|
|
15
|
+
type SomaWindowConfig,
|
|
16
|
+
type SomaWindowSelection,
|
|
17
|
+
type SomaWindowSort,
|
|
18
|
+
} from '../../shared/types/window.types';
|
|
19
|
+
import type { SomaDataFieldConfig } from '../../shared/types/data-config.types';
|
|
20
|
+
import { validatePredicate } from '../../shared/predicates';
|
|
21
|
+
import { parseDuration } from './duration';
|
|
22
|
+
|
|
23
|
+
export interface WindowParseInput {
|
|
24
|
+
raw: unknown;
|
|
25
|
+
fields: Record<string, SomaDataFieldConfig>;
|
|
26
|
+
path: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface WindowParseDeps {
|
|
30
|
+
fail(message: string, path: string): never;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** 过滤 AST 允许的最大嵌套层数——与谓词图同值,理由也相同:再深就没人读得懂了 */
|
|
34
|
+
const MAX_FILTER_DEPTH = 8;
|
|
35
|
+
|
|
36
|
+
const CONFIG_KEYS = new Set([
|
|
37
|
+
'mode', 'block', 'sort', 'filter', 'group', 'aggregate',
|
|
38
|
+
'selection', 'select_all', 'cache', 'revalidate',
|
|
39
|
+
]);
|
|
40
|
+
|
|
41
|
+
/** 只有这些字段类型能被聚合(`count` 除外,它数的是行不是值) */
|
|
42
|
+
const NUMERIC_TYPES = new Set(['int', 'float', 'money', 'percent', 'progress']);
|
|
43
|
+
|
|
44
|
+
const DEFAULT_BLOCK = { size: 100, max_blocks: 10, debounce_ms: 120 } as const;
|
|
45
|
+
|
|
46
|
+
function isPlainObject(value: unknown): value is Record<string, unknown> {
|
|
47
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function parseWindow(input: WindowParseInput, deps: WindowParseDeps): SomaWindowConfig {
|
|
51
|
+
const { raw, fields, path } = input;
|
|
52
|
+
// 显式标注类型:解构出来的 `deps.fail` 不带控制流断言,TS 不会认为
|
|
53
|
+
// `if (!ok) fail(...)` 之后 `ok` 已收窄。少了这一行,下面每一处
|
|
54
|
+
// `fail` 兜底之后的类型收窄全部失效(而收窄失效的表现是十几条无关的类型错)。
|
|
55
|
+
const fail: (message: string, at: string) => never = deps.fail;
|
|
56
|
+
|
|
57
|
+
if (!isPlainObject(raw)) fail('window 必须是映射', path);
|
|
58
|
+
const section = raw as Record<string, unknown>;
|
|
59
|
+
|
|
60
|
+
for (const key of Object.keys(section)) {
|
|
61
|
+
if (!CONFIG_KEYS.has(key)) {
|
|
62
|
+
fail(`未知的 window 字段 "${key}"(支持: ${[...CONFIG_KEYS].join(' / ')})`, `${path}.${key}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// ── mode:只有 server ────────────────────────────────────────────────
|
|
67
|
+
// 客户端窗口不做。它与「业务逻辑归后端」直接冲突:一旦前端持有全量数据并自己
|
|
68
|
+
// 排序筛选,后端就失去了对"这个用户能看到哪些行"的最终裁决权。
|
|
69
|
+
const mode = section.mode === undefined ? 'server' : String(section.mode);
|
|
70
|
+
if (mode !== 'server') {
|
|
71
|
+
fail(`window.mode 只能是 server(收到 "${mode}")——客户端窗口不做,见《数据对象层》§11`, `${path}.mode`);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const fieldKeys = Object.keys(fields);
|
|
75
|
+
const fieldTypes: Record<string, string | undefined> = Object.fromEntries(
|
|
76
|
+
fieldKeys.map((key) => [key, fields[key].type]),
|
|
77
|
+
);
|
|
78
|
+
/** 字段引用统一在这里落地:报错要说清"有哪些可选",否则作者只能去翻另一个文件 */
|
|
79
|
+
const requireField = (name: unknown, at: string): string => {
|
|
80
|
+
const key = String(name ?? '');
|
|
81
|
+
if (!fieldKeys.includes(key)) {
|
|
82
|
+
fail(`${at} 引用了不存在的字段 "${key}"(本对象字典:${fieldKeys.join(' / ') || '空'})`, at);
|
|
83
|
+
}
|
|
84
|
+
return key;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
// ── 步 1:过滤 AST ───────────────────────────────────────────────────
|
|
88
|
+
const parseFilter = (node: unknown, at: string, depth: number): SomaFilterNode => {
|
|
89
|
+
if (depth > MAX_FILTER_DEPTH) {
|
|
90
|
+
fail(`${at} 的过滤条件嵌套超过 ${MAX_FILTER_DEPTH} 层——再深就没人读得懂了`, at);
|
|
91
|
+
}
|
|
92
|
+
if (!isPlainObject(node)) fail(`${at} 必须是映射`, at);
|
|
93
|
+
|
|
94
|
+
if ('join' in node || 'conditions' in node) {
|
|
95
|
+
// `in` 收窄出来的是两个只含单键的 Record 的联合,读另一个键会被 TS 拒。
|
|
96
|
+
// 这里要的是「原始映射」而不是收窄结果,所以显式取一个宽类型的别名。
|
|
97
|
+
const branch = node as { join?: unknown; conditions?: unknown };
|
|
98
|
+
const join = String(branch.join ?? '');
|
|
99
|
+
if (join !== 'and' && join !== 'or') {
|
|
100
|
+
fail(`${at}.join 只能是 and / or(收到 ${JSON.stringify(branch.join)})`, `${at}.join`);
|
|
101
|
+
}
|
|
102
|
+
if (!Array.isArray(branch.conditions) || branch.conditions.length === 0) {
|
|
103
|
+
fail(`${at}.conditions 必须是非空数组`, `${at}.conditions`);
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
join: join as 'and' | 'or',
|
|
107
|
+
conditions: (branch.conditions as unknown[]).map(
|
|
108
|
+
(child, index) => parseFilter(child, `${at}.conditions[${index}]`, depth + 1),
|
|
109
|
+
),
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// 叶子:整条交给谓词图校验器,算子闭集与算子×类型配对都在那里,只有一份
|
|
114
|
+
const issues = validatePredicate(node, fieldKeys, at, { fieldTypes });
|
|
115
|
+
if (issues.length > 0) fail(issues.join(';'), at);
|
|
116
|
+
const leaf = node as { field: unknown; op: unknown; value?: unknown };
|
|
117
|
+
return {
|
|
118
|
+
field: String(leaf.field),
|
|
119
|
+
op: leaf.op as SomaFilterNode extends { op: infer O } ? O : never,
|
|
120
|
+
...(leaf.value === undefined ? {} : { value: leaf.value }),
|
|
121
|
+
} as SomaFilterNode;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const filter = section.filter === undefined || section.filter === null
|
|
125
|
+
? null
|
|
126
|
+
: parseFilter(section.filter, `${path}.filter`, 1);
|
|
127
|
+
|
|
128
|
+
// ── 步 2:sort / group / aggregate 的字段与函数 ──────────────────────
|
|
129
|
+
const sort: SomaWindowSort[] = [];
|
|
130
|
+
if (section.sort !== undefined) {
|
|
131
|
+
if (!Array.isArray(section.sort)) fail(`${path}.sort 必须是数组`, `${path}.sort`);
|
|
132
|
+
(section.sort as unknown[]).forEach((entry, index) => {
|
|
133
|
+
const at = `${path}.sort[${index}]`;
|
|
134
|
+
if (!isPlainObject(entry)) fail(`${at} 必须是 { field, order }`, at);
|
|
135
|
+
const order = String(entry.order ?? 'asc');
|
|
136
|
+
if (order !== 'asc' && order !== 'desc') {
|
|
137
|
+
fail(`${at}.order 只能是 asc / desc(收到 ${JSON.stringify(entry.order)})`, `${at}.order`);
|
|
138
|
+
}
|
|
139
|
+
sort.push({ field: requireField(entry.field, `${at}.field`), order: order as 'asc' | 'desc' });
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
let group: SomaWindowConfig['group'] = null;
|
|
144
|
+
if (section.group !== undefined && section.group !== null) {
|
|
145
|
+
const at = `${path}.group`;
|
|
146
|
+
if (!isPlainObject(section.group)) fail(`${at} 必须是 { by, keys? }`, at);
|
|
147
|
+
const by = section.group.by;
|
|
148
|
+
if (!Array.isArray(by) || by.length === 0) fail(`${at}.by 必须是非空数组`, `${at}.by`);
|
|
149
|
+
const keys = section.group.keys ?? [];
|
|
150
|
+
if (!Array.isArray(keys)) fail(`${at}.keys 必须是数组`, `${at}.keys`);
|
|
151
|
+
if (keys.length > by.length) {
|
|
152
|
+
// keys 是「展开到哪一层」的路径,它不可能比分组层数还深
|
|
153
|
+
fail(
|
|
154
|
+
`${at}.keys 有 ${keys.length} 段,但只按 ${by.length} 个字段分组——`
|
|
155
|
+
+ '展开路径不可能比分组层数深',
|
|
156
|
+
`${at}.keys`,
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
group = {
|
|
160
|
+
by: (by as unknown[]).map((name, index) => requireField(name, `${at}.by[${index}]`)),
|
|
161
|
+
keys: (keys as unknown[]).map((key) => String(key)),
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const aggregate: SomaWindowAggregate[] = [];
|
|
166
|
+
if (section.aggregate !== undefined) {
|
|
167
|
+
if (!Array.isArray(section.aggregate)) fail(`${path}.aggregate 必须是数组`, `${path}.aggregate`);
|
|
168
|
+
(section.aggregate as unknown[]).forEach((entry, index) => {
|
|
169
|
+
const at = `${path}.aggregate[${index}]`;
|
|
170
|
+
if (!isPlainObject(entry)) fail(`${at} 必须是 { field, fn }`, at);
|
|
171
|
+
const fn = String(entry.fn ?? '');
|
|
172
|
+
if (!(SOMA_AGGREGATE_FNS as readonly string[]).includes(fn)) {
|
|
173
|
+
fail(`${at}.fn 只能是 ${SOMA_AGGREGATE_FNS.join(' / ')}(收到 ${JSON.stringify(entry.fn)})`, `${at}.fn`);
|
|
174
|
+
}
|
|
175
|
+
const field = requireField(entry.field, `${at}.field`);
|
|
176
|
+
const type = fieldTypes[field] ?? '';
|
|
177
|
+
// count 数的是行,什么类型都能数;其余四个是算术,非数值型上求和是没有意义的
|
|
178
|
+
if (fn !== 'count' && !NUMERIC_TYPES.has(type)) {
|
|
179
|
+
fail(
|
|
180
|
+
`${at}.fn=${fn} 不能用在 ${type || '未声明类型'} 的字段 "${field}" 上`
|
|
181
|
+
+ `(只有 ${[...NUMERIC_TYPES].join(' / ')} 能求和求均;要数行数请用 count)`,
|
|
182
|
+
`${at}.fn`,
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
aggregate.push({ field, fn: fn as SomaAggregateFn });
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// ── 步 3:选择态 ────────────────────────────────────────────────────
|
|
190
|
+
let selection: SomaWindowSelection = { base: 'none', toggled: [] };
|
|
191
|
+
if (section.selection !== undefined) {
|
|
192
|
+
const at = `${path}.selection`;
|
|
193
|
+
if (!isPlainObject(section.selection)) fail(`${at} 必须是 { base, toggled }`, at);
|
|
194
|
+
const base = String(section.selection.base ?? 'none');
|
|
195
|
+
if (base !== 'none' && base !== 'all') {
|
|
196
|
+
fail(`${at}.base 只能是 none / all(收到 ${JSON.stringify(section.selection.base)})`, `${at}.base`);
|
|
197
|
+
}
|
|
198
|
+
const toggled = section.selection.toggled ?? [];
|
|
199
|
+
if (!Array.isArray(toggled)) fail(`${at}.toggled 必须是数组`, `${at}.toggled`);
|
|
200
|
+
selection = { base: base as 'none' | 'all', toggled: (toggled as unknown[]).map((id) => String(id)) };
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const selectAll = String(section.select_all ?? 'filtered');
|
|
204
|
+
if (!(SOMA_SELECT_ALL_MODES as readonly string[]).includes(selectAll)) {
|
|
205
|
+
fail(
|
|
206
|
+
`${path}.select_all 只能是 ${SOMA_SELECT_ALL_MODES.join(' / ')}(收到 ${JSON.stringify(section.select_all)})`,
|
|
207
|
+
`${path}.select_all`,
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
// `current_page` 与「基线全选」在语义上互斥:只选当前页却又声明基线是"全部",
|
|
211
|
+
// 两个读者会读出两个意思,而这条歧义会在批量删除时兑现。
|
|
212
|
+
if (selectAll === 'current_page' && selection.base === 'all') {
|
|
213
|
+
fail(
|
|
214
|
+
`${path}.select_all=current_page 与 selection.base=all 冲突——`
|
|
215
|
+
+ '只选当前页时基线只能是 none(否则"全选"到底指哪些行说不清)',
|
|
216
|
+
`${path}.select_all`,
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// ── 步 4:块 / 缓存 / 重验证 ────────────────────────────────────────
|
|
221
|
+
const block = { ...DEFAULT_BLOCK } as { size: number; max_blocks: number; debounce_ms: number };
|
|
222
|
+
if (section.block !== undefined) {
|
|
223
|
+
const at = `${path}.block`;
|
|
224
|
+
if (!isPlainObject(section.block)) fail(`${at} 必须是映射`, at);
|
|
225
|
+
const positive = (raw2: unknown, key: string, fallback: number): number => {
|
|
226
|
+
if (raw2 === undefined) return fallback;
|
|
227
|
+
const value = Number(raw2);
|
|
228
|
+
if (!Number.isInteger(value) || value <= 0) {
|
|
229
|
+
fail(`${at}.${key} 必须是正整数(收到 ${JSON.stringify(raw2)})`, `${at}.${key}`);
|
|
230
|
+
}
|
|
231
|
+
return value;
|
|
232
|
+
};
|
|
233
|
+
block.size = positive(section.block.size, 'size', DEFAULT_BLOCK.size);
|
|
234
|
+
block.max_blocks = positive(section.block.max_blocks, 'max_blocks', DEFAULT_BLOCK.max_blocks);
|
|
235
|
+
block.debounce_ms = section.block.debounce === undefined
|
|
236
|
+
? DEFAULT_BLOCK.debounce_ms
|
|
237
|
+
: parseDuration(String(section.block.debounce), `${at}.debounce`, (m) => fail(m, `${at}.debounce`));
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const cache = { ttl_ms: null as number | null, keep_previous: false };
|
|
241
|
+
if (section.cache !== undefined) {
|
|
242
|
+
const at = `${path}.cache`;
|
|
243
|
+
if (!isPlainObject(section.cache)) fail(`${at} 必须是 { ttl?, keep_previous? }`, at);
|
|
244
|
+
if (section.cache.ttl !== undefined) {
|
|
245
|
+
cache.ttl_ms = parseDuration(String(section.cache.ttl), `${at}.ttl`, (m) => fail(m, `${at}.ttl`));
|
|
246
|
+
}
|
|
247
|
+
cache.keep_previous = section.cache.keep_previous === true;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
const revalidateMs = section.revalidate === undefined
|
|
251
|
+
? null
|
|
252
|
+
: parseDuration(String(section.revalidate), `${path}.revalidate`, (m) => fail(m, `${path}.revalidate`));
|
|
253
|
+
|
|
254
|
+
return {
|
|
255
|
+
mode: 'server',
|
|
256
|
+
block,
|
|
257
|
+
sort,
|
|
258
|
+
filter,
|
|
259
|
+
group,
|
|
260
|
+
aggregate,
|
|
261
|
+
selection,
|
|
262
|
+
select_all: selectAll as SomaSelectAllMode,
|
|
263
|
+
cache,
|
|
264
|
+
revalidate_ms: revalidateMs,
|
|
265
|
+
dict_hash: dictHash(fields),
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* 字段字典的稳定哈希:字段名 + 类型 + 权限。
|
|
271
|
+
*
|
|
272
|
+
* 随每个请求下发,让后端能拒收「按一份它不认识的字典发来的意图」——这是本层唯一
|
|
273
|
+
* 对方结构上做不到的事(AG Grid 的列是函数,没有可哈希的字典)。
|
|
274
|
+
*
|
|
275
|
+
* 只取名/类型/权限三项:它们决定了**哪些意图是合法的**(能不能排序、能不能求和、
|
|
276
|
+
* 能不能进请求体)。`name` 这类展示位改了不该让后端拒收——那会把一次文案调整变成一次
|
|
277
|
+
* 前后端联合发布。字段先按名排序,声明顺序变化不改哈希,同理。
|
|
278
|
+
*
|
|
279
|
+
* 用 FNV-1a 而不是 sha256:这里要的是「字典变了没有」的指纹,不是抗碰撞的安全摘要,
|
|
280
|
+
* 而 `crypto.subtle` 是异步的——为一个同步的解析步骤引入异步是不划算的交换。
|
|
281
|
+
*/
|
|
282
|
+
export function dictHash(fields: Record<string, SomaDataFieldConfig>): string {
|
|
283
|
+
const canonical = Object.keys(fields)
|
|
284
|
+
.sort()
|
|
285
|
+
.map((key) => `${key}:${fields[key].type ?? ''}:${fields[key].permission ?? ''}`)
|
|
286
|
+
.join('|');
|
|
287
|
+
let hash = 0x811c9dc5;
|
|
288
|
+
for (let index = 0; index < canonical.length; index += 1) {
|
|
289
|
+
hash ^= canonical.charCodeAt(index);
|
|
290
|
+
// FNV 素数 16777619,用移位加法写以避免 32 位溢出丢精度
|
|
291
|
+
hash = (hash + (hash << 1) + (hash << 4) + (hash << 7) + (hash << 8) + (hash << 24)) >>> 0;
|
|
292
|
+
}
|
|
293
|
+
return `fnv1a-${hash.toString(16).padStart(8, '0')}`;
|
|
294
|
+
}
|
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
type SomaToneName,
|
|
34
34
|
} from './harmony';
|
|
35
35
|
import { ensureContrast } from './tone-solver';
|
|
36
|
+
import { componentTokenVar } from '../../shared/types/component-contract.types';
|
|
36
37
|
import { sceneColorTokens, sceneStructureTokens } from './scene-tokens';
|
|
37
38
|
|
|
38
39
|
export type { SomaPaletteAxes, SomaSceneAxes, SomaResolvedAxes } from './theme-axes';
|
|
@@ -65,6 +66,23 @@ export interface SomaThemeInput {
|
|
|
65
66
|
* 缺省不给 = 行为与之前字节级一致(不影响任何既有预设)。
|
|
66
67
|
*/
|
|
67
68
|
darkOverrides?: Record<string, string>;
|
|
69
|
+
/**
|
|
70
|
+
* 组件级令牌覆盖(REQ-009 M-1):组件名 → { 令牌名: 值 }。
|
|
71
|
+
*
|
|
72
|
+
* 这是三级令牌的第三级在主题输入侧的入口。它存在的理由:今天想只改 Button 的圆角,
|
|
73
|
+
* 只能改全局 `--soma-radius-control`,于是**所有 control 族**跟着变。
|
|
74
|
+
*
|
|
75
|
+
* 与 MUI 的 `theme.components.MuiX.styleOverrides.<slot>` 的关键差别:
|
|
76
|
+
* 这里能改的只有**组件自己在契约 `tokens` 段声明过的旋钮**,
|
|
77
|
+
* 而不是任意内部元素的任意 CSS 声明。组件内部结构仍然封闭
|
|
78
|
+
* (页面永不可寻址组件内部,`scopeAnchors()` 的既定边界)。
|
|
79
|
+
*
|
|
80
|
+
* 引擎不认识组件,所以这里只做展平;「组件名 / 令牌名是否存在」由装配层的
|
|
81
|
+
* `validateThemeComponentTokens` 在 bootstrap 期核对契约。
|
|
82
|
+
*/
|
|
83
|
+
components?: Record<string, Record<string, string>>;
|
|
84
|
+
/** 组件令牌的暗色专属覆盖:与 `darkOverrides` 同一纪律,只并进 darkCssVars */
|
|
85
|
+
darkComponents?: Record<string, Record<string, string>>;
|
|
68
86
|
}
|
|
69
87
|
|
|
70
88
|
export interface SomaThemeMeta {
|
|
@@ -74,6 +92,8 @@ export interface SomaThemeMeta {
|
|
|
74
92
|
readonly separationApplied: boolean;
|
|
75
93
|
/** 被推开的语气 */
|
|
76
94
|
readonly pushed: readonly SomaToneName[];
|
|
95
|
+
/** 本次写出的组件级令牌变量名(M-1)——快照与闸门的观测面 */
|
|
96
|
+
readonly componentTokens: readonly string[];
|
|
77
97
|
}
|
|
78
98
|
|
|
79
99
|
export interface SomaDerivedTheme {
|
|
@@ -497,7 +517,7 @@ function chartSeries(
|
|
|
497
517
|
// 12~24px 的字阶)全部是 16 的整数分之一倍,换算**无一需要取整**,
|
|
498
518
|
// 因此 16px 根字号下输出值与迁移前逐令牌恒等,视觉基线零 diff。
|
|
499
519
|
const STATIC_TOKENS: Record<string, string> = {
|
|
500
|
-
// 字体排印:系统栈 +
|
|
520
|
+
// 字体排印:系统栈 + 八档字号 + AntD 标准行高 + 三档字重
|
|
501
521
|
'--soma-font-family':
|
|
502
522
|
"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif",
|
|
503
523
|
'--soma-font-size-xs': '0.75rem', // 12px
|
|
@@ -506,6 +526,10 @@ const STATIC_TOKENS: Record<string, string> = {
|
|
|
506
526
|
'--soma-font-size-lg': '1.125rem', // 18px
|
|
507
527
|
'--soma-font-size-xl': '1.25rem', // 20px
|
|
508
528
|
'--soma-font-size-xxl': '1.5rem', // 24px
|
|
529
|
+
// 页头/落地页标题用的两级。加在这里而不是让组件写死回退值:
|
|
530
|
+
// 写死的话换肤对标题字号无效,而"无效"看不出来——回退值本身就是个合理的数。
|
|
531
|
+
'--soma-font-size-3xl': '1.875rem', // 30px
|
|
532
|
+
'--soma-font-size-4xl': '2.25rem', // 36px
|
|
509
533
|
// 行高三档齐(tight 给标题 / KPI 大数字 / 控件单行文本,base 给正文与一切默认,
|
|
510
534
|
// loose 给成段长文阅读区)。行高由本层**独占**:soma-ui 不得再置
|
|
511
535
|
// `--soma-ui-line-height-*` 同义副本——排版阶梯换一套组件库也不该丢,
|
|
@@ -1065,6 +1089,15 @@ export function deriveTheme(input: SomaThemeInput): SomaDerivedTheme {
|
|
|
1065
1089
|
Object.assign(cssVars, sceneColorTokens(cssVars, axes, params.fieldAlphas, hexWithAlpha, scale, rescale));
|
|
1066
1090
|
Object.assign(darkCssVars, sceneColorTokens(darkCssVars, axes, params.fieldAlphas, hexWithAlpha, scale, darkRescale));
|
|
1067
1091
|
|
|
1092
|
+
// ⑦ 组件级令牌(M-1):排在最后——它是「在最终语义令牌之上再收窄一档」,
|
|
1093
|
+
// 所以必须看得见 overrides 与场景色的最终结果。亮暗分列与 ⑥ 同纪律。
|
|
1094
|
+
const lightComponentTokens = flattenComponentTokens(input.components);
|
|
1095
|
+
const darkComponentTokens = flattenComponentTokens(
|
|
1096
|
+
input.darkComponents ? mergeComponentTokens(input.components, input.darkComponents) : input.components,
|
|
1097
|
+
);
|
|
1098
|
+
Object.assign(cssVars, lightComponentTokens);
|
|
1099
|
+
Object.assign(darkCssVars, darkComponentTokens);
|
|
1100
|
+
|
|
1068
1101
|
return {
|
|
1069
1102
|
scale,
|
|
1070
1103
|
cssVars,
|
|
@@ -1073,10 +1106,77 @@ export function deriveTheme(input: SomaThemeInput): SomaDerivedTheme {
|
|
|
1073
1106
|
primaryFg: contrastRatio(cssVars['--soma-c-primary'], cssVars['--soma-c-primary-fg']),
|
|
1074
1107
|
darkPrimaryFg: contrastRatio(darkCssVars['--soma-c-primary'], darkCssVars['--soma-c-primary-fg']),
|
|
1075
1108
|
},
|
|
1076
|
-
meta: {
|
|
1109
|
+
meta: {
|
|
1110
|
+
axes,
|
|
1111
|
+
separationApplied: guard.applied,
|
|
1112
|
+
pushed: guard.pushed,
|
|
1113
|
+
componentTokens: Object.keys({ ...lightComponentTokens, ...darkComponentTokens }).sort(),
|
|
1114
|
+
},
|
|
1077
1115
|
};
|
|
1078
1116
|
}
|
|
1079
1117
|
|
|
1118
|
+
/**
|
|
1119
|
+
* 组件令牌表 → CSS 变量表:{ Button: { radius: 'var(--soma-radius-pill)' } }
|
|
1120
|
+
* → { '--soma-button-radius': 'var(--soma-radius-pill)' }
|
|
1121
|
+
*
|
|
1122
|
+
* 值必须是令牌引用或几何字面量。裸色值在这里就拦下——它是零裸色值禁令的延伸:
|
|
1123
|
+
* 组件令牌若能写死颜色,换肤就在这一层破了口子,而且破得很隐蔽(只有那一个组件不跟随)。
|
|
1124
|
+
*/
|
|
1125
|
+
function flattenComponentTokens(
|
|
1126
|
+
input: Record<string, Record<string, string>> | undefined,
|
|
1127
|
+
): Record<string, string> {
|
|
1128
|
+
if (!input) return {};
|
|
1129
|
+
const result: Record<string, string> = {};
|
|
1130
|
+
for (const [componentName, tokens] of Object.entries(input)) {
|
|
1131
|
+
for (const [key, value] of Object.entries(tokens ?? {})) {
|
|
1132
|
+
assertComponentTokenValue(componentName, key, value);
|
|
1133
|
+
result[componentTokenVar(componentName, key)] = value;
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
return result;
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
function mergeComponentTokens(
|
|
1140
|
+
base: Record<string, Record<string, string>> | undefined,
|
|
1141
|
+
patch: Record<string, Record<string, string>>,
|
|
1142
|
+
): Record<string, Record<string, string>> {
|
|
1143
|
+
const result: Record<string, Record<string, string>> = {};
|
|
1144
|
+
for (const [name, tokens] of Object.entries(base ?? {})) result[name] = { ...tokens };
|
|
1145
|
+
for (const [name, tokens] of Object.entries(patch)) {
|
|
1146
|
+
result[name] = { ...(result[name] ?? {}), ...tokens };
|
|
1147
|
+
}
|
|
1148
|
+
return result;
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
/** 裸色值检测:#hex / rgb() / hsl() / oklch() / 具名色都不许直接写进组件令牌 */
|
|
1152
|
+
const NAKED_COLOR_PATTERN = /(^|[\s(,])(#[0-9a-fA-F]{3,8}\b|(rgba?|hsla?|oklch|oklab|lab|lch|color-mix)\s*\()/;
|
|
1153
|
+
|
|
1154
|
+
function assertComponentTokenValue(componentName: string, key: string, value: string): void {
|
|
1155
|
+
if (typeof value !== 'string' || !value.trim()) {
|
|
1156
|
+
throw new Error(
|
|
1157
|
+
`[soma-core][主题] 组件令牌 ${componentName}.${key} 的值必须是非空字符串`,
|
|
1158
|
+
);
|
|
1159
|
+
}
|
|
1160
|
+
if (NAKED_COLOR_PATTERN.test(value)) {
|
|
1161
|
+
throw new Error(
|
|
1162
|
+
`[soma-core][主题] 组件令牌 ${componentName}.${key} 写了裸色值 "${value}"。`
|
|
1163
|
+
+ '\n 组件令牌是语义令牌的收窄,不是新的颜色真源——'
|
|
1164
|
+
+ '写死颜色会让这一个组件不跟随换肤,而且很难发现。请改写 var(--soma-…)。',
|
|
1165
|
+
);
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
/**
|
|
1170
|
+
* 引擎会写出的令牌名全集(静态令牌 + 派生令牌),不跑派生。
|
|
1171
|
+
*
|
|
1172
|
+
* 给 soma-ui 的 `token-existence-lint` 用:契约 `tokens.default` 引用的语义令牌
|
|
1173
|
+
* 必须真的存在,否则组件令牌指向一个空变量,回退值一路生效而没人发现。
|
|
1174
|
+
*/
|
|
1175
|
+
export function listThemeTokenNames(): readonly string[] {
|
|
1176
|
+
const probe = deriveTheme({ brand: '#2563eb' });
|
|
1177
|
+
return Object.keys({ ...probe.cssVars, ...probe.darkCssVars }).sort();
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1080
1180
|
/**
|
|
1081
1181
|
* 派生结果 → 根元素属性。
|
|
1082
1182
|
*
|
package/core/index.ts
CHANGED
|
@@ -20,6 +20,12 @@ export type {
|
|
|
20
20
|
export { SomaComponentRegistry } from './client/component/component-registry';
|
|
21
21
|
export { SomaComponentManager } from './client/component/component-manager';
|
|
22
22
|
export { generateAiCatalog, buildCatalogEntry } from './client/component/ai-catalog';
|
|
23
|
+
export {
|
|
24
|
+
deriveKeyboardMatrix,
|
|
25
|
+
renderKeyboardMatrixLine,
|
|
26
|
+
SOMA_KEYBOARD_INTENTS,
|
|
27
|
+
} from './client/component/keyboard-matrix';
|
|
28
|
+
export type { SomaKeyboardIntent, SomaKeyboardMatrixRow } from './client/component/keyboard-matrix';
|
|
23
29
|
export type {
|
|
24
30
|
SomaAiCatalog,
|
|
25
31
|
SomaAiCatalogEntry,
|
|
@@ -57,6 +63,12 @@ export type {
|
|
|
57
63
|
SomaDataFieldType,
|
|
58
64
|
SomaDataFieldPermission,
|
|
59
65
|
SomaDataDicts,
|
|
66
|
+
// 写通道(REQ-009 M-5):自治组件按结构消费 data 端口,这三个类型必须公开,
|
|
67
|
+
// 否则每个消费方只能本地重声明一份结构型——那正是「同一个概念多份抄本」的起点
|
|
68
|
+
SomaDataWriteConfig,
|
|
69
|
+
SomaDataWriteEndpoint,
|
|
70
|
+
SomaDataSubmitResult,
|
|
71
|
+
SomaDataPort,
|
|
60
72
|
} from './shared/types/data-config.types';
|
|
61
73
|
// 字段类型的唯一真源(值导出):块解析器与 soma-ui 的双态映射表都消费它,
|
|
62
74
|
// 消费方不得再手抄一份清单——四份手写副本里漏改一份,就是「一处合法、一处静默按 text 渲染」。
|
|
@@ -64,6 +76,147 @@ export {
|
|
|
64
76
|
SOMA_DATA_FIELD_TYPES,
|
|
65
77
|
SOMA_DATA_FIELD_TYPE_ALIASES,
|
|
66
78
|
} from './shared/types/data-config.types';
|
|
79
|
+
|
|
80
|
+
// 字段谓词图(REQ-010 S1b):三个消费者共用的封闭布尔代数——
|
|
81
|
+
// RG 反应图的 when、DW 过滤 AST 的叶子、soma-ui 表单的 visible_when。
|
|
82
|
+
// 真源住在 core 是因为 core 不能反向依赖 ui,而三处各判一次必然判得不一样。
|
|
83
|
+
export {
|
|
84
|
+
SOMA_FIELD_PREDICATE_OPS,
|
|
85
|
+
evaluatePredicate,
|
|
86
|
+
validatePredicate,
|
|
87
|
+
validateNamedPredicates,
|
|
88
|
+
collectPredicateFields,
|
|
89
|
+
} from './shared/predicates';
|
|
90
|
+
export type {
|
|
91
|
+
SomaFieldPredicateOp,
|
|
92
|
+
SomaFieldCondition,
|
|
93
|
+
SomaFieldPredicateRef,
|
|
94
|
+
SomaFieldPredicateAllOf,
|
|
95
|
+
SomaFieldPredicateAnyOf,
|
|
96
|
+
SomaFieldPredicateNoneOf,
|
|
97
|
+
SomaFieldPredicate,
|
|
98
|
+
SomaNamedPredicates,
|
|
99
|
+
SomaPredicateValidateOptions,
|
|
100
|
+
} from './shared/predicates';
|
|
101
|
+
|
|
102
|
+
// calc 表达式层(REQ-010 S1a):派生列与反应图 `value: { calc }` 的共同语言。
|
|
103
|
+
// 它不是表达式语言,是一张受限算式表——函数名封闭集由 verify:no-eval 的 CALC_CHARTER 看守。
|
|
104
|
+
export {
|
|
105
|
+
parseCalc,
|
|
106
|
+
collectCalcRefs,
|
|
107
|
+
inferCalcType,
|
|
108
|
+
assertCalcResultType,
|
|
109
|
+
evaluateCalc,
|
|
110
|
+
SomaCalcSyntaxError,
|
|
111
|
+
SomaCalcTypeError,
|
|
112
|
+
CALC_FUNCTIONS,
|
|
113
|
+
} from './shared/calc';
|
|
114
|
+
export type { CalcAst, CalcType, CalcTypeContext, CalcSpan } from './shared/calc';
|
|
115
|
+
|
|
116
|
+
// 反应图(REQ-010 S1b):字段之间的联动。解析在 core,消费在 soma-ui 的表单族——
|
|
117
|
+
// 求值器只有这一套,字段上的 visible_when / disabled_when 也编译成反应走同一条路。
|
|
118
|
+
export { parseReactions } from './client/parser/reaction-parser';
|
|
119
|
+
export { compileFieldSugar } from './client/parser/reaction-sugar';
|
|
120
|
+
export type { SomaSugarField } from './client/parser/reaction-sugar';
|
|
121
|
+
export { runReactions, explainField } from './client/data/reaction-engine';
|
|
122
|
+
|
|
123
|
+
// 数据窗口(REQ-010 S2):一屏一屏地取。解析在 core,消费面是 QueryConsole / DataTable。
|
|
124
|
+
export { parseWindow, dictHash } from './client/parser/window-parser';
|
|
125
|
+
export { createWindow } from './client/data/window-engine';
|
|
126
|
+
|
|
127
|
+
// 动作编排(REQ-010 S4):一个交互按顺序做好几件事。编排图是纯数据——
|
|
128
|
+
// 可画、可 diff、可在编译期判定可终止性。逃生舱是具名动作注册表,不是脚本。
|
|
129
|
+
export { parseSteps } from './client/parser/step-parser';
|
|
130
|
+
export type { StepParseInput, StepParseDeps } from './client/parser/step-parser';
|
|
131
|
+
export { runSteps } from './client/engine/step-runner';
|
|
132
|
+
|
|
133
|
+
// 页面态切片(REQ-010 F-37):分享链接、用户偏好、审计回放共用一套结构。
|
|
134
|
+
export {
|
|
135
|
+
parsePageState,
|
|
136
|
+
parseStateValue,
|
|
137
|
+
encodePageState,
|
|
138
|
+
decodePageState,
|
|
139
|
+
} from './client/parser/page-state-parser';
|
|
140
|
+
// 约束布局(REQ-010 S3):声明词汇在 client(要能被页面解析器读),
|
|
141
|
+
// 求解与产出在 build(CL-4:运行期零求解,求解器不进 client 依赖图)。
|
|
142
|
+
// 列表路径代数(REQ-010 F-11):让一条反应作用在明细行的每一项上。
|
|
143
|
+
export {
|
|
144
|
+
isListPath,
|
|
145
|
+
parseListPath,
|
|
146
|
+
expandListPath,
|
|
147
|
+
readListPath,
|
|
148
|
+
validateListPath,
|
|
149
|
+
SomaPathError,
|
|
150
|
+
} from './shared/path-algebra';
|
|
151
|
+
export type { SomaListPath, SomaPathSelector } from './shared/path-algebra';
|
|
152
|
+
|
|
153
|
+
export { parseLayoutConstraint } from './client/parser/layout-parser';
|
|
154
|
+
export { SOMA_LAYOUT_PRIORITIES, SOMA_LAYOUT_ALIGNS } from './shared/types/layout-constraint.types';
|
|
155
|
+
export type {
|
|
156
|
+
SomaSizing,
|
|
157
|
+
SomaPriority,
|
|
158
|
+
SomaWrap,
|
|
159
|
+
SomaAlign,
|
|
160
|
+
SomaLayoutNodeConstraint,
|
|
161
|
+
SomaLayoutConstraint,
|
|
162
|
+
SomaLayoutSolution,
|
|
163
|
+
SomaLayoutPlan,
|
|
164
|
+
} from './shared/types/layout-constraint.types';
|
|
165
|
+
|
|
166
|
+
export type {
|
|
167
|
+
SomaPageState,
|
|
168
|
+
SomaPageStateConfig,
|
|
169
|
+
SomaWindowStateSlice,
|
|
170
|
+
SomaColumnStateSlice,
|
|
171
|
+
} from './shared/types/page-state.types';
|
|
172
|
+
export type { StepRunContext, StepRunResult } from './client/engine/step-runner';
|
|
173
|
+
export type {
|
|
174
|
+
SomaStep,
|
|
175
|
+
SomaDoStep,
|
|
176
|
+
SomaSwitchStep,
|
|
177
|
+
SomaParallelStep,
|
|
178
|
+
SomaForEachStep,
|
|
179
|
+
SomaStepOnError,
|
|
180
|
+
SomaStepSlot,
|
|
181
|
+
SomaCompiledStep,
|
|
182
|
+
SomaStepGraph,
|
|
183
|
+
} from './shared/types/step.types';
|
|
184
|
+
export type { SomaWindowHttpLike, SomaWindowDeps } from './client/data/window-engine';
|
|
185
|
+
export { SOMA_AGGREGATE_FNS, SOMA_SELECT_ALL_MODES } from './shared/types/window.types';
|
|
186
|
+
export type {
|
|
187
|
+
SomaFilterNode,
|
|
188
|
+
SomaWindowSort,
|
|
189
|
+
SomaAggregateFn,
|
|
190
|
+
SomaWindowAggregate,
|
|
191
|
+
SomaSelectAllMode,
|
|
192
|
+
SomaWindowSelection,
|
|
193
|
+
SomaWindowBlockConfig,
|
|
194
|
+
SomaWindowConfig,
|
|
195
|
+
SomaWindowRequest,
|
|
196
|
+
SomaWindowResponse,
|
|
197
|
+
SomaWindowRequestPatch,
|
|
198
|
+
SomaWindowHandle,
|
|
199
|
+
SomaTransaction,
|
|
200
|
+
} from './shared/types/window.types';
|
|
201
|
+
export {
|
|
202
|
+
SOMA_REACTION_PHASES,
|
|
203
|
+
SOMA_FIELD_DISPLAYS,
|
|
204
|
+
SOMA_FIELD_PATTERNS,
|
|
205
|
+
SOMA_REACTION_FORM_KEY,
|
|
206
|
+
} from './shared/types/reaction.types';
|
|
207
|
+
export type {
|
|
208
|
+
SomaReactionPhase,
|
|
209
|
+
SomaFieldDisplay,
|
|
210
|
+
SomaFieldPattern,
|
|
211
|
+
SomaFieldValuePatch,
|
|
212
|
+
SomaFieldStatePatch,
|
|
213
|
+
SomaFormStatePatch,
|
|
214
|
+
SomaReactionConfig,
|
|
215
|
+
SomaCompiledReaction,
|
|
216
|
+
SomaFieldProvenance,
|
|
217
|
+
SomaReactionGraph,
|
|
218
|
+
SomaReactionResult,
|
|
219
|
+
} from './shared/types/reaction.types';
|
|
67
220
|
export {
|
|
68
221
|
deriveTheme,
|
|
69
222
|
applyTheme,
|
|
@@ -133,11 +286,42 @@ export type {
|
|
|
133
286
|
SomaComponentContract,
|
|
134
287
|
SomaComponentLayer,
|
|
135
288
|
SomaGeometryFamily,
|
|
289
|
+
SomaContractField,
|
|
136
290
|
SomaContractProp,
|
|
137
291
|
SomaContractEmit,
|
|
138
292
|
SomaContractSlot,
|
|
293
|
+
SomaContractKeyboard,
|
|
294
|
+
SomaContractOverlay,
|
|
295
|
+
SomaContractToken,
|
|
139
296
|
} from './shared/types/component-contract.types';
|
|
140
297
|
export { findNestedMutableContractDefault } from './shared/types/component-contract.types';
|
|
298
|
+
|
|
299
|
+
// ── 字段行文法与样张派生(REQ-012) ──
|
|
300
|
+
// 契约里的 props / emits / slots 可以写成文本块:一行一个字段,缩进即嵌套。
|
|
301
|
+
// 示例值挂在字段上,样张是它的函数——不另写一份,就不会有两个真源。
|
|
302
|
+
export {
|
|
303
|
+
parseFieldLines,
|
|
304
|
+
parseEmitLines,
|
|
305
|
+
parseSlotLines,
|
|
306
|
+
renderFieldLines,
|
|
307
|
+
somaFields,
|
|
308
|
+
somaEmits,
|
|
309
|
+
somaSlots,
|
|
310
|
+
SomaFieldLinesError,
|
|
311
|
+
} from './shared/component/field-lines';
|
|
312
|
+
export {
|
|
313
|
+
deriveContractSample,
|
|
314
|
+
deriveFieldSample,
|
|
315
|
+
hasRenderableSample,
|
|
316
|
+
} from './shared/component/derive-sample';
|
|
317
|
+
export type { DeriveSampleResult, SampleGap } from './shared/component/derive-sample';
|
|
318
|
+
// 组件级令牌(REQ-009 M-1)的命名规则。宿主与闸门都要按同一条规则拼名字——
|
|
319
|
+
// 各自拼一遍的话,主题的 `components` 段覆盖不上任何东西,而覆盖不上是静默的。
|
|
320
|
+
export {
|
|
321
|
+
componentTokenPrefix,
|
|
322
|
+
componentTokenVar,
|
|
323
|
+
COMPONENT_TOKEN_KEY_PATTERN,
|
|
324
|
+
} from './shared/types/component-contract.types';
|
|
141
325
|
export { createDefaultRuntimeServices } from './client/runtime/SomaRuntimeServices';
|
|
142
326
|
export type { SomaRuntimeServices } from './client/runtime/SomaRuntimeServices';
|
|
143
327
|
export { SomaDiagnostics } from './client/diagnostics/SomaDiagnostics';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export class SomaBlockParseError extends Error {
|
|
2
|
+
constructor(
|
|
3
|
+
message: string,
|
|
4
|
+
readonly blockId?: string,
|
|
5
|
+
readonly line?: number,
|
|
6
|
+
) {
|
|
7
|
+
const where = blockId ? `(块: ${blockId}${line ? `,第 ${line} 行` : ''})` : '';
|
|
8
|
+
super(`[soma-core][引擎] ${message}${where}`);
|
|
9
|
+
this.name = 'SomaBlockParseError';
|
|
10
|
+
}
|
|
11
|
+
}
|