soma-core 1.4.2 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (212) hide show
  1. package/bin/component.cjs +240 -0
  2. package/bin/eject.cjs +174 -0
  3. package/bin/migrate.cjs +362 -0
  4. package/core/build/blocks/block-compile.ts +143 -17
  5. package/core/build/blocks/migrate-flat.ts +118 -25
  6. package/core/build/compiler/page-declaration-compiler.ts +149 -5
  7. package/core/build/compiler/route-builder.ts +0 -4
  8. package/core/build/compiler/soma-precompile.js +431 -26
  9. package/core/build/component/component-graph.ts +28 -105
  10. package/core/build/component/package-loader.ts +18 -4
  11. package/core/build/eject/component-eject.ts +8 -2
  12. package/core/build/layout/constraint-solver.ts +131 -16
  13. package/core/build/layout/css-emitter.ts +15 -9
  14. package/core/build/ooui/artifact/artifact.types.ts +275 -0
  15. package/core/build/ooui/artifact/emit-artifact.ts +269 -0
  16. package/core/build/ooui/artifact/emit-html.ts +204 -0
  17. package/core/build/ooui/artifact/index.ts +53 -0
  18. package/core/build/ooui/artifact/spatial-tree.ts +268 -0
  19. package/core/build/ooui/artifact/utility-class.ts +83 -0
  20. package/core/build/ooui/composition/candidate.types.ts +323 -0
  21. package/core/build/ooui/composition/control-model.ts +114 -0
  22. package/core/build/ooui/composition/registry.ts +520 -0
  23. package/core/build/ooui/composition/select.ts +232 -0
  24. package/core/build/ooui/diagnostics/codes.ts +230 -0
  25. package/core/build/ooui/diagnostics/error.ts +235 -0
  26. package/core/build/ooui/diagnostics/format.ts +106 -0
  27. package/core/build/ooui/diagnostics/index.ts +62 -0
  28. package/core/build/ooui/diagnostics/issue.types.ts +112 -0
  29. package/core/build/ooui/engine-slot.ts +184 -0
  30. package/core/build/ooui/index.ts +1427 -0
  31. package/core/build/ooui/intent/derive-intent.ts +450 -0
  32. package/core/build/ooui/intent/field-rules.ts +330 -0
  33. package/core/build/ooui/intent/intent.types.ts +476 -0
  34. package/core/build/ooui/intent/verb-events.ts +285 -0
  35. package/core/build/ooui/page/budget.ts +503 -0
  36. package/core/build/ooui/page/compose-page.ts +736 -0
  37. package/core/build/ooui/page/index.ts +66 -0
  38. package/core/build/ooui/page/page.types.ts +402 -0
  39. package/core/build/ooui/page/region-row.ts +241 -0
  40. package/core/build/ooui/semantic/expand-page-surface.ts +180 -0
  41. package/core/build/ooui/semantic/kernel.types.ts +187 -0
  42. package/core/build/ooui/semantic/normalize.ts +784 -0
  43. package/core/build/ooui/semantic/origin.types.ts +211 -0
  44. package/core/build/ooui/semantic/role-alias.ts +154 -0
  45. package/core/build/ooui/semantic/shorthand.ts +233 -0
  46. package/core/build/ooui/semantic/surface.types.ts +78 -0
  47. package/core/build/ooui/semantic/validate-request.ts +267 -0
  48. package/core/build/ooui/spatial/emit-utility.ts +480 -0
  49. package/core/build/ooui/spatial/ir.types.ts +443 -0
  50. package/core/build/ooui/spatial/registry.ts +565 -0
  51. package/core/build/ooui/spatial/solve.ts +769 -0
  52. package/core/build/ooui/spatial/utility.types.ts +242 -0
  53. package/core/build/ooui/trace/index.ts +40 -0
  54. package/core/build/ooui/trace/render.ts +190 -0
  55. package/core/build/ooui/trace/source.types.ts +69 -0
  56. package/core/build/ooui/trace/trace.types.ts +326 -0
  57. package/core/client/component/example-blocks.ts +1 -7
  58. package/core/client/component/theme-component-tokens.ts +12 -15
  59. package/core/client/data/data-object-resolver.ts +27 -8
  60. package/core/client/diagnostics/telemetry-context.ts +0 -4
  61. package/core/client/engine/asset-resolver.ts +0 -1
  62. package/core/client/engine/event-engine.ts +7 -3
  63. package/core/client/engine/soma-bootstrap.ts +292 -34
  64. package/core/client/engine/style-binder.ts +0 -1
  65. package/core/client/infra/http/IHttpClient.ts +0 -6
  66. package/core/client/infra/http/SomaHttpService.ts +4 -1
  67. package/core/client/infra/notify/DomNotifyService.ts +1 -1
  68. package/core/client/infra/router/router-path.ts +0 -6
  69. package/core/client/parser/annotation-extractor.ts +1 -1
  70. package/core/client/parser/blocks/namespace.ts +30 -5
  71. package/core/client/parser/blocks/page-parser.ts +44 -1
  72. package/core/client/parser/blocks/use-parser.ts +266 -46
  73. package/core/client/parser/data-config-parser.ts +71 -3
  74. package/core/client/parser/layout-parser.ts +4 -3
  75. package/core/client/parser/reaction-parser.ts +0 -1
  76. package/core/client/parser/ui-config-parser.ts +212 -74
  77. package/core/client/theme/scene-tokens.ts +9 -3
  78. package/core/client/theme/theme-axes.ts +74 -16
  79. package/core/client/theme/theme-engine.ts +280 -69
  80. package/core/client/theme/tone-solver.ts +9 -8
  81. package/core/index.ts +18 -4
  82. package/core/server/api/load-host-service.ts +8 -2
  83. package/core/server/declaration-safety.ts +11 -0
  84. package/core/server/host/page-response-request.ts +0 -2
  85. package/core/server/host/published-page-artifact-cache.ts +244 -0
  86. package/core/server/host/published-page-assets.ts +44 -5
  87. package/core/server/mock/node/cli.mjs +0 -1
  88. package/core/server/mock/node/schema-generator.mjs +0 -1
  89. package/core/server/ooui.ts +34 -0
  90. package/core/server/page-assets.ts +8 -0
  91. package/core/server/page-declaration.ts +18 -0
  92. package/core/server/registry/asset-store.ts +327 -0
  93. package/core/server/registry/declaration-precompiler.ts +49 -6
  94. package/core/server/registry/index.ts +47 -1
  95. package/core/server/registry/page-registry-repository.ts +6 -2
  96. package/core/server/registry/page-registry-store.ts +133 -19
  97. package/core/server/registry/publish-asset-pin.ts +557 -0
  98. package/core/server/registry/services/pages/List.ts +15 -3
  99. package/core/server/registry/validation/compile-gate.ts +180 -8
  100. package/core/server/registry/validation/declaration-safety-scan.ts +113 -23
  101. package/core/shared/component/derive-sample.ts +201 -16
  102. package/core/shared/component/field-lines.ts +98 -8
  103. package/core/shared/container-breakpoints.ts +46 -0
  104. package/core/shared/object-semantics.ts +240 -0
  105. package/core/shared/ooui-declaration.ts +235 -0
  106. package/core/shared/types/component-contract.types.ts +7 -6
  107. package/core/shared/types/data-config.types.ts +95 -0
  108. package/core/shared/types/domain.types.ts +0 -24
  109. package/core/shared/types/engine.types.ts +0 -5
  110. package/core/shared/types/layout-constraint.types.ts +16 -0
  111. package/core/shared/types/ui-config.types.ts +163 -13
  112. package/dist/cli/soma.js +24 -11
  113. package/dist/core/index.cjs +1563 -800
  114. package/dist/types/build/blocks/block-compile.d.ts +16 -1
  115. package/dist/types/build/blocks/migrate-flat.d.ts +17 -0
  116. package/dist/types/build/compiler/page-declaration-compiler.d.ts +46 -0
  117. package/dist/types/build/compiler/route-builder.d.ts +0 -1
  118. package/dist/types/build/component/component-graph.d.ts +17 -53
  119. package/dist/types/build/component/package-loader.d.ts +8 -1
  120. package/dist/types/build/layout/constraint-solver.d.ts +46 -4
  121. package/dist/types/build/ooui/artifact/artifact.types.d.ts +180 -0
  122. package/dist/types/build/ooui/artifact/emit-artifact.d.ts +58 -0
  123. package/dist/types/build/ooui/artifact/emit-html.d.ts +53 -0
  124. package/dist/types/build/ooui/artifact/index.d.ts +5 -0
  125. package/dist/types/build/ooui/artifact/spatial-tree.d.ts +48 -0
  126. package/dist/types/build/ooui/artifact/utility-class.d.ts +46 -0
  127. package/dist/types/build/ooui/composition/candidate.types.d.ts +206 -0
  128. package/dist/types/build/ooui/composition/control-model.d.ts +37 -0
  129. package/dist/types/build/ooui/composition/registry.d.ts +66 -0
  130. package/dist/types/build/ooui/composition/select.d.ts +63 -0
  131. package/dist/types/build/ooui/diagnostics/codes.d.ts +28 -0
  132. package/dist/types/build/ooui/diagnostics/error.d.ts +135 -0
  133. package/dist/types/build/ooui/diagnostics/format.d.ts +51 -0
  134. package/dist/types/build/ooui/diagnostics/index.d.ts +25 -0
  135. package/dist/types/build/ooui/diagnostics/issue.types.d.ts +56 -0
  136. package/dist/types/build/ooui/engine-slot.d.ts +41 -0
  137. package/dist/types/build/ooui/index.d.ts +286 -0
  138. package/dist/types/build/ooui/intent/derive-intent.d.ts +32 -0
  139. package/dist/types/build/ooui/intent/field-rules.d.ts +99 -0
  140. package/dist/types/build/ooui/intent/intent.types.d.ts +318 -0
  141. package/dist/types/build/ooui/intent/verb-events.d.ts +70 -0
  142. package/dist/types/build/ooui/page/budget.d.ts +28 -0
  143. package/dist/types/build/ooui/page/compose-page.d.ts +41 -0
  144. package/dist/types/build/ooui/page/index.d.ts +4 -0
  145. package/dist/types/build/ooui/page/page.types.d.ts +264 -0
  146. package/dist/types/build/ooui/page/region-row.d.ts +16 -0
  147. package/dist/types/build/ooui/semantic/expand-page-surface.d.ts +33 -0
  148. package/dist/types/build/ooui/semantic/kernel.types.d.ts +125 -0
  149. package/dist/types/build/ooui/semantic/normalize.d.ts +45 -0
  150. package/dist/types/build/ooui/semantic/origin.types.d.ts +95 -0
  151. package/dist/types/build/ooui/semantic/role-alias.d.ts +35 -0
  152. package/dist/types/build/ooui/semantic/shorthand.d.ts +60 -0
  153. package/dist/types/build/ooui/semantic/surface.types.d.ts +16 -0
  154. package/dist/types/build/ooui/semantic/validate-request.d.ts +19 -0
  155. package/dist/types/build/ooui/spatial/emit-utility.d.ts +43 -0
  156. package/dist/types/build/ooui/spatial/ir.types.d.ts +280 -0
  157. package/dist/types/build/ooui/spatial/registry.d.ts +110 -0
  158. package/dist/types/build/ooui/spatial/solve.d.ts +42 -0
  159. package/dist/types/build/ooui/spatial/utility.types.d.ts +191 -0
  160. package/dist/types/build/ooui/trace/index.d.ts +3 -0
  161. package/dist/types/build/ooui/trace/render.d.ts +42 -0
  162. package/dist/types/build/ooui/trace/source.types.d.ts +25 -0
  163. package/dist/types/build/ooui/trace/trace.types.d.ts +143 -0
  164. package/dist/types/client/component/example-blocks.d.ts +0 -2
  165. package/dist/types/client/component/theme-component-tokens.d.ts +8 -5
  166. package/dist/types/client/data/data-object-resolver.d.ts +10 -2
  167. package/dist/types/client/diagnostics/telemetry-context.d.ts +0 -1
  168. package/dist/types/client/engine/soma-bootstrap.d.ts +123 -10
  169. package/dist/types/client/infra/http/IHttpClient.d.ts +0 -5
  170. package/dist/types/client/infra/http/SomaHttpService.d.ts +1 -1
  171. package/dist/types/client/infra/router/router-path.d.ts +0 -2
  172. package/dist/types/client/parser/blocks/namespace.d.ts +20 -0
  173. package/dist/types/client/parser/blocks/page-parser.d.ts +9 -0
  174. package/dist/types/client/parser/blocks/use-parser.d.ts +38 -4
  175. package/dist/types/client/parser/data-config-parser.d.ts +13 -0
  176. package/dist/types/client/parser/ui-config-parser.d.ts +1 -11
  177. package/dist/types/client/theme/scene-tokens.d.ts +9 -3
  178. package/dist/types/client/theme/theme-axes.d.ts +64 -1
  179. package/dist/types/client/theme/theme-engine.d.ts +13 -8
  180. package/dist/types/client/theme/tone-solver.d.ts +9 -5
  181. package/dist/types/index.d.ts +4 -5
  182. package/dist/types/server/declaration-safety.d.ts +7 -0
  183. package/dist/types/server/host/page-response-request.d.ts +0 -1
  184. package/dist/types/server/host/published-page-artifact-cache.d.ts +64 -0
  185. package/dist/types/server/ooui.d.ts +18 -0
  186. package/dist/types/server/page-assets.d.ts +7 -0
  187. package/dist/types/server/page-declaration.d.ts +14 -0
  188. package/dist/types/server/registry/asset-store.d.ts +112 -0
  189. package/dist/types/server/registry/declaration-precompiler.d.ts +23 -3
  190. package/dist/types/server/registry/index.d.ts +3 -1
  191. package/dist/types/server/registry/page-registry-store.d.ts +57 -4
  192. package/dist/types/server/registry/publish-asset-pin.d.ts +166 -0
  193. package/dist/types/server/registry/services/pages/List.d.ts +9 -3
  194. package/dist/types/server/registry/validation/compile-gate.d.ts +63 -0
  195. package/dist/types/shared/component/derive-sample.d.ts +14 -0
  196. package/dist/types/shared/container-breakpoints.d.ts +42 -0
  197. package/dist/types/shared/object-semantics.d.ts +42 -0
  198. package/dist/types/shared/ooui-declaration.d.ts +135 -0
  199. package/dist/types/shared/types/component-contract.types.d.ts +7 -6
  200. package/dist/types/shared/types/data-config.types.d.ts +86 -0
  201. package/dist/types/shared/types/domain.types.d.ts +0 -21
  202. package/dist/types/shared/types/engine.types.d.ts +0 -4
  203. package/dist/types/shared/types/layout-constraint.types.d.ts +1 -0
  204. package/dist/types/shared/types/ui-config.types.d.ts +157 -12
  205. package/next.config.js +106 -13
  206. package/package.json +28 -2
  207. package/core/client/host-bridge/index.ts +0 -27
  208. package/core/client/parser/yaml-loader.ts +0 -36
  209. package/core/shared/manifest/manifest-contract.ts +0 -12
  210. package/dist/types/client/host-bridge/index.d.ts +0 -9
  211. package/dist/types/client/parser/yaml-loader.d.ts +0 -21
  212. package/dist/types/shared/manifest/manifest-contract.d.ts +0 -4
