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
@@ -48,6 +48,8 @@ __export(index_exports, {
48
48
  SOMA_AGGREGATE_FNS: () => SOMA_AGGREGATE_FNS,
49
49
  SOMA_DATA_FIELD_TYPES: () => SOMA_DATA_FIELD_TYPES,
50
50
  SOMA_DATA_FIELD_TYPE_ALIASES: () => SOMA_DATA_FIELD_TYPE_ALIASES,
51
+ SOMA_DATA_OBJECT_ROLES: () => SOMA_DATA_OBJECT_ROLES,
52
+ SOMA_DATA_RELATION_CARDINALITIES: () => SOMA_DATA_RELATION_CARDINALITIES,
51
53
  SOMA_DEFAULT_HYSTERESIS: () => SOMA_DEFAULT_HYSTERESIS,
52
54
  SOMA_FIELD_DISPLAYS: () => SOMA_FIELD_DISPLAYS,
53
55
  SOMA_FIELD_PATTERNS: () => SOMA_FIELD_PATTERNS,
@@ -107,7 +109,6 @@ __export(index_exports, {
107
109
  collectPredicateFields: () => collectPredicateFields,
108
110
  compileAdaptive: () => compileAdaptive,
109
111
  compileFieldSugar: () => compileFieldSugar,
110
- compilePageAssets: () => compilePageAssets,
111
112
  compileSomaBlocks: () => compileSomaBlocks,
112
113
  componentTokenPrefix: () => componentTokenPrefix,
113
114
  componentTokenVar: () => componentTokenVar,
@@ -123,6 +124,7 @@ __export(index_exports, {
123
124
  createWindow: () => createWindow,
124
125
  decodePageState: () => decodePageState,
125
126
  defaultPipeRegistry: () => defaultPipeRegistry,
127
+ deriveContractPreviewSample: () => deriveContractPreviewSample,
126
128
  deriveContractSample: () => deriveContractSample,
127
129
  deriveFieldSample: () => deriveFieldSample,
128
130
  deriveKeyboardMatrix: () => deriveKeyboardMatrix,
@@ -4267,8 +4269,8 @@ function requireDumper() {
4267
4269
  return state2.quotingType === QUOTING_TYPE_DOUBLE ? '"' + string + '"' : "'" + string + "'";
4268
4270
  }
4269
4271
  }
4270
- const indent2 = state2.indent * Math.max(1, level);
4271
- const lineWidth = state2.lineWidth === -1 ? -1 : Math.max(Math.min(state2.lineWidth, 40), state2.lineWidth - indent2);
4272
+ const indent = state2.indent * Math.max(1, level);
4273
+ const lineWidth = state2.lineWidth === -1 ? -1 : Math.max(Math.min(state2.lineWidth, 40), state2.lineWidth - indent);
4272
4274
  const singleLineOnly = iskey || // No block styles in flow mode.
4273
4275
  state2.flowLevel > -1 && level >= state2.flowLevel;
4274
4276
  function testAmbiguity(string2) {
@@ -4289,9 +4291,9 @@ function requireDumper() {
4289
4291
  case STYLE_SINGLE:
4290
4292
  return "'" + string.replace(/'/g, "''") + "'";
4291
4293
  case STYLE_LITERAL:
4292
- return "|" + blockHeader(string, state2.indent) + dropEndingNewline(indentString(string, indent2));
4294
+ return "|" + blockHeader(string, state2.indent) + dropEndingNewline(indentString(string, indent));
4293
4295
  case STYLE_FOLDED:
4294
- return ">" + blockHeader(string, state2.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent2));
4296
+ return ">" + blockHeader(string, state2.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
4295
4297
  case STYLE_DOUBLE:
4296
4298
  return '"' + escapeString(string) + '"';
4297
4299
  default:
@@ -4630,7 +4632,7 @@ function requireDumper() {
4630
4632
  }
4631
4633
  }
4632
4634
  }
4633
- function dump22(input, options) {
4635
+ function dump2(input, options) {
4634
4636
  options = options || {};
4635
4637
  const state2 = new State(options);
4636
4638
  if (!state2.noRefs) getDuplicateReferences(input, state2);
@@ -4641,7 +4643,7 @@ function requireDumper() {
4641
4643
  if (writeNode(state2, 0, value, true, true)) return state2.dump + "\n";
4642
4644
  return "";
4643
4645
  }
4644
- dumper.dump = dump22;
4646
+ dumper.dump = dump2;
4645
4647
  return dumper;
4646
4648
  }
4647
4649
  var hasRequiredJsYaml;
@@ -5110,9 +5112,9 @@ function producesArray(pipelineType) {
5110
5112
  }
5111
5113
  function parseSteps(input, deps) {
5112
5114
  const { raw: raw2, payloadFields, path } = input;
5113
- const fail2 = deps.fail;
5115
+ const fail = deps.fail;
5114
5116
  if (!Array.isArray(raw2) || raw2.length === 0) {
5115
- fail2("steps \u5FC5\u987B\u662F\u975E\u7A7A\u6570\u7EC4", path);
5117
+ fail("steps \u5FC5\u987B\u662F\u975E\u7A7A\u6570\u7EC4", path);
5116
5118
  }
5117
5119
  const slots = {};
5118
5120
  const edges = [];
@@ -5123,22 +5125,22 @@ function parseSteps(input, deps) {
5123
5125
  for (const field of collectPredicateFields(when)) {
5124
5126
  const root = field.split(".")[0];
5125
5127
  if (!payloadFields.includes(root) && slots[root] === void 0) {
5126
- fail2(
5128
+ fail(
5127
5129
  `${at} \u5F15\u7528\u4E86 "${root}"\uFF0C\u4F46\u5B83\u65E2\u4E0D\u662F\u4E8B\u4EF6\u8F7D\u8377\u5B57\u6BB5\uFF08${payloadFields.join(" / ") || "\u65E0"}\uFF09\uFF0C\u4E5F\u4E0D\u662F\u5148\u4E8E\u672C\u6B65\u58F0\u660E\u7684\u8F93\u51FA\u69FD\uFF08${Object.keys(slots).join(" / ") || "\u65E0"}\uFF09`,
5128
5130
  at
5129
5131
  );
5130
5132
  }
5131
5133
  }
5132
5134
  const issues = validatePredicate(when, scopeKeys(), at, {});
5133
- if (issues.length > 0) fail2(issues.join("\uFF1B"), at);
5135
+ if (issues.length > 0) fail(issues.join("\uFF1B"), at);
5134
5136
  };
5135
5137
  const declareSlot = (name, at, index, pipelineType) => {
5136
5138
  const slot = String(name ?? "");
5137
5139
  if (!SLOT_NAME_PATTERN.test(slot)) {
5138
- fail2(`${at}.output "${slot}" \u4E0D\u662F\u5408\u6CD5\u69FD\u540D\uFF08\u5C0F\u5199\u5B57\u6BCD\u5F00\u5934\u3001\u4E0B\u5212\u7EBF\u5206\u9694\uFF09`, `${at}.output`);
5140
+ fail(`${at}.output "${slot}" \u4E0D\u662F\u5408\u6CD5\u69FD\u540D\uFF08\u5C0F\u5199\u5B57\u6BCD\u5F00\u5934\u3001\u4E0B\u5212\u7EBF\u5206\u9694\uFF09`, `${at}.output`);
5139
5141
  }
5140
5142
  if (slots[slot] !== void 0) {
5141
- fail2(
5143
+ fail(
5142
5144
  `${at}.output \u69FD\u540D "${slot}" \u4E0E\u7B2C ${slots[slot].declaredAt + 1} \u6B65\u91CD\u540D\u2014\u2014\u540C\u540D\u69FD\u7684\u540E\u5199\u4F1A\u8986\u76D6\u524D\u5199\uFF0C\u800C\u5F15\u7528\u5B83\u7684\u6761\u4EF6\u8BFB\u5230\u54EA\u4E00\u4E2A\u53D6\u51B3\u4E8E\u6B65\u9AA4\u6B21\u5E8F`,
5143
5145
  `${at}.output`
5144
5146
  );
@@ -5148,12 +5150,12 @@ function parseSteps(input, deps) {
5148
5150
  };
5149
5151
  const parsePipe = (expression, at) => {
5150
5152
  if (typeof expression !== "string" || expression.trim() === "") {
5151
- fail2(`${at}.do \u5FC5\u987B\u662F\u7BA1\u9053\u8868\u8FBE\u5F0F\u5B57\u7B26\u4E32`, `${at}.do`);
5153
+ fail(`${at}.do \u5FC5\u987B\u662F\u7BA1\u9053\u8868\u8FBE\u5F0F\u5B57\u7B26\u4E32`, `${at}.do`);
5152
5154
  }
5153
5155
  try {
5154
5156
  return deps.parsePipeline(expression);
5155
5157
  } catch (error) {
5156
- fail2(error instanceof Error ? error.message : String(error), `${at}.do`);
5158
+ fail(error instanceof Error ? error.message : String(error), `${at}.do`);
5157
5159
  }
5158
5160
  };
5159
5161
  const parseOnError = (value, at, total, index) => {
@@ -5162,17 +5164,17 @@ function parseSteps(input, deps) {
5162
5164
  if (raw22 === "stop" || raw22 === "continue") return raw22;
5163
5165
  const match = /^goto:(\d+)$/.exec(raw22);
5164
5166
  if (!match) {
5165
- fail2(`${at}.on_error \u53EA\u80FD\u662F stop / continue / goto:<\u6B65\u9AA4\u5E8F\u53F7>\uFF08\u6536\u5230 "${raw22}"\uFF09`, `${at}.on_error`);
5167
+ fail(`${at}.on_error \u53EA\u80FD\u662F stop / continue / goto:<\u6B65\u9AA4\u5E8F\u53F7>\uFF08\u6536\u5230 "${raw22}"\uFF09`, `${at}.on_error`);
5166
5168
  }
5167
5169
  const target = Number(match[1]);
5168
5170
  if (target <= index + 1) {
5169
- fail2(
5171
+ fail(
5170
5172
  `${at}.on_error \u7684 goto:${target} \u6307\u5411\u7B2C ${target} \u6B65\uFF0C\u4E0D\u5728\u672C\u6B65\uFF08\u7B2C ${index + 1} \u6B65\uFF09\u4E4B\u540E\u2014\u2014\u53EA\u8BB8\u5411\u540E\u8DF3\uFF0C\u5426\u5219\u7F16\u6392\u53EF\u4EE5\u4E0D\u7EC8\u6B62`,
5171
5173
  `${at}.on_error`
5172
5174
  );
5173
5175
  }
5174
5176
  if (target > total) {
5175
- fail2(`${at}.on_error \u7684 goto:${target} \u8D8A\u8FC7\u4E86\u672B\u6B65\uFF08\u5171 ${total} \u6B65\uFF09`, `${at}.on_error`);
5177
+ fail(`${at}.on_error \u7684 goto:${target} \u8D8A\u8FC7\u4E86\u672B\u6B65\uFF08\u5171 ${total} \u6B65\uFF09`, `${at}.on_error`);
5176
5178
  }
5177
5179
  return `goto:${target}`;
5178
5180
  };
@@ -5181,10 +5183,10 @@ function parseSteps(input, deps) {
5181
5183
  const parallelLocalSlots = [];
5182
5184
  list.forEach((entry, position) => {
5183
5185
  const stepAt = `${at}[${position}]`;
5184
- if (!isPlainObject(entry)) fail2(`${stepAt} \u5FC5\u987B\u662F\u6620\u5C04`, stepAt);
5186
+ if (!isPlainObject(entry)) fail(`${stepAt} \u5FC5\u987B\u662F\u6620\u5C04`, stepAt);
5185
5187
  for (const key of Object.keys(entry)) {
5186
5188
  if (!STEP_KEYS.has(key)) {
5187
- fail2(`${stepAt} \u6709\u672A\u77E5\u952E "${key}"\uFF08\u652F\u6301: ${[...STEP_KEYS].join(" / ")}\uFF09`, `${stepAt}.${key}`);
5189
+ fail(`${stepAt} \u6709\u672A\u77E5\u952E "${key}"\uFF08\u652F\u6301: ${[...STEP_KEYS].join(" / ")}\uFF09`, `${stepAt}.${key}`);
5188
5190
  }
5189
5191
  }
5190
5192
  const index = counter;
@@ -5192,7 +5194,7 @@ function parseSteps(input, deps) {
5192
5194
  if (out.length > 0) edges.push([out[out.length - 1].index, index]);
5193
5195
  if (entry.parallel !== void 0) {
5194
5196
  if (!Array.isArray(entry.parallel) || entry.parallel.length < 2) {
5195
- fail2(`${stepAt}.parallel \u81F3\u5C11\u8981\u4E24\u4E2A\u5206\u652F\uFF08\u4E00\u4E2A\u5206\u652F\u7684\u5E76\u884C\u5C31\u662F\u987A\u5E8F\uFF09`, `${stepAt}.parallel`);
5197
+ fail(`${stepAt}.parallel \u81F3\u5C11\u8981\u4E24\u4E2A\u5206\u652F\uFF08\u4E00\u4E2A\u5206\u652F\u7684\u5E76\u884C\u5C31\u662F\u987A\u5E8F\uFF09`, `${stepAt}.parallel`);
5196
5198
  }
5197
5199
  const before = new Set(Object.keys(slots));
5198
5200
  const children = walk(entry.parallel, `${stepAt}.parallel`, depth, true);
@@ -5203,34 +5205,34 @@ function parseSteps(input, deps) {
5203
5205
  }
5204
5206
  if (entry.for_each !== void 0) {
5205
5207
  if (depth + 1 > MAX_FOR_EACH_DEPTH) {
5206
- fail2(
5208
+ fail(
5207
5209
  `${stepAt}.for_each \u5D4C\u5957\u8D85\u8FC7 ${MAX_FOR_EACH_DEPTH} \u5C42\u2014\u2014\u4E09\u5C42\u904D\u5386\u5728\u58F0\u660E\u5C42\u51E0\u4E4E\u80AF\u5B9A\u662F\u6570\u636E\u7ED3\u6784\u6CA1\u8BBE\u8BA1\u5BF9`,
5208
5210
  `${stepAt}.for_each`
5209
5211
  );
5210
5212
  }
5211
5213
  const box = entry.for_each;
5212
- if (!isPlainObject(box)) fail2(`${stepAt}.for_each \u5FC5\u987B\u662F { over, as, steps }`, `${stepAt}.for_each`);
5214
+ if (!isPlainObject(box)) fail(`${stepAt}.for_each \u5FC5\u987B\u662F { over, as, steps }`, `${stepAt}.for_each`);
5213
5215
  const over = String(box.over ?? "");
5214
5216
  const as = String(box.as ?? "");
5215
5217
  const isPayload = payloadFields.includes(over);
5216
5218
  const slot = slots[over];
5217
5219
  if (!isPayload && slot === void 0) {
5218
- fail2(
5220
+ fail(
5219
5221
  `${stepAt}.for_each.over "${over}" \u65E2\u4E0D\u662F\u4E8B\u4EF6\u8F7D\u8377\u5B57\u6BB5\uFF0C\u4E5F\u4E0D\u662F\u5148\u4E8E\u672C\u6B65\u58F0\u660E\u7684\u8F93\u51FA\u69FD`,
5220
5222
  `${stepAt}.for_each.over`
5221
5223
  );
5222
5224
  }
5223
5225
  if (slot !== void 0 && !slot.bounded) {
5224
- fail2(
5226
+ fail(
5225
5227
  `${stepAt}.for_each.over "${over}" \u6765\u81EA ${slot.producedBy}\uFF0C\u5B83\u4E0D\u8FD4\u56DE\u6570\u7EC4\u2014\u2014\u904D\u5386\u4E00\u4E2A\u4E0D\u662F\u6570\u7EC4\u7684\u4E1C\u897F\uFF0C\u6B65\u6570\u5C31\u6CA1\u6709\u4E0A\u754C\u4E86`,
5226
5228
  `${stepAt}.for_each.over`
5227
5229
  );
5228
5230
  }
5229
5231
  if (!SLOT_NAME_PATTERN.test(as)) {
5230
- fail2(`${stepAt}.for_each.as "${as}" \u4E0D\u662F\u5408\u6CD5\u9879\u540D`, `${stepAt}.for_each.as`);
5232
+ fail(`${stepAt}.for_each.as "${as}" \u4E0D\u662F\u5408\u6CD5\u9879\u540D`, `${stepAt}.for_each.as`);
5231
5233
  }
5232
5234
  if (!Array.isArray(box.steps) || box.steps.length === 0) {
5233
- fail2(`${stepAt}.for_each.steps \u5FC5\u987B\u662F\u975E\u7A7A\u6570\u7EC4`, `${stepAt}.for_each.steps`);
5235
+ fail(`${stepAt}.for_each.steps \u5FC5\u987B\u662F\u975E\u7A7A\u6570\u7EC4`, `${stepAt}.for_each.steps`);
5234
5236
  }
5235
5237
  slots[as] = { declaredAt: index, producedBy: "for_each", bounded: false };
5236
5238
  const children = walk(box.steps, `${stepAt}.for_each.steps`, depth + 1, inParallel);
@@ -5240,30 +5242,30 @@ function parseSteps(input, deps) {
5240
5242
  }
5241
5243
  if (entry.switch !== void 0) {
5242
5244
  if (!Array.isArray(entry.switch) || entry.switch.length === 0) {
5243
- fail2(`${stepAt}.switch \u5FC5\u987B\u662F\u975E\u7A7A\u5206\u652F\u6570\u7EC4`, `${stepAt}.switch`);
5245
+ fail(`${stepAt}.switch \u5FC5\u987B\u662F\u975E\u7A7A\u5206\u652F\u6570\u7EC4`, `${stepAt}.switch`);
5244
5246
  }
5245
5247
  checkWhen(entry.when, `${stepAt}.when`);
5246
5248
  const list2 = entry.switch;
5247
5249
  const branches = [];
5248
5250
  const otherwiseAt = list2.map((branch, position2) => isPlainObject(branch) && branch.otherwise === true ? position2 : -1).filter((position2) => position2 !== -1);
5249
5251
  if (otherwiseAt.length > 1) {
5250
- fail2(
5252
+ fail(
5251
5253
  `${stepAt}.switch \u6709 ${otherwiseAt.length} \u4E2A otherwise \u5206\u652F\uFF08\u7B2C ${otherwiseAt.map((n) => n + 1).join(" / ")} \u4E2A\uFF09\u2014\u2014\u515C\u5E95\u53EA\u80FD\u6709\u4E00\u4E2A`,
5252
5254
  `${stepAt}.switch`
5253
5255
  );
5254
5256
  }
5255
5257
  if (otherwiseAt.length === 1 && otherwiseAt[0] !== list2.length - 1) {
5256
- fail2(
5258
+ fail(
5257
5259
  `${stepAt}.switch[${otherwiseAt[0]}] \u7684 otherwise \u5FC5\u987B\u662F\u6700\u540E\u4E00\u4E2A\u5206\u652F\uFF08\u5B83\u662F\u515C\u5E95\uFF0C\u540E\u9762\u7684\u5206\u652F\u6C38\u8FDC\u8D70\u4E0D\u5230\uFF09`,
5258
5260
  `${stepAt}.switch[${otherwiseAt[0]}]`
5259
5261
  );
5260
5262
  }
5261
5263
  list2.forEach((branchRaw, branchIndex) => {
5262
5264
  const branchAt = `${stepAt}.switch[${branchIndex}]`;
5263
- if (!isPlainObject(branchRaw)) fail2(`${branchAt} \u5FC5\u987B\u662F\u6620\u5C04`, branchAt);
5265
+ if (!isPlainObject(branchRaw)) fail(`${branchAt} \u5FC5\u987B\u662F\u6620\u5C04`, branchAt);
5264
5266
  const otherwise = branchRaw.otherwise === true;
5265
5267
  if (!otherwise && branchRaw.when === void 0) {
5266
- fail2(`${branchAt} \u65E2\u6CA1\u6709 when \u4E5F\u4E0D\u662F otherwise\u2014\u2014\u5B83\u4F1A\u65E0\u6761\u4EF6\u547D\u4E2D\u5E76\u5403\u6389\u540E\u9762\u7684\u5206\u652F`, branchAt);
5268
+ fail(`${branchAt} \u65E2\u6CA1\u6709 when \u4E5F\u4E0D\u662F otherwise\u2014\u2014\u5B83\u4F1A\u65E0\u6761\u4EF6\u547D\u4E2D\u5E76\u5403\u6389\u540E\u9762\u7684\u5206\u652F`, branchAt);
5267
5269
  }
5268
5270
  if (!otherwise) checkWhen(branchRaw.when, `${branchAt}.when`);
5269
5271
  const pipeline2 = parsePipe(branchRaw.do, branchAt);
@@ -5303,7 +5305,7 @@ function parseSteps(input, deps) {
5303
5305
  if (!parallelLocalSlots.includes(root)) continue;
5304
5306
  const owner = out.findIndex((other) => other.output === root);
5305
5307
  if (owner !== -1 && owner !== position) {
5306
- fail2(
5308
+ fail(
5307
5309
  `${at}[${position}] \u7684 when \u5F15\u7528\u4E86\u540C\u4E00\u4E2A parallel \u91CC\u53E6\u4E00\u4E2A\u5206\u652F\u7684\u8F93\u51FA\u69FD "${root}"\u2014\u2014\u5E76\u884C\u5206\u652F\u4E4B\u95F4\u4E0D\u8BB8\u4E92\u5F15\uFF1A\u4E92\u5F15\u5C31\u610F\u5473\u7740\u6709\u987A\u5E8F\uFF0C\u90A3\u5B83\u5C31\u4E0D\u8BE5\u5199\u6210 parallel`,
5308
5310
  `${at}[${position}].when`
5309
5311
  );
@@ -5326,7 +5328,7 @@ function parseSteps(input, deps) {
5326
5328
  if (pipe.type !== "ACTION") continue;
5327
5329
  const name = String(pipe.funcPath ?? "");
5328
5330
  if (!known.has(name)) {
5329
- fail2(
5331
+ fail(
5330
5332
  `do: ACTION | ${name} \u2014\u2014 \u672A\u6CE8\u518C\u7684\u5177\u540D\u52A8\u4F5C\uFF08\u5DF2\u6CE8\u518C\uFF1A${[...known].join(" / ") || "\u65E0"}\uFF09\u3002\u5177\u540D\u52A8\u4F5C\u5728 bootstrap \u7684 options.actions \u91CC\u767B\u8BB0\uFF0C\u8FD9\u662F custom(script) \u7684\u66FF\u4EE3\uFF1A\u5B9E\u73B0\u5728 Host \u4EE3\u7801\u91CC\u3001\u6709\u540D\u5B57\u3001\u53EF\u5BA1\u8BA1\u3002`,
5331
5333
  path
5332
5334
  );
@@ -6027,6 +6029,82 @@ function parseStyleConfig(raw2) {
6027
6029
  };
6028
6030
  }
6029
6031
 
6032
+ // core/shared/types/layout-constraint.types.ts
6033
+ var SOMA_LAYOUT_PRIORITIES = [250, 500, 750, 1e3];
6034
+ var SIZING_SET = {
6035
+ fixed: true,
6036
+ hug: true,
6037
+ fill: true
6038
+ };
6039
+ var SOMA_LAYOUT_SIZINGS = Object.keys(SIZING_SET);
6040
+ var SOMA_LAYOUT_ALIGNS = [
6041
+ "start",
6042
+ "center",
6043
+ "end",
6044
+ "baseline",
6045
+ "space_between",
6046
+ "space_evenly",
6047
+ "space_around"
6048
+ ];
6049
+
6050
+ // core/shared/ooui-declaration.ts
6051
+ var SOMA_OOUI_ANCHOR_PATTERN = /^[A-Za-z_][A-Za-z0-9_-]*$/;
6052
+ var SOMA_OOUI_ANCHOR_GRAMMAR = "\u5B57\u6BCD\u6216\u4E0B\u5212\u7EBF\u5F00\u5934\uFF0C\u5176\u4F59\u53EF\u542B\u5B57\u6BCD\u3001\u6570\u5B57\u3001- \u4E0E _";
6053
+ var REQUEST_KEY_SET = {
6054
+ object: true,
6055
+ verb: true,
6056
+ focus: true,
6057
+ through: true,
6058
+ form: true,
6059
+ bound_to: true,
6060
+ layout: true
6061
+ };
6062
+ var SOMA_OOUI_REQUEST_KEYS = Object.keys(REQUEST_KEY_SET);
6063
+ var LAYOUT_VALUE_TYPES = {
6064
+ sizing: "string",
6065
+ width: "string",
6066
+ min: "string",
6067
+ max: "string",
6068
+ priority: "number"
6069
+ };
6070
+ var SOMA_OOUI_LAYOUT_KEYS = Object.keys(LAYOUT_VALUE_TYPES);
6071
+ var SOMA_OOUI_SIZINGS = SOMA_LAYOUT_SIZINGS;
6072
+ function isOouiSizing(value) {
6073
+ return typeof value === "string" && SOMA_OOUI_SIZINGS.includes(value);
6074
+ }
6075
+ function isOouiMap(value) {
6076
+ return value !== null && typeof value === "object" && !Array.isArray(value);
6077
+ }
6078
+ function isOouiText(value) {
6079
+ return typeof value === "string" && value.trim() !== "";
6080
+ }
6081
+ function isOouiFocus(value) {
6082
+ return Array.isArray(value) && value.length > 0 && value.every((item) => isOouiText(item));
6083
+ }
6084
+ var BINDING_KEY_SET = {
6085
+ region: true,
6086
+ as: true
6087
+ };
6088
+ var SOMA_OOUI_BINDING_KEYS = Object.keys(BINDING_KEY_SET);
6089
+ function findOouiBindingUnknownKey(binding) {
6090
+ return Object.keys(binding).find((key) => !SOMA_OOUI_BINDING_KEYS.includes(key));
6091
+ }
6092
+ function isOouiBinding(value) {
6093
+ return isOouiMap(value) && findOouiBindingUnknownKey(value) === void 0 && isOouiText(value.region) && isOouiText(value.as);
6094
+ }
6095
+ function findOouiLayoutProblem(layout) {
6096
+ for (const [key, value] of Object.entries(layout)) {
6097
+ if (!SOMA_OOUI_LAYOUT_KEYS.includes(key)) return { key, kind: "unknown-key" };
6098
+ const expected = LAYOUT_VALUE_TYPES[key];
6099
+ if (typeof value !== expected) return { key, kind: "value-type", expected };
6100
+ if (key === "sizing" && !isOouiSizing(value)) return { key, kind: "sizing-unknown" };
6101
+ }
6102
+ return void 0;
6103
+ }
6104
+ function isOouiLayout(value) {
6105
+ return isOouiMap(value) && findOouiLayoutProblem(value) === void 0;
6106
+ }
6107
+
6030
6108
  // core/shared/types/adaptive.types.ts
6031
6109
  var SOMA_ADAPTIVE_PROFILES = ["dashboard", "form", "list", "console"];
6032
6110
  var SOMA_ADAPTIVE_MAX_LADDER = 5;
@@ -6207,24 +6285,24 @@ function isPlainObject2(value) {
6207
6285
  }
6208
6286
  function parsePageState(input, deps) {
6209
6287
  const { raw: raw2, objectNames, anchorIds, path } = input;
6210
- const fail2 = deps.fail;
6211
- if (!isPlainObject2(raw2)) fail2("state \u5FC5\u987B\u662F\u6620\u5C04", path);
6288
+ const fail = deps.fail;
6289
+ if (!isPlainObject2(raw2)) fail("state \u5FC5\u987B\u662F\u6620\u5C04", path);
6212
6290
  for (const key of Object.keys(raw2)) {
6213
6291
  if (!CONFIG_KEYS.has(key)) {
6214
- fail2(`\u672A\u77E5\u7684 state \u5B57\u6BB5 "${key}"\uFF08\u652F\u6301: ${[...CONFIG_KEYS].join(" / ")}\uFF09`, `${path}.${key}`);
6292
+ fail(`\u672A\u77E5\u7684 state \u5B57\u6BB5 "${key}"\uFF08\u652F\u6301: ${[...CONFIG_KEYS].join(" / ")}\uFF09`, `${path}.${key}`);
6215
6293
  }
6216
6294
  }
6217
6295
  const version = raw2.version;
6218
6296
  if (!Number.isInteger(version) || version < 1) {
6219
- fail2("state.version \u5FC5\u586B\uFF0C\u4E14\u5FC5\u987B\u662F \u2265 1 \u7684\u6574\u6570\uFF08\u5B83\u51B3\u5B9A\u4E00\u4EFD\u65E7\u72B6\u6001\u8BE5\u4E0D\u8BE5\u88AB\u4E22\u5F03\uFF09", `${path}.version`);
6297
+ fail("state.version \u5FC5\u586B\uFF0C\u4E14\u5FC5\u987B\u662F \u2265 1 \u7684\u6574\u6570\uFF08\u5B83\u51B3\u5B9A\u4E00\u4EFD\u65E7\u72B6\u6001\u8BE5\u4E0D\u8BE5\u88AB\u4E22\u5F03\uFF09", `${path}.version`);
6220
6298
  }
6221
6299
  const names = (value, at, allowed, what) => {
6222
6300
  if (value === void 0) return [];
6223
- if (!Array.isArray(value)) fail2(`${at} \u5FC5\u987B\u662F\u540D\u5B57\u6570\u7EC4`, at);
6301
+ if (!Array.isArray(value)) fail(`${at} \u5FC5\u987B\u662F\u540D\u5B57\u6570\u7EC4`, at);
6224
6302
  return value.map((entry) => {
6225
6303
  const name = String(entry);
6226
6304
  if (!allowed.includes(name)) {
6227
- fail2(`${at} \u91CC\u7684 "${name}" \u4E0D\u662F${what}\uFF08\u53EF\u9009\uFF1A${allowed.join(" / ") || "\u65E0"}\uFF09`, at);
6305
+ fail(`${at} \u91CC\u7684 "${name}" \u4E0D\u662F${what}\uFF08\u53EF\u9009\uFF1A${allowed.join(" / ") || "\u65E0"}\uFF09`, at);
6228
6306
  }
6229
6307
  return name;
6230
6308
  });
@@ -6238,12 +6316,12 @@ function parsePageState(input, deps) {
6238
6316
  if (raw2.expanded !== void 0) config.expanded = raw2.expanded === true;
6239
6317
  if (raw2.url !== void 0) config.url = raw2.url === true;
6240
6318
  if (raw2.initial_state !== void 0) {
6241
- config.initial_state = parseStateValue(raw2.initial_state, `${path}.initial_state`, config, fail2);
6319
+ config.initial_state = parseStateValue(raw2.initial_state, `${path}.initial_state`, config, fail);
6242
6320
  }
6243
6321
  return config;
6244
6322
  }
6245
- function parseStateValue(raw2, path, config, fail2) {
6246
- if (!isPlainObject2(raw2)) fail2(`${path} \u5FC5\u987B\u662F\u6620\u5C04`, path);
6323
+ function parseStateValue(raw2, path, config, fail) {
6324
+ if (!isPlainObject2(raw2)) fail(`${path} \u5FC5\u987B\u662F\u6620\u5C04`, path);
6247
6325
  const state2 = { version: config.version };
6248
6326
  if (raw2.version !== void 0 && raw2.version !== config.version) {
6249
6327
  state2.version = raw2.version;
@@ -6298,20 +6376,7 @@ function decodePageState(encoded) {
6298
6376
  }
6299
6377
  }
6300
6378
 
6301
- // core/shared/types/layout-constraint.types.ts
6302
- var SOMA_LAYOUT_PRIORITIES = [250, 500, 750, 1e3];
6303
- var SOMA_LAYOUT_ALIGNS = [
6304
- "start",
6305
- "center",
6306
- "end",
6307
- "baseline",
6308
- "space_between",
6309
- "space_evenly",
6310
- "space_around"
6311
- ];
6312
-
6313
6379
  // core/client/parser/layout-parser.ts
6314
- var SIZINGS = /* @__PURE__ */ new Set(["fixed", "hug", "fill"]);
6315
6380
  var WRAPS = /* @__PURE__ */ new Set(["none", "below", "reel"]);
6316
6381
  var NODE_KEYS = /* @__PURE__ */ new Set(["sizing", "width", "min", "max", "priority"]);
6317
6382
  var SECTION_KEYS = /* @__PURE__ */ new Set(["gap", "wrap", "align", "container_name", "nodes"]);
@@ -6321,8 +6386,8 @@ function isPlainObject3(value) {
6321
6386
  }
6322
6387
  function parseLayoutConstraint(input, deps) {
6323
6388
  const { raw: raw2, path } = input;
6324
- const fail2 = deps.fail;
6325
- if (!isPlainObject3(raw2)) fail2("layout \u5FC5\u987B\u662F\u6620\u5C04", path);
6389
+ const fail = deps.fail;
6390
+ if (!isPlainObject3(raw2)) fail("layout \u5FC5\u987B\u662F\u6620\u5C04", path);
6326
6391
  const explicit = isPlainObject3(raw2.nodes) ? raw2.nodes : null;
6327
6392
  const source = explicit ?? Object.fromEntries(
6328
6393
  Object.entries(raw2).filter(([key]) => !SECTION_KEYS.has(key))
@@ -6331,7 +6396,7 @@ function parseLayoutConstraint(input, deps) {
6331
6396
  for (const key of Object.keys(raw2)) {
6332
6397
  if (SECTION_KEYS.has(key)) continue;
6333
6398
  if (!NAME_PATTERN.test(key)) {
6334
- fail2(
6399
+ fail(
6335
6400
  `${path}.${key} \u65E2\u4E0D\u662F\u6BB5\u7EA7\u952E\uFF08${[...SECTION_KEYS].join(" / ")}\uFF09\uFF0C\u4E5F\u4E0D\u662F\u5408\u6CD5\u5B50\u9879\u540D\uFF08\u5C0F\u5199\u5B57\u6BCD\u5F00\u5934\u3001\u4E0B\u5212\u7EBF\u5206\u9694\uFF09`,
6336
6401
  `${path}.${key}`
6337
6402
  );
@@ -6341,16 +6406,16 @@ function parseLayoutConstraint(input, deps) {
6341
6406
  const nodes = {};
6342
6407
  for (const [name, rawNode] of Object.entries(source)) {
6343
6408
  const at = `${path}.${name}`;
6344
- if (!isPlainObject3(rawNode)) fail2(`${at} \u5FC5\u987B\u662F\u6620\u5C04`, at);
6409
+ if (!isPlainObject3(rawNode)) fail(`${at} \u5FC5\u987B\u662F\u6620\u5C04`, at);
6345
6410
  for (const key of Object.keys(rawNode)) {
6346
6411
  if (!NODE_KEYS.has(key)) {
6347
- fail2(`${at} \u6709\u672A\u77E5\u952E "${key}"\uFF08\u652F\u6301: ${[...NODE_KEYS].join(" / ")}\uFF09`, `${at}.${key}`);
6412
+ fail(`${at} \u6709\u672A\u77E5\u952E "${key}"\uFF08\u652F\u6301: ${[...NODE_KEYS].join(" / ")}\uFF09`, `${at}.${key}`);
6348
6413
  }
6349
6414
  }
6350
6415
  const sizing = String(rawNode.sizing ?? "");
6351
- if (!SIZINGS.has(sizing)) {
6352
- fail2(
6353
- `${at}.sizing \u53EA\u80FD\u662F ${[...SIZINGS].join(" / ")}\uFF08\u6536\u5230 ${JSON.stringify(rawNode.sizing)}\uFF09\u2014\u2014fixed \u662F"\u5C31\u8FD9\u4E48\u5BBD"\uFF0Chug \u662F"\u5185\u5BB9\u591A\u5BBD\u6211\u591A\u5BBD"\uFF0Cfill \u662F"\u5269\u4E0B\u7684\u7ED9\u6211"`,
6416
+ if (!SOMA_LAYOUT_SIZINGS.includes(sizing)) {
6417
+ fail(
6418
+ `${at}.sizing \u53EA\u80FD\u662F ${SOMA_LAYOUT_SIZINGS.join(" / ")}\uFF08\u6536\u5230 ${JSON.stringify(rawNode.sizing)}\uFF09\u2014\u2014fixed \u662F"\u5C31\u8FD9\u4E48\u5BBD"\uFF0Chug \u662F"\u5185\u5BB9\u591A\u5BBD\u6211\u591A\u5BBD"\uFF0Cfill \u662F"\u5269\u4E0B\u7684\u7ED9\u6211"`,
6354
6419
  `${at}.sizing`
6355
6420
  );
6356
6421
  }
@@ -6359,7 +6424,7 @@ function parseLayoutConstraint(input, deps) {
6359
6424
  if (rawNode[key] === void 0) continue;
6360
6425
  const literal = String(rawNode[key]);
6361
6426
  if (!/^\d+(?:\.\d+)?(rem|%|cqi)$/.test(literal)) {
6362
- fail2(
6427
+ fail(
6363
6428
  `${at}.${key} \u7684\u957F\u5EA6 "${literal}" \u975E\u6CD5\u2014\u2014\u53EA\u8BA4 rem / % / cqi\uFF08\u5355\u4F4D\u5FC5\u586B\uFF0C\u4E0D\u731C\uFF09`,
6364
6429
  `${at}.${key}`
6365
6430
  );
@@ -6369,7 +6434,7 @@ function parseLayoutConstraint(input, deps) {
6369
6434
  if (rawNode.priority !== void 0) {
6370
6435
  const priority = Number(rawNode.priority);
6371
6436
  if (!SOMA_LAYOUT_PRIORITIES.includes(priority)) {
6372
- fail2(
6437
+ fail(
6373
6438
  `${at}.priority \u53EA\u80FD\u662F ${SOMA_LAYOUT_PRIORITIES.join(" / ")}\uFF08\u6536\u5230 ${String(rawNode.priority)}\uFF09\u2014\u2014250 \u662F"\u6211\u613F\u610F\u88AB\u62C9\u5927"\uFF0C750 \u662F"\u6211\u4E0D\u613F\u610F\u88AB\u538B\u5C0F"\uFF0C1000 \u662F\u4E0D\u53EF\u8FDD\u53CD`,
6374
6439
  `${at}.priority`
6375
6440
  );
@@ -6379,27 +6444,27 @@ function parseLayoutConstraint(input, deps) {
6379
6444
  nodes[name] = node;
6380
6445
  }
6381
6446
  if (Object.keys(nodes).length === 0) {
6382
- fail2(`${path} \u81F3\u5C11\u8981\u6709\u4E00\u4E2A\u5B50\u9879`, path);
6447
+ fail(`${path} \u81F3\u5C11\u8981\u6709\u4E00\u4E2A\u5B50\u9879`, path);
6383
6448
  }
6384
6449
  const constraint = { nodes };
6385
6450
  if (raw2.gap !== void 0) {
6386
6451
  const gap = String(raw2.gap);
6387
6452
  if (!/^\d+(?:\.\d+)?(rem|%|cqi)$/.test(gap)) {
6388
- fail2(`${path}.gap \u7684\u957F\u5EA6 "${gap}" \u975E\u6CD5\u2014\u2014\u53EA\u8BA4 rem / % / cqi`, `${path}.gap`);
6453
+ fail(`${path}.gap \u7684\u957F\u5EA6 "${gap}" \u975E\u6CD5\u2014\u2014\u53EA\u8BA4 rem / % / cqi`, `${path}.gap`);
6389
6454
  }
6390
6455
  constraint.gap = gap;
6391
6456
  }
6392
6457
  if (raw2.wrap !== void 0) {
6393
6458
  const wrap = String(raw2.wrap);
6394
6459
  if (!WRAPS.has(wrap)) {
6395
- fail2(`${path}.wrap \u53EA\u80FD\u662F ${[...WRAPS].join(" / ")}\uFF08\u6536\u5230 ${JSON.stringify(raw2.wrap)}\uFF09`, `${path}.wrap`);
6460
+ fail(`${path}.wrap \u53EA\u80FD\u662F ${[...WRAPS].join(" / ")}\uFF08\u6536\u5230 ${JSON.stringify(raw2.wrap)}\uFF09`, `${path}.wrap`);
6396
6461
  }
6397
6462
  constraint.wrap = wrap;
6398
6463
  }
6399
6464
  if (raw2.align !== void 0) {
6400
6465
  const align = String(raw2.align);
6401
6466
  if (!SOMA_LAYOUT_ALIGNS.includes(align)) {
6402
- fail2(
6467
+ fail(
6403
6468
  `${path}.align \u53EA\u80FD\u662F ${SOMA_LAYOUT_ALIGNS.join(" / ")}\uFF08\u6536\u5230 ${JSON.stringify(raw2.align)}\uFF09`,
6404
6469
  `${path}.align`
6405
6470
  );
@@ -6409,7 +6474,7 @@ function parseLayoutConstraint(input, deps) {
6409
6474
  if (raw2.container_name !== void 0) {
6410
6475
  const containerName = String(raw2.container_name);
6411
6476
  if (!/^[a-z][a-z0-9-]*$/.test(containerName)) {
6412
- fail2(
6477
+ fail(
6413
6478
  `${path}.container_name "${containerName}" \u4E0D\u662F\u5408\u6CD5\u7684\u5BB9\u5668\u540D\uFF08\u5C0F\u5199\u5B57\u6BCD\u5F00\u5934\u3001\u8FDE\u5B57\u7B26\u5206\u9694\uFF1B\u5B83\u8981\u51FA\u73B0\u5728 CSS \u7684 container-name \u4E0A\uFF09`,
6414
6479
  `${path}.container_name`
6415
6480
  );
@@ -6666,8 +6731,148 @@ function parseUiConfig(raw2, options) {
6666
6731
  }
6667
6732
  config.layoutCss = raw2.layout_css;
6668
6733
  }
6734
+ if ("ooui" in raw2 && raw2.ooui !== void 0) {
6735
+ config.ooui = parseOouiSection(raw2.ooui);
6736
+ }
6737
+ if ("ooui_artifact" in raw2 && raw2.ooui_artifact !== void 0) {
6738
+ config.oouiArtifact = parseOouiArtifact(raw2.ooui_artifact);
6739
+ }
6669
6740
  return config;
6670
6741
  }
6742
+ var OOUI_CSS_KEY_PATTERN = /^ooui:[0-9a-f]{8}$/;
6743
+ function parseOouiSection(raw2) {
6744
+ if (!isOouiMap(raw2)) {
6745
+ throw new SomaUiConfigError(
6746
+ "ooui \u5FC5\u987B\u662F\u6620\u5C04\uFF1A{ <\u951A\u70B9id>: { object: <data \u5BF9\u8C61\u540D>, verb: <\u52A8\u8BCD> } }",
6747
+ "ooui"
6748
+ );
6749
+ }
6750
+ const out = {};
6751
+ for (const [anchor, spec] of Object.entries(raw2)) {
6752
+ const path = `ooui.${anchor}`;
6753
+ if (!SOMA_OOUI_ANCHOR_PATTERN.test(anchor)) {
6754
+ throw new SomaUiConfigError(
6755
+ `ooui \u7684\u952E\u5FC5\u987B\u662F\u951A\u70B9 id\uFF08data-soma-id\uFF0C${SOMA_OOUI_ANCHOR_GRAMMAR}\uFF09\uFF0C\u6536\u5230 "${anchor}"`,
6756
+ path
6757
+ );
6758
+ }
6759
+ if (!isOouiMap(spec)) {
6760
+ throw new SomaUiConfigError("\u6F14\u7ECE\u8BF7\u6C42\u5FC5\u987B\u662F\u6620\u5C04\uFF08\u81F3\u5C11\u542B object \u4E0E verb\uFF09", path);
6761
+ }
6762
+ for (const key of Object.keys(spec)) {
6763
+ if (!SOMA_OOUI_REQUEST_KEYS.includes(key)) {
6764
+ throw new SomaUiConfigError(
6765
+ `\u6F14\u7ECE\u8BF7\u6C42\u4E0D\u652F\u6301\u952E "${key}"\uFF08\u53EF\u7528\uFF1A${SOMA_OOUI_REQUEST_KEYS.join(" / ")}\uFF09`,
6766
+ `${path}.${key}`
6767
+ );
6768
+ }
6769
+ }
6770
+ const { object, verb, focus, through, form, bound_to: bound, layout } = spec;
6771
+ if (!isOouiText(object)) {
6772
+ throw new SomaUiConfigError("\u6F14\u7ECE\u8BF7\u6C42\u7F3A\u5C11 object\uFF08\u9875\u9762 data: \u6BB5\u91CC\u7684\u5BF9\u8C61\u540D\uFF09", `${path}.object`);
6773
+ }
6774
+ if (!isOouiText(verb)) {
6775
+ throw new SomaUiConfigError("\u6F14\u7ECE\u8BF7\u6C42\u7F3A\u5C11 verb\uFF08\u516B\u52A8\u8BCD\u4E4B\u4E00\uFF09", `${path}.verb`);
6776
+ }
6777
+ const declaration = { object, verb };
6778
+ if (focus !== void 0) {
6779
+ if (!isOouiFocus(focus)) {
6780
+ throw new SomaUiConfigError("focus \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u6BB5\u540D\u6570\u7EC4\uFF08\u7701\u7565\u5B83\u624D\u8868\u793A\u5168\u90E8\u5B57\u6BB5\uFF09", `${path}.focus`);
6781
+ }
6782
+ declaration.focus = [...focus];
6783
+ }
6784
+ if (through !== void 0) {
6785
+ if (!isOouiText(through)) {
6786
+ throw new SomaUiConfigError("through \u5FC5\u987B\u662F\u5BF9\u8C61 relations \u91CC\u7684\u5173\u7CFB\u540D", `${path}.through`);
6787
+ }
6788
+ declaration.through = through;
6789
+ }
6790
+ if (form !== void 0) {
6791
+ if (!isOouiText(form)) {
6792
+ throw new SomaUiConfigError("form \u5FC5\u987B\u662F\u5F62\u6001\u540D\uFF08\u9003\u751F\u95E8\uFF0C\u7701\u7565\u5219\u7531\u52A8\u8BCD\u5206\u6D3E\uFF09", `${path}.form`);
6793
+ }
6794
+ declaration.form = form;
6795
+ }
6796
+ if (bound !== void 0) {
6797
+ const unknownKey = isOouiMap(bound) ? findOouiBindingUnknownKey(bound) : void 0;
6798
+ if (unknownKey !== void 0) {
6799
+ throw new SomaUiConfigError(
6800
+ `bound_to \u4E0D\u652F\u6301\u952E "${unknownKey}"\uFF08\u53EF\u7528\uFF1A${SOMA_OOUI_BINDING_KEYS.join(" / ")}\uFF09\u2014\u2014\u8054\u52A8\u53EA\u8BA4\u6E90\u533A\u57DF\u4E0E\u8BED\u4E49\u4E8B\u4EF6\u4E24\u9879\uFF0C\u591A\u5199\u7684\u952E\u4E0D\u4F1A\u88AB\u4EFB\u4F55\u4E00\u5C42\u8BFB\u5230`,
6801
+ `${path}.bound_to.${unknownKey}`
6802
+ );
6803
+ }
6804
+ if (!isOouiBinding(bound)) {
6805
+ throw new SomaUiConfigError(
6806
+ "bound_to \u5FC5\u987B\u662F { region, as } \u4E24\u9879\u4FF1\u5168\u7684\u6620\u5C04\uFF08region \u662F\u53E6\u4E00\u4E2A\u951A\u70B9\u540D\uFF0Cas \u662F\u8BED\u4E49\u4E8B\u4EF6\u540D\uFF09",
6807
+ `${path}.bound_to`
6808
+ );
6809
+ }
6810
+ declaration.bound_to = { region: bound.region, as: bound.as };
6811
+ }
6812
+ if (layout !== void 0) {
6813
+ if (!isOouiLayout(layout)) {
6814
+ const problem = isOouiMap(layout) ? findOouiLayoutProblem(layout) : void 0;
6815
+ throw new SomaUiConfigError(
6816
+ oouiLayoutProblemMessage(layout, problem),
6817
+ problem === void 0 ? `${path}.layout` : `${path}.layout.${problem.key}`
6818
+ );
6819
+ }
6820
+ declaration.layout = layout;
6821
+ }
6822
+ out[anchor] = declaration;
6823
+ }
6824
+ return out;
6825
+ }
6826
+ function oouiLayoutProblemMessage(layout, problem) {
6827
+ if (problem === void 0) return `layout \u5FC5\u987B\u662F\u6620\u5C04\uFF08\u53EF\u7528\u952E\uFF1A${SOMA_OOUI_LAYOUT_KEYS.join(" / ")}\uFF09`;
6828
+ if (problem.kind === "unknown-key") {
6829
+ return `layout \u4E0D\u652F\u6301\u952E "${problem.key}"\uFF08\u53EF\u7528\uFF1A${SOMA_OOUI_LAYOUT_KEYS.join(" / ")}\uFF09`;
6830
+ }
6831
+ if (problem.kind === "sizing-unknown") {
6832
+ return `layout.sizing \u53EA\u80FD\u662F ${SOMA_OOUI_SIZINGS.join(" / ")}\uFF08\u6536\u5230 ${JSON.stringify(layout.sizing)}\uFF09\u2014\u2014fixed \u662F"\u5C31\u8FD9\u4E48\u5BBD"\uFF0Chug \u662F"\u5185\u5BB9\u591A\u5BBD\u6211\u591A\u5BBD"\uFF0Cfill \u662F"\u5269\u4E0B\u7684\u7ED9\u6211"\uFF1B\u7701\u7565\u5373 fill`;
6833
+ }
6834
+ return `layout.${problem.key} \u5FC5\u987B\u662F ${problem.expected === "number" ? "\u6570\u5B57" : "\u5B57\u7B26\u4E32"}`;
6835
+ }
6836
+ function parseOouiArtifact(raw2) {
6837
+ if (!raw2 || typeof raw2 !== "object" || Array.isArray(raw2)) {
6838
+ throw new SomaUiConfigError("ooui_artifact \u5FC5\u987B\u662F\u6620\u5C04\uFF08\u6784\u5EFA\u671F\u6F14\u7ECE\u4EA7\u7269\uFF0C\u4E0D\u624B\u5199\uFF09", "ooui_artifact");
6839
+ }
6840
+ const entry = raw2;
6841
+ if (entry.version !== 1) {
6842
+ throw new SomaUiConfigError(
6843
+ `ooui_artifact.version \u5FC5\u987B\u662F 1\uFF0C\u6536\u5230 ${JSON.stringify(entry.version)}\u2014\u2014\u7248\u672C\u5BF9\u4E0D\u4E0A\u7684\u4EA7\u7269\u6574\u4EFD\u4E0D\u53EF\u4FE1\uFF0C\u6309\u65E7\u5B57\u6BB5\u540D\u8BFB\u51FA\u6765\u7684\u754C\u9762\u662F\u8C01\u90FD\u6CA1\u8BBE\u8BA1\u8FC7\u7684\u6837\u5B50`,
6844
+ "ooui_artifact.version"
6845
+ );
6846
+ }
6847
+ if (!Array.isArray(entry.regions)) {
6848
+ throw new SomaUiConfigError("ooui_artifact.regions \u5FC5\u987B\u662F\u6570\u7EC4", "ooui_artifact.regions");
6849
+ }
6850
+ for (const [index, region] of entry.regions.entries()) {
6851
+ if (!region || typeof region !== "object" || Array.isArray(region) || typeof region.anchor !== "string") {
6852
+ throw new SomaUiConfigError("\u6BCF\u4E2A region \u5FC5\u987B\u662F\u6620\u5C04\u4E14\u5E26 anchor\uFF08\u951A\u70B9 id\uFF09", `ooui_artifact.regions[${index}]`);
6853
+ }
6854
+ }
6855
+ const artifact = {
6856
+ version: 1,
6857
+ regions: entry.regions
6858
+ };
6859
+ const hasCss = typeof entry.css === "string" && entry.css.trim() !== "";
6860
+ if (entry.css !== void 0 && typeof entry.css !== "string") {
6861
+ throw new SomaUiConfigError("ooui_artifact.css \u5FC5\u987B\u662F\u5B57\u7B26\u4E32", "ooui_artifact.css");
6862
+ }
6863
+ if (hasCss) {
6864
+ const key = entry.css_key;
6865
+ if (typeof key !== "string" || !OOUI_CSS_KEY_PATTERN.test(key)) {
6866
+ throw new SomaUiConfigError(
6867
+ `ooui_artifact.css \u5B58\u5728\u65F6\u5FC5\u987B\u5E26\u5185\u5BB9\u54C8\u5E0C\u952E css_key\uFF08\u5F62\u5982 ooui:0a1b2c3d\uFF09\uFF0C\u6536\u5230 ${JSON.stringify(key)}\u2014\u2014\u6837\u5F0F\u6CE8\u5165\u6CA1\u6709\u5185\u5BB9\u51B2\u7A81\u68C0\u6D4B\uFF0C\u8BED\u4E49\u540D\u4F1A\u8BA9 SPA \u8DEF\u7531\u5207\u9875\u65F6\u9759\u9ED8\u6CBF\u7528\u4E0A\u4E00\u9875\u7684 CSS`,
6868
+ "ooui_artifact.css_key"
6869
+ );
6870
+ }
6871
+ artifact.css = entry.css;
6872
+ artifact.css_key = key;
6873
+ }
6874
+ return artifact;
6875
+ }
6671
6876
  function parseLayoutSection(raw2) {
6672
6877
  if (!raw2 || typeof raw2 !== "object" || Array.isArray(raw2)) {
6673
6878
  throw new SomaUiConfigError("layout \u5FC5\u987B\u662F\u6620\u5C04\uFF1A{ <\u951A\u70B9id>: { gap, wrap, <\u5B50\u9879>: { sizing, \u2026 } } }", "layout");
@@ -7978,7 +8183,7 @@ var SomaEventEngine = class {
7978
8183
  * 避免点击 product_name 等子节点时,closest 停在无事件的子 id 上。
7979
8184
  */
7980
8185
  resolveEventBinding(eventType, start, domEvent) {
7981
- let el = start instanceof HTMLElement ? start : null;
8186
+ let el = start instanceof Element ? start : null;
7982
8187
  while (el && el !== this.container) {
7983
8188
  const somaId = this.adapter.getAnchorId(el);
7984
8189
  if (somaId) {
@@ -11090,6 +11295,152 @@ var SOMA_DATA_FIELD_TYPES = [
11090
11295
  "cascade",
11091
11296
  ...Object.keys(SOMA_DATA_FIELD_TYPE_ALIASES)
11092
11297
  ];
11298
+ var SOMA_DATA_OBJECT_ROLES = [
11299
+ "id",
11300
+ "title",
11301
+ "subtitle",
11302
+ "status",
11303
+ "timestamp",
11304
+ "amount",
11305
+ "baseline"
11306
+ ];
11307
+ var SOMA_DATA_RELATION_CARDINALITIES = [
11308
+ "one",
11309
+ "many"
11310
+ ];
11311
+
11312
+ // core/shared/object-semantics.ts
11313
+ var IDENTIFIER = /^[a-zA-Z_]\w*$/;
11314
+ var RELATION_KEYS = ["name", "to", "cardinality", "via"];
11315
+ function isPlainObject4(value) {
11316
+ return typeof value === "object" && value !== null && !Array.isArray(value);
11317
+ }
11318
+ function fieldList(fieldKeys) {
11319
+ return fieldKeys.length > 0 ? fieldKeys.join(" / ") : "\uFF08\u7A7A\uFF09";
11320
+ }
11321
+ function validateObjectRoles(raw2, fieldKeys) {
11322
+ if (raw2 === void 0 || raw2 === null) return [];
11323
+ if (!isPlainObject4(raw2)) {
11324
+ return ["roles \u5FC5\u987B\u662F\u6620\u5C04\uFF08\u89D2\u8272\u540D \u2192 \u5B57\u6BB5\u540D\uFF09\uFF0C\u5982 `roles: { title: no, status: state }`"];
11325
+ }
11326
+ const entries = Object.entries(raw2);
11327
+ if (entries.length === 0) {
11328
+ return ["roles \u662F\u7A7A\u6620\u5C04\u2014\u2014\u4E0D\u58F0\u660E\u4E0E\u58F0\u660E\u6210\u7A7A\u662F\u4E24\u56DE\u4E8B\uFF0C\u5220\u6389\u6574\u6BB5\u6216\u81F3\u5C11\u7ED9\u4E00\u4E2A\u89D2\u8272"];
11329
+ }
11330
+ if (fieldKeys.length === 0) {
11331
+ return [
11332
+ "roles \u7684\u503C\u662F\u5B57\u6BB5\u540D\uFF0C\u4F46\u672C\u5BF9\u8C61\u6CA1\u6709\u58F0\u660E fields\uFF0C\u4EFB\u4F55\u89D2\u8272\u90FD\u65E0\u4ECE\u5BF9\u8D26\u2014\u2014\u8BF7\u5148\u8865 `fields:` \u5B57\u6BB5\u5B57\u5178\uFF0C\u518D\u58F0\u660E roles"
11333
+ ];
11334
+ }
11335
+ const issues = [];
11336
+ const known = SOMA_DATA_OBJECT_ROLES;
11337
+ for (const [role, target] of entries) {
11338
+ if (!known.includes(role)) {
11339
+ issues.push(
11340
+ `\u672A\u77E5\u7684\u89D2\u8272 "${role}"\uFF08\u5C01\u95ED\u96C6\uFF1A${known.join(" / ")}\uFF09\u2014\u2014\u89D2\u8272\u8868\u662F\u5C01\u95ED\u96C6\uFF0C\u52A0\u4E00\u4E2A\u89D2\u8272\u662F\u4E00\u6B21\u4F53\u7CFB\u51B3\u7B56\uFF0C\u4E0D\u5728\u58F0\u660E\u91CC\u4E34\u65F6\u6269`
11341
+ );
11342
+ continue;
11343
+ }
11344
+ if (typeof target !== "string" || target.trim() === "") {
11345
+ issues.push(`\u89D2\u8272 "${role}" \u7684\u503C\u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u6BB5\u540D\uFF0C\u5F53\u524D\u503C: ${JSON.stringify(target)}`);
11346
+ continue;
11347
+ }
11348
+ if (!fieldKeys.includes(target)) {
11349
+ issues.push(
11350
+ `\u89D2\u8272 "${role}" \u6307\u5411\u5B57\u6BB5 "${target}"\uFF0C\u4F46\u5B57\u5178\u91CC\u6CA1\u6709\u5B83\uFF08\u672C\u5BF9\u8C61\u5B57\u5178\uFF1A${fieldList(fieldKeys)}\uFF09\u2014\u2014\u6307\u9519\u7684\u540E\u679C\u662F\u90A3\u4E00\u4F4D\u9759\u9ED8\u7559\u7A7A\uFF0C\u9875\u9762\u7167\u5E38\u6E32\u67D3`
11351
+ );
11352
+ }
11353
+ }
11354
+ return issues;
11355
+ }
11356
+ function validateObjectRelations(raw2, ctx) {
11357
+ if (raw2 === void 0 || raw2 === null) return [];
11358
+ if (!Array.isArray(raw2)) {
11359
+ return [
11360
+ "relations \u5FC5\u987B\u662F\u6570\u7EC4\uFF0C\u5982 `relations: [{ name: items, to: order_item, cardinality: many, via: order_no }]`"
11361
+ ];
11362
+ }
11363
+ if (raw2.length === 0) {
11364
+ return ["relations \u662F\u7A7A\u6570\u7EC4\u2014\u2014\u4E0D\u58F0\u660E\u4E0E\u58F0\u660E\u6210\u7A7A\u662F\u4E24\u56DE\u4E8B\uFF0C\u5220\u6389\u6574\u6BB5\u6216\u81F3\u5C11\u7ED9\u4E00\u6761\u5173\u7CFB"];
11365
+ }
11366
+ const issues = [];
11367
+ const seen = /* @__PURE__ */ new Set();
11368
+ const cardinalities = SOMA_DATA_RELATION_CARDINALITIES;
11369
+ raw2.forEach((entry, index) => {
11370
+ const at = `relations[${index}]`;
11371
+ if (!isPlainObject4(entry)) {
11372
+ issues.push(`${at} \u5FC5\u987B\u662F\u5BF9\u8C61\uFF08name / to / cardinality / via\uFF09`);
11373
+ return;
11374
+ }
11375
+ for (const key of Object.keys(entry)) {
11376
+ if (!RELATION_KEYS.includes(key)) {
11377
+ issues.push(`${at} \u4E0D\u652F\u6301\u952E "${key}"\uFF08\u53EF\u7528\uFF1A${RELATION_KEYS.join(" / ")}\uFF09`);
11378
+ }
11379
+ }
11380
+ const { name, to, cardinality, via } = entry;
11381
+ if (typeof name !== "string" || !IDENTIFIER.test(name)) {
11382
+ issues.push(`${at}.name \u5FC5\u987B\u662F\u6807\u8BC6\u7B26\uFF08\u5B57\u6BCD/\u4E0B\u5212\u7EBF\u5F00\u5934\uFF09\uFF0C\u5F53\u524D\u503C: ${JSON.stringify(name)}`);
11383
+ } else if (seen.has(name)) {
11384
+ issues.push(
11385
+ `${at}.name "${name}" \u4E0E\u524D\u9762\u7684\u5173\u7CFB\u91CD\u540D\u2014\u2014\`through\` \u6309\u540D\u5B57\u5F15\u7528\u5173\u7CFB\uFF0C\u91CD\u540D\u7B49\u4E8E\u8BA9\u5B83\u6307\u5411\u4E24\u4E2A\u5730\u65B9`
11386
+ );
11387
+ } else {
11388
+ seen.add(name);
11389
+ }
11390
+ if (typeof to !== "string" || !IDENTIFIER.test(to)) {
11391
+ issues.push(`${at}.to \u5FC5\u987B\u662F\u6570\u636E\u5BF9\u8C61\u540D\uFF08\u6807\u8BC6\u7B26\uFF09\uFF0C\u5F53\u524D\u503C: ${JSON.stringify(to)}`);
11392
+ } else if (ctx.objectNames !== void 0 && !ctx.objectNames.includes(to)) {
11393
+ issues.push(
11394
+ `${at}.to \u6307\u5411\u672A\u58F0\u660E\u7684\u6570\u636E\u5BF9\u8C61 "${to}"\uFF08\u672C\u6B21\u58F0\u660E\u91CC\u6709\uFF1A${ctx.objectNames.length > 0 ? ctx.objectNames.join(" / ") : "\uFF08\u7A7A\uFF09"}\uFF09\u2014\u2014\u628A\u76EE\u6807\u5BF9\u8C61\u4E5F\u58F0\u660E\u8FDB data\uFF0C\u6216\u5220\u6389\u8FD9\u6761\u5173\u7CFB\uFF1B\u7559\u7740\u5B83\u4F1A\u8BA9 navigate / compare \u53D6\u4E0D\u5230\u76EE\u6807\u5B57\u5178\uFF0C\u6F14\u7ECE\u51FA\u4E00\u7247\u7A7A\u767D\u800C\u4E0D\u662F\u62A5\u9519`
11395
+ );
11396
+ }
11397
+ if (typeof cardinality !== "string" || !cardinalities.includes(cardinality)) {
11398
+ issues.push(
11399
+ `${at}.cardinality \u5FC5\u987B\u662F ${cardinalities.join(" / ")}\uFF0C\u5F53\u524D\u503C: ${JSON.stringify(cardinality)}\u2014\u2014\u57FA\u6570\u51B3\u5B9A\u7684\u662F"\u6F14\u7ECE\u6210\u4E00\u683C\u8FD8\u662F\u4E00\u5217"\uFF0C\u731C\u4E0D\u5F97`
11400
+ );
11401
+ }
11402
+ if (via !== void 0) {
11403
+ if (typeof via !== "string" || via.trim() === "") {
11404
+ issues.push(`${at}.via \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u6BB5\u540D\uFF0C\u5F53\u524D\u503C: ${JSON.stringify(via)}`);
11405
+ } else if (!ctx.fieldKeys.includes(via)) {
11406
+ issues.push(
11407
+ `${at}.via \u6307\u5411\u5B57\u6BB5 "${via}"\uFF0C\u4F46\u5B57\u5178\u91CC\u6CA1\u6709\u5B83\uFF08\u672C\u5BF9\u8C61\u5B57\u5178\uFF1A${fieldList(ctx.fieldKeys)}\uFF09`
11408
+ );
11409
+ }
11410
+ }
11411
+ });
11412
+ return issues;
11413
+ }
11414
+ function validateFieldModifies(fields) {
11415
+ const issues = [];
11416
+ const keys = Object.keys(fields);
11417
+ for (const key of keys) {
11418
+ const target = fields[key]?.modifies;
11419
+ if (target === void 0) continue;
11420
+ if (typeof target !== "string" || target.trim() === "") {
11421
+ issues.push(`\u5B57\u6BB5 "${key}" \u7684 modifies \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u6BB5\u540D\uFF0C\u5F53\u524D\u503C: ${JSON.stringify(target)}`);
11422
+ continue;
11423
+ }
11424
+ if (target === key) {
11425
+ issues.push(
11426
+ `\u5B57\u6BB5 "${key}" \u7684 modifies \u6307\u5411\u5B83\u81EA\u5DF1\u2014\u2014\u4FEE\u9970\u5173\u7CFB\u8BF4\u7684\u662F"\u6211\u662F\u522B\u4EBA\u7684\u8BED\u6C14/\u5355\u4F4D/\u56FE\u6807"\uFF0C\u81EA\u6307\u6CA1\u6709\u53EF\u6267\u884C\u542B\u4E49`
11427
+ );
11428
+ continue;
11429
+ }
11430
+ if (!(target in fields)) {
11431
+ issues.push(
11432
+ `\u5B57\u6BB5 "${key}" \u7684 modifies \u6307\u5411 "${target}"\uFF0C\u4F46\u5B57\u5178\u91CC\u6CA1\u6709\u5B83\uFF08\u672C\u5BF9\u8C61\u5B57\u5178\uFF1A${fieldList(keys)}\uFF09\u2014\u2014\u6307\u9519\u5219\u672C\u5B57\u6BB5\u4E0D\u4F1A\u88AB\u5E76\u5165\u88AB\u4FEE\u9970\u8005\uFF0C\u800C\u662F\u81EA\u5DF1\u5360\u4E00\u683C\uFF0C\u9875\u9762\u4E0A\u591A\u51FA\u4E00\u884C\u7A7A\u503C`
11433
+ );
11434
+ continue;
11435
+ }
11436
+ if (fields[target].modifies !== void 0) {
11437
+ issues.push(
11438
+ `\u5B57\u6BB5 "${key}" \u4FEE\u9970 "${target}"\uFF0C\u800C "${target}" \u81EA\u5DF1\u4E5F\u5E26 modifies\u2014\u2014\u4FEE\u9970\u4E0D\u53EF\u7EA7\u8054\uFF08\u8BF7\u8BA9 "${key}" \u76F4\u63A5\u6307\u5411\u6700\u7EC8\u88AB\u4FEE\u9970\u7684\u90A3\u4E2A\u5B57\u6BB5\uFF09`
11439
+ );
11440
+ }
11441
+ }
11442
+ return issues;
11443
+ }
11093
11444
 
11094
11445
  // core/shared/types/reaction.types.ts
11095
11446
  var SOMA_REACTION_PHASES = [
@@ -11140,7 +11491,7 @@ var DIGIT = /[0-9]/;
11140
11491
  function tokenize(source) {
11141
11492
  const tokens = [];
11142
11493
  let i = 0;
11143
- const fail2 = (message, from, to) => {
11494
+ const fail = (message, from, to) => {
11144
11495
  throw new SomaCalcSyntaxError(message, source, [from, to]);
11145
11496
  };
11146
11497
  while (i < source.length) {
@@ -11150,19 +11501,19 @@ function tokenize(source) {
11150
11501
  continue;
11151
11502
  }
11152
11503
  if (char === "\n" || char === "\r") {
11153
- fail2("\u8868\u8FBE\u5F0F\u4E0D\u80FD\u6362\u884C\uFF08\u5B83\u662F\u4E00\u4E2A YAML \u6807\u91CF\uFF0C\u4E0D\u662F\u5757\uFF09", i, i + 1);
11504
+ fail("\u8868\u8FBE\u5F0F\u4E0D\u80FD\u6362\u884C\uFF08\u5B83\u662F\u4E00\u4E2A YAML \u6807\u91CF\uFF0C\u4E0D\u662F\u5757\uFF09", i, i + 1);
11154
11505
  }
11155
11506
  const start = i;
11156
11507
  if (char === "[") {
11157
11508
  i += 1;
11158
11509
  const nameStart = i;
11159
11510
  while (i < source.length && source[i] !== "]") i += 1;
11160
- if (i >= source.length) fail2('\u5B57\u6BB5\u5F15\u7528\u7F3A\u5C11\u95ED\u5408\u7684 "]"', start, source.length);
11511
+ if (i >= source.length) fail('\u5B57\u6BB5\u5F15\u7528\u7F3A\u5C11\u95ED\u5408\u7684 "]"', start, source.length);
11161
11512
  const name = source.slice(nameStart, i);
11162
11513
  i += 1;
11163
- if (name === "") fail2("\u5B57\u6BB5\u5F15\u7528\u4E0D\u80FD\u4E3A\u7A7A\uFF08\u5199\u6210 [\u5B57\u6BB5\u540D]\uFF09", start, i);
11514
+ if (name === "") fail("\u5B57\u6BB5\u5F15\u7528\u4E0D\u80FD\u4E3A\u7A7A\uFF08\u5199\u6210 [\u5B57\u6BB5\u540D]\uFF09", start, i);
11164
11515
  if (!IDENT_START.test(name[0]) || ![...name].every((c) => IDENT_PART.test(c))) {
11165
- fail2(`\u5B57\u6BB5\u540D "${name}" \u5FC5\u987B\u662F\u6807\u8BC6\u7B26\uFF08\u5B57\u6BCD\u6216\u4E0B\u5212\u7EBF\u5F00\u5934\uFF09\uFF1B\u6D3E\u751F\u5217\u53EA\u80FD\u5F15\u7528\u540C\u5C42\u5B57\u6BB5\uFF0C\u4E0D\u652F\u6301 . \u6DF1\u53D6`, start, i);
11516
+ fail(`\u5B57\u6BB5\u540D "${name}" \u5FC5\u987B\u662F\u6807\u8BC6\u7B26\uFF08\u5B57\u6BCD\u6216\u4E0B\u5212\u7EBF\u5F00\u5934\uFF09\uFF1B\u6D3E\u751F\u5217\u53EA\u80FD\u5F15\u7528\u540C\u5C42\u5B57\u6BB5\uFF0C\u4E0D\u652F\u6301 . \u6DF1\u53D6`, start, i);
11166
11517
  }
11167
11518
  tokens.push({ kind: "ref", value: name, pos: [start, i] });
11168
11519
  continue;
@@ -11171,12 +11522,12 @@ function tokenize(source) {
11171
11522
  i += 1;
11172
11523
  const textStart = i;
11173
11524
  while (i < source.length && source[i] !== "#") i += 1;
11174
- if (i >= source.length) fail2('\u65E5\u671F\u5B57\u9762\u91CF\u7F3A\u5C11\u95ED\u5408\u7684 "#"', start, source.length);
11525
+ if (i >= source.length) fail('\u65E5\u671F\u5B57\u9762\u91CF\u7F3A\u5C11\u95ED\u5408\u7684 "#"', start, source.length);
11175
11526
  const text = source.slice(textStart, i);
11176
11527
  i += 1;
11177
11528
  const ms = parseDateLiteral(text);
11178
11529
  if (ms === null) {
11179
- fail2(`\u65E5\u671F\u5B57\u9762\u91CF "${text}" \u4E0D\u5408\u6CD5\uFF08\u53EA\u8BA4 #YYYY-MM-DD# \u4E0E #YYYY-MM-DDTHH:mm#\uFF09`, start, i);
11530
+ fail(`\u65E5\u671F\u5B57\u9762\u91CF "${text}" \u4E0D\u5408\u6CD5\uFF08\u53EA\u8BA4 #YYYY-MM-DD# \u4E0E #YYYY-MM-DDTHH:mm#\uFF09`, start, i);
11180
11531
  }
11181
11532
  tokens.push({ kind: "date", value: ms, pos: [start, i] });
11182
11533
  continue;
@@ -11185,11 +11536,11 @@ function tokenize(source) {
11185
11536
  i += 1;
11186
11537
  let text = "";
11187
11538
  while (i < source.length && source[i] !== '"') {
11188
- if (source[i] === "\n") fail2("\u5B57\u7B26\u4E32\u4E0D\u80FD\u8DE8\u884C", start, i);
11539
+ if (source[i] === "\n") fail("\u5B57\u7B26\u4E32\u4E0D\u80FD\u8DE8\u884C", start, i);
11189
11540
  if (source[i] === "\\") {
11190
11541
  const next = source[i + 1];
11191
11542
  if (next !== '"' && next !== "\\") {
11192
- fail2(`\u5B57\u7B26\u4E32\u91CC\u53EA\u5141\u8BB8 \\" \u4E0E \\\\ \u4E24\u79CD\u8F6C\u4E49\uFF0C\u6536\u5230 "\\${String(next ?? "")}"`, i, i + 2);
11543
+ fail(`\u5B57\u7B26\u4E32\u91CC\u53EA\u5141\u8BB8 \\" \u4E0E \\\\ \u4E24\u79CD\u8F6C\u4E49\uFF0C\u6536\u5230 "\\${String(next ?? "")}"`, i, i + 2);
11193
11544
  }
11194
11545
  text += next;
11195
11546
  i += 2;
@@ -11198,7 +11549,7 @@ function tokenize(source) {
11198
11549
  text += source[i];
11199
11550
  i += 1;
11200
11551
  }
11201
- if (i >= source.length) fail2("\u5B57\u7B26\u4E32\u7F3A\u5C11\u95ED\u5408\u7684\u53CC\u5F15\u53F7", start, source.length);
11552
+ if (i >= source.length) fail("\u5B57\u7B26\u4E32\u7F3A\u5C11\u95ED\u5408\u7684\u53CC\u5F15\u53F7", start, source.length);
11202
11553
  i += 1;
11203
11554
  tokens.push({ kind: "string", value: text, pos: [start, i] });
11204
11555
  continue;
@@ -11207,11 +11558,11 @@ function tokenize(source) {
11207
11558
  while (i < source.length && DIGIT.test(source[i])) i += 1;
11208
11559
  if (source[i] === ".") {
11209
11560
  i += 1;
11210
- if (!DIGIT.test(source[i] ?? "")) fail2("\u5C0F\u6570\u70B9\u540E\u7F3A\u5C11\u6570\u5B57", start, i + 1);
11561
+ if (!DIGIT.test(source[i] ?? "")) fail("\u5C0F\u6570\u70B9\u540E\u7F3A\u5C11\u6570\u5B57", start, i + 1);
11211
11562
  while (i < source.length && DIGIT.test(source[i])) i += 1;
11212
11563
  }
11213
11564
  if (source[i] === "e" || source[i] === "E") {
11214
- fail2("\u4E0D\u652F\u6301\u79D1\u5B66\u8BA1\u6570\u6CD5\u2014\u2014\u6D3E\u751F\u5217\u7684\u6570\u503C\u5E94\u5F53\u662F\u4EBA\u80FD\u4E00\u773C\u8BFB\u61C2\u7684\u5B57\u9762\u91CF", start, i + 1);
11565
+ fail("\u4E0D\u652F\u6301\u79D1\u5B66\u8BA1\u6570\u6CD5\u2014\u2014\u6D3E\u751F\u5217\u7684\u6570\u503C\u5E94\u5F53\u662F\u4EBA\u80FD\u4E00\u773C\u8BFB\u61C2\u7684\u5B57\u9762\u91CF", start, i + 1);
11215
11566
  }
11216
11567
  tokens.push({ kind: "number", value: Number(source.slice(start, i)), pos: [start, i] });
11217
11568
  continue;
@@ -11227,7 +11578,7 @@ function tokenize(source) {
11227
11578
  tokens.push({ kind: "ident", value: word, pos: [start, i] });
11228
11579
  continue;
11229
11580
  }
11230
- fail2(
11581
+ fail(
11231
11582
  `\u672A\u77E5\u7684\u6807\u8BC6\u7B26 "${word}"\u3002\u5B57\u6BB5\u8981\u5199\u6210 [${word}]\uFF1B\u51FD\u6570\u53EA\u6709 ${CALC_FUNCTIONS.join(" / ")}`,
11232
11583
  start,
11233
11584
  i
@@ -11255,7 +11606,7 @@ function tokenize(source) {
11255
11606
  continue;
11256
11607
  }
11257
11608
  const hint = char === "=" ? "\u5224\u65AD\u76F8\u7B49\u8981\u5199 ==" : char === "&" ? "\u5E76\u4E14\u8981\u5199\u6210 IF \u7684\u5D4C\u5957\uFF1Bcalc \u4E0D\u652F\u6301\u903B\u8F91\u8FD0\u7B97\u7B26" : char === "|" ? "\u6216\u8005\u8981\u5199\u6210 IF \u7684\u5D4C\u5957\uFF1Bcalc \u4E0D\u652F\u6301\u903B\u8F91\u8FD0\u7B97\u7B26" : char === "!" ? "\u4E0D\u7B49\u8981\u5199 !=" : char === "'" ? "\u5B57\u7B26\u4E32\u8981\u7528\u53CC\u5F15\u53F7\uFF08\u5355\u5F15\u53F7\u662F YAML \u7684\u5F15\u53F7\uFF09" : "\u5B83\u4E0D\u5728 calc \u7684\u8BCD\u6CD5\u8868\u91CC";
11258
- fail2(`\u65E0\u6CD5\u8BC6\u522B\u7684\u5B57\u7B26 "${char}"\u2014\u2014${hint}`, start, i + 1);
11609
+ fail(`\u65E0\u6CD5\u8BC6\u522B\u7684\u5B57\u7B26 "${char}"\u2014\u2014${hint}`, start, i + 1);
11259
11610
  }
11260
11611
  tokens.push({ kind: "eof", value: "", pos: [source.length, source.length] });
11261
11612
  return tokens;
@@ -11291,12 +11642,12 @@ function parseCalc(source) {
11291
11642
  let at = 0;
11292
11643
  const peek = () => tokens[at];
11293
11644
  const next = () => tokens[at++];
11294
- const fail2 = (message, token) => {
11645
+ const fail = (message, token) => {
11295
11646
  throw new SomaCalcSyntaxError(message, source, token.pos);
11296
11647
  };
11297
11648
  const expect = (kind, what) => {
11298
11649
  const token = peek();
11299
- if (token.kind !== kind) fail2(`\u7F3A\u5C11${what}`, token);
11650
+ if (token.kind !== kind) fail(`\u7F3A\u5C11${what}`, token);
11300
11651
  return next();
11301
11652
  };
11302
11653
  const parseCmp = () => {
@@ -11307,7 +11658,7 @@ function parseCalc(source) {
11307
11658
  const right = parseSum();
11308
11659
  const after = peek();
11309
11660
  if (after.kind === "op" && CMP_OPS.includes(String(after.value))) {
11310
- fail2("\u6BD4\u8F83\u4E0D\u80FD\u8FDE\u5199\uFF08a < b < c \u51E0\u4E4E\u603B\u662F\u5199\u9519\u4E86\u610F\u601D\uFF09\u2014\u2014\u8BF7\u62C6\u6210\u4E24\u4E2A IF \u6216\u6539\u7528 between \u8C13\u8BCD", after);
11661
+ fail("\u6BD4\u8F83\u4E0D\u80FD\u8FDE\u5199\uFF08a < b < c \u51E0\u4E4E\u603B\u662F\u5199\u9519\u4E86\u610F\u601D\uFF09\u2014\u2014\u8BF7\u62C6\u6210\u4E24\u4E2A IF \u6216\u6539\u7528 between \u8C13\u8BCD", after);
11311
11662
  }
11312
11663
  return { k: "bin", op: String(token.value), left, right, pos: [left.pos[0], right.pos[1]] };
11313
11664
  }
@@ -11363,11 +11714,11 @@ function parseCalc(source) {
11363
11714
  case "ident":
11364
11715
  return parseCall(token);
11365
11716
  case "op":
11366
- return fail2(`\u8FD0\u7B97\u7B26 "${String(token.value)}" \u524D\u9762\u7F3A\u5C11\u64CD\u4F5C\u6570`, token);
11717
+ return fail(`\u8FD0\u7B97\u7B26 "${String(token.value)}" \u524D\u9762\u7F3A\u5C11\u64CD\u4F5C\u6570`, token);
11367
11718
  case "eof":
11368
- return fail2("\u8868\u8FBE\u5F0F\u4E0D\u5B8C\u6574", token);
11719
+ return fail("\u8868\u8FBE\u5F0F\u4E0D\u5B8C\u6574", token);
11369
11720
  default:
11370
- return fail2(`\u610F\u5916\u7684 "${String(token.value)}"`, token);
11721
+ return fail(`\u610F\u5916\u7684 "${String(token.value)}"`, token);
11371
11722
  }
11372
11723
  };
11373
11724
  const parseCall = (name) => {
@@ -11381,7 +11732,7 @@ function parseCalc(source) {
11381
11732
  if (fn === "ROUND" && args.length === 1) {
11382
11733
  const digits = peek();
11383
11734
  if (digits.kind !== "number" || !Number.isInteger(digits.value) || digits.value < 0 || digits.value > 6) {
11384
- fail2("ROUND \u7684\u7B2C\u4E8C\u53C2\u5FC5\u987B\u662F 0~6 \u7684\u6574\u6570\u5B57\u9762\u91CF", digits);
11735
+ fail("ROUND \u7684\u7B2C\u4E8C\u53C2\u5FC5\u987B\u662F 0~6 \u7684\u6574\u6570\u5B57\u9762\u91CF", digits);
11385
11736
  }
11386
11737
  next();
11387
11738
  args.push({ k: "num", v: digits.value, pos: digits.pos });
@@ -11394,14 +11745,14 @@ function parseCalc(source) {
11394
11745
  const [min, max] = ARITY[fn];
11395
11746
  if (args.length < min || args.length > max) {
11396
11747
  const want = max === Infinity ? `\u81F3\u5C11 ${min} \u4E2A` : min === max ? `${min} \u4E2A` : `${min}~${max} \u4E2A`;
11397
- fail2(`${fn} \u9700\u8981${want}\u53C2\u6570\uFF0C\u6536\u5230 ${args.length} \u4E2A`, name);
11748
+ fail(`${fn} \u9700\u8981${want}\u53C2\u6570\uFF0C\u6536\u5230 ${args.length} \u4E2A`, name);
11398
11749
  }
11399
11750
  return { k: "call", fn, args, pos: [name.pos[0], close.pos[1]] };
11400
11751
  };
11401
11752
  const ast = parseCmp();
11402
11753
  const rest = peek();
11403
11754
  if (rest.kind !== "eof") {
11404
- fail2(`\u8868\u8FBE\u5F0F\u5728\u8FD9\u91CC\u5C31\u7ED3\u675F\u4E86\uFF0C\u540E\u9762\u7684 "${String(rest.value)}" \u662F\u591A\u4F59\u7684`, rest);
11755
+ fail(`\u8868\u8FBE\u5F0F\u5728\u8FD9\u91CC\u5C31\u7ED3\u675F\u4E86\uFF0C\u540E\u9762\u7684 "${String(rest.value)}" \u662F\u591A\u4F59\u7684`, rest);
11405
11756
  }
11406
11757
  return ast;
11407
11758
  }
@@ -11686,8 +12037,8 @@ var CONFIG_KEYS2 = /* @__PURE__ */ new Set(["when", "depends", "on", "target", "
11686
12037
  var CALC_WRITABLE = /* @__PURE__ */ new Set(["int", "float", "money", "percent", "progress", "text", "url", "enum", "date", "datetime"]);
11687
12038
  function parseReactions(input, deps) {
11688
12039
  const { raw: raw2, fields, named, path } = input;
11689
- const { fail: fail2 } = deps;
11690
- if (!Array.isArray(raw2)) fail2("reactions \u5FC5\u987B\u662F\u6570\u7EC4", path);
12040
+ const { fail } = deps;
12041
+ if (!Array.isArray(raw2)) fail("reactions \u5FC5\u987B\u662F\u6570\u7EC4", path);
11691
12042
  const list = raw2;
11692
12043
  const fieldKeys = Object.keys(fields);
11693
12044
  const fieldTypes = Object.fromEntries(
@@ -11697,50 +12048,50 @@ function parseReactions(input, deps) {
11697
12048
  list.forEach((entry, index) => {
11698
12049
  const at = `${path}[${index}]`;
11699
12050
  if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
11700
- fail2("\u6BCF\u6761\u53CD\u5E94\u5FC5\u987B\u662F\u5BF9\u8C61", at);
12051
+ fail("\u6BCF\u6761\u53CD\u5E94\u5FC5\u987B\u662F\u5BF9\u8C61", at);
11701
12052
  }
11702
12053
  const box = entry;
11703
12054
  for (const key of Object.keys(box)) {
11704
12055
  if (!CONFIG_KEYS2.has(key)) {
11705
- fail2(`\u672A\u77E5\u7684\u53CD\u5E94\u5B57\u6BB5 "${key}"\uFF08\u652F\u6301: ${[...CONFIG_KEYS2].join(" / ")}\uFF09`, `${at}.${key}`);
12056
+ fail(`\u672A\u77E5\u7684\u53CD\u5E94\u5B57\u6BB5 "${key}"\uFF08\u652F\u6301: ${[...CONFIG_KEYS2].join(" / ")}\uFF09`, `${at}.${key}`);
11706
12057
  }
11707
12058
  }
11708
12059
  const phaseRaw = box.on === void 0 ? "field_value_change" : String(box.on);
11709
12060
  if (!PHASES.has(phaseRaw)) {
11710
- fail2(`\u672A\u77E5\u7684\u89E6\u53D1\u65F6\u673A "${phaseRaw}"\uFF08\u652F\u6301: ${SOMA_REACTION_PHASES.join(" / ")}\uFF09`, `${at}.on`);
12061
+ fail(`\u672A\u77E5\u7684\u89E6\u53D1\u65F6\u673A "${phaseRaw}"\uFF08\u652F\u6301: ${SOMA_REACTION_PHASES.join(" / ")}\uFF09`, `${at}.on`);
11711
12062
  }
11712
12063
  const phase = phaseRaw;
11713
12064
  const reads = /* @__PURE__ */ new Set();
11714
12065
  if (box.when !== void 0) {
11715
12066
  const issues = validatePredicate(box.when, fieldKeys, `${at}.when`, { fieldTypes, named });
11716
- if (issues.length > 0) fail2(issues.join("\uFF1B"), `${at}.when`);
12067
+ if (issues.length > 0) fail(issues.join("\uFF1B"), `${at}.when`);
11717
12068
  for (const field of collectPredicateFields(box.when, named)) reads.add(field);
11718
12069
  }
11719
12070
  if (box.depends !== void 0) {
11720
- if (!Array.isArray(box.depends)) fail2("depends \u5FC5\u987B\u662F\u5B57\u6BB5\u540D\u6570\u7EC4", `${at}.depends`);
12071
+ if (!Array.isArray(box.depends)) fail("depends \u5FC5\u987B\u662F\u5B57\u6BB5\u540D\u6570\u7EC4", `${at}.depends`);
11721
12072
  for (const item of box.depends) {
11722
12073
  const field = String(item ?? "");
11723
12074
  if (!fieldKeys.includes(field)) {
11724
- fail2(`depends \u5F15\u7528\u4E86\u4E0D\u5B58\u5728\u7684\u5B57\u6BB5 "${field}"`, `${at}.depends`);
12075
+ fail(`depends \u5F15\u7528\u4E86\u4E0D\u5B58\u5728\u7684\u5B57\u6BB5 "${field}"`, `${at}.depends`);
11725
12076
  }
11726
12077
  reads.add(field);
11727
12078
  }
11728
12079
  }
11729
12080
  if (box.when === void 0 && box.depends === void 0) {
11730
- fail2(
12081
+ fail(
11731
12082
  "when \u4E0E depends \u81F3\u5C11\u8981\u7ED9\u4E00\u4E2A\u2014\u2014\u4E24\u4E2A\u90FD\u6CA1\u6709\u7684\u53CD\u5E94\u4E0D\u77E5\u9053\u4F55\u65F6\u8BE5\u8DD1\uFF0C\u5B83\u65E2\u4E0D\u4F1A\u751F\u6548\u4E5F\u4E0D\u4F1A\u62A5\u9519\uFF0C\u662F\u6700\u96BE\u53D1\u73B0\u7684\u4E00\u7C7B\u7A7A\u58F0\u660E",
11732
12083
  at
11733
12084
  );
11734
12085
  }
11735
12086
  if (box.target !== void 0) {
11736
12087
  const target = String(box.target);
11737
- if (!fieldKeys.includes(target)) fail2(`target \u5F15\u7528\u4E86\u4E0D\u5B58\u5728\u7684\u5B57\u6BB5 "${target}"`, `${at}.target`);
12088
+ if (!fieldKeys.includes(target)) fail(`target \u5F15\u7528\u4E86\u4E0D\u5B58\u5728\u7684\u5B57\u6BB5 "${target}"`, `${at}.target`);
11738
12089
  if (!phase.startsWith("field_validate")) {
11739
- fail2('target \u53EA\u5728 on: field_validate_* \u65F6\u6709\u610F\u4E49\uFF08\u5176\u4F59\u65F6\u673A\u6CA1\u6709"\u54EA\u4E2A\u5B57\u6BB5"\u8FD9\u4E2A\u6982\u5FF5\uFF09', `${at}.target`);
12090
+ fail('target \u53EA\u5728 on: field_validate_* \u65F6\u6709\u610F\u4E49\uFF08\u5176\u4F59\u65F6\u673A\u6CA1\u6709"\u54EA\u4E2A\u5B57\u6BB5"\u8FD9\u4E2A\u6982\u5FF5\uFF09', `${at}.target`);
11740
12091
  }
11741
12092
  reads.add(target);
11742
12093
  } else if (phase.startsWith("field_validate")) {
11743
- fail2(`on: ${phase} \u5FC5\u987B\u7ED9 target\uFF08\u76EF\u7740\u54EA\u4E2A\u5B57\u6BB5\u7684\u6821\u9A8C\u7ED3\u679C\uFF09`, at);
12094
+ fail(`on: ${phase} \u5FC5\u987B\u7ED9 target\uFF08\u76EF\u7740\u54EA\u4E2A\u5B57\u6BB5\u7684\u6821\u9A8C\u7ED3\u679C\uFF09`, at);
11744
12095
  }
11745
12096
  const writes = /* @__PURE__ */ new Set();
11746
12097
  const calcAsts = {};
@@ -11748,18 +12099,18 @@ function parseReactions(input, deps) {
11748
12099
  const value = box[branch];
11749
12100
  if (value === void 0) continue;
11750
12101
  if (!value || typeof value !== "object" || Array.isArray(value)) {
11751
- fail2(`${branch} \u5FC5\u987B\u662F { \u5B57\u6BB5\u540D: patch } \u5BF9\u8C61`, `${at}.${branch}`);
12102
+ fail(`${branch} \u5FC5\u987B\u662F { \u5B57\u6BB5\u540D: patch } \u5BF9\u8C61`, `${at}.${branch}`);
11752
12103
  }
11753
12104
  for (const [target, patchRaw] of Object.entries(value)) {
11754
12105
  const patchPath = `${at}.${branch}.${target}`;
11755
12106
  if (target === SOMA_REACTION_FORM_KEY) {
11756
- checkFormPatch(patchRaw, patchPath, fail2);
12107
+ checkFormPatch(patchRaw, patchPath, fail);
11757
12108
  continue;
11758
12109
  }
11759
12110
  if (!fieldKeys.includes(target)) {
11760
- fail2(`${branch} \u7684\u76EE\u6807 "${target}" \u4E0D\u662F\u5B57\u5178\u91CC\u7684\u5B57\u6BB5`, patchPath);
12111
+ fail(`${branch} \u7684\u76EE\u6807 "${target}" \u4E0D\u662F\u5B57\u5178\u91CC\u7684\u5B57\u6BB5`, patchPath);
11761
12112
  }
11762
- const ast = checkFieldPatch(patchRaw, target, fields[target], fieldKeys, fieldTypes, patchPath, fail2);
12113
+ const ast = checkFieldPatch(patchRaw, target, fields[target], fieldKeys, fieldTypes, patchPath, fail);
11763
12114
  if (ast) {
11764
12115
  calcAsts[`${branch}:${target}`] = ast.node;
11765
12116
  for (const ref of ast.refs) reads.add(ref);
@@ -11768,7 +12119,7 @@ function parseReactions(input, deps) {
11768
12119
  }
11769
12120
  }
11770
12121
  if (box.fulfill === void 0 && box.otherwise === void 0) {
11771
- fail2("fulfill \u4E0E otherwise \u81F3\u5C11\u8981\u7ED9\u4E00\u4E2A\uFF08\u4E00\u6761\u4EC0\u4E48\u90FD\u4E0D\u505A\u7684\u53CD\u5E94\u6CA1\u6709\u610F\u4E49\uFF09", at);
12122
+ fail("fulfill \u4E0E otherwise \u81F3\u5C11\u8981\u7ED9\u4E00\u4E2A\uFF08\u4E00\u6761\u4EC0\u4E48\u90FD\u4E0D\u505A\u7684\u53CD\u5E94\u6CA1\u6709\u610F\u4E49\uFF09", at);
11772
12123
  }
11773
12124
  parsed.push({
11774
12125
  config: box,
@@ -11779,7 +12130,7 @@ function parseReactions(input, deps) {
11779
12130
  declaredAt: index
11780
12131
  });
11781
12132
  });
11782
- const order = topoSort(parsed, path, fail2);
12133
+ const order = topoSort(parsed, path, fail);
11783
12134
  const reactions = order.map((declaredAt, position) => {
11784
12135
  const item = parsed[declaredAt];
11785
12136
  return {
@@ -11804,57 +12155,57 @@ function parseReactions(input, deps) {
11804
12155
  provenance: buildProvenance(reactions, fieldKeys, input.sourceApiOf ?? {})
11805
12156
  };
11806
12157
  }
11807
- function checkFormPatch(raw2, path, fail2) {
12158
+ function checkFormPatch(raw2, path, fail) {
11808
12159
  if (!raw2 || typeof raw2 !== "object" || Array.isArray(raw2)) {
11809
- fail2("submit \u7684 patch \u5FC5\u987B\u662F\u5BF9\u8C61 { disabled: \u5E03\u5C14 }", path);
12160
+ fail("submit \u7684 patch \u5FC5\u987B\u662F\u5BF9\u8C61 { disabled: \u5E03\u5C14 }", path);
11810
12161
  }
11811
12162
  const box = raw2;
11812
12163
  for (const key of Object.keys(box)) {
11813
- if (key !== "disabled") fail2(`submit \u53EA\u652F\u6301 disabled\uFF0C\u6536\u5230 "${key}"`, `${path}.${key}`);
12164
+ if (key !== "disabled") fail(`submit \u53EA\u652F\u6301 disabled\uFF0C\u6536\u5230 "${key}"`, `${path}.${key}`);
11814
12165
  }
11815
12166
  if (box.disabled !== void 0 && typeof box.disabled !== "boolean") {
11816
- fail2("submit.disabled \u5FC5\u987B\u662F\u5E03\u5C14", `${path}.disabled`);
12167
+ fail("submit.disabled \u5FC5\u987B\u662F\u5E03\u5C14", `${path}.disabled`);
11817
12168
  }
11818
12169
  }
11819
- function checkFieldPatch(raw2, target, field, fieldKeys, fieldTypes, path, fail2) {
12170
+ function checkFieldPatch(raw2, target, field, fieldKeys, fieldTypes, path, fail) {
11820
12171
  if (!raw2 || typeof raw2 !== "object" || Array.isArray(raw2)) {
11821
- fail2("patch \u5FC5\u987B\u662F\u5BF9\u8C61", path);
12172
+ fail("patch \u5FC5\u987B\u662F\u5BF9\u8C61", path);
11822
12173
  }
11823
12174
  const patch = raw2;
11824
12175
  for (const key of Object.keys(patch)) {
11825
12176
  if (!PATCH_KEYS.has(key)) {
11826
- fail2(`\u672A\u77E5\u7684 patch \u952E "${key}"\uFF08\u652F\u6301: ${[...PATCH_KEYS].join(" / ")}\uFF09`, `${path}.${key}`);
12177
+ fail(`\u672A\u77E5\u7684 patch \u952E "${key}"\uFF08\u652F\u6301: ${[...PATCH_KEYS].join(" / ")}\uFF09`, `${path}.${key}`);
11827
12178
  }
11828
12179
  }
11829
12180
  if (patch.visible !== void 0 && typeof patch.visible !== "boolean") {
11830
- fail2("visible \u5FC5\u987B\u662F\u5E03\u5C14\uFF08\u8981\u8FDE\u6570\u636E\u4E00\u8D77\u6458\u9664\u8BF7\u5199 display: none\uFF09", `${path}.visible`);
12181
+ fail("visible \u5FC5\u987B\u662F\u5E03\u5C14\uFF08\u8981\u8FDE\u6570\u636E\u4E00\u8D77\u6458\u9664\u8BF7\u5199 display: none\uFF09", `${path}.visible`);
11831
12182
  }
11832
12183
  if (patch.visible !== void 0 && patch.display !== void 0) {
11833
- fail2("visible \u4E0E display \u53EA\u80FD\u7ED9\u4E00\u4E2A\u2014\u2014visible \u672C\u6765\u5C31\u662F display \u7684\u8BED\u6CD5\u7CD6", path);
12184
+ fail("visible \u4E0E display \u53EA\u80FD\u7ED9\u4E00\u4E2A\u2014\u2014visible \u672C\u6765\u5C31\u662F display \u7684\u8BED\u6CD5\u7CD6", path);
11834
12185
  }
11835
12186
  if (patch.display !== void 0 && !DISPLAYS.has(String(patch.display))) {
11836
- fail2(`display \u53EA\u80FD\u662F ${SOMA_FIELD_DISPLAYS.join(" / ")}`, `${path}.display`);
12187
+ fail(`display \u53EA\u80FD\u662F ${SOMA_FIELD_DISPLAYS.join(" / ")}`, `${path}.display`);
11837
12188
  }
11838
12189
  if (patch.pattern !== void 0 && !PATTERNS.has(String(patch.pattern))) {
11839
- fail2(`pattern \u53EA\u80FD\u662F ${SOMA_FIELD_PATTERNS.join(" / ")}`, `${path}.pattern`);
12190
+ fail(`pattern \u53EA\u80FD\u662F ${SOMA_FIELD_PATTERNS.join(" / ")}`, `${path}.pattern`);
11840
12191
  }
11841
12192
  if (patch.required !== void 0 && typeof patch.required !== "boolean") {
11842
- fail2("required \u5FC5\u987B\u662F\u5E03\u5C14", `${path}.required`);
12193
+ fail("required \u5FC5\u987B\u662F\u5E03\u5C14", `${path}.required`);
11843
12194
  }
11844
12195
  if (patch.message !== void 0 && typeof patch.message !== "string") {
11845
- fail2("message \u5FC5\u987B\u662F\u5B57\u7B26\u4E32", `${path}.message`);
12196
+ fail("message \u5FC5\u987B\u662F\u5B57\u7B26\u4E32", `${path}.message`);
11846
12197
  }
11847
12198
  if (patch.options !== void 0) {
11848
12199
  const from = patch.options.from;
11849
12200
  if (typeof from !== "string" || !/^[A-Za-z_]\w*\.[A-Za-z_]\w*$/.test(from)) {
11850
- fail2("options.from \u5FC5\u987B\u662F '<\u5BF9\u8C61>.<\u5B57\u6BB5>' \u5F62\u6001", `${path}.options`);
12201
+ fail("options.from \u5FC5\u987B\u662F '<\u5BF9\u8C61>.<\u5B57\u6BB5>' \u5F62\u6001", `${path}.options`);
11851
12202
  }
11852
12203
  if (field.type !== "enum") {
11853
- fail2(`options \u53EA\u80FD\u5199\u5728 enum \u5B57\u6BB5\u4E0A\uFF0C"${target}" \u662F ${field.type ?? "text"}`, `${path}.options`);
12204
+ fail(`options \u53EA\u80FD\u5199\u5728 enum \u5B57\u6BB5\u4E0A\uFF0C"${target}" \u662F ${field.type ?? "text"}`, `${path}.options`);
11854
12205
  }
11855
12206
  }
11856
12207
  if (patch.value !== void 0 && field.permission === "r") {
11857
- fail2(
12208
+ fail(
11858
12209
  `"${target}" \u662F\u53EA\u8BFB\u5B57\u6BB5\uFF08permission: r\uFF09\uFF0C\u53CD\u5E94\u4E0D\u80FD\u7ED9\u5B83\u5199\u503C\u2014\u2014\u53EA\u8BFB\u662F\u6570\u636E\u5C42\u7684\u88C1\u51B3\uFF0C\u8054\u52A8\u7ED5\u8FC7\u5B83\u5C31\u7B49\u4E8E\u6CA1\u6709\u88C1\u51B3`,
11859
12210
  `${path}.value`
11860
12211
  );
@@ -11863,14 +12214,14 @@ function checkFieldPatch(raw2, target, field, fieldKeys, fieldTypes, path, fail2
11863
12214
  if (patch.value === "clear") return null;
11864
12215
  if (typeof patch.value === "object" && patch.value !== null && "from" in patch.value) {
11865
12216
  const from = String(patch.value.from);
11866
- if (!fieldKeys.includes(from)) fail2(`value.from \u5F15\u7528\u4E86\u4E0D\u5B58\u5728\u7684\u5B57\u6BB5 "${from}"`, `${path}.value`);
12217
+ if (!fieldKeys.includes(from)) fail(`value.from \u5F15\u7528\u4E86\u4E0D\u5B58\u5728\u7684\u5B57\u6BB5 "${from}"`, `${path}.value`);
11867
12218
  return { node: null, refs: [from] };
11868
12219
  }
11869
12220
  if (typeof patch.value === "object" && patch.value !== null && "calc" in patch.value) {
11870
12221
  const source = String(patch.value.calc);
11871
12222
  const declared = field.type ?? "text";
11872
12223
  if (!CALC_WRITABLE.has(declared)) {
11873
- fail2(`calc \u4E0D\u80FD\u5199\u8FDB ${declared} \u7C7B\u578B\u7684\u5B57\u6BB5 "${target}"`, `${path}.value`);
12224
+ fail(`calc \u4E0D\u80FD\u5199\u8FDB ${declared} \u7C7B\u578B\u7684\u5B57\u6BB5 "${target}"`, `${path}.value`);
11874
12225
  }
11875
12226
  try {
11876
12227
  const node = parseCalc(source);
@@ -11880,14 +12231,14 @@ function checkFieldPatch(raw2, target, field, fieldKeys, fieldTypes, path, fail2
11880
12231
  return { node, refs: collectCalcRefs(node) };
11881
12232
  } catch (error) {
11882
12233
  if (error instanceof SomaCalcSyntaxError || error instanceof SomaCalcTypeError) {
11883
- fail2(error.message, `${path}.value`);
12234
+ fail(error.message, `${path}.value`);
11884
12235
  }
11885
12236
  throw error;
11886
12237
  }
11887
12238
  }
11888
- return fail2("value \u53EA\u80FD\u662F 'clear' / { from: \u5B57\u6BB5 } / { calc: \u8868\u8FBE\u5F0F }", `${path}.value`);
12239
+ return fail("value \u53EA\u80FD\u662F 'clear' / { from: \u5B57\u6BB5 } / { calc: \u8868\u8FBE\u5F0F }", `${path}.value`);
11889
12240
  }
11890
- function topoSort(parsed, path, fail2) {
12241
+ function topoSort(parsed, path, fail) {
11891
12242
  const n = parsed.length;
11892
12243
  const writerOf = /* @__PURE__ */ new Map();
11893
12244
  parsed.forEach((item, index) => {
@@ -11928,7 +12279,7 @@ function topoSort(parsed, path, fail2) {
11928
12279
  const remaining = /* @__PURE__ */ new Set();
11929
12280
  for (let i = 0; i < n; i += 1) if (!order.includes(i)) remaining.add(i);
11930
12281
  const cycle = traceCycle(remaining, edges);
11931
- fail2(
12282
+ fail(
11932
12283
  `\u53CD\u5E94\u4E4B\u95F4\u6210\u73AF\uFF1A${cycle.map((i) => `#${i + 1}`).join(" \u2192 ")} \u2192 #${cycle[0] + 1}\uFF08\u7F16\u53F7\u662F\u58F0\u660E\u5E8F\uFF09\u3002\u6210\u73AF\u7684\u53CD\u5E94\u4F1A\u5728\u4E00\u6B21\u8F93\u5165\u91CC\u6765\u56DE\u6539\u540C\u4E00\u6279\u5B57\u6BB5\uFF0C\u8868\u73B0\u662F\u8F93\u5165\u6846\u81EA\u5DF1\u8DF3\uFF1B\u8BF7\u628A\u5176\u4E2D\u4E00\u6761\u6539\u6210\u5355\u5411\uFF0C\u6216\u628A\u4E2D\u95F4\u7ED3\u679C\u505A\u6210\u4E00\u4E2A\u771F\u5B9E\u5B57\u6BB5`,
11933
12284
  path
11934
12285
  );
@@ -12000,10 +12351,10 @@ var SOMA_AGGREGATE_FNS = ["sum", "avg", "min", "max", "count"];
12000
12351
  var SOMA_SELECT_ALL_MODES = ["all", "filtered", "current_page"];
12001
12352
 
12002
12353
  // core/client/parser/duration.ts
12003
- function parseDuration(raw2, where, fail2) {
12354
+ function parseDuration(raw2, where, fail) {
12004
12355
  const match = /^(\d+(?:\.\d+)?)(ms|s|m)$/.exec(raw2.trim());
12005
12356
  if (!match) {
12006
- fail2(`${where} \u7684\u65F6\u957F "${raw2}" \u975E\u6CD5\u2014\u2014\u5F62\u5982 500ms / 30s / 5m\uFF08\u5355\u4F4D\u5FC5\u586B\uFF0C\u4E0D\u731C\uFF09`);
12357
+ fail(`${where} \u7684\u65F6\u957F "${raw2}" \u975E\u6CD5\u2014\u2014\u5F62\u5982 500ms / 30s / 5m\uFF08\u5355\u4F4D\u5FC5\u586B\uFF0C\u4E0D\u731C\uFF09`);
12007
12358
  }
12008
12359
  const value = Number(match[1]);
12009
12360
  const unit = match[2];
@@ -12026,22 +12377,22 @@ var CONFIG_KEYS3 = /* @__PURE__ */ new Set([
12026
12377
  ]);
12027
12378
  var NUMERIC_TYPES = /* @__PURE__ */ new Set(["int", "float", "money", "percent", "progress"]);
12028
12379
  var DEFAULT_BLOCK = { size: 100, max_blocks: 10, debounce_ms: 120 };
12029
- function isPlainObject4(value) {
12380
+ function isPlainObject5(value) {
12030
12381
  return value !== null && typeof value === "object" && !Array.isArray(value);
12031
12382
  }
12032
12383
  function parseWindow(input, deps) {
12033
12384
  const { raw: raw2, fields, path } = input;
12034
- const fail2 = deps.fail;
12035
- if (!isPlainObject4(raw2)) fail2("window \u5FC5\u987B\u662F\u6620\u5C04", path);
12385
+ const fail = deps.fail;
12386
+ if (!isPlainObject5(raw2)) fail("window \u5FC5\u987B\u662F\u6620\u5C04", path);
12036
12387
  const section = raw2;
12037
12388
  for (const key of Object.keys(section)) {
12038
12389
  if (!CONFIG_KEYS3.has(key)) {
12039
- fail2(`\u672A\u77E5\u7684 window \u5B57\u6BB5 "${key}"\uFF08\u652F\u6301: ${[...CONFIG_KEYS3].join(" / ")}\uFF09`, `${path}.${key}`);
12390
+ fail(`\u672A\u77E5\u7684 window \u5B57\u6BB5 "${key}"\uFF08\u652F\u6301: ${[...CONFIG_KEYS3].join(" / ")}\uFF09`, `${path}.${key}`);
12040
12391
  }
12041
12392
  }
12042
12393
  const mode = section.mode === void 0 ? "server" : String(section.mode);
12043
12394
  if (mode !== "server") {
12044
- fail2(`window.mode \u53EA\u80FD\u662F server\uFF08\u6536\u5230 "${mode}"\uFF09\u2014\u2014\u5BA2\u6237\u7AEF\u7A97\u53E3\u4E0D\u505A\uFF0C\u89C1\u300A\u6570\u636E\u5BF9\u8C61\u5C42\u300B\xA711`, `${path}.mode`);
12395
+ fail(`window.mode \u53EA\u80FD\u662F server\uFF08\u6536\u5230 "${mode}"\uFF09\u2014\u2014\u5BA2\u6237\u7AEF\u7A97\u53E3\u4E0D\u505A\uFF0C\u89C1\u300A\u6570\u636E\u5BF9\u8C61\u5C42\u300B\xA711`, `${path}.mode`);
12045
12396
  }
12046
12397
  const fieldKeys = Object.keys(fields);
12047
12398
  const fieldTypes = Object.fromEntries(
@@ -12050,23 +12401,23 @@ function parseWindow(input, deps) {
12050
12401
  const requireField = (name, at) => {
12051
12402
  const key = String(name ?? "");
12052
12403
  if (!fieldKeys.includes(key)) {
12053
- fail2(`${at} \u5F15\u7528\u4E86\u4E0D\u5B58\u5728\u7684\u5B57\u6BB5 "${key}"\uFF08\u672C\u5BF9\u8C61\u5B57\u5178\uFF1A${fieldKeys.join(" / ") || "\u7A7A"}\uFF09`, at);
12404
+ fail(`${at} \u5F15\u7528\u4E86\u4E0D\u5B58\u5728\u7684\u5B57\u6BB5 "${key}"\uFF08\u672C\u5BF9\u8C61\u5B57\u5178\uFF1A${fieldKeys.join(" / ") || "\u7A7A"}\uFF09`, at);
12054
12405
  }
12055
12406
  return key;
12056
12407
  };
12057
12408
  const parseFilter = (node, at, depth) => {
12058
12409
  if (depth > MAX_FILTER_DEPTH) {
12059
- fail2(`${at} \u7684\u8FC7\u6EE4\u6761\u4EF6\u5D4C\u5957\u8D85\u8FC7 ${MAX_FILTER_DEPTH} \u5C42\u2014\u2014\u518D\u6DF1\u5C31\u6CA1\u4EBA\u8BFB\u5F97\u61C2\u4E86`, at);
12410
+ fail(`${at} \u7684\u8FC7\u6EE4\u6761\u4EF6\u5D4C\u5957\u8D85\u8FC7 ${MAX_FILTER_DEPTH} \u5C42\u2014\u2014\u518D\u6DF1\u5C31\u6CA1\u4EBA\u8BFB\u5F97\u61C2\u4E86`, at);
12060
12411
  }
12061
- if (!isPlainObject4(node)) fail2(`${at} \u5FC5\u987B\u662F\u6620\u5C04`, at);
12412
+ if (!isPlainObject5(node)) fail(`${at} \u5FC5\u987B\u662F\u6620\u5C04`, at);
12062
12413
  if ("join" in node || "conditions" in node) {
12063
12414
  const branch = node;
12064
12415
  const join = String(branch.join ?? "");
12065
12416
  if (join !== "and" && join !== "or") {
12066
- fail2(`${at}.join \u53EA\u80FD\u662F and / or\uFF08\u6536\u5230 ${JSON.stringify(branch.join)}\uFF09`, `${at}.join`);
12417
+ fail(`${at}.join \u53EA\u80FD\u662F and / or\uFF08\u6536\u5230 ${JSON.stringify(branch.join)}\uFF09`, `${at}.join`);
12067
12418
  }
12068
12419
  if (!Array.isArray(branch.conditions) || branch.conditions.length === 0) {
12069
- fail2(`${at}.conditions \u5FC5\u987B\u662F\u975E\u7A7A\u6570\u7EC4`, `${at}.conditions`);
12420
+ fail(`${at}.conditions \u5FC5\u987B\u662F\u975E\u7A7A\u6570\u7EC4`, `${at}.conditions`);
12070
12421
  }
12071
12422
  return {
12072
12423
  join,
@@ -12076,7 +12427,7 @@ function parseWindow(input, deps) {
12076
12427
  };
12077
12428
  }
12078
12429
  const issues = validatePredicate(node, fieldKeys, at, { fieldTypes });
12079
- if (issues.length > 0) fail2(issues.join("\uFF1B"), at);
12430
+ if (issues.length > 0) fail(issues.join("\uFF1B"), at);
12080
12431
  const leaf = node;
12081
12432
  return {
12082
12433
  field: String(leaf.field),
@@ -12087,13 +12438,13 @@ function parseWindow(input, deps) {
12087
12438
  const filter = section.filter === void 0 || section.filter === null ? null : parseFilter(section.filter, `${path}.filter`, 1);
12088
12439
  const sort = [];
12089
12440
  if (section.sort !== void 0) {
12090
- if (!Array.isArray(section.sort)) fail2(`${path}.sort \u5FC5\u987B\u662F\u6570\u7EC4`, `${path}.sort`);
12441
+ if (!Array.isArray(section.sort)) fail(`${path}.sort \u5FC5\u987B\u662F\u6570\u7EC4`, `${path}.sort`);
12091
12442
  section.sort.forEach((entry, index) => {
12092
12443
  const at = `${path}.sort[${index}]`;
12093
- if (!isPlainObject4(entry)) fail2(`${at} \u5FC5\u987B\u662F { field, order }`, at);
12444
+ if (!isPlainObject5(entry)) fail(`${at} \u5FC5\u987B\u662F { field, order }`, at);
12094
12445
  const order = String(entry.order ?? "asc");
12095
12446
  if (order !== "asc" && order !== "desc") {
12096
- fail2(`${at}.order \u53EA\u80FD\u662F asc / desc\uFF08\u6536\u5230 ${JSON.stringify(entry.order)}\uFF09`, `${at}.order`);
12447
+ fail(`${at}.order \u53EA\u80FD\u662F asc / desc\uFF08\u6536\u5230 ${JSON.stringify(entry.order)}\uFF09`, `${at}.order`);
12097
12448
  }
12098
12449
  sort.push({ field: requireField(entry.field, `${at}.field`), order });
12099
12450
  });
@@ -12101,13 +12452,13 @@ function parseWindow(input, deps) {
12101
12452
  let group = null;
12102
12453
  if (section.group !== void 0 && section.group !== null) {
12103
12454
  const at = `${path}.group`;
12104
- if (!isPlainObject4(section.group)) fail2(`${at} \u5FC5\u987B\u662F { by, keys? }`, at);
12455
+ if (!isPlainObject5(section.group)) fail(`${at} \u5FC5\u987B\u662F { by, keys? }`, at);
12105
12456
  const by = section.group.by;
12106
- if (!Array.isArray(by) || by.length === 0) fail2(`${at}.by \u5FC5\u987B\u662F\u975E\u7A7A\u6570\u7EC4`, `${at}.by`);
12457
+ if (!Array.isArray(by) || by.length === 0) fail(`${at}.by \u5FC5\u987B\u662F\u975E\u7A7A\u6570\u7EC4`, `${at}.by`);
12107
12458
  const keys = section.group.keys ?? [];
12108
- if (!Array.isArray(keys)) fail2(`${at}.keys \u5FC5\u987B\u662F\u6570\u7EC4`, `${at}.keys`);
12459
+ if (!Array.isArray(keys)) fail(`${at}.keys \u5FC5\u987B\u662F\u6570\u7EC4`, `${at}.keys`);
12109
12460
  if (keys.length > by.length) {
12110
- fail2(
12461
+ fail(
12111
12462
  `${at}.keys \u6709 ${keys.length} \u6BB5\uFF0C\u4F46\u53EA\u6309 ${by.length} \u4E2A\u5B57\u6BB5\u5206\u7EC4\u2014\u2014\u5C55\u5F00\u8DEF\u5F84\u4E0D\u53EF\u80FD\u6BD4\u5206\u7EC4\u5C42\u6570\u6DF1`,
12112
12463
  `${at}.keys`
12113
12464
  );
@@ -12119,18 +12470,18 @@ function parseWindow(input, deps) {
12119
12470
  }
12120
12471
  const aggregate = [];
12121
12472
  if (section.aggregate !== void 0) {
12122
- if (!Array.isArray(section.aggregate)) fail2(`${path}.aggregate \u5FC5\u987B\u662F\u6570\u7EC4`, `${path}.aggregate`);
12473
+ if (!Array.isArray(section.aggregate)) fail(`${path}.aggregate \u5FC5\u987B\u662F\u6570\u7EC4`, `${path}.aggregate`);
12123
12474
  section.aggregate.forEach((entry, index) => {
12124
12475
  const at = `${path}.aggregate[${index}]`;
12125
- if (!isPlainObject4(entry)) fail2(`${at} \u5FC5\u987B\u662F { field, fn }`, at);
12476
+ if (!isPlainObject5(entry)) fail(`${at} \u5FC5\u987B\u662F { field, fn }`, at);
12126
12477
  const fn = String(entry.fn ?? "");
12127
12478
  if (!SOMA_AGGREGATE_FNS.includes(fn)) {
12128
- fail2(`${at}.fn \u53EA\u80FD\u662F ${SOMA_AGGREGATE_FNS.join(" / ")}\uFF08\u6536\u5230 ${JSON.stringify(entry.fn)}\uFF09`, `${at}.fn`);
12479
+ fail(`${at}.fn \u53EA\u80FD\u662F ${SOMA_AGGREGATE_FNS.join(" / ")}\uFF08\u6536\u5230 ${JSON.stringify(entry.fn)}\uFF09`, `${at}.fn`);
12129
12480
  }
12130
12481
  const field = requireField(entry.field, `${at}.field`);
12131
12482
  const type2 = fieldTypes[field] ?? "";
12132
12483
  if (fn !== "count" && !NUMERIC_TYPES.has(type2)) {
12133
- fail2(
12484
+ fail(
12134
12485
  `${at}.fn=${fn} \u4E0D\u80FD\u7528\u5728 ${type2 || "\u672A\u58F0\u660E\u7C7B\u578B"} \u7684\u5B57\u6BB5 "${field}" \u4E0A\uFF08\u53EA\u6709 ${[...NUMERIC_TYPES].join(" / ")} \u80FD\u6C42\u548C\u6C42\u5747\uFF1B\u8981\u6570\u884C\u6570\u8BF7\u7528 count\uFF09`,
12135
12486
  `${at}.fn`
12136
12487
  );
@@ -12141,24 +12492,24 @@ function parseWindow(input, deps) {
12141
12492
  let selection = { base: "none", toggled: [] };
12142
12493
  if (section.selection !== void 0) {
12143
12494
  const at = `${path}.selection`;
12144
- if (!isPlainObject4(section.selection)) fail2(`${at} \u5FC5\u987B\u662F { base, toggled }`, at);
12495
+ if (!isPlainObject5(section.selection)) fail(`${at} \u5FC5\u987B\u662F { base, toggled }`, at);
12145
12496
  const base = String(section.selection.base ?? "none");
12146
12497
  if (base !== "none" && base !== "all") {
12147
- fail2(`${at}.base \u53EA\u80FD\u662F none / all\uFF08\u6536\u5230 ${JSON.stringify(section.selection.base)}\uFF09`, `${at}.base`);
12498
+ fail(`${at}.base \u53EA\u80FD\u662F none / all\uFF08\u6536\u5230 ${JSON.stringify(section.selection.base)}\uFF09`, `${at}.base`);
12148
12499
  }
12149
12500
  const toggled = section.selection.toggled ?? [];
12150
- if (!Array.isArray(toggled)) fail2(`${at}.toggled \u5FC5\u987B\u662F\u6570\u7EC4`, `${at}.toggled`);
12501
+ if (!Array.isArray(toggled)) fail(`${at}.toggled \u5FC5\u987B\u662F\u6570\u7EC4`, `${at}.toggled`);
12151
12502
  selection = { base, toggled: toggled.map((id) => String(id)) };
12152
12503
  }
12153
12504
  const selectAll = String(section.select_all ?? "filtered");
12154
12505
  if (!SOMA_SELECT_ALL_MODES.includes(selectAll)) {
12155
- fail2(
12506
+ fail(
12156
12507
  `${path}.select_all \u53EA\u80FD\u662F ${SOMA_SELECT_ALL_MODES.join(" / ")}\uFF08\u6536\u5230 ${JSON.stringify(section.select_all)}\uFF09`,
12157
12508
  `${path}.select_all`
12158
12509
  );
12159
12510
  }
12160
12511
  if (selectAll === "current_page" && selection.base === "all") {
12161
- fail2(
12512
+ fail(
12162
12513
  `${path}.select_all=current_page \u4E0E selection.base=all \u51B2\u7A81\u2014\u2014\u53EA\u9009\u5F53\u524D\u9875\u65F6\u57FA\u7EBF\u53EA\u80FD\u662F none\uFF08\u5426\u5219"\u5168\u9009"\u5230\u5E95\u6307\u54EA\u4E9B\u884C\u8BF4\u4E0D\u6E05\uFF09`,
12163
12514
  `${path}.select_all`
12164
12515
  );
@@ -12166,29 +12517,29 @@ function parseWindow(input, deps) {
12166
12517
  const block = { ...DEFAULT_BLOCK };
12167
12518
  if (section.block !== void 0) {
12168
12519
  const at = `${path}.block`;
12169
- if (!isPlainObject4(section.block)) fail2(`${at} \u5FC5\u987B\u662F\u6620\u5C04`, at);
12520
+ if (!isPlainObject5(section.block)) fail(`${at} \u5FC5\u987B\u662F\u6620\u5C04`, at);
12170
12521
  const positive = (raw22, key, fallback) => {
12171
12522
  if (raw22 === void 0) return fallback;
12172
12523
  const value = Number(raw22);
12173
12524
  if (!Number.isInteger(value) || value <= 0) {
12174
- fail2(`${at}.${key} \u5FC5\u987B\u662F\u6B63\u6574\u6570\uFF08\u6536\u5230 ${JSON.stringify(raw22)}\uFF09`, `${at}.${key}`);
12525
+ fail(`${at}.${key} \u5FC5\u987B\u662F\u6B63\u6574\u6570\uFF08\u6536\u5230 ${JSON.stringify(raw22)}\uFF09`, `${at}.${key}`);
12175
12526
  }
12176
12527
  return value;
12177
12528
  };
12178
12529
  block.size = positive(section.block.size, "size", DEFAULT_BLOCK.size);
12179
12530
  block.max_blocks = positive(section.block.max_blocks, "max_blocks", DEFAULT_BLOCK.max_blocks);
12180
- block.debounce_ms = section.block.debounce === void 0 ? DEFAULT_BLOCK.debounce_ms : parseDuration(String(section.block.debounce), `${at}.debounce`, (m) => fail2(m, `${at}.debounce`));
12531
+ block.debounce_ms = section.block.debounce === void 0 ? DEFAULT_BLOCK.debounce_ms : parseDuration(String(section.block.debounce), `${at}.debounce`, (m) => fail(m, `${at}.debounce`));
12181
12532
  }
12182
12533
  const cache = { ttl_ms: null, keep_previous: false };
12183
12534
  if (section.cache !== void 0) {
12184
12535
  const at = `${path}.cache`;
12185
- if (!isPlainObject4(section.cache)) fail2(`${at} \u5FC5\u987B\u662F { ttl?, keep_previous? }`, at);
12536
+ if (!isPlainObject5(section.cache)) fail(`${at} \u5FC5\u987B\u662F { ttl?, keep_previous? }`, at);
12186
12537
  if (section.cache.ttl !== void 0) {
12187
- cache.ttl_ms = parseDuration(String(section.cache.ttl), `${at}.ttl`, (m) => fail2(m, `${at}.ttl`));
12538
+ cache.ttl_ms = parseDuration(String(section.cache.ttl), `${at}.ttl`, (m) => fail(m, `${at}.ttl`));
12188
12539
  }
12189
12540
  cache.keep_previous = section.cache.keep_previous === true;
12190
12541
  }
12191
- const revalidateMs = section.revalidate === void 0 ? null : parseDuration(String(section.revalidate), `${path}.revalidate`, (m) => fail2(m, `${path}.revalidate`));
12542
+ const revalidateMs = section.revalidate === void 0 ? null : parseDuration(String(section.revalidate), `${path}.revalidate`, (m) => fail(m, `${path}.revalidate`));
12192
12543
  return {
12193
12544
  mode: "server",
12194
12545
  block,
@@ -12224,6 +12575,29 @@ var SomaDataConfigError = class extends Error {
12224
12575
  };
12225
12576
  var VALID_FIELD_TYPES = new Set(SOMA_DATA_FIELD_TYPES);
12226
12577
  var VALID_PERMISSIONS = /* @__PURE__ */ new Set(["r", "w"]);
12578
+ var SOMA_DATA_OBJECT_KEYS = [
12579
+ "from",
12580
+ "transform",
12581
+ "fields",
12582
+ "mock",
12583
+ "write",
12584
+ "predicates",
12585
+ "reactions",
12586
+ "window",
12587
+ // REQ-014 期 2'.1:对象界面演绎的语义位与关系
12588
+ "roles",
12589
+ "relations"
12590
+ ];
12591
+ var SOMA_DATA_FIELD_KEYS = [
12592
+ "name",
12593
+ "type",
12594
+ "permission",
12595
+ "rules",
12596
+ "options",
12597
+ "calc",
12598
+ // REQ-014 期 2'.1:修饰关系(`status_tone` 修饰 `status_text`)
12599
+ "modifies"
12600
+ ];
12227
12601
  var RULE_VALUE_TYPES = {
12228
12602
  required: "boolean",
12229
12603
  max_len: "number",
@@ -12433,9 +12807,14 @@ function parseField(raw2, path) {
12433
12807
  throw new SomaDataConfigError("calc \u5FC5\u987B\u662F\u975E\u7A7A\u8868\u8FBE\u5F0F\u5B57\u7B26\u4E32", `${path}.calc`);
12434
12808
  }
12435
12809
  field.calc = value;
12810
+ } else if (key === "modifies") {
12811
+ if (typeof value !== "string" || value.trim() === "") {
12812
+ throw new SomaDataConfigError("modifies \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u6BB5\u540D", `${path}.modifies`);
12813
+ }
12814
+ field.modifies = value;
12436
12815
  } else {
12437
12816
  throw new SomaDataConfigError(
12438
- `\u672A\u77E5\u7684\u5B57\u5178\u5B57\u6BB5 "${key}"\uFF08\u652F\u6301: name / type / permission / rules / options / calc\uFF09`,
12817
+ `\u672A\u77E5\u7684\u5B57\u5178\u5B57\u6BB5 "${key}"\uFF08\u652F\u6301: ${SOMA_DATA_FIELD_KEYS.join(" / ")}\uFF09`,
12439
12818
  `${path}.${key}`
12440
12819
  );
12441
12820
  }
@@ -12635,6 +13014,8 @@ function parseObject(name, raw2, path, objectNames) {
12635
13014
  let predicatesRaw;
12636
13015
  let reactionsRaw;
12637
13016
  let windowRaw;
13017
+ let rolesRaw;
13018
+ let relationsRaw;
12638
13019
  for (const [key, value] of Object.entries(raw2)) {
12639
13020
  if (key === "from") {
12640
13021
  if (!Array.isArray(value) || value.length === 0) {
@@ -12652,6 +13033,10 @@ function parseObject(name, raw2, path, objectNames) {
12652
13033
  fields2[fieldName] = parseField(fieldRaw, `${path}.fields.${fieldName}`);
12653
13034
  }
12654
13035
  validateDerivedFields(fields2, `${path}.fields`);
13036
+ const modifiesIssues = validateFieldModifies(fields2);
13037
+ if (modifiesIssues.length > 0) {
13038
+ throw new SomaDataConfigError(modifiesIssues.join("\uFF1B"), `${path}.fields`);
13039
+ }
12655
13040
  config.fields = fields2;
12656
13041
  } else if (key === "mock") {
12657
13042
  config.mock = value;
@@ -12663,13 +13048,35 @@ function parseObject(name, raw2, path, objectNames) {
12663
13048
  reactionsRaw = value;
12664
13049
  } else if (key === "window") {
12665
13050
  windowRaw = value;
13051
+ } else if (key === "roles") {
13052
+ rolesRaw = value;
13053
+ } else if (key === "relations") {
13054
+ relationsRaw = value;
12666
13055
  } else {
12667
13056
  throw new SomaDataConfigError(
12668
- `\u672A\u77E5\u7684\u58F0\u660E\u5B57\u6BB5 "${key}"\uFF08\u652F\u6301: from / transform / fields / mock / write / predicates / reactions / window\uFF09`,
13057
+ `\u672A\u77E5\u7684\u58F0\u660E\u5B57\u6BB5 "${key}"\uFF08\u652F\u6301: ${SOMA_DATA_OBJECT_KEYS.join(" / ")}\uFF09`,
12669
13058
  `${path}.${key}`
12670
13059
  );
12671
13060
  }
12672
13061
  }
13062
+ if (rolesRaw !== void 0) {
13063
+ const issues = validateObjectRoles(rolesRaw, Object.keys(config.fields ?? {}));
13064
+ if (issues.length > 0) {
13065
+ throw new SomaDataConfigError(issues.join("\uFF1B"), `${path}.roles`);
13066
+ }
13067
+ config.roles = rolesRaw;
13068
+ }
13069
+ if (relationsRaw !== void 0) {
13070
+ const issues = validateObjectRelations(relationsRaw, {
13071
+ fieldKeys: Object.keys(config.fields ?? {}),
13072
+ objectNames: [...objectNames],
13073
+ selfName: name
13074
+ });
13075
+ if (issues.length > 0) {
13076
+ throw new SomaDataConfigError(issues.join("\uFF1B"), `${path}.relations`);
13077
+ }
13078
+ config.relations = relationsRaw;
13079
+ }
12673
13080
  if (writeRaw !== void 0) {
12674
13081
  config.write = parseWrite(writeRaw, config.fields ?? {}, `${path}.write`, objectNames);
12675
13082
  }
@@ -13093,7 +13500,7 @@ function isSomaMockEnabled() {
13093
13500
  const envFlag = typeof process !== "undefined" ? process.env?.SOMA_MOCK_ENABLED : void 0;
13094
13501
  return envFlag === "1" || envFlag === "true";
13095
13502
  }
13096
- function isPlainObject5(value) {
13503
+ function isPlainObject6(value) {
13097
13504
  return typeof value === "object" && value !== null && !Array.isArray(value);
13098
13505
  }
13099
13506
  function readPath2(root, segments) {
@@ -13116,22 +13523,22 @@ function referencesObject(value, objectName) {
13116
13523
  if (Array.isArray(value)) {
13117
13524
  return value.some((item) => referencesObject(item, objectName));
13118
13525
  }
13119
- if (isPlainObject5(value)) {
13526
+ if (isPlainObject6(value)) {
13120
13527
  return Object.values(value).some((item) => referencesObject(item, objectName));
13121
13528
  }
13122
13529
  return false;
13123
13530
  }
13124
13531
  function extractErrorPayload(error) {
13125
13532
  const candidates = [error];
13126
- if (isPlainObject5(error)) {
13533
+ if (isPlainObject6(error)) {
13127
13534
  candidates.push(error.response, error.data, error.body);
13128
- if (isPlainObject5(error.response)) candidates.push(error.response.data);
13535
+ if (isPlainObject6(error.response)) candidates.push(error.response.data);
13129
13536
  }
13130
13537
  for (const candidate of candidates) {
13131
- if (!isPlainObject5(candidate)) continue;
13538
+ if (!isPlainObject6(candidate)) continue;
13132
13539
  const rawFieldErrors = candidate.fieldErrors ?? candidate.field_errors ?? candidate.errors;
13133
13540
  const message = typeof candidate.message === "string" ? candidate.message : void 0;
13134
- if (isPlainObject5(rawFieldErrors)) {
13541
+ if (isPlainObject6(rawFieldErrors)) {
13135
13542
  const fieldErrors = {};
13136
13543
  for (const [key, value] of Object.entries(rawFieldErrors)) {
13137
13544
  if (typeof value === "string") fieldErrors[key] = value;
@@ -13343,7 +13750,7 @@ var SomaDataObjectResolver = class {
13343
13750
  if (!write.update) return "create";
13344
13751
  if (!write.create) return "update";
13345
13752
  const current = this.objects[name];
13346
- const hasRecord = isPlainObject5(current) && Object.keys(current).length > 0;
13753
+ const hasRecord = isPlainObject6(current) && Object.keys(current).length > 0;
13347
13754
  return hasRecord ? "update" : "create";
13348
13755
  }
13349
13756
  /** 构造请求体:剔除只读字段 → map 改名 → 补乐观锁位 */
@@ -13359,7 +13766,7 @@ var SomaDataObjectResolver = class {
13359
13766
  }
13360
13767
  if (write.version && !(write.version in model)) {
13361
13768
  const current = this.objects[decl.name];
13362
- const versionValue = isPlainObject5(current) ? current[write.version] : void 0;
13769
+ const versionValue = isPlainObject6(current) ? current[write.version] : void 0;
13363
13770
  if (versionValue !== void 0) {
13364
13771
  body[write.map?.[write.version] ?? write.version] = versionValue;
13365
13772
  }
@@ -13503,12 +13910,12 @@ var SomaDataObjectResolver = class {
13503
13910
  /** 聚合来源结果:into 写入子键;缺省浅合并进根(非对象结果整体替换) */
13504
13911
  mergeSource(current, source, data) {
13505
13912
  if (source.into) {
13506
- const target = isPlainObject5(current) ? current : {};
13913
+ const target = isPlainObject6(current) ? current : {};
13507
13914
  target[source.into] = data;
13508
13915
  return target;
13509
13916
  }
13510
- if (isPlainObject5(data)) {
13511
- if (isPlainObject5(current)) {
13917
+ if (isPlainObject6(data)) {
13918
+ if (isPlainObject6(current)) {
13512
13919
  Object.assign(current, data);
13513
13920
  return current;
13514
13921
  }
@@ -13544,7 +13951,7 @@ var SomaDataObjectResolver = class {
13544
13951
  if (Array.isArray(raw2)) {
13545
13952
  return raw2.map((item) => this.resolveParamValue(item, selfName, selfValue));
13546
13953
  }
13547
- if (isPlainObject5(raw2)) {
13954
+ if (isPlainObject6(raw2)) {
13548
13955
  const result = {};
13549
13956
  for (const [key, item] of Object.entries(raw2)) {
13550
13957
  result[key] = this.resolveParamValue(item, selfName, selfValue);
@@ -13580,7 +13987,7 @@ var SomaDataObjectResolver = class {
13580
13987
  }
13581
13988
  applyTransform(value, decl) {
13582
13989
  if (!decl.transform) return value;
13583
- if (!isPlainObject5(value)) {
13990
+ if (!isPlainObject6(value)) {
13584
13991
  console.warn(`[soma-core][\u6570\u636E] \u5BF9\u8C61 "${decl.name}" \u4E0D\u662F\u5BF9\u8C61\u7ED3\u6784\uFF0Ctransform \u6D3E\u751F\u5B57\u6BB5\u88AB\u8DF3\u8FC7`);
13585
13992
  return value;
13586
13993
  }
@@ -13635,20 +14042,39 @@ var SomaDataObjectResolver = class {
13635
14042
  for (const key of order) row[key] = evaluateCalc(asts.get(key), row);
13636
14043
  };
13637
14044
  if (Array.isArray(value)) {
13638
- for (const row of value) if (isPlainObject5(row)) fill(row);
14045
+ for (const row of value) if (isPlainObject6(row)) fill(row);
13639
14046
  return value;
13640
14047
  }
13641
- if (isPlainObject5(value)) {
14048
+ if (isPlainObject6(value)) {
13642
14049
  fill(value);
13643
14050
  for (const nested of Object.values(value)) {
13644
14051
  if (Array.isArray(nested)) {
13645
- for (const row of nested) if (isPlainObject5(row)) fill(row);
14052
+ for (const row of nested) if (isPlainObject6(row)) fill(row);
13646
14053
  }
13647
14054
  }
13648
14055
  }
13649
14056
  return value;
13650
14057
  }
13651
14058
  };
14059
+ function createSomaDataPort(currentResolver) {
14060
+ const noResolver = (action) => ({
14061
+ ok: false,
14062
+ message: `\u6570\u636E\u5BF9\u8C61\u5C1A\u672A\u5C31\u7EEA\uFF0C\u65E0\u6CD5${action}\uFF08\u672C\u9875\u53EF\u80FD\u6CA1\u6709\u58F0\u660E *_data.yaml\uFF09`
14063
+ });
14064
+ return {
14065
+ getObject: (name) => currentResolver()?.getObject(name),
14066
+ getDict: (name) => currentResolver()?.getDict(name) ?? {},
14067
+ getReactions: (name) => currentResolver()?.getReactions(name) ?? null,
14068
+ window: (name) => currentResolver()?.window(name) ?? null,
14069
+ submit: async (name, model, mode) => {
14070
+ const resolver = currentResolver();
14071
+ return resolver ? resolver.submit(name, model, mode) : noResolver(`\u63D0\u4EA4 "${name}"`);
14072
+ },
14073
+ reload: async (names) => {
14074
+ await currentResolver()?.reload(names);
14075
+ }
14076
+ };
14077
+ }
13652
14078
 
13653
14079
  // core/shared/types/component-contract.types.ts
13654
14080
  function findNestedMutableContractDefault(value) {
@@ -14032,7 +14458,7 @@ var SomaComponentManager = class {
14032
14458
  prepare(container, uiConfig) {
14033
14459
  this.propsIndex = collectPagePropsDecls(uiConfig.show);
14034
14460
  this.staticDecls = [];
14035
- for (let round2 = 0; round2 < MAX_EXPANSION_ROUNDS + 1; round2++) {
14461
+ for (let round = 0; round < MAX_EXPANSION_ROUNDS + 1; round++) {
14036
14462
  const pending2 = Array.from(
14037
14463
  container.querySelectorAll(`[${SOMA_COMPONENT_ATTR}]`)
14038
14464
  ).filter(
@@ -14041,7 +14467,7 @@ var SomaComponentManager = class {
14041
14467
  if (pending2.length === 0) {
14042
14468
  return;
14043
14469
  }
14044
- if (round2 === MAX_EXPANSION_ROUNDS) {
14470
+ if (round === MAX_EXPANSION_ROUNDS) {
14045
14471
  throw new SomaComponentExpandError(
14046
14472
  `\u7EC4\u4EF6\u5D4C\u5957\u6DF1\u5EA6\u8D85\u8FC7\u4E0A\u9650 ${MAX_EXPANSION_ROUNDS}\uFF08\u53EF\u80FD\u5B58\u5728\u5FAA\u73AF\u5F15\u7528\uFF09`
14047
14473
  );
@@ -14239,7 +14665,7 @@ var SomaComponentManager = class {
14239
14665
  * 未注册的组件名在此静默跳过(不阻塞收敛),照旧由 applyChildComponent 抛错点名。
14240
14666
  */
14241
14667
  expandNestedTemplates(root) {
14242
- for (let round2 = 0; round2 < MAX_EXPANSION_ROUNDS + 1; round2++) {
14668
+ for (let round = 0; round < MAX_EXPANSION_ROUNDS + 1; round++) {
14243
14669
  const pending2 = Array.from(
14244
14670
  root.querySelectorAll(`[${SOMA_CHILD_COMPONENT_ID_ATTR}]`)
14245
14671
  ).filter((host) => {
@@ -14250,7 +14676,7 @@ var SomaComponentManager = class {
14250
14676
  if (pending2.length === 0) {
14251
14677
  return;
14252
14678
  }
14253
- if (round2 === MAX_EXPANSION_ROUNDS) {
14679
+ if (round === MAX_EXPANSION_ROUNDS) {
14254
14680
  throw new SomaComponentExpandError(
14255
14681
  `\u7EC4\u4EF6\u5D4C\u5957\u6DF1\u5EA6\u8D85\u8FC7\u4E0A\u9650 ${MAX_EXPANSION_ROUNDS}\uFF08\u53EF\u80FD\u5B58\u5728\u5FAA\u73AF\u5F15\u7528\uFF09`
14256
14682
  );
@@ -14776,13 +15202,13 @@ var CHROMA_MUL = {
14776
15202
  vivid: 1.35
14777
15203
  };
14778
15204
  var CONTRAST_TARGETS = {
14779
- soft: { toneOnPage: 3.2, fgOnTone: 4.5, textOnPage: 4.5 },
14780
- standard: { toneOnPage: 4, fgOnTone: 4.5, textOnPage: 4.5 },
15205
+ soft: { toneOnPage: 1.2, fgOnTone: 4.5, textOnPage: 4.5 },
15206
+ standard: { toneOnPage: 1.6, fgOnTone: 4.5, textOnPage: 4.5 },
14781
15207
  strong: { toneOnPage: 5.5, fgOnTone: 7, textOnPage: 7 }
14782
15208
  };
14783
15209
  var DARK_CONTRAST_TARGETS = {
14784
- soft: { toneOnPage: 3, fgOnTone: 4.5, textOnPage: 4.5 },
14785
- standard: { toneOnPage: 3.6, fgOnTone: 4.5, textOnPage: 4.5 },
15210
+ soft: { toneOnPage: 2.8, fgOnTone: 4.5, textOnPage: 4.5 },
15211
+ standard: { toneOnPage: 3, fgOnTone: 4.5, textOnPage: 4.5 },
14786
15212
  strong: { toneOnPage: 5, fgOnTone: 7, textOnPage: 7 }
14787
15213
  };
14788
15214
  var SOFT_LIGHTNESS_BAND = [0.7, 0.86];
@@ -14984,6 +15410,14 @@ function applySeparationGuard(anchors, brandHue, brandLightness, toneLightness,
14984
15410
  // core/client/theme/tone-solver.ts
14985
15411
  var MAX_SOLVE_ITER = 16;
14986
15412
  var STEP = 0.04;
15413
+ function pushLightnessUntil(color, satisfied, direction, maxIter = MAX_SOLVE_ITER) {
15414
+ let current = color;
15415
+ const delta = direction === "lighten" ? STEP : -STEP;
15416
+ for (let i = 0; i < maxIter && !satisfied(current); i += 1) {
15417
+ current = { ...current, l: current.l + delta };
15418
+ }
15419
+ return current;
15420
+ }
14987
15421
  function ensureContrast(bg, deps, minRatio = 4.5, maxIter = MAX_SOLVE_ITER, forceDirection) {
14988
15422
  let current = bg;
14989
15423
  let fg = deps.bestFg(current);
@@ -14995,6 +15429,21 @@ function ensureContrast(bg, deps, minRatio = 4.5, maxIter = MAX_SOLVE_ITER, forc
14995
15429
  }
14996
15430
  return { bg: current, fg };
14997
15431
  }
15432
+ function solveTone(seed, pageHex, target, band, deps) {
15433
+ const meets = (candidate) => deps.contrastRatio(deps.oklchToHex(candidate), pageHex) >= target.toneOnPage;
15434
+ let start = seed;
15435
+ let bandBroken = false;
15436
+ if (band) {
15437
+ start = { ...seed, l: Math.min(band[1], Math.max(band[0], seed.l)) };
15438
+ }
15439
+ const pageL = deps.hexToOklch(pageHex).l;
15440
+ const direction = start.l > pageL ? "lighten" : "darken";
15441
+ const solved = pushLightnessUntil(start, meets, direction);
15442
+ if (band && (solved.l < band[0] - 1e-6 || solved.l > band[1] + 1e-6)) {
15443
+ bandBroken = true;
15444
+ }
15445
+ return { tone: solved, bandBroken };
15446
+ }
14998
15447
 
14999
15448
  // core/client/theme/scene-tokens.ts
15000
15449
  var SIGNAL_IDLE = {
@@ -15021,6 +15470,17 @@ function sceneStructureTokens(axes) {
15021
15470
  ...signal
15022
15471
  };
15023
15472
  }
15473
+ function glassTokens(dark) {
15474
+ return dark ? {
15475
+ "--soma-surface-glass": "rgba(255, 255, 255, 0.06)",
15476
+ "--soma-surface-glass-strong": "rgba(255, 255, 255, 0.1)",
15477
+ "--soma-surface-glass-weak": "rgba(255, 255, 255, 0.04)"
15478
+ } : {
15479
+ "--soma-surface-glass": "rgba(255, 255, 255, 0.72)",
15480
+ "--soma-surface-glass-strong": "rgba(255, 255, 255, 0.88)",
15481
+ "--soma-surface-glass-weak": "rgba(255, 255, 255, 0.52)"
15482
+ };
15483
+ }
15024
15484
  function sceneColorTokens(finalVars, axes, alphas, hexWithAlpha2, scale, rescale) {
15025
15485
  const out = {};
15026
15486
  if (!alphas) {
@@ -15289,7 +15749,7 @@ function chartSeries(hue, chroma, lightness, anchors) {
15289
15749
  return vars;
15290
15750
  }
15291
15751
  var STATIC_TOKENS = {
15292
- // 字体排印:系统栈 + 八档字号 + AntD 标准行高 + 三档字重
15752
+ // 字体排印:系统栈 + 八档字号 + AntD 标准行高 + 四档字重
15293
15753
  "--soma-font-family": "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif",
15294
15754
  "--soma-font-size-xs": "0.75rem",
15295
15755
  // 12px
@@ -15322,6 +15782,13 @@ var STATIC_TOKENS = {
15322
15782
  "--soma-font-weight-normal": "400",
15323
15783
  "--soma-font-weight-medium": "500",
15324
15784
  "--soma-font-weight-bold": "600",
15785
+ // 展示档(2026-09-12 补):把字形当**图形**用的位置——头像/角标的首字母牌、
15786
+ // 序号与勾选标记、KPI 大数字、倒计时格、hero 标题、金额主数字。
15787
+ // 它不是文本层次的第四级(层次到 bold 就封顶,见排版册"层次三维"),
15788
+ // 所以不参与"页题→脚注"六级;单列一档是因为这些位置此前各写各的裸值
15789
+ // (650/700/750/800 混用,同一个 `__eyebrow` 在三个卡片工厂里是三个数),
15790
+ // 没有令牌可引就只能硬编码,换肤对它们永远无效。
15791
+ "--soma-font-weight-heavy": "800",
15325
15792
  // 间距:4px 基准;0 贴合,9=48px,10=56px(文档 space.0~16,未一次铺满)
15326
15793
  "--soma-space-0": "0rem",
15327
15794
  "--soma-space-1": "0.25rem",
@@ -15392,6 +15859,7 @@ var STEPS = ["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"
15392
15859
  var LIGHTNESS = [0.985, 0.955, 0.91, 0.85, 0.78, 0.7, 0.62, 0.54, 0.46, 0.38, 0.3];
15393
15860
  var CHROMA_CURVE = [0.14, 0.28, 0.48, 0.68, 0.85, 1, 1, 0.92, 0.8, 0.66, 0.52];
15394
15861
  var SOLVER_DEPS = { oklchToHex, hexToOklch, contrastRatio, bestFg };
15862
+ var AWAY_FROM_LIGHT_PAGE = "darken";
15395
15863
  function deriveTheme(input) {
15396
15864
  const brand = hexToOklch(input.brand);
15397
15865
  const { axes, params } = resolveAxes(input);
@@ -15404,6 +15872,8 @@ function deriveTheme(input) {
15404
15872
  const grayHue = input.mode === "warm" ? 60 : input.mode === "cool" ? 250 : brand.h;
15405
15873
  const grayChroma = input.mode === "neutral" || !input.mode ? 8e-3 : 0.014;
15406
15874
  const gray = (l) => oklchToHex({ l, c: grayChroma, h: grayHue });
15875
+ const bgPage = gray(0.965);
15876
+ const darkBgPage = gray(0.18);
15407
15877
  const primaryIdx = Math.max(4, Math.min(7, brandSlot));
15408
15878
  const primary = scale[STEPS[primaryIdx]];
15409
15879
  const hover = oklchToHex({ ...hexToOklch(primary), l: hexToOklch(primary).l - 0.06 });
@@ -15417,12 +15887,45 @@ function deriveTheme(input) {
15417
15887
  const band = params.softLightnessBand;
15418
15888
  return band ? Math.min(band[1], Math.max(band[0], l)) : l;
15419
15889
  };
15890
+ const bandBroken = /* @__PURE__ */ new Set();
15891
+ const solveOnPage = (record, seed, pageHex, target, band) => {
15892
+ const solved = solveTone(seed, pageHex, target, band, SOLVER_DEPS);
15893
+ if (record && solved.bandBroken) bandBroken.add(record);
15894
+ return {
15895
+ tone: solved.tone,
15896
+ hex: oklchToHex(solved.tone),
15897
+ pushed: Math.abs(solved.tone.l - seed.l) > 1e-9
15898
+ };
15899
+ };
15900
+ const dirAfter = (solved, away) => solved.pushed ? away : void 0;
15420
15901
  const solveSemantics = (hues) => {
15421
- const dangerHex = oklchToHex({ l: banded(0.6), c: toneChroma(0.95), h: hues.danger });
15902
+ const band = params.softLightnessBand;
15903
+ const seed = (l, mul, h) => solveOnPage(
15904
+ null,
15905
+ { l: banded(l), c: toneChroma(mul), h },
15906
+ bgPage,
15907
+ params.targets,
15908
+ band
15909
+ );
15910
+ const danger2 = seed(0.6, 0.95, hues.danger);
15911
+ const success2 = seed(0.58, 0.85, hues.success);
15912
+ const warning2 = seed(0.72, 0.9, hues.warning);
15422
15913
  return {
15423
- danger: { bg: dangerHex, fg: "#ffffff", l: banded(0.6) },
15424
- success: ensureContrast(oklchToHex({ l: banded(0.58), c: toneChroma(0.85), h: hues.success }), SOLVER_DEPS),
15425
- warning: ensureContrast(oklchToHex({ l: banded(0.72), c: toneChroma(0.9), h: hues.warning }), SOLVER_DEPS)
15914
+ danger: { bg: danger2.hex, fg: "#ffffff", l: danger2.tone.l },
15915
+ success: ensureContrast(
15916
+ success2.hex,
15917
+ SOLVER_DEPS,
15918
+ params.targets.fgOnTone,
15919
+ void 0,
15920
+ dirAfter(success2, AWAY_FROM_LIGHT_PAGE)
15921
+ ),
15922
+ warning: ensureContrast(
15923
+ warning2.hex,
15924
+ SOLVER_DEPS,
15925
+ params.targets.fgOnTone,
15926
+ void 0,
15927
+ dirAfter(warning2, AWAY_FROM_LIGHT_PAGE)
15928
+ )
15426
15929
  };
15427
15930
  };
15428
15931
  const firstPass = solveSemantics(anchors0.tones);
@@ -15458,40 +15961,110 @@ function deriveTheme(input) {
15458
15961
  const clamped = need.direction > 0 ? Math.max(current.l, floor) : Math.min(current.l, floor);
15459
15962
  return Math.abs(clamped - current.l) < 1e-6 ? hex : oklchToHex({ ...current, l: clamped });
15460
15963
  };
15461
- const solveDir = (tone) => {
15964
+ const solveDir = (tone, solved) => {
15462
15965
  const need = guard.lightnessSeparation[tone];
15463
- return need ? need.direction > 0 ? "lighten" : "darken" : void 0;
15966
+ if (need) return need.direction > 0 ? "lighten" : "darken";
15967
+ return dirAfter(solved, AWAY_FROM_LIGHT_PAGE);
15464
15968
  };
15465
- const dangerSeed = oklchToHex({ l: separatedL("danger", banded(0.6)), c: toneChroma(0.95), h: anchors.tones.danger });
15466
- const danger = clampSeparatedHex("danger", dangerSeed);
15467
- const success = oklchToHex({ l: separatedL("success", banded(0.58)), c: toneChroma(0.85), h: anchors.tones.success });
15468
- const warning = oklchToHex({ l: separatedL("warning", banded(0.72)), c: toneChroma(0.9), h: anchors.tones.warning });
15969
+ const bandFor = (tone) => guard.lightnessSeparation[tone] ? null : params.softLightnessBand;
15970
+ const dangerSolved = solveOnPage(
15971
+ "danger",
15972
+ { l: separatedL("danger", banded(0.6)), c: toneChroma(0.95), h: anchors.tones.danger },
15973
+ bgPage,
15974
+ params.targets,
15975
+ bandFor("danger")
15976
+ );
15977
+ const danger = clampSeparatedHex("danger", dangerSolved.hex);
15978
+ const successSolved = solveOnPage(
15979
+ "success",
15980
+ { l: separatedL("success", banded(0.58)), c: toneChroma(0.85), h: anchors.tones.success },
15981
+ bgPage,
15982
+ params.targets,
15983
+ bandFor("success")
15984
+ );
15985
+ const success = successSolved.hex;
15986
+ const warningSolved = solveOnPage(
15987
+ "warning",
15988
+ { l: separatedL("warning", banded(0.72)), c: toneChroma(0.9), h: anchors.tones.warning },
15989
+ bgPage,
15990
+ params.targets,
15991
+ bandFor("warning")
15992
+ );
15993
+ const warning = warningSolved.hex;
15469
15994
  void firstPass;
15995
+ const infoOnPage = solveOnPage(
15996
+ "info",
15997
+ { l: banded(0.6), c: toneChroma(0.9), h: anchors.tones.info },
15998
+ bgPage,
15999
+ params.targets,
16000
+ params.softLightnessBand
16001
+ );
15470
16002
  const infoSolved = ensureContrast(
15471
- oklchToHex({ l: banded(0.6), c: toneChroma(0.9), h: anchors.tones.info }),
15472
- SOLVER_DEPS
16003
+ infoOnPage.hex,
16004
+ SOLVER_DEPS,
16005
+ params.targets.fgOnTone,
16006
+ void 0,
16007
+ dirAfter(infoOnPage, AWAY_FROM_LIGHT_PAGE)
15473
16008
  );
15474
16009
  const info = infoSolved.bg;
15475
16010
  const infoFg = infoSolved.fg;
15476
- const ensureBrandTone = (seed) => {
15477
- const solved = ensureContrast(oklchToHex(seed), SOLVER_DEPS);
16011
+ const ensureBrandTone = (seedHex, forceDirection) => {
16012
+ const solved = ensureContrast(
16013
+ seedHex,
16014
+ SOLVER_DEPS,
16015
+ params.targets.fgOnTone,
16016
+ void 0,
16017
+ forceDirection
16018
+ );
15478
16019
  return { bg: solved.bg, fg: solved.fg, soft: hexWithAlpha(solved.bg, 0.12) };
15479
16020
  };
15480
- const secondaryTone = ensureBrandTone({
15481
- l: banded(Math.min(0.72, Math.max(0.45, brand.l + 0.04))),
16021
+ const secondarySeed = {
16022
+ l: Math.min(0.72, Math.max(0.45, brand.l + 0.04)),
15482
16023
  c: Math.max(brand.c, 0.1) * 0.9 * params.chromaMul,
15483
16024
  h: anchors.tones.secondary
15484
- });
15485
- const accentTone = ensureBrandTone({
15486
- l: banded(Math.min(0.78, Math.max(0.48, brand.l + 0.08))),
16025
+ };
16026
+ const accentSeed = {
16027
+ l: Math.min(0.78, Math.max(0.48, brand.l + 0.08)),
15487
16028
  c: Math.max(brand.c, 0.1) * 0.85 * params.chromaMul,
15488
16029
  h: anchors.tones.accent
15489
- });
15490
- const neutralTone = ensureBrandTone({
16030
+ };
16031
+ const secondaryOnPage = solveOnPage(
16032
+ "secondary",
16033
+ { ...secondarySeed, l: banded(secondarySeed.l) },
16034
+ bgPage,
16035
+ params.targets,
16036
+ params.softLightnessBand
16037
+ );
16038
+ const secondaryTone = ensureBrandTone(
16039
+ secondaryOnPage.hex,
16040
+ dirAfter(secondaryOnPage, AWAY_FROM_LIGHT_PAGE)
16041
+ );
16042
+ const accentOnPage = solveOnPage(
16043
+ "accent",
16044
+ { ...accentSeed, l: banded(accentSeed.l) },
16045
+ bgPage,
16046
+ params.targets,
16047
+ params.softLightnessBand
16048
+ );
16049
+ const accentTone = ensureBrandTone(
16050
+ accentOnPage.hex,
16051
+ dirAfter(accentOnPage, AWAY_FROM_LIGHT_PAGE)
16052
+ );
16053
+ const secondaryDarkBase = ensureContrast(
16054
+ oklchToHex(secondarySeed),
16055
+ SOLVER_DEPS,
16056
+ params.targets.fgOnTone
16057
+ ).bg;
16058
+ const accentDarkBase = ensureContrast(
16059
+ oklchToHex(accentSeed),
16060
+ SOLVER_DEPS,
16061
+ params.targets.fgOnTone
16062
+ ).bg;
16063
+ const neutralTone = ensureBrandTone(oklchToHex({
15491
16064
  l: 0.18,
15492
16065
  c: grayChroma * 1.4,
15493
16066
  h: grayHue
15494
- });
16067
+ }));
15495
16068
  const clampSeparated = (tone, solved) => {
15496
16069
  const need = guard.lightnessSeparation[tone];
15497
16070
  if (!need) return solved;
@@ -15504,13 +16077,12 @@ function deriveTheme(input) {
15504
16077
  };
15505
16078
  const successFg = clampSeparated(
15506
16079
  "success",
15507
- ensureContrast(success, SOLVER_DEPS, params.targets.fgOnTone, void 0, solveDir("success"))
16080
+ ensureContrast(success, SOLVER_DEPS, params.targets.fgOnTone, void 0, solveDir("success", successSolved))
15508
16081
  );
15509
16082
  const warningFg = clampSeparated(
15510
16083
  "warning",
15511
- ensureContrast(warning, SOLVER_DEPS, params.targets.fgOnTone, void 0, solveDir("warning"))
16084
+ ensureContrast(warning, SOLVER_DEPS, params.targets.fgOnTone, void 0, solveDir("warning", warningSolved))
15512
16085
  );
15513
- const bgPage = gray(0.965);
15514
16086
  let textPrimary = gray(0.25);
15515
16087
  for (let i = 0; i < 16 && contrastRatio(bgPage, textPrimary) < params.targets.textOnPage; i++) {
15516
16088
  const cur = hexToOklch(textPrimary);
@@ -15519,10 +16091,8 @@ function deriveTheme(input) {
15519
16091
  const glassShadow = hexWithAlpha(scale["500"], 0.14);
15520
16092
  const glassShadowSoft = hexWithAlpha(scale["500"], 0.09);
15521
16093
  const cssVars = {
15522
- // 玻璃材质:面/强面/高光边/彩色投影
15523
- "--soma-surface-glass": "rgba(255, 255, 255, 0.72)",
15524
- "--soma-surface-glass-strong": "rgba(255, 255, 255, 0.88)",
15525
- "--soma-surface-glass-weak": "rgba(255, 255, 255, 0.52)",
16094
+ // 玻璃材质:面/强面/高光边/彩色投影。玻璃三档的值只住在 scene-tokens 的 glassTokens 一处
16095
+ ...glassTokens(false),
15526
16096
  "--soma-edge-highlight": "rgba(255, 255, 255, 0.72)",
15527
16097
  "--soma-shadow-tinted": `0 24px 70px ${glassShadow}`,
15528
16098
  "--soma-shadow-tinted-soft": `0 16px 36px ${glassShadowSoft}`,
@@ -15608,21 +16178,21 @@ function deriveTheme(input) {
15608
16178
  }
15609
16179
  const darkHover = oklchToHex({ ...hexToOklch(darkPrimary), l: hexToOklch(darkPrimary).l + 0.05 });
15610
16180
  const darkToneHues = axes.palette.harmony === "functional" && axes.palette.semantics === "faithful" && axes.palette.chroma === "balanced" && axes.palette.accents.length === 0 ? FUNCTIONAL_HUES : anchors.tones;
15611
- const darkDanger = oklchToHex({
16181
+ const darkDanger = solveOnPage("danger", {
15612
16182
  l: 0.68,
15613
16183
  c: Math.max(brand.c, 0.12) * 0.9 * params.chromaMul,
15614
16184
  h: darkToneHues.danger
15615
- });
15616
- const darkSuccess = oklchToHex({
16185
+ }, darkBgPage, params.darkTargets, null).hex;
16186
+ const darkSuccess = solveOnPage("success", {
15617
16187
  l: 0.66,
15618
16188
  c: Math.max(brand.c, 0.12) * 0.8 * params.chromaMul,
15619
16189
  h: darkToneHues.success
15620
- });
15621
- const darkWarning = oklchToHex({
16190
+ }, darkBgPage, params.darkTargets, null).hex;
16191
+ const darkWarning = solveOnPage("warning", {
15622
16192
  l: 0.76,
15623
16193
  c: Math.max(brand.c, 0.12) * 0.85 * params.chromaMul,
15624
16194
  h: darkToneHues.warning
15625
- });
16195
+ }, darkBgPage, params.darkTargets, null).hex;
15626
16196
  const darkSuccessEnsured = (() => {
15627
16197
  let bg = darkSuccess;
15628
16198
  let fg2 = bestFg(bg);
@@ -15643,18 +16213,25 @@ function deriveTheme(input) {
15643
16213
  }
15644
16214
  return { bg, fg: fg2 };
15645
16215
  })();
15646
- let darkInfo = oklchToHex({
16216
+ let darkInfo = solveOnPage("info", {
15647
16217
  l: 0.68,
15648
16218
  c: Math.max(brand.c, 0.12) * 0.85 * params.chromaMul,
15649
16219
  h: darkToneHues.info
15650
- });
16220
+ }, darkBgPage, params.darkTargets, null).hex;
15651
16221
  let darkInfoFg = bestFg(darkInfo);
15652
16222
  for (let i = 0; i < 16 && contrastRatio(darkInfo, darkInfoFg) < params.darkTargets.fgOnTone; i++) {
15653
16223
  const cur = hexToOklch(darkInfo);
15654
16224
  darkInfo = oklchToHex({ ...cur, l: cur.l > 0.55 ? cur.l + 0.04 : cur.l - 0.04 });
15655
16225
  darkInfoFg = bestFg(darkInfo);
15656
16226
  }
15657
- const darkBgPage = gray(0.18);
16227
+ const darkSecondary = solveOnPage("secondary", {
16228
+ ...hexToOklch(secondaryDarkBase),
16229
+ l: Math.min(0.78, hexToOklch(secondaryDarkBase).l + 0.08)
16230
+ }, darkBgPage, params.darkTargets, null).hex;
16231
+ const darkAccent = solveOnPage("accent", {
16232
+ ...hexToOklch(accentDarkBase),
16233
+ l: Math.min(0.82, hexToOklch(accentDarkBase).l + 0.08)
16234
+ }, darkBgPage, params.darkTargets, null).hex;
15658
16235
  let darkTextPrimary = gray(0.92);
15659
16236
  for (let i = 0; i < 16 && contrastRatio(darkBgPage, darkTextPrimary) < params.darkTargets.textOnPage; i++) {
15660
16237
  const cur = hexToOklch(darkTextPrimary);
@@ -15667,11 +16244,11 @@ function deriveTheme(input) {
15667
16244
  "--soma-c-primary-active": oklchToHex({ ...hexToOklch(darkPrimary), l: hexToOklch(darkPrimary).l + 0.1 }),
15668
16245
  "--soma-c-primary-fg": darkFg,
15669
16246
  "--soma-c-primary-soft": hexWithAlpha(scale["400"], 0.14),
15670
- "--soma-c-secondary": oklchToHex({ ...hexToOklch(secondaryTone.bg), l: Math.min(0.78, hexToOklch(secondaryTone.bg).l + 0.08) }),
15671
- "--soma-c-secondary-fg": bestFg(oklchToHex({ ...hexToOklch(secondaryTone.bg), l: Math.min(0.78, hexToOklch(secondaryTone.bg).l + 0.08) })),
16247
+ "--soma-c-secondary": darkSecondary,
16248
+ "--soma-c-secondary-fg": bestFg(darkSecondary),
15672
16249
  "--soma-c-secondary-soft": hexWithAlpha(secondaryTone.bg, 0.18),
15673
- "--soma-c-accent": oklchToHex({ ...hexToOklch(accentTone.bg), l: Math.min(0.82, hexToOklch(accentTone.bg).l + 0.08) }),
15674
- "--soma-c-accent-fg": bestFg(oklchToHex({ ...hexToOklch(accentTone.bg), l: Math.min(0.82, hexToOklch(accentTone.bg).l + 0.08) })),
16250
+ "--soma-c-accent": darkAccent,
16251
+ "--soma-c-accent-fg": bestFg(darkAccent),
15675
16252
  "--soma-c-accent-soft": hexWithAlpha(accentTone.bg, 0.18),
15676
16253
  "--soma-c-danger": darkDanger,
15677
16254
  "--soma-c-success": darkSuccessEnsured.bg,
@@ -15698,11 +16275,9 @@ function deriveTheme(input) {
15698
16275
  "--soma-c-info-soft": hexWithAlpha(darkInfo, 0.16),
15699
16276
  // 暗色下的阴影:亮色那套 rgba(0,0,0,.06~.16) 落在深底上等于不存在,
15700
16277
  // 层级会整个塌掉。加深并加大扩散,让浮层仍然"浮"得起来
15701
- // 暗色玻璃:半透明**黑**而不是白——白玻璃落在深底上会变成一块发光的板,
15702
- // 层级反而糊掉。高光边同理减弱,只留一线。
15703
- "--soma-surface-glass": "rgba(255, 255, 255, 0.06)",
15704
- "--soma-surface-glass-strong": "rgba(255, 255, 255, 0.1)",
15705
- "--soma-surface-glass-weak": "rgba(255, 255, 255, 0.04)",
16278
+ // 暗色玻璃:仍是白,但 alpha 只有 4%~10%(亮色是 52%~88%)——高 alpha 的白玻璃
16279
+ // 落在深底上会变成一块发光的板,层级反而糊掉。高光边同理减弱,只留一线。
16280
+ ...glassTokens(true),
15706
16281
  "--soma-edge-highlight": "rgba(255, 255, 255, 0.12)",
15707
16282
  "--soma-shadow-tinted": "0 24px 70px rgba(0, 0, 0, 0.55)",
15708
16283
  "--soma-shadow-tinted-soft": "0 16px 36px rgba(0, 0, 0, 0.45)",
@@ -15778,6 +16353,8 @@ function deriveTheme(input) {
15778
16353
  axes,
15779
16354
  separationApplied: guard.applied,
15780
16355
  pushed: guard.pushed,
16356
+ // 排序保证确定性:meta 也要满足"同输入必同输出"
16357
+ bandBroken: [...bandBroken].sort(),
15781
16358
  componentTokens: Object.keys({ ...lightComponentTokens, ...darkComponentTokens }).sort()
15782
16359
  }
15783
16360
  };
@@ -15888,6 +16465,31 @@ function writeTokensBatch(el, vars) {
15888
16465
  style.cssText = `${parts.join("; ")};`;
15889
16466
  }
15890
16467
 
16468
+ // core/client/component/theme-component-tokens.ts
16469
+ function validateThemeComponentTokens(input, components) {
16470
+ const issues = [];
16471
+ for (const segment of [input.components, input.darkComponents]) {
16472
+ if (!segment) continue;
16473
+ for (const [componentName, tokens] of Object.entries(segment)) {
16474
+ const definition = Object.hasOwn(components, componentName) ? components[componentName] : void 0;
16475
+ if (!definition) {
16476
+ issues.push(`\u672A\u77E5\u7EC4\u4EF6 "${componentName}"`);
16477
+ continue;
16478
+ }
16479
+ const declared = definition.contract.tokens ?? {};
16480
+ for (const key of Object.keys(tokens ?? {})) {
16481
+ if (!(key in declared)) {
16482
+ const available = Object.keys(declared);
16483
+ issues.push(
16484
+ `"${componentName}" \u6CA1\u6709\u58F0\u660E\u53EF\u8C03\u4EE4\u724C "${key}"` + (available.length > 0 ? `\uFF08\u5B83\u58F0\u660E\u7684\u662F\uFF1A${available.join(" / ")}\uFF09` : "\uFF08\u5B83\u4E00\u4E2A\u53EF\u8C03\u4EE4\u724C\u90FD\u6CA1\u58F0\u660E\u2014\u2014\u7EC4\u4EF6\u4EE4\u724C\u662F\u7EC4\u4EF6\u81EA\u5DF1\u7684\u627F\u8BFA\uFF0C\u4E0D\u80FD\u7531\u5916\u9762\u51ED\u7A7A\u6307\u5B9A\uFF09")
16485
+ );
16486
+ }
16487
+ }
16488
+ }
16489
+ }
16490
+ return issues;
16491
+ }
16492
+
15891
16493
  // core/client/observability/error-reporter.ts
15892
16494
  function safePath() {
15893
16495
  if (typeof location === "undefined") {
@@ -15991,16 +16593,54 @@ function isSomaDeclarationSource(value) {
15991
16593
  return text === "{{";
15992
16594
  });
15993
16595
  }
15994
- function reportToConsole(event) {
15995
- console.error(`[soma-core][\u53EF\u89C2\u6D4B] ${JSON.stringify(event)}`);
15996
- }
15997
- var SomaBootstrap = class {
15998
- constructor(options = {}) {
15999
- this.runtimeBuilder = new SomaRuntimeBuilder();
16000
- this.snapshotStore = new SomaSnapshotStore();
16001
- this.routerUnsubscribe = null;
16002
- this.renderEngine = null;
16003
- this.eventEngine = null;
16596
+ var SOMA_OOUI_REGION_ATTR = "data-soma-ooui";
16597
+ var SOMA_OOUI_ALLOWED_TAGS = /* @__PURE__ */ new Set(["DIV", "SPAN"]);
16598
+ var SOMA_OOUI_ALLOWED_ATTRS = /* @__PURE__ */ new Set([
16599
+ "class",
16600
+ "data-soma-node",
16601
+ "data-soma-id",
16602
+ "data-soma-component"
16603
+ ]);
16604
+ function findOouiDomOffence(fragment) {
16605
+ const roots = fragment.children;
16606
+ if (roots.length !== 1) {
16607
+ return `\u9876\u5C42\u5143\u7D20\u6709 ${roots.length} \u4E2A\uFF0C\u4EA7\u7269\u6052\u4E3A\u5355\u4E2A\u533A\u57DF\u5916\u58F3`;
16608
+ }
16609
+ for (const node of Array.from(fragment.childNodes)) {
16610
+ if (node.nodeType !== 1 && (node.textContent ?? "").trim() !== "") {
16611
+ return `\u9876\u5C42\u6DF7\u6709\u5143\u7D20\u4EE5\u5916\u7684\u8282\u70B9\uFF08nodeType ${node.nodeType}\uFF09`;
16612
+ }
16613
+ }
16614
+ for (const element of Array.from(fragment.querySelectorAll("*"))) {
16615
+ if (!SOMA_OOUI_ALLOWED_TAGS.has(element.tagName)) {
16616
+ return `\u6807\u7B7E <${element.tagName.toLowerCase()}>`;
16617
+ }
16618
+ for (const attribute of Array.from(element.attributes)) {
16619
+ if (!SOMA_OOUI_ALLOWED_ATTRS.has(attribute.name)) {
16620
+ return `\u5C5E\u6027 ${attribute.name}`;
16621
+ }
16622
+ }
16623
+ }
16624
+ return null;
16625
+ }
16626
+ function oouiHtmlFingerprint(html) {
16627
+ let hash = 2166136261;
16628
+ for (let index = 0; index < html.length; index += 1) {
16629
+ hash ^= html.charCodeAt(index);
16630
+ hash = Math.imul(hash, 16777619);
16631
+ }
16632
+ return (hash >>> 0).toString(16).padStart(8, "0");
16633
+ }
16634
+ function reportToConsole(event) {
16635
+ console.error(`[soma-core][\u53EF\u89C2\u6D4B] ${JSON.stringify(event)}`);
16636
+ }
16637
+ var SomaBootstrap = class {
16638
+ constructor(options = {}) {
16639
+ this.runtimeBuilder = new SomaRuntimeBuilder();
16640
+ this.snapshotStore = new SomaSnapshotStore();
16641
+ this.routerUnsubscribe = null;
16642
+ this.renderEngine = null;
16643
+ this.eventEngine = null;
16004
16644
  this.styleBinder = null;
16005
16645
  this.propertyWatcher = null;
16006
16646
  this.onChangeEngine = null;
@@ -16062,6 +16702,7 @@ var SomaBootstrap = class {
16062
16702
  this.assets = { ...assets };
16063
16703
  const parsed = this.assetResolver.resolve(this.assets);
16064
16704
  this.adapter.mount(container, this.assets.html, this.assets.includes);
16705
+ this.installOouiHtml(container, parsed.uiConfig);
16065
16706
  this.setupComponentManager(container, this.assets, parsed.uiConfig);
16066
16707
  this.applyHostTheme(parsed.appConfig);
16067
16708
  this.domainInstance = this.createDomainInstance(assets.DomainClass, parsed, assets.routerPath);
@@ -16107,6 +16748,7 @@ var SomaBootstrap = class {
16107
16748
  this.componentManager?.destroy();
16108
16749
  this.componentManager = null;
16109
16750
  this.adapter.mount(this.container, merged.html, merged.includes);
16751
+ this.installOouiHtml(this.container, parsed.uiConfig);
16110
16752
  this.setupComponentManager(this.container, merged, parsed.uiConfig);
16111
16753
  if (overrides.DomainClass) {
16112
16754
  this.proxy?.dispose();
@@ -16383,6 +17025,7 @@ var SomaBootstrap = class {
16383
17025
  if (!theme?.brand) {
16384
17026
  return;
16385
17027
  }
17028
+ this.reconcileThemeComponentTokens(theme);
16386
17029
  try {
16387
17030
  applyTheme(theme);
16388
17031
  } catch (error) {
@@ -16390,6 +17033,37 @@ var SomaBootstrap = class {
16390
17033
  this.captureEngineError(error);
16391
17034
  }
16392
17035
  }
17036
+ /**
17037
+ * 组件令牌对账(REQ-009 M-1):`components: { Buton: { radius: … } }` 这样一个
17038
+ * 拼写错误,不对账时的表现是**"改了没反应"**——变量确实写进了 :root,
17039
+ * 只是没有任何组件读它。这类错误的排查成本远高于报错。
17040
+ *
17041
+ * 判据住在 `component/theme-component-tokens.ts`,而它此前**一个调用者都没有**
17042
+ * (由 `verify:reachable` 查出)。这里是全仓唯一同时持有「主题输入」与
17043
+ * 「这一页实际可用的组件表」的地方,所以对账只能发生在这一点上。
17044
+ *
17045
+ * 两条边界:
17046
+ * · **只告警、不阻断换装**。主题是 app 级、全部页面共享的,组件表却是逐页的;
17047
+ * 曾经对账与 applyTheme 同在一个 try 里,一条对不上就把整份品牌主题一起丢掉
17048
+ * (全页回落默认令牌 + 一条"主题派生失败"),与"一个令牌没人读"的后果不成比例。
17049
+ * · **组件表 = Host 级 + 页面级**,与 setupComponentManager 实际装配的那张表同一口径
17050
+ * (页面同名胜出)。只看 Host 级的话,只在页面资产里注册的组件会被误报成未知组件。
17051
+ * 拿不到组件表时(纯预览场景)按设计跳过,不猜。
17052
+ */
17053
+ reconcileThemeComponentTokens(theme) {
17054
+ const components = { ...this.hostComponents, ...this.assets?.components ?? {} };
17055
+ if (Object.keys(components).length === 0) {
17056
+ return;
17057
+ }
17058
+ const issues = validateThemeComponentTokens(theme, components);
17059
+ if (issues.length === 0) {
17060
+ return;
17061
+ }
17062
+ const message = `\u4E3B\u9898\u7684\u7EC4\u4EF6\u4EE4\u724C\u6BB5\u6709 ${issues.length} \u5904\u5BF9\u4E0D\u4E0A\u7EC4\u4EF6\u5951\u7EA6\uFF08\u4E3B\u9898\u7167\u5E38\u751F\u6548\uFF1B\u8FD9\u4E9B\u4EE4\u724C\u4F1A\u5199\u8FDB :root\uFF0C\u4F46\u5F53\u524D\u9875\u6CA1\u6709\u7EC4\u4EF6\u8BFB\u5B83\u4EEC\uFF09\uFF1A
17063
+ ${issues.map((issue) => ` \xB7 ${issue}`).join("\n")}`;
17064
+ console.warn(`[soma-core][\u4E3B\u9898] ${message}`);
17065
+ this.diagnostics.recordValidation("warning", `[\u4E3B\u9898\u7EC4\u4EF6\u4EE4\u724C] ${message}`);
17066
+ }
16393
17067
  /**
16394
17068
  * 组件可见的服务表:页面运行时服务 + data 端口(M-5)。
16395
17069
  *
@@ -16402,17 +17076,6 @@ var SomaBootstrap = class {
16402
17076
  if (!base) return void 0;
16403
17077
  return { ...base, data: this.createStableDataPort() };
16404
17078
  }
16405
- /**
16406
- * 页面态装配(REQ-010 F-37)。
16407
- *
16408
- * 三个来源按优先级取:**URL > initial_state > 空**。
16409
- * URL 在最前是因为它是"用户此刻明确要求看到的那一屏"(分享链接、书签、回退按钮),
16410
- * 而 `initial_state` 只是作者写的缺省。反过来的话,分享链接打开后会被缺省覆盖,
16411
- * 而那正是分享链接唯一的用途。
16412
- *
16413
- * 版本对不上的 URL 状态整份丢弃并 warn 一次:恢复一份旧结构的状态会让界面进入
16414
- * 一个谁都没设计过的样子,而那种坏法是静默的(列还在、但顺序是乱的)。
16415
- */
16416
17079
  /**
16417
17080
  * 约束布局产物注入(REQ-011 接线 / CL-4)。
16418
17081
  *
@@ -16436,6 +17099,120 @@ var SomaBootstrap = class {
16436
17099
  );
16437
17100
  }
16438
17101
  }
17102
+ /**
17103
+ * OOUI 演绎产物的 DOM 落点(REQ-014 最后一公里)。
17104
+ *
17105
+ * ── 为什么"没有这一步"是一种静默失败 ─────────────────────────────
17106
+ * 在它之前,整条演绎链止于 `deduce()` 的返回值:六层全绿、`ooui_artifact`
17107
+ * 在资产里、样式表也注入了,**页面上什么都没有**。而"锚点空着"与
17108
+ * "这块本来就没写内容"在浏览器里长得一模一样——没有异常、没有日志、
17109
+ * 截图里也分不开。这是最像成功的那种失败,所以落点必须有断言守着。
17110
+ *
17111
+ * ── 运行时收到产物就用,收到声明就拒绝代算 ───────────────────────
17112
+ * 与 `installLayoutCss` / `installOouiArtifact` 同一条范式:本方法**只搬运**。
17113
+ * 它不认识形态、不认识候选表、不认识组件契约——那些词汇住在 soma-ui,
17114
+ * 浏览器手里根本没有,代算出来的只会是一份猜的界面。
17115
+ *
17116
+ * ── 为什么"引擎生成的"不等于"可信的"(架构 §24.1)───────────────
17117
+ * 这串 html 随 `_ui.yaml` 走。发布期的注入面静态扫描(`declaration-safety-scan.ts`)
17118
+ * 如今对 YAML 面也跑 html 那四条判据(禁用标签 / on\* 处理器 / srcdoc / 伪协议),
17119
+ * 门口已经拦得住一份被改过的 `_ui.yaml`。但门口只守 Registry 这一条写路径:
17120
+ * 文件态 Host 的资产、预览器直接喂进来的资产都不经过它;而 innerHTML 插入的
17121
+ * `<script>` 虽然不执行,`<img onerror=…>` 却会立刻执行。所以注入前必须再核一道——
17122
+ * 这是纵深防御的最后一层,不因门口补齐而省掉。
17123
+ *
17124
+ * 核的方式是**允许集**不是禁用集:`emitRegionHtml` 今天只产出
17125
+ * `div` / `span` 两种标签与四个 `class` / `data-soma-*` 属性,
17126
+ * 把这个全集写死,任何多出来的东西一律拒收。禁用集在这种两标签的产物上
17127
+ * 严格更差——它只挡得住今天想得到的那几样。发射器哪天真加了新标签,
17128
+ * 这里会**当场红**(而不是静默放行),红在写下的那天,这正是要的。
17129
+ *
17130
+ * 解析走 `<template>`:template 的内容是**惰性的**——不加载图片、不跑脚本,
17131
+ * 所以"先解析再检查"这个顺序本身不会触发任何东西。检查通过之后才搬进文档。
17132
+ */
17133
+ installOouiHtml(container, uiConfig) {
17134
+ const artifact = uiConfig.oouiArtifact;
17135
+ if (!artifact || artifact.regions.length === 0) return;
17136
+ const doc = container.ownerDocument ?? globalThis.document ?? null;
17137
+ if (!doc || typeof doc.createElement !== "function") {
17138
+ console.warn(
17139
+ `[soma-core][\u6F14\u7ECE] \u9875\u9762 "${uiConfig.bind.obj}" \u6709 ${artifact.regions.length} \u4E2A\u6F14\u7ECE\u533A\u57DF\uFF0C\u4F46\u5F53\u524D\u5BB9\u5668\u6CA1\u6709 document\uFF0C\u6F14\u7ECE DOM \u65E0\u6CD5\u843D\u5730\u2014\u2014\u6F14\u7ECE\u4EA7\u7269\u4ECA\u5929\u53EA\u652F\u6301 Web \u5BB9\u5668\uFF08DOM \u7531 <template> \u60F0\u6027\u89E3\u6790\u540E\u642C\u5165\uFF09\u3002`
17140
+ );
17141
+ return;
17142
+ }
17143
+ for (const region of artifact.regions) {
17144
+ const host = this.adapter.findAnchor(container, region.anchor);
17145
+ if (!host) {
17146
+ console.warn(
17147
+ `[soma-core][\u6F14\u7ECE] \u6F14\u7ECE\u533A\u57DF "${region.anchor}" \u5728\u9875\u9762 HTML \u91CC\u627E\u4E0D\u5230\u951A\u70B9\uFF08data-soma-id\uFF09\u2014\u2014html \u4E0E _ui.yaml \u4E0D\u662F\u540C\u4E00\u6B21\u7F16\u8BD1\u7684\u4EA7\u7269\u3002\u8FD9\u4E00\u5757\u4E0D\u4F1A\u6709\u4EFB\u4F55\u5185\u5BB9\u3002`
17148
+ );
17149
+ continue;
17150
+ }
17151
+ const html = typeof region.html === "string" ? region.html : "";
17152
+ if (html.trim() === "") {
17153
+ console.warn(
17154
+ `[soma-core][\u6F14\u7ECE] \u6F14\u7ECE\u533A\u57DF "${region.anchor}" \u7684\u4EA7\u7269\u91CC\u6CA1\u6709 html\u2014\u2014\u8FD9\u662F\u4E00\u4EFD\u65E7\u683C\u5F0F\uFF08\u6216\u624B\u5199\uFF09\u7684 ooui_artifact\u3002\u91CD\u65B0\u8DD1\u4E00\u6B21\u6784\u5EFA\u671F\u7F16\u8BD1\uFF08compilePageDeclaration\uFF09\u5373\u53EF\uFF0C\u8FD0\u884C\u65F6\u4E0D\u4EE3\u4E3A\u6F14\u7ECE\u3002`
17155
+ );
17156
+ continue;
17157
+ }
17158
+ const fingerprint = oouiHtmlFingerprint(html);
17159
+ if (host.getAttribute(SOMA_OOUI_REGION_ATTR) === fingerprint) continue;
17160
+ const template = doc.createElement("template");
17161
+ template.innerHTML = html;
17162
+ const offence = findOouiDomOffence(template.content);
17163
+ if (offence !== null) {
17164
+ console.error(
17165
+ `[soma-core][\u6F14\u7ECE] \u6F14\u7ECE\u533A\u57DF "${region.anchor}" \u7684\u4EA7\u7269 DOM \u4E0D\u5728\u5141\u8BB8\u96C6\u5185\uFF08${offence}\uFF09\uFF0C\u5DF2\u62D2\u7EDD\u6CE8\u5165\u3002\u4EA7\u7269\u968F _ui.yaml \u8D70\uFF0C\u800C\u90A3\u4EFD\u8D44\u4EA7\u53EF\u4EE5\u88AB\u624B\u5199\u3001\u88AB\u6539\uFF1A\u53D1\u5E03\u671F\u7684\u6CE8\u5165\u9762\u626B\u63CF\u867D\u7136\u4E5F\u626B YAML \u9762\uFF0C\u4F46\u5B83\u53EA\u5B88"\u5199\u8FDB\u58F0\u660E\u4ED3\u5E93"\u8FD9\u4E2A\u5165\u53E3\uFF0C\u7ED5\u8FC7 Registry \u7684\u6784\u5EFA\u4E0E\u53D1\u5E03\u540E\u6539\u8D44\u4EA7\u90FD\u4E0D\u7ECF\u8FC7\u5B83\u3002\u6240\u4EE5\u6CE8\u5165\u524D\u8FD9\u9053\u7ED3\u6784\u95F8\u95E8\u662F\u6700\u540E\u4E00\u5173\u2014\u2014\u653E\u884C\u4E00\u6B21\u5C31\u7B49\u4E8E\u628A innerHTML \u4EA4\u4E86\u51FA\u53BB\u3002\u6B63\u5E38\u4EA7\u7269\u53EA\u542B div/span \u4E0E class/data-soma-node/data-soma-id/data-soma-component\u3002\u82E5\u8FD9\u662F\u53D1\u5C04\u5668\u65B0\u52A0\u7684\u5408\u6CD5\u5F62\u72B6\uFF0C\u8BF7\u540C\u6B65 soma-bootstrap.ts \u7684 SOMA_OOUI_ALLOWED_TAGS / _ATTRS\uFF1B\u5426\u5219\u8BF7\u91CD\u65B0\u8DD1\u4E00\u6B21 compilePageDeclaration \u751F\u6210\u4EA7\u7269\uFF0C\u4E0D\u8981\u624B\u5199 ooui_artifact\u3002`
17166
+ );
17167
+ continue;
17168
+ }
17169
+ while (host.firstChild) host.removeChild(host.firstChild);
17170
+ host.appendChild(template.content);
17171
+ host.setAttribute(SOMA_OOUI_REGION_ATTR, fingerprint);
17172
+ }
17173
+ }
17174
+ /**
17175
+ * OOUI 演绎产物注入(REQ-014 接线)。
17176
+ *
17177
+ * 与 `installLayoutCss` 逐点同构:运行时只认**产物**,收到声明本身只告警。
17178
+ * 演绎链住在 core/build/ooui/,进 client 就等于把「运行期零演绎」这条
17179
+ * 结构性承诺撤回去——而且浏览器手里根本没有候选表与组件契约,
17180
+ * 代算出来的只会是一份猜的界面。
17181
+ *
17182
+ * 注入键用产物自带的**内容哈希**(`ooui:<sha256 前 8 位>`),不用页面名:
17183
+ * `injectStyleOnce` 没有内容冲突检测(同键不同内容静默保留第一份),
17184
+ * 按页面名命名的话,SPA 内路由切到同名不同产物的页面会继续用上一页的 CSS,
17185
+ * 页面看着渲染正常、间距全错、控制台一行都没有。
17186
+ * 位置紧接 `installLayoutCss`——都在组件实例挂载**之前**,级联顺序才稳定。
17187
+ */
17188
+ installOouiArtifact(uiConfig) {
17189
+ const artifact = uiConfig.oouiArtifact;
17190
+ if (artifact?.css && artifact.css_key) {
17191
+ injectStyleOnce(
17192
+ artifact.css_key,
17193
+ artifact.css,
17194
+ { nonce: this.componentStyleNonce ?? null }
17195
+ );
17196
+ return;
17197
+ }
17198
+ if (artifact) return;
17199
+ if (uiConfig.ooui && Object.keys(uiConfig.ooui).length > 0) {
17200
+ console.warn(
17201
+ `[soma-core][\u6F14\u7ECE] \u9875\u9762 "${uiConfig.bind.obj}" \u58F0\u660E\u4E86 ooui: \u6BB5\u4F46\u6CA1\u6709\u6784\u5EFA\u671F\u4EA7\u7269\uFF08ooui_artifact\uFF09\u2014\u2014\u58F0\u660E\u672A\u7ECF compilePageDeclaration \u6F14\u7ECE\uFF0C\u672C\u9875\u4E0D\u4F1A\u4EA7\u751F\u4EFB\u4F55\u6F14\u7ECE\u754C\u9762\u3002\u6F14\u7ECE\u53EA\u5728\u6784\u5EFA\u671F\u53D1\u751F\uFF08Registry \u53D1\u5E03 / Host \u9884\u7F16\u8BD1\uFF09\uFF0C\u8FD0\u884C\u65F6\u4E0D\u4EE3\u7B97\u3002`
17202
+ );
17203
+ }
17204
+ }
17205
+ /**
17206
+ * 页面态装配(REQ-010 F-37)。
17207
+ *
17208
+ * 三个来源按优先级取:**URL > initial_state > 空**。
17209
+ * URL 在最前是因为它是"用户此刻明确要求看到的那一屏"(分享链接、书签、回退按钮),
17210
+ * 而 `initial_state` 只是作者写的缺省。反过来的话,分享链接打开后会被缺省覆盖,
17211
+ * 而那正是分享链接唯一的用途。
17212
+ *
17213
+ * 版本对不上的 URL 状态整份丢弃并 warn 一次:恢复一份旧结构的状态会让界面进入
17214
+ * 一个谁都没设计过的样子,而那种坏法是静默的(列还在、但顺序是乱的)。
17215
+ */
16439
17216
  installPageState(config) {
16440
17217
  const instance = this.domainInstance;
16441
17218
  if (!instance) return;
@@ -16523,22 +17300,12 @@ ${lines}
16523
17300
  \u5728 configureSomaBootstrap \u7684 options.actions \u91CC\u767B\u8BB0\u5B83\u4EEC\u3002\u5177\u540D\u52A8\u4F5C\u662F custom(script) \u7684\u66FF\u4EE3\uFF1A\u5B9E\u73B0\u5728 Host \u4EE3\u7801\u91CC\u3001\u6709\u540D\u5B57\u3001\u53EF\u5BA1\u8BA1\u3002`
16524
17301
  );
16525
17302
  }
16526
- /** 稳定的 data 端口壳:每次调用现取当前解析器 */
17303
+ /**
17304
+ * 稳定的 data 端口壳:每次调用现取当前解析器(解析器暂缺时的兜底住在 createSomaDataPort 里,
17305
+ * 与端口的方法面同一处——测试守的就是这里注入的那一个端口)。
17306
+ */
16527
17307
  createStableDataPort() {
16528
- const noResolver = (action) => ({
16529
- ok: false,
16530
- message: `\u6570\u636E\u5BF9\u8C61\u5C1A\u672A\u5C31\u7EEA\uFF0C\u65E0\u6CD5${action}\uFF08\u672C\u9875\u53EF\u80FD\u6CA1\u6709\u58F0\u660E *_data.yaml\uFF09`
16531
- });
16532
- return {
16533
- getObject: (name) => this.dataResolver?.getObject(name),
16534
- getDict: (name) => this.dataResolver?.getDict(name) ?? {},
16535
- getReactions: (name) => this.dataResolver?.getReactions(name) ?? null,
16536
- window: (name) => this.dataResolver?.window(name) ?? null,
16537
- submit: async (name, model, mode) => this.dataResolver ? this.dataResolver.submit(name, model, mode) : noResolver(`\u63D0\u4EA4 "${name}"`),
16538
- reload: async (names) => {
16539
- await this.dataResolver?.reload(names);
16540
- }
16541
- };
17308
+ return createSomaDataPort(() => this.dataResolver);
16542
17309
  }
16543
17310
  /** 组件管理器装配:无 components 资产时保持 null,组件能力整体旁路 */
16544
17311
  setupComponentManager(container, assets, uiConfig) {
@@ -16609,6 +17376,7 @@ ${featureIssues.map((issue) => ` \xB7 ${issue}`).join("\n")}`
16609
17376
  this.assertNamedActionsResolvable(parsed.eventConfig);
16610
17377
  this.installPageState(parsed.uiConfig.state);
16611
17378
  this.installLayoutCss(parsed.uiConfig);
17379
+ this.installOouiArtifact(parsed.uiConfig);
16612
17380
  this.styleBinder = runtime.styleBinder;
16613
17381
  this.propertyWatcher = runtime.propertyWatcher;
16614
17382
  this.onChangeEngine = runtime.onChangeEngine;
@@ -16924,8 +17692,43 @@ function parseType(raw2, line) {
16924
17692
  }
16925
17693
  return { type: text };
16926
17694
  }
17695
+ function isValueClosed(value) {
17696
+ const text = value.trim();
17697
+ const head = text[0];
17698
+ if (head === '"' || head === "'") return text.length >= 2 && text.endsWith(head);
17699
+ if (head !== "[" && head !== "{") return true;
17700
+ let depth = 0;
17701
+ let quote = null;
17702
+ for (const ch of text) {
17703
+ if (quote) {
17704
+ if (ch === quote) quote = null;
17705
+ continue;
17706
+ }
17707
+ if (ch === '"' || ch === "'") quote = ch;
17708
+ else if (ch === "[" || ch === "{") depth += 1;
17709
+ else if (ch === "]" || ch === "}") depth -= 1;
17710
+ }
17711
+ return depth <= 0 && quote === null;
17712
+ }
16927
17713
  function splitSegments(rest, line) {
16928
- const parts = rest.split(", ");
17714
+ const raw2 = rest.split(", ");
17715
+ const parts = [];
17716
+ for (let index = 0; index < raw2.length; index += 1) {
17717
+ let part = raw2[index];
17718
+ const trimmed = part.trimStart();
17719
+ if (trimmed.startsWith("\u9ED8\u8BA4 ") && !isValueClosed(trimmed.slice("\u9ED8\u8BA4 ".length))) {
17720
+ let merged = part;
17721
+ for (let next = index + 1; next < raw2.length; next += 1) {
17722
+ merged = `${merged}, ${raw2[next]}`;
17723
+ if (isValueClosed(merged.trimStart().slice("\u9ED8\u8BA4 ".length))) {
17724
+ part = merged;
17725
+ index = next;
17726
+ break;
17727
+ }
17728
+ }
17729
+ }
17730
+ parts.push(part);
17731
+ }
16929
17732
  const exampleAt = parts.findIndex((part) => part.startsWith("\u793A\u4F8B ") || part === "\u793A\u4F8B");
16930
17733
  if (exampleAt < 0) return parts.map((part) => part.trim());
16931
17734
  const head = parts.slice(0, exampleAt).map((part) => part.trim());
@@ -17043,14 +17846,27 @@ function parseSlotLines(text) {
17043
17846
  }
17044
17847
  return out;
17045
17848
  }
17046
- function renderValue(value) {
17849
+ var SCALAR_LOOKALIKE = /^(?:null|~|true|false|-?\d+(?:\.\d+)?)$/;
17850
+ var FLOW_SYNTAX = /[,[\]{}"']/;
17851
+ function quoteText(text) {
17852
+ const mark = !text.includes('"') ? '"' : !text.includes("'") ? "'" : '"';
17853
+ return `${mark}${text}${mark}`;
17854
+ }
17855
+ function renderString(text, site) {
17856
+ const needsQuote = text === "" || text !== text.trim() || SCALAR_LOOKALIKE.test(text) || /^["'[{]/.test(text) || site === "default" && text.includes(", ") || site === "flow" && FLOW_SYNTAX.test(text);
17857
+ return needsQuote ? quoteText(text) : text;
17858
+ }
17859
+ function renderFlowKey(key) {
17860
+ return key === "" || key !== key.trim() || FLOW_SYNTAX.test(key) ? quoteText(key) : key;
17861
+ }
17862
+ function renderValue(value, site) {
17047
17863
  if (value === null) return "null";
17048
- if (typeof value === "string") return value === "" ? '""' : value;
17049
- if (Array.isArray(value)) return `[${value.map(renderValue).join(", ")}]`;
17864
+ if (typeof value === "string") return renderString(value, site);
17865
+ if (Array.isArray(value)) return `[${value.map((item) => renderValue(item, "flow")).join(", ")}]`;
17050
17866
  if (typeof value === "object") {
17051
17867
  const entries = Object.entries(value);
17052
17868
  if (entries.length === 0) return "{}";
17053
- return `{ ${entries.map(([key, item]) => `${key}: ${renderValue(item)}`).join(", ")} }`;
17869
+ return `{ ${entries.map(([key, item]) => `${renderFlowKey(key)}: ${renderValue(item, "flow")}`).join(", ")} }`;
17054
17870
  }
17055
17871
  return String(value);
17056
17872
  }
@@ -17066,9 +17882,9 @@ function renderFieldNode(name, field, depth, out) {
17066
17882
  const segments = [renderTypeLabel(field)];
17067
17883
  if (field.desc) segments.push(field.desc);
17068
17884
  if (field.required === true) segments.push("\u5FC5\u586B");
17069
- else if (field.default !== void 0) segments.push(`\u9ED8\u8BA4 ${renderValue(field.default)}`);
17070
- if (field.example !== void 0) segments.push(`\u793A\u4F8B ${renderValue(field.example)}`);
17885
+ else if (field.default !== void 0) segments.push(`\u9ED8\u8BA4 ${renderValue(field.default, "default")}`);
17071
17886
  if (field.mode === "model") segments.push("\u53CC\u5411");
17887
+ if (field.example !== void 0) segments.push(`\u793A\u4F8B ${renderValue(field.example, "example")}`);
17072
17888
  out.push(`${" ".repeat(depth * INDENT_UNIT)}${name}: ${segments.join(", ")}`);
17073
17889
  const children = field.type === "array" ? field.items?.fields : field.fields;
17074
17890
  for (const [childName, child] of Object.entries(children ?? {})) {
@@ -17105,14 +17921,14 @@ function somaSlots(strings, ...values) {
17105
17921
  }
17106
17922
 
17107
17923
  // core/shared/component/derive-sample.ts
17108
- function deriveField(field, path, gaps) {
17924
+ function walkField(field, path, strategy) {
17109
17925
  if (field.example !== void 0) return clone(field.example);
17110
17926
  if (field.type === "object") {
17111
17927
  const fields = field.fields;
17112
17928
  if (fields && Object.keys(fields).length > 0) {
17113
17929
  const out = {};
17114
17930
  for (const [name, child] of Object.entries(fields)) {
17115
- const value = deriveField(child, `${path}.${name}`, gaps);
17931
+ const value = walkField(child, `${path}.${name}`, strategy);
17116
17932
  if (value !== void 0) out[name] = value;
17117
17933
  }
17118
17934
  return out;
@@ -17121,21 +17937,37 @@ function deriveField(field, path, gaps) {
17121
17937
  if (field.type === "array") {
17122
17938
  const items = field.items;
17123
17939
  if (items) {
17124
- const element = deriveField(items, `${path}[]`, gaps);
17940
+ const element = walkField(items, `${path}[]`, strategy);
17125
17941
  if (element !== void 0) return [element];
17126
17942
  }
17127
17943
  }
17128
- if (field.default !== void 0) return clone(field.default);
17944
+ if (field.default !== void 0 && strategy.useDefault(field, path)) return clone(field.default);
17129
17945
  if (field.type === "enum" && field.values && field.values.length > 0) {
17130
17946
  return field.values[0];
17131
17947
  }
17132
- if (field.required === true) {
17133
- gaps.push({
17134
- path,
17135
- reason: "\u5FC5\u586B\u5B57\u6BB5\u65E2\u6CA1\u6709 \u793A\u4F8B \u4E5F\u6CA1\u6709 \u9ED8\u8BA4\u2014\u2014\u6837\u5F20\u6E32\u67D3\u4E0D\u51FA\u8FD9\u4E00\u683C"
17136
- });
17948
+ return strategy.fallback(field, path);
17949
+ }
17950
+ function walkProps(contract, strategy) {
17951
+ const props = {};
17952
+ for (const [name, prop] of Object.entries(contract.props ?? {})) {
17953
+ const value = walkField(prop, name, strategy);
17954
+ if (value !== void 0) props[name] = value;
17137
17955
  }
17138
- return void 0;
17956
+ return props;
17957
+ }
17958
+ function sampleStrategy(gaps) {
17959
+ return {
17960
+ useDefault: () => true,
17961
+ fallback(field, path) {
17962
+ if (field.required === true) {
17963
+ gaps.push({
17964
+ path,
17965
+ reason: "\u5FC5\u586B\u5B57\u6BB5\u65E2\u6CA1\u6709 \u793A\u4F8B \u4E5F\u6CA1\u6709 \u9ED8\u8BA4\u2014\u2014\u6837\u5F20\u6E32\u67D3\u4E0D\u51FA\u8FD9\u4E00\u683C"
17966
+ });
17967
+ }
17968
+ return void 0;
17969
+ }
17970
+ };
17139
17971
  }
17140
17972
  function clone(value) {
17141
17973
  if (value === null || typeof value !== "object") return value;
@@ -17143,15 +17975,125 @@ function clone(value) {
17143
17975
  }
17144
17976
  function deriveContractSample(contract) {
17145
17977
  const gaps = [];
17146
- const props = {};
17147
- for (const [name, prop] of Object.entries(contract.props ?? {})) {
17148
- const value = deriveField(prop, name, gaps);
17149
- if (value !== void 0) props[name] = value;
17150
- }
17978
+ const props = walkProps(contract, sampleStrategy(gaps));
17151
17979
  return { props, gaps };
17152
17980
  }
17981
+ function previewFieldName(path) {
17982
+ const segments = path.replace(/\[\]/gu, "").split(".");
17983
+ return (segments[segments.length - 1] ?? "").toLocaleLowerCase();
17984
+ }
17985
+ function previewString(path) {
17986
+ const name = previewFieldName(path);
17987
+ if (/(?:^|_)(?:id|key|code|sku)(?:$|_)/u.test(name)) return "sample-item";
17988
+ if (/(?:date|day)$/u.test(name)) return "2026-01-15";
17989
+ if (/(?:time|hour)$/u.test(name)) return "09:30";
17990
+ if (/(?:email|mail)$/u.test(name)) return "demo@example.test";
17991
+ if (/(?:phone|tel|mobile)$/u.test(name)) return "138 0000 0000";
17992
+ if (/(?:url|href|link)$/u.test(name)) return "#";
17993
+ if (/(?:src|image|avatar|cover|icon)$/u.test(name)) return "";
17994
+ if (/(?:color|colour)$/u.test(name)) return "var(--soma-c-primary)";
17995
+ if (/(?:placeholder)$/u.test(name)) return "\u8BF7\u8F93\u5165\u5185\u5BB9";
17996
+ if (/(?:label|action|button|cta)$/u.test(name)) return "\u793A\u4F8B\u64CD\u4F5C";
17997
+ if (/(?:title|name|heading)$/u.test(name)) return "\u793A\u4F8B\u6807\u9898";
17998
+ if (/(?:description|summary|message|hint|help|text|content|subtitle)$/u.test(name)) {
17999
+ return "\u8FD9\u662F\u4E00\u6BB5\u6765\u81EA\u7EC4\u4EF6\u5951\u7EA6\u7684\u9884\u89C8\u5185\u5BB9";
18000
+ }
18001
+ if (/(?:status|state)$/u.test(name)) return "active";
18002
+ return "\u793A\u4F8B\u503C";
18003
+ }
18004
+ function previewNumber(path) {
18005
+ const name = previewFieldName(path);
18006
+ if (/(?:percent|ratio|rate|progress)$/u.test(name)) return 68;
18007
+ if (/(?:quantity|qty|count|index|page|step)$/u.test(name)) return 2;
18008
+ if (/(?:price|amount|total|cost|value)$/u.test(name)) return 1280;
18009
+ return 42;
18010
+ }
18011
+ function previewBoolean(path) {
18012
+ const name = previewFieldName(path);
18013
+ if (/(?:open|visible|expanded|selected|checked|active)$/u.test(name)) return true;
18014
+ return false;
18015
+ }
18016
+ function previewRecord() {
18017
+ return {
18018
+ id: "sample-item",
18019
+ key: "sample-item",
18020
+ name: "\u793A\u4F8B\u540D\u79F0",
18021
+ label: "\u793A\u4F8B\u6807\u7B7E",
18022
+ title: "\u793A\u4F8B\u6807\u9898",
18023
+ subtitle: "\u7528\u4E8E\u7EC4\u4EF6\u9884\u89C8\u7684\u8F85\u52A9\u8BF4\u660E",
18024
+ description: "\u8FD9\u662F\u4E00\u6BB5\u6765\u81EA\u7EC4\u4EF6\u5951\u7EA6\u7684\u9884\u89C8\u5185\u5BB9",
18025
+ value: "sample-value",
18026
+ text: "\u793A\u4F8B\u5185\u5BB9",
18027
+ status: "active",
18028
+ amount: 1280,
18029
+ count: 12,
18030
+ quantity: 2
18031
+ };
18032
+ }
18033
+ function previewArrayFallback(path) {
18034
+ const name = previewFieldName(path);
18035
+ if (/(?:ids?|keys?|values?|dates?|tags?)$/u.test(name)) return [previewString(path)];
18036
+ return [previewRecord()];
18037
+ }
18038
+ var PRESENTATIONAL_EMPTY_ARRAY_FIELDS = /* @__PURE__ */ new Set([
18039
+ "accounts",
18040
+ "actions",
18041
+ "balances",
18042
+ "blockers",
18043
+ "breadcrumb",
18044
+ "candidates",
18045
+ "checks",
18046
+ "columns",
18047
+ "data",
18048
+ "detail",
18049
+ "downstream",
18050
+ "entries",
18051
+ "events",
18052
+ "evidence",
18053
+ "facts",
18054
+ "files",
18055
+ "items",
18056
+ "lab_panels",
18057
+ "lines",
18058
+ "messages",
18059
+ "presets",
18060
+ "products",
18061
+ "records",
18062
+ "rows",
18063
+ "stats",
18064
+ "steps",
18065
+ "tabs",
18066
+ "tags",
18067
+ "upstream"
18068
+ ]);
18069
+ function shouldSynthesizeEmptyArrayPreview(field, path) {
18070
+ return field.required === true || field.items !== void 0 || PRESENTATIONAL_EMPTY_ARRAY_FIELDS.has(previewFieldName(path));
18071
+ }
18072
+ function previewStrategy(synthesized) {
18073
+ return {
18074
+ // A product-facing empty array is often the correct default. Only recognised
18075
+ // visual collections may reach the deterministic preview fallback: arbitrary
18076
+ // configuration arrays must stay empty so a generic record cannot enable an
18077
+ // invalid reaction/rule/condition in the component preview.
18078
+ useDefault: (field, path) => !(field.type === "array" && Array.isArray(field.default) && field.default.length === 0 && shouldSynthesizeEmptyArrayPreview(field, path)),
18079
+ fallback(field, path) {
18080
+ synthesized.push(path);
18081
+ if (field.type === "string") return previewString(path);
18082
+ if (field.type === "number") return previewNumber(path);
18083
+ if (field.type === "boolean") return previewBoolean(path);
18084
+ if (field.type === "array") return previewArrayFallback(path);
18085
+ if (field.type === "object") return previewRecord();
18086
+ return void 0;
18087
+ }
18088
+ };
18089
+ }
18090
+ function deriveContractPreviewSample(contract) {
18091
+ const synthesized = [];
18092
+ const props = walkProps(contract, previewStrategy(synthesized));
18093
+ return { props, synthesized };
18094
+ }
17153
18095
  function deriveFieldSample(field) {
17154
- return deriveField(field, "", []);
18096
+ return walkField(field, "", sampleStrategy([]));
17155
18097
  }
17156
18098
  function hasRenderableSample(contract) {
17157
18099
  const seen = (field) => {
@@ -18001,20 +18943,6 @@ function precompileUiModule(yamlStr) {
18001
18943
  parseSomaBlockContainer(yamlStr);
18002
18944
  return "null";
18003
18945
  }
18004
- function compileEventConfigFromRaw(raw2) {
18005
- const { eventsRaw, triggers, timers } = splitEventConfigRaw(raw2);
18006
- return {
18007
- events: parseEventConfig(eventsRaw),
18008
- triggers,
18009
- timers
18010
- };
18011
- }
18012
- function compileDataConfig(yamlStr) {
18013
- if (!yamlStr.trim()) {
18014
- return { objects: {} };
18015
- }
18016
- return parseDataConfig(yaml.load(yamlStr));
18017
- }
18018
18946
  function precompileYaml(yamlStr) {
18019
18947
  const obj = yaml.load(yamlStr);
18020
18948
  return JSON.stringify(obj ?? {});
@@ -19698,6 +20626,9 @@ var SomaScopeError = class extends Error {
19698
20626
  };
19699
20627
  var RESERVED = /* @__PURE__ */ new Set(["page", "p", "ctrl"]);
19700
20628
  var NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
20629
+ function blockDataObjectName(blockId, localName) {
20630
+ return `${blockId}__${localName}`;
20631
+ }
19701
20632
  function buildBlockScope(input) {
19702
20633
  const blockId = input.blockId;
19703
20634
  const dataNames = new Set(input.dataNames ?? []);
@@ -19761,7 +20692,7 @@ function resolvePath(raw2, scope) {
19761
20692
  const hits = [inData, inRow, isPage].filter(Boolean).length;
19762
20693
  if (hits > 1) {
19763
20694
  const candidates = [
19764
- inData ? `data \u5BF9\u8C61 ${scope.blockId}.${head}` : "",
20695
+ inData ? `\u672C\u5757 data \u540D ${head}` : "",
19765
20696
  inRow ? `\u884C\u53D8\u91CF ${head}` : "",
19766
20697
  isPage ? "\u9875\u9762\u53D8\u91CF page" : ""
19767
20698
  ].filter(Boolean);
@@ -19771,7 +20702,8 @@ function resolvePath(raw2, scope) {
19771
20702
  );
19772
20703
  }
19773
20704
  if (inData) {
19774
- return { kind: "data", full: [`${scope.blockId}.${head}`, ...segments.slice(1)].join(".") };
20705
+ const base = scope.dataPaths?.get(head) ?? `${scope.blockId}.${head}`;
20706
+ return { kind: "data", full: [base, ...segments.slice(1)].join(".") };
19775
20707
  }
19776
20708
  if (inRow) return { kind: "row", full: text };
19777
20709
  if (isPage) return { kind: "page", full: text };
@@ -19827,57 +20759,82 @@ var PAGE_KEYS = /* @__PURE__ */ new Set([
19827
20759
  // 只有测试里直接喂平铺 YAML 的路径能用。文档承诺了一件真实页面做不到的事。
19828
20760
  // 这里只直通原文;形状校验在 parseUiConfig(运行时)与 compilePageDeclaration(构建期)各做一次。
19829
20761
  "state",
19830
- "layout"
20762
+ "layout",
20763
+ // ooui(REQ-014 演绎接线):第三个平铺 UiConfig 保留键的直通。
20764
+ //
20765
+ // 少了这一条,块声明页写 `ooui:` 会当场收到「page 块不支持键 "ooui"」——
20766
+ // 而**真实发布的页面只有块声明这一条路**(compilePageDeclaration 只收块声明),
20767
+ // 于是整条演绎链只在"直接喂平铺 YAML"的测试路径上活着,生产页面一次都用不上。
20768
+ // 这与上面 state / layout 那次踩的是同一个坑,不再重踩第三次。
20769
+ // 这里只直通原文;形状校验在 parseUiConfig(运行时)与 compilePageDeclaration(构建期)各做一次。
20770
+ "ooui",
20771
+ // objects(REQ-014 表层语义,§38.5 断线 ②):**面向人书写的那一层对象声明**。
20772
+ //
20773
+ // `data:` 是核心层——完备、显式、机器好翻译(`{ type: text, rules: [{ required: true }] }`)。
20774
+ // 表层是同一件事的人写形态(`no: text!`)。两层的转换点只有一个
20775
+ // (`build/ooui/semantic/normalize.ts`),而在此之前**它一个生产调用者都没有**:
20776
+ // 表层类型、展开器、台账三样都写完了,页面上却没有任何地方能写出表层来。
20777
+ //
20778
+ // 不接这一条的后果不是"少个语法糖",是**来历台账永远是空的**:
20779
+ // 系统按默认补的值(如 `permission: r`)与作者显式写的值在产物里长得一模一样,
20780
+ // 于是 `OOUI-SEM-EDIT-ALL-READONLY` 只能说"你写错了",说不出"我按默认补的、
20781
+ // 你需要显式写 permission: w"——同一条错误,两种修法,指向两个人(§34.2)。
20782
+ //
20783
+ // 这里只直通原文;展开与校验在 compilePageDeclaration(构建期)做一次。
20784
+ "objects"
19831
20785
  ]);
19832
20786
  var SUFFIXES = ["when", "model", "class"];
19833
20787
  function parsePageBlock(input) {
19834
20788
  const { body } = input;
19835
- const fail2 = (message) => {
20789
+ const fail = (message) => {
19836
20790
  throw new SomaBlockParseError(message, "page");
19837
20791
  };
19838
20792
  for (const key of Object.keys(body)) {
19839
20793
  if (!PAGE_KEYS.has(key)) {
19840
- fail2(`page \u5757\u4E0D\u652F\u6301\u952E "${key}"\uFF08\u53EF\u7528\uFF1A${[...PAGE_KEYS].join("/")}\uFF09`);
20794
+ fail(`page \u5757\u4E0D\u652F\u6301\u952E "${key}"\uFF08\u53EF\u7528\uFF1A${[...PAGE_KEYS].join("/")}\uFF09`);
19841
20795
  }
19842
20796
  }
19843
20797
  const domain = body.domain;
19844
20798
  if (typeof domain !== "string" || domain.trim() === "") {
19845
- fail2("page \u5757\u7F3A\u5C11 domain\uFF08\u9875\u9762 Domain \u7C7B\u540D\uFF0C\u5FC5\u586B\uFF09");
20799
+ fail("page \u5757\u7F3A\u5C11 domain\uFF08\u9875\u9762 Domain \u7C7B\u540D\uFF0C\u5FC5\u586B\uFF09");
19846
20800
  }
19847
20801
  const scope = buildBlockScope({
19848
20802
  blockId: "page",
19849
- dataNames: Object.keys(body.data ?? {}),
20803
+ dataNames: [.../* @__PURE__ */ new Set([
20804
+ ...Object.keys(body.data ?? {}),
20805
+ ...Object.keys(body.objects ?? {})
20806
+ ])],
19850
20807
  aliasRaw: body.alias
19851
20808
  });
19852
20809
  const show = {};
19853
20810
  const locale = body.locale;
19854
20811
  if (locale !== void 0) {
19855
- if (!Array.isArray(locale)) fail2("locale \u5FC5\u987B\u662F\u540D\u5355\u6570\u7EC4");
20812
+ if (!Array.isArray(locale)) fail("locale \u5FC5\u987B\u662F\u540D\u5355\u6570\u7EC4");
19856
20813
  for (const item of locale) {
19857
20814
  const key = String(item);
19858
20815
  if (!input.anchors.has(key)) {
19859
- fail2(`locale \u540D\u5355\u91CC\u7684 "${key}" \u5728 HTML \u4E2D\u6CA1\u6709\u5BF9\u5E94\u951A\u70B9`);
20816
+ fail(`locale \u540D\u5355\u91CC\u7684 "${key}" \u5728 HTML \u4E2D\u6CA1\u6709\u5BF9\u5E94\u951A\u70B9`);
19860
20817
  }
19861
20818
  if (input.localeKeys && !input.localeKeys.has(key)) {
19862
- fail2(`locale \u540D\u5355\u91CC\u7684 "${key}" \u5728\u8BCD\u5178\u4E2D\u6CA1\u6709\u5BF9\u5E94\u952E`);
20819
+ fail(`locale \u540D\u5355\u91CC\u7684 "${key}" \u5728\u8BCD\u5178\u4E2D\u6CA1\u6709\u5BF9\u5E94\u952E`);
19863
20820
  }
19864
20821
  show[key] = `page._locale.${key}`;
19865
20822
  }
19866
20823
  }
19867
20824
  const uiRaw = body.ui ?? {};
19868
- if (typeof uiRaw !== "object" || Array.isArray(uiRaw)) fail2("ui \u6BB5\u5FC5\u987B\u662F\u6620\u5C04");
20825
+ if (typeof uiRaw !== "object" || Array.isArray(uiRaw)) fail("ui \u6BB5\u5FC5\u987B\u662F\u6620\u5C04");
19869
20826
  parseShowLevel(uiRaw, show, scope, input, "page");
19870
20827
  const bind = { obj: String(domain), var: "page" };
19871
20828
  const watch = body.watch;
19872
20829
  if (watch !== void 0) {
19873
- if (!Array.isArray(watch)) fail2("watch \u5FC5\u987B\u662F\u6570\u7EC4");
20830
+ if (!Array.isArray(watch)) fail("watch \u5FC5\u987B\u662F\u6570\u7EC4");
19874
20831
  const rules = [];
19875
20832
  for (const item of watch) {
19876
- if (!item || typeof item !== "object") fail2("watch \u9879\u5FC5\u987B\u662F\u6620\u5C04");
20833
+ if (!item || typeof item !== "object") fail("watch \u9879\u5FC5\u987B\u662F\u6620\u5C04");
19877
20834
  const path = item.path;
19878
20835
  const call = item.call;
19879
- if (typeof path !== "string" || path.trim() === "") fail2("watch \u9879\u7F3A\u5C11 path");
19880
- if (typeof call !== "string" || call.trim() === "") fail2("watch \u9879\u7F3A\u5C11 call");
20836
+ if (typeof path !== "string" || path.trim() === "") fail("watch \u9879\u7F3A\u5C11 path");
20837
+ if (typeof call !== "string" || call.trim() === "") fail("watch \u9879\u7F3A\u5C11 call");
19881
20838
  const rule = {
19882
20839
  condition: expandPath(String(path), scope),
19883
20840
  callback: String(call).includes(".") ? String(call) : `page.${call}`
@@ -19891,7 +20848,7 @@ function parsePageBlock(input) {
19891
20848
  const ui = { bind, show };
19892
20849
  if (body.initProps !== void 0) {
19893
20850
  if (body.initProps === null || typeof body.initProps !== "object" || Array.isArray(body.initProps)) {
19894
- fail2("initProps \u5FC5\u987B\u662F\u6620\u5C04\uFF08\u952E\u4E3A var \u522B\u540D\u8DEF\u5F84\uFF0C\u5982 page.title\uFF09");
20851
+ fail("initProps \u5FC5\u987B\u662F\u6620\u5C04\uFF08\u952E\u4E3A var \u522B\u540D\u8DEF\u5F84\uFF0C\u5982 page.title\uFF09");
19895
20852
  }
19896
20853
  ui.initProps = body.initProps;
19897
20854
  }
@@ -19904,28 +20861,32 @@ function parsePageBlock(input) {
19904
20861
  if (body.layout !== void 0) {
19905
20862
  ui.layout = body.layout;
19906
20863
  }
19907
- const eventRaw = normalizeEventSection(body.event, input, fail2);
20864
+ if (body.ooui !== void 0) {
20865
+ ui.ooui = body.ooui;
20866
+ }
20867
+ const eventRaw = normalizeEventSection(body.event, input, fail);
19908
20868
  return {
19909
20869
  ui,
19910
20870
  eventRaw,
19911
20871
  ...body.data ? { dataRaw: body.data } : {},
20872
+ ...body.objects ? { surfaceRaw: body.objects } : {},
19912
20873
  scope
19913
20874
  };
19914
20875
  }
19915
20876
  function parseShowLevel(raw2, target, scope, input, where) {
19916
- const fail2 = (message) => {
20877
+ const fail = (message) => {
19917
20878
  throw new SomaBlockParseError(message, "page");
19918
20879
  };
19919
20880
  for (const [key, value] of Object.entries(raw2)) {
19920
20881
  if (key === "each") continue;
19921
20882
  const { anchor, suffix, attr } = splitKey(key);
19922
20883
  if (input.instances.has(anchor)) {
19923
- fail2(
20884
+ fail(
19924
20885
  `"${anchor}" \u662F\u7EC4\u4EF6\u5B9E\u4F8B\u951A\u70B9\uFF0C\u4E0D\u80FD\u5199\u5728 page \u5757\u7684 ui \u6BB5\u2014\u2014\u7EC4\u4EF6\u7684\u4E00\u5207\u58F0\u660E\u4F4F\u5728\u5B83\u81EA\u5DF1\u7684\u5757\u91CC\uFF08\u9876\u5C42\u5199 ${anchor}:\uFF09`
19925
20886
  );
19926
20887
  }
19927
20888
  if (!input.anchors.has(anchor)) {
19928
- fail2(`${where} \u7684 ui \u5F15\u7528\u4E86 HTML \u4E2D\u4E0D\u5B58\u5728\u7684\u951A\u70B9 "${anchor}"`);
20889
+ fail(`${where} \u7684 ui \u5F15\u7528\u4E86 HTML \u4E2D\u4E0D\u5B58\u5728\u7684\u951A\u70B9 "${anchor}"`);
19929
20890
  }
19930
20891
  if (isEachBlock(value)) {
19931
20892
  target[anchor] = parseEachBlock(value, scope, input, anchor);
@@ -19933,23 +20894,23 @@ function parseShowLevel(raw2, target, scope, input, where) {
19933
20894
  }
19934
20895
  if (suffix) {
19935
20896
  const existing2 = asExtended(target[anchor]);
19936
- applySuffix(existing2, suffix, value, scope, fail2);
20897
+ applySuffix(existing2, suffix, value, scope, fail);
19937
20898
  target[anchor] = existing2;
19938
20899
  continue;
19939
20900
  }
19940
20901
  if (attr) {
19941
20902
  if (value !== null && typeof value === "object") {
19942
- fail2(`"${key}" \u7684\u5C5E\u6027\u7ED1\u5B9A\u503C\u5FC5\u987B\u662F\u6807\u91CF\u8DEF\u5F84\uFF0C\u4E0D\u80FD\u5199\u6620\u5C04\u6216\u6570\u7EC4`);
20903
+ fail(`"${key}" \u7684\u5C5E\u6027\u7ED1\u5B9A\u503C\u5FC5\u987B\u662F\u6807\u91CF\u8DEF\u5F84\uFF0C\u4E0D\u80FD\u5199\u6620\u5C04\u6216\u6570\u7EC4`);
19943
20904
  }
19944
- target[`${anchor}@${attr}`] = expandValue(value, scope, fail2);
20905
+ target[`${anchor}@${attr}`] = expandValue(value, scope, fail);
19945
20906
  continue;
19946
20907
  }
19947
20908
  if (value !== null && typeof value === "object" && !Array.isArray(value)) {
19948
- fail2(
20909
+ fail(
19949
20910
  `"${key}" \u7684\u503C\u662F\u6620\u5C04\uFF0C\u4F46 ui \u6BB5\u53EA\u5141\u8BB8\u5E73\u94FA\u5199\u6CD5\uFF08\u663E\u9690\u7528 \u951A\u70B9.when\u3001\u6761\u4EF6\u7C7B\u7528 \u951A\u70B9.class\u3001\u5217\u8868\u7528 each\uFF09`
19950
20911
  );
19951
20912
  }
19952
- const expanded = expandValue(value, scope, fail2);
20913
+ const expanded = expandValue(value, scope, fail);
19953
20914
  const existing = target[anchor];
19954
20915
  if (existing !== void 0 && typeof existing === "object" && !Array.isArray(existing)) {
19955
20916
  existing.text = expanded;
@@ -19962,13 +20923,13 @@ function isEachBlock(value) {
19962
20923
  return value !== null && typeof value === "object" && !Array.isArray(value) && typeof value.each === "string";
19963
20924
  }
19964
20925
  function parseEachBlock(block, scope, input, anchor) {
19965
- const fail2 = (message) => {
20926
+ const fail = (message) => {
19966
20927
  throw new SomaBlockParseError(message, "page");
19967
20928
  };
19968
20929
  const raw2 = String(block.each);
19969
20930
  const match = /^(\S+)\s+as\s+([A-Za-z_][A-Za-z0-9_]*)(?:\s+by\s+(\S+))?(?:\s+key\s+(\S+))?$/.exec(raw2.trim());
19970
20931
  if (!match) {
19971
- fail2(`each \u8BED\u6CD5\u9519\u8BEF: "${raw2}"\uFF08\u5E94\u4E3A each: \u8DEF\u5F84 as \u53D8\u91CF [by \u8DEF\u5F84] [key \u5B57\u6BB5]\uFF09`);
20932
+ fail(`each \u8BED\u6CD5\u9519\u8BEF: "${raw2}"\uFF08\u5E94\u4E3A each: \u8DEF\u5F84 as \u53D8\u91CF [by \u8DEF\u5F84] [key \u5B57\u6BB5]\uFF09`);
19972
20933
  }
19973
20934
  const [, sourcePath, rowVar, byPath] = match;
19974
20935
  const bind = {
@@ -20008,10 +20969,10 @@ function asExtended(current) {
20008
20969
  if (typeof current === "string") return { text: current };
20009
20970
  return current;
20010
20971
  }
20011
- function applySuffix(target, suffix, value, scope, fail2) {
20972
+ function applySuffix(target, suffix, value, scope, fail) {
20012
20973
  if (suffix === "class") {
20013
20974
  if (value === null || typeof value !== "object" || Array.isArray(value)) {
20014
- fail2(".class \u7684\u503C\u5FC5\u987B\u662F { \u7C7B\u540D: \u6761\u4EF6\u8DEF\u5F84 } \u6620\u5C04");
20975
+ fail(".class \u7684\u503C\u5FC5\u987B\u662F { \u7C7B\u540D: \u6761\u4EF6\u8DEF\u5F84 } \u6620\u5C04");
20015
20976
  }
20016
20977
  const map2 = {};
20017
20978
  for (const [cls, cond] of Object.entries(value)) {
@@ -20032,30 +20993,30 @@ function expandCondition(raw2, scope) {
20032
20993
  const bare = negated ? text.slice(1).trim() : text;
20033
20994
  return `${negated ? "!" : ""}${expandPath(bare, scope)}`;
20034
20995
  }
20035
- function expandValue(value, scope, fail2) {
20036
- if (value === null || value === void 0) fail2("\u7ED1\u5B9A\u503C\u4E0D\u80FD\u4E3A\u7A7A");
20996
+ function expandValue(value, scope, fail) {
20997
+ if (value === null || value === void 0) fail("\u7ED1\u5B9A\u503C\u4E0D\u80FD\u4E3A\u7A7A");
20037
20998
  if (typeof value !== "string") return String(value);
20038
20999
  const segments = String(value).split(/\s+\|\s+/);
20039
21000
  segments[0] = expandPath(segments[0], scope);
20040
21001
  return segments.join(" | ");
20041
21002
  }
20042
- function normalizeEventSection(raw2, input, fail2) {
21003
+ function normalizeEventSection(raw2, input, fail) {
20043
21004
  if (raw2 === void 0) return {};
20044
21005
  if (raw2 === null || typeof raw2 !== "object" || Array.isArray(raw2)) {
20045
- fail2("event \u6BB5\u5FC5\u987B\u662F\u6620\u5C04\uFF08\u5B50\u952E on / timers / triggers\uFF09");
21006
+ fail("event \u6BB5\u5FC5\u987B\u662F\u6620\u5C04\uFF08\u5B50\u952E on / timers / triggers\uFF09");
20046
21007
  }
20047
21008
  const section = raw2;
20048
21009
  for (const key of Object.keys(section)) {
20049
21010
  if (!["on", "timers", "triggers"].includes(key)) {
20050
- fail2(`page \u5757\u7684 event \u6BB5\u4E0D\u652F\u6301\u5B50\u952E "${key}"\uFF08\u53EF\u7528\uFF1Aon / timers / triggers\uFF09`);
21011
+ fail(`page \u5757\u7684 event \u6BB5\u4E0D\u652F\u6301\u5B50\u952E "${key}"\uFF08\u53EF\u7528\uFF1Aon / timers / triggers\uFF09`);
20051
21012
  }
20052
21013
  }
20053
21014
  const on = section.on ?? {};
20054
- if (typeof on !== "object" || Array.isArray(on)) fail2("event.on \u5FC5\u987B\u662F\u6620\u5C04");
21015
+ if (typeof on !== "object" || Array.isArray(on)) fail("event.on \u5FC5\u987B\u662F\u6620\u5C04");
20055
21016
  for (const key of Object.keys(on)) {
20056
21017
  const anchor = key.split(".")[0];
20057
21018
  if (input.instances.has(anchor)) {
20058
- fail2(
21019
+ fail(
20059
21020
  `"${key}" \u7684\u951A\u70B9 "${anchor}" \u662F\u7EC4\u4EF6\u5B9E\u4F8B\u2014\u2014\u7EC4\u4EF6\u4E8B\u4EF6\uFF08emit \u8DEF\u7531\uFF09\u4F4F\u5728\u8BE5\u7EC4\u4EF6\u5757\u7684 event.on \u6BB5\uFF0Cpage \u5757\u7684 event \u53EA\u9762\u5411 DOM \u4E8B\u4EF6`
20060
21021
  );
20061
21022
  }
@@ -20068,7 +21029,22 @@ function normalizeEventSection(raw2, input, fail2) {
20068
21029
 
20069
21030
  // core/client/parser/blocks/use-parser.ts
20070
21031
  var BLOCK_KEYS = /* @__PURE__ */ new Set(["component", "alias", "when", "data", "ui", "event"]);
20071
- var DATA_OBJECT_KEYS = /* @__PURE__ */ new Set(["from", "save", "refresh", "reload_on", "fields"]);
21032
+ var USE_BLOCK_DATA_OBJECT_KEYS = [
21033
+ "from",
21034
+ "save",
21035
+ "fields",
21036
+ "roles",
21037
+ "relations"
21038
+ ];
21039
+ var DATA_OBJECT_KEYS = new Set(USE_BLOCK_DATA_OBJECT_KEYS);
21040
+ var RETIRED_DATA_OBJECT_KEYS = /* @__PURE__ */ new Map([
21041
+ ["refresh", "\u6570\u636E\u5BF9\u8C61\u5C42\u4E0D\u505A\u5468\u671F\u91CD\u53D6\uFF0C\u5199\u4E86\u4E5F\u4E0D\u4F1A\u8F6E\u8BE2\u2014\u2014\u8981\u5B9A\u65F6\u91CD\u53D6\uFF0C\u5728 page \u5757 event.timers \u6302\u4E00\u4E2A tick \u8C03 Domain \u65B9\u6CD5\uFF0C\u65B9\u6CD5\u91CC\u8C03 this.reloadData()"],
21042
+ ["reload_on", "\u6570\u636E\u5BF9\u8C61\u5C42\u4E0D\u76D1\u542C\u8DEF\u5F84\u53D8\u5316\uFF0C\u5199\u4E86\u4E5F\u4E0D\u4F1A\u91CD\u53D6\u2014\u2014\u8981\u4F9D\u8D56\u53D8\u5316\u540E\u91CD\u53D6\uFF0C\u5728 page \u5757 watch \u91CC\u5199 { path, call }\uFF0C\u88AB\u8C03\u7684 Domain \u65B9\u6CD5\u91CC\u8C03 this.reloadData()"]
21043
+ ]);
21044
+ var FROM_KEYS = /* @__PURE__ */ new Set(["api", "params"]);
21045
+ var SAVE_KEYS = /* @__PURE__ */ new Set(["api", "method", "key", "fields"]);
21046
+ var DATA_OBJECT_NAME_RE = /^[A-Za-z_]\w*$/;
21047
+ var PARAM_PATH_RE = /^[A-Za-z_]\w*(?:\.\w+)*$/;
20072
21048
  var EVENT_KEYS = /* @__PURE__ */ new Set(["actions", "on"]);
20073
21049
  var ACTION_KEYS = /* @__PURE__ */ new Set([
20074
21050
  "label",
@@ -20080,47 +21056,80 @@ var ACTION_KEYS = /* @__PURE__ */ new Set([
20080
21056
  "when",
20081
21057
  "disabled_reason"
20082
21058
  ]);
20083
- var FIELD_KEYS = /* @__PURE__ */ new Set(["name", "type", "values", "permission", "rules"]);
21059
+ var USE_BLOCK_FIELD_KEYS = [
21060
+ "name",
21061
+ "type",
21062
+ "values",
21063
+ "permission",
21064
+ "rules",
21065
+ "modifies"
21066
+ ];
21067
+ var FIELD_KEYS = new Set(USE_BLOCK_FIELD_KEYS);
20084
21068
  var FIELD_TYPES = new Set(SOMA_DATA_FIELD_TYPES);
20085
21069
  function parseUseBlock(input) {
20086
21070
  const { blockId, body } = input;
20087
- const fail2 = (message) => {
21071
+ const fail = (message) => {
20088
21072
  throw new SomaBlockParseError(message, blockId);
20089
21073
  };
20090
21074
  for (const key of Object.keys(body)) {
20091
21075
  if (!BLOCK_KEYS.has(key)) {
20092
- fail2(`\u7EC4\u4EF6\u5757\u4E0D\u652F\u6301\u952E "${key}"\uFF08\u53EF\u7528\uFF1A${[...BLOCK_KEYS].join("/")}\uFF09`);
21076
+ fail(`\u7EC4\u4EF6\u5757\u4E0D\u652F\u6301\u952E "${key}"\uFF08\u53EF\u7528\uFF1A${[...BLOCK_KEYS].join("/")}\uFF09`);
20093
21077
  }
20094
21078
  }
20095
21079
  const component = body.component === void 0 ? void 0 : String(body.component);
20096
21080
  if (component && input.htmlComponent && component !== input.htmlComponent) {
20097
- fail2(
21081
+ fail(
20098
21082
  `component \u58F0\u660E\u4E3A "${component}"\uFF0C\u4F46 HTML \u91CC\u662F "${input.htmlComponent}"\u2014\u2014\u4E24\u5904\u5FC5\u987B\u4E00\u81F4\uFF08\u6539\u4E86\u4E00\u5904\u5FD8\u4E86\u53E6\u4E00\u5904\u65F6\uFF0C\u9875\u9762\u6E32\u67D3\u7684\u662F\u54EA\u4E2A\u53EA\u80FD\u9760\u731C\uFF09`
20099
21083
  );
20100
21084
  }
20101
21085
  const dataRaw = body.data ?? {};
20102
- if (typeof dataRaw !== "object" || Array.isArray(dataRaw)) fail2("data \u6BB5\u5FC5\u987B\u662F\u6620\u5C04");
20103
- const scope = buildBlockScope({
21086
+ if (typeof dataRaw !== "object" || Array.isArray(dataRaw)) fail("data \u6BB5\u5FC5\u987B\u662F\u6620\u5C04");
21087
+ const baseScope = buildBlockScope({
20104
21088
  blockId,
20105
21089
  dataNames: Object.keys(dataRaw),
20106
21090
  aliasRaw: body.alias,
20107
21091
  rowVars: input.rowVars
20108
21092
  });
20109
- const { actions, emitRoutes } = parseEventSection(body.event, blockId, scope, fail2);
20110
- const dataObjects = [];
21093
+ const dataPaths = /* @__PURE__ */ new Map();
20111
21094
  const dataImports = [];
20112
21095
  for (const [localName, raw2] of Object.entries(dataRaw)) {
20113
21096
  if (typeof raw2 === "string") {
20114
- dataImports.push({ localName, targetPath: expandPath(raw2, { ...scope, dataNames: /* @__PURE__ */ new Set() }) });
21097
+ const target = resolvePath(raw2, { ...baseScope, dataNames: /* @__PURE__ */ new Set() });
21098
+ if (target.kind === "literal") {
21099
+ fail(
21100
+ `data.${localName} \u7684\u5F15\u5165\u8DEF\u5F84 "${raw2}" \u4E0D\u5728\u4EFB\u4F55\u4F5C\u7528\u57DF\u5185\u2014\u2014\u5F15\u5165\u53EA\u80FD\u6307\u5411 page.*\uFF08\u5982 page.data.profile\uFF09\u3001\u884C\u53D8\u91CF\u6216\u8DEF\u5F84\u522B\u540D`
21101
+ );
21102
+ }
21103
+ const targetPath = target.full;
21104
+ dataPaths.set(localName, targetPath);
21105
+ dataImports.push({ localName, targetPath });
20115
21106
  continue;
20116
21107
  }
20117
21108
  if (raw2 === null || typeof raw2 !== "object" || Array.isArray(raw2)) {
20118
- fail2(`data.${localName} \u5FC5\u987B\u662F\u6620\u5C04\uFF08\u58F0\u660E\uFF09\u6216\u5B57\u7B26\u4E32\u8DEF\u5F84\uFF08\u5F15\u5165\uFF09`);
21109
+ fail(`data.${localName} \u5FC5\u987B\u662F\u6620\u5C04\uFF08\u58F0\u660E\uFF09\u6216\u5B57\u7B26\u4E32\u8DEF\u5F84\uFF08\u5F15\u5165\uFF09`);
21110
+ }
21111
+ if (input.inRowTemplate) {
21112
+ fail(
21113
+ `data.${localName} \u662F\u5757\u79C1\u6709\u6570\u636E\u5BF9\u8C61\uFF0C\u4F46\u5B9E\u4F8B "${blockId}" \u4F4D\u4E8E\u5217\u8868\u884C\u6A21\u677F\u5185\u2014\u2014\u884C\u6A21\u677F\u6BCF\u884C\u6E32\u67D3\u4E00\u4E2A\u5B9E\u4F8B\uFF0C\u6570\u636E\u5BF9\u8C61\u5C42\u6CA1\u6709\u300C\u6BCF\u884C\u4E00\u4E2A\u5BF9\u8C61\u300D\u7684\u8868\u8FBE\uFF1B\u8BF7\u628A\u5BF9\u8C61\u58F0\u660E\u5230 page \u5757\u7684 data:\uFF0C\u884C\u5185\u7528\u884C\u53D8\u91CF\u6216\u5F15\u5165\uFF08\u540D: \u8DEF\u5F84\uFF09\u53D6\u503C`
21114
+ );
21115
+ }
21116
+ const fullName = blockDataObjectName(blockId, localName);
21117
+ if (!DATA_OBJECT_NAME_RE.test(fullName)) {
21118
+ fail(
21119
+ `\u79C1\u6709\u6570\u636E\u5BF9\u8C61 "${localName}" \u7684\u5168\u5C40\u540D "${fullName}" \u4E0D\u662F\u6807\u8BC6\u7B26\u2014\u2014\u5757 id "${blockId}" \u542B\u5B57\u6BCD/\u6570\u5B57/\u4E0B\u5212\u7EBF\u4EE5\u5916\u7684\u5B57\u7B26\uFF0C\u800C\u6570\u636E\u5BF9\u8C61\u5C42\u7684\u5BF9\u8C61\u540D\u5FC5\u987B\u662F\u6807\u8BC6\u7B26\uFF1B\u8BF7\u628A\u8BE5\u5B9E\u4F8B\u7684 data-soma-id \u6539\u6210\u4E0B\u5212\u7EBF\u5199\u6CD5`
21120
+ );
20119
21121
  }
20120
- dataObjects.push(parseDataObject(localName, raw2, blockId, scope, actions, fail2));
21122
+ dataPaths.set(localName, `page.data.${fullName}`);
21123
+ }
21124
+ const scope = { ...baseScope, dataPaths };
21125
+ const { actions, emitRoutes } = parseEventSection(body.event, blockId, scope, fail);
21126
+ const dataObjects = [];
21127
+ for (const [localName, raw2] of Object.entries(dataRaw)) {
21128
+ if (typeof raw2 === "string") continue;
21129
+ dataObjects.push(parseDataObject(localName, raw2, blockId, scope, fail));
20121
21130
  }
20122
21131
  const uiRaw = body.ui ?? {};
20123
- if (typeof uiRaw !== "object" || Array.isArray(uiRaw)) fail2("ui \u6BB5\u5FC5\u987B\u662F\u6620\u5C04");
21132
+ if (typeof uiRaw !== "object" || Array.isArray(uiRaw)) fail("ui \u6BB5\u5FC5\u987B\u662F\u6620\u5C04");
20124
21133
  const when = body.when === void 0 ? void 0 : expandCondition2(String(body.when), scope);
20125
21134
  const ast = {
20126
21135
  blockId,
@@ -20140,127 +21149,200 @@ function parseUseBlock(input) {
20140
21149
  };
20141
21150
  return ast;
20142
21151
  }
20143
- function parseDataObject(localName, raw2, blockId, scope, actions, fail2) {
21152
+ function parseDataObject(localName, raw2, blockId, scope, fail) {
20144
21153
  for (const key of Object.keys(raw2)) {
21154
+ const retired = RETIRED_DATA_OBJECT_KEYS.get(key);
21155
+ if (retired !== void 0) {
21156
+ fail(`data.${localName}.${key} \u6CA1\u6709\u8FD0\u884C\u65F6\u5BF9\u5E94\u7269\uFF1A${retired}`);
21157
+ }
20145
21158
  if (!DATA_OBJECT_KEYS.has(key)) {
20146
- fail2(`data.${localName} \u4E0D\u652F\u6301\u952E "${key}"\uFF08\u53EF\u7528\uFF1A${[...DATA_OBJECT_KEYS].join("/")}\uFF09`);
21159
+ fail(`data.${localName} \u4E0D\u652F\u6301\u952E "${key}"\uFF08\u53EF\u7528\uFF1A${[...DATA_OBJECT_KEYS].join("/")}\uFF09`);
20147
21160
  }
20148
21161
  }
20149
- const decl = { localName, fullName: `${blockId}.${localName}` };
21162
+ const decl = { localName, fullName: blockDataObjectName(blockId, localName) };
20150
21163
  const from = raw2.from;
20151
21164
  if (from !== void 0) {
20152
- if (typeof from !== "object" || Array.isArray(from)) fail2(`data.${localName}.from \u5FC5\u987B\u662F\u6620\u5C04`);
20153
- const api = from.api;
20154
- if (typeof api !== "string" || api.trim() === "") fail2(`data.${localName}.from \u7F3A\u5C11 api`);
21165
+ if (from === null || typeof from !== "object" || Array.isArray(from)) {
21166
+ fail(`data.${localName}.from \u5FC5\u987B\u662F\u6620\u5C04 { api, params }\uFF08\u5757\u79C1\u6709\u5BF9\u8C61\u53EA\u6709\u4E00\u4E2A\u53D6\u6570\u6765\u6E90\uFF09`);
21167
+ }
21168
+ const source = from;
21169
+ for (const key of Object.keys(source)) {
21170
+ if (!FROM_KEYS.has(key)) {
21171
+ fail(`data.${localName}.from \u4E0D\u652F\u6301\u952E "${key}"\uFF08\u53EF\u7528\uFF1A${[...FROM_KEYS].join("/")}\uFF09`);
21172
+ }
21173
+ }
21174
+ const api = source.api;
21175
+ if (typeof api !== "string" || api.trim() === "") fail(`data.${localName}.from \u7F3A\u5C11 api`);
21176
+ const paramsRaw = source.params ?? {};
21177
+ if (paramsRaw === null || typeof paramsRaw !== "object" || Array.isArray(paramsRaw)) {
21178
+ fail(`data.${localName}.from.params \u5FC5\u987B\u662F\u6620\u5C04\uFF08\u53C2\u6570\u540D \u2192 \u8DEF\u5F84\u6216\u5B57\u9762\u91CF\uFF09`);
21179
+ }
20155
21180
  const params = {};
20156
- for (const [key, value] of Object.entries(from.params ?? {})) {
20157
- params[key] = expandPath(String(value), scope);
21181
+ for (const [key, value] of Object.entries(paramsRaw)) {
21182
+ params[key] = toDataParam(value, `data.${localName}.from.params.${key}`, scope, fail);
20158
21183
  }
20159
21184
  decl.from = { api: resolveApiRef(String(api), scope), params };
20160
21185
  }
20161
21186
  const save = raw2.save;
20162
21187
  if (save !== void 0) {
20163
- if (typeof save !== "object" || Array.isArray(save)) fail2(`data.${localName}.save \u5FC5\u987B\u662F\u6620\u5C04`);
20164
- const api = save.api;
20165
- const trigger = save.trigger;
20166
- if (typeof api !== "string" || api.trim() === "") fail2(`data.${localName}.save \u7F3A\u5C11 api`);
20167
- if (typeof trigger !== "string" || trigger.trim() === "") {
20168
- fail2(`data.${localName}.save \u7F3A\u5C11 trigger\uFF08\u7531\u54EA\u4E2A\u52A8\u4F5C\u89E6\u53D1\u56DE\u5199\uFF09`);
20169
- }
20170
- if (!actions.has(String(trigger))) {
20171
- const known = [...actions.keys()].join("/") || "\uFF08\u672C\u5757\u672A\u5B9A\u4E49\u4EFB\u4F55\u52A8\u4F5C\uFF09";
20172
- fail2(
20173
- `data.${localName}.save.trigger \u6307\u5411\u672A\u5B9A\u4E49\u7684\u52A8\u4F5C "${trigger}"\u2014\u2014\u8BF7\u5728 event.actions \u91CC\u5B9A\u4E49\u5B83\uFF08\u73B0\u6709\uFF1A${known}\uFF09`
20174
- );
21188
+ if (save === null || typeof save !== "object" || Array.isArray(save)) {
21189
+ fail(`data.${localName}.save \u5FC5\u987B\u662F\u6620\u5C04`);
21190
+ }
21191
+ const channel = save;
21192
+ for (const key of Object.keys(channel)) {
21193
+ if (key === "trigger") {
21194
+ fail(
21195
+ `data.${localName}.save.trigger \u6CA1\u6709\u8FD0\u884C\u65F6\u5BF9\u5E94\u7269\uFF1A\u5199\u901A\u9053\u6CA1\u6709\u300C\u54EA\u4E2A\u52A8\u4F5C\u89E6\u53D1\u63D0\u4EA4\u300D\u8FD9\u4E00\u73AF\u2014\u2014\u63D0\u4EA4\u7531\u6D88\u8D39\u8BE5\u5BF9\u8C61\u7684\u7EC4\u4EF6\u7ECF data \u7AEF\u53E3\u53D1\u8D77\uFF08\u5982 FormConsole \u7684 data_object: ${decl.fullName}\uFF09\uFF0C\u5220\u6389 trigger`
21196
+ );
21197
+ }
21198
+ if (!SAVE_KEYS.has(key)) {
21199
+ fail(`data.${localName}.save \u4E0D\u652F\u6301\u952E "${key}"\uFF08\u53EF\u7528\uFF1A${[...SAVE_KEYS].join("/")}\uFF09`);
21200
+ }
21201
+ }
21202
+ const api = channel.api;
21203
+ if (typeof api !== "string" || api.trim() === "") fail(`data.${localName}.save \u7F3A\u5C11 api`);
21204
+ if (channel.fields !== void 0 && (!Array.isArray(channel.fields) || channel.fields.some((item) => typeof item !== "string"))) {
21205
+ fail(`data.${localName}.save.fields \u5FC5\u987B\u662F\u5B57\u6BB5\u540D\u6570\u7EC4`);
20175
21206
  }
20176
21207
  decl.save = {
20177
21208
  api: resolveApiRef(String(api), scope),
20178
- method: String(save.method ?? "POST").toUpperCase(),
20179
- trigger: String(trigger),
20180
- ...save.key !== void 0 ? { key: String(save.key) } : {},
20181
- ...Array.isArray(save.fields) ? { fields: save.fields.map(String) } : {}
21209
+ method: String(channel.method ?? "POST").toUpperCase(),
21210
+ ...channel.key !== void 0 ? { key: String(channel.key) } : {},
21211
+ ...channel.fields !== void 0 ? { fields: [...channel.fields] } : {}
20182
21212
  };
20183
21213
  }
20184
- if (raw2.refresh !== void 0) decl.refreshMs = parseDuration(String(raw2.refresh), localName, fail2);
20185
- if (raw2.reload_on !== void 0) {
20186
- if (!Array.isArray(raw2.reload_on)) fail2(`data.${localName}.reload_on \u5FC5\u987B\u662F\u6570\u7EC4`);
20187
- decl.reloadOn = raw2.reload_on.map((item) => expandPath(String(item), scope));
20188
- }
20189
21214
  if (raw2.fields !== void 0) {
20190
21215
  const fieldsRaw = raw2.fields;
20191
- if (typeof fieldsRaw !== "object" || Array.isArray(fieldsRaw)) {
20192
- fail2(`data.${localName}.fields \u5FC5\u987B\u662F\u6620\u5C04`);
21216
+ if (fieldsRaw === null || typeof fieldsRaw !== "object" || Array.isArray(fieldsRaw)) {
21217
+ fail(`data.${localName}.fields \u5FC5\u987B\u662F\u6620\u5C04`);
20193
21218
  }
20194
21219
  const fields = {};
20195
21220
  for (const [fieldName, fieldRaw] of Object.entries(fieldsRaw)) {
20196
- fields[fieldName] = parseField2(localName, fieldName, fieldRaw, fail2);
21221
+ fields[fieldName] = parseField2(localName, fieldName, fieldRaw, fail);
20197
21222
  }
21223
+ const modifiesIssues = validateFieldModifies(fields);
21224
+ if (modifiesIssues.length > 0) fail(`data.${localName}.fields\uFF1A${modifiesIssues.join("\uFF1B")}`);
20198
21225
  decl.fields = fields;
20199
21226
  }
21227
+ const fieldKeys = Object.keys(decl.fields ?? {});
21228
+ if (raw2.roles !== void 0) {
21229
+ const issues = validateObjectRoles(raw2.roles, fieldKeys);
21230
+ if (issues.length > 0) fail(`data.${localName}.roles\uFF1A${issues.join("\uFF1B")}`);
21231
+ decl.roles = raw2.roles;
21232
+ }
21233
+ if (raw2.relations !== void 0) {
21234
+ const issues = validateObjectRelations(raw2.relations, { fieldKeys, selfName: localName });
21235
+ if (issues.length > 0) fail(`data.${localName}.relations\uFF1A${issues.join("\uFF1B")}`);
21236
+ decl.relations = raw2.relations;
21237
+ }
20200
21238
  return decl;
20201
21239
  }
20202
- function parseField2(objectName, fieldName, raw2, fail2) {
21240
+ function toDataParam(raw2, where, scope, fail) {
21241
+ if (raw2 === null || typeof raw2 === "object") {
21242
+ fail(`${where} \u5FC5\u987B\u662F\u6807\u91CF\u6216\u8DEF\u5F84\uFF0C\u5F53\u524D\u503C: ${JSON.stringify(raw2)}`);
21243
+ }
21244
+ const text = String(raw2).trim();
21245
+ if (text.startsWith("$")) return text;
21246
+ const resolved = resolvePath(text, scope);
21247
+ if (resolved.kind === "literal") return text;
21248
+ if (!PARAM_PATH_RE.test(text)) {
21249
+ fail(`${where} \u7684\u503C "${text}" \u4E0D\u662F\u5355\u4E00\u8DEF\u5F84\u2014\u2014\u6570\u636E\u5BF9\u8C61\u5C42\u7684 \`$\` \u5F15\u7528\u53EA\u53D6\u4E00\u4E2A\u5B57\u6BB5\uFF0C\u4E0D\u5E26\u7BA1\u9053\u4E0E\u7B97\u672F`);
21250
+ }
21251
+ const segments = resolved.full.split(".");
21252
+ if (resolved.kind === "row" || segments[0] !== "page") {
21253
+ fail(`${where} \u5F15\u7528\u4E86\u884C\u53D8\u91CF "${text}"\u2014\u2014\u6570\u636E\u5BF9\u8C61\u4E0D\u968F\u884C\u91CD\u590D\uFF0C\u53D6\u6570\u53C2\u6570\u91CC\u6CA1\u6709\u884C\u53D8\u91CF`);
21254
+ }
21255
+ if (segments[1] === "data" && segments.length >= 3) {
21256
+ if (segments.length === 3) {
21257
+ fail(`${where} \u5F15\u7528\u7684\u662F\u6574\u4E2A\u6570\u636E\u5BF9\u8C61 "${segments[2]}"\u2014\u2014\u53C2\u6570\u53EA\u80FD\u53D6\u5BF9\u8C61\u7684\u67D0\u4E2A\u5B57\u6BB5\uFF08\u5199 ${text}.<\u5B57\u6BB5>\uFF09`);
21258
+ }
21259
+ return `$${segments.slice(2).join(".")}`;
21260
+ }
21261
+ if (segments.length === 1) {
21262
+ fail(`${where} \u5F15\u7528\u7684\u662F\u6574\u4E2A page\u2014\u2014\u53C2\u6570\u53EA\u80FD\u53D6 page \u4E0A\u7684\u67D0\u4E2A\u5B57\u6BB5`);
21263
+ }
21264
+ return `$page.${segments.slice(1).join(".")}`;
21265
+ }
21266
+ function parseField2(objectName, fieldName, raw2, fail) {
20203
21267
  if (raw2 === null || typeof raw2 !== "object" || Array.isArray(raw2)) {
20204
- fail2(`\u5B57\u6BB5\u5B57\u5178 ${objectName}.${fieldName} \u5FC5\u987B\u662F\u6620\u5C04`);
21268
+ fail(`\u5B57\u6BB5\u5B57\u5178 ${objectName}.${fieldName} \u5FC5\u987B\u662F\u6620\u5C04`);
20205
21269
  }
20206
21270
  const field = raw2;
20207
21271
  for (const key of Object.keys(field)) {
20208
21272
  if (!FIELD_KEYS.has(key)) {
20209
- fail2(`\u5B57\u6BB5 ${objectName}.${fieldName} \u4E0D\u652F\u6301\u952E "${key}"\uFF08\u53EF\u7528\uFF1A${[...FIELD_KEYS].join("/")}\uFF09`);
21273
+ fail(`\u5B57\u6BB5 ${objectName}.${fieldName} \u4E0D\u652F\u6301\u952E "${key}"\uFF08\u53EF\u7528\uFF1A${[...FIELD_KEYS].join("/")}\uFF09`);
20210
21274
  }
20211
21275
  }
20212
21276
  const declaredType = String(field.type ?? "");
20213
21277
  const type2 = SOMA_DATA_FIELD_TYPE_ALIASES[declaredType] ?? declaredType;
20214
21278
  if (!FIELD_TYPES.has(declaredType)) {
20215
- fail2(
21279
+ fail(
20216
21280
  `\u5B57\u6BB5 ${objectName}.${fieldName} \u7684 type "${declaredType}" \u975E\u6CD5\uFF08\u5C01\u95ED\u96C6\uFF1A${[...FIELD_TYPES].join("/")}\uFF09`
20217
21281
  );
20218
21282
  }
20219
21283
  if (type2 === "enum") {
20220
21284
  const values = field.values;
20221
21285
  if (values === null || typeof values !== "object" || Array.isArray(values) || Object.keys(values).length === 0) {
20222
- fail2(`\u5B57\u6BB5 ${objectName}.${fieldName} \u662F enum\uFF0C\u5FC5\u987B\u63D0\u4F9B\u975E\u7A7A values \u6620\u5C04\uFF08\u5B83\u540C\u65F6\u662F\u7FFB\u8BD1\u8868\u4E0E\u9009\u9879\u8868\uFF09`);
21286
+ fail(`\u5B57\u6BB5 ${objectName}.${fieldName} \u662F enum\uFF0C\u5FC5\u987B\u63D0\u4F9B\u975E\u7A7A values \u6620\u5C04\uFF08\u5B83\u540C\u65F6\u662F\u7FFB\u8BD1\u8868\u4E0E\u9009\u9879\u8868\uFF09`);
20223
21287
  }
20224
21288
  }
21289
+ if (field.values !== void 0 && (field.values === null || typeof field.values !== "object" || Array.isArray(field.values))) {
21290
+ fail(`\u5B57\u6BB5 ${objectName}.${fieldName} \u7684 values \u5FC5\u987B\u662F\u6620\u5C04\uFF08\u503C \u2192 \u663E\u793A\u6587\u6848\uFF09`);
21291
+ }
20225
21292
  const permission = field.permission === void 0 ? "r" : String(field.permission);
20226
21293
  if (permission !== "r" && permission !== "w") {
20227
- fail2(`\u5B57\u6BB5 ${objectName}.${fieldName} \u7684 permission \u53EA\u80FD\u662F r \u6216 w`);
21294
+ fail(`\u5B57\u6BB5 ${objectName}.${fieldName} \u7684 permission \u53EA\u80FD\u662F r \u6216 w`);
20228
21295
  }
20229
21296
  if (field.rules !== void 0 && !Array.isArray(field.rules)) {
20230
- fail2(`\u5B57\u6BB5 ${objectName}.${fieldName} \u7684 rules \u5FC5\u987B\u662F\u6570\u7EC4`);
21297
+ fail(`\u5B57\u6BB5 ${objectName}.${fieldName} \u7684 rules \u5FC5\u987B\u662F\u6570\u7EC4`);
21298
+ }
21299
+ (field.rules ?? []).forEach((rule, index) => {
21300
+ if (rule === null || typeof rule !== "object" || Array.isArray(rule)) {
21301
+ fail(`\u5B57\u6BB5 ${objectName}.${fieldName} \u7684 rules[${index}] \u5FC5\u987B\u662F\u6620\u5C04\uFF08\u4E00\u4E2A\u6761\u4EF6 + message\uFF09`);
21302
+ }
21303
+ const message = rule.message;
21304
+ if (typeof message !== "string" || message.trim() === "") {
21305
+ fail(
21306
+ `\u5B57\u6BB5 ${objectName}.${fieldName} \u7684 rules[${index}] \u7F3A\u5C11 message\u2014\u2014\u6570\u636E\u5BF9\u8C61\u5C42\u8981\u6C42\u6BCF\u6761\u89C4\u5219\u90FD\u5E26\u6821\u9A8C\u4E0D\u901A\u8FC7\u65F6\u7684\u63D0\u793A\u6587\u6848\uFF0C\u5982 { max_len: 200, message: \u5907\u6CE8\u6700\u591A 200 \u5B57 }`
21307
+ );
21308
+ }
21309
+ });
21310
+ if (field.modifies !== void 0 && (typeof field.modifies !== "string" || field.modifies.trim() === "")) {
21311
+ fail(`\u5B57\u6BB5 ${objectName}.${fieldName} \u7684 modifies \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u6BB5\u540D`);
20231
21312
  }
20232
21313
  return {
20233
21314
  type: type2,
20234
21315
  permission,
20235
21316
  ...field.name !== void 0 ? { name: String(field.name) } : {},
20236
21317
  ...field.values ? { values: field.values } : {},
20237
- ...field.rules ? { rules: field.rules } : {}
21318
+ ...field.rules ? { rules: field.rules } : {},
21319
+ ...field.modifies !== void 0 ? { modifies: String(field.modifies) } : {}
20238
21320
  };
20239
21321
  }
20240
- function parseEventSection(raw2, blockId, scope, fail2) {
21322
+ function parseEventSection(raw2, blockId, scope, fail) {
20241
21323
  const actions = /* @__PURE__ */ new Map();
20242
21324
  const emitRoutes = {};
20243
21325
  if (raw2 === void 0) return { actions, emitRoutes };
20244
21326
  if (raw2 === null || typeof raw2 !== "object" || Array.isArray(raw2)) {
20245
- fail2("event \u6BB5\u5FC5\u987B\u662F\u6620\u5C04\uFF08\u5B50\u952E actions / on\uFF09");
21327
+ fail("event \u6BB5\u5FC5\u987B\u662F\u6620\u5C04\uFF08\u5B50\u952E actions / on\uFF09");
20246
21328
  }
20247
21329
  const section = raw2;
20248
21330
  for (const key of Object.keys(section)) {
20249
21331
  if (!EVENT_KEYS.has(key)) {
20250
- fail2(`event \u6BB5\u4E0D\u652F\u6301\u5B50\u952E "${key}"\uFF08\u53EF\u7528\uFF1Aactions / on\uFF09\u2014\u2014\u5B9A\u4E49\u4E0E\u8DEF\u7531\u5206\u5F00\u4F4F\uFF0C\u4E0D\u9760\u503C\u5F62\u72B6\u731C`);
21332
+ fail(`event \u6BB5\u4E0D\u652F\u6301\u5B50\u952E "${key}"\uFF08\u53EF\u7528\uFF1Aactions / on\uFF09\u2014\u2014\u5B9A\u4E49\u4E0E\u8DEF\u7531\u5206\u5F00\u4F4F\uFF0C\u4E0D\u9760\u503C\u5F62\u72B6\u731C`);
20251
21333
  }
20252
21334
  }
20253
21335
  for (const [id, actionRaw] of Object.entries(section.actions ?? {})) {
20254
21336
  if (actionRaw === null || typeof actionRaw !== "object" || Array.isArray(actionRaw)) {
20255
- fail2(`event.actions.${id} \u5FC5\u987B\u662F\u6620\u5C04`);
21337
+ fail(`event.actions.${id} \u5FC5\u987B\u662F\u6620\u5C04`);
20256
21338
  }
20257
21339
  const action = actionRaw;
20258
21340
  for (const key of Object.keys(action)) {
20259
21341
  if (!ACTION_KEYS.has(key)) {
20260
- fail2(`\u52A8\u4F5C ${id} \u4E0D\u652F\u6301\u5B57\u6BB5 "${key}"\uFF08\u53EF\u7528\uFF1A${[...ACTION_KEYS].join("/")}\uFF09`);
21342
+ fail(`\u52A8\u4F5C ${id} \u4E0D\u652F\u6301\u5B57\u6BB5 "${key}"\uFF08\u53EF\u7528\uFF1A${[...ACTION_KEYS].join("/")}\uFF09`);
20261
21343
  }
20262
21344
  }
20263
- if (action.label === void 0) fail2(`\u52A8\u4F5C ${id} \u7F3A\u5C11 label`);
21345
+ if (action.label === void 0) fail(`\u52A8\u4F5C ${id} \u7F3A\u5C11 label`);
20264
21346
  actions.set(id, {
20265
21347
  id,
20266
21348
  label: String(action.label),
@@ -20275,7 +21357,7 @@ function parseEventSection(raw2, blockId, scope, fail2) {
20275
21357
  }
20276
21358
  for (const [emitName, expr] of Object.entries(section.on ?? {})) {
20277
21359
  if (emitName.includes(".")) {
20278
- fail2(
21360
+ fail(
20279
21361
  `event.on \u7684\u952E "${emitName}" \u542B\u70B9\u53F7\u2014\u2014\u7EC4\u4EF6\u5757\u53EA\u8BA2\u9605\u672C\u5B9E\u4F8B\u7684\u5951\u7EA6 emit\uFF08\u76F4\u63A5\u5199 emit \u540D\uFF09\uFF0CDOM \u4E8B\u4EF6\u5199\u5728 page \u5757\u7684 event.on`
20280
21362
  );
20281
21363
  }
@@ -20354,6 +21436,13 @@ function compileSomaBlocks(input) {
20354
21436
  for (const [name, decl] of Object.entries(page.dataRaw ?? {})) {
20355
21437
  data[name] = decl;
20356
21438
  }
21439
+ const dataOwners = /* @__PURE__ */ new Map();
21440
+ for (const name of Object.keys(page.dataRaw ?? {})) {
21441
+ dataOwners.set(name, "page \u5757 data: \u91CC\u7684\u540C\u540D\u5BF9\u8C61");
21442
+ }
21443
+ for (const name of Object.keys(page.surfaceRaw ?? {})) {
21444
+ if (!dataOwners.has(name)) dataOwners.set(name, "page \u5757 objects: \u91CC\u7684\u540C\u540D\u5BF9\u8C61");
21445
+ }
20357
21446
  const blocks = /* @__PURE__ */ new Map();
20358
21447
  for (const raw2 of rawBlocks) {
20359
21448
  if (raw2.blockId === PAGE_BLOCK_ID) continue;
@@ -20362,32 +21451,78 @@ function compileSomaBlocks(input) {
20362
21451
  blockId: raw2.blockId,
20363
21452
  body: raw2.body,
20364
21453
  ...info?.component ? { htmlComponent: info.component } : {},
20365
- rowVars: rowVarsFor(raw2.blockId, htmlIndex, ui)
21454
+ rowVars: rowVarsFor(raw2.blockId, htmlIndex, ui),
21455
+ inRowTemplate: info?.inRowTemplate === true
20366
21456
  });
20367
21457
  blocks.set(raw2.blockId, ast);
20368
21458
  attachInstance(ui, raw2.blockId, ast, htmlIndex);
20369
21459
  for (const [emitName, expr] of Object.entries(ast.emitRoutes)) {
20370
21460
  event[`${raw2.blockId}.${emitName}`] = expr;
20371
21461
  }
21462
+ const flatNames = new Map(ast.dataObjects.map((object) => [object.localName, object.fullName]));
20372
21463
  for (const object of ast.dataObjects) {
20373
- data[object.fullName] = {
20374
- ...object.from ? { from: object.from } : {},
20375
- ...object.save ? { write: normalizeSave(object.save) } : {},
20376
- ...object.refreshMs !== void 0 ? { refreshMs: object.refreshMs } : {},
20377
- ...object.reloadOn ? { reloadOn: object.reloadOn } : {},
20378
- ...object.fields ? { fields: object.fields } : {}
20379
- };
21464
+ const owner = dataOwners.get(object.fullName);
21465
+ if (owner) {
21466
+ throw new SomaBlockParseError(
21467
+ `\u79C1\u6709\u6570\u636E\u5BF9\u8C61 "${object.localName}" \u7684\u5168\u5C40\u540D "${object.fullName}" \u4E0E ${owner} \u649E\u540D\u2014\u2014\u4E24\u8005\u4F1A\u843D\u5230\u540C\u4E00\u4E2A page.data \u952E\u4E0A\uFF0C\u540E\u5199\u7684\u9759\u9ED8\u76D6\u6389\u5148\u5199\u7684\uFF1B\u8BF7\u7ED9\u5176\u4E2D\u4E00\u65B9\u6539\u540D`,
21468
+ raw2.blockId
21469
+ );
21470
+ }
21471
+ dataOwners.set(object.fullName, `\u5757 "${raw2.blockId}" \u7684\u79C1\u6709\u5BF9\u8C61 "${object.localName}"`);
21472
+ data[object.fullName] = toDataObjectConfig(object, flatNames, raw2.blockId);
20380
21473
  }
20381
21474
  }
20382
- return { ui, event, data, blocks, htmlIndex };
21475
+ return {
21476
+ ui,
21477
+ event,
21478
+ data,
21479
+ ...page.surfaceRaw ? { surface: page.surfaceRaw } : {},
21480
+ blocks,
21481
+ htmlIndex
21482
+ };
21483
+ }
21484
+ function toDataObjectConfig(object, flatNames, blockId) {
21485
+ if (!object.from) {
21486
+ throw new SomaBlockParseError(
21487
+ `\u79C1\u6709\u6570\u636E\u5BF9\u8C61 "${object.localName}" \u7F3A\u5C11 from\u2014\u2014\u6570\u636E\u5BF9\u8C61\u5C42\u7684\u5BF9\u8C61\u5FC5\u987B\u6709\u53D6\u6570\u6765\u6E90\uFF08\u5757\u58F0\u660E\u6CA1\u6709 mock \u6837\u672C\u4F4D\uFF09\uFF0C\u8BF7\u8865 from: { api, params }`,
21488
+ blockId
21489
+ );
21490
+ }
21491
+ const params = Object.keys(object.from.params).length > 0 ? { params: object.from.params } : {};
21492
+ return {
21493
+ from: [{ api: object.from.api, ...params }],
21494
+ ...object.save ? { write: normalizeSave(object.save) } : {},
21495
+ ...object.fields ? { fields: toDataFields(object.fields) } : {},
21496
+ // REQ-014 期 2'.1:对象级角色与关系必须一路带下去。
21497
+ // use-parser 已经解析并校验了它们,这里不带 = 「解析了、引擎不消费」——
21498
+ // 那正是 `save:` 归一之前踩过的坑(见下方 normalizeSave 的注释):
21499
+ // 语法检查通过、声明看起来生效了,运行期没有任何东西读它。
21500
+ ...object.roles ? { roles: object.roles } : {},
21501
+ ...object.relations ? { relations: flattenRelationTargets(object.relations, flatNames) } : {}
21502
+ };
21503
+ }
21504
+ function toDataFields(fields) {
21505
+ const result = {};
21506
+ for (const [key, field] of Object.entries(fields)) {
21507
+ const { values, ...rest } = field;
21508
+ result[key] = {
21509
+ ...rest,
21510
+ ...values ? { options: Object.entries(values).map(([value, label]) => ({ key: value, label: String(label) })) } : {}
21511
+ };
21512
+ }
21513
+ return result;
21514
+ }
21515
+ function flattenRelationTargets(relations, flatNames) {
21516
+ return relations.map((relation) => {
21517
+ const flat = flatNames.get(relation.to);
21518
+ return flat ? { ...relation, to: flat } : relation;
21519
+ });
20383
21520
  }
20384
21521
  function normalizeSave(save) {
20385
21522
  return {
20386
21523
  update: { api: save.api, method: save.method },
20387
21524
  ...save.key !== void 0 ? { version: save.key } : {},
20388
- ...save.fields !== void 0 ? { only: save.fields } : {},
20389
- // 触发动作:等 AO 动作编排(S4)接手,届时编译成一条 `do: DATA | commit` 步骤
20390
- trigger: save.trigger
21525
+ ...save.fields !== void 0 ? { only: save.fields } : {}
20391
21526
  };
20392
21527
  }
20393
21528
  function rowVarsFor(blockId, htmlIndex, ui) {
@@ -20445,380 +21580,6 @@ function findListShow(show, listAnchor) {
20445
21580
  }
20446
21581
  return void 0;
20447
21582
  }
20448
-
20449
- // core/build/compiler/html-include-expander.ts
20450
- var SomaHtmlIncludeError = class extends Error {
20451
- constructor(message) {
20452
- super(`[soma-core][HTML include] ${message}`);
20453
- this.name = "SomaHtmlIncludeError";
20454
- }
20455
- };
20456
- var INCLUDE_ATTRIBUTE = /\sdata-soma-include\s*=\s*(["'])([^"']+)\1/i;
20457
- var OPEN_TAG = /<([A-Za-z][A-Za-z0-9:-]*)(\s[^<>]*?)?>/g;
20458
- function expandSomaHtmlIncludes(html, includes) {
20459
- if (!includes || Object.keys(includes).length === 0 || !html.includes("data-soma-include")) {
20460
- return html;
20461
- }
20462
- const expand = (source, chain) => source.replace(
20463
- OPEN_TAG,
20464
- (full, tagName, attributes) => {
20465
- const rawAttributes = attributes ?? "";
20466
- const matched = INCLUDE_ATTRIBUTE.exec(rawAttributes);
20467
- if (!matched) return full;
20468
- const includeName = matched[2];
20469
- if (!Object.prototype.hasOwnProperty.call(includes, includeName)) {
20470
- throw new SomaHtmlIncludeError(`\u627E\u4E0D\u5230\u5171\u4EAB\u7247\u6BB5 "${includeName}"`);
20471
- }
20472
- if (chain.includes(includeName)) {
20473
- throw new SomaHtmlIncludeError(`\u68C0\u6D4B\u5230\u5FAA\u73AF\u5F15\u7528\uFF1A${[...chain, includeName].join(" -> ")}`);
20474
- }
20475
- const withoutInclude = rawAttributes.replace(INCLUDE_ATTRIBUTE, "");
20476
- const expandedFragment = expand(includes[includeName], [...chain, includeName]);
20477
- return `<${tagName}${withoutInclude}>${expandedFragment}`;
20478
- }
20479
- );
20480
- return expand(html, []);
20481
- }
20482
-
20483
- // core/build/layout/constraint-solver.ts
20484
- var CONTAINER_STEPS = [
20485
- ["cqXs", 20],
20486
- ["cqSm", 24],
20487
- ["cqMd", 28],
20488
- ["cqLg", 36],
20489
- ["cqXl", 40],
20490
- ["cq2xl", 48],
20491
- ["cq3xl", 56],
20492
- ["cq4xl", 64]
20493
- ];
20494
- var SomaLayoutConstraintError = class extends Error {
20495
- constructor(message, conflict) {
20496
- super(`[SOMA Layout] ${message}`);
20497
- this.name = "SomaLayoutConstraintError";
20498
- this.conflict = conflict;
20499
- }
20500
- };
20501
- function toRem(literal, containerRem, where) {
20502
- const text = String(literal).trim();
20503
- const match = /^(-?\d+(?:\.\d+)?)(rem|%|cqi)$/.exec(text);
20504
- if (!match) {
20505
- throw new SomaLayoutConstraintError(
20506
- `${where} \u7684\u957F\u5EA6 "${text}" \u975E\u6CD5\u2014\u2014\u53EA\u8BA4 rem / % / cqi\uFF08\u5355\u4F4D\u5FC5\u586B\uFF0C\u4E0D\u731C\uFF09`,
20507
- [where, text]
20508
- );
20509
- }
20510
- const value = Number(match[1]);
20511
- if (value < 0) {
20512
- throw new SomaLayoutConstraintError(`${where} \u7684\u957F\u5EA6\u4E0D\u80FD\u662F\u8D1F\u6570\uFF08\u6536\u5230 ${text}\uFF09`, [where, text]);
20513
- }
20514
- return match[2] === "rem" ? value : value / 100 * containerRem;
20515
- }
20516
- function validateConstraint(constraint, path) {
20517
- const names = Object.keys(constraint.nodes ?? {});
20518
- if (names.length === 0) {
20519
- throw new SomaLayoutConstraintError(`${path} \u81F3\u5C11\u8981\u6709\u4E00\u4E2A\u5B50\u9879`, [path, "nodes"]);
20520
- }
20521
- for (const name of names) {
20522
- const node = constraint.nodes[name];
20523
- const at = `${path}.${name}`;
20524
- if (node.priority !== void 0 && !SOMA_LAYOUT_PRIORITIES.includes(node.priority)) {
20525
- throw new SomaLayoutConstraintError(
20526
- `${at}.priority \u53EA\u80FD\u662F ${SOMA_LAYOUT_PRIORITIES.join(" / ")}\uFF08\u6536\u5230 ${node.priority}\uFF09\u2014\u2014\u4F18\u5148\u7EA7\u53EA\u5728\u76F8\u5BF9\u6B21\u5E8F\u4E0A\u6709\u610F\u4E49\uFF0C\u5F00\u653E\u6210\u4EFB\u610F\u6574\u6570\u53EA\u4F1A\u8BA9\u4EBA\u5199\u51FA\u81EA\u5DF1\u4E5F\u8BF4\u4E0D\u6E05\u5DEE\u522B\u7684\u503C`,
20527
- [at, String(node.priority)]
20528
- );
20529
- }
20530
- if (node.sizing === "fixed" && node.width === void 0) {
20531
- throw new SomaLayoutConstraintError(
20532
- `${at} \u662F fixed \u5374\u6CA1\u7ED9 width\u2014\u2014"\u56FA\u5B9A"\u56FA\u5B9A\u5230\u591A\u5C11\u5FC5\u987B\u8BF4\u51FA\u6765`,
20533
- [at, "sizing: fixed"]
20534
- );
20535
- }
20536
- if (node.sizing === "hug" && (node.min !== void 0 || node.max !== void 0)) {
20537
- throw new SomaLayoutConstraintError(
20538
- `${at} \u662F hug\uFF0C\u4E0D\u80FD\u540C\u65F6\u7ED9 min / max\u2014\u2014hug \u7684\u5BBD\u5EA6\u7531\u5185\u5BB9\u51B3\u5B9A\uFF0C\u518D\u52A0\u4E0A\u4E0B\u754C\u7B49\u4E8E\u8BA9\u4E24\u4E2A\u6765\u6E90\u4E89\u540C\u4E00\u4E2A\u6570\u3002\u8981\u5939\u5728\u533A\u95F4\u91CC\u8BF7\u6539\u7528 fill \u6216 fixed`,
20539
- [at, "sizing: hug"]
20540
- );
20541
- }
20542
- if (node.min !== void 0 && node.max !== void 0) {
20543
- const minRem = /rem$/.test(node.min) ? Number.parseFloat(node.min) : NaN;
20544
- const maxRem = /rem$/.test(node.max) ? Number.parseFloat(node.max) : NaN;
20545
- if (Number.isFinite(minRem) && Number.isFinite(maxRem) && minRem > maxRem) {
20546
- throw new SomaLayoutConstraintError(
20547
- `${at} \u7684 min (${node.min}) \u5927\u4E8E max (${node.max})\u2014\u2014\u8FD9\u6761\u7EA6\u675F\u65E0\u89E3`,
20548
- [`${at}.min`, `${at}.max`]
20549
- );
20550
- }
20551
- }
20552
- }
20553
- }
20554
- function solveStep(constraint, containerRem, breakpoint, path) {
20555
- const names = Object.keys(constraint.nodes);
20556
- const gap = constraint.gap === void 0 ? 0 : toRem(constraint.gap, containerRem, `${path}.gap`);
20557
- const available = containerRem - gap * Math.max(0, names.length - 1);
20558
- const at = (name) => `${path}.${name}`;
20559
- const bounds = names.map((name) => {
20560
- const node = constraint.nodes[name];
20561
- const min = node.min === void 0 ? 0 : toRem(node.min, containerRem, `${at(name)}.min`);
20562
- const max = node.max === void 0 ? Number.POSITIVE_INFINITY : toRem(node.max, containerRem, `${at(name)}.max`);
20563
- if (min > max) {
20564
- throw new SomaLayoutConstraintError(
20565
- `${at(name)} \u5728 ${breakpoint}\uFF08\u5BB9\u5668 ${containerRem}rem\uFF09\u6863\u4E0A min (${min}rem) \u5927\u4E8E max (${max}rem)\u2014\u2014\u6DF7\u7528 rem \u4E0E % \u65F6\uFF0C\u4E24\u8005\u7684\u5927\u5C0F\u5173\u7CFB\u4F1A\u968F\u6863\u53D8\u5316\uFF0C\u8FD9\u4E00\u6863\u7FFB\u8FC7\u6765\u4E86`,
20566
- [`${at(name)}.min`, `${at(name)}.max`]
20567
- );
20568
- }
20569
- const base = node.sizing === "fixed" ? toRem(node.width, containerRem, `${at(name)}.width`) : min;
20570
- return {
20571
- name,
20572
- node,
20573
- min,
20574
- max,
20575
- priority: node.priority ?? 500,
20576
- width: Math.min(Math.max(base, min), max)
20577
- };
20578
- });
20579
- let total = bounds.reduce((sum, item) => sum + item.width, 0);
20580
- if (total > available) {
20581
- for (const priority of SOMA_LAYOUT_PRIORITIES) {
20582
- if (total <= available) break;
20583
- if (priority === 1e3) break;
20584
- const group = bounds.filter((item) => item.priority === priority && item.width > item.min);
20585
- const slack = group.reduce((sum, item) => sum + (item.width - item.min), 0);
20586
- if (slack <= 0) continue;
20587
- const need = Math.min(total - available, slack);
20588
- for (const item of group) {
20589
- const share = (item.width - item.min) / slack * need;
20590
- item.width -= share;
20591
- }
20592
- total -= need;
20593
- }
20594
- }
20595
- const wrapped = total > available + 1e-9;
20596
- if (wrapped && (constraint.wrap ?? "none") === "none") {
20597
- const sorted = [...bounds].sort((a, b) => b.min - a.min);
20598
- throw new SomaLayoutConstraintError(
20599
- `${path} \u5728 ${breakpoint}\uFF08\u5BB9\u5668 ${containerRem}rem\uFF09\u6863\u4E0A\u653E\u4E0D\u4E0B\uFF1A\u5404\u9879 min \u4E4B\u548C ${total.toFixed(2)}rem \u5DF2\u8D85\u8FC7\u53EF\u7528 ${available.toFixed(2)}rem\u3002\u6700\u6324\u7684\u4E24\u9879\u662F "${sorted[0]?.name}"(min ${sorted[0]?.min}rem) \u4E0E "${sorted[1]?.name}"(min ${sorted[1]?.min ?? 0}rem)\u3002\u628A\u5176\u4E2D\u4E00\u4E2A\u7684 min \u8C03\u5C0F\uFF0C\u6216\u58F0\u660E wrap: below \u8BA9\u5B83\u4EEC\u5728\u7A84\u6863\u7AD6\u6392\u3002`,
20600
- [at(sorted[0]?.name ?? ""), at(sorted[1]?.name ?? "")]
20601
- );
20602
- }
20603
- if (!wrapped && total < available) {
20604
- for (const priority of SOMA_LAYOUT_PRIORITIES) {
20605
- const rest = available - total;
20606
- if (rest <= 1e-9) break;
20607
- const group = bounds.filter(
20608
- (item) => item.priority === priority && item.node.sizing === "fill" && item.width < item.max
20609
- );
20610
- if (group.length === 0) continue;
20611
- const room = group.reduce((sum, item) => sum + (item.max - item.width), 0);
20612
- const give = Math.min(rest, room);
20613
- for (const item of group) {
20614
- const share = room === Number.POSITIVE_INFINITY ? give / group.length : (item.max - item.width) / room * give;
20615
- item.width += share;
20616
- }
20617
- total += give;
20618
- }
20619
- }
20620
- const widths = {};
20621
- for (const item of bounds) widths[item.name] = round(item.width);
20622
- return { breakpoint, containerRem, widths, wrapped };
20623
- }
20624
- function solveLayout(constraint, path) {
20625
- validateConstraint(constraint, path);
20626
- const solutions = CONTAINER_STEPS.map(
20627
- ([name, rem]) => solveStep(constraint, rem, name, path)
20628
- );
20629
- return { constraint, solutions };
20630
- }
20631
- function round(value) {
20632
- return Math.round(value * 1e4) / 1e4;
20633
- }
20634
-
20635
- // core/build/layout/css-emitter.ts
20636
- var ALIGN_MAIN = {
20637
- space_between: "space-between",
20638
- space_evenly: "space-evenly",
20639
- space_around: "space-around"
20640
- };
20641
- var ALIGN_CROSS = {
20642
- start: "flex-start",
20643
- center: "center",
20644
- end: "flex-end",
20645
- baseline: "baseline"
20646
- };
20647
- function emitLayoutCss(plan, options) {
20648
- const { root } = options;
20649
- const selectorOf = options.selectorOf ?? ((name) => `${root} > [data-soma-slot="${name}"]`);
20650
- const wrap = plan.constraint.wrap ?? "none";
20651
- const align = plan.constraint.align;
20652
- const gap = plan.constraint.gap;
20653
- const containerRule = [
20654
- `${root} {`,
20655
- " display: flex;",
20656
- // 具名容器(§5.4):子孙的 `@container <name> (…)` 靠它寻址
20657
- plan.constraint.container_name === void 0 ? " container-type: inline-size;" : ` container: ${plan.constraint.container_name} / inline-size;`,
20658
- gap === void 0 ? null : ` gap: ${gap};`,
20659
- align !== void 0 && ALIGN_MAIN[align] !== void 0 ? ` justify-content: ${ALIGN_MAIN[align]};` : null,
20660
- align !== void 0 && ALIGN_CROSS[align] !== void 0 ? ` align-items: ${ALIGN_CROSS[align]};` : null,
20661
- wrap === "reel" ? " overflow-inline: auto;" : null,
20662
- "}"
20663
- ].filter((line) => line !== null).join("\n");
20664
- const ruleFor = (index) => {
20665
- const solution = plan.solutions[index];
20666
- const lines = [];
20667
- if (solution.wrapped && wrap === "below") {
20668
- lines.push(`${root} { flex-wrap: wrap; }`);
20669
- } else if (wrap !== "reel") {
20670
- lines.push(`${root} { flex-wrap: nowrap; }`);
20671
- }
20672
- for (const [name, width] of Object.entries(solution.widths)) {
20673
- const node = plan.constraint.nodes[name];
20674
- const selector = selectorOf(name);
20675
- if (node.sizing === "hug") {
20676
- lines.push(`${selector} { flex: 0 0 auto; }`);
20677
- continue;
20678
- }
20679
- const basis = `${width}rem`;
20680
- const grow = node.sizing === "fill" ? "1 1" : "0 0";
20681
- const bounds = [
20682
- node.min === void 0 ? null : `min-inline-size: ${node.min};`,
20683
- node.max === void 0 ? null : `max-inline-size: ${node.max};`
20684
- ].filter((part) => part !== null).join(" ");
20685
- const declaration = solution.wrapped && wrap === "below" ? `flex: 1 1 100%;` : `flex: ${grow} ${basis};`;
20686
- lines.push(`${selector} { ${declaration}${bounds === "" ? "" : ` ${bounds}`} }`);
20687
- }
20688
- return lines.join("\n");
20689
- };
20690
- const blocks = [containerRule, ruleFor(0)];
20691
- for (let index = 1; index < plan.solutions.length; index += 1) {
20692
- const [, rem] = CONTAINER_STEPS[index];
20693
- const body = ruleFor(index);
20694
- if (body === ruleFor(index - 1)) continue;
20695
- blocks.push(`@container (min-width: ${rem}rem) {
20696
- ${indent(body)}
20697
- }`);
20698
- }
20699
- return blocks.join("\n");
20700
- }
20701
- function indent(text) {
20702
- return text.split("\n").map((line) => line === "" ? line : ` ${line}`).join("\n");
20703
- }
20704
-
20705
- // core/build/layout/page-layout.ts
20706
- var SomaPageLayoutError = class extends Error {
20707
- constructor(message, path) {
20708
- super(`[soma-core][\u5E03\u5C40] ${message}\uFF08${path}\uFF09`);
20709
- this.path = path;
20710
- this.name = "SomaPageLayoutError";
20711
- }
20712
- };
20713
- var fail = (message, path) => {
20714
- throw new SomaPageLayoutError(message, path);
20715
- };
20716
- function anchorSelector(hostClass, anchor) {
20717
- return `[data-soma-host="${hostClass}"] [data-soma-id="${anchor}"]`;
20718
- }
20719
- function compilePageLayout(input) {
20720
- const { raw: raw2, htmlIndex, hostClass } = input;
20721
- if (!raw2 || typeof raw2 !== "object" || Array.isArray(raw2)) {
20722
- fail("layout \u5FC5\u987B\u662F\u6620\u5C04\uFF1A{ <\u951A\u70B9id>: { gap, wrap, <\u5B50\u9879>: { sizing, \u2026 } } }", "layout");
20723
- }
20724
- const constraints = {};
20725
- const chunks = [];
20726
- for (const [anchor, spec] of Object.entries(raw2)) {
20727
- const path = `layout.${anchor}`;
20728
- if (!htmlIndex.anchors.has(anchor)) {
20729
- fail(`\u951A\u70B9 "${anchor}" \u4E0D\u5B58\u5728\u4E8E HTML\uFF08data-soma-id\uFF09`, path);
20730
- }
20731
- const constraint = parseLayoutConstraint({ raw: spec, path }, { fail });
20732
- for (const child of Object.keys(constraint.nodes)) {
20733
- if (!htmlIndex.anchors.has(child)) {
20734
- fail(`\u5B50\u9879 "${child}" \u4E0D\u662F\u9875\u9762\u951A\u70B9\u2014\u2014\u5B83\u5FC5\u987B\u662F "${anchor}" \u7684\u76F4\u63A5\u5B50\u5143\u7D20\u4E14\u5E26 data-soma-id`, `${path}.${child}`);
20735
- }
20736
- }
20737
- const plan = solveLayout(constraint, path);
20738
- const root = anchorSelector(hostClass, anchor);
20739
- chunks.push(emitLayoutCss(plan, {
20740
- root,
20741
- selectorOf: (name) => `${root} > [data-soma-id="${name}"]`
20742
- }));
20743
- constraints[anchor] = constraint;
20744
- }
20745
- return { constraints, css: chunks.join("\n") };
20746
- }
20747
-
20748
- // core/build/compiler/page-declaration-compiler.ts
20749
- var dump2 = (value) => yaml.dump(value, { lineWidth: 120, noRefs: true, quotingType: '"' });
20750
- function compilePageDeclaration(input) {
20751
- const eventYaml = input.eventYaml ?? "";
20752
- const styleYaml = input.styleYaml ?? "";
20753
- const dataYaml = input.dataYaml ?? "";
20754
- const sidecars = [
20755
- eventYaml.trim() ? "eventYaml / *_event.yaml" : "",
20756
- styleYaml.trim() ? "styleYaml / *_style.yaml" : "",
20757
- dataYaml.trim() ? "dataYaml / *_data.yaml" : ""
20758
- ].filter(Boolean);
20759
- if (sidecars.length > 0) {
20760
- throw new Error(
20761
- `[soma-core][SOMA DSL] \u9875\u9762\u4FA7\u8F66\u5DF2\u9000\u5F79\uFF1A${sidecars.join("\u3001")}\u3002\u4E8B\u4EF6\u3001\u6837\u5F0F\u72B6\u6001\u4E0E\u6570\u636E\u5BF9\u8C61\u5FC5\u987B\u5199\u8FDB\u540C\u4E00\u4EFD SOMA DSL \u58F0\u660E\u3002`
20762
- );
20763
- }
20764
- const compiled = compileSomaBlocks({
20765
- html: expandSomaHtmlIncludes(input.html, input.includes),
20766
- uiYamlRaw: input.uiYaml,
20767
- ...input.externalBlocks ? { externalBlocks: input.externalBlocks } : {}
20768
- });
20769
- const eventBundle = compileEventConfigFromRaw(compiled.event);
20770
- const embeddedDataYaml = Object.keys(compiled.data).length > 0 ? dump2({ data: compiled.data }) : "";
20771
- if (compiled.ui.state !== void 0) {
20772
- compiled.ui.state = parsePageState(
20773
- {
20774
- raw: compiled.ui.state,
20775
- objectNames: Object.keys(compiled.data),
20776
- anchorIds: [...compiled.htmlIndex.anchors.keys()],
20777
- path: "page.state"
20778
- },
20779
- { fail(message, path) {
20780
- throw new Error(`[soma-core][\u9875\u9762\u6001] ${message}\uFF08${path}\uFF09`);
20781
- } }
20782
- );
20783
- }
20784
- const layout = compiled.ui.layout !== void 0 ? compilePageLayout({ raw: compiled.ui.layout, htmlIndex: compiled.htmlIndex, hostClass: compiled.ui.bind.obj }) : null;
20785
- if (layout) compiled.ui.layout = layout.constraints;
20786
- const { layout: _layoutDecl, ...runtimeUi } = compiled.ui;
20787
- const runtimeUiWithCss = layout ? { ...runtimeUi, layout_css: layout.css } : runtimeUi;
20788
- return {
20789
- uiConfig: layout ? { ...compiled.ui, layoutCss: layout.css } : compiled.ui,
20790
- eventConfig: eventBundle.events,
20791
- triggers: eventBundle.triggers,
20792
- timers: eventBundle.timers,
20793
- ...embeddedDataYaml ? { dataConfig: compileDataConfig(embeddedDataYaml) } : {},
20794
- ...layout ? { layoutCss: layout.css } : {},
20795
- runtimeAssets: {
20796
- uiYaml: dump2(runtimeUiWithCss),
20797
- eventYaml: Object.keys(compiled.event).length > 0 ? dump2(compiled.event) : "",
20798
- styleYaml: "",
20799
- ...embeddedDataYaml ? { dataYaml: embeddedDataYaml } : {}
20800
- }
20801
- };
20802
- }
20803
-
20804
- // core/build/compiler/page-assets.ts
20805
- function compilePageAssets(assets) {
20806
- const compiled = compilePageDeclaration({
20807
- html: assets.html ?? "",
20808
- uiYaml: assets.uiYaml ?? "",
20809
- ...assets.eventYaml ? { eventYaml: assets.eventYaml } : {},
20810
- ...assets.styleYaml ? { styleYaml: assets.styleYaml } : {},
20811
- ...assets.dataYaml ? { dataYaml: assets.dataYaml } : {},
20812
- ...assets.declarationBlocks ? { externalBlocks: assets.declarationBlocks } : {}
20813
- });
20814
- return {
20815
- ...assets,
20816
- uiYaml: compiled.runtimeAssets.uiYaml,
20817
- eventYaml: compiled.runtimeAssets.eventYaml,
20818
- styleYaml: "",
20819
- ...compiled.runtimeAssets.dataYaml ? { dataYaml: compiled.runtimeAssets.dataYaml } : { dataYaml: void 0 }
20820
- };
20821
- }
20822
21583
  // Annotate the CommonJS export names for ESM import in node:
20823
21584
  0 && (module.exports = {
20824
21585
  CALC_FUNCTIONS,
@@ -20839,6 +21600,8 @@ function compilePageAssets(assets) {
20839
21600
  SOMA_AGGREGATE_FNS,
20840
21601
  SOMA_DATA_FIELD_TYPES,
20841
21602
  SOMA_DATA_FIELD_TYPE_ALIASES,
21603
+ SOMA_DATA_OBJECT_ROLES,
21604
+ SOMA_DATA_RELATION_CARDINALITIES,
20842
21605
  SOMA_DEFAULT_HYSTERESIS,
20843
21606
  SOMA_FIELD_DISPLAYS,
20844
21607
  SOMA_FIELD_PATTERNS,
@@ -20898,7 +21661,6 @@ function compilePageAssets(assets) {
20898
21661
  collectPredicateFields,
20899
21662
  compileAdaptive,
20900
21663
  compileFieldSugar,
20901
- compilePageAssets,
20902
21664
  compileSomaBlocks,
20903
21665
  componentTokenPrefix,
20904
21666
  componentTokenVar,
@@ -20914,6 +21676,7 @@ function compilePageAssets(assets) {
20914
21676
  createWindow,
20915
21677
  decodePageState,
20916
21678
  defaultPipeRegistry,
21679
+ deriveContractPreviewSample,
20917
21680
  deriveContractSample,
20918
21681
  deriveFieldSample,
20919
21682
  deriveKeyboardMatrix,