soma-core 2.0.0 → 2.1.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 (1103) hide show
  1. package/README.md +28 -19
  2. package/bin/codegen.cjs +191 -0
  3. package/bin/eject.cjs +25 -12
  4. package/bin/service-codegen.cjs +98 -0
  5. package/bin/soma-lsp.cjs +140 -23
  6. package/bin/soma-runtime.cjs +75 -0
  7. package/bin/soma-sync-runtime.cjs +130 -0
  8. package/bin/soma.cjs +200 -13
  9. package/bin/soma.ts +170 -0
  10. package/core/build/compiler/flat-page.ts +305 -0
  11. package/core/build/compiler/full-manifest-builder.ts +68 -27
  12. package/core/build/compiler/html-index.ts +169 -0
  13. package/core/build/compiler/page-assets.ts +30 -7
  14. package/core/build/compiler/page-base-resolver.ts +11 -0
  15. package/core/build/compiler/page-declaration-compiler.ts +264 -226
  16. package/core/build/compiler/rollup-plugin-soma.ts +7 -2
  17. package/core/build/compiler/soma-manifest-webpack-plugin.js +114 -229
  18. package/core/build/compiler/soma-precompile.js +3733 -1892
  19. package/core/build/compiler/soma-precompile.ts +15 -20
  20. package/core/build/compiler/soma-rspack-yaml-loader.js +4 -3
  21. package/core/build/compiler/soma-webpack-loader.js +8 -4
  22. package/core/build/compiler/vite-plugin-soma.ts +8 -8
  23. package/core/build/component/component-graph.ts +1 -1
  24. package/core/build/component-tree/artifact-codec.ts +9 -42
  25. package/core/build/component-tree/collection-binding-lowerer.ts +1 -1
  26. package/core/build/component-tree/definition-preparation.ts +4 -5
  27. package/core/build/component-tree/parser.ts +1 -1
  28. package/core/build/component-tree/registry-snapshot.ts +45 -10
  29. package/core/build/component-tree/source-preflight.ts +2 -90
  30. package/core/build/component-tree/structure-topology.ts +1 -1
  31. package/core/build/eject/plan-eject.ts +9 -11
  32. package/core/build/lsp/component-tree-service.ts +4 -1
  33. package/core/build/lsp/component-tree.cjs +1 -1
  34. package/core/build/lsp/cross-file-diagnostics.cjs +5 -21
  35. package/core/build/lsp/soma-declaration.cjs +45 -47
  36. package/core/build/lsp/std-completion.generated.json +26 -0
  37. package/core/build/lsp/ui-yaml-completion.cjs +25 -37
  38. package/core/client/a11y/a11y-config.ts +50 -0
  39. package/core/client/a11y/announcer.ts +140 -0
  40. package/core/client/a11y/dom-id.ts +31 -0
  41. package/core/client/a11y/index.ts +40 -0
  42. package/core/client/a11y/motion-hook.ts +48 -0
  43. package/core/client/a11y/motion.ts +95 -0
  44. package/core/client/base/SomaPageRootBase.ts +44 -2
  45. package/core/client/base/index.ts +10 -8
  46. package/core/client/behavior/adapter-collection.ts +65 -0
  47. package/core/client/behavior/adapter-popper.ts +60 -0
  48. package/core/client/behavior/aria-hide-outside.ts +144 -0
  49. package/core/client/behavior/css-escape.ts +51 -0
  50. package/core/client/behavior/focus-scope.ts +433 -0
  51. package/core/client/behavior/focus-traversal.ts +68 -0
  52. package/core/client/behavior/index.ts +109 -0
  53. package/core/client/behavior/layer-stack.ts +234 -0
  54. package/core/client/behavior/overlay-host/index.ts +192 -0
  55. package/core/client/behavior/overlay-host/port.ts +76 -0
  56. package/core/client/behavior/overlay-wiring.ts +186 -0
  57. package/core/client/behavior/port.ts +85 -0
  58. package/core/client/behavior/positioner.ts +32 -0
  59. package/core/client/behavior/presence.ts +197 -0
  60. package/core/client/behavior/zag/adapter-vanilla.ts +96 -0
  61. package/core/client/behavior/zag/layer-bridge.ts +51 -0
  62. package/core/client/behavior/zag/machine-host.ts +69 -0
  63. package/core/client/behavior/zag/machines.ts +52 -0
  64. package/core/client/compiler/manifest-compiler.ts +33 -70
  65. package/core/client/component/adapter/adapt.ts +79 -0
  66. package/core/client/component/adapter/index.ts +3 -0
  67. package/core/client/component/adapter/types.ts +37 -0
  68. package/core/client/component/adapter/web-component.ts +130 -0
  69. package/core/client/component/component-defaults.ts +1 -1
  70. package/core/client/component/component-definition.types.ts +27 -5
  71. package/core/client/component/component-expander.ts +24 -16
  72. package/core/client/component/component-manager.ts +245 -814
  73. package/core/client/component/component-pack.ts +58 -216
  74. package/core/client/component/component-registry.ts +53 -29
  75. package/core/client/component/projection-admission.ts +63 -0
  76. package/core/client/component/projection-registry.ts +653 -0
  77. package/core/client/component/projection.types.ts +48 -0
  78. package/core/client/component/region-unavailable.ts +37 -0
  79. package/core/client/component/scoped-adapter.ts +3 -3
  80. package/core/client/component/structure-adapter.ts +93 -8
  81. package/core/client/container/IContainerAdapter.ts +4 -3
  82. package/core/client/container/SomaContainerAdapter.ts +22 -123
  83. package/core/client/data/collection-payload.ts +2 -0
  84. package/core/client/data/data-object-resolver.ts +827 -330
  85. package/core/client/data/data-polling.ts +110 -0
  86. package/core/client/data/data-subscriptions.ts +98 -0
  87. package/core/client/data/data-write-actions.ts +118 -0
  88. package/core/client/data/envelope-failure.ts +48 -0
  89. package/core/client/data/format-config.ts +62 -0
  90. package/core/client/data/region-scope-port.ts +265 -0
  91. package/core/client/data/region-scope-views.ts +96 -0
  92. package/core/client/data/role-gate.ts +44 -0
  93. package/core/client/data/write-outcome-store.ts +101 -0
  94. package/core/client/data/write-outcome.ts +175 -0
  95. package/core/client/engine/asset-resolver.ts +12 -21
  96. package/core/client/engine/dom-renderer.ts +85 -460
  97. package/core/client/engine/event-engine.ts +349 -323
  98. package/core/client/engine/locale-text-binder.ts +168 -0
  99. package/core/client/engine/property-watcher.ts +18 -164
  100. package/core/client/engine/reactive-proxy.ts +23 -194
  101. package/core/client/engine/render-engine.ts +16 -118
  102. package/core/client/engine/row-range.ts +11 -0
  103. package/core/client/engine/runtime-builder.ts +10 -13
  104. package/core/client/engine/scope-resolver.ts +3 -3
  105. package/core/client/engine/soma-bootstrap.ts +1238 -323
  106. package/core/client/engine/step-runner.ts +90 -12
  107. package/core/client/engine/style-binder.ts +2 -162
  108. package/core/client/engine/timer-engine.ts +2 -1
  109. package/core/client/engines/chart/adapter-echarts.ts +144 -0
  110. package/core/client/engines/chart/echarts-subpaths.d.ts +3 -0
  111. package/core/client/engines/chart/index.ts +90 -0
  112. package/core/client/engines/chart/kind-modules.ts +74 -0
  113. package/core/client/engines/chart/port.ts +44 -0
  114. package/core/client/engines/diff/adapter-jsdiff.ts +35 -0
  115. package/core/client/engines/diff/index.ts +33 -0
  116. package/core/client/engines/diff/port.ts +26 -0
  117. package/core/client/engines/dnd/adapter-pragmatic.ts +159 -0
  118. package/core/client/engines/dnd/index.ts +67 -0
  119. package/core/client/engines/dnd/port.ts +45 -0
  120. package/core/client/engines/engine-adapters.ts +29 -0
  121. package/core/client/engines/load.ts +44 -0
  122. package/core/client/engines/qrcode/adapter-qrcode-generator.ts +52 -0
  123. package/core/client/engines/qrcode/index.ts +30 -0
  124. package/core/client/engines/qrcode/port.ts +27 -0
  125. package/core/client/engines/table/adapter-tanstack.ts +132 -0
  126. package/core/client/engines/table/index.ts +80 -0
  127. package/core/client/engines/table/port.ts +55 -0
  128. package/core/client/engines/temporal/adapter-polyfill.ts +158 -0
  129. package/core/client/engines/temporal/index.ts +84 -0
  130. package/core/client/engines/temporal/port.ts +53 -0
  131. package/core/client/engines/virtual/adapter-tanstack.ts +133 -0
  132. package/core/client/engines/virtual/index.ts +43 -0
  133. package/core/client/engines/virtual/port.ts +43 -0
  134. package/core/client/format/formatter.ts +32 -0
  135. package/core/client/format/index.ts +26 -0
  136. package/core/client/format/zoned.ts +10 -0
  137. package/core/client/host-bridge/index.ts +17 -0
  138. package/core/client/host-bridge/load-host-domain-class.ts +15 -4
  139. package/core/client/host-bridge/resolve-host-bootstrap.ts +63 -11
  140. package/core/client/host-bridge/soma-app-host.stub.ts +3 -0
  141. package/core/client/host-bridge/soma-bootstrap-from-app.ts +25 -0
  142. package/core/client/infra/auth/IAuthService.ts +18 -13
  143. package/core/client/infra/auth/TokenAuthService.ts +126 -112
  144. package/core/client/infra/config/SomaConfig.ts +16 -0
  145. package/core/client/infra/config/feature-flags.ts +28 -0
  146. package/core/client/infra/http/IHttpClient.ts +2 -0
  147. package/core/client/infra/http/SomaHttpService.ts +1 -0
  148. package/core/client/infra/i18n/II18n.ts +23 -6
  149. package/core/client/infra/i18n/builtin-locale.ts +31 -0
  150. package/core/client/infra/i18n/index.ts +4 -0
  151. package/core/client/infra/i18n/interpolate.ts +28 -0
  152. package/core/client/infra/i18n/locale-catalog.ts +233 -0
  153. package/core/client/infra/i18n/pack-locales.ts +117 -0
  154. package/core/client/infra/identity/identity-port.ts +178 -0
  155. package/core/client/infra/notify/DefaultNotifyService.ts +86 -31
  156. package/core/client/infra/notify/INotifyService.ts +2 -14
  157. package/core/client/infra/notify/notify-declaration.ts +37 -0
  158. package/core/client/infra/permission/SomaPermission.ts +58 -48
  159. package/core/client/infra/router/IRouter.ts +24 -19
  160. package/core/client/infra/router/SomaRouter.ts +78 -66
  161. package/core/client/keyboard/collection.ts +197 -0
  162. package/core/client/keyboard/compose-keys.ts +68 -0
  163. package/core/client/keyboard/cursor.ts +117 -0
  164. package/core/client/keyboard/delegate.ts +195 -0
  165. package/core/client/keyboard/ime.ts +8 -0
  166. package/core/client/keyboard/index.ts +73 -0
  167. package/core/client/keyboard/intents.ts +60 -0
  168. package/core/client/keyboard/matrix.ts +269 -0
  169. package/core/client/keyboard/submit.ts +30 -0
  170. package/core/client/keyboard/typeahead.ts +203 -0
  171. package/core/client/keyboard/wiring.ts +324 -0
  172. package/core/client/middleware/createPermissionMiddleware.ts +20 -11
  173. package/core/client/mount/domain-rule.ts +43 -0
  174. package/core/client/mount/index.ts +3 -0
  175. package/core/client/mount/mount-page.ts +163 -0
  176. package/core/client/mount/types.ts +93 -0
  177. package/core/client/observability/runtime-observer.ts +136 -0
  178. package/core/client/parser/annotation-extractor.ts +1 -1
  179. package/core/client/parser/confirm-spec.ts +139 -0
  180. package/core/client/parser/data-config-parser.ts +416 -217
  181. package/core/client/parser/duration.ts +2 -16
  182. package/core/client/parser/page-state-parser.ts +59 -64
  183. package/core/client/parser/pipeline-parser.ts +178 -236
  184. package/core/client/parser/style-config-parser.ts +15 -81
  185. package/core/client/parser/subscribe-parser.ts +83 -0
  186. package/core/client/parser/timer-parser.ts +1 -1
  187. package/core/client/parser/trigger-parser.ts +1 -1
  188. package/core/client/parser/ui-config-parser.ts +244 -243
  189. package/core/client/pipes/pipe-registry.ts +304 -76
  190. package/core/client/registry/declaration-renderer.ts +20 -8
  191. package/core/client/registry/page-lifecycle.ts +4 -4
  192. package/core/client/registry/remote-page.ts +4 -4
  193. package/core/client/render-ports/index.ts +18 -0
  194. package/core/client/render-ports/notify-renderer.ts +45 -0
  195. package/core/client/render-ports/region-fallback.ts +8 -0
  196. package/core/client/render-ports/scheduling/prompt-queue.ts +102 -0
  197. package/core/client/render-ports/scheduling/toast-scheduler.ts +253 -0
  198. package/core/client/runtime/SomaRuntimeServices.ts +180 -16
  199. package/core/client/runtime/SomaSnapshotStore.ts +100 -100
  200. package/core/client/runtime/nav-history.ts +147 -0
  201. package/core/client/runtime/nav-port.ts +68 -0
  202. package/core/client/runtime/shortcuts.ts +360 -0
  203. package/core/client/runtime/write-feedback.ts +71 -0
  204. package/core/client/runtime-entry.ts +29 -0
  205. package/core/client/scheduler/SomaScheduler.ts +13 -3
  206. package/core/client/scheduling/flush-scheduler.ts +100 -0
  207. package/core/client/scheduling/index.ts +22 -0
  208. package/core/client/scheduling/observer-pool.ts +109 -0
  209. package/core/client/security/attribute-presence.ts +1 -3
  210. package/core/client/security/html-sanitizer.ts +23 -1
  211. package/core/client/security/url-guard.ts +0 -0
  212. package/core/client/styles/compiled-styles.ts +47 -0
  213. package/core/client/styles/index.ts +10 -0
  214. package/core/client/styles/pack-styles.ts +169 -0
  215. package/core/client/styles/sheet-mount.ts +48 -0
  216. package/core/client/styles/style-features.ts +131 -0
  217. package/core/client/time/clock.ts +36 -0
  218. package/core/client/time/instant.ts +2 -0
  219. package/core/client/url-state/index.ts +15 -0
  220. package/core/client/url-state/page-tabs-controller.ts +47 -0
  221. package/core/client/url-state/state-query-binding.ts +114 -0
  222. package/core/client/url-state/url-state.ts +149 -0
  223. package/core/client/validation/async-check-registry.ts +129 -0
  224. package/core/client/validation/async-rules.ts +259 -0
  225. package/core/client/validation/contract-validator.ts +44 -5
  226. package/core/client/validation/field-rules.ts +49 -0
  227. package/core/client/validation/index.ts +53 -0
  228. package/core/client/validation/object-rules.ts +72 -0
  229. package/core/index.ts +290 -264
  230. package/core/inspect/check-product.ts +542 -0
  231. package/core/inspect/check-runtime.ts +865 -0
  232. package/core/inspect/runtime.ts +98 -0
  233. package/core/page-target/index.ts +9 -0
  234. package/core/page-target/provenance.ts +119 -0
  235. package/core/page-target/slug.ts +7 -0
  236. package/core/page-target/testing/index.ts +329 -0
  237. package/core/page-target/types.ts +279 -0
  238. package/core/predicates-entry.ts +43 -0
  239. package/core/server/api/load-host-service.ts +3 -0
  240. package/core/server/compile-port.ts +18 -0
  241. package/core/server/diagnostic-gate-entry.ts +14 -0
  242. package/core/server/engines/style/candidate-guard.ts +59 -0
  243. package/core/server/engines/style/index.ts +57 -0
  244. package/core/server/engines/style/port.ts +34 -0
  245. package/core/server/engines/style/tailwind-adapter.ts +68 -0
  246. package/core/server/host/content-security-policy.ts +3 -5
  247. package/core/server/host/host-assembly-entry.ts +24 -0
  248. package/core/server/host/host-assembly.ts +267 -0
  249. package/core/server/host/host-caller.ts +52 -0
  250. package/core/server/host/host-response-headers.ts +49 -0
  251. package/core/server/host/invoke-host-request-hook.ts +5 -0
  252. package/core/server/host/locale-yaml.ts +53 -0
  253. package/core/server/host/page-markup-config.ts +13 -0
  254. package/core/server/host/published-page-artifact-cache.ts +355 -124
  255. package/core/server/host/published-page-assets.ts +91 -46
  256. package/core/server/host/resolve-host-request-hook.ts +9 -10
  257. package/core/server/host/resolve-host-tree-context.ts +8 -28
  258. package/core/server/host/server-page-assets.ts +175 -57
  259. package/core/server/host/soma-page-compile.ts +57 -16
  260. package/core/server/host/source-packages.cjs +184 -0
  261. package/core/server/host/source-packages.ts +18 -126
  262. package/core/server/host/virtual-pages.ts +197 -0
  263. package/core/server/index.ts +12 -43
  264. package/core/server/node.ts +52 -0
  265. package/core/server/page-assets.ts +73 -0
  266. package/core/server/page-declaration.ts +83 -7
  267. package/core/server/registry/api-registry-store.ts +17 -28
  268. package/core/server/registry/asset-store.ts +17 -19
  269. package/core/server/registry/batch-publish.ts +38 -0
  270. package/core/server/registry/batch-stage.ts +130 -0
  271. package/core/server/registry/component-supply.ts +31 -0
  272. package/core/server/registry/declaration-precompiler.ts +48 -34
  273. package/core/server/registry/index.ts +78 -1
  274. package/core/server/registry/page-registry-repository.ts +484 -69
  275. package/core/server/registry/page-registry-store.ts +617 -108
  276. package/core/server/registry/publish-asset-pin.ts +22 -20
  277. package/core/server/registry/registry-file-lock.ts +16 -3
  278. package/core/server/registry/registry-subjects.ts +6 -6
  279. package/core/server/registry/registry-write-pipeline.ts +65 -1
  280. package/core/server/registry/request-body-limit.ts +3 -1
  281. package/core/server/registry/rollback-plan.ts +181 -0
  282. package/core/server/registry/services/index.ts +14 -1
  283. package/core/server/registry/services/pages/Get.ts +26 -4
  284. package/core/server/registry/services/pages/Register.ts +29 -7
  285. package/core/server/registry/services/pages/RegisterBatch.ts +68 -0
  286. package/core/server/registry/services/pages/Rollback.ts +14 -4
  287. package/core/server/registry/services/pages/Unregister.ts +2 -1
  288. package/core/server/registry/source/canonical.ts +57 -0
  289. package/core/server/registry/source/errors.ts +81 -0
  290. package/core/server/registry/source/index.ts +49 -0
  291. package/core/server/registry/source/ledger.ts +306 -0
  292. package/core/server/registry/source/snapshot.ts +29 -0
  293. package/core/server/registry/source/source-name.ts +48 -0
  294. package/core/server/registry/source/types.ts +106 -0
  295. package/core/server/registry/source/version-store.ts +349 -0
  296. package/core/server/registry/standard-product.ts +185 -0
  297. package/core/server/registry/validation/compile-gate.ts +39 -50
  298. package/core/server/registry/validation/cross-check.ts +18 -5
  299. package/core/server/registry/validation/declaration-safety-scan.ts +12 -10
  300. package/core/server/registry/validation/region-scopes.ts +50 -0
  301. package/core/server/runtime-space/access-gate.ts +206 -0
  302. package/core/server/runtime-space/advice-log.ts +67 -0
  303. package/core/server/runtime-space/artifact-evict.ts +15 -0
  304. package/core/server/runtime-space/bindings.ts +478 -0
  305. package/core/server/runtime-space/digest.ts +62 -0
  306. package/core/server/runtime-space/dynamic-pages.ts +379 -0
  307. package/core/server/runtime-space/errors.ts +96 -0
  308. package/core/server/runtime-space/gc.ts +116 -0
  309. package/core/server/runtime-space/index.ts +106 -0
  310. package/core/server/runtime-space/inject.ts +497 -0
  311. package/core/server/runtime-space/nav-catalog.ts +140 -0
  312. package/core/server/runtime-space/page-grants.ts +436 -0
  313. package/core/server/runtime-space/prewarm.ts +234 -0
  314. package/core/server/runtime-space/registry-cold-start.ts +69 -0
  315. package/core/server/runtime-space/resolve.ts +538 -0
  316. package/core/server/runtime-space/root.cjs +160 -0
  317. package/core/server/runtime-space/root.ts +26 -0
  318. package/core/server/runtime-space/static-source.ts +85 -0
  319. package/core/server/runtime-space/store.ts +253 -0
  320. package/core/server/runtime-space/submit-steps.ts +412 -0
  321. package/core/server/runtime-space/types.ts +314 -0
  322. package/core/shared/anchor-space.ts +48 -0
  323. package/core/shared/artifact-compatibility.ts +156 -0
  324. package/core/shared/behavior-machine-names.ts +8 -0
  325. package/core/shared/calc/coerce.ts +2 -29
  326. package/core/shared/calc/errors.ts +4 -7
  327. package/core/shared/calc/evaluator.ts +23 -11
  328. package/core/shared/calc/index.ts +3 -4
  329. package/core/shared/calc/lexer.ts +7 -12
  330. package/core/shared/calc/parser.ts +8 -19
  331. package/core/shared/calc/typer.ts +10 -23
  332. package/core/shared/component-tree-artifact.ts +81 -7
  333. package/core/shared/contract-a11y.ts +335 -0
  334. package/core/shared/contract-sections.ts +344 -0
  335. package/core/shared/core-diagnostic-codes.ts +208 -0
  336. package/core/shared/data-declaration-checks.ts +211 -0
  337. package/core/shared/date-parts.ts +2 -0
  338. package/core/shared/declaration-errors.ts +14 -0
  339. package/core/shared/declaration-keys.ts +36 -0
  340. package/core/shared/diagnostic-code-index-entry.ts +14 -0
  341. package/core/shared/diagnostic-gate.ts +139 -0
  342. package/core/shared/engines/engine-error.ts +33 -0
  343. package/core/shared/engines/style/style-engine.types.ts +28 -0
  344. package/core/shared/envelope-text-width.generated.d.mts +19 -0
  345. package/core/shared/envelope-text-width.generated.mjs +413 -0
  346. package/core/shared/fragments-section.ts +10 -0
  347. package/core/shared/generation-diagnostics.ts +58 -0
  348. package/core/shared/generation-error.ts +73 -0
  349. package/core/shared/hook-attributes.ts +159 -0
  350. package/core/shared/inert-data-element.ts +50 -0
  351. package/core/shared/nav-back.ts +120 -0
  352. package/core/shared/page-access-text.ts +7 -0
  353. package/core/shared/page-envelope-runtime.ts +88 -0
  354. package/core/shared/page-envelope.ts +618 -0
  355. package/core/shared/page-scopes.ts +83 -0
  356. package/core/shared/pipeline-error-codes-view.ts +30 -0
  357. package/core/shared/pipeline-limits-view.ts +27 -0
  358. package/core/shared/predicates/index.ts +85 -497
  359. package/core/shared/predicates/relative-window.ts +19 -0
  360. package/core/shared/published-page-route.ts +5 -14
  361. package/core/shared/region-scope-decl.ts +488 -0
  362. package/core/shared/registry-generated/compile-purposes.ts +53 -0
  363. package/core/shared/registry-generated/diagnostic-registry-index.ts +796 -0
  364. package/core/shared/registry-generated/diagnostic-registry.ts +5872 -0
  365. package/core/shared/registry-generated/error-codes.ts +137 -0
  366. package/core/shared/registry-generated/index.ts +13 -0
  367. package/core/shared/registry-generated/limits.ts +552 -0
  368. package/core/shared/registry-generated/platform-keys.ts +56 -0
  369. package/core/shared/registry-generated/region-scope.ts +823 -0
  370. package/core/shared/registry-generated/std-grammar-completion.ts +216 -0
  371. package/core/shared/registry-generated/std-grammar-views.ts +139 -0
  372. package/core/shared/registry-generated/std-grammar.ts +161 -0
  373. package/core/shared/rule-step.ts +2 -0
  374. package/core/shared/runtime-address.ts +244 -0
  375. package/core/shared/scope-decl.ts +77 -0
  376. package/core/shared/sha256.ts +108 -0
  377. package/core/shared/show-when.ts +77 -0
  378. package/core/shared/source-file-suffix.ts +8 -0
  379. package/core/shared/std-auth-scan.ts +158 -0
  380. package/core/shared/types/choice-confirm.types.ts +2 -0
  381. package/core/shared/types/compile-diagnostic.types.ts +42 -0
  382. package/core/shared/types/compile-port.types.ts +41 -0
  383. package/core/shared/types/component-contract.types.ts +145 -156
  384. package/core/shared/types/component-tree-artifact.types.ts +18 -2
  385. package/core/shared/types/component-tree.types.ts +17 -6
  386. package/core/shared/types/data-config.types.ts +182 -222
  387. package/core/shared/types/domain.types.ts +20 -5
  388. package/core/shared/types/engine.types.ts +2 -0
  389. package/core/shared/types/event.types.ts +78 -8
  390. package/core/shared/types/generation-error.types.ts +83 -0
  391. package/core/shared/types/host-assembly.types.ts +126 -0
  392. package/core/shared/types/locale.types.ts +46 -0
  393. package/core/shared/types/manifest.types.ts +2 -7
  394. package/core/shared/types/nav-context.types.ts +46 -0
  395. package/core/shared/types/nav.types.ts +57 -0
  396. package/core/shared/types/notify.types.ts +45 -0
  397. package/core/shared/types/observation.types.ts +76 -0
  398. package/core/shared/types/page-envelope.types.ts +125 -0
  399. package/core/shared/types/page-state.types.ts +21 -42
  400. package/core/shared/types/region-scope.types.ts +177 -0
  401. package/core/shared/types/registry-batch.types.ts +45 -0
  402. package/core/shared/types/shortcuts.types.ts +61 -0
  403. package/core/shared/types/source.types.ts +10 -0
  404. package/core/shared/types/style-config.types.ts +61 -82
  405. package/core/shared/types/temporal.types.ts +3 -0
  406. package/core/shared/types/ui-config.types.ts +80 -152
  407. package/core/shared/types/write-outcome-view.types.ts +24 -0
  408. package/core/shared/types/write-runtime.types.ts +10 -0
  409. package/core/shared/types/write.types.ts +86 -0
  410. package/dist/browser/runtime-bundle.manifest.json +938 -0
  411. package/dist/browser/soma-runtime.js +120260 -0
  412. package/dist/cli/soma.js +120 -456
  413. package/dist/core/adaptive-pure.cjs +41 -0
  414. package/dist/core/index.cjs +119695 -22484
  415. package/dist/core/theme-pure.cjs +38 -0
  416. package/dist/diagnostics/telemetry.cjs +2 -1
  417. package/dist/lsp/component-tree.cjs +6398 -8254
  418. package/dist/preview-export.cjs +3401 -0
  419. package/dist/types/build/compiler/flat-page.d.ts +52 -0
  420. package/dist/types/build/compiler/full-manifest-builder.d.ts +26 -1
  421. package/dist/types/build/compiler/html-index.d.ts +48 -0
  422. package/dist/types/build/compiler/page-assets.d.ts +11 -3
  423. package/dist/types/build/compiler/page-base-resolver.d.ts +5 -0
  424. package/dist/types/build/compiler/page-declaration-compiler.d.ts +97 -56
  425. package/dist/types/build/compiler/soma-precompile.d.ts +3 -3
  426. package/dist/types/build/compiler/vite-plugin-soma.d.ts +2 -2
  427. package/dist/types/build/component/component-graph.d.ts +1 -1
  428. package/dist/types/build/component-tree/artifact-codec.d.ts +5 -8
  429. package/dist/types/build/component-tree/registry-snapshot.d.ts +18 -0
  430. package/dist/types/build/component-tree/source-preflight.d.ts +4 -14
  431. package/dist/types/build/component-tree/structure-topology.d.ts +1 -1
  432. package/dist/types/build/eject/plan-eject.d.ts +0 -1
  433. package/dist/types/build/lsp/component-tree-service.d.ts +2 -0
  434. package/dist/types/client/a11y/a11y-config.d.ts +15 -0
  435. package/dist/types/client/a11y/announcer.d.ts +45 -0
  436. package/dist/types/client/a11y/dom-id.d.ts +4 -0
  437. package/dist/types/client/a11y/index.d.ts +5 -0
  438. package/dist/types/client/a11y/motion-hook.d.ts +13 -0
  439. package/dist/types/client/a11y/motion.d.ts +24 -0
  440. package/dist/types/client/base/SomaPageRootBase.d.ts +17 -2
  441. package/dist/types/client/base/index.d.ts +8 -8
  442. package/dist/types/client/behavior/adapter-collection.d.ts +39 -0
  443. package/dist/types/client/behavior/adapter-popper.d.ts +2 -0
  444. package/dist/types/client/behavior/aria-hide-outside.d.ts +13 -0
  445. package/dist/types/client/behavior/css-escape.d.ts +11 -0
  446. package/dist/types/client/behavior/focus-scope.d.ts +69 -0
  447. package/dist/types/client/behavior/focus-traversal.d.ts +3 -0
  448. package/dist/types/client/behavior/index.d.ts +17 -0
  449. package/dist/types/client/behavior/layer-stack.d.ts +39 -0
  450. package/dist/types/client/behavior/overlay-host/index.d.ts +5 -0
  451. package/dist/types/client/behavior/overlay-host/port.d.ts +55 -0
  452. package/dist/types/client/behavior/overlay-wiring.d.ts +59 -0
  453. package/dist/types/client/behavior/port.d.ts +79 -0
  454. package/dist/types/client/behavior/positioner.d.ts +2 -0
  455. package/dist/types/client/behavior/presence.d.ts +27 -0
  456. package/dist/types/client/behavior/zag/adapter-vanilla.d.ts +2 -0
  457. package/dist/types/client/behavior/zag/layer-bridge.d.ts +15 -0
  458. package/dist/types/client/behavior/zag/machine-host.d.ts +22 -0
  459. package/dist/types/client/behavior/zag/machines.d.ts +23 -0
  460. package/dist/types/client/compiler/manifest-compiler.d.ts +4 -14
  461. package/dist/types/client/component/adapter/adapt.d.ts +9 -0
  462. package/dist/types/client/component/adapter/index.d.ts +3 -0
  463. package/dist/types/client/component/adapter/types.d.ts +33 -0
  464. package/dist/types/client/component/adapter/web-component.d.ts +9 -0
  465. package/dist/types/client/component/component-definition.types.d.ts +23 -5
  466. package/dist/types/client/component/component-expander.d.ts +1 -12
  467. package/dist/types/client/component/component-manager.d.ts +39 -89
  468. package/dist/types/client/component/component-pack.d.ts +21 -54
  469. package/dist/types/client/component/component-registry.d.ts +5 -0
  470. package/dist/types/client/component/projection-admission.d.ts +5 -0
  471. package/dist/types/client/component/projection-registry.d.ts +6 -0
  472. package/dist/types/client/component/projection.types.d.ts +44 -0
  473. package/dist/types/client/component/region-unavailable.d.ts +10 -0
  474. package/dist/types/client/component/scoped-adapter.d.ts +2 -3
  475. package/dist/types/client/container/IContainerAdapter.d.ts +8 -3
  476. package/dist/types/client/container/SomaContainerAdapter.d.ts +7 -10
  477. package/dist/types/client/data/collection-payload.d.ts +1 -0
  478. package/dist/types/client/data/data-object-resolver.d.ts +231 -110
  479. package/dist/types/client/data/data-polling.d.ts +28 -0
  480. package/dist/types/client/data/data-subscriptions.d.ts +20 -0
  481. package/dist/types/client/data/data-write-actions.d.ts +9 -0
  482. package/dist/types/client/data/envelope-failure.d.ts +17 -0
  483. package/dist/types/client/data/format-config.d.ts +13 -0
  484. package/dist/types/client/data/region-scope-port.d.ts +34 -0
  485. package/dist/types/client/data/region-scope-views.d.ts +15 -0
  486. package/dist/types/client/data/role-gate.d.ts +10 -0
  487. package/dist/types/client/data/write-outcome-store.d.ts +23 -0
  488. package/dist/types/client/data/write-outcome.d.ts +48 -0
  489. package/dist/types/client/engine/asset-resolver.d.ts +2 -7
  490. package/dist/types/client/engine/dom-renderer.d.ts +5 -111
  491. package/dist/types/client/engine/event-engine.d.ts +52 -63
  492. package/dist/types/client/engine/locale-text-binder.d.ts +28 -0
  493. package/dist/types/client/engine/property-watcher.d.ts +1 -41
  494. package/dist/types/client/engine/reactive-proxy.d.ts +2 -42
  495. package/dist/types/client/engine/render-engine.d.ts +3 -54
  496. package/dist/types/client/engine/row-range.d.ts +1 -0
  497. package/dist/types/client/engine/runtime-builder.d.ts +7 -3
  498. package/dist/types/client/engine/soma-bootstrap.d.ts +314 -91
  499. package/dist/types/client/engine/step-runner.d.ts +20 -2
  500. package/dist/types/client/engine/style-binder.d.ts +2 -16
  501. package/dist/types/client/engines/chart/adapter-echarts.d.ts +6 -0
  502. package/dist/types/client/engines/chart/index.d.ts +8 -0
  503. package/dist/types/client/engines/chart/kind-modules.d.ts +8 -0
  504. package/dist/types/client/engines/chart/port.d.ts +46 -0
  505. package/dist/types/client/engines/diff/adapter-jsdiff.d.ts +6 -0
  506. package/dist/types/client/engines/diff/index.d.ts +8 -0
  507. package/dist/types/client/engines/diff/port.d.ts +16 -0
  508. package/dist/types/client/engines/dnd/adapter-pragmatic.d.ts +9 -0
  509. package/dist/types/client/engines/dnd/index.d.ts +6 -0
  510. package/dist/types/client/engines/dnd/port.d.ts +33 -0
  511. package/dist/types/client/engines/engine-adapters.d.ts +23 -0
  512. package/dist/types/client/engines/load.d.ts +11 -0
  513. package/dist/types/client/engines/qrcode/adapter-qrcode-generator.d.ts +6 -0
  514. package/dist/types/client/engines/qrcode/index.d.ts +8 -0
  515. package/dist/types/client/engines/qrcode/port.d.ts +16 -0
  516. package/dist/types/client/engines/table/adapter-tanstack.d.ts +6 -0
  517. package/dist/types/client/engines/table/index.d.ts +8 -0
  518. package/dist/types/client/engines/table/port.d.ts +51 -0
  519. package/dist/types/client/engines/temporal/adapter-polyfill.d.ts +6 -0
  520. package/dist/types/client/engines/temporal/index.d.ts +8 -0
  521. package/dist/types/client/engines/temporal/port.d.ts +41 -0
  522. package/dist/types/client/engines/virtual/adapter-tanstack.d.ts +9 -0
  523. package/dist/types/client/engines/virtual/index.d.ts +8 -0
  524. package/dist/types/client/engines/virtual/port.d.ts +33 -0
  525. package/dist/types/client/format/formatter.d.ts +3 -0
  526. package/dist/types/client/format/index.d.ts +2 -0
  527. package/dist/types/client/format/zoned.d.ts +1 -0
  528. package/dist/types/client/host-bridge/index.d.ts +3 -0
  529. package/dist/types/client/host-bridge/resolve-host-bootstrap.d.ts +7 -1
  530. package/dist/types/client/host-bridge/soma-app-host.stub.d.ts +3 -0
  531. package/dist/types/client/host-bridge/soma-bootstrap-from-app.d.ts +9 -0
  532. package/dist/types/client/infra/auth/IAuthService.d.ts +5 -0
  533. package/dist/types/client/infra/auth/TokenAuthService.d.ts +1 -0
  534. package/dist/types/client/infra/config/SomaConfig.d.ts +4 -0
  535. package/dist/types/client/infra/config/feature-flags.d.ts +10 -0
  536. package/dist/types/client/infra/http/IHttpClient.d.ts +4 -0
  537. package/dist/types/client/infra/i18n/II18n.d.ts +17 -1
  538. package/dist/types/client/infra/i18n/builtin-locale.d.ts +11 -0
  539. package/dist/types/client/infra/i18n/index.d.ts +1 -0
  540. package/dist/types/client/infra/i18n/interpolate.d.ts +12 -0
  541. package/dist/types/client/infra/i18n/locale-catalog.d.ts +71 -0
  542. package/dist/types/client/infra/i18n/pack-locales.d.ts +29 -0
  543. package/dist/types/client/infra/identity/identity-port.d.ts +54 -0
  544. package/dist/types/client/infra/notify/DefaultNotifyService.d.ts +29 -7
  545. package/dist/types/client/infra/notify/INotifyService.d.ts +1 -12
  546. package/dist/types/client/infra/notify/notify-declaration.d.ts +10 -0
  547. package/dist/types/client/infra/permission/SomaPermission.d.ts +7 -0
  548. package/dist/types/client/infra/router/IRouter.d.ts +5 -1
  549. package/dist/types/client/infra/router/SomaRouter.d.ts +6 -2
  550. package/dist/types/client/keyboard/collection.d.ts +58 -0
  551. package/dist/types/client/keyboard/compose-keys.d.ts +24 -0
  552. package/dist/types/client/keyboard/cursor.d.ts +48 -0
  553. package/dist/types/client/keyboard/delegate.d.ts +48 -0
  554. package/dist/types/client/keyboard/ime.d.ts +2 -0
  555. package/dist/types/client/keyboard/index.d.ts +10 -0
  556. package/dist/types/client/keyboard/intents.d.ts +35 -0
  557. package/dist/types/client/keyboard/matrix.d.ts +29 -0
  558. package/dist/types/client/keyboard/submit.d.ts +7 -0
  559. package/dist/types/client/keyboard/typeahead.d.ts +28 -0
  560. package/dist/types/client/keyboard/wiring.d.ts +85 -0
  561. package/dist/types/client/middleware/createPermissionMiddleware.d.ts +5 -0
  562. package/dist/types/client/mount/domain-rule.d.ts +17 -0
  563. package/dist/types/client/mount/index.d.ts +3 -0
  564. package/dist/types/client/mount/mount-page.d.ts +11 -0
  565. package/dist/types/client/mount/types.d.ts +100 -0
  566. package/dist/types/client/observability/runtime-observer.d.ts +24 -0
  567. package/dist/types/client/parser/confirm-spec.d.ts +37 -0
  568. package/dist/types/client/parser/data-config-parser.d.ts +23 -17
  569. package/dist/types/client/parser/duration.d.ts +1 -1
  570. package/dist/types/client/parser/page-state-parser.d.ts +1 -6
  571. package/dist/types/client/parser/pipeline-parser.d.ts +7 -12
  572. package/dist/types/client/parser/style-config-parser.d.ts +2 -1
  573. package/dist/types/client/parser/subscribe-parser.d.ts +5 -0
  574. package/dist/types/client/parser/ui-config-parser.d.ts +26 -25
  575. package/dist/types/client/pipes/pipe-registry.d.ts +30 -40
  576. package/dist/types/client/registry/declaration-renderer.d.ts +11 -3
  577. package/dist/types/client/registry/page-lifecycle.d.ts +3 -3
  578. package/dist/types/client/registry/remote-page.d.ts +3 -3
  579. package/dist/types/client/render-ports/index.d.ts +15 -0
  580. package/dist/types/client/render-ports/notify-renderer.d.ts +55 -0
  581. package/dist/types/client/render-ports/region-fallback.d.ts +10 -0
  582. package/dist/types/client/render-ports/scheduling/prompt-queue.d.ts +19 -0
  583. package/dist/types/client/render-ports/scheduling/toast-scheduler.d.ts +60 -0
  584. package/dist/types/client/runtime/SomaRuntimeServices.d.ts +102 -5
  585. package/dist/types/client/runtime/nav-history.d.ts +31 -0
  586. package/dist/types/client/runtime/nav-port.d.ts +12 -0
  587. package/dist/types/client/runtime/shortcuts.d.ts +41 -0
  588. package/dist/types/client/runtime/write-feedback.d.ts +22 -0
  589. package/dist/types/client/runtime-entry.d.ts +13 -0
  590. package/dist/types/client/scheduler/SomaScheduler.d.ts +5 -0
  591. package/dist/types/client/scheduling/flush-scheduler.d.ts +13 -0
  592. package/dist/types/client/scheduling/index.d.ts +4 -0
  593. package/dist/types/client/scheduling/observer-pool.d.ts +15 -0
  594. package/dist/types/client/security/url-guard.d.ts +18 -0
  595. package/dist/types/client/styles/compiled-styles.d.ts +10 -0
  596. package/dist/types/client/styles/index.d.ts +3 -0
  597. package/dist/types/client/styles/pack-styles.d.ts +51 -0
  598. package/dist/types/client/styles/sheet-mount.d.ts +7 -0
  599. package/dist/types/client/styles/style-features.d.ts +26 -0
  600. package/dist/types/client/time/clock.d.ts +10 -0
  601. package/dist/types/client/time/instant.d.ts +1 -0
  602. package/dist/types/client/url-state/index.d.ts +6 -0
  603. package/dist/types/client/url-state/page-tabs-controller.d.ts +22 -0
  604. package/dist/types/client/url-state/state-query-binding.d.ts +22 -0
  605. package/dist/types/client/url-state/url-state.d.ts +47 -0
  606. package/dist/types/client/validation/async-check-registry.d.ts +41 -0
  607. package/dist/types/client/validation/async-rules.d.ts +81 -0
  608. package/dist/types/client/validation/contract-validator.d.ts +10 -0
  609. package/dist/types/client/validation/field-rules.d.ts +6 -0
  610. package/dist/types/client/validation/index.d.ts +5 -0
  611. package/dist/types/client/validation/object-rules.d.ts +22 -0
  612. package/dist/types/index.d.ts +97 -61
  613. package/dist/types/inspect/check-product.d.ts +123 -0
  614. package/dist/types/inspect/check-runtime.d.ts +19 -0
  615. package/dist/types/inspect/runtime.d.ts +39 -0
  616. package/dist/types/page-target/index.d.ts +3 -0
  617. package/dist/types/page-target/provenance.d.ts +20 -0
  618. package/dist/types/page-target/slug.d.ts +7 -0
  619. package/dist/types/page-target/testing/index.d.ts +55 -0
  620. package/dist/types/page-target/types.d.ts +260 -0
  621. package/dist/types/predicates-entry.d.ts +3 -0
  622. package/dist/types/server/compile-port.d.ts +13 -0
  623. package/dist/types/server/diagnostic-gate-entry.d.ts +3 -0
  624. package/dist/types/server/engines/style/candidate-guard.d.ts +14 -0
  625. package/dist/types/server/engines/style/index.d.ts +10 -0
  626. package/dist/types/server/engines/style/port.d.ts +8 -0
  627. package/dist/types/server/engines/style/tailwind-adapter.d.ts +6 -0
  628. package/dist/types/server/host/host-assembly-entry.d.ts +5 -0
  629. package/dist/types/server/host/host-assembly.d.ts +61 -0
  630. package/dist/types/server/host/host-caller.d.ts +10 -0
  631. package/dist/types/server/host/host-config-paths.d.cts +7 -0
  632. package/dist/types/server/host/host-response-headers.d.ts +16 -0
  633. package/dist/types/server/host/locale-yaml.d.ts +3 -0
  634. package/dist/types/server/host/page-markup-config.d.ts +6 -0
  635. package/dist/types/server/host/published-page-artifact-cache.d.ts +99 -22
  636. package/dist/types/server/host/published-page-assets.d.ts +75 -5
  637. package/dist/types/server/host/resolve-host-request-hook.d.ts +0 -4
  638. package/dist/types/server/host/resolve-host-tree-context.d.ts +1 -1
  639. package/dist/types/server/host/server-page-assets.d.ts +29 -3
  640. package/dist/types/server/host/soma-page-compile.d.ts +26 -4
  641. package/dist/types/server/host/source-packages.d.cts +23 -0
  642. package/dist/types/server/host/source-packages.d.ts +15 -2
  643. package/dist/types/server/host/virtual-pages.d.ts +33 -0
  644. package/dist/types/server/index.d.ts +7 -12
  645. package/dist/types/server/node.d.ts +16 -0
  646. package/dist/types/server/page-assets.d.ts +7 -0
  647. package/dist/types/server/page-declaration.d.ts +21 -6
  648. package/dist/types/server/registry/api-registry-store.d.ts +4 -7
  649. package/dist/types/server/registry/asset-store.d.ts +4 -7
  650. package/dist/types/server/registry/batch-publish.d.ts +12 -0
  651. package/dist/types/server/registry/batch-stage.d.ts +24 -0
  652. package/dist/types/server/registry/component-supply.d.ts +6 -0
  653. package/dist/types/server/registry/declaration-precompiler.d.ts +22 -8
  654. package/dist/types/server/registry/index.d.ts +12 -3
  655. package/dist/types/server/registry/page-registry-repository.d.ts +50 -4
  656. package/dist/types/server/registry/page-registry-store.d.ts +227 -33
  657. package/dist/types/server/registry/publish-asset-pin.d.ts +5 -4
  658. package/dist/types/server/registry/registry-file-lock.d.ts +5 -0
  659. package/dist/types/server/registry/registry-subjects.d.ts +2 -2
  660. package/dist/types/server/registry/registry-write-pipeline.d.ts +22 -0
  661. package/dist/types/server/registry/request-body-limit.d.ts +1 -1
  662. package/dist/types/server/registry/rollback-plan.d.ts +58 -0
  663. package/dist/types/server/registry/services/index.d.ts +5 -0
  664. package/dist/types/server/registry/services/pages/Register.d.ts +1 -1
  665. package/dist/types/server/registry/services/pages/RegisterBatch.d.ts +12 -0
  666. package/dist/types/server/registry/services/pages/Rollback.d.ts +4 -1
  667. package/dist/types/server/registry/source/canonical.d.ts +2 -0
  668. package/dist/types/server/registry/source/errors.d.ts +44 -0
  669. package/dist/types/server/registry/source/index.d.ts +7 -0
  670. package/dist/types/server/registry/source/ledger.d.ts +99 -0
  671. package/dist/types/server/registry/source/snapshot.d.ts +6 -0
  672. package/dist/types/server/registry/source/source-name.d.ts +20 -0
  673. package/dist/types/server/registry/source/types.d.ts +89 -0
  674. package/dist/types/server/registry/source/version-store.d.ts +58 -0
  675. package/dist/types/server/registry/standard-product.d.ts +78 -0
  676. package/dist/types/server/registry/validation/compile-gate.d.ts +12 -45
  677. package/dist/types/server/registry/validation/cross-check.d.ts +7 -0
  678. package/dist/types/server/registry/validation/declaration-safety-scan.d.ts +0 -1
  679. package/dist/types/server/registry/validation/region-scopes.d.ts +10 -0
  680. package/dist/types/server/runtime-space/access-gate.d.ts +41 -0
  681. package/dist/types/server/runtime-space/advice-log.d.ts +18 -0
  682. package/dist/types/server/runtime-space/artifact-evict.d.ts +4 -0
  683. package/dist/types/server/runtime-space/bindings.d.ts +115 -0
  684. package/dist/types/server/runtime-space/digest.d.ts +19 -0
  685. package/dist/types/server/runtime-space/dynamic-pages.d.ts +120 -0
  686. package/dist/types/server/runtime-space/errors.d.ts +37 -0
  687. package/dist/types/server/runtime-space/gc.d.ts +6 -0
  688. package/dist/types/server/runtime-space/index.d.ts +19 -0
  689. package/dist/types/server/runtime-space/inject.d.ts +55 -0
  690. package/dist/types/server/runtime-space/nav-catalog.d.ts +33 -0
  691. package/dist/types/server/runtime-space/page-grants.d.ts +90 -0
  692. package/dist/types/server/runtime-space/prewarm.d.ts +60 -0
  693. package/dist/types/server/runtime-space/registry-cold-start.d.ts +4 -0
  694. package/dist/types/server/runtime-space/resolve.d.ts +35 -0
  695. package/dist/types/server/runtime-space/root.d.cts +65 -0
  696. package/dist/types/server/runtime-space/root.d.ts +16 -0
  697. package/dist/types/server/runtime-space/static-source.d.ts +8 -0
  698. package/dist/types/server/runtime-space/store.d.ts +63 -0
  699. package/dist/types/server/runtime-space/submit-steps.d.ts +116 -0
  700. package/dist/types/server/runtime-space/types.d.ts +255 -0
  701. package/dist/types/shared/anchor-space.d.ts +17 -0
  702. package/dist/types/shared/artifact-compatibility.d.ts +75 -0
  703. package/dist/types/shared/behavior-machine-names.d.ts +2 -0
  704. package/dist/types/shared/calc/coerce.d.ts +1 -4
  705. package/dist/types/shared/calc/lexer.d.ts +1 -2
  706. package/dist/types/shared/calc/parser.d.ts +1 -7
  707. package/dist/types/shared/calc/typer.d.ts +1 -6
  708. package/dist/types/shared/component-tree-artifact.d.ts +16 -2
  709. package/dist/types/shared/contract-a11y.d.ts +33 -0
  710. package/dist/types/shared/contract-sections.d.ts +50 -0
  711. package/dist/types/shared/core-diagnostic-codes.d.ts +28 -0
  712. package/dist/types/shared/data-declaration-checks.d.ts +71 -0
  713. package/dist/types/shared/date-parts.d.ts +1 -0
  714. package/dist/types/shared/declaration-errors.d.ts +12 -0
  715. package/dist/types/shared/declaration-keys.d.ts +9 -0
  716. package/dist/types/shared/diagnostic-code-index-entry.d.ts +5 -0
  717. package/dist/types/shared/diagnostic-gate.d.ts +60 -0
  718. package/dist/types/shared/engines/engine-error.d.ts +14 -0
  719. package/dist/types/shared/engines/style/style-engine.types.d.ts +22 -0
  720. package/dist/types/shared/fragments-section.d.ts +2 -0
  721. package/dist/types/shared/generation-diagnostics.d.ts +7 -0
  722. package/dist/types/shared/generation-error.d.ts +20 -0
  723. package/dist/types/shared/hook-attributes.d.ts +220 -0
  724. package/dist/types/shared/inert-data-element.d.ts +14 -0
  725. package/dist/types/shared/nav-back.d.ts +22 -0
  726. package/dist/types/shared/page-access-text.d.ts +4 -0
  727. package/dist/types/shared/page-envelope-runtime.d.ts +32 -0
  728. package/dist/types/shared/page-envelope.d.ts +61 -0
  729. package/dist/types/shared/page-scopes.d.ts +35 -0
  730. package/dist/types/shared/pipeline-error-codes-view.d.ts +11 -0
  731. package/dist/types/shared/pipeline-limits-view.d.ts +8 -0
  732. package/dist/types/shared/predicates/index.d.ts +24 -67
  733. package/dist/types/shared/predicates/relative-window.d.ts +1 -0
  734. package/dist/types/shared/published-page-route.d.ts +3 -5
  735. package/dist/types/shared/region-scope-decl.d.ts +121 -0
  736. package/dist/types/shared/registry-generated/compile-purposes.d.ts +37 -0
  737. package/dist/types/shared/registry-generated/diagnostic-registry-index.d.ts +2 -0
  738. package/dist/types/shared/registry-generated/diagnostic-registry.d.ts +5011 -0
  739. package/dist/types/shared/registry-generated/error-codes.d.ts +115 -0
  740. package/dist/types/shared/registry-generated/index.d.ts +10 -0
  741. package/dist/types/shared/registry-generated/limits.d.ts +461 -0
  742. package/dist/types/shared/registry-generated/platform-keys.d.ts +42 -0
  743. package/dist/types/shared/registry-generated/region-scope.d.ts +511 -0
  744. package/dist/types/shared/registry-generated/std-grammar-completion.d.ts +773 -0
  745. package/dist/types/shared/registry-generated/std-grammar-views.d.ts +203 -0
  746. package/dist/types/shared/registry-generated/std-grammar.d.ts +3515 -0
  747. package/dist/types/shared/rule-step.d.ts +1 -0
  748. package/dist/types/shared/runtime-address.d.ts +70 -0
  749. package/dist/types/shared/scope-decl.d.ts +15 -0
  750. package/dist/types/shared/sha256.d.ts +4 -0
  751. package/dist/types/shared/show-when.d.ts +21 -0
  752. package/dist/types/shared/source-file-suffix.d.ts +2 -0
  753. package/dist/types/shared/std-auth-scan.d.ts +45 -0
  754. package/dist/types/shared/types/choice-confirm.types.d.ts +1 -0
  755. package/dist/types/shared/types/compile-diagnostic.types.d.ts +34 -0
  756. package/dist/types/shared/types/compile-port.types.d.ts +30 -0
  757. package/dist/types/shared/types/component-contract.types.d.ts +134 -129
  758. package/dist/types/shared/types/component-tree-artifact.types.d.ts +16 -2
  759. package/dist/types/shared/types/component-tree.types.d.ts +15 -6
  760. package/dist/types/shared/types/data-config.types.d.ts +175 -191
  761. package/dist/types/shared/types/domain.types.d.ts +20 -5
  762. package/dist/types/shared/types/engine.types.d.ts +2 -0
  763. package/dist/types/shared/types/event.types.d.ts +59 -9
  764. package/dist/types/shared/types/generation-error.types.d.ts +28 -0
  765. package/dist/types/shared/types/host-assembly.types.d.ts +121 -0
  766. package/dist/types/shared/types/locale.types.d.ts +17 -0
  767. package/dist/types/shared/types/manifest.types.d.ts +2 -7
  768. package/dist/types/shared/types/nav-context.types.d.ts +41 -0
  769. package/dist/types/shared/types/nav.types.d.ts +53 -0
  770. package/dist/types/shared/types/notify.types.d.ts +37 -0
  771. package/dist/types/shared/types/observation.types.d.ts +72 -0
  772. package/dist/types/shared/types/page-envelope.types.d.ts +98 -0
  773. package/dist/types/shared/types/page-state.types.d.ts +17 -33
  774. package/dist/types/shared/types/region-scope.types.d.ts +150 -0
  775. package/dist/types/shared/types/registry-batch.types.d.ts +48 -0
  776. package/dist/types/shared/types/shortcuts.types.d.ts +67 -0
  777. package/dist/types/shared/types/source.types.d.ts +10 -0
  778. package/dist/types/shared/types/style-config.types.d.ts +0 -19
  779. package/dist/types/shared/types/temporal.types.d.ts +1 -0
  780. package/dist/types/shared/types/ui-config.types.d.ts +77 -148
  781. package/dist/types/shared/types/write-outcome-view.types.d.ts +19 -0
  782. package/dist/types/shared/types/write-runtime.types.d.ts +1 -0
  783. package/dist/types/shared/types/write.types.d.ts +70 -0
  784. package/global.d.ts +2 -10
  785. package/host-next/app/SomaPageClient.tsx +359 -0
  786. package/host-next/app/api/[...path]/route.ts +98 -0
  787. package/host-next/app/api/soma-registry/[...path]/route.ts +79 -0
  788. package/host-next/app/components/SomaPageForbidden.tsx +19 -0
  789. package/host-next/app/globals.css +177 -0
  790. package/host-next/app/page-access.ts +47 -0
  791. package/host-next/app/router-bridge.ts +42 -0
  792. package/host-next/app/soma/_shared/host-prepare.ts +33 -0
  793. package/host-next/app/soma/_shared/page-http.ts +86 -0
  794. package/host-next/app/soma/manifest/route.ts +98 -0
  795. package/host-next/app/soma/page/route.ts +36 -0
  796. package/host-next/app/soma-runtime/[...file]/route.ts +21 -0
  797. package/host-next/app/soma-runtime/_shared/static-file.ts +89 -0
  798. package/host-next/bin/host-next.cjs +59 -0
  799. package/host-next/instrumentation.ts +13 -0
  800. package/host-next/next-env.d.ts +7 -0
  801. package/host-next/next.config.js +382 -0
  802. package/host-next/proxy.ts +43 -0
  803. package/host-next/src/shell-routes.cjs +51 -0
  804. package/host-next/src/workspace.ts +543 -0
  805. package/package.json +238 -59
  806. package/tsconfig.json +4 -11
  807. package/app/SomaPageClient.tsx +0 -313
  808. package/app/api/[...path]/route.ts +0 -86
  809. package/app/api/soma-registry/[...path]/route.ts +0 -67
  810. package/app/globals.css +0 -126
  811. package/app/soma/manifest/route.ts +0 -43
  812. package/app/soma/page/route.ts +0 -44
  813. package/app/soma/page-object/route.ts +0 -159
  814. package/bin/component.cjs +0 -240
  815. package/bin/migrate.cjs +0 -432
  816. package/bin/soma-db.cjs +0 -13
  817. package/bin/soma-mock.mjs +0 -38
  818. package/bin/soma-sync.cjs +0 -3
  819. package/core/build/blocks/block-compile.ts +0 -373
  820. package/core/build/blocks/block-container.ts +0 -207
  821. package/core/build/blocks/block-loader.ts +0 -33
  822. package/core/build/blocks/html-index.ts +0 -120
  823. package/core/build/blocks/migrate-flat.ts +0 -463
  824. package/core/build/compiler/precompiled-manifest-loader.ts +0 -41
  825. package/core/build/component/pack-from-dir.ts +0 -58
  826. package/core/build/component/package-loader.ts +0 -358
  827. package/core/build/component-tree/binding-bridge.ts +0 -272
  828. package/core/build/component-tree/migration-files.ts +0 -214
  829. package/core/build/component-tree/migration.ts +0 -170
  830. package/core/build/component-tree/validator.ts +0 -318
  831. package/core/build/db/cli.ts +0 -10
  832. package/core/build/db/emit-entities.ts +0 -45
  833. package/core/build/db/emit-mappers.ts +0 -175
  834. package/core/build/db/emit-prisma-schema.ts +0 -92
  835. package/core/build/db/generate.ts +0 -166
  836. package/core/build/db/ir.ts +0 -75
  837. package/core/build/db/load-db-yaml.ts +0 -241
  838. package/core/build/eject/component-eject.ts +0 -480
  839. package/core/build/eject/component-upgrade.ts +0 -359
  840. package/core/build/layout/constraint-solver.ts +0 -350
  841. package/core/build/layout/css-emitter.ts +0 -135
  842. package/core/build/layout/page-layout.ts +0 -85
  843. package/core/build/ooui/artifact/artifact.types.ts +0 -275
  844. package/core/build/ooui/artifact/emit-artifact.ts +0 -269
  845. package/core/build/ooui/artifact/emit-html.ts +0 -204
  846. package/core/build/ooui/artifact/index.ts +0 -53
  847. package/core/build/ooui/artifact/spatial-tree.ts +0 -268
  848. package/core/build/ooui/artifact/utility-class.ts +0 -83
  849. package/core/build/ooui/composition/candidate.types.ts +0 -323
  850. package/core/build/ooui/composition/control-model.ts +0 -114
  851. package/core/build/ooui/composition/registry.ts +0 -520
  852. package/core/build/ooui/composition/select.ts +0 -232
  853. package/core/build/ooui/diagnostics/codes.ts +0 -230
  854. package/core/build/ooui/diagnostics/error.ts +0 -235
  855. package/core/build/ooui/diagnostics/format.ts +0 -106
  856. package/core/build/ooui/diagnostics/index.ts +0 -62
  857. package/core/build/ooui/diagnostics/issue.types.ts +0 -112
  858. package/core/build/ooui/engine-slot.ts +0 -184
  859. package/core/build/ooui/index.ts +0 -1427
  860. package/core/build/ooui/intent/derive-intent.ts +0 -450
  861. package/core/build/ooui/intent/field-rules.ts +0 -330
  862. package/core/build/ooui/intent/intent.types.ts +0 -476
  863. package/core/build/ooui/intent/verb-events.ts +0 -285
  864. package/core/build/ooui/page/budget.ts +0 -503
  865. package/core/build/ooui/page/compose-page.ts +0 -736
  866. package/core/build/ooui/page/index.ts +0 -66
  867. package/core/build/ooui/page/page.types.ts +0 -402
  868. package/core/build/ooui/page/region-row.ts +0 -241
  869. package/core/build/ooui/semantic/expand-page-surface.ts +0 -180
  870. package/core/build/ooui/semantic/kernel.types.ts +0 -187
  871. package/core/build/ooui/semantic/normalize.ts +0 -784
  872. package/core/build/ooui/semantic/origin.types.ts +0 -211
  873. package/core/build/ooui/semantic/role-alias.ts +0 -154
  874. package/core/build/ooui/semantic/shorthand.ts +0 -233
  875. package/core/build/ooui/semantic/surface.types.ts +0 -78
  876. package/core/build/ooui/semantic/validate-request.ts +0 -267
  877. package/core/build/ooui/spatial/emit-utility.ts +0 -480
  878. package/core/build/ooui/spatial/ir.types.ts +0 -443
  879. package/core/build/ooui/spatial/registry.ts +0 -565
  880. package/core/build/ooui/spatial/solve.ts +0 -769
  881. package/core/build/ooui/spatial/utility.types.ts +0 -242
  882. package/core/build/ooui/trace/index.ts +0 -40
  883. package/core/build/ooui/trace/render.ts +0 -190
  884. package/core/build/ooui/trace/source.types.ts +0 -69
  885. package/core/build/ooui/trace/trace.types.ts +0 -326
  886. package/core/build/pack/pack-init.ts +0 -270
  887. package/core/client/adaptive/flush-scheduler.ts +0 -96
  888. package/core/client/adaptive/hysteresis.ts +0 -56
  889. package/core/client/adaptive/index.ts +0 -23
  890. package/core/client/adaptive/observer-pool.ts +0 -204
  891. package/core/client/compiler/adaptive-compile.ts +0 -136
  892. package/core/client/component/ai-catalog.ts +0 -432
  893. package/core/client/component/catalog-examples.ts +0 -60
  894. package/core/client/component/contract-compat.ts +0 -161
  895. package/core/client/component/example-blocks.ts +0 -126
  896. package/core/client/component/keyboard-matrix.ts +0 -144
  897. package/core/client/component/pack-styles.ts +0 -152
  898. package/core/client/component/style-features.ts +0 -131
  899. package/core/client/component/theme-component-tokens.ts +0 -80
  900. package/core/client/component/verify-pack.ts +0 -429
  901. package/core/client/container/MiniProgramContainerAdapter.ts +0 -204
  902. package/core/client/container/ReactNativeContainerAdapter.ts +0 -203
  903. package/core/client/data/reaction-engine.ts +0 -176
  904. package/core/client/data/window-engine.ts +0 -477
  905. package/core/client/infra/i18n/DefaultI18n.ts +0 -29
  906. package/core/client/infra/notify/DomNotifyService.ts +0 -99
  907. package/core/client/infra/notify/INotifyTheme.ts +0 -22
  908. package/core/client/parser/adaptive-parser.ts +0 -264
  909. package/core/client/parser/blocks/namespace.ts +0 -207
  910. package/core/client/parser/blocks/page-parser.ts +0 -466
  911. package/core/client/parser/blocks/use-parser.ts +0 -646
  912. package/core/client/parser/layout-parser.ts +0 -158
  913. package/core/client/parser/reaction-parser.ts +0 -458
  914. package/core/client/parser/reaction-sugar.ts +0 -47
  915. package/core/client/parser/window-parser.ts +0 -294
  916. package/core/client/quality/SomaQualityRegistry.ts +0 -71
  917. package/core/client/runtime/serialize-page-state.ts +0 -152
  918. package/core/client/theme/harmony.ts +0 -429
  919. package/core/client/theme/scene-tokens.ts +0 -155
  920. package/core/client/theme/theme-axes.ts +0 -323
  921. package/core/client/theme/theme-engine.ts +0 -2390
  922. package/core/client/theme/tone-solver.ts +0 -119
  923. package/core/client/typography/typography-base.ts +0 -34
  924. package/core/server/headless/soma-headless-page.ts +0 -103
  925. package/core/server/host/page-response-mode.cjs +0 -96
  926. package/core/server/host/page-response-request.ts +0 -33
  927. package/core/server/host/request-origin.ts +0 -18
  928. package/core/server/host/soma-request-hook-host.stub.ts +0 -4
  929. package/core/server/infra/db/errors.ts +0 -11
  930. package/core/server/infra/db/mapper/PrismaSomaMapper.ts +0 -313
  931. package/core/server/infra/db/mapper/SomaBaseMapper.ts +0 -23
  932. package/core/server/infra/db/mapper/SomaMapperHooks.ts +0 -13
  933. package/core/server/infra/db/query/SomaQuery.ts +0 -149
  934. package/core/server/infra/db/service/SomaDbService.ts +0 -64
  935. package/core/server/infra/db/soma-db.ts +0 -120
  936. package/core/server/infra/db/types.ts +0 -21
  937. package/core/server/mock/node/catch-all.mjs +0 -35
  938. package/core/server/mock/node/cli.d.mts +0 -58
  939. package/core/server/mock/node/cli.mjs +0 -244
  940. package/core/server/mock/node/context.mjs +0 -167
  941. package/core/server/mock/node/environment-policy.mjs +0 -52
  942. package/core/server/mock/node/plugin-loader.mjs +0 -212
  943. package/core/server/mock/node/preload.mjs +0 -91
  944. package/core/server/mock/node/process-lifecycle.mjs +0 -236
  945. package/core/server/mock/node/public.d.mts +0 -110
  946. package/core/server/mock/node/public.mjs +0 -4
  947. package/core/server/mock/node/registry.mjs +0 -336
  948. package/core/server/mock/node/schema-generator.mjs +0 -1309
  949. package/core/server/mock/testing/host-harness.d.mts +0 -66
  950. package/core/server/mock/testing/host-harness.mjs +0 -276
  951. package/core/server/mock/testing/host-runtime.mjs +0 -48
  952. package/core/server/ooui.ts +0 -34
  953. package/core/shared/block-errors.ts +0 -11
  954. package/core/shared/component/derive-sample.ts +0 -290
  955. package/core/shared/component/field-lines.ts +0 -563
  956. package/core/shared/container-breakpoints.ts +0 -46
  957. package/core/shared/object-semantics.ts +0 -240
  958. package/core/shared/ooui-declaration.ts +0 -235
  959. package/core/shared/path-algebra.ts +0 -169
  960. package/core/shared/types/adaptive.types.ts +0 -109
  961. package/core/shared/types/layout-constraint.types.ts +0 -89
  962. package/core/shared/types/reaction.types.ts +0 -144
  963. package/core/shared/types/window.types.ts +0 -177
  964. package/dist/types/build/blocks/block-compile.d.ts +0 -52
  965. package/dist/types/build/blocks/block-container.d.ts +0 -40
  966. package/dist/types/build/blocks/block-loader.d.ts +0 -9
  967. package/dist/types/build/blocks/html-index.d.ts +0 -37
  968. package/dist/types/build/blocks/migrate-flat.d.ts +0 -49
  969. package/dist/types/build/compiler/precompiled-manifest-loader.d.ts +0 -5
  970. package/dist/types/build/component/pack-from-dir.d.ts +0 -17
  971. package/dist/types/build/component/package-loader.d.ts +0 -50
  972. package/dist/types/build/component-tree/binding-bridge.d.ts +0 -19
  973. package/dist/types/build/component-tree/migration-files.d.ts +0 -35
  974. package/dist/types/build/component-tree/migration.d.ts +0 -28
  975. package/dist/types/build/component-tree/validator.d.ts +0 -9
  976. package/dist/types/build/db/cli.d.ts +0 -2
  977. package/dist/types/build/db/emit-entities.d.ts +0 -5
  978. package/dist/types/build/db/emit-mappers.d.ts +0 -15
  979. package/dist/types/build/db/emit-prisma-schema.d.ts +0 -2
  980. package/dist/types/build/db/generate.d.ts +0 -7
  981. package/dist/types/build/db/ir.d.ts +0 -58
  982. package/dist/types/build/db/load-db-yaml.d.ts +0 -14
  983. package/dist/types/build/eject/component-eject.d.ts +0 -121
  984. package/dist/types/build/eject/component-upgrade.d.ts +0 -43
  985. package/dist/types/build/layout/constraint-solver.d.ts +0 -78
  986. package/dist/types/build/layout/css-emitter.d.ts +0 -18
  987. package/dist/types/build/layout/page-layout.d.ts +0 -24
  988. package/dist/types/build/ooui/artifact/artifact.types.d.ts +0 -180
  989. package/dist/types/build/ooui/artifact/emit-artifact.d.ts +0 -58
  990. package/dist/types/build/ooui/artifact/emit-html.d.ts +0 -53
  991. package/dist/types/build/ooui/artifact/index.d.ts +0 -5
  992. package/dist/types/build/ooui/artifact/spatial-tree.d.ts +0 -48
  993. package/dist/types/build/ooui/artifact/utility-class.d.ts +0 -46
  994. package/dist/types/build/ooui/composition/candidate.types.d.ts +0 -206
  995. package/dist/types/build/ooui/composition/control-model.d.ts +0 -37
  996. package/dist/types/build/ooui/composition/registry.d.ts +0 -66
  997. package/dist/types/build/ooui/composition/select.d.ts +0 -63
  998. package/dist/types/build/ooui/diagnostics/codes.d.ts +0 -28
  999. package/dist/types/build/ooui/diagnostics/error.d.ts +0 -135
  1000. package/dist/types/build/ooui/diagnostics/format.d.ts +0 -51
  1001. package/dist/types/build/ooui/diagnostics/index.d.ts +0 -25
  1002. package/dist/types/build/ooui/diagnostics/issue.types.d.ts +0 -56
  1003. package/dist/types/build/ooui/engine-slot.d.ts +0 -41
  1004. package/dist/types/build/ooui/index.d.ts +0 -286
  1005. package/dist/types/build/ooui/intent/derive-intent.d.ts +0 -32
  1006. package/dist/types/build/ooui/intent/field-rules.d.ts +0 -99
  1007. package/dist/types/build/ooui/intent/intent.types.d.ts +0 -318
  1008. package/dist/types/build/ooui/intent/verb-events.d.ts +0 -70
  1009. package/dist/types/build/ooui/page/budget.d.ts +0 -28
  1010. package/dist/types/build/ooui/page/compose-page.d.ts +0 -41
  1011. package/dist/types/build/ooui/page/index.d.ts +0 -4
  1012. package/dist/types/build/ooui/page/page.types.d.ts +0 -264
  1013. package/dist/types/build/ooui/page/region-row.d.ts +0 -16
  1014. package/dist/types/build/ooui/semantic/expand-page-surface.d.ts +0 -33
  1015. package/dist/types/build/ooui/semantic/kernel.types.d.ts +0 -125
  1016. package/dist/types/build/ooui/semantic/normalize.d.ts +0 -45
  1017. package/dist/types/build/ooui/semantic/origin.types.d.ts +0 -95
  1018. package/dist/types/build/ooui/semantic/role-alias.d.ts +0 -35
  1019. package/dist/types/build/ooui/semantic/shorthand.d.ts +0 -60
  1020. package/dist/types/build/ooui/semantic/surface.types.d.ts +0 -16
  1021. package/dist/types/build/ooui/semantic/validate-request.d.ts +0 -19
  1022. package/dist/types/build/ooui/spatial/emit-utility.d.ts +0 -43
  1023. package/dist/types/build/ooui/spatial/ir.types.d.ts +0 -280
  1024. package/dist/types/build/ooui/spatial/registry.d.ts +0 -110
  1025. package/dist/types/build/ooui/spatial/solve.d.ts +0 -42
  1026. package/dist/types/build/ooui/spatial/utility.types.d.ts +0 -191
  1027. package/dist/types/build/ooui/trace/index.d.ts +0 -3
  1028. package/dist/types/build/ooui/trace/render.d.ts +0 -42
  1029. package/dist/types/build/ooui/trace/source.types.d.ts +0 -25
  1030. package/dist/types/build/ooui/trace/trace.types.d.ts +0 -143
  1031. package/dist/types/build/pack/pack-init.d.ts +0 -8
  1032. package/dist/types/client/adaptive/flush-scheduler.d.ts +0 -13
  1033. package/dist/types/client/adaptive/hysteresis.d.ts +0 -16
  1034. package/dist/types/client/adaptive/index.d.ts +0 -5
  1035. package/dist/types/client/adaptive/observer-pool.d.ts +0 -22
  1036. package/dist/types/client/compiler/adaptive-compile.d.ts +0 -26
  1037. package/dist/types/client/component/ai-catalog.d.ts +0 -122
  1038. package/dist/types/client/component/catalog-examples.d.ts +0 -18
  1039. package/dist/types/client/component/contract-compat.d.ts +0 -16
  1040. package/dist/types/client/component/example-blocks.d.ts +0 -7
  1041. package/dist/types/client/component/keyboard-matrix.d.ts +0 -24
  1042. package/dist/types/client/component/pack-styles.d.ts +0 -43
  1043. package/dist/types/client/component/style-features.d.ts +0 -26
  1044. package/dist/types/client/component/theme-component-tokens.d.ts +0 -17
  1045. package/dist/types/client/component/verify-pack.d.ts +0 -24
  1046. package/dist/types/client/container/MiniProgramContainerAdapter.d.ts +0 -52
  1047. package/dist/types/client/container/ReactNativeContainerAdapter.d.ts +0 -47
  1048. package/dist/types/client/data/reaction-engine.d.ts +0 -21
  1049. package/dist/types/client/data/window-engine.d.ts +0 -27
  1050. package/dist/types/client/infra/i18n/DefaultI18n.d.ts +0 -7
  1051. package/dist/types/client/infra/notify/DomNotifyService.d.ts +0 -17
  1052. package/dist/types/client/infra/notify/INotifyTheme.d.ts +0 -12
  1053. package/dist/types/client/parser/adaptive-parser.d.ts +0 -28
  1054. package/dist/types/client/parser/blocks/namespace.d.ts +0 -72
  1055. package/dist/types/client/parser/blocks/page-parser.d.ts +0 -30
  1056. package/dist/types/client/parser/blocks/use-parser.d.ts +0 -124
  1057. package/dist/types/client/parser/layout-parser.d.ts +0 -9
  1058. package/dist/types/client/parser/reaction-parser.d.ts +0 -16
  1059. package/dist/types/client/parser/reaction-sugar.d.ts +0 -13
  1060. package/dist/types/client/parser/window-parser.d.ts +0 -25
  1061. package/dist/types/client/quality/SomaQualityRegistry.d.ts +0 -31
  1062. package/dist/types/client/runtime/serialize-page-state.d.ts +0 -10
  1063. package/dist/types/client/theme/harmony.d.ts +0 -119
  1064. package/dist/types/client/theme/scene-tokens.d.ts +0 -41
  1065. package/dist/types/client/theme/theme-axes.d.ts +0 -174
  1066. package/dist/types/client/theme/theme-engine.d.ts +0 -119
  1067. package/dist/types/client/theme/tone-solver.d.ts +0 -51
  1068. package/dist/types/client/typography/typography-base.d.ts +0 -15
  1069. package/dist/types/server/headless/soma-headless-page.d.ts +0 -12
  1070. package/dist/types/server/host/page-response-request.d.ts +0 -8
  1071. package/dist/types/server/host/request-origin.d.ts +0 -1
  1072. package/dist/types/server/host/soma-request-hook-host.stub.d.ts +0 -2
  1073. package/dist/types/server/infra/db/errors.d.ts +0 -5
  1074. package/dist/types/server/infra/db/mapper/PrismaSomaMapper.d.ts +0 -77
  1075. package/dist/types/server/infra/db/mapper/SomaBaseMapper.d.ts +0 -20
  1076. package/dist/types/server/infra/db/mapper/SomaMapperHooks.d.ts +0 -12
  1077. package/dist/types/server/infra/db/query/SomaQuery.d.ts +0 -42
  1078. package/dist/types/server/infra/db/service/SomaDbService.d.ts +0 -24
  1079. package/dist/types/server/infra/db/soma-db.d.ts +0 -45
  1080. package/dist/types/server/infra/db/types.d.ts +0 -18
  1081. package/dist/types/server/ooui.d.ts +0 -18
  1082. package/dist/types/shared/block-errors.d.ts +0 -5
  1083. package/dist/types/shared/component/derive-sample.d.ts +0 -37
  1084. package/dist/types/shared/component/field-lines.d.ts +0 -19
  1085. package/dist/types/shared/container-breakpoints.d.ts +0 -42
  1086. package/dist/types/shared/object-semantics.d.ts +0 -42
  1087. package/dist/types/shared/ooui-declaration.d.ts +0 -135
  1088. package/dist/types/shared/path-algebra.d.ts +0 -56
  1089. package/dist/types/shared/types/adaptive.types.d.ts +0 -88
  1090. package/dist/types/shared/types/layout-constraint.types.d.ts +0 -53
  1091. package/dist/types/shared/types/reaction.types.d.ts +0 -115
  1092. package/dist/types/shared/types/window.types.d.ts +0 -171
  1093. package/next.config.js +0 -387
  1094. package/proxy.ts +0 -62
  1095. /package/{app → host-next/app}/[...path]/page.tsx +0 -0
  1096. /package/{app → host-next/app}/components/SomaHostPage.tsx +0 -0
  1097. /package/{app → host-next/app}/components/SomaHydrationShell.tsx +0 -0
  1098. /package/{app → host-next/app}/components/SomaPageClientBoundary.tsx +0 -0
  1099. /package/{app → host-next/app}/favicon.ico/route.ts +0 -0
  1100. /package/{app → host-next/app}/layout.tsx +0 -0
  1101. /package/{app → host-next/app}/page.tsx +0 -0
  1102. /package/{app → host-next/app}/soma/[...path]/route.ts +0 -0
  1103. /package/{app → host-next/app}/soma/route.ts +0 -0