@@ -17,20 +17,72 @@ import {
17
17
  SOMA_DATA_FIELD_TYPES,
18
18
  SOMA_DATA_FIELD_TYPE_ALIASES,
19
19
  } from '../../../shared/types/data-config.types';
20
+ import type {
21
+ SomaDataObjectRelation,
22
+ SomaDataObjectRoles,
23
+ } from '../../../shared/types/data-config.types';
24
+ import {
25
+ validateFieldModifies,
26
+ validateObjectRelations,
27
+ validateObjectRoles,
28
+ } from '../../../shared/object-semantics';
20
29
  import {
30
+ blockDataObjectName,
21
31
  buildBlockScope,
22
32
  expandPath,
23
33
  resolveApiRef,
34
+ resolvePath,
24
35
  type BlockScope,
25
36
  } from './namespace';
26
37
 
27
38
  const BLOCK_KEYS = new Set(['component', 'alias', 'when', 'data', 'ui', 'event']);
28
- const DATA_OBJECT_KEYS = new Set(['from', 'save', 'refresh', 'reload_on', 'fields']);
39
+ /**
40
+ * 块声明的**对象级封闭键集**。导出是为了让"两条书写路径的键集差异"有一处可断言的地方
41
+ * ——平铺 `_data.yaml` 那侧是 `SOMA_DATA_OBJECT_KEYS`,两份键集此前只活在各自的
42
+ * `if/else` 里,谁多谁少没有任何东西看得见。差集本身由测试盯着,只减不增。
43
+ *
44
+ * `roles` / `relations` 随 REQ-014 期 2'.1 进表:不进的话,写 `roles:` 会当场报
45
+ * 「data.X 不支持键 "roles"」,而这个错经 `dryRunCompile` 被压成一句
46
+ * 「声明未通过编译闸门」,发布期直接拒收——报错离原因很远。
47
+ *
48
+ * `refresh` / `reload_on` 已移出:数据对象层没有对应物(不轮询、不监听路径),
49
+ * 收着它们就是「解析了、引擎不消费」——写了 `refresh: 30s` 的对象永远不会重取,且不报错。
50
+ * 现在写它们由 RETIRED_DATA_OBJECT_KEYS 当场拒收并指路。
51
+ */
52
+ export const USE_BLOCK_DATA_OBJECT_KEYS: readonly string[] = [
53
+ 'from', 'save', 'fields', 'roles', 'relations',
54
+ ];
55
+ const DATA_OBJECT_KEYS = new Set(USE_BLOCK_DATA_OBJECT_KEYS);
56
+ /**
57
+ * 没有运行时对应物的对象键 → 拒收时的指路。
58
+ *
59
+ * 不混进「不支持键」的通用报错:它们写在旧文档与旧示例里,作者是照着抄的,
60
+ * 光说「不支持」他不知道该改成什么。用 Map 而不是字面量对象——`constructor`
61
+ * 这类键名会从原型链上查出一个函数来。
62
+ */
63
+ const RETIRED_DATA_OBJECT_KEYS: ReadonlyMap<string, string> = new Map([
64
+ ['refresh', '数据对象层不做周期重取,写了也不会轮询'
65
+ + '——要定时重取,在 page 块 event.timers 挂一个 tick 调 Domain 方法,方法里调 this.reloadData()'],
66
+ ['reload_on', '数据对象层不监听路径变化,写了也不会重取'
67
+ + '——要依赖变化后重取,在 page 块 watch 里写 { path, call },被调的 Domain 方法里调 this.reloadData()'],
68
+ ]);
69
+ /** `from` 的封闭键集:块私有对象只有一个取数来源(编译成数据对象层 `from` 数组的唯一一项) */
70
+ const FROM_KEYS = new Set(['api', 'params']);
71
+ /** `save` 的封闭键集(`trigger` 单独拒收并指路,见 parseDataObject) */
72
+ const SAVE_KEYS = new Set(['api', 'method', 'key', 'fields']);
73
+ /** 块私有对象的扁平名必须是数据对象层认的标识符(与 data-config-parser 同一条) */
74
+ const DATA_OBJECT_NAME_RE = /^[A-Za-z_]\w*$/;
75
+ /** 取数参数里的路径:只能是一条纯路径(`$` 引用没有管道与算术) */
76
+ const PARAM_PATH_RE = /^[A-Za-z_]\w*(?:\.\w+)*$/;
29
77
  const EVENT_KEYS = new Set(['actions', 'on']);
30
78
  const ACTION_KEYS = new Set([
31
79
  'label', 'handler', 'change', 'confirm', 'permission', 'tone', 'when', 'disabled_reason',
32
80
  ]);
33
- const FIELD_KEYS = new Set(['name', 'type', 'values', 'permission', 'rules']);
81
+ /** 块声明的**字段级封闭键集**(导出理由同上) */
82
+ export const USE_BLOCK_FIELD_KEYS: readonly string[] = [
83
+ 'name', 'type', 'values', 'permission', 'rules', 'modifies',
84
+ ];
85
+ const FIELD_KEYS = new Set(USE_BLOCK_FIELD_KEYS);
34
86
  // 字段类型不在这里再抄一份:唯一真源是 shared/types/data-config.types.ts 的
35
87
  // SomaDataFieldType。此前这里手写了一套 9 型,与数据对象层的 11 型已经漂开——
36
88
  // `type: url` 在块声明里被拒收,`type: percent` 能过解析器却在 soma-ui 侧没有映射。
@@ -38,23 +90,36 @@ const FIELD_TYPES = new Set(SOMA_DATA_FIELD_TYPES);
38
90
 
39
91
  export interface DataObjectDecl {
40
92
  localName: string;
41
- /** 全局身份:块id.名 */
93
+ /**
94
+ * 全局身份:扁平名 `块id__名`(blockDataObjectName)。
95
+ * 它就是数据对象层的对象名,也是运行时 `page.data` 的键。
96
+ */
42
97
  fullName: string;
98
+ /** 取数来源(块里只有一个);params 已换成数据对象层的 `$` 引用或字面量 */
43
99
  from?: { api: string; params: Record<string, string> };
100
+ /** 写通道(block-compile 归一为 `write`) */
44
101
  save?: {
45
- api: string; method: string; key?: string; trigger: string; fields?: string[];
102
+ api: string; method: string; key?: string; fields?: string[];
46
103
  };
47
- refreshMs?: number;
48
- reloadOn?: string[];
49
104
  fields?: Record<string, FieldDecl>;
105
+ /** 对象级角色(REQ-014 §3.1.2):哪个字段是标题 / 状态 / 金额 / 对比基准 */
106
+ roles?: SomaDataObjectRoles;
107
+ /**
108
+ * 对象间关系(REQ-014 §3.1.2):compare / navigate 的作用路径。
109
+ * `to` 保留块内短名,block-compile 把指向本块对象的那些换成扁平名。
110
+ */
111
+ relations?: SomaDataObjectRelation[];
50
112
  }