@@ -1,1427 +0,0 @@
1
- // OOUI 演绎引擎 · 编排层(架构 REQ-014 §19.1)。
2
- //
3
- // 六层管线的**唯一对外入口**:装配词汇 → 一次演绎 → 装配自检。
4
- // 各层自己不认识彼此(依赖闸门 `verify-ooui-dep-graph` 守着单向),
5
- // 串起来这件事只发生在这一个文件里。
6
- //
7
- // ── 为什么"没有这个文件"是一种静默失败 ─────────────────────────────
8
- // 语义、意图、构件、空间四层今天都已落地,各自单测全绿——**而没有任何一条
9
- // 真实页面走过它们**。四层各自"对",串起来是否还对,没有任何断言在看:
10
- //
11
- // ① 层间形状漂移不报错。意图层产的 `SomaIntent` 与构件层收的
12
- // `SomaCompositionRequest` 是结构相容的两个类型,不是同一个。
13
- // 某一层加一个必填字段、另一层没跟上,TypeScript 在**各自的单测里**
14
- // 依然全绿(夹具是手搓的),只有真串起来的那一次才会露馅。
15
- // 没有编排层,这次露馅被推迟到"第一个真页面用它"的那天。
16
- //
17
- // ② 装配空洞不报错。候选表少了某个形态(`comparison` 一条候选都没有),
18
- // `composeComponentCandidates` 不会拦——它只查已写条目的合法性。
19
- // 空洞要到某个页面恰好演绎出这个形态才炸,而那时人在写业务,
20
- // 不在写候选表。`verify()` 把这件事提到宿主启动时。
21
- //
22
- // ③ 词汇装反不报错。`soma-ui` 的空间词表与候选表都是**反向注册**进来的
23
- // (core 不许 import soma-ui)。宿主忘了传其中一份,引擎照样能构造出来,
24
- // 只是"演绎出的界面没有任何间距类"——页面渲染正常,间距全塌,
25
- // 控制台一行都没有。所以装配入口必须在拿不到词表时当场拒收。
26
- //
27
- // ── 今天这条链走到哪里(**不要把这段注释删掉,它是接线的验收面**)──
28
- // 六层已全部接通:① 语义校验 → ② 意图演绎 → ③ 构件选型与 eventMap 接线
29
- // → ④ 空间求解(IR 树 → 逐档解 → 容器查询 CSS + 原子类样式表)
30
- // → ⑤ 产物发射(HTML / bindings / events / selectorProvenance)。
31
- //
32
- // **求解与发射由本文件调,不由产物层自己调。** 依赖闸门只放行"相邻回看上一层的
33
- // 产物契约",所以 `artifact/` 够不着 `spatial/solve.ts` 与 `spatial/emit-utility.ts`。
34
- // 这不是绕路:产物层若自己再解一次布局,仓库里就有了第二份求解器,
35
- // 两份在写下的那天结果一致、单测各自全绿,漂开发生在半年后只修了其中一份那天。
36
- // 编排层同时看得见两层,串起来这件事只发生在这一个文件里。
37
- //
38
- // **最后一公里已接通**:`compilePageOoui()` 产出的 `SomaPageOouiArtifact` 里
39
- // 每个 region 现在带 `html`——`deduce()` 发射出来的那份 DOM 随 `_ui.yaml`
40
- // 一路走到浏览器,由 `soma-bootstrap.ts` 的 `installOouiHtml` 插进锚点。
41
- // 在此之前这条链**止于 `deduce()` 的返回值**:六层全绿、产物齐全、页面上什么都没有,
42
- // 而"锚点空着"与"这块本来就没写内容"长得一模一样——最像成功的那种失败。
43
- //
44
- // 三条纪律随之落到本文件头上,改这里的人必须一起守:
45
- // · **html 逐区域**,不在这里拼成一份整页串。落点是各自的 `data-soma-id` 容器,
46
- // 拼起来运行时就得再拆,而拆的判据是第二份发射器语法。
47
- // · **幂等**:`emitRegionHtml` 的缩进、属性顺序、类名书写序都是定死的,
48
- // 本文件只做搬运,不在中间做任何"顺手整理"(§19.3 内容寻址的前提)。
49
- // · **不可信**:本文件产的 html 会被运行时**再核一道**。这不是不信任自己,
50
- // 是因为产物随 `_ui.yaml` 走,而那份资产可以被手写、被改。
51
- // "引擎生成的"与"可信的"不是同一句话(架构 §24.1)。
52
-
53
- import { createHash } from 'node:crypto';
54
-
55
- import type { HtmlAnchorIndex } from '../blocks/html-index';
56
- // 页面组合层(§29):它在五层之上**扇出**,所以编排层看得见它,反过来不行。
57
- import {
58
- assertPageComposition,
59
- findRegionRow,
60
- narrowestAvailRem,
61
- pageBudgetTraces,
62
- pageCompositionTraces,
63
- solvePageBudget,
64
- } from './page';
65
- import type { SomaPageComposition, SomaRegion } from './page';
66
- import type {
67
- ShowMapping,
68
- SomaOouiNode,
69
- SomaOouiRegion,
70
- SomaOouiRequestDeclaration,
71
- SomaPageOouiArtifact,
72
- } from '../../shared/types/ui-config.types';
73
- // `ooui:` 段的键闭集与形状判据:运行时解析器(`ui-config-parser.ts`)用的是**同一份**。
74
- // 住在 `core/shared/` 是因为 client 不许 import `core/build`,而两边各抄一份的结果是
75
- // 解析器收下了 `bound_to` / `layout` 却没有搬进声明——能写、不报错、值被静默丢弃。
76
- import {
77
- SOMA_OOUI_BINDING_KEYS,
78
- SOMA_OOUI_LAYOUT_KEYS,
79
- SOMA_OOUI_REQUEST_KEYS,
80
- SOMA_OOUI_SIZINGS,
81
- findOouiBindingUnknownKey,
82
- findOouiLayoutProblem,
83
- isOouiBinding,
84
- isOouiFocus,
85
- isOouiLayout,
86
- isOouiMap,
87
- isOouiText,
88
- } from '../../shared/ooui-declaration';
89
-
90
- import type { SomaObject, SomaSemanticRequest, SomaSource, SomaVerb } from './semantic/kernel.types';
91
- import { semanticRequestTrace, validateSemanticRequest } from './semantic/validate-request';
92
-
93
- import type {
94
- SomaControlModel,
95
- SomaIntent,
96
- SomaIntentFieldRule,
97
- SomaInteractionForm,
98
- SomaInteractionKind,
99
- } from './intent/intent.types';
100
- import { deriveIntent } from './intent/derive-intent';
101
- import { intentTrace } from './intent/intent.types';
102
- import { verifyIntentRules } from './intent/field-rules';
103
-
104
- import type {
105
- SomaCandidateRegistryLike,
106
- SomaComponentCandidate,
107
- SomaComponentCandidateInput,
108
- SomaComponentContractView,
109
- SomaCompositionVocabulary,
110
- } from './composition/candidate.types';
111
- import {
112
- composeComponentCandidates,
113
- verifyInteractionKindPartition,
114
- type SomaCandidateRegistry,
115
- type SomaFormCoverage,
116
- } from './composition/registry';
117
- import { compositionRequestFromIntent, selectComponent } from './composition/select';
118
- import { compositionTrace } from './composition/candidate.types';
119
-
120
- import type { SomaSpatialToken, SomaUtility, SomaVariant } from './spatial/utility.types';
121
- import { composeSpatialVocabulary, type SomaSpatialRegistry } from './spatial/registry';
122
- import { emitUtilityStylesheet } from './spatial/emit-utility';
123
- import { solveSpatial } from './spatial/solve';
124
- import { spatialTraces } from './spatial/ir.types';
125
-
126
- import { emitArtifact, spatialTreeFromNode, type SomaArtifact } from './artifact';
127
-
128
- import { SomaOouiError, foldOouiIssues } from './diagnostics';
129
- import type { SomaOouiIssue } from './diagnostics';
130
-
131
- // 横切层 trace(架构 §5):链条由**本文件**接起来。
132
- // 各层只造自己那一跳(层内才认识自己的产物字段),跨层挂 parent 是编排层的活——
133
- // 让某一层去认识上一层的 trace 实例,依赖闸门当场判 SKIP-BACK / ADJACENT-IMPL。
134
- import type { SomaTrace } from './trace';
135
-
136
- /**
137
- * trace 的对外面(架构 §5 的两种形态):结构化链条给闸门与工具,`renderTrace` 给人。
138
- *
139
- * 为什么从这里转口而不是让调用方 import `./trace/*`:`ooui/index.ts` 是六层管线的
140
- * **唯一对外入口**(§19.1)。调用方一旦按目录结构 import,层搬一次家就有一批
141
- * import 要改,而改漏的那几处只在别人的构建里才断(`SomaSource` 已经因此漂成过三份)。
142
- */
143
- export {
144
- SOMA_TRACE_LAYERS,
145
- formatTraceLine,
146
- linkTrace,
147
- pushTrace,
148
- renderTrace,
149
- renderTraceNotes,
150
- renderTraces,
151
- traceAtLayer,
152
- traceChain,
153
- traceDefects,
154
- traceLink,
155
- traceRoot,
156
- tracesForPath,
157
- type SomaRenderTraceOptions,
158
- type SomaTraceDefectOptions,
159
- type SomaTraceInput,
160
- type SomaTraceLayer,
161
- type SomaTraceOrigin,
162
- } from './trace';
163
- export { originTraces } from './semantic/origin.types';
164
- // 表层在页面上的入口(§38.5 断线 ②)。转口在这里而不是让编译器 import
165
- // `./semantic/expand-page-surface`,理由同上:`ooui/index.ts` 是六层管线的唯一对外入口。
166
- export { expandPageSurface } from './semantic/expand-page-surface';
167
- export type { ExpandPageSurfaceInput, ExpandedPageSurface } from './semantic/expand-page-surface';
168
- export { intentTrace } from './intent/intent.types';
169
- export { compositionTrace } from './composition/candidate.types';
170
- // 组件契约 → 构件层视图的**唯一转换点**。宿主拼词汇包时要用它把自己注册的那张组件表
171
- // 转成 `SomaOouiPack.contracts`(soma-ui 的 `createSomaUiOouiPack({ contracts })` 就这么要求);
172
- // 不从入口转口的话,第三方宿主只能 deep-import 构件层,或者自己摊一遍——后者就是第二份转换。
173
- export { contractView } from './composition/candidate.types';
174
- export { decisionTrace, spatialPlanTrace, spatialTraces } from './spatial/ir.types';
175
- export { semanticRequestTrace } from './semantic/validate-request';
176
- export { traceChainForSelector, traceForSelector } from './artifact';
177
-
178
- // ─────────────────────────────────────────────────────────────────────
179
- // 错误
180
- // ─────────────────────────────────────────────────────────────────────
181
-
182
- /**
183
- * 编排层的错误:**直接用横切层的 `SomaOouiError`**(架构 §20.1),不另立一个类。
184
- *
185
- * 此前这里有一个同名的本地类,构造签名是 `(message, path)`——**没有 code、
186
- * 没有 layer、没有 remedy**,而它占用的正是架构给统一错误保留的那个名字。
187
- * 这不是"少了两个字段":发布闸门 `compile-gate.ts` 用鸭子类型从抛出来的错误上读
188
- * `code` / `layer` / `remedy` / `src` / `trace` 五个字段装进结构化诊断,
189
- * soma-ai 的自修复回路正是靠 `remedy` 决定改哪一行的。本地类一个都没有,
190
- * 于是页面接线的十处失败抛出来的诊断里 code 与 remedy 全是空的,
191
- * **而闸门不会红**——诊断结构是全可选字段,少字段与"这次错误确实没有更多信息"
192
- * 长得一模一样。
193
- *
194
- * 各层自己的错误(`SomaCompositionError` / 空间层的 `SomaSpatialError`)**原样上抛**,
195
- * 不再包一层:它们已经是同一个基类的子类,文案已经是三段式、已经点到了具体声明,
196
- * 再包一层只会把关键信息推到第二屏。这里只负责各层**返回 issues 而不抛**的那几处
197
- * (语义校验与意图演绎),以及页面级接线自己的判断(锚点、对象名、请求形状)。
198
- */
199
- export { SomaOouiError };
200
-
201
- // ─────────────────────────────────────────────────────────────────────
202
- // 装配
203
- // ─────────────────────────────────────────────────────────────────────
204
-
205
- /**
206
- * 一个包交给引擎的东西(架构 §19.1 的 `SomaOouiPack`)。
207
- *
208
- * `contracts` 是架构原文没有的一项,但**没它装不起来**:构件层要拿组件的真 `emits`
209
- * 去核 `eventMap` 的每一个键(`OOUI-CMP-GHOST-EMIT`),而契约住在组件库那边,
210
- * core 不许 import 它。谁提供候选,谁就得同时提供那些组件的契约视图——
211
- * 否则"候选表写了一个不存在的 emit"这件事就没人查得出来,
212
- * 表现是运行期"点了没反应",而候选表看着完全正常。
213
- */
214
- export interface SomaOouiPack {
215
- /** 包名。冲突消息、来源登记与覆盖裁决都用它 */
216
- name: string;
217
- version?: string;
218
- /** 构件层:形态 → 组件候选 */
219
- candidates?: readonly SomaComponentCandidateInput[];
220
- /** 构件层:本包提供的组件契约视图(候选里出现的组件都得在这里) */
221
- contracts?: readonly SomaComponentContractView[];
222
- /** 空间层:令牌表 */
223
- tokens?: readonly SomaSpatialToken[];
224
- /** 空间层:原子类表 */
225
- utilities?: readonly SomaUtility[];
226
- /** 空间层:变体表。通常不必给——容器变体由 core 内建 */
227
- variants?: readonly SomaVariant[];
228
- /** 意图层:追加的字段级规则,与内置表**一起**参与冲突判定 */
229
- intentRules?: readonly SomaIntentFieldRule[];
230
- /** 空间词汇的显式覆盖声明:本包允许盖掉哪些包的同名条目 */
231
- overrides?: readonly string[];
232
- }
233
-
234
- /**
235
- * 一次演绎的环境(架构 §19.1 的 `SomaEnvironment`)。
236
- *
237
- * 与架构原文的两处出入,都是实现时才暴露出来的:
238
- * · 多了 `relatedObjects`——`through`(§27.2)要拿关系另一端的对象去演绎字段,
239
- * 缺它则 `compare` / `navigate` 演绎出一个没有字段的页面,
240
- * 而那恰好是最像成功的失败:框架在、标题在、空白在。
241
- * · 少了 `grants`——写通道授权今天由对象自己的 `write` 段承担
242
- * (`OOUI-SEM-WRITE-NO-ENDPOINT` / `OOUI-INT-GRANT-MISSING` 都从那里判),
243
- * 再放一份 env 级授权会出现两个都"对"的答案。
244
- */
245
- export interface SomaEnvironment {
246
- /**
247
- * 容器可用宽度档名(如 `cqLg`)。**今天仍然只是记录,不参与任何求解。**
248
- *
249
- * 二级求解按八档**全部**解一遍并发容器查询(`@container`),运行时按真实容器宽
250
- * 自己命中哪一档——那正是它比"编译期挑一档焊死"强的地方(架构 D4)。
251
- * 所以这个字段没有消费方;留着是因为诊断报告要说得出"这次演绎是按哪一档看的"。
252
- * 真正影响构件选择的是 `availRem`。
253
- */
254
- breakpoint?: string;
255
- /**
256
- * 本次可用的行内宽(rem)。
257
- *
258
- * **省略是有风险的**:`minInline` 是唯一挡得住"组件塞不进去"的东西,
259
- * 而塞不进去在浏览器里不报错。页面级演绎请把档位宽度传进来。
260
- */
261
- availRem?: number;
262
- /** 宿主实际装配了哪些组件。给了就按它筛候选,不给 = 不筛 */
263
- availableComponents?: ReadonlySet<string>;
264
- /** `through` 指向的关联对象字典 */
265
- relatedObjects?: Readonly<Record<string, SomaObject>>;
266
- /**
267
- * 这一处演绎落在哪个 HTML 锚点上(`data-soma-id`)。产物层按它生成内部 id
268
- * (`<锚点>-shell` / `<锚点>-root`)与 `selectorProvenance` 的值。
269
- *
270
- * 缺省 `'ooui'` 只服务于**单区域**的直接调用(测试、工具)。
271
- * 页面级接线永远显式给:同一页两个区域共用一个缺省锚点的话,
272
- * 两份产物的选择器会完全重合,后注入的那份静默盖住先注入的,
273
- * 而两块都还渲染着——只是其中一块的样式来自另一块。
274
- */
275
- anchor?: string;
276
- /**
277
- * 整页已占用的锚点 id。给了就核对产出的 id 有没有撞车(`OOUI-ART-ANCHOR-DUPLICATE`)。
278
- * 不给则**不核**,且这件事会记进产物的 `decisions`——不假装核过了。
279
- */
280
- reservedAnchors?: ReadonlySet<string>;
281
- locale?: string;
282
- }
283
-
284
- /** 一次演绎的产物片段。`root` 是这一处界面的节点树 */
285
- export interface SomaOouiFragment {
286
- root: SomaOouiNode;
287
- /**
288
- * 空间层要发射的原子类候选(升序去重)。
289
- *
290
- * 它就是 `artifact.classes`——**同一份数组,不是第二份清单**。
291
- * 留这个字段是因为页面级接线要把各区域的候选并起来发一份总样式表,
292
- * 而那一段代码不必知道产物层的内部结构。
293
- */
294
- classes: readonly string[];
295
- /**
296
- * ④ 这一处区域的**布局 CSS**(容器查询与组骨架),不含原子类规则。
297
- *
298
- * 单独留一份而不是只给 `artifact.css`:页面级要把各区域的**原子类合并成一份**
299
- * (同一个 `soma-pad-5` 在五个区域里只该有一条规则),而布局 CSS 是逐区域的、
300
- * 不可合并。两者混在一起的话,页面级只能选"重复发射原子类"或"丢掉布局",
301
- * 而后者的表现是**间距类整片失效**——`gap` 只在 flex/grid 容器上生效,
302
- * 骨架没发出来时它一条都不起作用,页面照常渲染,控制台一行都没有。
303
- */
304
- layoutCss: string;
305
- /** ⑤ 产物:HTML / CSS / 绑定 / 事件 / selectorProvenance(架构 §3.5) */
306
- artifact: SomaArtifact; /**
307
- * 本次演绎的完整推导链(架构 §5)。**它就是 `artifact.trace`——同一份数组,不是第二份台账。**
308
- *
309
- * 留这个字段是因为闸门与诊断工具要的是"这次演绎解释得了自己吗",
310
- * 而那一问不该逼调用方先知道产物层的内部结构。复制一份出来则更坏:
311
- * 两份数组在某次改动后各带一半链条,而"链条少一节"在产物里看不出来。
312
- */
313
- trace: readonly SomaTrace[];
314
- }
315
-
316
- /** 装配自检报告(架构 §19.1 的 `SomaVerifyReport`) */
317
- export interface SomaVerifyReport {
318
- ok: boolean;
319
- /** 十九形态全景,含零候选的那些 */
320
- coverage: readonly SomaFormCoverage[];
321
- /** 一条候选都没有的形态——**这才是最该在启动时看见的那一行** */
322
- hollows: readonly string[];
323
- /** 其余问题:规则表、事件族划分 */
324
- issues: readonly string[];
325
- stats: {
326
- packs: number;
327
- components: number;
328
- utilities: number;
329
- tokens: number;
330
- variants: number;
331
- intentRules: number;
332
- };
333
- }
334
-
335
- /**
336
- * 形态逃生门(§3.2):直接指定根形态,跳过动词分派。
337
- *
338
- * 它是**第三个参数**而不是 `SomaEnvironment` 的一个字段(架构 §19.1 只写了两个参数):
339
- * 塞进 env 会让"同一份语义在不同环境下形态不同"成为可能,而形态是语义的函数,
340
- * 不是环境的函数——环境只挑组件(宽度、已装配清单),不挑形态。
341
- * 两者混在一起之后,"为什么这页是列表那页是卡片"就再也答不出来了。
342
- */
343
- export interface SomaOouiHatch {
344
- form?: SomaInteractionForm;
345
- }
346
-
347
- /** 引擎(架构 §19.1 的 `SomaOouiEngine`) */
348
- export interface SomaOouiEngine {
349
- /** 一次演绎:语义 → 界面节点树 + 布局解 + 可执行产物(HTML / CSS / 绑定 / 事件) */
350
- deduce(request: SomaSemanticRequest, env?: SomaEnvironment, hatch?: SomaOouiHatch): SomaOouiFragment;
351
- /** 只跑到意图层,用于诊断与工具 */
352
- explain(request: SomaSemanticRequest, env?: SomaEnvironment, hatch?: SomaOouiHatch): SomaIntent;
353
- /** 装配自检:候选覆盖率、形态空洞、规则表 */
354
- verify(): SomaVerifyReport;
355
- /** 一批原子类候选 → 一份样式表。候选为空时返回空串(不产出空 `<style>`) */
356
- emitStylesheet(classes: readonly string[]): string;
357
- readonly candidates: SomaCandidateRegistry;
358
- readonly spatial: SomaSpatialRegistry;
359
- readonly intentRules: readonly SomaIntentFieldRule[];
360
- }
361
-
362
- /** 只暴露候选表最小面的筛选视图:`availableComponents` 之外的候选当作不存在 */
363
- function filterRegistry(
364
- registry: SomaCandidateRegistry,
365
- available: ReadonlySet<string>,
366
- ): SomaCandidateRegistryLike {
367
- const cache = new Map<string, readonly SomaComponentCandidate[]>();
368
- return {
369
- forms: registry.forms,
370
- candidatesFor(form: SomaInteractionForm): readonly SomaComponentCandidate[] {
371
- const hit = cache.get(form);
372
- if (hit) return hit;
373
- // 文本节点没有契约、也不需要装配,永远可用——把它当"未装配"筛掉,
374
- // 会让 display/plain 这类最常见的字段级形态整片选不出组件。
375
- const list = registry.candidatesFor(form)
376
- .filter((candidate) => candidate.layer === 'text-node' || available.has(candidate.component));
377
- cache.set(form, list);
378
- return list;
379
- },
380
- };
381
- }
382
-
383
- /**
384
- * 装配引擎。宿主启动时一次。
385
- *
386
- * 装配不过**当场抛**(`composeComponentCandidates` / `composeSpatialVocabulary` 的既有行为):
387
- * 一个装不起来的引擎继续跑下去,产出的是"少了一半词汇"的界面,而不是错误。
388
- */
389
- export function assembleOoui(packs: readonly SomaOouiPack[]): SomaOouiEngine {
390
- if (!Array.isArray(packs) || packs.length === 0) {
391
- throw new SomaOouiError({
392
- layer: 'assembly',
393
- code: 'OOUI-ASM-NO-PACK',
394
- situation: '没有传入任何词汇包。',
395
- problem: '引擎自己不持有任何组件候选与空间词汇——它们由组件库反向注册进来'
396
- + '(core 不许 import soma-ui)。零包装配出来的引擎能构造、能调用,'
397
- + '只是每一次演绎都选不出组件,而那时的报错指向的是页面,不是这次装配。',
398
- remedy: "assembleOoui([{ name: 'soma-ui', "
399
- + 'candidates: createSomaUiComponentCandidates().candidates, '
400
- + 'contracts: somaUiContractViewsFromCatalog(catalog.entries), '
401
- + '...createSomaUiSpatialVocabulary() }])',
402
- src: { file: '<host:bootstrap>', path: 'assembleOoui' },
403
- });
404
- }
405
-
406
- const spatialVocabularies = packs
407
- .filter((pack) => pack.tokens?.length || pack.utilities?.length || pack.variants?.length)
408
- .map((pack) => ({
409
- name: pack.name,
410
- ...(pack.version !== undefined ? { version: pack.version } : {}),
411
- ...(pack.tokens ? { tokens: pack.tokens } : {}),
412
- ...(pack.utilities ? { utilities: pack.utilities } : {}),
413
- ...(pack.variants ? { variants: pack.variants } : {}),
414
- ...(pack.overrides ? { overrides: pack.overrides } : {}),
415
- }));
416
- // 容器变体由 core 内建并入(断点真源归 core),不要关掉它。
417
- const spatial = composeSpatialVocabulary(spatialVocabularies);
418
-
419
- const compositionVocabularies: SomaCompositionVocabulary[] = packs
420
- .filter((pack) => pack.candidates?.length)
421
- .map((pack) => ({
422
- name: pack.name,
423
- ...(pack.version !== undefined ? { version: pack.version } : {}),
424
- candidates: pack.candidates!,
425
- }));
426
- const contracts = packs.flatMap((pack) => pack.contracts ?? []);
427
- const candidates = composeComponentCandidates(compositionVocabularies, { contracts });
428
-
429
- const intentRules = packs.flatMap((pack) => pack.intentRules ?? []);
430
-
431
- const engine: SomaOouiEngine = {
432
- candidates,
433
- spatial,
434
- intentRules,
435
-
436
- emitStylesheet(classes: readonly string[]): string {
437
- if (classes.length === 0) return '';
438
- return emitUtilityStylesheet(classes, spatial).css;
439
- },
440
-
441
- explain(request: SomaSemanticRequest, env: SomaEnvironment = {}, hatch: SomaOouiHatch = {}): SomaIntent {
442
- return explainWithTrace(request, env, hatch).intent;
443
- },
444
-
445
- deduce(request: SomaSemanticRequest, env: SomaEnvironment = {}, hatch: SomaOouiHatch = {}): SomaOouiFragment {
446
- // 链条的根:那句对象声明(架构 §5「一路回溯到某句对象声明」的落点)。
447
- // `explainWithTrace` 顺手把它交回来,免得这里再算一遍——同一份链条算两次
448
- // 不会错,但下一个人改了其中一处就会漂,而两条链看起来都像完整的。
449
- const traces: SomaTrace[] = [];
450
- const { intent, semanticLink } = explainWithTrace(request, env, hatch);
451
- traces.push(semanticLink);
452
- // 从这里往下的每一层失败,都要带上**到失败点为止**的链条(§38.5 断线 ③)。
453
- //
454
- // 为什么补在这里而不是各层的抛出点:抛的那一层手里没有链条。
455
- // 空间层求解失败时它只知道自己收到的 IR,"这份 IR 是哪个动词、经哪条规则、
456
- // 选中哪个组件推出来的"住在本层。要让每一层都能传,就得把整条链一路穿过
457
- // 五层的函数签名——而任何一层忘了透传都不报错,表现是"某一类错误没有 trace",
458
- // 与"这类错误本来就推不出链"分不开。
459
- //
460
- // soma-ai 的自修复回路读的正是这条链:没有它,模型看到的只是
461
- // "comparison 形态无可用候选",看不到是哪个对象的哪个动词推到这一步的。
462
- try {
463
- return deduceFrom(intent, request, env, hatch, traces);
464
- } catch (error) {
465
- if (error instanceof SomaOouiError) throw error.attachTrace(traces);
466
- throw error;
467
- }
468
- },
469
-
470
- verify(): SomaVerifyReport {
471
- const coverage = candidates.coverage();
472
- const hollows = coverage.filter((entry) => entry.count === 0).map((entry) => entry.form);
473
- const issues = [
474
- ...verifyInteractionKindPartition(),
475
- ...verifyIntentRules(intentRules.length > 0 ? intentRules : undefined).issues,
476
- ];
477
- return {
478
- ok: hollows.length === 0 && issues.length === 0,
479
- coverage,
480
- hollows,
481
- issues,
482
- stats: {
483
- packs: packs.length,
484
- // 文本节点不是组件:把它算进"装配了几个组件"会让这个数字永远比实际多一,
485
- // 而这个数字的唯一用途就是"防空词表也叫绿"。
486
- components: new Set(
487
- candidates.candidates
488
- .filter((candidate) => candidate.layer !== 'text-node')
489
- .map((candidate) => candidate.component),
490
- ).size,
491
- utilities: spatial.stats.utilities,
492
- tokens: spatial.stats.tokens,
493
- variants: spatial.stats.variants,
494
- intentRules: intentRules.length,
495
- },
496
- };
497
- },
498
- };
499
-
500
- /**
501
- * 意图层之后的四步(构件 → 空间 → 样式表 → 产物)。
502
- *
503
- * 单独拆出来只为一件事:让 `deduce` 能用一个 try 把它整段包住,
504
- * 在 catch 里给错误补上**到失败点为止**的链条(§38.5 断线 ③)。
505
- * 内联在 try 里也能跑,但那会让 `deduce` 变成一个七十行的 try 块,
506
- * 而"哪些语句在 try 里"这件事以后靠缩进去读。
507
- *
508
- * `traces` 是**入参且会被就地追加**:调用方在 catch 里读的正是这个数组,
509
- * 所以这里不能换成新数组返回——换了之后 catch 拿到的还是只有语义那一跳。
510
- */
511
- /**
512
- * 语义校验 + 意图演绎,**顺手把语义那一跳的 trace 交回来**。
513
- *
514
- * `explain()` 是公开 API,签名只返回 `SomaIntent`——不动它。
515
- * 而 `deduce()` 需要那一跳当链条的根(架构 §5「一路回溯到某句对象声明」),
516
- * 在 `deduce` 里再调一次 `semanticRequestTrace(request)` 也能拿到,
517
- * 只是仓库里就有了两处算同一条链的地方:下一个人改了其中一处就会漂,
518
- * 而两条链看起来都像完整的。
519
- */
520
- function explainWithTrace(
521
- request: SomaSemanticRequest,
522
- env: SomaEnvironment,
523
- hatch: SomaOouiHatch,
524
- ): { intent: SomaIntent; semanticLink: SomaTrace } {
525
- const path = request.src?.path ?? 'ooui';
526
- const semanticIssues = validateSemanticRequest(request);
527
- if (semanticIssues.length > 0) {
528
- // 语义校验失败时**不带链条**,且这是有意的:那一刻什么都还没推出来。
529
- // 编一条链上去等于告诉读者"它是这么推到这一步的",而它并没有。
530
- throw aggregate('semantic', '语义声明不合法', semanticIssues, path);
531
- }
532
- const semanticLink = semanticRequestTrace(request);
533
- const result = deriveIntent(request, {
534
- ...(hatch.form !== undefined ? { form: hatch.form } : {}),
535
- ...(intentRules.length > 0 ? { rules: intentRules } : {}),
536
- ...(env.relatedObjects ? { relatedObjects: env.relatedObjects } : {}),
537
- });
538
- if (result.intent === null || result.issues.length > 0) {
539
- // 意图层失败时**带上语义那一跳**:它确实成立了,而"哪句对象声明"
540
- // 正是修法的起点——soma-ai 的自修复回路读的就是这条链。
541
- throw aggregate('intent', '意图演绎不通过', result.issues, path, [semanticLink]);
542
- }
543
- return { intent: result.intent, semanticLink };
544
- }
545
-
546
- function deduceFrom(
547
- intent: SomaIntent,
548
- request: SomaSemanticRequest,
549
- env: SomaEnvironment,
550
- hatch: SomaOouiHatch,
551
- traces: SomaTrace[],
552
- ): SomaOouiFragment {
553
-
554
- const registry = env.availableComponents
555
- ? filterRegistry(candidates, env.availableComponents)
556
- : candidates;
557
- const region = env.anchor ?? DEFAULT_ANCHOR;
558
- const semanticLink = traces[0]!;
559
- const composed = composeNode(intent, registry, env.availRem, {
560
- traces,
561
- parent: semanticLink,
562
- path: region,
563
- // 逃生门给了形态 = 作者显式声明(铁律一:显式声明永远赢)。
564
- // 不标注的话,报告会把作者亲手写下的 form 说成"命中规则「…」推出来的",
565
- // 而他去改那条规则改不动任何东西。
566
- forcedForm: hatch.form !== undefined,
567
- });
568
- const root = composed.node;
569
-
570
- // ④→⑤ 的三步由**编排层**串(见文件头):组树 → 求解 → 发射样式表,
571
- // 然后把三份产物一起交给产物层。产物层自己够不着这三个函数,也不该够得着。
572
- const tree = spatialTreeFromNode(root, {
573
- region,
574
- ...(env.reservedAnchors !== undefined ? { reservedAnchors: env.reservedAnchors } : {}),
575
- });
576
- const plan = solveSpatial(tree.tree, {
577
- ...(env.availRem !== undefined ? { availRem: env.availRem } : {}),
578
- });
579
- const stylesheet = emitUtilityStylesheet(plan.utilityCandidates, spatial);
580
- // ④ 的 trace 由空间层自己转(`spatialTraces`),本文件只负责把它挂到 ③ 下面。
581
- // 第 0 位恒为层首,产物层的每一跳都挂在它下面。
582
- const spatialLinks = spatialTraces(plan, composed.composition);
583
- traces.push(...spatialLinks);
584
- const artifact = emitArtifact({
585
- node: root,
586
- region,
587
- object: request.object.name,
588
- labels: fieldLabels(request.object),
589
- tree,
590
- plan,
591
- stylesheet,
592
- trace: traces,
593
- parent: spatialLinks[0],
594
- });
595
-
596
- return {
597
- root,
598
- classes: artifact.classes,
599
- layoutCss: plan.css,
600
- artifact,
601
- // 同一份数组,不复制(见 `SomaOouiFragment.trace` 的注释)。
602
- trace: artifact.trace,
603
- };
604
- }
605
-
606
- return engine;
607
- }
608
-
609
- /**
610
- * 意图树 → 界面节点树。
611
- *
612
- * 行内宽只传给**根节点**:字段级形态由容器分配空间,把页面档宽原样传给每个字段,
613
- * 等于宣称"每个字段都能用整页宽",宽度约束(`minInline`)就此形同虚设——
614
- * 而形同虚设的约束不会报错,只会让窄档下的组件挤成一团。
615
- */
616
- /**
617
- * 组树时收 trace 的上下文(架构 §5)。
618
- *
619
- * `path` 与产物层的决策路径**必须同一套口径**(根是区域名,字段是 `区域.字段键`,
620
- * 见 `collectFieldBindings`):两边各写各的话,`traceForSelector` 会按选择器查到
621
- * 一个节点路径、却在 trace 里一条都匹配不上——而"查不到"与"这条选择器没有推导"
622
- * 长得一模一样,且两边各自的测试都是绿的。
623
- */
624
- interface ComposeTraceContext {
625
- /** 收集面:本次演绎的全部 trace,按发生顺序 */
626
- readonly traces: SomaTrace[];
627
- /** 上一跳(根节点是语义层那条,子节点是父意图那条) */
628
- readonly parent: SomaTrace;
629
- /** 本节点在产物里的路径 */
630
- readonly path: string;
631
- /** 根形态是不是逃生门显式给的 */
632
- readonly forcedForm: boolean;
633
- }
634
-
635
- function composeNode(
636
- intent: SomaIntent,
637
- registry: SomaCandidateRegistryLike,
638
- availRem: number | undefined,
639
- ctx: ComposeTraceContext,
640
- ): { node: SomaOouiNode; composition: SomaTrace } {
641
- // ② 这一跳:形态是怎么来的。挂在 ① 那句对象声明下面。
642
- const intentLink = intentTrace(intent, {
643
- parent: ctx.parent,
644
- ...(ctx.forcedForm ? { origin: 'declared' as const } : {}),
645
- });
646
- ctx.traces.push(intentLink);
647
-
648
- // 选不出来 selectComponent 当场抛(`OOUI-CMP-NO-CANDIDATE` / `-NO-VIABLE-CANDIDATE`),
649
- // 那两条错误已经把候选逐个列了出来,这里不拦。
650
- const choice = selectComponent(compositionRequestFromIntent(intent, availRem), registry);
651
- // ③ 这一跳:组件是怎么选出来的。`availRem` 只在根节点有值——
652
- // 字段级的可用宽由容器分配,把页面档宽原样传下去等于宣称"每个字段都能用整页宽",
653
- // 而 trace 里那句"可用宽 40rem ≥ 其要求的 18rem"会因此在字段级说谎。
654
- const compositionLink = compositionTrace(choice, {
655
- parent: intentLink,
656
- path: ctx.path,
657
- ...(availRem !== undefined ? { availRem } : {}),
658
- });
659
- ctx.traces.push(compositionLink);
660
-
661
- const node: SomaOouiNode = {
662
- form: choice.form,
663
- component: choice.component,
664
- layer: choice.layer,
665
- control_model: choice.controlModel,
666
- rule: intent.rule,
667
- };
668
- if (intent.variant !== undefined) node.variant = intent.variant;
669
- if (intent.field !== undefined) node.field = intent.field;
670
- if (choice.eventRoutes.length > 0) {
671
- node.events = choice.eventRoutes.map((route) => ({ emit: route.emit, kinds: [...route.kinds] }));
672
- }
673
- if (intent.children && intent.children.length > 0) {
674
- node.children = intent.children.map((child) => composeNode(child, registry, undefined, {
675
- traces: ctx.traces,
676
- // 子意图的因果上一跳是**父意图**,不是父构件:字段形态是从根意图分派下来的,
677
- // 与根节点选中了哪个组件无关。挂到父构件下的话,报告会说
678
- // "因为根选了 DetailConsole,所以这个字段是 amount 形态"——那是假因果。
679
- parent: intentLink,
680
- path: `${ctx.path}.${child.field ?? '?'}`,
681
- forcedForm: false,
682
- }).node);
683
- }
684
- return { node, composition: compositionLink };
685
- }
686
-
687
- /**
688
- * 单区域直接调用时的缺省锚点。**只给测试与工具用**——页面级接线永远显式给。
689
- *
690
- * 不留缺省的话,`deduce(request)` 这条最短调用路径就得先编一个锚点名出来,
691
- * 而各调用点各编一个的结果是产物里的选择器随调用点变化,
692
- * 内容寻址(§22.2 ⑤ 的缓存键)会把同一份界面当成好几份资产。
693
- */
694
- const DEFAULT_ANCHOR = 'ooui';
695
-
696
- /**
697
- * 字段键 → 业务显示名(§24.2:显示名在语义层解决,引擎不产生任何面向用户的文案)。
698
- *
699
- * 为什么由编排层搬运:产物层要给每个字段一个标签,而对象声明住在语义层,
700
- * 产物层回看四层是 `SKIP-BACK`;构件层的产物 `SomaOouiNode` 上**没有显示名字段**。
701
- * 这条搬运是编排层的活——它同时看得见两端。缺 `name` 的字段不补默认文案,
702
- * 由产物层回退成字段键并记一条 `inferred` 决策。
703
- */
704
- function fieldLabels(object: SomaObject): Record<string, string> {
705
- const labels: Record<string, string> = {};
706
- for (const [key, field] of Object.entries(object.fields ?? {})) {
707
- if (typeof field?.name === 'string' && field.name !== '') labels[key] = field.name;
708
- }
709
- return labels;
710
- }
711
-
712
- // ─────────────────────────────────────────────────────────────────────
713
- // 页面级接线(仿 `core/build/layout/page-layout.ts`)
714
- // ─────────────────────────────────────────────────────────────────────
715
-
716
- export interface CompilePageOouiInput {
717
- /** 页面块直通的 `ooui:` 段原文 */
718
- raw: unknown;
719
- htmlIndex: HtmlAnchorIndex;
720
- /**
721
- * 页面 HTML——**与 `htmlIndex` 同一份**(include 已展开)。锚点索引只回答"有没有这个锚点",
722
- * 预算 CSS 还要知道"各区域锚点的父元素是谁"(`findRegionRow`),那得看元素结构。
723
- *
724
- * **必填**,理由同 `show`:可选的话调用方忘传时预算 CSS 就静默不发,而"没发"与
725
- * "这页的区域本来就不并排"在产物里分不开。
726
- */
727
- html: string;
728
- /** 页面 `data:` 段解析出的对象字典(对象名 → 对象) */
729
- objects: Readonly<Record<string, SomaObject>>;
730
- /** 宿主装配好的引擎。缺它则页面写了 `ooui:` 也演绎不了——调用方负责当场拒收 */
731
- engine: SomaOouiEngine;
732
- /**
733
- * 宿主类名(= 页面根上 `data-soma-host` 的值)。用于 `src.file` 的合成来源,
734
- * 以及页面区域组 CSS 的作用域前缀(`[data-soma-host="<宿主类>"]`,与 `layout:` 段同一写法)。
735
- */
736
- hostClass: string;
737
- /**
738
- * 整页 `show:` 段(`compiled.ui.show`)。用来交叉校验"这个锚点是不是也被 show 绑着"
739
- * (`OOUI-SEM-ANCHOR-SHOW-CONFLICT`)。
740
- *
741
- * **必填,不给可选默认值。** 可选的话,调用方哪天忘了传,这道交叉校验就静默关掉,
742
- * 而它守的失败正是"渲染正常、控制台一行都没有"那一类——闸门关了与"页面没冲突"
743
- * 长得一模一样。写成必填,忘传当场是编译错误。
744
- */
745
- show: ShowMapping;
746
- env?: SomaEnvironment;
747
- }
748
-
749
- export interface CompiledPageOoui {
750
- /** 声明本身(已校验形状与引用)。写回内存 UiConfig,**不下发给运行时** */
751
- declarations: Record<string, SomaOouiRequestDeclaration>;
752
- /** 产物。下发给运行时 */
753
- artifact: SomaPageOouiArtifact;
754
- /**
755
- * 页面组合层的推导链:空间预算的决策(每个区域按什么约束分宽、sizing / gap / wrap 取了缺省、
756
- * 预算 CSS 落在哪个区域行上或为什么没发)在前,演绎之后那一遍联动裁决
757
- * (哪条 `bound_to` 依据哪个动词、哪种控制模型成立)在后。
758
- *
759
- * 架构 §5 的硬要求是"没有 trace 的推导不允许进主路径"——而这两项推导此前**只在单测里
760
- * 转成过 trace**:`compilePageOoui` 算完预算、裁完联动就把结论丢了,于是报告说得出
761
- * "这个组件为什么被选中",说不出"这个区域为什么只分到 22rem"、"这条联动凭什么成立"。
762
- *
763
- * **编译期诊断,不进产物**(与 `oouiOrigins` 同一条纪律):它对渲染没有任何影响,
764
- * 进产物只会让内容寻址把"报告措辞改了一个字"当成一次产物变更。
765
- * 各区域自己的六层链条仍挂在各自的错误与产物上,这里只放页面这一层的。
766
- */
767
- traces: readonly SomaTrace[];
768
- }
769
-
770
- /**
771
- * 页面接线的形状拒收。
772
- *
773
- * `code` 默认取 `OOUI-SEM-BLOCK-SHAPE`——`ooui:` 段是**语义表层的声明**,
774
- * 形状写错违反的是语义层的契约,虽然发现它的是编排层(`layer: 'semantic'` 同理)。
775
- * 锚点与对象名两处指错各有自己的码:它们的修法不同(一个去改 HTML,
776
- * 一个去改 data: 段),而码正是下游用来查修法的键。
777
- *
778
- * `problem` 与 `remedy` 由调用点给:这十处的静默形态各不相同
779
- * (空区域、少一格、演绎出答非所问的页面),写一句通用的"问题:形状不对"
780
- * 等于把三段式退化成两段式。
781
- *
782
- * **写成函数声明,不写成 `const fail = (): never => …`**:TS 只对函数声明
783
- * (或带显式类型标注的 const)做 `never` 收窄。箭头函数的形态下,`fail()` 之后
784
- * 被校验的值仍是 `unknown`,调用点只好一处一处 `as string` 顶回去——
785
- * 而 `as` 顶回去的那一刻,"校验过"与"没校验过"在类型上就再也分不开了。
786
- */
787
- function fail(input: {
788
- situation: string;
789
- problem: string;
790
- remedy: string;
791
- path: string;
792
- code?: string;
793
- }): never {
794
- throw new SomaOouiError({
795
- layer: 'semantic',
796
- code: input.code ?? 'OOUI-SEM-BLOCK-SHAPE',
797
- situation: input.situation,
798
- problem: input.problem,
799
- remedy: input.remedy,
800
- src: { file: '<page:ooui>', path: input.path },
801
- });
802
- }
803
-
804
- /**
805
- * 把某一层"返回 issues 而不抛"的那批问题汇总成一个错误。
806
- *
807
- * 折叠口径(码取第一条、一次列全、单条时直接给那一条的修法)归横切层
808
- * `foldOouiIssues` 一处;本函数只补编排层自己的两样:声明位置 `<page:ooui>`
809
- * 与空清单时的兜底码。
810
- */
811
- function aggregate(
812
- layer: 'semantic' | 'intent',
813
- headline: string,
814
- issues: readonly SomaOouiIssue[],
815
- path: string,
816
- /**
817
- * 到失败点为止的推导链(REQ-014 §38.5 断线 ③)。
818
- *
819
- * 语义校验失败时**如实为空**——那一刻什么都还没推出来,编一条链上去
820
- * 等于告诉读者"它是这么推到这一步的",而它并没有。
821
- * 意图层失败时非空:语义那一跳确实成立了,而"哪句对象声明"正是修法的起点。
822
- */
823
- trace?: readonly SomaTrace[],
824
- ): SomaOouiError {
825
- return foldOouiIssues({
826
- layer,
827
- headline,
828
- issues,
829
- src: { file: '<page:ooui>', path },
830
- ...(trace !== undefined ? { trace } : {}),
831
- fallback: {
832
- code: 'OOUI-SEM-BLOCK-SHAPE',
833
- problem: '演绎的输入不自洽时产出的是一个能渲染、能点、看着正常的页面,只是答非所问。',
834
- },
835
- });
836
- }
837
-
838
- /**
839
- * `show:` 段里每一个绑定目标的 `data-soma-id` → 写下它的声明路径。
840
- *
841
- * 递归进嵌套作用域(`bind` + `show`)与 `item:<变体>` 分组:`data-soma-id`
842
- * **页面内唯一**是既有铁律(`build/blocks/html-index.ts` 收集 `duplicates`),
843
- * 所以不论写在哪一层,同一个 id 指的都是同一个元素。只看顶层的话,
844
- * 一条写在列表子作用域里的绑定就能绕过这道交叉校验。
845
- *
846
- * `item:<变体>` 键本身不是锚点(它是异构行模板的分组名,见 dom-renderer 的
847
- * `^item:(.+)$` 分支),只递归它的子 show,不把它算成一个目标。
848
- */
849
- function collectShowTargets(
850
- show: ShowMapping,
851
- path: string,
852
- into: Map<string, string[]>,
853
- ): Map<string, string[]> {
854
- for (const [key, value] of Object.entries(show)) {
855
- const here = `${path}.${key}`;
856
- if (!key.startsWith('item:')) {
857
- // `somaId@attr` 的目标是同一个元素,键要原样留在路径里——作者要照着它去删那一行。
858
- const somaId = key.split('@')[0];
859
- const at = into.get(somaId) ?? [];
860
- at.push(here);
861
- into.set(somaId, at);
862
- }
863
- if (value !== null && typeof value === 'object') {
864
- const nested = (value as { show?: ShowMapping }).show;
865
- if (nested !== undefined && nested !== null && typeof nested === 'object') {
866
- collectShowTargets(nested, `${here}.show`, into);
867
- }
868
- }
869
- }
870
- return into;
871
- }
872
-
873
- /**
874
- * `show:` 与 `ooui:` 落在同一个锚点上——**编译期当场拒收**(§38.5 断线 ④ 的孪生问题)。
875
- *
876
- * ── 为什么这个失败模式是静默的 ─────────────────────────────────────
877
- * 运行时的两步都"成功"了:`installOouiHtml` 先把演绎 DOM 整块插进锚点,
878
- * 随后 renderEngine 按 `show` 绑定对同一个元素调 `setText`(或 `setHtml`、
879
- * 或按嵌套作用域重建子树),把刚插进去的整块 DOM **擦成一行文本**。
880
- * 页面渲染正常、控制台一行都没有:看上去像"演绎没生效"或"这块内容就是这样",
881
- * 而真正的原因写在另一份资产的另一段里。
882
- *
883
- * 为什么不留一个运行时告警了事:告警要等页面真被打开、真跑到那一帧才出现,
884
- * 而那时人不在写声明。这件事在编译期**已经完全可判**(两份声明都在手上),
885
- * 判得出来就不该拖到运行时。
886
- *
887
- * ── 为什么连 `@class` / `when` 这类"今天不擦内容"的绑定也一起拒 ────
888
- * 两个理由,都不是保守起见:
889
- * ① 锚点是产物的落点,`installOouiHtml` 对它做的是"清空 + 整块换掉"。
890
- * 同一个元素上再挂任何一条 show 绑定,两边写的就是同一块 DOM,
891
- * 而写入顺序由运行时的挂载次序决定,不由声明决定。
892
- * ② 判据若按"这个形态今天擦不擦内容"来裁,它就绑死在渲染器当前的实现上:
893
- * `when` 哪天从 `setVisibility` 改成重建子树,判据无声失效,
894
- * 而失效的表现又回到"渲染正常、控制台一行都没有"。
895
- * 要给演绎区域套显隐或样式,把绑定挂到**外层**元素上(另一个 `data-soma-id`)——
896
- * 那也是插槽出口那条既有纪律(样式挂长期存活的外层壳,不挂 outlet 本身)。
897
- */
898
- function assertNoShowConflict(anchors: readonly string[], show: ShowMapping): void {
899
- const targets = collectShowTargets(show ?? {}, 'show', new Map());
900
- // anchors 已按锚点名升序;每个锚点的 show 路径再排一次序:
901
- // 同一份声明必须给出同一串消息(消息会回喂 soma-ai 自修复)。
902
- const conflicts = anchors
903
- .filter((anchor) => targets.has(anchor))
904
- .map((anchor) => ({ anchor, paths: [...targets.get(anchor)!].sort() }));
905
- if (conflicts.length === 0) return;
906
-
907
- const first = conflicts[0]!;
908
- const listed = conflicts
909
- .map(({ anchor, paths }) => ` · "${anchor}":${paths.join('、')}`)
910
- .join('\n');
911
- fail({
912
- path: `ooui.${first.anchor}`,
913
- code: 'OOUI-SEM-ANCHOR-SHOW-CONFLICT',
914
- situation: `${conflicts.length} 个锚点既是 ooui: 的演绎落点、又是 show: 的绑定目标:\n${listed}`,
915
- problem: '运行时先由 installOouiHtml 把演绎 DOM 整块插进锚点,随后 renderEngine 按 show 绑定'
916
- + '对同一个元素写内容(setText / setHtml / 按嵌套作用域重建子树),把整块产物擦成一行文本。'
917
- + '两步都"成功",所以页面渲染正常、控制台一行都没有——看起来像"演绎没生效",'
918
- + '而原因写在另一段声明里。',
919
- remedy: '三选一:\n'
920
- + ` ① 这一块交给演绎:删掉 show 里的这几行(${first.paths.join('、')});\n`
921
- + ` ② 这一块自己写绑定:删掉 ooui: 段的 "${first.anchor}" 这条;\n`
922
- + ' ③ 两块都要:给演绎另开一个锚点,show 留给原来那个——\n'
923
- + ` <section data-soma-id="${first.anchor}-ooui"></section>\n`
924
- + ` ooui:\n ${first.anchor}-ooui: { object: <对象名>, verb: inspect }\n`
925
- + ' 要给演绎区域套显隐/样式,把 when / @class 挂到**外层**元素上,锚点本身留给产物。',
926
- });
927
- }
928
-
929
- /**
930
- * 锚点本身必须是**演绎产物住得下的那种落点**。
931
- *
932
- * 两种落点看着都是合法锚点(`htmlIndex.anchors` 里都有),而产物插进去之后
933
- * 都会被别人擦掉——与 `assertNoShowConflict` 是同一族失效,只是擦它的人不同:
934
- *
935
- * ① **行模板里的锚点**(`<template data-soma-role="item">` 内)。
936
- * 运行时 `findAnchor` 是 `root.querySelector`——列表还没渲染时一个都找不到
937
- * (那时只报一句"html 与 _ui.yaml 不是同一次编译的产物",指向完全错误的原因);
938
- * 渲染之后找到的是**恰好第一个被克隆出来的那一行**,于是产物插进了某一行里,
939
- * 而作者以为它在列表外面。两种表现都不是"报错"。
940
- *
941
- * ② **锚点自己就是组件实例**(同标签上有 `data-soma-component`)。
942
- * `installOouiHtml` 跑在 `setupComponentManager` **之前**,组件模板注入随后
943
- * 整块盖掉演绎 DOM。作者同时给那个实例写了块声明时,`assertNoShowConflict`
944
- * 会兜住(块会落进 `ui.show[blockId]`);**没写块就漏**——而没写块恰恰是
945
- * "我只想让它演绎"的那种写法。
946
- *
947
- * 这两条与 ①(show 冲突)一起在演绎**之前**判:冲突时产物根本不该被产出来,
948
- * 产出来就会有人拿它去对账。
949
- */
950
- function assertAnchorHostable(anchors: readonly string[], htmlIndex: HtmlAnchorIndex): void {
951
- for (const anchor of anchors) {
952
- const info = htmlIndex.anchors.get(anchor);
953
- if (info === undefined) continue; // 不存在那一支由 OOUI-SEM-ANCHOR-UNKNOWN 报
954
- if (info.inRowTemplate) {
955
- fail({
956
- path: `ooui.${anchor}`,
957
- code: 'OOUI-SEM-ANCHOR-IN-ROW-TEMPLATE',
958
- situation: `锚点 "${anchor}" 写在行模板(data-soma-role="item")里面。`,
959
- problem: '运行时按 querySelector 找落点:列表渲染前一个都找不到——那时报的是'
960
- + '"html 与 _ui.yaml 不是同一次编译的产物",指向完全错误的原因;'
961
- + '渲染之后找到的是**恰好第一个被克隆出来的那一行**,产物插进了某一行里,'
962
- + '而作者以为它在列表外面。两种表现都不是报错。'
963
- + '演绎是**整块一次**产出的,它没有"每行一份"这个形态。',
964
- remedy: '把锚点移到行模板**外面**(列表容器的兄弟或父级):\n'
965
- + ` <section data-soma-id="${anchor}"></section>\n`
966
- + ' <ul data-soma-id="rows"><template data-soma-role="item">…</template></ul>\n'
967
- + ' 要演绎一份列表,用 verb: browse —— 它自己会选出列表类组件,\n'
968
- + ' 不需要作者先摆一个行模板。',
969
- });
970
- }
971
- if (info.component !== undefined) {
972
- fail({
973
- path: `ooui.${anchor}`,
974
- code: 'OOUI-SEM-ANCHOR-IS-COMPONENT',
975
- situation: `锚点 "${anchor}" 自己就是组件实例(data-soma-component="${info.component}")。`,
976
- problem: 'installOouiHtml 跑在 setupComponentManager 之前,随后组件模板注入会'
977
- + '整块盖掉演绎 DOM。两步都"成功",所以页面渲染正常、控制台一行都没有——'
978
- + `看上去像"演绎没生效",而真正发生的是 ${info.component} 的模板赢了。`,
979
- remedy: '二选一:\n'
980
- + ` ① 这一块交给演绎:去掉这个元素上的 data-soma-component="${info.component}"\n`
981
- + ' (演绎自己会选组件——那正是它的职责);\n'
982
- + ` ② 这一块交给组件:删掉 ooui: 段的 "${anchor}" 这条,给演绎另开一个锚点:\n`
983
- + ` <section data-soma-id="${anchor}-ooui"></section>`,
984
- });
985
- }
986
- }
987
- }
988
-
989
- /**
990
- * 编译整页的 `ooui:` 段。
991
- *
992
- * 锚点对着 HTML 锚点索引核、对象名对着页面 `data:` 段核:写错一个字母的表现是
993
- * "某个区域完全没有演绎产物",而页面上看着只是那一块空着——
994
- * 空着的区域和"这个区域本来就没写内容"长得一模一样,只有在这里指名才有人发现。
995
- */
996
- export function compilePageOoui(input: CompilePageOouiInput): CompiledPageOoui {
997
- const { raw, htmlIndex, objects, engine, hostClass } = input;
998
- if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {
999
- fail({
1000
- path: 'ooui',
1001
- situation: 'ooui: 段不是映射。',
1002
- problem: '非映射(字符串、数组、null)取不出任何锚点,整段声明会被当成"这一页没有演绎"——'
1003
- + '页面照常编译、照常上线,只是那几块内容永远不出现,且没有任何日志。',
1004
- remedy: 'ooui: 段的形状是「锚点 → 演绎请求」:\n'
1005
- + ' ooui:\n'
1006
- + ' detail: { object: order, verb: inspect }',
1007
- });
1008
- }
1009
-
1010
- const declarations: Record<string, SomaOouiRequestDeclaration> = {};
1011
- const regions: SomaOouiRegion[] = [];
1012
- const classes = new Set<string>();
1013
- // 布局 CSS 逐区域收集,原子类整页合并去重:同一个 `soma-pad-5` 在五个区域里
1014
- // 只该有一条规则,而每个区域的容器骨架是它自己的。
1015
- const layoutChunks: string[] = [];
1016
-
1017
- // 按锚点名升序遍历:同一份声明必须产出同一份字节(§19.3 幂等)。
1018
- // 依赖 `Object.entries` 的书写序也是确定的,但那让"调整两段声明的先后"
1019
- // 变成一次产物变更,内容寻址会把它当成两份不同的资产。
1020
- const anchors = Object.keys(raw as Record<string, unknown>).sort();
1021
- // 与 `show:` 的交叉校验放在演绎之前:这件事只看两份声明,不必先花一遍演绎的代价,
1022
- // 而且冲突时"演绎产物"根本不该被产出来——产出来就会有人拿它去对账。
1023
- assertNoShowConflict(anchors, input.show);
1024
- // 落点本身的形态(行模板内 / 自己是组件实例)——同一族失效,擦它的人不同。
1025
- assertAnchorHostable(anchors, htmlIndex);
1026
- // ── 页面组合层(REQ-014 §29):先把整页看成一件事,再逐区域演绎 ────────
1027
- //
1028
- // 为什么不能只逐区域各演各的(此前正是这样):
1029
- // ① **空间预算是页面级的**。一个区域该多宽,取决于同一行还有谁、各自的约束是什么。
1030
- // 逐区域各算各的时,每个区域都以为自己拥有整页宽度——演绎出的组件按最宽档选,
1031
- // 而真实可用宽只有三分之一。表现是组件被 CSS 压扁,**不报错**。
1032
- // ② **联动是跨区域的**。`bound_to` 说的是"我监听那个区域的那个事件",
1033
- // 而那个事件产不产得出来,取决于**源区域**的动词、控制模型与选中组件。
1034
- // 这三件事只有把整页放在一起看才知道。不看的话表现是
1035
- // "点了左边列表右边没反应"——两块都渲染正常、事件也确实发出去了,只是没有人接。
1036
- //
1037
- // 顺序是定死的:解析全部声明 → 求页面预算 → 逐区域按各自 availRem 演绎
1038
- // → 拿选中候选的控制模型与真实 emits 回头裁决联动。
1039
- // 最后一步必须在演绎**之后**:联动成不成立取决于选中了哪个组件,而那是演绎的产物。
1040
- const parsed = new Map<string, SomaOouiRequestDeclaration>();
1041
- /** 锚点 → 语义请求。**只在这里构造一次**:预算、联动裁决与逐区域演绎用的是同一个对象 */
1042
- const requests = new Map<string, SomaSemanticRequest>();
1043
- for (const anchor of anchors) {
1044
- const path = `ooui.${anchor}`;
1045
- const spec = (raw as Record<string, unknown>)[anchor];
1046
- if (!htmlIndex.anchors.has(anchor)) {
1047
- fail({
1048
- path,
1049
- code: 'OOUI-SEM-ANCHOR-UNKNOWN',
1050
- situation: `锚点 "${anchor}" 不存在于 HTML(data-soma-id)——演绎产物没有落点。`,
1051
- problem: '产物没有落点时不会抛异常,只是那一块永远是空的——'
1052
- + '而"空着的区域"和"这个区域本来就没写内容"长得一模一样。',
1053
- remedy: `给要演绎的容器加 data-soma-id="${anchor}":\n`
1054
- + ` <section data-soma-id="${anchor}"></section>\n`
1055
- + ` 或把这条声明的键改成已有锚点(本页锚点:${[...htmlIndex.anchors.keys()].sort().join('、') || '一个都没有'})`,
1056
- });
1057
- }
1058
- const declaration = parseRequest(spec, path);
1059
- const object = objects[declaration.object];
1060
- if (object === undefined) {
1061
- fail({
1062
- path: `${path}.object`,
1063
- code: 'OOUI-SEM-OBJECT-UNKNOWN',
1064
- situation: `演绎所依据的数据对象 "${declaration.object}" 不在页面 data: 段里。`,
1065
- problem: '对象名是演绎的全部输入——取不到它就什么都推不出来,'
1066
- + '而"什么都推不出来"在页面上表现为那一块是空的。',
1067
- remedy: `在 page 块的 data: 段声明它:\n`
1068
- + ` data:\n ${declaration.object}:\n`
1069
- + ' from: [{ api: /api/xxx/detail }]\n'
1070
- + ' fields: { … }\n'
1071
- + ` 或改成已有对象名(本页对象:${Object.keys(objects).sort().join('、') || '一个都没有'})`,
1072
- });
1073
- }
1074
-
1075
- parsed.set(anchor, declaration);
1076
- requests.set(anchor, semanticRequestOf(declaration, object, { file: `<page:${hostClass}>`, path }));
1077
- }
1078
-
1079
- // ── 空间预算:整页一次求解,给每个区域一份逐档可用宽 ──────────────
1080
- //
1081
- // 取**最窄档**喂给演绎(`narrowestAvailRem`),这是铁律四:编译期决策对
1082
- // 运行时可变量取**保守边界**。取最宽档的话,窄档上那个组件放不下,
1083
- // 而"放不下"在 CSS 里表现为压扁,不是报错。
1084
- const composition: SomaPageComposition = {
1085
- slug: hostClass,
1086
- regions: anchors.map((anchor) => {
1087
- const declaration = parsed.get(anchor)!;
1088
- return {
1089
- name: anchor,
1090
- request: requests.get(anchor)!,
1091
- // 联动事件名的闭集由页面组合层判(`OOUI-SEM-BINDING-EVENT-UNKNOWN`),这里只搬字面量。
1092
- ...(declaration.bound_to
1093
- ? { boundTo: { region: declaration.bound_to.region, as: declaration.bound_to.as as SomaInteractionKind } }
1094
- : {}),
1095
- // 键、值的原始类型与 sizing 三档已在 `parseRequest` 核过(`findOouiLayoutProblem`,
1096
- // 三档常量 `SOMA_OOUI_SIZINGS` 与解析器、页面组合层、空间层是同一份)。这里的 `as`
1097
- // 只收窄到区域约束类型;priority 的档位与长度单位由空间层求解器核。
1098
- // **没写 sizing 按 fill**——缺省只在 `budget.ts` 的 `effectiveConstraint` 一处补、并记进 decisions,
1099
- // 这里不改写声明:声明原样写回 uiConfig,"作者写的"与"系统补的"才分得开。
1100
- ...(declaration.layout ? { layout: declaration.layout as SomaRegion['layout'] } : {}),
1101
- };
1102
- }),
1103
- };
1104
- // 预算 CSS 挂在页面 DOM 里真实存在的元素上:区域行(各区域锚点的共同父元素)与区域锚点本身。
1105
- // 此前用的是 IR 的缺省选择器 `[data-soma-node="page"] > [data-soma-node="<区域>"]`,
1106
- // 而编译后的页面上没有任何元素带这两个属性——整段预算 CSS 从来没有命中过。
1107
- // 找不到可挂的行时不发 CSS,原因进 decisions(也就进了 `traces`)。
1108
- const row = findRegionRow({ html: input.html, hostClass, regions: anchors });
1109
- const budget = solvePageBudget(composition, { row });
1110
-
1111
- /** 区域名 → 选中候选的控制模型 / 真实路由出的语义事件。演绎之后才知道 */
1112
- const controlModels: Record<string, SomaControlModel> = {};
1113
- const routedEvents: Record<string, SomaInteractionKind[]> = {};
1114
-
1115
- for (const anchor of anchors) {
1116
- const declaration = parsed.get(anchor)!;
1117
- const request = requests.get(anchor)!;
1118
-
1119
- // 显式声明永远赢(铁律一):调用方给了 availRem 就用它,不拿预算顶掉。
1120
- const budgeted = narrowestAvailRem(budget, anchor);
1121
- const env: SomaEnvironment = {
1122
- ...input.env,
1123
- ...(input.env?.availRem === undefined && budgeted !== undefined ? { availRem: budgeted } : {}),
1124
- relatedObjects: input.env?.relatedObjects ?? objects,
1125
- // 锚点与已占用清单由页面这一侧给:产物层要往页面里插元素,
1126
- // 插进去的 id 与页面已有锚点重名时,运行时的 `show:` 绑定会挂到先找到的那一个上,
1127
- // 表现是"这一块的数据串到另一块去了",而两块都渲染正常、控制台一行都没有。
1128
- anchor,
1129
- reservedAnchors: new Set(htmlIndex.anchors.keys()),
1130
- };
1131
- // 形态闭集由意图层判(`OOUI-INT-FORM-UNKNOWN`),这里只负责把作者写下的字面量带过去。
1132
- const hatch: SomaOouiHatch = declaration.form !== undefined
1133
- ? { form: declaration.form as SomaInteractionForm }
1134
- : {};
1135
- const fragment = engine.deduce(request, env, hatch);
1136
-
1137
- for (const candidate of fragment.classes) classes.add(candidate);
1138
- if (fragment.layoutCss.trim() !== '') layoutChunks.push(fragment.layoutCss);
1139
- regions.push({
1140
- anchor,
1141
- object: declaration.object,
1142
- verb: declaration.verb,
1143
- root: fragment.root,
1144
- // 原样搬运,不加工。`emitRegionHtml` 已经把缩进、属性顺序、类名书写序定死了,
1145
- // 而它产出的每一个 class、每一个属性都刚过完 `verifyArtifactHtml` 的三条判据
1146
- // (类名有登记、登记有规则、没有内联处理器)。在这里再"顺手"trim 一下或换个缩进,
1147
- // 同一份声明就会产出两份字节——内容寻址(§22.2 ⑤)会把它当成两份资产,
1148
- // 而两份资产在页面上长得一模一样。
1149
- html: fragment.artifact.html,
1150
- });
1151
- // 联动裁决的输入:**这一个**组件到底接没接那个事件。
1152
- // 控制模型只说"这类组件会不会 emit",eventMap 说的是"这一个接没接"——
1153
- // 候选表漏接一个 select 的表现,与组件根本没 emit 完全一样。
1154
- controlModels[anchor] = fragment.root.control_model as SomaControlModel;
1155
- routedEvents[anchor] = (fragment.root.events ?? [])
1156
- .flatMap((route) => route.kinds as SomaInteractionKind[]);
1157
- declarations[anchor] = declaration;
1158
- }
1159
-
1160
- // ── 联动契约:演绎之后才裁决得了 ────────────────────────────────────
1161
- // 到这里才有"选中了哪个组件、它真正路由出哪些语义事件"。
1162
- // 不带这两项的话 `holdsFor` 只能给出保守区间,而保守区间会把
1163
- // "源区域选了自治型候选、这条线其实是死的"记成"通过"。
1164
- const plan = assertPageComposition(composition, { controlModels, emits: routedEvents });
1165
-
1166
- const artifact: SomaPageOouiArtifact = { version: 1, regions };
1167
- // 布局在前、原子类在后:两者的选择器特异度相同(属性选择器与类选择器都是 0,1,0),
1168
- // 谁在后面谁赢。原子类是"局部覆盖"的那一侧,必须排在骨架之后。
1169
- // 页面区域组的容器查询排在各区域布局之前:它定的是"这一行怎么分",
1170
- // 各区域内部的骨架定的是"这一块里面怎么排"。顺序反了的话外层被内层顶掉。
1171
- const css = [budget.css, layoutChunks.join('\n\n'), engine.emitStylesheet([...classes].sort())]
1172
- .filter((chunk) => chunk.trim() !== '')
1173
- .join('\n\n');
1174
- if (css.trim() !== '') {
1175
- artifact.css = css;
1176
- artifact.css_key = oouiStyleKey(css);
1177
- }
1178
- // 页面这一层的两项推导(预算决策、联动裁决)转成 trace 交出去——此前算完就丢,
1179
- // 违反 §5「没有 trace 的推导不允许进主路径」。只进编译结果,不进产物(见 `traces` 的注释)。
1180
- const traces = [...pageBudgetTraces(budget), ...pageCompositionTraces(plan)];
1181
- return { declarations, artifact, traces };
1182
- }
1183
-
1184
- /**
1185
- * 声明 → 语义请求。**唯一的构造点。**
1186
- *
1187
- * 此前页面组合(预算与联动)与逐区域演绎各拼一遍,字段逐个相同。
1188
- * 两份在写下那天一致;下一个人给其中一处加字段时另一处不会跟上,
1189
- * 于是预算与演绎对着两份"看起来一样"的请求各算各的,没有任何断言会红。
1190
- */
1191
- function semanticRequestOf(
1192
- declaration: SomaOouiRequestDeclaration,
1193
- object: SomaObject,
1194
- src: SomaSource,
1195
- ): SomaSemanticRequest {
1196
- return {
1197
- object,
1198
- // 动词闭集由语义层判(`OOUI-SEM-VERB-UNKNOWN`)——那条错误已经把八动词列全了。
1199
- // 在这里再判一次,等于让同一件事有两个错误码,而 soma-ai 的自修复提示词按码匹配。
1200
- verb: declaration.verb as SomaVerb,
1201
- ...(declaration.focus ? { focus: [...declaration.focus] } : {}),
1202
- ...(declaration.through ? { through: declaration.through } : {}),
1203
- src,
1204
- };
1205
- }
1206
-
1207
- /**
1208
- * 一条演绎请求的形状校验。闭集之外的键当场红——写错一个字母不该悄悄变成"没这一项"。
1209
- *
1210
- * 键闭集与形状判据(`isOouiText` / `isOouiFocus` / `isOouiBinding` / `isOouiLayout`)
1211
- * 与运行时解析器共用 `shared/ooui-declaration.ts` 那一份;两边各自只保留自己的措辞
1212
- * (这里是三段式 + 错误码,解析器是一行 `SomaUiConfigError`)。
1213
- */
1214
- function parseRequest(spec: unknown, path: string): SomaOouiRequestDeclaration {
1215
- if (!isOouiMap(spec)) {
1216
- fail({
1217
- path,
1218
- situation: '演绎请求不是映射(至少含 object 与 verb)。',
1219
- problem: '非映射取不出 object/verb,这一个锚点会被整条跳过——页面上少一块,不报错。',
1220
- remedy: `${path}: { object: <data 对象名>, verb: <八动词之一> }`,
1221
- });
1222
- }
1223
- const entry = spec;
1224
- for (const key of Object.keys(entry)) {
1225
- if (!(SOMA_OOUI_REQUEST_KEYS as readonly string[]).includes(key)) {
1226
- fail({
1227
- path: `${path}.${key}`,
1228
- situation: `演绎请求不支持键 "${key}"。`,
1229
- problem: '闭集之外的键会被静默丢弃——把 `verb` 写成 `verbs` 的表现不是报错,'
1230
- + '而是"这条声明缺 verb",报错指向的是另一行。',
1231
- remedy: `可用的键:${SOMA_OOUI_REQUEST_KEYS.join(' / ')}(focus / through / form 可省)。`,
1232
- });
1233
- }
1234
- }
1235
- const object = entry.object;
1236
- if (!isOouiText(object)) {
1237
- fail({
1238
- path: `${path}.object`,
1239
- situation: '演绎请求缺少 object(页面 data: 段里的对象名)。',
1240
- problem: '对象名是演绎的全部输入。缺它时朴素实现会拿 undefined 去查字典,'
1241
- + '查不到就演绎出一个空区域——看起来像"接口还没返回"。',
1242
- remedy: `${path}: { object: order, verb: inspect } # order 要在本页 data: 段里`,
1243
- });
1244
- }
1245
- const verb = entry.verb;
1246
- if (!isOouiText(verb)) {
1247
- fail({
1248
- path: `${path}.verb`,
1249
- situation: '演绎请求缺少 verb(八动词之一)。',
1250
- problem: '动词是根形态的唯一分派依据。缺它时没有任何形态可推,'
1251
- + '而"推不出形态"在下游表现成"这个形态没有候选组件"——那句话指向构件层,不指向这一行。',
1252
- remedy: `${path}: { object: <对象名>, verb: inspect } # 八动词见 OOUI-SEM-VERB-UNKNOWN 的建议`,
1253
- });
1254
- }
1255
- const declaration: SomaOouiRequestDeclaration = { object, verb };
1256
- const focus = entry.focus;
1257
- if (focus !== undefined) {
1258
- if (!isOouiFocus(focus)) {
1259
- fail({
1260
- path: `${path}.focus`,
1261
- code: 'OOUI-SEM-FOCUS-EMPTY',
1262
- situation: 'focus 不是非空字段名数组。',
1263
- problem: '"省略 focus" 表示全部字段,"focus: []" 表示一个字段都不要——'
1264
- + '后者演绎出的是一张空界面,而它看起来像加载失败。两者不该长得这么像。',
1265
- remedy: '要全部字段就删掉 focus 这一行;确实只要几个字段就把它们列出来:\n'
1266
- + ` ${path}: { object: <对象名>, verb: inspect, focus: [no, amount] }`,
1267
- });
1268
- }
1269
- declaration.focus = [...focus];
1270
- }
1271
- const through = entry.through;
1272
- if (through !== undefined) {
1273
- if (!isOouiText(through)) {
1274
- fail({
1275
- path: `${path}.through`,
1276
- situation: 'through 不是非空字符串。',
1277
- problem: 'through 是动词的作用路径(§27.2):要比的是"一个实验内部的多个变体",'
1278
- + '要导航的必然是关系的另一端。取不到它时演绎照样出得来一个页面,只是答非所问。',
1279
- remedy: `${path}: { object: <对象名>, verb: compare, through: variants }\n`
1280
- + ' 关系名必须是该对象 relations 里已声明的 name。',
1281
- });
1282
- }
1283
- declaration.through = through;
1284
- }
1285
- const form = entry.form;
1286
- if (form !== undefined) {
1287
- if (!isOouiText(form)) {
1288
- fail({
1289
- path: `${path}.form`,
1290
- situation: 'form 不是非空字符串。',
1291
- problem: 'form 是逃生门:给了就覆盖动词分派出来的根形态。写成空串时'
1292
- + '朴素实现会当成"给了一个形态",于是分派结果被一个空值顶掉,产出兜底呈现。',
1293
- remedy: '省略 form 让动词分派(推荐);确实要覆盖就写封闭集里的形态名:\n'
1294
- + ` ${path}: { object: <对象名>, verb: browse, form: 'table' }`,
1295
- });
1296
- }
1297
- declaration.form = form;
1298
- }
1299
- const bound = entry.bound_to;
1300
- if (bound !== undefined) {
1301
- // 闭集之外的键先单独报,且有自己的码:此前这里只取 region / as 两项、其余静默丢弃,
1302
- // 写成 `bound_to: { region: list, as: select, event: row_click }` 的作者以为钉住了组件的 emit,
1303
- // 实际那一项从解析那一刻起就不存在。键闭集与运行时解析器同一份(`SOMA_OOUI_BINDING_KEYS`)。
1304
- const unknownKey = isOouiMap(bound) ? findOouiBindingUnknownKey(bound) : undefined;
1305
- if (unknownKey !== undefined) {
1306
- fail({
1307
- path: `${path}.bound_to.${unknownKey}`,
1308
- code: 'OOUI-SEM-BINDING-KEY-UNKNOWN',
1309
- situation: `bound_to 不支持键 "${unknownKey}"。`,
1310
- problem: '联动只认两项:源区域(region)与语义事件(as)。多出来的键没有任何一层会读——'
1311
- + '作者以为钉住了的那一项(比如组件的 emit 名)从解析那一刻起就不存在,'
1312
- + '而"写了没生效"与"这个能力不存在"在页面上分不开。',
1313
- remedy: `bound_to 只收 ${SOMA_OOUI_BINDING_KEYS.join(' / ')};as 写语义事件名,`
1314
- + '组件的 emit 名由候选表的 eventMap 接到语义事件上,不在页面声明里写:\n'
1315
- + ` ${path}: { object: <对象名>, verb: inspect, bound_to: { region: list, as: select } }`,
1316
- });
1317
- }
1318
- if (!isOouiBinding(bound)) {
1319
- fail({
1320
- path: `${path}.bound_to`,
1321
- situation: 'bound_to 不是 { region, as } 两项俱全的映射。',
1322
- problem: '联动取不出源区域或事件名时,这条声明会被整条跳过——'
1323
- + '**而跳过不报错**:两块都渲染正常、事件也确实发出去了,只是没有人接。'
1324
- + '"点了左边列表右边没反应"在浏览器里与"这个列表本来就不联动"分不开。',
1325
- remedy: `${path}: { object: <对象名>, verb: inspect, bound_to: { region: list, as: select } }\n`
1326
- + ' region 是**另一个锚点名**;as 是语义事件名(不是组件的 emit 名)。',
1327
- });
1328
- }
1329
- declaration.bound_to = { region: bound.region, as: bound.as };
1330
- }
1331
- const layout = entry.layout;
1332
- if (layout !== undefined) {
1333
- if (!isOouiMap(layout)) {
1334
- fail({
1335
- path: `${path}.layout`,
1336
- situation: 'layout 不是映射。',
1337
- problem: '取不出约束时本区域会退回"与其余区域等分",而作者写下的宽度声明静默消失——'
1338
- + '页面渲染正常、比例全错,控制台一行都没有。',
1339
- remedy: `${path}: { object: <对象名>, verb: browse, layout: { sizing: fill, min: 10rem, priority: 750 } }`,
1340
- });
1341
- }
1342
- if (!isOouiLayout(layout)) {
1343
- // 键白名单 + 值的原始类型 + sizing 三档。约束会被摊进空间 IR 的叶子,而叶子上还有
1344
- // `id` / `kind` / `anchor` / `classes` 这些结构键——放行 `layout: { id: x }`
1345
- // 叶子就被改了名,求解结果里再也找不到这个区域(此前那里读成 0rem)。
1346
- const problem = findOouiLayoutProblem(layout);
1347
- const key = problem?.key ?? '';
1348
- if (problem?.kind === 'sizing-unknown') {
1349
- // 码取 `OOUI-SPA-*`:被违反的是空间层的闭集(前缀 = 谁的契约,layer = 谁发现的)。
1350
- // 在这里报而不是留给求解器,是为了指着作者写错的这一行,而不是 IR 树里的 `page.<锚点>`。
1351
- fail({
1352
- path: `${path}.layout.sizing`,
1353
- code: 'OOUI-SPA-SIZING-UNKNOWN',
1354
- situation: `layout.sizing 是 ${JSON.stringify(layout.sizing)},不在尺寸意图三档里。`,
1355
- problem: '闭集之外的 sizing 既不是 fixed(按 width 定宽)也不是 fill(分余量),'
1356
- + '求解器只剩"从 min 起步"一条路:这个区域静默缩到下界(没写 min 就是 0rem),'
1357
- + '构件选型随之降到最窄的候选——页面照常渲染、控制台一行都没有。',
1358
- remedy: `sizing 只能是 ${SOMA_OOUI_SIZINGS.join(' / ')};省略即 fill(与其余区域等分):\n`
1359
- + ` ${path}: { object: <对象名>, verb: browse, layout: { sizing: fill, min: 10rem, priority: 750 } }`,
1360
- });
1361
- }
1362
- fail({
1363
- path: `${path}.layout.${key}`,
1364
- situation: problem?.kind === 'unknown-key'
1365
- ? `layout 不支持键 "${key}"。`
1366
- : `layout.${key} 应当是 ${problem?.expected ?? '字符串或数字'}(收到 ${typeof layout[key]})。`,
1367
- problem: '区域约束会被摊进空间 IR 的叶子:约束键之外的键要么被静默丢弃,要么顶掉叶子的结构键'
1368
- + '(`layout: { id: x }` 把叶子改了名,这个区域的宽度从此读不出来)。'
1369
- + '值的类型写错时,求解器报出来的是某一档"放不下",指不回这一行。',
1370
- remedy: `layout 只收 ${SOMA_OOUI_LAYOUT_KEYS.join(' / ')};长度写带单位的字符串,priority 写数字:\n`
1371
- + ` ${path}: { object: <对象名>, verb: browse, layout: { sizing: fill, min: 10rem, priority: 750 } }`,
1372
- });
1373
- }
1374
- declaration.layout = layout;
1375
- }
1376
- return declaration;
1377
- }
1378
-
1379
- /**
1380
- * 演绎样式表的注入键:`ooui:` + 内容 sha256 前 8 位。
1381
- *
1382
- * **必须是内容哈希,不能是语义名。** `pack-styles.ts` 的 `injectOnce` 是:
1383
- *
1384
- * if (!css.trim() || injected.has(key)) return; // 同键不同内容 → 静默保留第一份
1385
- *
1386
- * 它没有内容冲突检测。按 `(对象, 动词)` 命名的话,SPA 内从 `/order/edit` 切到
1387
- * 另一张同样 `(order, edit)` 但产物不同的页面,第二页会继续用第一页的 CSS:
1388
- * 页面渲染正常、间距全错、控制台一行都没有。内容哈希让"同键"与"同内容"
1389
- * 变成同一件事,顺带把内容寻址提前一半。
1390
- */
1391
- export function oouiStyleKey(css: string): string {
1392
- return `ooui:${createHash('sha256').update(css, 'utf8').digest('hex').slice(0, 8)}`;
1393
- }
1394
-
1395
- /**
1396
- * 转口各层的产物契约。
1397
- *
1398
- * 调用方(宿主、闸门、诊断工具)不该为了写一个 `SomaSemanticRequest`
1399
- * 而去 import `./semantic/kernel.types`——那等于让每个调用点都记住六层的目录结构,
1400
- * 层搬一次家就有一批 import 要改,而改漏的那几处只在编译时才发现。
1401
- * 这里**只转口类型,不重新声明**:重新声明的那一份必然与真源漂。
1402
- */
1403
- export type {
1404
- SomaTrace,
1405
- SomaOouiNode,
1406
- SomaOouiRegion,
1407
- SomaOouiRequestDeclaration,
1408
- SomaPageOouiArtifact,
1409
- SomaObject,
1410
- SomaSemanticRequest,
1411
- SomaSource,
1412
- SomaVerb,
1413
- SomaIntent,
1414
- SomaInteractionForm,
1415
- SomaIntentFieldRule,
1416
- SomaComponentCandidateInput,
1417
- SomaComponentContractView,
1418
- SomaSpatialToken,
1419
- SomaUtility,
1420
- SomaVariant,
1421
- // 产物层的对外形态。此前只在本文件内 import 未转口,于是
1422
- // `import type { SomaArtifact } from '@core/build/ooui'` 会报 TS2459
1423
- // (declares locally, but is not exported),而连带的
1424
- // `artifact.trace.map((trace) => …)` 退化成隐式 any——
1425
- // **两条错误在开了 tsbuildinfo 增量缓存时不复现**,单跑 typecheck 是绿的。
1426
- SomaArtifact,
1427
- };