51
113
 
52
114
  export interface FieldDecl {
53
115
  name?: string;
54
116
  type: string;
117
+ /** 值 → 显示文案(块拼写;block-compile 编成数据对象层的 `options` 数组) */
55
118
  values?: Record<string, string>;
56
119
  permission: 'r' | 'w';
57
120
  rules?: Array<Record<string, unknown>>;
121
+ /** 修饰关系(REQ-014 §15.3):本字段是另一个字段的语气 / 单位 / 图标,不独立占格 */
122
+ modifies?: string;
58
123
  }
59
124
 
60
125
  export interface ActionDecl {
@@ -96,6 +161,11 @@ export interface ParseUseInput {
96
161
  htmlComponent?: string;
97
162
  /** 该实例可见的行变量(由 HTML 位置决定) */
98
163
  rowVars?: Iterable<string>;
164
+ /**
165
+ * 该实例是否位于列表行模板内(由 HTML 位置决定)。
166
+ * 行内实例不得声明私有数据对象:每行渲染一个实例,而数据对象层没有「每行一个对象」。
167
+ */
168
+ inRowTemplate?: boolean;
99
169
  }
100
170
 
101
171
  export function parseUseBlock(input: ParseUseInput): UseBlockAst {
@@ -123,28 +193,62 @@ export function parseUseBlock(input: ParseUseInput): UseBlockAst {
123
193
  const dataRaw = (body.data as Record<string, unknown>) ?? {};
124
194
  if (typeof dataRaw !== 'object' || Array.isArray(dataRaw)) fail('data 段必须是映射');
125
195
 
126
- const scope = buildBlockScope({
196
+ const baseScope = buildBlockScope({
127
197
  blockId,
128
198
  dataNames: Object.keys(dataRaw),
129
199
  aliasRaw: body.alias as Record<string, unknown> | undefined,
130
200
  rowVars: input.rowVars,
131
201
  });
132
202
 
133
- // ── event 段:先解析(data.save.trigger 要校验动作存在) ────────────────
134
- const { actions, emitRoutes } = parseEventSection(body.event, blockId, scope, fail);
135
-
136
- // ── data 段:声明与引入 ─────────────────────────────────────────────────
137
- const dataObjects: DataObjectDecl[] = [];
203
+ // ── data 名 → 运行时绑定路径 ─────────────────────────────────────────────
204
+ // 声明走扁平名 `page.data.块id__名`(数据对象层与运行时都认的标识符),引入走目标路径。
205
+ // 必须先于 event / ui / 对象体定下来:它们都可能引用本块的 data 名。
206
+ const dataPaths = new Map<string, string>();
138
207
  const dataImports: Array<{ localName: string; targetPath: string }> = [];
139
208
  for (const [localName, raw] of Object.entries(dataRaw)) {
140
209
  if (typeof raw === 'string') {
141
- dataImports.push({ localName, targetPath: expandPath(raw, { ...scope, dataNames: new Set() }) });
210
+ const target = resolvePath(raw, { ...baseScope, dataNames: new Set() });
211
+ if (target.kind === 'literal') {
212
+ fail(
213
+ `data.${localName} 的引入路径 "${raw}" 不在任何作用域内`
214
+ + '——引入只能指向 page.*(如 page.data.profile)、行变量或路径别名',
215
+ );
216
+ }
217
+ const targetPath = (target as { full: string }).full;
218
+ dataPaths.set(localName, targetPath);
219
+ dataImports.push({ localName, targetPath });
142
220
  continue;
143
221
  }
144
222
  if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) {
145
223
  fail(`data.${localName} 必须是映射(声明)或字符串路径(引入)`);
146
224
  }
147
- dataObjects.push(parseDataObject(localName, raw as Record<string, unknown>, blockId, scope, actions, fail));
225
+ if (input.inRowTemplate) {
226
+ fail(
227
+ `data.${localName} 是块私有数据对象,但实例 "${blockId}" 位于列表行模板内`
228
+ + '——行模板每行渲染一个实例,数据对象层没有「每行一个对象」的表达;'
229
+ + '请把对象声明到 page 块的 data:,行内用行变量或引入(名: 路径)取值',
230
+ );
231
+ }
232
+ const fullName = blockDataObjectName(blockId, localName);
233
+ if (!DATA_OBJECT_NAME_RE.test(fullName)) {
234
+ fail(
235
+ `私有数据对象 "${localName}" 的全局名 "${fullName}" 不是标识符`
236
+ + `——块 id "${blockId}" 含字母/数字/下划线以外的字符,而数据对象层的对象名必须是标识符;`
237
+ + '请把该实例的 data-soma-id 改成下划线写法',
238
+ );
239
+ }
240
+ dataPaths.set(localName, `page.data.${fullName}`);
241
+ }
242
+ const scope: BlockScope = { ...baseScope, dataPaths };
243
+
244
+ // ── event 段 ───────────────────────────────────────────────────────────
245
+ const { actions, emitRoutes } = parseEventSection(body.event, blockId, scope, fail);
246
+
247
+ // ── data 段:私有对象声明(引入已在上面登记) ─────────────────────────────
248
+ const dataObjects: DataObjectDecl[] = [];
249
+ for (const [localName, raw] of Object.entries(dataRaw)) {
250
+ if (typeof raw === 'string') continue;
251
+ dataObjects.push(parseDataObject(localName, raw as Record<string, unknown>, blockId, scope, fail));
148
252
  }
149
253
 
150
254
  // ── ui 段 ──────────────────────────────────────────────────────────────
@@ -177,76 +281,166 @@ function parseDataObject(
177
281
  raw: Record<string, unknown>,
178
282
  blockId: string,
179
283
  scope: BlockScope,
180
- actions: Map<string, ActionDecl>,
181
284
  fail: (m: string) => never,
182
285
  ): DataObjectDecl {
183
286
  for (const key of Object.keys(raw)) {
287
+ const retired = RETIRED_DATA_OBJECT_KEYS.get(key);
288
+ if (retired !== undefined) {
289
+ fail(`data.${localName}.${key} 没有运行时对应物:${retired}`);
290
+ }
184
291
  if (!DATA_OBJECT_KEYS.has(key)) {
185
292
  fail(`data.${localName} 不支持键 "${key}"(可用:${[...DATA_OBJECT_KEYS].join('/')})`);
186
293
  }
187
294
  }
188
295
 
189
- const decl: DataObjectDecl = { localName, fullName: `${blockId}.${localName}` };
296
+ const decl: DataObjectDecl = { localName, fullName: blockDataObjectName(blockId, localName) };
190
297
 
191
- const from = raw.from as Record<string, unknown> | undefined;
298
+ const from = raw.from as Record<string, unknown> | null | undefined;
192
299
  if (from !== undefined) {
193
- if (typeof from !== 'object' || Array.isArray(from)) fail(`data.${localName}.from 必须是映射`);
194
- const api = from.api;
300
+ if (from === null || typeof from !== 'object' || Array.isArray(from)) {
301
+ fail(`data.${localName}.from 必须是映射 { api, params }(块私有对象只有一个取数来源)`);
302
+ }
303
+ const source = from as Record<string, unknown>;
304
+ for (const key of Object.keys(source)) {
305
+ if (!FROM_KEYS.has(key)) {
306
+ fail(`data.${localName}.from 不支持键 "${key}"(可用:${[...FROM_KEYS].join('/')})`);
307
+ }
308
+ }
309
+ const api = source.api;
195
310
  if (typeof api !== 'string' || api.trim() === '') fail(`data.${localName}.from 缺少 api`);
311
+ const paramsRaw = source.params ?? {};
312
+ if (paramsRaw === null || typeof paramsRaw !== 'object' || Array.isArray(paramsRaw)) {
313
+ fail(`data.${localName}.from.params 必须是映射(参数名 → 路径或字面量)`);
314
+ }
196
315
  const params: Record<string, string> = {};
197
- for (const [key, value] of Object.entries((from.params as Record<string, unknown>) ?? {})) {
198
- params[key] = expandPath(String(value), scope);
316
+ for (const [key, value] of Object.entries(paramsRaw as Record<string, unknown>)) {
317
+ params[key] = toDataParam(value, `data.${localName}.from.params.${key}`, scope, fail);
199
318
  }
200
319
  decl.from = { api: resolveApiRef(String(api), scope), params };
201
320
  }
202
321
 
203
- const save = raw.save as Record<string, unknown> | undefined;
322
+ const save = raw.save as Record<string, unknown> | null | undefined;
204
323
  if (save !== undefined) {
205
- if (typeof save !== 'object' || Array.isArray(save)) fail(`data.${localName}.save 必须是映射`);
206
- const api = save.api;
207
- const trigger = save.trigger;
208
- if (typeof api !== 'string' || api.trim() === '') fail(`data.${localName}.save 缺少 api`);
209
- if (typeof trigger !== 'string' || trigger.trim() === '') {
210
- fail(`data.${localName}.save 缺少 trigger(由哪个动作触发回写)`);
324
+ if (save === null || typeof save !== 'object' || Array.isArray(save)) {
325
+ fail(`data.${localName}.save 必须是映射`);
211
326
  }
212
- if (!actions.has(String(trigger))) {
213
- const known = [...actions.keys()].join('/') || '(本块未定义任何动作)';
214
- fail(
215
- `data.${localName}.save.trigger 指向未定义的动作 "${trigger}"`
216
- + `——请在 event.actions 里定义它(现有:${known})`,
217
- );
327
+ const channel = save as Record<string, unknown>;
328
+ for (const key of Object.keys(channel)) {
329
+ if (key === 'trigger') {
330
+ // 写通道没有「哪个动作触发提交」这一环:提交由消费该对象的组件经 data 端口发起。
331
+ // 以前它被原样塞进 `write.trigger`,整张页因此过不了数据对象层的闭集。
332
+ fail(
333
+ `data.${localName}.save.trigger 没有运行时对应物:写通道没有「哪个动作触发提交」这一环`
334
+ + '——提交由消费该对象的组件经 data 端口发起'
335
+ + `(如 FormConsole 的 data_object: ${decl.fullName}),删掉 trigger`,
336
+ );
337
+ }
338
+ if (!SAVE_KEYS.has(key)) {
339
+ fail(`data.${localName}.save 不支持键 "${key}"(可用:${[...SAVE_KEYS].join('/')})`);
340
+ }
341
+ }
342
+ const api = channel.api;
343
+ if (typeof api !== 'string' || api.trim() === '') fail(`data.${localName}.save 缺少 api`);
344
+ if (channel.fields !== undefined
345
+ && (!Array.isArray(channel.fields) || channel.fields.some((item) => typeof item !== 'string'))) {
346
+ fail(`data.${localName}.save.fields 必须是字段名数组`);
218
347
  }
219
348
  decl.save = {
220
349
  api: resolveApiRef(String(api), scope),
221
- method: String(save.method ?? 'POST').toUpperCase(),
222
- trigger: String(trigger),
223
- ...(save.key !== undefined ? { key: String(save.key) } : {}),
224
- ...(Array.isArray(save.fields) ? { fields: (save.fields as unknown[]).map(String) } : {}),
350
+ method: String(channel.method ?? 'POST').toUpperCase(),
351
+ ...(channel.key !== undefined ? { key: String(channel.key) } : {}),
352
+ ...(channel.fields !== undefined ? { fields: [...(channel.fields as string[])] } : {}),
225
353
  };
226
354
  }
227
355
 
228
- if (raw.refresh !== undefined) decl.refreshMs = parseDuration(String(raw.refresh), localName, fail);
229
-
230
- if (raw.reload_on !== undefined) {
231
- if (!Array.isArray(raw.reload_on)) fail(`data.${localName}.reload_on 必须是数组`);
232
- decl.reloadOn = (raw.reload_on as unknown[]).map((item) => expandPath(String(item), scope));
233
- }
234
-
235
356
  if (raw.fields !== undefined) {
236
357
  const fieldsRaw = raw.fields as Record<string, unknown>;
237
- if (typeof fieldsRaw !== 'object' || Array.isArray(fieldsRaw)) {
358
+ if (fieldsRaw === null || typeof fieldsRaw !== 'object' || Array.isArray(fieldsRaw)) {
238
359
  fail(`data.${localName}.fields 必须是映射`);
239
360
  }
240
361
  const fields: Record<string, FieldDecl> = {};
241
362
  for (const [fieldName, fieldRaw] of Object.entries(fieldsRaw)) {
242
363
  fields[fieldName] = parseField(localName, fieldName, fieldRaw, fail);
243
364
  }
365
+ // 修饰关系要等整本字典就位才对得上(它指的是兄弟字段)
366
+ const modifiesIssues = validateFieldModifies(fields);
367
+ if (modifiesIssues.length > 0) fail(`data.${localName}.fields:${modifiesIssues.join(';')}`);
244
368
  decl.fields = fields;
245
369
  }
246
370
 
371
+ // roles / relations 必须在 fields 之后:它们的值就是字段名,没有字典就无从对账
372
+ const fieldKeys = Object.keys(decl.fields ?? {});
373
+
374
+ if (raw.roles !== undefined) {
375
+ const issues = validateObjectRoles(raw.roles, fieldKeys);
376
+ if (issues.length > 0) fail(`data.${localName}.roles:${issues.join(';')}`);
377
+ decl.roles = raw.roles as SomaDataObjectRoles;
378
+ }
379
+
380
+ if (raw.relations !== undefined) {
381
+ // objectNames 传 undefined 是刻意的:全页对象名单(页面级 + 各块扁平名)
382
+ // 要等 block-compile 合并全页之后才成形,这里拿不到。
383
+ // 于是本轮只保证形状与 via 对得上字典,`to` 的存在性留给合并后的那一遍
384
+ // (`to` 写本块短名即可,block-compile 把它与对象键一起换成扁平名 `块id__名`)。
385
+ const issues = validateObjectRelations(raw.relations, { fieldKeys, selfName: localName });
386
+ if (issues.length > 0) fail(`data.${localName}.relations:${issues.join(';')}`);
387
+ decl.relations = raw.relations as SomaDataObjectRelation[];
388
+ }
389
+
247
390
  return decl;
248
391
  }
249
392
 
393
+ /**
394
+ * 块参数 → 数据对象层的参数值(`$` 引用或字面量)。
395
+ *
396
+ * 数据对象层只认 `$` 引用(`$query.<键>` / `$page.<路径>` / `$<对象>.<字段>`),其余一律
397
+ * 按字面量发给接口。块里写的是块作用域路径,原样交下去就会把 "page.filters.keyword"
398
+ * 这串字当参数发出去——接口照样 200,查的条件永远不对,而且不报错。所以在这里换形:
399
+ *
400
+ * | 块里写 | 交给数据对象层 |
401
+ * |---|---|
402
+ * | `page.<路径>` | `$page.<路径>`(取数那一刻读 Domain 字段) |
403
+ * | 本块对象 `detail.<字段>`、`page.data.<对象>.<字段>` | `$<对象>.<字段>`(进依赖图) |
404
+ * | 已写成 `$…` | 原样(由合并后的数据解析校验) |
405
+ * | 作用域外的值 | 字面量原样 |
406
+ *
407
+ * `page.data.<对象>` 不换成 `$page.data…`:Domain 的 data 要等全部对象取完才整体注入,
408
+ * 取数途中读它永远是上一轮(首轮为空);换成 `$<对象>` 才会让目标对象先取完。
409
+ */
410
+ function toDataParam(
411
+ raw: unknown,
412
+ where: string,
413
+ scope: BlockScope,
414
+ fail: (m: string) => never,
415
+ ): string {
416
+ if (raw === null || typeof raw === 'object') {
417
+ fail(`${where} 必须是标量或路径,当前值: ${JSON.stringify(raw)}`);
418
+ }
419
+ const text = String(raw).trim();
420
+ if (text.startsWith('$')) return text;
421
+
422
+ const resolved = resolvePath(text, scope);
423
+ if (resolved.kind === 'literal') return text;
424
+ if (!PARAM_PATH_RE.test(text)) {
425
+ fail(`${where} 的值 "${text}" 不是单一路径——数据对象层的 \`$\` 引用只取一个字段,不带管道与算术`);
426
+ }
427
+ const segments = (resolved as { full: string }).full.split('.');
428
+ // 行变量(含指向行变量的引入):私有对象在行模板里已被拒收,这里只是不让它漏成 `$page.…`
429
+ if (resolved.kind === 'row' || segments[0] !== 'page') {
430
+ fail(`${where} 引用了行变量 "${text}"——数据对象不随行重复,取数参数里没有行变量`);
431
+ }
432
+ if (segments[1] === 'data' && segments.length >= 3) {
433
+ if (segments.length === 3) {
434
+ fail(`${where} 引用的是整个数据对象 "${segments[2]}"——参数只能取对象的某个字段(写 ${text}.<字段>)`);
435
+ }
436
+ return `$${segments.slice(2).join('.')}`;
437
+ }
438
+ if (segments.length === 1) {
439
+ fail(`${where} 引用的是整个 page——参数只能取 page 上的某个字段`);
440
+ }
441
+ return `$page.${segments.slice(1).join('.')}`;
442
+ }
443
+
250
444
  function parseField(
251
445
  objectName: string,
252
446
  fieldName: string,
@@ -279,6 +473,12 @@ function parseField(
279
473
  fail(`字段 ${objectName}.${fieldName} 是 enum,必须提供非空 values 映射(它同时是翻译表与选项表)`);
280
474
  }
281
475
  }
476
+ // values 编成数据对象层的 options 数组(block-compile):只收「值 → 文案」映射,
477
+ // 数组逐项拆出来会变成 `{ key: '0' }` 这种没人认得的选项
478
+ if (field.values !== undefined
479
+ && (field.values === null || typeof field.values !== 'object' || Array.isArray(field.values))) {
480
+ fail(`字段 ${objectName}.${fieldName} 的 values 必须是映射(值 → 显示文案)`);
481
+ }
282
482
  const permission = field.permission === undefined ? 'r' : String(field.permission);
283
483
  if (permission !== 'r' && permission !== 'w') {
284
484
  fail(`字段 ${objectName}.${fieldName} 的 permission 只能是 r 或 w`);
@@ -286,6 +486,25 @@ function parseField(
286
486
  if (field.rules !== undefined && !Array.isArray(field.rules)) {
287
487
  fail(`字段 ${objectName}.${fieldName} 的 rules 必须是数组`);
288
488
  }
489
+ // 数据对象层要求每条规则都带 message(校验不通过时给用户看的那句话)。
490
+ // 块声明不替作者编一句:编出来的「格式不正确」对用户没有信息量,还会被当成作者写的。
491
+ ((field.rules as unknown[] | undefined) ?? []).forEach((rule, index) => {
492
+ if (rule === null || typeof rule !== 'object' || Array.isArray(rule)) {
493
+ fail(`字段 ${objectName}.${fieldName} 的 rules[${index}] 必须是映射(一个条件 + message)`);
494
+ }
495
+ const message = (rule as Record<string, unknown>).message;
496
+ if (typeof message !== 'string' || message.trim() === '') {
497
+ fail(
498
+ `字段 ${objectName}.${fieldName} 的 rules[${index}] 缺少 message`
499
+ + '——数据对象层要求每条规则都带校验不通过时的提示文案,如 { max_len: 200, message: 备注最多 200 字 }',
500
+ );
501
+ }
502
+ });
503
+
504
+ if (field.modifies !== undefined
505
+ && (typeof field.modifies !== 'string' || field.modifies.trim() === '')) {
506
+ fail(`字段 ${objectName}.${fieldName} 的 modifies 必须是非空字段名`);
507
+ }
289
508
 
290
509
  return {
291
510
  type,
@@ -293,6 +512,7 @@ function parseField(
293
512
  ...(field.name !== undefined ? { name: String(field.name) } : {}),
294
513
  ...(field.values ? { values: field.values as Record<string, string> } : {}),
295
514
  ...(field.rules ? { rules: field.rules as Array<Record<string, unknown>> } : {}),
515
+ ...(field.modifies !== undefined ? { modifies: String(field.modifies) } : {}),
296
516
  };
297
517
  }
298
518
 
@@ -13,10 +13,17 @@ import type {
13
13
  SomaDataFieldRule,
14
14
  SomaDataFieldType,
15
15
  SomaDataObjectConfig,
16
+ SomaDataObjectRelation,
17
+ SomaDataObjectRoles,
16
18
  SomaDataSourceConfig,
17
19
  SomaDataWriteConfig,
18
20
  SomaDataWriteEndpoint,
19
21
  } from '../../shared/types/data-config.types';
22
+ import {
23
+ validateFieldModifies,
24
+ validateObjectRelations,
25
+ validateObjectRoles,
26
+ } from '../../shared/object-semantics';
20
27
  import {
21
28
  SOMA_DATA_FIELD_TYPES,
22
29
  SOMA_DATA_FIELD_TYPE_ALIASES,
@@ -60,6 +67,29 @@ const VALID_FIELD_TYPES = new Set<string>(SOMA_DATA_FIELD_TYPES);
60
67
 
61
68
  const VALID_PERMISSIONS = new Set<SomaDataFieldPermission>(['r', 'w']);
62
69
 
70
+ /**
71
+ * 平铺 `_data.yaml` 的**对象级封闭键集**。导出是为了让"两条书写路径的键集差异"
72
+ * 有一处可断言的地方——SOMA 有两条声明路径(块声明与平铺 YAML),
73
+ * 而它们的键集此前只存在于各自的 `if/else` 里,谁多谁少没有任何东西看得见。
74
+ *
75
+ * 未知键在这里被拒收,是因为拼错的键在 YAML 里**长得像生效了**:
76
+ * 写 `role:`(少个 s)不会有任何提示,只是那个对象永远没有角色。
77
+ * 而这个错经 `dryRunCompile` 会被压成一句"声明未通过编译闸门",发布期直接拒收——
78
+ * 报错离原因很远,所以这里的消息必须自己把可用键列全。
79
+ */
80
+ export const SOMA_DATA_OBJECT_KEYS: readonly string[] = [
81
+ 'from', 'transform', 'fields', 'mock', 'write', 'predicates', 'reactions', 'window',
82
+ // REQ-014 期 2'.1:对象界面演绎的语义位与关系
83
+ 'roles', 'relations',
84
+ ];
85
+
86
+ /** 平铺 `_data.yaml` 的**字段级封闭键集**(导出理由同上) */
87
+ export const SOMA_DATA_FIELD_KEYS: readonly string[] = [
88
+ 'name', 'type', 'permission', 'rules', 'options', 'calc',
89
+ // REQ-014 期 2'.1:修饰关系(`status_tone` 修饰 `status_text`)
90
+ 'modifies',
91
+ ];
92
+
63
93
  /** 规则键 → 期望的值类型 */
64
94
  const RULE_VALUE_TYPES: Record<string, 'boolean' | 'number' | 'string'> = {
65
95
  required: 'boolean',
@@ -329,9 +359,15 @@ function parseField(raw: unknown, path: string): SomaDataFieldConfig {
329
359
  // 表达式本身在这里还校验不了:它引用的是**兄弟字段**,而兄弟还没解析完。
330
360
  // 留到 validateDerivedFields 那一遍统一对账。
331
361
  field.calc = value;
362
+ } else if (key === 'modifies') {
363
+ if (typeof value !== 'string' || value.trim() === '') {
364
+ throw new SomaDataConfigError('modifies 必须是非空字段名', `${path}.modifies`);
365
+ }
366
+ // 指向的是**兄弟字段**,兄弟这会儿还没解析完——留到 validateFieldModifies 那一遍对账
367
+ field.modifies = value;
332
368
  } else {
333
369
  throw new SomaDataConfigError(
334
- `未知的字典字段 "${key}"(支持: name / type / permission / rules / options / calc)`,
370
+ `未知的字典字段 "${key}"(支持: ${SOMA_DATA_FIELD_KEYS.join(' / ')})`,
335
371
  `${path}.${key}`,
336
372
  );
337
373
  }
@@ -569,6 +605,8 @@ function parseObject(
569
605
  let predicatesRaw: unknown;
570
606
  let reactionsRaw: unknown;
571
607
  let windowRaw: unknown;
608
+ let rolesRaw: unknown;
609
+ let relationsRaw: unknown;
572
610
 
573
611
  for (const [key, value] of Object.entries(raw)) {
574
612
  if (key === 'from') {
@@ -587,6 +625,11 @@ function parseObject(
587
625
  fields[fieldName] = parseField(fieldRaw, `${path}.fields.${fieldName}`);
588
626
  }
589
627
  validateDerivedFields(fields, `${path}.fields`);
628
+ // 修饰关系要等整本字典就位才对得上(它指的是兄弟字段)
629
+ const modifiesIssues = validateFieldModifies(fields);
630
+ if (modifiesIssues.length > 0) {
631
+ throw new SomaDataConfigError(modifiesIssues.join(';'), `${path}.fields`);
632
+ }
590
633
  config.fields = fields;
591
634
  } else if (key === 'mock') {
592
635
  config.mock = value;
@@ -598,15 +641,40 @@ function parseObject(
598
641
  reactionsRaw = value;
599
642
  } else if (key === 'window') {
600
643
  windowRaw = value;
644
+ } else if (key === 'roles') {
645
+ rolesRaw = value;
646
+ } else if (key === 'relations') {
647
+ relationsRaw = value;
601
648
  } else {
602
649
  throw new SomaDataConfigError(
603
- `未知的声明字段 "${key}"(支持: from / transform / fields / mock / write / predicates / reactions / window)`,
650
+ `未知的声明字段 "${key}"(支持: ${SOMA_DATA_OBJECT_KEYS.join(' / ')})`,
604
651
  `${path}.${key}`,
605
652
  );
606
653
  }
607
654
  }
608
655
 
609
- // write / predicates / reactions 都必须在 fields 之后解析:它们的每条规则都要对着字典校验
656
+ // roles / relations / write / predicates / reactions 都必须在 fields 之后解析:
657
+ // 它们的每条规则都要对着字典校验。角色与关系尤其如此——它们的值就是字段名。
658
+ if (rolesRaw !== undefined) {
659
+ const issues = validateObjectRoles(rolesRaw, Object.keys(config.fields ?? {}));
660
+ if (issues.length > 0) {
661
+ throw new SomaDataConfigError(issues.join(';'), `${path}.roles`);
662
+ }
663
+ config.roles = rolesRaw as SomaDataObjectRoles;
664
+ }
665
+
666
+ if (relationsRaw !== undefined) {
667
+ const issues = validateObjectRelations(relationsRaw, {
668
+ fieldKeys: Object.keys(config.fields ?? {}),
669
+ objectNames: [...objectNames],
670
+ selfName: name,
671
+ });
672
+ if (issues.length > 0) {
673
+ throw new SomaDataConfigError(issues.join(';'), `${path}.relations`);
674
+ }
675
+ config.relations = relationsRaw as SomaDataObjectRelation[];
676
+ }
677
+
610
678
  if (writeRaw !== undefined) {
611
679
  config.write = parseWrite(writeRaw, config.fields ?? {}, `${path}.write`, objectNames);
612
680
  }
@@ -10,6 +10,7 @@
10
10
  import {
11
11
  SOMA_LAYOUT_ALIGNS,
12
12
  SOMA_LAYOUT_PRIORITIES,
13
+ SOMA_LAYOUT_SIZINGS,
13
14
  type SomaAlign,
14
15
  type SomaLayoutConstraint,
15
16
  type SomaLayoutNodeConstraint,
@@ -27,7 +28,6 @@ export interface LayoutParseDeps {
27
28
  fail(message: string, path: string): never;
28
29
  }
29
30
 
30
- const SIZINGS = new Set<string>(['fixed', 'hug', 'fill']);
31
31
  const WRAPS = new Set<string>(['none', 'below', 'reel']);
32
32
  const NODE_KEYS = new Set(['sizing', 'width', 'min', 'max', 'priority']);
33
33
  const SECTION_KEYS = new Set(['gap', 'wrap', 'align', 'container_name', 'nodes']);
@@ -77,9 +77,10 @@ export function parseLayoutConstraint(
77
77
  }
78
78
  }
79
79
  const sizing = String(rawNode.sizing ?? '');
80
- if (!SIZINGS.has(sizing)) {
80
+ // 三档闭集只认 `SOMA_LAYOUT_SIZINGS` 这一份(与 `ooui:` 区域的 sizing 同源)
81
+ if (!(SOMA_LAYOUT_SIZINGS as readonly string[]).includes(sizing)) {
81
82
  fail(
82
- `${at}.sizing 只能是 ${[...SIZINGS].join(' / ')}(收到 ${JSON.stringify(rawNode.sizing)})`
83
+ `${at}.sizing 只能是 ${SOMA_LAYOUT_SIZINGS.join(' / ')}(收到 ${JSON.stringify(rawNode.sizing)})`
83
84
  + '——fixed 是"就这么宽",hug 是"内容多宽我多宽",fill 是"剩下的给我"',
84
85
  `${at}.sizing`,
85
86
  );
@@ -18,7 +18,6 @@ import type {
18
18
  SomaCompiledReaction,
19
19
  SomaFieldProvenance,
20
20
  SomaFieldStatePatch,
21
- SomaFormStatePatch,
22
21
  SomaReactionConfig,
23
22
  SomaReactionGraph,
24
23
  SomaReactionPhase,