soma-core 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1065) 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 +193 -0
  7. package/bin/soma-sync-runtime.cjs +130 -0
  8. package/bin/soma.cjs +200 -13
  9. package/bin/soma.ts +182 -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/{blocks → compiler}/html-index.ts +64 -15
  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 +265 -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 +50 -46
  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 +348 -317
  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 +1246 -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 +24 -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 +230 -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 +74 -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 +327 -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 +247 -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/{adaptive → scheduling}/flush-scheduler.ts +16 -12
  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/{component → styles}/style-features.ts +3 -3
  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 +866 -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 +12 -5
  247. package/core/server/host/host-assembly-entry.ts +16 -0
  248. package/core/server/host/host-assembly.ts +249 -0
  249. package/core/server/host/invoke-host-request-hook.ts +5 -0
  250. package/core/server/host/locale-yaml.ts +51 -0
  251. package/core/server/host/page-markup-config.ts +13 -0
  252. package/core/server/host/published-page-artifact-cache.ts +355 -124
  253. package/core/server/host/published-page-assets.ts +90 -45
  254. package/core/server/host/resolve-host-request-hook.ts +8 -0
  255. package/core/server/host/resolve-host-tree-context.ts +15 -1
  256. package/core/server/host/server-page-assets.ts +178 -38
  257. package/core/server/host/soma-page-compile.ts +57 -16
  258. package/core/server/host/source-packages.cjs +185 -0
  259. package/core/server/host/source-packages.ts +18 -126
  260. package/core/server/host/virtual-pages.ts +255 -0
  261. package/core/server/index.ts +13 -42
  262. package/core/server/node.ts +53 -0
  263. package/core/server/page-assets.ts +91 -0
  264. package/core/server/page-declaration.ts +83 -7
  265. package/core/server/registry/api-registry-store.ts +38 -29
  266. package/core/server/registry/asset-store.ts +35 -19
  267. package/core/server/registry/batch-publish.ts +38 -0
  268. package/core/server/registry/batch-stage.ts +130 -0
  269. package/core/server/registry/component-supply.ts +31 -0
  270. package/core/server/registry/declaration-precompiler.ts +48 -34
  271. package/core/server/registry/index.ts +78 -1
  272. package/core/server/registry/page-registry-repository.ts +479 -60
  273. package/core/server/registry/page-registry-store.ts +627 -80
  274. package/core/server/registry/publish-asset-pin.ts +19 -16
  275. package/core/server/registry/registry-file-lock.ts +16 -3
  276. package/core/server/registry/registry-write-pipeline.ts +65 -1
  277. package/core/server/registry/request-body-limit.ts +3 -1
  278. package/core/server/registry/rollback-plan.ts +184 -0
  279. package/core/server/registry/services/index.ts +14 -1
  280. package/core/server/registry/services/pages/Get.ts +26 -4
  281. package/core/server/registry/services/pages/Register.ts +29 -7
  282. package/core/server/registry/services/pages/RegisterBatch.ts +68 -0
  283. package/core/server/registry/services/pages/Rollback.ts +14 -4
  284. package/core/server/registry/services/pages/Unregister.ts +2 -1
  285. package/core/server/registry/source/canonical.ts +57 -0
  286. package/core/server/registry/source/errors.ts +81 -0
  287. package/core/server/registry/source/index.ts +49 -0
  288. package/core/server/registry/source/ledger.ts +306 -0
  289. package/core/server/registry/source/snapshot.ts +29 -0
  290. package/core/server/registry/source/source-name.ts +48 -0
  291. package/core/server/registry/source/types.ts +106 -0
  292. package/core/server/registry/source/version-store.ts +371 -0
  293. package/core/server/registry/standard-product.ts +185 -0
  294. package/core/server/registry/validation/compile-gate.ts +39 -50
  295. package/core/server/registry/validation/cross-check.ts +18 -5
  296. package/core/server/registry/validation/declaration-safety-scan.ts +12 -10
  297. package/core/server/registry/validation/region-scopes.ts +50 -0
  298. package/core/server/runtime-space/access-gate.ts +206 -0
  299. package/core/server/runtime-space/advice-log.ts +67 -0
  300. package/core/server/runtime-space/artifact-evict.ts +15 -0
  301. package/core/server/runtime-space/bindings.ts +481 -0
  302. package/core/server/runtime-space/digest.ts +62 -0
  303. package/core/server/runtime-space/dynamic-pages.ts +379 -0
  304. package/core/server/runtime-space/errors.ts +96 -0
  305. package/core/server/runtime-space/gc.ts +117 -0
  306. package/core/server/runtime-space/index.ts +106 -0
  307. package/core/server/runtime-space/inject.ts +498 -0
  308. package/core/server/runtime-space/migrate-sources.ts +124 -0
  309. package/core/server/runtime-space/nav-catalog.ts +140 -0
  310. package/core/server/runtime-space/page-grants.ts +436 -0
  311. package/core/server/runtime-space/prewarm.ts +234 -0
  312. package/core/server/runtime-space/registry-cold-start.ts +69 -0
  313. package/core/server/runtime-space/resolve.ts +552 -0
  314. package/core/server/runtime-space/root.cjs +251 -0
  315. package/core/server/runtime-space/root.ts +46 -0
  316. package/core/server/runtime-space/static-source.ts +85 -0
  317. package/core/server/runtime-space/store.ts +253 -0
  318. package/core/server/runtime-space/submit-steps.ts +412 -0
  319. package/core/server/runtime-space/types.ts +325 -0
  320. package/core/shared/anchor-space.ts +48 -0
  321. package/core/shared/artifact-compatibility.ts +166 -0
  322. package/core/shared/behavior-machine-names.ts +8 -0
  323. package/core/shared/calc/coerce.ts +2 -29
  324. package/core/shared/calc/errors.ts +4 -7
  325. package/core/shared/calc/evaluator.ts +23 -11
  326. package/core/shared/calc/index.ts +3 -4
  327. package/core/shared/calc/lexer.ts +7 -12
  328. package/core/shared/calc/parser.ts +8 -19
  329. package/core/shared/calc/typer.ts +10 -23
  330. package/core/shared/component-tree-artifact.ts +85 -7
  331. package/core/shared/contract-a11y.ts +335 -0
  332. package/core/shared/contract-sections.ts +344 -0
  333. package/core/shared/core-diagnostic-codes.ts +210 -0
  334. package/core/shared/data-declaration-checks.ts +211 -0
  335. package/core/shared/date-parts.ts +2 -0
  336. package/core/shared/declaration-errors.ts +14 -0
  337. package/core/shared/declaration-keys.ts +36 -0
  338. package/core/shared/diagnostic-code-index-entry.ts +14 -0
  339. package/core/shared/diagnostic-gate.ts +139 -0
  340. package/core/shared/engines/engine-error.ts +33 -0
  341. package/core/shared/engines/style/style-engine.types.ts +28 -0
  342. package/core/shared/envelope-text-width.generated.d.mts +19 -0
  343. package/core/shared/envelope-text-width.generated.mjs +413 -0
  344. package/core/shared/fragments-section.ts +10 -0
  345. package/core/shared/generation-diagnostics.ts +58 -0
  346. package/core/shared/generation-error.ts +73 -0
  347. package/core/shared/hook-attributes.ts +159 -0
  348. package/core/shared/inert-data-element.ts +50 -0
  349. package/core/shared/nav-back.ts +120 -0
  350. package/core/shared/page-access-text.ts +7 -0
  351. package/core/shared/page-envelope-runtime.ts +88 -0
  352. package/core/shared/page-envelope.ts +618 -0
  353. package/core/shared/page-scopes.ts +83 -0
  354. package/core/shared/pipeline-error-codes-view.ts +31 -0
  355. package/core/shared/pipeline-limits-view.ts +27 -0
  356. package/core/shared/predicates/index.ts +85 -497
  357. package/core/shared/predicates/relative-window.ts +19 -0
  358. package/core/shared/published-page-route.ts +4 -8
  359. package/core/shared/region-scope-decl.ts +488 -0
  360. package/core/shared/registry-generated/compile-purposes.ts +53 -0
  361. package/core/shared/registry-generated/diagnostic-registry-index.ts +798 -0
  362. package/core/shared/registry-generated/diagnostic-registry.ts +5886 -0
  363. package/core/shared/registry-generated/error-codes.ts +137 -0
  364. package/core/shared/registry-generated/index.ts +13 -0
  365. package/core/shared/registry-generated/limits.ts +552 -0
  366. package/core/shared/registry-generated/platform-keys.ts +56 -0
  367. package/core/shared/registry-generated/region-scope.ts +823 -0
  368. package/core/shared/registry-generated/std-grammar-completion.ts +216 -0
  369. package/core/shared/registry-generated/std-grammar-views.ts +139 -0
  370. package/core/shared/registry-generated/std-grammar.ts +161 -0
  371. package/core/shared/rule-step.ts +2 -0
  372. package/core/shared/runtime-address.ts +244 -0
  373. package/core/shared/scope-decl.ts +77 -0
  374. package/core/shared/sha256.ts +108 -0
  375. package/core/shared/show-when.ts +77 -0
  376. package/core/shared/source-compat.ts +9 -0
  377. package/core/shared/std-auth-scan.ts +158 -0
  378. package/core/shared/types/choice-confirm.types.ts +2 -0
  379. package/core/shared/types/compile-diagnostic.types.ts +42 -0
  380. package/core/shared/types/compile-port.types.ts +41 -0
  381. package/core/shared/types/component-contract.types.ts +145 -156
  382. package/core/shared/types/component-tree-artifact.types.ts +31 -2
  383. package/core/shared/types/component-tree.types.ts +17 -6
  384. package/core/shared/types/data-config.types.ts +182 -222
  385. package/core/shared/types/domain.types.ts +20 -5
  386. package/core/shared/types/engine.types.ts +2 -0
  387. package/core/shared/types/event.types.ts +78 -8
  388. package/core/shared/types/generation-error.types.ts +83 -0
  389. package/core/shared/types/host-assembly.types.ts +97 -0
  390. package/core/shared/types/locale.types.ts +46 -0
  391. package/core/shared/types/manifest.types.ts +2 -7
  392. package/core/shared/types/nav-context.types.ts +46 -0
  393. package/core/shared/types/nav.types.ts +57 -0
  394. package/core/shared/types/notify.types.ts +45 -0
  395. package/core/shared/types/observation.types.ts +76 -0
  396. package/core/shared/types/page-envelope.types.ts +125 -0
  397. package/core/shared/types/page-state.types.ts +21 -42
  398. package/core/shared/types/region-scope.types.ts +177 -0
  399. package/core/shared/types/registry-batch.types.ts +45 -0
  400. package/core/shared/types/shortcuts.types.ts +61 -0
  401. package/core/shared/types/source.types.ts +10 -0
  402. package/core/shared/types/style-config.types.ts +61 -82
  403. package/core/shared/types/temporal.types.ts +3 -0
  404. package/core/shared/types/ui-config.types.ts +85 -152
  405. package/core/shared/types/write-outcome-view.types.ts +24 -0
  406. package/core/shared/types/write-runtime.types.ts +10 -0
  407. package/core/shared/types/write.types.ts +86 -0
  408. package/dist/browser/runtime-bundle.manifest.json +938 -0
  409. package/dist/browser/soma-runtime.js +120276 -0
  410. package/dist/cli/soma.js +131 -454
  411. package/dist/core/adaptive-pure.cjs +41 -0
  412. package/dist/core/index.cjs +119747 -22518
  413. package/dist/core/theme-pure.cjs +38 -0
  414. package/dist/diagnostics/telemetry.cjs +2 -1
  415. package/dist/lsp/component-tree.cjs +6412 -8261
  416. package/dist/preview-export.cjs +3401 -0
  417. package/dist/types/build/compiler/flat-page.d.ts +52 -0
  418. package/dist/types/build/compiler/full-manifest-builder.d.ts +26 -1
  419. package/dist/types/build/{blocks → compiler}/html-index.d.ts +19 -8
  420. package/dist/types/build/compiler/page-assets.d.ts +11 -3
  421. package/dist/types/build/compiler/page-base-resolver.d.ts +5 -0
  422. package/dist/types/build/compiler/page-declaration-compiler.d.ts +97 -56
  423. package/dist/types/build/compiler/soma-precompile.d.ts +3 -3
  424. package/dist/types/build/compiler/vite-plugin-soma.d.ts +2 -2
  425. package/dist/types/build/component/component-graph.d.ts +1 -1
  426. package/dist/types/build/component-tree/artifact-codec.d.ts +5 -8
  427. package/dist/types/build/component-tree/registry-snapshot.d.ts +18 -0
  428. package/dist/types/build/component-tree/source-preflight.d.ts +4 -14
  429. package/dist/types/build/component-tree/structure-topology.d.ts +1 -1
  430. package/dist/types/build/eject/plan-eject.d.ts +0 -1
  431. package/dist/types/build/lsp/component-tree-service.d.ts +2 -0
  432. package/dist/types/client/a11y/a11y-config.d.ts +15 -0
  433. package/dist/types/client/a11y/announcer.d.ts +45 -0
  434. package/dist/types/client/a11y/dom-id.d.ts +4 -0
  435. package/dist/types/client/a11y/index.d.ts +5 -0
  436. package/dist/types/client/a11y/motion-hook.d.ts +13 -0
  437. package/dist/types/client/a11y/motion.d.ts +24 -0
  438. package/dist/types/client/base/SomaPageRootBase.d.ts +17 -2
  439. package/dist/types/client/base/index.d.ts +8 -8
  440. package/dist/types/client/behavior/adapter-collection.d.ts +39 -0
  441. package/dist/types/client/behavior/adapter-popper.d.ts +2 -0
  442. package/dist/types/client/behavior/aria-hide-outside.d.ts +13 -0
  443. package/dist/types/client/behavior/css-escape.d.ts +11 -0
  444. package/dist/types/client/behavior/focus-scope.d.ts +69 -0
  445. package/dist/types/client/behavior/focus-traversal.d.ts +3 -0
  446. package/dist/types/client/behavior/index.d.ts +17 -0
  447. package/dist/types/client/behavior/layer-stack.d.ts +39 -0
  448. package/dist/types/client/behavior/overlay-host/index.d.ts +5 -0
  449. package/dist/types/client/behavior/overlay-host/port.d.ts +55 -0
  450. package/dist/types/client/behavior/overlay-wiring.d.ts +59 -0
  451. package/dist/types/client/behavior/port.d.ts +79 -0
  452. package/dist/types/client/behavior/positioner.d.ts +2 -0
  453. package/dist/types/client/behavior/presence.d.ts +27 -0
  454. package/dist/types/client/behavior/zag/adapter-vanilla.d.ts +2 -0
  455. package/dist/types/client/behavior/zag/layer-bridge.d.ts +15 -0
  456. package/dist/types/client/behavior/zag/machine-host.d.ts +22 -0
  457. package/dist/types/client/behavior/zag/machines.d.ts +23 -0
  458. package/dist/types/client/compiler/manifest-compiler.d.ts +4 -14
  459. package/dist/types/client/component/adapter/adapt.d.ts +9 -0
  460. package/dist/types/client/component/adapter/index.d.ts +3 -0
  461. package/dist/types/client/component/adapter/types.d.ts +33 -0
  462. package/dist/types/client/component/adapter/web-component.d.ts +9 -0
  463. package/dist/types/client/component/component-definition.types.d.ts +23 -5
  464. package/dist/types/client/component/component-expander.d.ts +1 -12
  465. package/dist/types/client/component/component-manager.d.ts +39 -89
  466. package/dist/types/client/component/component-pack.d.ts +21 -54
  467. package/dist/types/client/component/component-registry.d.ts +5 -0
  468. package/dist/types/client/component/projection-admission.d.ts +5 -0
  469. package/dist/types/client/component/projection-registry.d.ts +6 -0
  470. package/dist/types/client/component/projection.types.d.ts +44 -0
  471. package/dist/types/client/component/region-unavailable.d.ts +10 -0
  472. package/dist/types/client/component/scoped-adapter.d.ts +2 -3
  473. package/dist/types/client/container/IContainerAdapter.d.ts +8 -3
  474. package/dist/types/client/container/SomaContainerAdapter.d.ts +7 -10
  475. package/dist/types/client/data/collection-payload.d.ts +1 -0
  476. package/dist/types/client/data/data-object-resolver.d.ts +231 -110
  477. package/dist/types/client/data/data-polling.d.ts +28 -0
  478. package/dist/types/client/data/data-subscriptions.d.ts +20 -0
  479. package/dist/types/client/data/data-write-actions.d.ts +9 -0
  480. package/dist/types/client/data/envelope-failure.d.ts +17 -0
  481. package/dist/types/client/data/format-config.d.ts +13 -0
  482. package/dist/types/client/data/region-scope-port.d.ts +34 -0
  483. package/dist/types/client/data/region-scope-views.d.ts +15 -0
  484. package/dist/types/client/data/role-gate.d.ts +10 -0
  485. package/dist/types/client/data/write-outcome-store.d.ts +23 -0
  486. package/dist/types/client/data/write-outcome.d.ts +48 -0
  487. package/dist/types/client/engine/asset-resolver.d.ts +2 -7
  488. package/dist/types/client/engine/dom-renderer.d.ts +5 -111
  489. package/dist/types/client/engine/event-engine.d.ts +52 -61
  490. package/dist/types/client/engine/locale-text-binder.d.ts +28 -0
  491. package/dist/types/client/engine/property-watcher.d.ts +1 -41
  492. package/dist/types/client/engine/reactive-proxy.d.ts +2 -42
  493. package/dist/types/client/engine/render-engine.d.ts +3 -54
  494. package/dist/types/client/engine/row-range.d.ts +1 -0
  495. package/dist/types/client/engine/runtime-builder.d.ts +7 -3
  496. package/dist/types/client/engine/soma-bootstrap.d.ts +315 -91
  497. package/dist/types/client/engine/step-runner.d.ts +20 -2
  498. package/dist/types/client/engine/style-binder.d.ts +2 -16
  499. package/dist/types/client/engines/chart/adapter-echarts.d.ts +6 -0
  500. package/dist/types/client/engines/chart/index.d.ts +8 -0
  501. package/dist/types/client/engines/chart/kind-modules.d.ts +8 -0
  502. package/dist/types/client/engines/chart/port.d.ts +46 -0
  503. package/dist/types/client/engines/diff/adapter-jsdiff.d.ts +6 -0
  504. package/dist/types/client/engines/diff/index.d.ts +8 -0
  505. package/dist/types/client/engines/diff/port.d.ts +16 -0
  506. package/dist/types/client/engines/dnd/adapter-pragmatic.d.ts +9 -0
  507. package/dist/types/client/engines/dnd/index.d.ts +6 -0
  508. package/dist/types/client/engines/dnd/port.d.ts +33 -0
  509. package/dist/types/client/engines/engine-adapters.d.ts +23 -0
  510. package/dist/types/client/engines/load.d.ts +11 -0
  511. package/dist/types/client/engines/qrcode/adapter-qrcode-generator.d.ts +6 -0
  512. package/dist/types/client/engines/qrcode/index.d.ts +8 -0
  513. package/dist/types/client/engines/qrcode/port.d.ts +16 -0
  514. package/dist/types/client/engines/table/adapter-tanstack.d.ts +6 -0
  515. package/dist/types/client/engines/table/index.d.ts +8 -0
  516. package/dist/types/client/engines/table/port.d.ts +51 -0
  517. package/dist/types/client/engines/temporal/adapter-polyfill.d.ts +6 -0
  518. package/dist/types/client/engines/temporal/index.d.ts +8 -0
  519. package/dist/types/client/engines/temporal/port.d.ts +41 -0
  520. package/dist/types/client/engines/virtual/adapter-tanstack.d.ts +9 -0
  521. package/dist/types/client/engines/virtual/index.d.ts +8 -0
  522. package/dist/types/client/engines/virtual/port.d.ts +33 -0
  523. package/dist/types/client/format/formatter.d.ts +3 -0
  524. package/dist/types/client/format/index.d.ts +2 -0
  525. package/dist/types/client/format/zoned.d.ts +1 -0
  526. package/dist/types/client/host-bridge/index.d.ts +3 -0
  527. package/dist/types/client/host-bridge/resolve-host-bootstrap.d.ts +7 -1
  528. package/dist/types/client/host-bridge/soma-app-host.stub.d.ts +3 -0
  529. package/dist/types/client/host-bridge/soma-bootstrap-from-app.d.ts +9 -0
  530. package/dist/types/client/infra/auth/IAuthService.d.ts +5 -0
  531. package/dist/types/client/infra/auth/TokenAuthService.d.ts +1 -0
  532. package/dist/types/client/infra/config/SomaConfig.d.ts +4 -0
  533. package/dist/types/client/infra/config/feature-flags.d.ts +10 -0
  534. package/dist/types/client/infra/http/IHttpClient.d.ts +4 -0
  535. package/dist/types/client/infra/i18n/II18n.d.ts +18 -1
  536. package/dist/types/client/infra/i18n/builtin-locale.d.ts +11 -0
  537. package/dist/types/client/infra/i18n/index.d.ts +1 -0
  538. package/dist/types/client/infra/i18n/interpolate.d.ts +12 -0
  539. package/dist/types/client/infra/i18n/locale-catalog.d.ts +71 -0
  540. package/dist/types/client/infra/i18n/pack-locales.d.ts +29 -0
  541. package/dist/types/client/infra/identity/identity-port.d.ts +54 -0
  542. package/dist/types/client/infra/notify/DefaultNotifyService.d.ts +29 -7
  543. package/dist/types/client/infra/notify/INotifyService.d.ts +1 -12
  544. package/dist/types/client/infra/notify/notify-declaration.d.ts +10 -0
  545. package/dist/types/client/infra/permission/SomaPermission.d.ts +7 -0
  546. package/dist/types/client/infra/router/IRouter.d.ts +5 -1
  547. package/dist/types/client/infra/router/SomaRouter.d.ts +6 -2
  548. package/dist/types/client/keyboard/collection.d.ts +58 -0
  549. package/dist/types/client/keyboard/compose-keys.d.ts +24 -0
  550. package/dist/types/client/keyboard/cursor.d.ts +48 -0
  551. package/dist/types/client/keyboard/delegate.d.ts +48 -0
  552. package/dist/types/client/keyboard/ime.d.ts +2 -0
  553. package/dist/types/client/keyboard/index.d.ts +10 -0
  554. package/dist/types/client/keyboard/intents.d.ts +35 -0
  555. package/dist/types/client/keyboard/matrix.d.ts +29 -0
  556. package/dist/types/client/keyboard/submit.d.ts +7 -0
  557. package/dist/types/client/keyboard/typeahead.d.ts +28 -0
  558. package/dist/types/client/keyboard/wiring.d.ts +87 -0
  559. package/dist/types/client/middleware/createPermissionMiddleware.d.ts +5 -0
  560. package/dist/types/client/mount/domain-rule.d.ts +17 -0
  561. package/dist/types/client/mount/index.d.ts +3 -0
  562. package/dist/types/client/mount/mount-page.d.ts +11 -0
  563. package/dist/types/client/mount/types.d.ts +100 -0
  564. package/dist/types/client/observability/runtime-observer.d.ts +24 -0
  565. package/dist/types/client/parser/confirm-spec.d.ts +37 -0
  566. package/dist/types/client/parser/data-config-parser.d.ts +23 -17
  567. package/dist/types/client/parser/duration.d.ts +1 -1
  568. package/dist/types/client/parser/page-state-parser.d.ts +1 -6
  569. package/dist/types/client/parser/pipeline-parser.d.ts +7 -12
  570. package/dist/types/client/parser/style-config-parser.d.ts +2 -1
  571. package/dist/types/client/parser/subscribe-parser.d.ts +5 -0
  572. package/dist/types/client/parser/ui-config-parser.d.ts +26 -25
  573. package/dist/types/client/pipes/pipe-registry.d.ts +30 -40
  574. package/dist/types/client/registry/declaration-renderer.d.ts +11 -3
  575. package/dist/types/client/registry/page-lifecycle.d.ts +3 -3
  576. package/dist/types/client/registry/remote-page.d.ts +3 -3
  577. package/dist/types/client/render-ports/index.d.ts +15 -0
  578. package/dist/types/client/render-ports/notify-renderer.d.ts +55 -0
  579. package/dist/types/client/render-ports/region-fallback.d.ts +10 -0
  580. package/dist/types/client/render-ports/scheduling/prompt-queue.d.ts +19 -0
  581. package/dist/types/client/render-ports/scheduling/toast-scheduler.d.ts +60 -0
  582. package/dist/types/client/runtime/SomaRuntimeServices.d.ts +102 -5
  583. package/dist/types/client/runtime/nav-history.d.ts +31 -0
  584. package/dist/types/client/runtime/nav-port.d.ts +12 -0
  585. package/dist/types/client/runtime/shortcuts.d.ts +41 -0
  586. package/dist/types/client/runtime/write-feedback.d.ts +22 -0
  587. package/dist/types/client/runtime-entry.d.ts +13 -0
  588. package/dist/types/client/scheduler/SomaScheduler.d.ts +5 -0
  589. package/dist/types/client/{adaptive → scheduling}/flush-scheduler.d.ts +2 -2
  590. package/dist/types/client/scheduling/index.d.ts +4 -0
  591. package/dist/types/client/scheduling/observer-pool.d.ts +15 -0
  592. package/dist/types/client/security/url-guard.d.ts +18 -0
  593. package/dist/types/client/styles/compiled-styles.d.ts +10 -0
  594. package/dist/types/client/styles/index.d.ts +3 -0
  595. package/dist/types/client/styles/pack-styles.d.ts +51 -0
  596. package/dist/types/client/styles/sheet-mount.d.ts +7 -0
  597. package/dist/types/client/{component → styles}/style-features.d.ts +1 -1
  598. package/dist/types/client/time/clock.d.ts +10 -0
  599. package/dist/types/client/time/instant.d.ts +1 -0
  600. package/dist/types/client/url-state/index.d.ts +6 -0
  601. package/dist/types/client/url-state/page-tabs-controller.d.ts +22 -0
  602. package/dist/types/client/url-state/state-query-binding.d.ts +22 -0
  603. package/dist/types/client/url-state/url-state.d.ts +47 -0
  604. package/dist/types/client/validation/async-check-registry.d.ts +41 -0
  605. package/dist/types/client/validation/async-rules.d.ts +81 -0
  606. package/dist/types/client/validation/contract-validator.d.ts +10 -0
  607. package/dist/types/client/validation/field-rules.d.ts +6 -0
  608. package/dist/types/client/validation/index.d.ts +5 -0
  609. package/dist/types/client/validation/object-rules.d.ts +22 -0
  610. package/dist/types/index.d.ts +97 -61
  611. package/dist/types/inspect/check-product.d.ts +123 -0
  612. package/dist/types/inspect/check-runtime.d.ts +19 -0
  613. package/dist/types/inspect/runtime.d.ts +39 -0
  614. package/dist/types/page-target/index.d.ts +3 -0
  615. package/dist/types/page-target/provenance.d.ts +20 -0
  616. package/dist/types/page-target/slug.d.ts +7 -0
  617. package/dist/types/page-target/testing/index.d.ts +55 -0
  618. package/dist/types/page-target/types.d.ts +260 -0
  619. package/dist/types/predicates-entry.d.ts +3 -0
  620. package/dist/types/server/compile-port.d.ts +13 -0
  621. package/dist/types/server/diagnostic-gate-entry.d.ts +3 -0
  622. package/dist/types/server/engines/style/candidate-guard.d.ts +14 -0
  623. package/dist/types/server/engines/style/index.d.ts +10 -0
  624. package/dist/types/server/engines/style/port.d.ts +8 -0
  625. package/dist/types/server/engines/style/tailwind-adapter.d.ts +6 -0
  626. package/dist/types/server/host/content-security-policy.d.ts +5 -0
  627. package/dist/types/server/host/host-assembly-entry.d.ts +2 -0
  628. package/dist/types/server/host/host-assembly.d.ts +56 -0
  629. package/dist/types/server/host/host-config-paths.d.cts +7 -0
  630. package/dist/types/server/host/locale-yaml.d.ts +3 -0
  631. package/dist/types/server/host/page-markup-config.d.ts +6 -0
  632. package/dist/types/server/host/published-page-artifact-cache.d.ts +99 -22
  633. package/dist/types/server/host/published-page-assets.d.ts +74 -4
  634. package/dist/types/server/host/server-page-assets.d.ts +29 -1
  635. package/dist/types/server/host/soma-page-compile.d.ts +26 -4
  636. package/dist/types/server/host/source-packages.d.cts +23 -0
  637. package/dist/types/server/host/source-packages.d.ts +15 -2
  638. package/dist/types/server/host/virtual-pages.d.ts +43 -0
  639. package/dist/types/server/index.d.ts +8 -12
  640. package/dist/types/server/node.d.ts +16 -0
  641. package/dist/types/server/page-assets.d.ts +10 -0
  642. package/dist/types/server/page-declaration.d.ts +21 -6
  643. package/dist/types/server/registry/api-registry-store.d.ts +9 -7
  644. package/dist/types/server/registry/asset-store.d.ts +13 -7
  645. package/dist/types/server/registry/batch-publish.d.ts +12 -0
  646. package/dist/types/server/registry/batch-stage.d.ts +24 -0
  647. package/dist/types/server/registry/component-supply.d.ts +6 -0
  648. package/dist/types/server/registry/declaration-precompiler.d.ts +22 -8
  649. package/dist/types/server/registry/index.d.ts +12 -3
  650. package/dist/types/server/registry/page-registry-repository.d.ts +46 -0
  651. package/dist/types/server/registry/page-registry-store.d.ts +225 -23
  652. package/dist/types/server/registry/publish-asset-pin.d.ts +5 -4
  653. package/dist/types/server/registry/registry-file-lock.d.ts +5 -0
  654. package/dist/types/server/registry/registry-write-pipeline.d.ts +22 -0
  655. package/dist/types/server/registry/request-body-limit.d.ts +1 -1
  656. package/dist/types/server/registry/rollback-plan.d.ts +61 -0
  657. package/dist/types/server/registry/services/index.d.ts +5 -0
  658. package/dist/types/server/registry/services/pages/Register.d.ts +1 -1
  659. package/dist/types/server/registry/services/pages/RegisterBatch.d.ts +12 -0
  660. package/dist/types/server/registry/services/pages/Rollback.d.ts +4 -1
  661. package/dist/types/server/registry/source/canonical.d.ts +2 -0
  662. package/dist/types/server/registry/source/errors.d.ts +44 -0
  663. package/dist/types/server/registry/source/index.d.ts +7 -0
  664. package/dist/types/server/registry/source/ledger.d.ts +99 -0
  665. package/dist/types/server/registry/source/snapshot.d.ts +6 -0
  666. package/dist/types/server/registry/source/source-name.d.ts +20 -0
  667. package/dist/types/server/registry/source/types.d.ts +89 -0
  668. package/dist/types/server/registry/source/version-store.d.ts +66 -0
  669. package/dist/types/server/registry/standard-product.d.ts +78 -0
  670. package/dist/types/server/registry/validation/compile-gate.d.ts +12 -45
  671. package/dist/types/server/registry/validation/cross-check.d.ts +7 -0
  672. package/dist/types/server/registry/validation/declaration-safety-scan.d.ts +0 -1
  673. package/dist/types/server/registry/validation/region-scopes.d.ts +10 -0
  674. package/dist/types/server/runtime-space/access-gate.d.ts +41 -0
  675. package/dist/types/server/runtime-space/advice-log.d.ts +18 -0
  676. package/dist/types/server/runtime-space/artifact-evict.d.ts +4 -0
  677. package/dist/types/server/runtime-space/bindings.d.ts +115 -0
  678. package/dist/types/server/runtime-space/digest.d.ts +19 -0
  679. package/dist/types/server/runtime-space/dynamic-pages.d.ts +120 -0
  680. package/dist/types/server/runtime-space/errors.d.ts +37 -0
  681. package/dist/types/server/runtime-space/gc.d.ts +6 -0
  682. package/dist/types/server/runtime-space/index.d.ts +19 -0
  683. package/dist/types/server/runtime-space/inject.d.ts +55 -0
  684. package/dist/types/server/runtime-space/migrate-sources.d.ts +19 -0
  685. package/dist/types/server/runtime-space/nav-catalog.d.ts +33 -0
  686. package/dist/types/server/runtime-space/page-grants.d.ts +90 -0
  687. package/dist/types/server/runtime-space/prewarm.d.ts +60 -0
  688. package/dist/types/server/runtime-space/registry-cold-start.d.ts +4 -0
  689. package/dist/types/server/runtime-space/resolve.d.ts +38 -0
  690. package/dist/types/server/runtime-space/root.d.cts +88 -0
  691. package/dist/types/server/runtime-space/root.d.ts +21 -0
  692. package/dist/types/server/runtime-space/static-source.d.ts +8 -0
  693. package/dist/types/server/runtime-space/store.d.ts +63 -0
  694. package/dist/types/server/runtime-space/submit-steps.d.ts +116 -0
  695. package/dist/types/server/runtime-space/types.d.ts +264 -0
  696. package/dist/types/shared/anchor-space.d.ts +17 -0
  697. package/dist/types/shared/artifact-compatibility.d.ts +77 -0
  698. package/dist/types/shared/behavior-machine-names.d.ts +2 -0
  699. package/dist/types/shared/calc/coerce.d.ts +1 -4
  700. package/dist/types/shared/calc/lexer.d.ts +1 -2
  701. package/dist/types/shared/calc/parser.d.ts +1 -7
  702. package/dist/types/shared/calc/typer.d.ts +1 -6
  703. package/dist/types/shared/component-tree-artifact.d.ts +16 -2
  704. package/dist/types/shared/contract-a11y.d.ts +33 -0
  705. package/dist/types/shared/contract-sections.d.ts +50 -0
  706. package/dist/types/shared/core-diagnostic-codes.d.ts +28 -0
  707. package/dist/types/shared/data-declaration-checks.d.ts +71 -0
  708. package/dist/types/shared/date-parts.d.ts +1 -0
  709. package/dist/types/shared/declaration-errors.d.ts +12 -0
  710. package/dist/types/shared/declaration-keys.d.ts +9 -0
  711. package/dist/types/shared/diagnostic-code-index-entry.d.ts +5 -0
  712. package/dist/types/shared/diagnostic-gate.d.ts +60 -0
  713. package/dist/types/shared/engines/engine-error.d.ts +14 -0
  714. package/dist/types/shared/engines/style/style-engine.types.d.ts +22 -0
  715. package/dist/types/shared/fragments-section.d.ts +2 -0
  716. package/dist/types/shared/generation-diagnostics.d.ts +7 -0
  717. package/dist/types/shared/generation-error.d.ts +20 -0
  718. package/dist/types/shared/hook-attributes.d.ts +220 -0
  719. package/dist/types/shared/inert-data-element.d.ts +14 -0
  720. package/dist/types/shared/nav-back.d.ts +22 -0
  721. package/dist/types/shared/page-access-text.d.ts +4 -0
  722. package/dist/types/shared/page-envelope-runtime.d.ts +32 -0
  723. package/dist/types/shared/page-envelope.d.ts +61 -0
  724. package/dist/types/shared/page-scopes.d.ts +35 -0
  725. package/dist/types/shared/pipeline-error-codes-view.d.ts +11 -0
  726. package/dist/types/shared/pipeline-limits-view.d.ts +8 -0
  727. package/dist/types/shared/predicates/index.d.ts +24 -67
  728. package/dist/types/shared/predicates/relative-window.d.ts +1 -0
  729. package/dist/types/shared/published-page-route.d.ts +2 -2
  730. package/dist/types/shared/region-scope-decl.d.ts +121 -0
  731. package/dist/types/shared/registry-generated/compile-purposes.d.ts +37 -0
  732. package/dist/types/shared/registry-generated/diagnostic-registry-index.d.ts +2 -0
  733. package/dist/types/shared/registry-generated/diagnostic-registry.d.ts +5023 -0
  734. package/dist/types/shared/registry-generated/error-codes.d.ts +115 -0
  735. package/dist/types/shared/registry-generated/index.d.ts +10 -0
  736. package/dist/types/shared/registry-generated/limits.d.ts +461 -0
  737. package/dist/types/shared/registry-generated/platform-keys.d.ts +42 -0
  738. package/dist/types/shared/registry-generated/region-scope.d.ts +511 -0
  739. package/dist/types/shared/registry-generated/std-grammar-completion.d.ts +773 -0
  740. package/dist/types/shared/registry-generated/std-grammar-views.d.ts +203 -0
  741. package/dist/types/shared/registry-generated/std-grammar.d.ts +3515 -0
  742. package/dist/types/shared/rule-step.d.ts +1 -0
  743. package/dist/types/shared/runtime-address.d.ts +70 -0
  744. package/dist/types/shared/scope-decl.d.ts +15 -0
  745. package/dist/types/shared/sha256.d.ts +4 -0
  746. package/dist/types/shared/show-when.d.ts +21 -0
  747. package/dist/types/shared/source-compat.d.ts +2 -0
  748. package/dist/types/shared/std-auth-scan.d.ts +45 -0
  749. package/dist/types/shared/types/choice-confirm.types.d.ts +1 -0
  750. package/dist/types/shared/types/compile-diagnostic.types.d.ts +34 -0
  751. package/dist/types/shared/types/compile-port.types.d.ts +30 -0
  752. package/dist/types/shared/types/component-contract.types.d.ts +134 -129
  753. package/dist/types/shared/types/component-tree-artifact.types.d.ts +29 -2
  754. package/dist/types/shared/types/component-tree.types.d.ts +15 -6
  755. package/dist/types/shared/types/data-config.types.d.ts +175 -191
  756. package/dist/types/shared/types/domain.types.d.ts +20 -5
  757. package/dist/types/shared/types/engine.types.d.ts +2 -0
  758. package/dist/types/shared/types/event.types.d.ts +59 -9
  759. package/dist/types/shared/types/generation-error.types.d.ts +28 -0
  760. package/dist/types/shared/types/host-assembly.types.d.ts +95 -0
  761. package/dist/types/shared/types/locale.types.d.ts +17 -0
  762. package/dist/types/shared/types/manifest.types.d.ts +2 -7
  763. package/dist/types/shared/types/nav-context.types.d.ts +41 -0
  764. package/dist/types/shared/types/nav.types.d.ts +53 -0
  765. package/dist/types/shared/types/notify.types.d.ts +37 -0
  766. package/dist/types/shared/types/observation.types.d.ts +72 -0
  767. package/dist/types/shared/types/page-envelope.types.d.ts +98 -0
  768. package/dist/types/shared/types/page-state.types.d.ts +17 -33
  769. package/dist/types/shared/types/region-scope.types.d.ts +150 -0
  770. package/dist/types/shared/types/registry-batch.types.d.ts +48 -0
  771. package/dist/types/shared/types/shortcuts.types.d.ts +67 -0
  772. package/dist/types/shared/types/source.types.d.ts +10 -0
  773. package/dist/types/shared/types/style-config.types.d.ts +0 -19
  774. package/dist/types/shared/types/temporal.types.d.ts +1 -0
  775. package/dist/types/shared/types/ui-config.types.d.ts +82 -148
  776. package/dist/types/shared/types/write-outcome-view.types.d.ts +19 -0
  777. package/dist/types/shared/types/write-runtime.types.d.ts +1 -0
  778. package/dist/types/shared/types/write.types.d.ts +70 -0
  779. package/global.d.ts +2 -1
  780. package/package.json +216 -62
  781. package/tsconfig.json +2 -10
  782. package/app/SomaPageClient.tsx +0 -313
  783. package/app/[...path]/page.tsx +0 -22
  784. package/app/api/[...path]/route.ts +0 -86
  785. package/app/api/soma-registry/[...path]/route.ts +0 -67
  786. package/app/components/SomaHostPage.tsx +0 -128
  787. package/app/components/SomaHydrationShell.tsx +0 -20
  788. package/app/components/SomaPageClientBoundary.tsx +0 -13
  789. package/app/favicon.ico/route.ts +0 -13
  790. package/app/globals.css +0 -126
  791. package/app/layout.tsx +0 -27
  792. package/app/page.tsx +0 -9
  793. package/app/soma/[...path]/route.ts +0 -9
  794. package/app/soma/manifest/route.ts +0 -43
  795. package/app/soma/page/route.ts +0 -44
  796. package/app/soma/page-object/route.ts +0 -159
  797. package/app/soma/route.ts +0 -9
  798. package/bin/component.cjs +0 -240
  799. package/bin/migrate.cjs +0 -432
  800. package/bin/soma-db.cjs +0 -13
  801. package/bin/soma-mock.mjs +0 -38
  802. package/bin/soma-sync.cjs +0 -3
  803. package/core/build/blocks/block-compile.ts +0 -373
  804. package/core/build/blocks/block-container.ts +0 -207
  805. package/core/build/blocks/block-loader.ts +0 -33
  806. package/core/build/blocks/migrate-flat.ts +0 -463
  807. package/core/build/compiler/precompiled-manifest-loader.ts +0 -41
  808. package/core/build/component/pack-from-dir.ts +0 -58
  809. package/core/build/component/package-loader.ts +0 -358
  810. package/core/build/component-tree/binding-bridge.ts +0 -272
  811. package/core/build/component-tree/migration-files.ts +0 -214
  812. package/core/build/component-tree/migration.ts +0 -170
  813. package/core/build/component-tree/validator.ts +0 -318
  814. package/core/build/db/cli.ts +0 -10
  815. package/core/build/db/emit-entities.ts +0 -45
  816. package/core/build/db/emit-mappers.ts +0 -175
  817. package/core/build/db/emit-prisma-schema.ts +0 -92
  818. package/core/build/db/generate.ts +0 -166
  819. package/core/build/db/ir.ts +0 -75
  820. package/core/build/db/load-db-yaml.ts +0 -241
  821. package/core/build/eject/component-eject.ts +0 -480
  822. package/core/build/eject/component-upgrade.ts +0 -359
  823. package/core/build/layout/constraint-solver.ts +0 -350
  824. package/core/build/layout/css-emitter.ts +0 -135
  825. package/core/build/layout/page-layout.ts +0 -85
  826. package/core/build/ooui/artifact/artifact.types.ts +0 -275
  827. package/core/build/ooui/artifact/emit-artifact.ts +0 -269
  828. package/core/build/ooui/artifact/emit-html.ts +0 -204
  829. package/core/build/ooui/artifact/index.ts +0 -53
  830. package/core/build/ooui/artifact/spatial-tree.ts +0 -268
  831. package/core/build/ooui/artifact/utility-class.ts +0 -83
  832. package/core/build/ooui/composition/candidate.types.ts +0 -323
  833. package/core/build/ooui/composition/control-model.ts +0 -114
  834. package/core/build/ooui/composition/registry.ts +0 -520
  835. package/core/build/ooui/composition/select.ts +0 -232
  836. package/core/build/ooui/diagnostics/codes.ts +0 -230
  837. package/core/build/ooui/diagnostics/error.ts +0 -235
  838. package/core/build/ooui/diagnostics/format.ts +0 -106
  839. package/core/build/ooui/diagnostics/index.ts +0 -62
  840. package/core/build/ooui/diagnostics/issue.types.ts +0 -112
  841. package/core/build/ooui/engine-slot.ts +0 -184
  842. package/core/build/ooui/index.ts +0 -1427
  843. package/core/build/ooui/intent/derive-intent.ts +0 -450
  844. package/core/build/ooui/intent/field-rules.ts +0 -330
  845. package/core/build/ooui/intent/intent.types.ts +0 -476
  846. package/core/build/ooui/intent/verb-events.ts +0 -285
  847. package/core/build/ooui/page/budget.ts +0 -503
  848. package/core/build/ooui/page/compose-page.ts +0 -736
  849. package/core/build/ooui/page/index.ts +0 -66
  850. package/core/build/ooui/page/page.types.ts +0 -402
  851. package/core/build/ooui/page/region-row.ts +0 -241
  852. package/core/build/ooui/semantic/expand-page-surface.ts +0 -180
  853. package/core/build/ooui/semantic/kernel.types.ts +0 -187
  854. package/core/build/ooui/semantic/normalize.ts +0 -784
  855. package/core/build/ooui/semantic/origin.types.ts +0 -211
  856. package/core/build/ooui/semantic/role-alias.ts +0 -154
  857. package/core/build/ooui/semantic/shorthand.ts +0 -233
  858. package/core/build/ooui/semantic/surface.types.ts +0 -78
  859. package/core/build/ooui/semantic/validate-request.ts +0 -267
  860. package/core/build/ooui/spatial/emit-utility.ts +0 -480
  861. package/core/build/ooui/spatial/ir.types.ts +0 -443
  862. package/core/build/ooui/spatial/registry.ts +0 -565
  863. package/core/build/ooui/spatial/solve.ts +0 -769
  864. package/core/build/ooui/spatial/utility.types.ts +0 -242
  865. package/core/build/ooui/trace/index.ts +0 -40
  866. package/core/build/ooui/trace/render.ts +0 -190
  867. package/core/build/ooui/trace/source.types.ts +0 -69
  868. package/core/build/ooui/trace/trace.types.ts +0 -326
  869. package/core/build/pack/pack-init.ts +0 -270
  870. package/core/client/adaptive/hysteresis.ts +0 -56
  871. package/core/client/adaptive/index.ts +0 -23
  872. package/core/client/adaptive/observer-pool.ts +0 -204
  873. package/core/client/compiler/adaptive-compile.ts +0 -136
  874. package/core/client/component/ai-catalog.ts +0 -432
  875. package/core/client/component/catalog-examples.ts +0 -60
  876. package/core/client/component/contract-compat.ts +0 -161
  877. package/core/client/component/example-blocks.ts +0 -126
  878. package/core/client/component/keyboard-matrix.ts +0 -144
  879. package/core/client/component/pack-styles.ts +0 -152
  880. package/core/client/component/theme-component-tokens.ts +0 -80
  881. package/core/client/component/verify-pack.ts +0 -429
  882. package/core/client/container/MiniProgramContainerAdapter.ts +0 -204
  883. package/core/client/container/ReactNativeContainerAdapter.ts +0 -203
  884. package/core/client/data/reaction-engine.ts +0 -176
  885. package/core/client/data/window-engine.ts +0 -477
  886. package/core/client/infra/i18n/DefaultI18n.ts +0 -29
  887. package/core/client/infra/notify/DomNotifyService.ts +0 -99
  888. package/core/client/infra/notify/INotifyTheme.ts +0 -22
  889. package/core/client/parser/adaptive-parser.ts +0 -264
  890. package/core/client/parser/blocks/namespace.ts +0 -207
  891. package/core/client/parser/blocks/page-parser.ts +0 -466
  892. package/core/client/parser/blocks/use-parser.ts +0 -646
  893. package/core/client/parser/layout-parser.ts +0 -158
  894. package/core/client/parser/reaction-parser.ts +0 -458
  895. package/core/client/parser/reaction-sugar.ts +0 -47
  896. package/core/client/parser/window-parser.ts +0 -294
  897. package/core/client/quality/SomaQualityRegistry.ts +0 -71
  898. package/core/client/runtime/serialize-page-state.ts +0 -152
  899. package/core/client/theme/harmony.ts +0 -429
  900. package/core/client/theme/scene-tokens.ts +0 -155
  901. package/core/client/theme/theme-axes.ts +0 -323
  902. package/core/client/theme/theme-engine.ts +0 -2390
  903. package/core/client/theme/tone-solver.ts +0 -119
  904. package/core/client/typography/typography-base.ts +0 -34
  905. package/core/server/headless/soma-headless-page.ts +0 -103
  906. package/core/server/infra/db/errors.ts +0 -11
  907. package/core/server/infra/db/mapper/PrismaSomaMapper.ts +0 -313
  908. package/core/server/infra/db/mapper/SomaBaseMapper.ts +0 -23
  909. package/core/server/infra/db/mapper/SomaMapperHooks.ts +0 -13
  910. package/core/server/infra/db/query/SomaQuery.ts +0 -149
  911. package/core/server/infra/db/service/SomaDbService.ts +0 -64
  912. package/core/server/infra/db/soma-db.ts +0 -120
  913. package/core/server/infra/db/types.ts +0 -21
  914. package/core/server/mock/node/catch-all.mjs +0 -35
  915. package/core/server/mock/node/cli.d.mts +0 -58
  916. package/core/server/mock/node/cli.mjs +0 -244
  917. package/core/server/mock/node/context.mjs +0 -167
  918. package/core/server/mock/node/environment-policy.mjs +0 -52
  919. package/core/server/mock/node/plugin-loader.mjs +0 -212
  920. package/core/server/mock/node/preload.mjs +0 -91
  921. package/core/server/mock/node/process-lifecycle.mjs +0 -236
  922. package/core/server/mock/node/public.d.mts +0 -110
  923. package/core/server/mock/node/public.mjs +0 -4
  924. package/core/server/mock/node/registry.mjs +0 -336
  925. package/core/server/mock/node/schema-generator.mjs +0 -1309
  926. package/core/server/mock/testing/host-harness.d.mts +0 -66
  927. package/core/server/mock/testing/host-harness.mjs +0 -276
  928. package/core/server/mock/testing/host-runtime.mjs +0 -48
  929. package/core/server/ooui.ts +0 -34
  930. package/core/shared/block-errors.ts +0 -11
  931. package/core/shared/component/derive-sample.ts +0 -290
  932. package/core/shared/component/field-lines.ts +0 -563
  933. package/core/shared/container-breakpoints.ts +0 -46
  934. package/core/shared/object-semantics.ts +0 -240
  935. package/core/shared/ooui-declaration.ts +0 -235
  936. package/core/shared/path-algebra.ts +0 -169
  937. package/core/shared/types/adaptive.types.ts +0 -109
  938. package/core/shared/types/layout-constraint.types.ts +0 -89
  939. package/core/shared/types/reaction.types.ts +0 -144
  940. package/core/shared/types/window.types.ts +0 -177
  941. package/dist/types/build/blocks/block-compile.d.ts +0 -52
  942. package/dist/types/build/blocks/block-container.d.ts +0 -40
  943. package/dist/types/build/blocks/block-loader.d.ts +0 -9
  944. package/dist/types/build/blocks/migrate-flat.d.ts +0 -49
  945. package/dist/types/build/compiler/precompiled-manifest-loader.d.ts +0 -5
  946. package/dist/types/build/component/pack-from-dir.d.ts +0 -17
  947. package/dist/types/build/component/package-loader.d.ts +0 -50
  948. package/dist/types/build/component-tree/binding-bridge.d.ts +0 -19
  949. package/dist/types/build/component-tree/migration-files.d.ts +0 -35
  950. package/dist/types/build/component-tree/migration.d.ts +0 -28
  951. package/dist/types/build/component-tree/validator.d.ts +0 -9
  952. package/dist/types/build/db/cli.d.ts +0 -2
  953. package/dist/types/build/db/emit-entities.d.ts +0 -5
  954. package/dist/types/build/db/emit-mappers.d.ts +0 -15
  955. package/dist/types/build/db/emit-prisma-schema.d.ts +0 -2
  956. package/dist/types/build/db/generate.d.ts +0 -7
  957. package/dist/types/build/db/ir.d.ts +0 -58
  958. package/dist/types/build/db/load-db-yaml.d.ts +0 -14
  959. package/dist/types/build/eject/component-eject.d.ts +0 -121
  960. package/dist/types/build/eject/component-upgrade.d.ts +0 -43
  961. package/dist/types/build/layout/constraint-solver.d.ts +0 -78
  962. package/dist/types/build/layout/css-emitter.d.ts +0 -18
  963. package/dist/types/build/layout/page-layout.d.ts +0 -24
  964. package/dist/types/build/ooui/artifact/artifact.types.d.ts +0 -180
  965. package/dist/types/build/ooui/artifact/emit-artifact.d.ts +0 -58
  966. package/dist/types/build/ooui/artifact/emit-html.d.ts +0 -53
  967. package/dist/types/build/ooui/artifact/index.d.ts +0 -5
  968. package/dist/types/build/ooui/artifact/spatial-tree.d.ts +0 -48
  969. package/dist/types/build/ooui/artifact/utility-class.d.ts +0 -46
  970. package/dist/types/build/ooui/composition/candidate.types.d.ts +0 -206
  971. package/dist/types/build/ooui/composition/control-model.d.ts +0 -37
  972. package/dist/types/build/ooui/composition/registry.d.ts +0 -66
  973. package/dist/types/build/ooui/composition/select.d.ts +0 -63
  974. package/dist/types/build/ooui/diagnostics/codes.d.ts +0 -28
  975. package/dist/types/build/ooui/diagnostics/error.d.ts +0 -135
  976. package/dist/types/build/ooui/diagnostics/format.d.ts +0 -51
  977. package/dist/types/build/ooui/diagnostics/index.d.ts +0 -25
  978. package/dist/types/build/ooui/diagnostics/issue.types.d.ts +0 -56
  979. package/dist/types/build/ooui/engine-slot.d.ts +0 -41
  980. package/dist/types/build/ooui/index.d.ts +0 -286
  981. package/dist/types/build/ooui/intent/derive-intent.d.ts +0 -32
  982. package/dist/types/build/ooui/intent/field-rules.d.ts +0 -99
  983. package/dist/types/build/ooui/intent/intent.types.d.ts +0 -318
  984. package/dist/types/build/ooui/intent/verb-events.d.ts +0 -70
  985. package/dist/types/build/ooui/page/budget.d.ts +0 -28
  986. package/dist/types/build/ooui/page/compose-page.d.ts +0 -41
  987. package/dist/types/build/ooui/page/index.d.ts +0 -4
  988. package/dist/types/build/ooui/page/page.types.d.ts +0 -264
  989. package/dist/types/build/ooui/page/region-row.d.ts +0 -16
  990. package/dist/types/build/ooui/semantic/expand-page-surface.d.ts +0 -33
  991. package/dist/types/build/ooui/semantic/kernel.types.d.ts +0 -125
  992. package/dist/types/build/ooui/semantic/normalize.d.ts +0 -45
  993. package/dist/types/build/ooui/semantic/origin.types.d.ts +0 -95
  994. package/dist/types/build/ooui/semantic/role-alias.d.ts +0 -35
  995. package/dist/types/build/ooui/semantic/shorthand.d.ts +0 -60
  996. package/dist/types/build/ooui/semantic/surface.types.d.ts +0 -16
  997. package/dist/types/build/ooui/semantic/validate-request.d.ts +0 -19
  998. package/dist/types/build/ooui/spatial/emit-utility.d.ts +0 -43
  999. package/dist/types/build/ooui/spatial/ir.types.d.ts +0 -280
  1000. package/dist/types/build/ooui/spatial/registry.d.ts +0 -110
  1001. package/dist/types/build/ooui/spatial/solve.d.ts +0 -42
  1002. package/dist/types/build/ooui/spatial/utility.types.d.ts +0 -191
  1003. package/dist/types/build/ooui/trace/index.d.ts +0 -3
  1004. package/dist/types/build/ooui/trace/render.d.ts +0 -42
  1005. package/dist/types/build/ooui/trace/source.types.d.ts +0 -25
  1006. package/dist/types/build/ooui/trace/trace.types.d.ts +0 -143
  1007. package/dist/types/build/pack/pack-init.d.ts +0 -8
  1008. package/dist/types/client/adaptive/hysteresis.d.ts +0 -16
  1009. package/dist/types/client/adaptive/index.d.ts +0 -5
  1010. package/dist/types/client/adaptive/observer-pool.d.ts +0 -22
  1011. package/dist/types/client/compiler/adaptive-compile.d.ts +0 -26
  1012. package/dist/types/client/component/ai-catalog.d.ts +0 -122
  1013. package/dist/types/client/component/catalog-examples.d.ts +0 -18
  1014. package/dist/types/client/component/contract-compat.d.ts +0 -16
  1015. package/dist/types/client/component/example-blocks.d.ts +0 -7
  1016. package/dist/types/client/component/keyboard-matrix.d.ts +0 -24
  1017. package/dist/types/client/component/pack-styles.d.ts +0 -43
  1018. package/dist/types/client/component/theme-component-tokens.d.ts +0 -17
  1019. package/dist/types/client/component/verify-pack.d.ts +0 -24
  1020. package/dist/types/client/container/MiniProgramContainerAdapter.d.ts +0 -52
  1021. package/dist/types/client/container/ReactNativeContainerAdapter.d.ts +0 -47
  1022. package/dist/types/client/data/reaction-engine.d.ts +0 -21
  1023. package/dist/types/client/data/window-engine.d.ts +0 -27
  1024. package/dist/types/client/infra/i18n/DefaultI18n.d.ts +0 -7
  1025. package/dist/types/client/infra/notify/DomNotifyService.d.ts +0 -17
  1026. package/dist/types/client/infra/notify/INotifyTheme.d.ts +0 -12
  1027. package/dist/types/client/parser/adaptive-parser.d.ts +0 -28
  1028. package/dist/types/client/parser/blocks/namespace.d.ts +0 -72
  1029. package/dist/types/client/parser/blocks/page-parser.d.ts +0 -30
  1030. package/dist/types/client/parser/blocks/use-parser.d.ts +0 -124
  1031. package/dist/types/client/parser/layout-parser.d.ts +0 -9
  1032. package/dist/types/client/parser/reaction-parser.d.ts +0 -16
  1033. package/dist/types/client/parser/reaction-sugar.d.ts +0 -13
  1034. package/dist/types/client/parser/window-parser.d.ts +0 -25
  1035. package/dist/types/client/quality/SomaQualityRegistry.d.ts +0 -31
  1036. package/dist/types/client/runtime/serialize-page-state.d.ts +0 -10
  1037. package/dist/types/client/theme/harmony.d.ts +0 -119
  1038. package/dist/types/client/theme/scene-tokens.d.ts +0 -41
  1039. package/dist/types/client/theme/theme-axes.d.ts +0 -174
  1040. package/dist/types/client/theme/theme-engine.d.ts +0 -119
  1041. package/dist/types/client/theme/tone-solver.d.ts +0 -51
  1042. package/dist/types/client/typography/typography-base.d.ts +0 -15
  1043. package/dist/types/server/headless/soma-headless-page.d.ts +0 -12
  1044. package/dist/types/server/infra/db/errors.d.ts +0 -5
  1045. package/dist/types/server/infra/db/mapper/PrismaSomaMapper.d.ts +0 -77
  1046. package/dist/types/server/infra/db/mapper/SomaBaseMapper.d.ts +0 -20
  1047. package/dist/types/server/infra/db/mapper/SomaMapperHooks.d.ts +0 -12
  1048. package/dist/types/server/infra/db/query/SomaQuery.d.ts +0 -42
  1049. package/dist/types/server/infra/db/service/SomaDbService.d.ts +0 -24
  1050. package/dist/types/server/infra/db/soma-db.d.ts +0 -45
  1051. package/dist/types/server/infra/db/types.d.ts +0 -18
  1052. package/dist/types/server/ooui.d.ts +0 -18
  1053. package/dist/types/shared/block-errors.d.ts +0 -5
  1054. package/dist/types/shared/component/derive-sample.d.ts +0 -37
  1055. package/dist/types/shared/component/field-lines.d.ts +0 -19
  1056. package/dist/types/shared/container-breakpoints.d.ts +0 -42
  1057. package/dist/types/shared/object-semantics.d.ts +0 -42
  1058. package/dist/types/shared/ooui-declaration.d.ts +0 -135
  1059. package/dist/types/shared/path-algebra.d.ts +0 -56
  1060. package/dist/types/shared/types/adaptive.types.d.ts +0 -88
  1061. package/dist/types/shared/types/layout-constraint.types.d.ts +0 -53
  1062. package/dist/types/shared/types/reaction.types.d.ts +0 -115
  1063. package/dist/types/shared/types/window.types.d.ts +0 -171
  1064. package/next.config.js +0 -387
  1065. package/proxy.ts +0 -62
@@ -1,6 +1,8 @@
1
1
  // core/client/engine/soma-bootstrap.ts
2
2
  // 职责:生命周期编排(唯一职责)
3
3
 
4
+ import type { SomaRenderPorts } from '../render-ports';
5
+ import type { SomaEngineAdapters } from '../engines/engine-adapters';
4
6
  import { SomaContainerAdapter } from '../container/SomaContainerAdapter';
5
7
  import type { IContainerAdapter } from '../container/IContainerAdapter';
6
8
  import { SomaDiagnostics, type SomaDiagnosticsSnapshot } from '../diagnostics/SomaDiagnostics';
@@ -9,16 +11,22 @@ import { setActiveTelemetry, recordMetric } from '../diagnostics/telemetry-conte
9
11
  import { markBootPhase, maybeStartBootTimings } from '../diagnostics/boot-timings';
10
12
  import { SomaMiddlewareChain } from '../middleware/SomaMiddlewareChain';
11
13
  import { SomaScheduler } from '../scheduler/SomaScheduler';
12
- import type { ParsedEvent } from '../../shared/types/event.types';
14
+ import type { ParsedEvent, SomaConfirmSpec } from '../../shared/types/event.types';
13
15
  import type { PropertyTrigger } from '../../shared/types/trigger.types';
14
16
  import type { ParsedTimer } from '../../shared/types/timer.types';
15
17
  import type { StyleConfig } from '../../shared/types/style-config.types';
16
- import type { UiConfig } from '../../shared/types/ui-config.types';
17
- import type { SomaAdaptiveVocabulary } from '../../shared/types/adaptive.types';
18
- import type { SomaPageRoot } from '../../shared/types/domain.types';
18
+ import type { SomaCompiledStyle, UiConfig } from '../../shared/types/ui-config.types';
19
+ import type { SomaPageRoot as SharedPageRoot } from '../../shared/types/domain.types';
20
+ import type { SomaRuntimeServices } from '../runtime/SomaRuntimeServices';
21
+
22
+ import { createClock } from '../time/clock';
23
+ import type { SomaClockPort } from '../../shared/types/temporal.types';
24
+
25
+ /** 引擎内部视角的页面根:`_services` 是完整的运行期服务表(shared 层只认最小接口,AD-65 / C-int) */
26
+ type SomaPageRoot = SharedPageRoot<SomaRuntimeServices>;
19
27
  import { SomaSnapshotStore } from '../runtime/SomaSnapshotStore';
20
28
  import { SomaAssetResolver } from './asset-resolver';
21
- import type { SomaEventMiddlewareContext } from './event-engine';
29
+ import type { SomaEventMiddlewareContext, SomaScopeEventHandler } from './event-engine';
22
30
  import { SomaReactiveProxy } from './reactive-proxy';
23
31
  import type { SomaRenderEngine, SomaRenderMiddlewareContext } from './render-engine';
24
32
  import type { SomaEventEngine } from './event-engine';
@@ -31,27 +39,55 @@ import type { SomaOnChangeEngine } from './on-change-engine';
31
39
  import type { SomaTriggerEngine } from './trigger-engine';
32
40
  import type { SomaTimerEngine } from './timer-engine';
33
41
  import { createDefaultRuntimeServices } from '../runtime/SomaRuntimeServices';
42
+ import type { SomaIdentityProvider } from '../infra/identity/identity-port';
34
43
  import { getBrowserUrlPath, readQueryParam } from '../infra/router/router-path';
35
44
  import { parseDataYaml } from '../parser/data-config-parser';
36
- import { SomaDataObjectResolver, createSomaDataPort } from '../data/data-object-resolver';
45
+ import { createDataWriteActions } from '../data/data-write-actions';
46
+ import { SomaDataObjectResolver } from '../data/data-object-resolver';
47
+ import { attachDataSubscriptions, type SomaDataSubscriptionHandle } from '../data/data-subscriptions';
48
+ import { attachDataPolling, type SomaDataPollingHandle } from '../data/data-polling';
49
+ import { createWriteOutcomeStore, type SomaWriteOutcomeStore } from '../data/write-outcome-store';
37
50
  import type { SomaDataPort } from '../../shared/types/data-config.types';
38
51
  import type { SomaDataConfig, SomaDataDicts } from '../../shared/types/data-config.types';
39
52
  import type { WatchCallback, WatcherOptions } from '../../shared/types/watcher.types';
40
53
  import type { SomaStepGraph } from '../../shared/types/step.types';
41
54
  import type { SomaPageState, SomaPageStateConfig } from '../../shared/types/page-state.types';
42
55
  import { decodePageState, encodePageState, parseStateValue } from '../parser/page-state-parser';
43
- import { injectStyleOnce } from '../component/pack-styles';
56
+ import { injectStyleOnce } from '../styles/pack-styles';
57
+ import { installCompiledStyles } from '../styles/compiled-styles';
58
+ import { SomaUiConfigError } from '../parser/ui-config-parser';
59
+ import { SomaLocaleCatalog, type SomaLocaleMissingEvent } from '../infra/i18n/locale-catalog';
60
+ import { SOMA_BUILTIN_LOCALE } from '../infra/i18n/builtin-locale';
61
+ import { createLocaleTextBinder, type SomaLocaleTextBinder } from './locale-text-binder';
62
+ import { createRegionScopeStore } from '../data/region-scope-port';
63
+ import type { SomaShortcutRegistry } from '../../shared/types/write-runtime.types';
64
+ import { createShortcutRegistry, shortcutsDesign } from '../runtime/shortcuts';
65
+ import { bindRegionScopeViews } from '../data/region-scope-views';
66
+ import { checkPageScopes, scopeIssueDiagnostics } from '../../shared/region-scope-decl';
67
+ import { formatGenerationError } from '../../shared/generation-error';
68
+ import type { SomaAuthOption } from '../data/role-gate';
69
+ import { isLocaleBundle, type SomaLocaleBundle } from '../../shared/types/locale.types';
70
+ import { coreDiagnostic } from '../../shared/core-diagnostic-codes';
71
+ import { SOMA_COMPONENT_ATTR, SOMA_CORE_HOOK_ATTRIBUTES, SOMA_FRAGMENT_ATTR, SOMA_HOST_ATTR, SOMA_ID_ATTR, SOMA_OPAQUE_ATTRIBUTE_REGISTRY, SOMA_REPEAT_TEMPLATE_ATTR, SOMA_ROLE_ATTR, SOMA_SLOT_ATTR } from '../../shared/hook-attributes';
72
+
73
+ import {
74
+ createRuntimeObserver,
75
+ NOOP_OBSERVATION_CHANNEL,
76
+ type SomaRuntimeObserver,
77
+ } from '../observability/runtime-observer';
78
+ import type { RuntimeObservation } from '../../shared/types/observation.types';
44
79
  import type { SomaComponentDefinition } from '../component/component-definition.types';
45
80
  import { SomaComponentRegistry } from '../component/component-registry';
46
- import { SomaComponentManager, warnSubscriptionsWithoutComponents } from '../component/component-manager';
81
+ import { SomaComponentManager } from '../component/component-manager';
82
+ import { applyDegradedRegions } from '../component/region-unavailable';
83
+ import { SOMA_ANCHOR_SITE_PAGE, anchorDuplicateMessage, anchorSiteOfFragment } from '../../shared/anchor-space';
84
+ import { SomaLocaleOnlyPageRoot } from '../base/SomaLocaleOnlyPageRoot';
47
85
  import {
48
86
  validateComponentDefaults,
49
87
  type SomaComponentDefaults,
50
88
  } from '../component/component-defaults';
51
- import { validateStyleFeatures } from '../component/style-features';
89
+ import { validateStyleFeatures } from '../styles/style-features';
52
90
  import { SomaPipeRegistry, type SomaPipeFn } from '../pipes/pipe-registry';
53
- import { applyTheme, type SomaThemeInput } from '../theme/theme-engine';
54
- import { validateThemeComponentTokens } from '../component/theme-component-tokens';
55
91
  import {
56
92
  installSomaErrorReporter,
57
93
  type SomaErrorEvent,
@@ -60,22 +96,44 @@ import {
60
96
  } from '../observability/error-reporter';
61
97
 
62
98
  // ─── 类型定义 ──────────────────────────────────────────
99
+ import { createFormatter, type SomaFormatter } from '../format';
100
+ import { parseFormatAppConfig, type SomaFormatDefaults } from '../data/format-config';
101
+ import { registerComponentPackLocales, validatePackLocales, type PackWithLocales } from '../infra/i18n/pack-locales';
63
102
  import { assertRuntimeArtifact } from '../../shared/component-tree-artifact';
103
+ import { checkArtifactRuntimeCompatibility, supplyFromDefinitions } from '../../shared/artifact-compatibility';
64
104
  import { SomaComponentTreeError } from '../../shared/component-tree-errors';
65
105
  import type { ComponentTreeRuntimeEnvelope } from '../../shared/types/component-tree-artifact.types';
106
+ import { createUrlStatePort } from '../url-state/url-state';
107
+ import { bindStateQuery } from '../url-state/state-query-binding';
108
+ import { queryBindingsFromContract } from '../../shared/page-envelope-runtime';
109
+ import type { SomaEnvelopeQuerySpec } from '../../shared/types/page-envelope.types';
110
+ import type { SomaNavView } from '../../shared/types/nav.types';
111
+ import { createNavStore } from '../runtime/nav-port';
112
+ import { installMotionHook } from '../a11y/motion-hook';
113
+ import { createNavHistory, type SomaNavHistory } from '../runtime/nav-history';
114
+ import type { SomaNavHistoryPort } from '../../shared/types/nav-context.types';
115
+ import { parseA11yAppConfig } from '../a11y/a11y-config';
116
+ import {
117
+ createAsyncCheckService,
118
+ findUnregisteredAsyncChecks,
119
+ unregisteredAsyncCheckError,
120
+ type SomaAsyncCheckTable,
121
+ type SomaValidationService,
122
+ } from '../validation/async-check-registry';
66
123
 
67
124
  export interface SomaPageAssets extends ComponentTreeRuntimeEnvelope {
68
125
  html: string;
69
126
  includes?: Record<string, string>;
70
- DomainClass: new () => SomaPageRoot;
127
+ /**
128
+ * 页面根类。可省(06e AD-CORE-19):无业务类的页面缺省实例化 `SomaLocaleOnlyPageRoot`(空页面根,只承载
129
+ * `_locale` / `_config` / `_services` / `data`)。
130
+ */
131
+ DomainClass?: new () => SharedPageRoot;
71
132
 
72
133
  // ── 编译后的运行时资产(源声明不得直接进入浏览器) ──
73
134
  uiYaml?: string;
74
- /** 仅供构建/测试入口携带的外置声明块;mount 本身不读取。 */
75
- declarationBlocks?: ReadonlyMap<string, string>;
76
135
  eventYaml?: string;
77
136
  styleYaml?: string;
78
- localeYaml?: string;
79
137
  appConfigYaml?: string;
80
138
  /**
81
139
  * 从统一声明编译出的数据对象运行时资产。
@@ -91,14 +149,40 @@ export interface SomaPageAssets extends ComponentTreeRuntimeEnvelope {
91
149
  triggerConfig?: PropertyTrigger[];
92
150
  timerConfig?: ParsedTimer[];
93
151
  styleConfig?: StyleConfig;
94
- locale?: Record<string, unknown>;
152
+ /**
153
+ * 多语言词表(KC2,`format: 'soma.locale-bundle'`);迁移期仍认单字典(无 `format` 视为应用缺省语言词表)。
154
+ * 运行期按当前显示语言渲染文案,切换不重编、不换产物(`setLocale`)。
155
+ * 与注入载荷同名同形:可给词表文本(YAML 字符串,运行期解析)或已解析对象。
156
+ */
157
+ locale?: string | SomaLocaleBundle | Record<string, unknown>;
158
+ /** 应用配置;不携带 `theme` 段(编译器消费后剥离),core 不按具名段访问(KI-6) */
95
159
  appConfig?: unknown;
160
+ /**
161
+ * 页面编译样式片(KC2 `compiledStyles`,KC12 序 2):core 按数组顺序逐片注入,逐字节、不改写、不排序。
162
+ * 作用域与层序是产出方义务;首片为层序声明。
163
+ */
164
+ compiledStyles?: readonly SomaCompiledStyle[];
165
+ /**
166
+ * 暗色首帧载体(KC2 `colorScheme`):只由服务端页面外壳读取并输出 `<meta name="color-scheme">`,
167
+ * 浏览器端 core 不写任何 DOM / 样式属性(KI-2)。
168
+ */
169
+ colorScheme?: 'light dark' | 'light' | 'dark';
96
170
  /** 数据对象层声明的预编译形态(构建阶段已解析校验,优先于 dataYaml) */
97
171
  dataConfig?: SomaDataConfig;
98
172
 
99
173
  /** Full router path including query string (e.g. /items/detail?id=1) */
100
174
  routerPath?: string;
101
175
 
176
+ // ── 页面信封的运行期上下文(E3 / E4;由取页响应带来,缺省则页面没有这些东西) ──
177
+ /** 地址参数(按信封 `params` 类型还原,`int` 是 number):装为只读的 `page.params`;空对象不装 */
178
+ pageParams?: Readonly<Record<string, string | number>>;
179
+ /** 信封 `query` 契约还原出的初始值:装为 `page.query`(没有契约不装) */
180
+ pageQuery?: Readonly<Record<string, string | number | boolean | null>>;
181
+ /** 信封 `query` 契约:`page.query.<名>` ⇄ 地址栏双向同步,与 `state.query` 合并 */
182
+ queryContract?: Readonly<Record<string, SomaEnvelopeQuerySpec>>;
183
+ /** 随页下发的导航目录(已按请求身份裁剪):换入 `services.nav` */
184
+ nav?: SomaNavView;
185
+
102
186
  /**
103
187
  * 组件运行时定义(组件体系模块 7,可选)。
104
188
  * 键为契约名;页面 HTML 中 data-soma-component 引用的组件必须在此提供。
@@ -107,21 +191,92 @@ export interface SomaPageAssets extends ComponentTreeRuntimeEnvelope {
107
191
  components?: Record<string, SomaComponentDefinition>;
108
192
  }
109
193
 
194
+ const COMPONENT_ATTR_RE = /data-soma-component\s*=\s*\\?["']([A-Za-z][A-Za-z0-9_-]*)\\?["']/g;
195
+
196
+ /** 页面标注:`data-soma-needs="A B"` 显式点名本页要用的按需组件(组件模板里的可选行模板据此补载) */
197
+ const COMPONENT_NEEDS_RE = /data-soma-needs\s*=\s*\\?["']([A-Za-z0-9_ -]+)\\?["']/g;
198
+ /** 可选行模板:带 `data-soma-on-demand` 的 `<template>` 里的组件引用不参与定义模板的补载闭包 */
199
+ const ON_DEMAND_TEMPLATE_RE = /<template\b[^>]*\bdata-soma-on-demand\b[^>]*>[\s\S]*?<\/template>/g;
200
+
201
+ /** 文本里 `data-soma-component="名"` 引用到的组件名,加上 `data-soma-needs` 点名的组件 */
202
+ function componentNamesIn(text: unknown): string[] {
203
+ if (typeof text !== 'string' || text === '') return [];
204
+ const names = [...text.matchAll(COMPONENT_ATTR_RE)].map((m) => m[1]!);
205
+ for (const m of text.matchAll(COMPONENT_NEEDS_RE)) names.push(...m[1]!.split(/\s+/).filter((n) => n !== ''));
206
+ return names;
207
+ }
208
+
209
+ /** 组件定义模板引用到的组件名:跳过可选行模板,由页面的 `data-soma-needs` 触发 */
210
+ function componentNamesInDefinition(templateHtml: unknown): string[] {
211
+ if (typeof templateHtml !== 'string') return [];
212
+ return componentNamesIn(templateHtml.replace(ON_DEMAND_TEMPLATE_RE, ''));
213
+ }
214
+
215
+ /** 一份页面资产引用到的组件名:HTML、声明(源文本或已解析配置)、产物 componentRefs */
216
+ function referencedComponentNames(assets: SomaPageAssets): string[] {
217
+ const names = new Set<string>(componentNamesIn(assets.html));
218
+ for (const text of [assets.uiYaml, assets.eventYaml, ...Object.values(assets.includes ?? {})]) for (const n of componentNamesIn(text)) names.add(n);
219
+ if (assets.uiConfig !== undefined) {
220
+ try { for (const n of componentNamesIn(JSON.stringify(assets.uiConfig))) names.add(n); } catch { /* 含环的配置不扫 */ }
221
+ }
222
+ for (const ref of assets.artifact?.componentRefs ?? []) names.add(ref.name);
223
+ return [...names];
224
+ }
225
+
226
+ /**
227
+ * 按页面引用补载按需组件,返回补齐后的组件表(不改入参):命中 `lazy` 且 `hostComponents` / 页面级组件里没有的才加载,
228
+ * 加载出的模板里引用的组件继续扫描到闭包补齐。给不经 `SomaBootstrap.mount` 就要先做装配期校验的入口(如生成页预览)用;
229
+ * 与 `SomaBootstrap` 内部补载规则一致(契约名须与登记名一致)。
230
+ */
231
+ export async function loadLazyComponentsFor(
232
+ assets: SomaPageAssets,
233
+ hostComponents: Record<string, SomaComponentDefinition>,
234
+ lazy: Readonly<Record<string, () => Promise<SomaComponentDefinition>>> | undefined,
235
+ ): Promise<Record<string, SomaComponentDefinition>> {
236
+ const table: Record<string, SomaComponentDefinition> = { ...hostComponents };
237
+ if (lazy === undefined || Object.keys(lazy).length === 0) return table;
238
+ const pageComponents = assets.components ?? {};
239
+ const seen = new Set<string>();
240
+ const queue = referencedComponentNames(assets);
241
+ while (queue.length > 0) {
242
+ const name = queue.pop()!;
243
+ if (seen.has(name)) continue;
244
+ seen.add(name);
245
+ if (Object.hasOwn(table, name) || Object.hasOwn(pageComponents, name)) continue;
246
+ const make = Object.hasOwn(lazy, name) ? lazy[name] : undefined;
247
+ if (make === undefined) continue;
248
+ const def = await make();
249
+ if (def?.contract?.name !== name) {
250
+ throw new Error(`[soma-core][组件] 按需组件 "${name}" 的工厂返回的定义契约名为 "${String(def?.contract?.name)}",与登记名不一致`);
251
+ }
252
+ table[name] = def;
253
+ queue.push(...componentNamesInDefinition(def.templateHtml));
254
+ }
255
+ return table;
256
+ }
257
+
110
258
  /** Validate before mutating the current DOM or instantiating any business Domain. */
111
259
  export function assertPageRuntimeAssets(assets: SomaPageAssets, hostComponents: Record<string, SomaComponentDefinition>): void {
112
260
  assertRuntimeArtifact(assets);
113
261
  if (assets.uiYaml && isSomaDeclarationSource(assets.uiYaml)) {
114
- throw new Error('[soma-core][引擎] 收到未编译的 SOMA DSL 源声明,请先在服务端编译。');
262
+ throw new Error('[SomaBootstrap] 收到未编译的 SOMA DSL 源声明,请先在服务端编译。');
115
263
  }
116
264
  if (assets.sourceMarkup === 'component-tree') {
117
- for (const ref of assets.artifact!.componentRefs) {
118
- const definition = assets.components?.[ref.name] ?? hostComponents[ref.name];
119
- if (!definition || definition.contractDigest !== ref.contractDigest || definition.structureDigest !== ref.structureDigest) {
120
- throw new SomaComponentTreeError({
121
- code: 'CT-ARTIFACT-CAPABILITY', phase: 'artifact', sourceId: '<runtime-assets>', nodePath: 'componentRefs',
122
- fixHint: '客户端组件供货缺失或契约/结构摘要与资产不一致;请同步部署服务端与客户端供货。',
123
- });
124
- }
265
+ // 组件供货摘要比对:与服务端回滚 / 路径访问是同一个判据函数(2.16a,KI-27 / KI-28)
266
+ const supply = supplyFromDefinitions({ ...hostComponents, ...(assets.components ?? {}) });
267
+ const verdict = checkArtifactRuntimeCompatibility({
268
+ sourceMarkup: 'component-tree',
269
+ ...(assets.artifact!.format !== undefined ? { format: assets.artifact!.format } : {}),
270
+ ...(assets.artifact!.schemaVersion !== undefined ? { schemaVersion: assets.artifact!.schemaVersion } : {}),
271
+ ...(assets.artifact!.grammarVersion !== undefined ? { grammarVersion: assets.artifact!.grammarVersion } : {}),
272
+ capabilities: assets.artifact!.capabilities,
273
+ componentRefs: assets.artifact!.componentRefs,
274
+ }, supply);
275
+ if (!verdict.compatible) {
276
+ throw new SomaComponentTreeError({
277
+ code: verdict.code, phase: 'artifact', sourceId: '<runtime-assets>', nodePath: 'componentRefs',
278
+ fixHint: '客户端组件供货缺失或契约/结构摘要与资产不一致;请同步部署服务端与客户端供货。',
279
+ });
125
280
  }
126
281
  const objectConfig = assets.uiConfig !== undefined && assets.eventConfig !== undefined;
127
282
  const yamlConfig = typeof assets.uiYaml === 'string' && assets.uiYaml.trim() !== ''
@@ -156,13 +311,13 @@ export function assertPageRuntimeAssets(assets: SomaPageAssets, hostComponents:
156
311
  });
157
312
  }
158
313
  if (assets.sourceMarkup === 'component-tree') {
159
- if (element.hasAttribute('data-soma-component')) {
160
- const symbol = element.getAttribute('data-soma-id') ?? '';
314
+ if (element.hasAttribute(SOMA_COMPONENT_ATTR)) {
315
+ const symbol = element.getAttribute(SOMA_ID_ATTR) ?? '';
161
316
  if (!symbol || treeHosts.has(symbol)) invalidPlan();
162
317
  treeHosts.set(symbol, element);
163
318
  }
164
- if (element.hasAttribute('data-soma-repeat-template')) {
165
- const symbol = element.getAttribute('data-soma-repeat-template') ?? '';
319
+ if (element.hasAttribute(SOMA_REPEAT_TEMPLATE_ATTR)) {
320
+ const symbol = element.getAttribute(SOMA_REPEAT_TEMPLATE_ATTR) ?? '';
166
321
  if (!symbol || !isHtmlTemplateElement(element) || treeTemplates.has(symbol)) invalidPlan();
167
322
  treeTemplates.set(symbol, element);
168
323
  }
@@ -175,10 +330,10 @@ export function assertPageRuntimeAssets(assets: SomaPageAssets, hostComponents:
175
330
  }
176
331
  if (assets.sourceMarkup === 'component-tree') {
177
332
  if (treeHosts.size !== assets.artifact!.structurePlan.length || treeTemplates.size !== assets.artifact!.repeatPlans.length
178
- || probe.content.children.length !== 1 || !probe.content.firstElementChild?.hasAttribute('data-soma-host')) invalidPlan();
333
+ || probe.content.children.length !== 1 || !probe.content.firstElementChild?.hasAttribute(SOMA_HOST_ATTR)) invalidPlan();
179
334
  for (const plan of assets.artifact!.structurePlan) {
180
335
  const host = treeHosts.get(plan.instanceSymbol);
181
- if (!host || host.getAttribute('data-soma-component') !== plan.componentName
336
+ if (!host || host.getAttribute(SOMA_COMPONENT_ATTR) !== plan.componentName
182
337
  || host.localName !== plan.hostTag || host.namespaceURI !== 'http://www.w3.org/1999/xhtml') invalidPlan();
183
338
  }
184
339
  const repeats = assets.artifact!.repeatPlans;
@@ -186,7 +341,7 @@ export function assertPageRuntimeAssets(assets: SomaPageAssets, hostComponents:
186
341
  let parent: Node | null = element.parentNode;
187
342
  while (parent) {
188
343
  const template = templateParents.get(parent);
189
- if (template?.hasAttribute('data-soma-repeat-template')) return template.getAttribute('data-soma-repeat-template')!;
344
+ if (template?.hasAttribute(SOMA_REPEAT_TEMPLATE_ATTR)) return template.getAttribute(SOMA_REPEAT_TEMPLATE_ATTR)!;
190
345
  parent = template ? template.parentNode : parent.parentNode;
191
346
  }
192
347
  return undefined;
@@ -199,8 +354,8 @@ export function assertPageRuntimeAssets(assets: SomaPageAssets, hostComponents:
199
354
  const ownerPlan = assets.artifact!.structurePlan.find(item => item.instanceSymbol === plan.consumerOwner.instanceSymbol);
200
355
  const slotPlan = ownerPlan?.slotPlans.find(item => item.name === plan.consumerOwner.slotName);
201
356
  if (!template || !slot || !owner || slot.parentElement !== owner
202
- || slot.getAttribute('data-soma-slot') !== plan.consumerOwner.slotName
203
- || template.getAttribute('data-soma-role') !== 'item'
357
+ || slot.getAttribute(SOMA_SLOT_ATTR) !== plan.consumerOwner.slotName
358
+ || template.getAttribute(SOMA_ROLE_ATTR) !== 'item'
204
359
  || slot.content.children.length !== 1 || slot.content.firstElementChild !== template
205
360
  || slotPlan?.kind !== 'collection' || slotPlan.layoutRootKey !== plan.consumerOwner.layoutRootKey
206
361
  || slotPlan.rowContainer !== plan.consumerOwner.rowContainer
@@ -224,88 +379,105 @@ function isHtmlTemplateElement(element: Element): element is HTMLTemplateElement
224
379
  && 'content' in element && (element as HTMLTemplateElement).content?.nodeType === 11;
225
380
  }
226
381
 
227
- /** 浏览器只用于拒绝源声明;不存在旧/新两套执行分派。 */
382
+ /**
383
+ * 浏览器只用于拒绝源声明;不存在旧/新两套执行分派。
384
+ * 源声明的形状是「第一条有效行(跳过空行与注释)就是 `{{` 开关行」(与块容器 `stripSwitch` 同一判据)。
385
+ * 只看第一条有效行:编译产物的 YAML 折叠长字符串(`>-`)后,内部可能恰有一行缩进的 `{{`(文案键表达式的开头),那不是源声明。
386
+ */
228
387
  function isSomaDeclarationSource(value: string): boolean {
229
- return value.split('\n').some((line) => {
388
+ for (const line of value.split('\n')) {
230
389
  const text = line.trim();
231
- if (!text || text.startsWith('#')) return false;
390
+ if (!text || text.startsWith('#')) continue;
232
391
  return text === '{{';
233
- });
392
+ }
393
+ return false;
234
394
  }
235
395
 
236
396
  // ─────────────────────────────────────────────────────────────────────
237
- // OOUI 演绎产物的注入面(REQ-014 最后一公里)
397
+ // 编译产物 HTML 片段的注入面(载体 `fragments.regions`)
238
398
  //
239
399
  // 这三个常量与两个函数是**运行时那道结构闸门**的全部判据。它们刻意做成模块级
240
400
  // 纯函数:闸门必须能对着"外面拿来的一份 html"单独跑,否则"引擎不产生内联事件
241
401
  // 处理器"这句话在运行时这一侧就只是一句没人验证过的话
242
- // (构建期那一侧是 `core/build/ooui/artifact/emit-html.ts` 的 `verifyArtifactHtml`)。
402
+ // (构建期那一侧是方言编译器自己的产物校验)。
243
403
  // ─────────────────────────────────────────────────────────────────────
244
404
 
245
405
  /**
246
- * 演绎区域已注入的标记。值是这份 html 的**内容指纹**,不是布尔。
406
+ * 片段已注入的标记(`data-soma-fragment`)。值是这份 html 的**内容指纹**,不是布尔。
247
407
  *
248
408
  * 布尔标记的坏法:同一个锚点换了一份产物会被当成"已经注入过了"而跳过,
249
409
  * 页面继续显示上一版 DOM——渲染正常、内容是旧的、控制台一行都没有。
250
410
  * 与产物侧 `css_key` 用内容哈希是同一条理由,只是这一侧的作用域是单个锚点。
251
411
  */
252
- export const SOMA_OOUI_REGION_ATTR = 'data-soma-ooui';
412
+ export const SOMA_FRAGMENT_HOST_ATTR = SOMA_FRAGMENT_ATTR;
253
413
 
254
414
  /**
255
- * 产物 DOM 的标签允许集。**这就是 `emitRegionHtml` 今天产出的全集**
256
- * (区域外壳恒为 `div`,根构件是组件时 `div`、是纯文本节点时 `span`)。
415
+ * 产物 DOM 的标签允许集。**这就是编译产物今天产出的全集**:区域与
416
+ * 实例用 `div`,带子组件内容的 slot 出口由 `template[data-soma-slot]` 惰性承载。
257
417
  *
258
- * 为什么是允许集不是禁用集:产物只有两种标签,禁用集只挡得住今天想得到的那几样,
259
- * 而允许集把"想不到的那些"一并挡住。代价是发射器加新标签时这里会红——
260
- * 那正是要的:红在写下的那天,而不是在某份被改过的资产送进 innerHTML 的那天。
418
+ * 为什么是允许集不是禁用集:允许集把"想不到的那些"一并挡住。代价是编译产物加新标签时
419
+ * 这里会红——红在写下的那天,而不是在某份被改过的资产送进 innerHTML 的那天。
261
420
  */
262
- export const SOMA_OOUI_ALLOWED_TAGS: ReadonlySet<string> = new Set(['DIV', 'SPAN']);
421
+ export const SOMA_FRAGMENT_ALLOWED_TAGS: ReadonlySet<string> = new Set(['DIV', 'TEMPLATE']);
263
422
 
264
423
  /**
265
424
  * 产物 DOM 的属性允许集(HTML 解析器会把属性名小写化,所以只写小写)。
266
425
  *
267
- * `on*`、`src`/`href` 这类属性一个都不在里面——引擎从不产出它们
268
- * (事件走 `eventConfig`,不进 DOM 属性;架构 §24.1),所以它们出现在这里
269
- * 只有一个含义:这份产物不是编译器产的。
426
+ * 由 `shared/hook-attributes` 登记表派生,不手抄:登记表里标 `inArtifact` 的钩子属性,
427
+ * 加不透明属性登记(`data-soma-instance`),再加两个通用属性 `class`、`hidden`。
428
+ * `on*`、`src`/`href`、`style` 等都不在里面——事件走 event 配置,样式走 class 与页面样式片,不进内联属性。
429
+ * 旧钩子名(`data-soma-when` / `data-soma-node` 等)不在其内,按闭集外属性拒收。
270
430
  */
271
- export const SOMA_OOUI_ALLOWED_ATTRS: ReadonlySet<string> = new Set([
272
- 'class', 'data-soma-node', 'data-soma-id', 'data-soma-component',
431
+ export const SOMA_FRAGMENT_ALLOWED_ATTRS: ReadonlySet<string> = new Set([
432
+ 'class',
433
+ 'hidden',
434
+ ...SOMA_OPAQUE_ATTRIBUTE_REGISTRY.attributes,
435
+ ...SOMA_CORE_HOOK_ATTRIBUTES.filter((entry) => 'inArtifact' in entry && entry.inArtifact === true).map((entry) => entry.name),
273
436
  ]);
274
437
 
275
438
  /**
276
439
  * 结构闸门:返回 `null` 表示这份 DOM 就是产物该有的样子,否则返回违规描述。
277
440
  *
278
441
  * 三条判据:
279
- * ① 顶层恰好一个元素(`emitRegionHtml` 恒产出单个区域外壳)。
280
- * 不查这条的话,一份"外壳 + 一段裸文本"的产物会被照单全收,
281
- * 而多出来的那段文本在页面上只是多了一行字。
282
- * ② 每个元素的标签在允许集内;
442
+ * ① 顶层恰好一个元素(编译产物恒为单个区域外壳);
443
+ * ② 每个元素(包括 `template.content` 中的元素)的标签在允许集内;
283
444
  * ③ 每个属性名在允许集内。
284
445
  */
285
- export function findOouiDomOffence(fragment: DocumentFragment): string | null {
446
+ export function findFragmentDomOffence(fragment: DocumentFragment): string | null {
286
447
  const roots = fragment.children;
287
448
  if (roots.length !== 1) {
288
449
  return `顶层元素有 ${roots.length} 个,产物恒为单个区域外壳`;
289
450
  }
290
451
  for (const node of Array.from(fragment.childNodes)) {
291
- // 元素之外的顶层节点(裸文本、注释)一律拒收。发射器只产出一个外壳元素,
452
+ // 元素之外的顶层节点(裸文本、注释)一律拒收。编译产物只有一个外壳元素,
292
453
  // 多出来的那一段在页面上只是"莫名其妙多了一行字"——没人会把它报成 bug。
293
454
  // 纯空白放行:YAML 的块标量可能带一个尾换行,那不是内容。
294
455
  if (node.nodeType !== 1 && (node.textContent ?? '').trim() !== '') {
295
456
  return `顶层混有元素以外的节点(nodeType ${node.nodeType})`;
296
457
  }
297
458
  }
298
- for (const element of Array.from(fragment.querySelectorAll('*'))) {
299
- if (!SOMA_OOUI_ALLOWED_TAGS.has(element.tagName)) {
300
- return `标签 <${element.tagName.toLowerCase()}>`;
301
- }
302
- for (const attribute of Array.from(element.attributes)) {
303
- if (!SOMA_OOUI_ALLOWED_ATTRS.has(attribute.name)) {
459
+ // querySelectorAll('*') 不进入 HTMLTemplateElement.content;slot 出口虽惰性,
460
+ // 内容仍会被组件投影搬入活动 DOM,因此必须沿同一棵发射树递归执行完整允许集。
461
+ const inspect = (parent: ParentNode): string | null => {
462
+ for (const node of Array.from(parent.childNodes)) {
463
+ if (node.nodeType !== 1) continue;
464
+ const element = node as Element;
465
+ if (!SOMA_FRAGMENT_ALLOWED_TAGS.has(element.tagName)) {
466
+ return `标签 <${element.tagName.toLowerCase()}>`;
467
+ }
468
+ for (const attribute of Array.from(element.attributes)) {
469
+ if (SOMA_FRAGMENT_ALLOWED_ATTRS.has(attribute.name)) continue;
304
470
  return `属性 ${attribute.name}`;
305
471
  }
472
+ const children = element.tagName === 'TEMPLATE'
473
+ ? (element as HTMLTemplateElement).content
474
+ : element;
475
+ const offence = inspect(children);
476
+ if (offence !== null) return offence;
306
477
  }
307
- }
308
- return null;
478
+ return null;
479
+ };
480
+ return inspect(fragment);
309
481
  }
310
482
 
311
483
  /**
@@ -316,7 +488,7 @@ export function findOouiDomOffence(fragment: DocumentFragment): string | null {
316
488
  * 而 `crypto.subtle.digest` 是异步的,为一次同步的"变没变"判断引入异步
317
489
  * 会把注入挪到组件展开之后(见 mount 的 2.4 与 2.5 的顺序)。
318
490
  */
319
- export function oouiHtmlFingerprint(html: string): string {
491
+ export function fragmentHtmlFingerprint(html: string): string {
320
492
  let hash = 0x811c9dc5;
321
493
  for (let index = 0; index < html.length; index += 1) {
322
494
  hash ^= html.charCodeAt(index);
@@ -325,6 +497,8 @@ export function oouiHtmlFingerprint(html: string): string {
325
497
  return (hash >>> 0).toString(16).padStart(8, '0');
326
498
  }
327
499
 
500
+ /** @deprecated 改用 fragmentHtmlFingerprint(同一算法;本别名保留一个发布周期) */
501
+
328
502
  /**
329
503
  * 错误采集接线声明(可观测性,默认关闭)。
330
504
  *
@@ -358,6 +532,14 @@ export interface SomaBootstrapOptions {
358
532
  * 对该 Host 的所有页面生效;页面资产 components 同名时覆盖 Host 级定义。
359
533
  */
360
534
  components?: Record<string, SomaComponentDefinition>;
535
+ /**
536
+ * Host 级按需组件(通用的异步组件定义能力):组件名 → 返回定义的异步工厂。
537
+ * 页面挂载 / 热替换前,core 只扫描本页引用到的组件名(HTML、声明里的 `data-soma-component`、产物 componentRefs),
538
+ * 命中本表且 `components` 里没有的才调用工厂(同名只调一次,结果缓存);加载出的定义模板里再引用的组件名同样递归补载。
539
+ * 工厂返回定义的契约名必须等于登记名,否则抛错。运行期才由代码动态创建的组件不在扫描范围,须放进 `components` 常驻。
540
+ * 与 `components` 同名时以 `components` 为准。
541
+ */
542
+ lazyComponents?: Readonly<Record<string, () => Promise<SomaComponentDefinition>>>;
361
543
  /**
362
544
  * Host 级默认 props(REQ-009 M-2):组件名 → { prop: 默认值 }。
363
545
  * 「本站所有表格都要 size: sm」这类站点级口径的落点,
@@ -378,19 +560,46 @@ export interface SomaBootstrapOptions {
378
560
  * 对不上就抛。留到运行期才发现的话,那是用户点了按钮之后什么都没发生。
379
561
  */
380
562
  actions?: Record<string, (payload: Record<string, unknown>) => Promise<unknown> | unknown>;
563
+ /**
564
+ * 异步字段检查器注册表(C6-c):`{ 检查器名: 检查器 }`,应用经 `browserMount().asyncChecks` 交入。
565
+ * 字段规则 `rules[].async` 写的就是这里的名字;装配期对着这张表核对页面引用,缺登记抛 `CORE-ASYNC-CHECK-UNREGISTERED`,
566
+ * 表形状非法抛 `CORE-ASYNC-CHECK-TABLE`。组件在契约 `services` 声明 `validation`,经 `ctx.services.validation.asyncCheck(name)` 取用。
567
+ */
568
+ asyncChecks?: SomaAsyncCheckTable;
381
569
  /**
382
570
  * Host 自定义格式化管道(模块 7 U4):{ 管道名: 纯函数 },与内置管道合并。
383
571
  * 内置:money / tpl / date / percent / plural。
384
572
  */
385
573
  pipes?: Record<string, SomaPipeFn>;
386
574
  /**
387
- * 阶梯词汇注册位(F-09 / 契约 C5),与组件注册同点:
388
- * `adaptiveVocabulary: createSomaUiAdaptiveVocabulary()`。
389
- *
390
- * core **不内置任何级语义**——语法归语言、词汇归组件。不注册而页面声明了
391
- * `adaptive.ladder` 时按"词汇未知"快速失败,而不是静默忽略那些级。
575
+ * 角色集来源(KC13 `auth`):Host 经 soma-ui 入口取自身份上下文。给出时角色判定(动作可用性、`permission:`
576
+ * 管道、命令动作)一律走默认拒绝的角色门——读不到 / 非字符串数组即无角色。请求不附带任何 core 生成的身份字段。
577
+ */
578
+ auth?: SomaAuthOption;
579
+ /**
580
+ * 当前用户身份来源(K8):返回 `{ id, team, … }` 快照,每次现读。`services.identity` 与查询里的 `$user.id` / `$user.team`、
581
+ * 偏好的「用户」维度都取自它;core 不从 token 反解身份。不给 = 什么字段都不提供。
582
+ */
583
+ identity?: SomaIdentityProvider;
584
+ /**
585
+ * 时间源(C19 `SomaClockPort`,C-int 接线):解析器的 `now`(生命周期派生)与无偏移日期时间的时区都取它。
586
+ * 不给 = 系统时间 + 应用配置 `format.time_zone`(缺省 UTC)。
392
587
  */
393
- adaptiveVocabulary?: SomaAdaptiveVocabulary;
588
+ clock?: SomaClockPort;
589
+ /** 宿主路由端口(C48,K53):`services.navHistory` 的跳转经它;不给退化为浏览器历史 */
590
+ navHistory?: SomaNavHistoryPort;
591
+ /**
592
+ * 快捷键注册中心(C56 K81):bootstrap 持有的唯一一份,`services.shortcuts` 直通;不给则自建(modKey 取 `shortcutsModKey`,序列间隔读 design)。
593
+ */
594
+ shortcuts?: SomaShortcutRegistry;
595
+ /** 本平台 mod 对应的物理修饰键(mac 传 meta);自建注册中心时用 */
596
+ shortcutsModKey?: 'ctrl' | 'meta';
597
+ /** UI 体系注入的渲染端口(notify 等);缺省全部无头(只记录),soma-ui / soma-lite 入口各给一份 */
598
+ renderPorts?: SomaRenderPorts;
599
+ /** 引擎端口的适配器替换(样式 / 行为 / 表格 / 图表 / 拖放等);未给的槽位用各端口缺省适配器,装配由 UI 体系入口完成 */
600
+ engines?: Partial<SomaEngineAdapters>;
601
+ /** 多语言:初始显示语言与内置受控词表覆盖(KC13 / 2.2a);缺省取词表的应用缺省语言与 core 内置词表 */
602
+ locale?: SomaLocaleOptions;
394
603
  /** Render-engine middleware chain (opt-in) */
395
604
  renderMiddleware?: SomaMiddlewareChain<SomaRenderMiddlewareContext>;
396
605
  /**
@@ -403,7 +612,25 @@ export interface SomaBootstrapOptions {
403
612
  * 库不该擅自劫持 window 的错误钩子,是否采集由 Host 显式决定。
404
613
  */
405
614
  errorReporting?: SomaBootstrapErrorReporting;
406
- // 主题不在此:无 theme / themeEngine。声明走 appConfig.theme,函数走 applyTheme(引擎内建)。
615
+ /**
616
+ * 运行期观测(M03,KC13 / KC18):缺省关闭。显式 `true` 才采集并在浏览器挂 `window.__somaObserve`;
617
+ * 关闭时 `window.__somaObserve === undefined`,组件的 `services.observation` 为空操作通道。
618
+ * 采集只读,不改 DOM(KI-22)。
619
+ */
620
+ observe?: boolean;
621
+ // 主题不在此:core 不认识主题(无 theme / themeEngine / appConfig.theme);主题由编译期进 compiledStyles。
622
+ }
623
+
624
+ export interface SomaLocaleOptions {
625
+ /** 初始显示语言(Host 取应用 `app.locale` 给出);缺省 = 词表的应用缺省语言 */
626
+ readonly initial?: string;
627
+ /** Host 覆盖 / 补语言的内置受控词表;产物中同键词条优先 */
628
+ readonly builtin?: SomaLocaleBundle;
629
+ /**
630
+ * 组件包词条(S5,K1 ②):`composeComponentPacks(...).locales`(或任何 `{ name, locales }` 列表),
631
+ * 构造期经 `registerComponentPackLocales` 按序登记进文案目录——后面的包优先;优先级 应用词表 > 包词条 > 内置受控词表。
632
+ */
633
+ readonly packs?: readonly PackWithLocales[];
407
634
  }
408
635
 
409
636
  /**
@@ -420,7 +647,7 @@ export interface ParsedRuntimeAssets {
420
647
  triggers: PropertyTrigger[];
421
648
  timers: ParsedTimer[];
422
649
  styleConfig?: StyleConfig;
423
- locale: Record<string, unknown>;
650
+ locale: SomaLocaleBundle | Record<string, unknown>;
424
651
  appConfig: unknown;
425
652
  }
426
653
 
@@ -435,6 +662,8 @@ export class SomaBootstrap {
435
662
  private readonly renderMiddleware: SomaMiddlewareChain<SomaRenderMiddlewareContext>;
436
663
  private readonly eventMiddleware: SomaMiddlewareChain<SomaEventMiddlewareContext>;
437
664
  private routerUnsubscribe: (() => void) | null = null;
665
+ /** WP3b-C 页面钩子(`state.query` 绑定、`data-soma-motion`)的卸载函数;每次 buildRuntime 重装 */
666
+ private pageHookDisposers: Array<() => void> = [];
438
667
 
439
668
  private renderEngine: SomaRenderEngine | null = null;
440
669
  private eventEngine: SomaEventEngine | null = null;
@@ -449,24 +678,58 @@ export class SomaBootstrap {
449
678
  private domainInstance: SomaPageRoot | null = null;
450
679
  private componentManager: SomaComponentManager | null = null;
451
680
  private hostComponents: Record<string, SomaComponentDefinition> = {};
681
+ private lazyComponents: Readonly<Record<string, () => Promise<SomaComponentDefinition>>> = {};
682
+ private lazyLoading = new Map<string, Promise<SomaComponentDefinition>>();
452
683
  private componentDefaults?: SomaComponentDefaults;
453
684
  /**
454
685
  * 当前页的数据对象解析器(写通道 §8.4 的真身)。
455
686
  * 它在 loadDataObjects 里被换掉——每次重取都是一个新解析器。
456
687
  */
457
688
  private dataResolver: SomaDataObjectResolver | null = null;
689
+ private dataLoadEpoch = 0;
690
+ private dataOwnerEpoch = 0;
691
+ /** 写入结果存储:与 bootstrap 同寿(字段错误、冲突、乐观叠层),`services.data.writeOutcome` 读它 */
692
+ private readonly writeOutcomeStore: SomaWriteOutcomeStore = createWriteOutcomeStore();
693
+ /** 快捷键注册中心(C-r18):唯一一份,`services.shortcuts` 直通 */
694
+ private shortcutsInstance!: SomaShortcutRegistry;
458
695
  private componentStyleNonce?: string | null;
459
696
  private pipeRegistry: SomaPipeRegistry;
460
- /** 阶梯词汇表:Host 级注册,对该 Host 全部页面生效;未注册时恒为 undefined */
461
- private readonly adaptiveVocabulary?: SomaAdaptiveVocabulary;
462
- /** 数据对象层:当前页面的声明(无 *_data.yaml 时为 null,整条路径旁路) */
697
+ /** 多语言文案目录(跨挂载同一个实例,挂载时 reset 再装词表):`services.i18n` 就是它 */
698
+ private readonly localeCatalog: SomaLocaleCatalog;
699
+ private readonly localeOptions: SomaLocaleOptions;
700
+ /** 文案位登记(`{{ t('键') }}`):切换显示语言只重渲这些位 */
701
+ private readonly localeBinder: SomaLocaleTextBinder = createLocaleTextBinder();
702
+ private stopLocaleObserver: (() => void) | null = null;
703
+ /** 用户 / Host 最近一次选定的显示语言:热替换换词表后据此恢复 */
704
+ private preferredLocale: string | undefined;
705
+ /** 最近一次解析出的页面词表(`_locale` 绑定表在切换语言时由它重算) */
706
+ private lastLocale: SomaLocaleBundle | Record<string, unknown> = {};
707
+ /** 角色集来源(KC13 auth) */
708
+ private readonly authOption?: SomaAuthOption;
709
+ /** 身份来源(K8):每个页面根的 services 装配时交给 createDefaultRuntimeServices */
710
+ private readonly identityOption?: SomaIdentityProvider;
711
+ private readonly clockOption?: SomaClockPort;
712
+ private derivedClock: { readonly zone: string | undefined; readonly clock: SomaClockPort } | null = null;
713
+ /** 返回栈(C48):bootstrap 持有的唯一一份,每个页面根的 services.navHistory 都是它 */
714
+ private readonly navHistoryInstance: SomaNavHistory;
715
+ /** 渲染端口(notify 等) */
716
+ private readonly renderPorts?: SomaRenderPorts;
717
+ /** 引擎端口适配器替换(未给的槽位 = 缺省适配器);各端口 `create<X>Port` 经它取替换项 */
718
+ readonly engines: Readonly<Partial<SomaEngineAdapters>>;
719
+ /** 数据对象层:当前页面的声明(无 `data:` 声明时为 null,整条路径旁路) */
463
720
  private dataConfig: SomaDataConfig | null = null;
721
+ /** 数据变更订阅(REQ-019 D-5):随数据声明接线,随数据归属换代断开 */
722
+ private dataSubscriptions: SomaDataSubscriptionHandle | null = null;
723
+ /** 对象级轮询(`poll:`):随数据声明接线,随数据归属换代 / 卸载清理 */
724
+ private dataPolling: SomaDataPollingHandle | null = null;
464
725
  /** 数据对象层:最近一次取数任务(whenDataReady 暴露给测试/调试) */
465
726
  private dataReady: Promise<void> | null = null;
466
727
  /** 数据对象层:字段字典产物(soma-ui 双态映射消费) */
467
728
  private dataDicts: SomaDataDicts = {};
468
729
  private mounted = false;
469
730
  private diagnostics: SomaDiagnostics;
731
+ private readonly observeEnabled: boolean;
732
+ private observer: SomaRuntimeObserver | null = null;
470
733
  private readonly telemetry: SomaTelemetry;
471
734
  private container: HTMLElement | null = null;
472
735
  private assets: SomaPageAssets | null = null;
@@ -476,22 +739,64 @@ export class SomaBootstrap {
476
739
  private errorReporter: SomaErrorReporterHandle | null = null;
477
740
  /** 具名动作注册表(AO-3);构造期定下,运行中不换 */
478
741
  private readonly namedActions: Record<string, (payload: Record<string, unknown>) => Promise<unknown> | unknown>;
742
+ /** 异步字段检查器登记(`services.validation`):构造期复制并验形状,页面生命周期内不变 */
743
+ private readonly validationService: SomaValidationService;
744
+ /**
745
+ * 区域协调作用域 store(`services.region`):每个 bootstrap 一份(实例字段,不是模块单例——
746
+ * 预览 + 主页两个 bootstrap 互不可见);每次挂载 / 热替换 `install` 本页声明,cleanup 清空。
747
+ * 组件手里的旧句柄靠 store 内的代次失效,不会写进新页面的状态。
748
+ */
749
+ private readonly regionScopes = createRegionScopeStore();
750
+ /** 区域协调的视图绑定(切片镜像 + 显隐门)的解除函数;每次建运行时重绑 */
751
+ private regionViewsOff: (() => void) | null = null;
752
+ /** 本页组件注册表(契约 a11y 段交页面校验器做地标检查);无组件时为 null */
753
+ private componentRegistry: SomaComponentRegistry | null = null;
754
+ /** 导航目录仓(`services.nav` 的只读端口由它出;取页 / 客户端导航后 `replace`) */
755
+ private readonly navStore = createNavStore();
756
+ /** 应用配置 `format:` 的解析缓存(按原值身份;热替换换了 appConfig 时重解) */
757
+ private formatDefaultsCache: { readonly raw: unknown; readonly value: SomaFormatDefaults } | null = null;
479
758
 
480
759
  constructor(options: SomaBootstrapOptions = {}) {
481
760
  this.adapter = options.adapter ?? new SomaContainerAdapter();
482
761
  this.scheduler = options.scheduler ?? new SomaScheduler();
483
762
  this.diagnostics = options.diagnostics ?? new SomaDiagnostics();
763
+ this.observeEnabled = options.observe === true;
484
764
  this.telemetry = options.telemetry ?? new SomaTelemetry();
485
- this.adaptiveVocabulary = options.adaptiveVocabulary;
486
- this.assetResolver = options.assetResolver
487
- ?? new SomaAssetResolver(undefined, { adaptiveVocabulary: this.adaptiveVocabulary });
488
- this.hostComponents = options.components ?? {};
765
+ this.authOption = options.auth;
766
+ this.identityOption = options.identity;
767
+ this.clockOption = options.clock;
768
+ this.navHistoryInstance = createNavHistory(options.navHistory ? { port: options.navHistory } : {});
769
+ // 快捷键注册中心(唯一一份,跨页面共享)
770
+ this.shortcutsInstance = options.shortcuts ?? createShortcutRegistry({
771
+ ...(options.shortcutsModKey !== undefined ? { modKey: options.shortcutsModKey } : {}),
772
+ ...(shortcutsDesign()?.sequenceTimeoutMs !== undefined ? { sequenceTimeoutMs: shortcutsDesign()!.sequenceTimeoutMs } : {}),
773
+ });
774
+ this.renderPorts = options.renderPorts;
775
+ this.engines = options.engines ?? {};
776
+ this.localeOptions = options.locale ?? {};
777
+ this.preferredLocale = this.localeOptions.initial;
778
+ this.localeCatalog = new SomaLocaleCatalog({
779
+ builtin: this.localeOptions.builtin ?? SOMA_BUILTIN_LOCALE,
780
+ onMissing: (event) => this.reportLocaleMissing(event),
781
+ });
782
+ // 组件包词条(S5):目录跨挂载同一个实例,构造期登记一次即对本 bootstrap 的全部页面生效;
783
+ // 形状越界(CORE-LOCALE-PACK-*)在这里拒收——没经 composeComponentPacks 的列表也过同一判据
784
+ this.registerPackLocales(this.localeOptions.packs);
785
+ this.assetResolver = options.assetResolver ?? new SomaAssetResolver();
786
+ this.lazyComponents = options.lazyComponents ?? {};
787
+ // 有按需组件时复制一份,补载的定义只进本 bootstrap 的表,不改到调用方手里的对象
788
+ this.hostComponents = options.lazyComponents !== undefined ? { ...(options.components ?? {}) } : (options.components ?? {});
489
789
  this.componentDefaults = options.componentDefaults;
490
790
  this.componentStyleNonce = options.componentStyleNonce ?? null;
491
791
  // 复制一份:注册表在页面生命周期内不该被调用方改到(换掉的后果是
492
792
  // "解析期查过、运行期又不在了",而那条路径只有抛异常一个出口)
493
793
  this.namedActions = { ...(options.actions ?? {}) };
794
+ this.validationService = createAsyncCheckService(options.asyncChecks);
494
795
  this.pipeRegistry = new SomaPipeRegistry(options.pipes);
796
+ // 内置管道(money / date / percent / plural)读当前显示语言走 Intl
797
+ this.pipeRegistry.setLocaleProvider(() => this.localeCatalog.currentLocale());
798
+ // 应用配置 `format.time_zone`(WP3b-A,K1 ①):管道缺省时区;每次求值现读(热替换换配置后立即生效)
799
+ this.pipeRegistry.setFormatDefaults(() => this.formatDefaults());
495
800
  // 复制一份:身份会随 setErrorReportingPage 变,不该改到调用方手里的对象
496
801
  this.errorReporting = options.errorReporting ? { ...options.errorReporting } : null;
497
802
 
@@ -501,6 +806,10 @@ export class SomaBootstrap {
501
806
  }
502
807
 
503
808
  async mount(container: HTMLElement, assets: SomaPageAssets): Promise<void> {
809
+ const ownerEpoch = ++this.dataOwnerEpoch;
810
+ const assertCurrentMount = (): void => {
811
+ if (ownerEpoch !== this.dataOwnerEpoch) throw new DOMException('页面初始化已被卸载或替换', 'AbortError');
812
+ };
504
813
  const mountStarted = globalThis.performance?.now?.() ?? Date.now();
505
814
  // 首屏三段打点:走到这里资产已经在手(宿主若在拉取前 startBootTimings,段一即覆盖网络耗时;
506
815
  // 宿主直接带资产调 mount 时段一趋近 0,属实测事实而非误差)。默认未开启时这两行是两次布尔判断。
@@ -515,11 +824,14 @@ export class SomaBootstrap {
515
824
  this.scheduler.setDiagnostics(this.diagnostics);
516
825
  }
517
826
  this.container = container;
827
+ this.setupObserver(container);
828
+ await this.ensureLazyComponents(assets);
829
+ assertCurrentMount();
518
830
  assertPageRuntimeAssets(assets, this.hostComponents);
519
831
  // 源声明只允许在构建/服务端编译;浏览器 mount 只消费运行时资产。
520
832
  if (assets.uiYaml && isSomaDeclarationSource(assets.uiYaml)) {
521
833
  throw new Error(
522
- '[soma-core][引擎] 收到未编译的 SOMA DSL 源声明。'
834
+ '[SomaBootstrap] 收到未编译的 SOMA DSL 源声明。'
523
835
  + '请先用 compilePageAssets(构建/测试)或 Host 页面编译入口生成运行时资产。',
524
836
  );
525
837
  }
@@ -528,52 +840,65 @@ export class SomaBootstrap {
528
840
  // 1. 解析资产(委托给 AssetResolver)
529
841
  const parsed = this.assetResolver.resolve(this.assets);
530
842
 
843
+ // 1.5 文案目录:词表信封 / 单字典装入,定当前显示语言(挂载选项 locale.initial,缺省取词表的缺省语言)
844
+ this.loadLocale(parsed.locale);
845
+
531
846
  // 2. 挂载 HTML
532
847
  this.adapter.mount(container, this.assets.html, this.assets.includes);
533
848
 
849
+ // 2.1 页面编译样式片(KC12 序 2)与构建期产物样式(序 3 layout、序 4 片段样式):按固定序先于组件分片(序 6)
850
+ // 进入文档,层序才稳定。运行时只搬运,不代算。
851
+ this.installPageStyles(this.assets, parsed.uiConfig);
852
+
534
853
  // 2.4 演绎产物的 DOM 落点(REQ-014 最后一公里)。
535
854
  // **必须在 2.5 之前**:演绎出的根构件带 `data-soma-component`,
536
855
  // 而组件展开是一次性扫描 `container.querySelectorAll('[data-soma-component]')`。
537
856
  // 插在它之后的话,演绎出来的组件不会被展开——DOM 在、锚点在、
538
857
  // `data-soma-component` 属性也在,只是那个组件的模板永远不注入,
539
858
  // 页面上就是一个空 div,没有异常也没有日志。
540
- this.installOouiHtml(container, parsed.uiConfig);
859
+ this.installFragmentHtml(container, parsed.uiConfig);
860
+
861
+ // 2.4.1 区域协调作用域:声明对页面实例对账(区域内实例必须由页面 HTML 直接声明)后装入 store。
862
+ // 在组件展开之前:此刻容器里还是未展开的页面 HTML,复合组件模板里的子实例不在其中。
863
+ this.installRegionScopes(container, parsed.uiConfig, parsed.eventConfig);
541
864
 
542
865
  // 2.5 组件展开(页面引擎构建前:模板注入、锚点作用域化、插槽投影)
543
866
  this.setupComponentManager(container, this.assets, parsed.uiConfig);
544
867
 
545
- // 2.6 主题派生与注入(app.config theme: { brand } 一行换装,缺省旁路)
546
- this.applyHostTheme(parsed.appConfig);
868
+ // 2.6 文案位登记并按当前显示语言首次渲染(组件展开之后:模板里的 `{{ t() }}` 都已落进文档)
869
+ this.bindLocaleSlots(container);
547
870
 
548
871
  // 3. 创建领域实例并注入配置
549
- this.domainInstance = this.createDomainInstance(assets.DomainClass, parsed, assets.routerPath);
872
+ this.domainInstance = this.createDomainInstance(assets.DomainClass ?? SomaLocaleOnlyPageRoot, parsed, assets.routerPath, assets);
550
873
 
551
874
  // 3.5 数据对象层(五件套可选件):首渲前解析声明并注入 reloadData 钩子;
552
875
  // 声明非法只告警不阻断挂载(data 保持空对象)
553
876
  this.prepareDataLayer(this.domainInstance, assets);
554
877
 
555
878
  // 4. 包装响应式代理
556
- // 第三参(数组变异守卫)这里**故意不传**:传 false 会把开发期也一起关掉,
557
- // 而这条告警正是写页面时唯一能发现"就地 push 不触发更新"的提示。
558
- // 该开还是该关交给 SomaReactiveProxy 的默认值按环境判定(isSomaArrayGuardEnabled)——
559
- // 生产包里是关的,`npm run dev` 与 `globalThis.SOMA_DEV_GUARD = true` 时照旧报。
560
879
  this.proxy = new SomaReactiveProxy(undefined, this.diagnostics);
561
880
  this.domainInstance = this.proxy.wrap(this.domainInstance);
562
881
 
563
- // 5. 构建运行时(委托给 RuntimeBuilder)
564
- await this.buildRuntime(parsed);
565
-
566
- // 5.5 数据对象层:异步取数(不阻塞首屏),完成后注入 page.data 并全量渲染
882
+ // 数据 resolver 先于自治组件 onMount 建立;首轮取数仍异步,不阻塞首屏。
567
883
  if (this.dataConfig) {
568
884
  void this.loadDataObjects();
569
885
  }
886
+
887
+ // 5. 构建运行时(委托给 RuntimeBuilder)
888
+ await this.buildRuntime(parsed);
889
+ assertCurrentMount();
570
890
  if (typeof this.domainInstance.onMount === 'function') {
571
891
  await this.domainInstance.onMount();
572
892
  }
893
+ assertCurrentMount();
894
+ await this.componentManager?.whenInitialized();
895
+ assertCurrentMount();
573
896
  this.startDeclarativeTimers();
574
897
  this.mounted = true;
575
898
  recordMetric('bootstrap.mount', (globalThis.performance?.now?.() ?? Date.now()) - mountStarted);
576
899
  } catch (error) {
900
+ // 旧挂载已被卸载或新挂载替代时,不能用旧失败清场当前页面。
901
+ if (ownerEpoch !== this.dataOwnerEpoch) throw error;
577
902
  console.error('[soma-core][引擎] 页面挂载失败:', error);
578
903
  // 必须在 cleanup 之前上报:cleanup 会摘掉采集器
579
904
  this.captureEngineError(error);
@@ -587,18 +912,18 @@ export class SomaBootstrap {
587
912
  options?: { resetDiagnostics?: boolean; preserveState?: boolean },
588
913
  ): Promise<void> {
589
914
  if (!this.mounted || !this.container || !this.assets || !this.domainInstance) {
590
- throw new Error('[soma-core][引擎] Cannot hotSwap before mount');
915
+ throw new Error('[SomaBootstrap] Cannot hotSwap before mount');
591
916
  }
592
917
 
593
918
  const savedLocale =
594
- overrides.localeYaml !== undefined && this.domainInstance._locale
919
+ overrides.locale !== undefined && this.domainInstance._locale
595
920
  ? { ...this.domainInstance._locale }
596
921
  : null;
597
922
 
598
923
  const snapshotId = options?.preserveState
599
924
  ? this.snapshotStore.capture(
600
925
  this.domainInstance,
601
- overrides.localeYaml !== undefined ? { exclude: ['_locale'] } : undefined,
926
+ overrides.locale !== undefined ? { exclude: ['_locale'] } : undefined,
602
927
  )
603
928
  : null;
604
929
 
@@ -628,6 +953,7 @@ export class SomaBootstrap {
628
953
  }
629
954
  }
630
955
  }
956
+ await this.ensureLazyComponents(merged);
631
957
  assertPageRuntimeAssets(merged, this.hostComponents);
632
958
 
633
959
  if (options?.resetDiagnostics) {
@@ -636,6 +962,11 @@ export class SomaBootstrap {
636
962
  }
637
963
 
638
964
  const parsed = this.assetResolver.resolve(merged);
965
+ // 应用配置 `format:` 先验后换:越界即抛 CORE-FORMAT-CONFIG(与装配期同一判据),此时页面还没动
966
+ const nextFormat = parsed.appConfig && typeof parsed.appConfig === 'object'
967
+ ? (parsed.appConfig as Record<string, unknown>).format
968
+ : undefined;
969
+ parseFormatAppConfig(nextFormat);
639
970
 
640
971
  // 旧页面的组件实例必须在 DOM 被换掉**之前**销毁。
641
972
  // adapter.mount 是 `container.innerHTML = html`:跑完之后旧宿主已是游离节点,
@@ -646,39 +977,47 @@ export class SomaBootstrap {
646
977
  // setupComponentManager 里那次 destroy() 是防御性兜底,删这一行会把上述后果全部放回来。
647
978
  this.componentManager?.destroy();
648
979
  this.componentManager = null;
980
+ this.dataOwnerEpoch += 1;
981
+ this.invalidateDataResolver();
649
982
 
983
+ this.releaseLocaleSlots();
984
+ if (overrides.locale !== undefined) this.loadLocale(parsed.locale);
650
985
  this.adapter.mount(this.container, merged.html, merged.includes);
651
- // 与 mount 同序:演绎 DOM 先落,组件展开后扫。热替换换的是整份 innerHTML,
986
+ // 与 mount 同序:样式先入、演绎 DOM 再落、作用域声明装入,组件展开最后扫。热替换换的是整份 innerHTML,
652
987
  // 上一版的区域连同它的已注入标记一起没了,所以这里必然是一次真注入。
653
- this.installOouiHtml(this.container, parsed.uiConfig);
988
+ this.installPageStyles(merged, parsed.uiConfig);
989
+ this.installFragmentHtml(this.container, parsed.uiConfig);
990
+ this.installRegionScopes(this.container, parsed.uiConfig, parsed.eventConfig);
654
991
  this.setupComponentManager(this.container, merged, parsed.uiConfig);
992
+ this.bindLocaleSlots(this.container);
655
993
 
656
994
  if (overrides.DomainClass) {
657
995
  this.proxy?.dispose();
658
- const raw = this.createDomainInstance(merged.DomainClass, parsed, merged.routerPath);
659
- // 与 mount 第 4 步同一口径:守卫开关交给默认值按环境判定,这里不传死
996
+ const raw = this.createDomainInstance(merged.DomainClass ?? SomaLocaleOnlyPageRoot, parsed, merged.routerPath, merged);
660
997
  this.proxy = new SomaReactiveProxy(undefined, this.diagnostics);
661
998
  this.domainInstance = this.proxy.wrap(raw);
662
999
  } else {
663
- if (!options?.preserveState || overrides.localeYaml !== undefined) {
664
- this.domainInstance._locale = parsed.locale as Record<string, string>;
665
- this.domainInstance._services?.i18n.loadContent(parsed.locale as Record<string, string>);
1000
+ if (!options?.preserveState || overrides.locale !== undefined) {
1001
+ // 词表已在 loadLocale 装入文案目录;`_locale` 是当前显示语言的词条表
1002
+ this.domainInstance._locale = this.localeTable(parsed.locale);
666
1003
  }
667
1004
  if (parsed.appConfig) {
668
1005
  this.domainInstance._config = parsed.appConfig as any;
669
1006
  }
670
1007
  applyLocaleMetadata(this.domainInstance);
1008
+ // `format:` 的读取点是服务里的配置(装配期装入、config.load 只合并不删键),所以这里整段换掉;
1009
+ // 不换的话热替换后占位 / 时区 / 周起始仍是旧值(缓存按原值身份,新旧值不同即重解)
1010
+ this.domainInstance._services?.config.set('format', nextFormat);
671
1011
  }
672
1012
 
673
1013
  this.assets = merged;
674
- await this.buildRuntime(parsed);
675
- this.startDeclarativeTimers();
676
-
677
- // 数据对象层:hotSwap 后按合并资产重建声明并重取(无声明时零路径变化)
1014
+ // 新组件取得端口前先替换数据声明;旧端口不能取得新页面的数据写能力。
678
1015
  this.prepareDataLayer(this.domainInstance, merged);
679
1016
  if (this.dataConfig) {
680
1017
  void this.loadDataObjects();
681
1018
  }
1019
+ await this.buildRuntime(parsed);
1020
+ this.startDeclarativeTimers();
682
1021
 
683
1022
  if (snapshotId !== null) {
684
1023
  try {
@@ -687,7 +1026,7 @@ export class SomaBootstrap {
687
1026
  /* snapshot 与新区划不兼容时忽略 */
688
1027
  }
689
1028
  if (savedLocale) {
690
- this.domainInstance._locale = { ...savedLocale, ...parsed.locale } as Record<string, string>;
1029
+ this.domainInstance._locale = { ...savedLocale, ...this.localeTable(parsed.locale) } as Record<string, string>;
691
1030
  applyLocaleMetadata(this.domainInstance);
692
1031
  this.renderEngine?.render();
693
1032
  }
@@ -696,14 +1035,14 @@ export class SomaBootstrap {
696
1035
 
697
1036
  captureSnapshot(options?: { exclude?: string[] }): number {
698
1037
  if (!this.domainInstance) {
699
- throw new Error('[soma-core][引擎] Cannot capture snapshot before mount');
1038
+ throw new Error('[SomaBootstrap] Cannot capture snapshot before mount');
700
1039
  }
701
1040
  return this.snapshotStore.capture(this.domainInstance, options);
702
1041
  }
703
1042
 
704
1043
  restoreSnapshot(snapshotId: number): void {
705
1044
  if (!this.domainInstance) {
706
- throw new Error('[soma-core][引擎] Cannot restore snapshot before mount');
1045
+ throw new Error('[SomaBootstrap] Cannot restore snapshot before mount');
707
1046
  }
708
1047
  this.snapshotStore.restore(snapshotId, this.domainInstance);
709
1048
  this.renderEngine?.render();
@@ -711,7 +1050,7 @@ export class SomaBootstrap {
711
1050
 
712
1051
  batch(fn: () => void): void {
713
1052
  if (!this.proxy) {
714
- throw new Error('[soma-core][引擎] Cannot batch before mount');
1053
+ throw new Error('[SomaBootstrap] Cannot batch before mount');
715
1054
  }
716
1055
  this.proxy.beginBatch();
717
1056
  try {
@@ -722,7 +1061,7 @@ export class SomaBootstrap {
722
1061
  }
723
1062
 
724
1063
  async unmount(): Promise<void> {
725
- if (!this.mounted) return;
1064
+ if (!this.mounted && this.container === null) return;
726
1065
 
727
1066
  try {
728
1067
  if (this.domainInstance && typeof this.domainInstance.onUnmount === 'function') {
@@ -744,16 +1083,46 @@ export class SomaBootstrap {
744
1083
  return this.telemetry.snapshot();
745
1084
  }
746
1085
 
747
- getAvailableThemes(): string[] {
748
- return this.styleBinder?.getAvailableThemes() ?? [];
749
- }
750
-
751
1086
  getStyleBinder(): SomaStyleBinder | null {
752
1087
  return this.styleBinder;
753
1088
  }
754
1089
 
755
- switchTheme(themeName: string | null): void {
756
- this.styleBinder?.switchTheme(themeName);
1090
+ /**
1091
+ * 切换显示语言(2.2a,00e Q-163):只改当前语言并按词表重渲文案位(文本节点与属性位),
1092
+ * 不重编、不换产物、不重建 DOM 结构、不改类名;状态、草稿、窗口、焦点保留。
1093
+ * 语言不在词表内:记 `CORE-LOCALE-UNKNOWN` 诊断、保持当前语言、不抛。
1094
+ */
1095
+ setLocale(locale: string): void {
1096
+ if (!this.localeCatalog.setCurrentLocale(locale)) {
1097
+ const diagnostic = coreDiagnostic({
1098
+ code: 'CORE-LOCALE-UNKNOWN',
1099
+ severity: 'warning',
1100
+ situation: '切换显示语言',
1101
+ problem: `词表里没有语言 "${locale}"`,
1102
+ remedy: `确认语言标识与应用 locales 一致;已保持当前语言 "${this.localeCatalog.currentLocale()}"`,
1103
+ });
1104
+ this.diagnostics.recordValidation('warning', `[${diagnostic.code}] ${diagnostic.problem}。${diagnostic.remedy}。`);
1105
+ return;
1106
+ }
1107
+ this.refreshLocaleSurface();
1108
+ }
1109
+
1110
+ /** 当前显示语言(只读) */
1111
+ currentLocale(): string {
1112
+ return this.localeCatalog.currentLocale();
1113
+ }
1114
+
1115
+ /**
1116
+ * 运行出口专用:注入额外语言词表(伪本地化等测试语言)。不进根导出(AD-CORE-08)。
1117
+ * 之后可对该语言调 `setLocale`。
1118
+ */
1119
+ registerLocaleDictionary(locale: string, dictionary: Readonly<Record<string, string>>): void {
1120
+ this.localeCatalog.registerLocale(locale, dictionary);
1121
+ }
1122
+
1123
+ /** 编译端口每发起一次调用,同进程 Host / 测试替身调用本方法计入观测 `compileCalls`(未开观测时空操作) */
1124
+ noteCompileCall(): void {
1125
+ this.observer?.countCompileCall();
757
1126
  }
758
1127
 
759
1128
  /** 获取当前挂载的业务实例(测试 / 调试) */
@@ -767,15 +1136,19 @@ export class SomaBootstrap {
767
1136
 
768
1137
  isSettled(): boolean {
769
1138
  return this.isInitialized()
1139
+ && (this.componentManager?.isInitialized() ?? true)
770
1140
  && this.scheduler.isSettled()
771
1141
  && (this.domainInstance?._services?.http.pendingCount() ?? 0) === 0;
772
1142
  }
773
1143
 
774
1144
  async whenSettled(): Promise<void> {
775
- await this.scheduler.whenSettled();
776
- while (this.isInitialized() && (this.domainInstance?._services?.http.pendingCount() ?? 0) > 0) {
777
- await new Promise<void>((resolve) => setTimeout(resolve, 0));
778
- }
1145
+ do {
1146
+ await this.componentManager?.whenInitialized();
1147
+ await this.scheduler.whenSettled();
1148
+ while (this.isInitialized() && (this.domainInstance?._services?.http.pendingCount() ?? 0) > 0) {
1149
+ await new Promise<void>((resolve) => setTimeout(resolve, 0));
1150
+ }
1151
+ } while (this.isInitialized() && !this.isSettled());
779
1152
  }
780
1153
 
781
1154
  getDomainValue(path: string): unknown {
@@ -805,7 +1178,7 @@ export class SomaBootstrap {
805
1178
  /** 监听属性变更(委托 RenderEngine.watch) */
806
1179
  watch(path: string, callback: WatchCallback, options?: WatcherOptions): () => void {
807
1180
  if (!this.renderEngine) {
808
- throw new Error('[soma-core][引擎] Cannot watch before mount');
1181
+ throw new Error('[SomaBootstrap] Cannot watch before mount');
809
1182
  }
810
1183
  return this.renderEngine.watch(path, callback, options);
811
1184
  }
@@ -843,22 +1216,34 @@ export class SomaBootstrap {
843
1216
  });
844
1217
  }
845
1218
 
1219
+ /** 未登记的异步检查器:诊断走可观察通道,不抛(降级口径见 async-check-registry.ts 头注) */
1220
+ private reportUnregisteredAsyncChecks(objects: Parameters<typeof findUnregisteredAsyncChecks>[0]): void {
1221
+ const missing = findUnregisteredAsyncChecks(objects, this.validationService);
1222
+ if (missing.length === 0) return;
1223
+ const error = unregisteredAsyncCheckError(missing, this.validationService);
1224
+ console.error('[soma-core][引擎] 异步检查器未注册(只有引用它的规则不可用,页面其余部分照常):', error);
1225
+ this.captureEngineError(error);
1226
+ }
1227
+
846
1228
  /**
847
1229
  * 引擎自身捕获的异常进同一采集通道。
848
1230
  * 全局 error 监听抓不到这些——它们已经被引擎 catch 住了(页面不崩,但确实错了),
849
1231
  * 不显式补一条,可观测数据就会漏掉最该看的那类问题。
850
1232
  */
851
1233
  private captureEngineError(error: unknown): void {
1234
+ const code = (error as { code?: unknown } | null)?.code;
1235
+ this.observer?.recordError({ code: typeof code === 'string' ? code : 'CORE-RUNTIME-ERROR' });
852
1236
  this.errorReporter?.capture(error, 'runtime');
853
1237
  }
854
1238
 
855
1239
  private createDomainInstance(
856
- DomainClass: new () => SomaPageRoot,
1240
+ DomainClass: new () => SharedPageRoot,
857
1241
  parsed: ParsedRuntimeAssets,
858
1242
  routerPath?: string,
1243
+ routeAssets?: SomaPageAssets,
859
1244
  ): SomaPageRoot {
860
- const raw = new DomainClass();
861
- raw._locale = parsed.locale as Record<string, string>;
1245
+ const raw = new DomainClass() as SomaPageRoot;
1246
+ raw._locale = this.localeTable(parsed.locale);
862
1247
  if (parsed.appConfig) {
863
1248
  raw._config = parsed.appConfig as any;
864
1249
  }
@@ -866,9 +1251,23 @@ export class SomaBootstrap {
866
1251
 
867
1252
  raw._services = createDefaultRuntimeServices({
868
1253
  appConfig: parsed.appConfig,
869
- locale: parsed.locale,
1254
+ // 文案目录是 bootstrap 的(跨挂载同一个实例,词表已在 loadLocale 装入):services.i18n 就是它
1255
+ catalog: this.localeCatalog,
870
1256
  initialPath: routerPath ?? getBrowserUrlPath(),
1257
+ auth: this.authOption,
1258
+ ...(this.identityOption ? { identity: this.identityOption } : {}),
1259
+ navHistory: this.navHistoryInstance,
1260
+ renderPorts: this.renderPorts,
1261
+ engines: this.engines,
1262
+ engineTelemetry: this.telemetry,
1263
+ shortcuts: this.shortcutsInstance,
871
1264
  });
1265
+ raw._services.observation = this.observer ?? NOOP_OBSERVATION_CHANNEL;
1266
+ raw._services.nav = this.navStore.port;
1267
+ if (routeAssets !== undefined) {
1268
+ this.navStore.replace(routeAssets.nav);
1269
+ this.seedRouteContext(raw, routeAssets);
1270
+ }
872
1271
 
873
1272
  this.wireRouter(raw);
874
1273
 
@@ -883,7 +1282,52 @@ export class SomaBootstrap {
883
1282
  return raw;
884
1283
  }
885
1284
 
886
- // ─── 数据对象层(*_data.yaml,可选件) ─────────────────────
1285
+ /**
1286
+ * 把取页响应带来的地址参数与查询值装进页面根(E3,姊妹稿 §4.8):`page.params` 冻结(只读,写入被拒;
1287
+ * 声明面的写入已在编译期拒收),`page.query` 是可写的普通对象(回写地址栏由 `installDeclaredPageHooks` 的绑定负责)。
1288
+ * 没有参数 / 没有查询契约就什么也不装,不去占页面根上同名的成员。
1289
+ */
1290
+ private seedRouteContext(raw: SomaPageRoot, assets: SomaPageAssets): void {
1291
+ const target = raw as unknown as Record<string, unknown>;
1292
+ if (assets.pageParams !== undefined && Object.keys(assets.pageParams).length > 0) {
1293
+ target.params = Object.freeze({ ...assets.pageParams });
1294
+ }
1295
+ if (assets.queryContract !== undefined && Object.keys(assets.queryContract).length > 0) {
1296
+ target.query = { ...(assets.pageQuery ?? {}) };
1297
+ }
1298
+ }
1299
+
1300
+ /**
1301
+ * 同一页面模式下的客户端导航(E3):只换地址参数 / 查询值 / 导航目录,不重载页面、不重建运行时。
1302
+ * `page.params` 整体换成新的冻结对象,依赖它的数据对象按「依赖值变化即重取」的现有规则重取。
1303
+ * 返回是否生效(没有已挂载的页面时为 false,调用方应整页重挂)。
1304
+ */
1305
+ updateRouteContext(next: {
1306
+ readonly params?: Readonly<Record<string, string | number>>;
1307
+ readonly query?: Readonly<Record<string, string | number | boolean | null>>;
1308
+ readonly nav?: SomaNavView;
1309
+ }): boolean {
1310
+ const instance = this.domainInstance as unknown as Record<string, unknown> | null;
1311
+ if (instance === null || this.assets === null) return false;
1312
+ if (next.nav !== undefined) {
1313
+ this.navStore.replace(next.nav);
1314
+ this.assets = { ...this.assets, nav: next.nav };
1315
+ }
1316
+ if (next.params !== undefined) {
1317
+ // 页面根上原本没装 params 且新的也是空:不去占页面根上同名成员(与 seedRouteContext 同一规则)
1318
+ if (instance.params !== undefined || Object.keys(next.params).length > 0) {
1319
+ instance.params = Object.freeze({ ...next.params });
1320
+ }
1321
+ this.assets = { ...this.assets, pageParams: next.params };
1322
+ }
1323
+ if (next.query !== undefined && this.assets.queryContract !== undefined) {
1324
+ instance.query = { ...next.query };
1325
+ this.assets = { ...this.assets, pageQuery: next.query };
1326
+ }
1327
+ return true;
1328
+ }
1329
+
1330
+ // ─── 数据对象层(page 块 `data:`,Soma Data) ─────────────────────
887
1331
 
888
1332
  /**
889
1333
  * 首渲前解析数据对象声明并向 Domain 实例注入 reloadData 钩子。
@@ -891,25 +1335,59 @@ export class SomaBootstrap {
891
1335
  * 声明非法只 console.error,页面继续以空 data 挂载(不阻塞)。
892
1336
  */
893
1337
  private prepareDataLayer(instance: SomaPageRoot, assets: SomaPageAssets): void {
1338
+ this.invalidateDataResolver();
1339
+ this.disposeDataSubscriptions();
894
1340
  this.dataConfig = null;
895
1341
  this.dataReady = null;
896
1342
  this.dataDicts = {};
1343
+ instance._reloadData = undefined;
1344
+ instance.data = {};
897
1345
 
898
1346
  const hasDeclaration = assets.dataConfig !== undefined
899
1347
  || (typeof assets.dataYaml === 'string' && assets.dataYaml.trim() !== '');
900
1348
  if (!hasDeclaration) return;
901
1349
 
1350
+ const owner = this.dataOwnerEpoch;
902
1351
  try {
903
1352
  const config = assets.dataConfig ?? parseDataYaml(assets.dataYaml!);
904
1353
  if (Object.keys(config.objects).length === 0) return;
1354
+ // 字段规则 rules[].async 引用的检查器名:与具名动作同一时机核对。缺登记只让引用它的规则不可用(AD-45):
1355
+ // 报 CORE-ASYNC-CHECK-UNREGISTERED 诊断(captureEngineError + console),其余数据对象、字段、规则照常挂载
1356
+ this.reportUnregisteredAsyncChecks(config.objects);
905
1357
  this.dataConfig = config;
1358
+ // 数据变更订阅(REQ-019 D-5):后端在频道上推"哪些数据变了",按声明刷新;realtime 没配地址时静默不接
1359
+ if (config.subscribe && config.subscribe.length > 0) {
1360
+ this.dataSubscriptions = attachDataSubscriptions({
1361
+ subscriptions: config.subscribe,
1362
+ realtime: instance._services?.realtime,
1363
+ refresh: (names) => this.refreshDataObjects(owner, names),
1364
+ onError: (error) => this.captureEngineError(error),
1365
+ });
1366
+ }
1367
+ // 对象级轮询:声明了 poll 的对象,只要数据里还有命中 while 的记录就按 every 秒重取
1368
+ const polls = Object.values(config.objects)
1369
+ .filter((decl) => decl.poll !== undefined)
1370
+ .map((decl) => ({ name: decl.name, poll: decl.poll! }));
1371
+ if (polls.length > 0) {
1372
+ this.dataPolling = attachDataPolling({
1373
+ polls,
1374
+ read: (name) => this.dataResolver?.getObject(name),
1375
+ refresh: async (name) => {
1376
+ await this.refreshDataObjects(owner, [name]);
1377
+ if (owner !== this.dataOwnerEpoch) return;
1378
+ this.renderEngine?.render();
1379
+ this.componentManager?.refreshAll();
1380
+ },
1381
+ onError: (error) => this.captureEngineError(error),
1382
+ });
1383
+ }
906
1384
  } catch (error) {
907
1385
  console.error('[soma-core][数据] 数据对象声明解析失败(页面继续以空 data 挂载):', error);
908
1386
  this.captureEngineError(error);
909
1387
  return;
910
1388
  }
911
1389
 
912
- instance._reloadData = () => this.loadDataObjects();
1390
+ instance._reloadData = () => owner === this.dataOwnerEpoch ? this.loadDataObjects() : Promise.resolve();
913
1391
  }
914
1392
 
915
1393
  /**
@@ -923,6 +1401,9 @@ export class SomaBootstrap {
923
1401
  if (!instance || !config || !services) {
924
1402
  return Promise.resolve();
925
1403
  }
1404
+ this.invalidateDataResolver();
1405
+ const epoch = this.dataLoadEpoch;
1406
+ const isCurrent = (): boolean => epoch === this.dataLoadEpoch && this.domainInstance === instance;
926
1407
 
927
1408
  // api 声明允许写全路径(如 /api/order/detail):与 http 服务 baseURL 重叠时去重,
928
1409
  // 避免拼出 /api/api/... 的双前缀
@@ -943,42 +1424,56 @@ export class SomaBootstrap {
943
1424
  post: writeVerb('post'),
944
1425
  put: writeVerb('put'),
945
1426
  patch: writeVerb('patch'),
1427
+ // 删除(S-X1:write.delete 与 method: DELETE 的命令动作):此前这里漏接,Host 的 http 有 delete 也报「不支持」
1428
+ delete: typeof (services.http as unknown as Record<string, unknown>).delete === 'function'
1429
+ ? <T,>(url: string) => services.http.delete<T>(strip(url))
1430
+ : undefined,
946
1431
  };
947
1432
 
1433
+ if (!isCurrent()) return Promise.resolve();
1434
+ const resolver = new SomaDataObjectResolver(config, {
1435
+ http,
1436
+ query: (key) => readQueryParam(key, services.router.getCurrentPath()),
1437
+ page: () => this.domainInstance,
1438
+ pipes: this.pipeRegistry,
1439
+ locale: () => instance._locale as Record<string, unknown> | undefined,
1440
+ identity: services.identity,
1441
+ onFetch: this.observer ? (entry) => this.observer?.recordFetch(entry) : undefined,
1442
+ onReload: (objects) => {
1443
+ if (!isCurrent() || this.dataResolver !== resolver) return;
1444
+ instance.data = objects;
1445
+ this.renderEngine?.render();
1446
+ this.componentManager?.refreshAll();
1447
+ },
1448
+ // 401 / 403 → CORE-DATA-FORBIDDEN、外键批取失败 → CORE-DATA-RELATION:进诊断簿(不含角色值与键值)
1449
+ onDiagnostic: (diagnostic) => this.diagnostics.recordValidation(
1450
+ diagnostic.severity === 'error' ? 'error' : 'warning',
1451
+ `[${diagnostic.code}] ${diagnostic.situation}:${diagnostic.problem}。${diagnostic.remedy}`,
1452
+ ),
1453
+ });
1454
+ // 解析器换新:组件手里的 data 端口是稳定壳,调用时才取当前解析器(见 buildComponentServices)
1455
+ this.dataResolver = resolver;
1456
+
948
1457
  const task = Promise.resolve()
949
- .then(() => {
950
- const resolver = new SomaDataObjectResolver(config, {
951
- http,
952
- query: (key) => readQueryParam(key, services.router.getCurrentPath()),
953
- page: () => this.domainInstance,
954
- pipes: this.pipeRegistry,
955
- locale: () => instance._locale as Record<string, unknown> | undefined,
956
- });
957
- // 解析器换新:组件手里的 data 端口是稳定壳,调用时才取当前解析器(见 buildComponentServices)
958
- this.dataResolver = resolver;
959
- // 窗口是**自己会动**的:滚动触发取数、取数完成换行,这些都不经过页面的
960
- // 事件通道。不接这一下,滚动之后行取回来了但一帧都不重渲。
961
- resolver.setWindowChangeHandler(() => {
962
- this.renderEngine?.render();
963
- this.componentManager?.refreshAll();
964
- });
965
- return resolver.resolve();
966
- })
967
- .then((result) => {
968
- if (this.domainInstance !== instance) return; // 页面已卸载/热换,丢弃过期结果
1458
+ .then(async () => {
1459
+ if (!isCurrent() || this.dataResolver !== resolver) return;
1460
+ const result = await resolver.resolve();
1461
+ if (!isCurrent() || this.dataResolver !== resolver) return;
969
1462
  this.dataDicts = result.dicts;
970
- this.domainInstance.data = result.objects;
1463
+ instance.data = result.objects;
971
1464
  this.renderEngine?.render();
972
1465
  // 自治组件有自己的渲染引擎,页面重渲进不去。数据对象刚刚才到,
973
- // 而它们(FormConsole 的字典与回填、DetailConsole 的字段…)在挂载那一刻
1466
+ // 而它们(表单组件的字典与回填、详情组件的字段…)在挂载那一刻
974
1467
  // 读到的是空字典——不推这一下,它们会一直显示挂载时的空表单。
975
1468
  this.componentManager?.refreshAll();
1469
+ this.dataPolling?.arm();
976
1470
  })
977
1471
  .catch((error) => {
1472
+ if (!isCurrent()) return;
978
1473
  console.error('[soma-core][数据] 数据对象解析失败(data 保持空对象):', error);
979
1474
  this.captureEngineError(error);
980
- if (this.domainInstance === instance) {
981
- this.domainInstance.data = {};
1475
+ if (isCurrent()) {
1476
+ instance.data = {};
982
1477
  this.renderEngine?.render();
983
1478
  }
984
1479
  });
@@ -987,58 +1482,6 @@ export class SomaBootstrap {
987
1482
  return task;
988
1483
  }
989
1484
 
990
- /**
991
- * 主题派生注入:app.config 声明 theme.brand 时全库换装;配置非法只告警不阻断挂载。
992
- * 主题是引擎内建路径,不是 bootstrap 可注册能力。
993
- */
994
- private applyHostTheme(appConfig: unknown): void {
995
- const theme = (appConfig as { theme?: SomaThemeInput } | undefined)?.theme;
996
- if (!theme?.brand) {
997
- return;
998
- }
999
- this.reconcileThemeComponentTokens(theme);
1000
- try {
1001
- applyTheme(theme);
1002
- } catch (error) {
1003
- console.error('[soma-core][主题] 主题派生失败(保持默认令牌):', error);
1004
- this.captureEngineError(error);
1005
- }
1006
- }
1007
-
1008
- /**
1009
- * 组件令牌对账(REQ-009 M-1):`components: { Buton: { radius: … } }` 这样一个
1010
- * 拼写错误,不对账时的表现是**"改了没反应"**——变量确实写进了 :root,
1011
- * 只是没有任何组件读它。这类错误的排查成本远高于报错。
1012
- *
1013
- * 判据住在 `component/theme-component-tokens.ts`,而它此前**一个调用者都没有**
1014
- * (由 `verify:reachable` 查出)。这里是全仓唯一同时持有「主题输入」与
1015
- * 「这一页实际可用的组件表」的地方,所以对账只能发生在这一点上。
1016
- *
1017
- * 两条边界:
1018
- * · **只告警、不阻断换装**。主题是 app 级、全部页面共享的,组件表却是逐页的;
1019
- * 曾经对账与 applyTheme 同在一个 try 里,一条对不上就把整份品牌主题一起丢掉
1020
- * (全页回落默认令牌 + 一条"主题派生失败"),与"一个令牌没人读"的后果不成比例。
1021
- * · **组件表 = Host 级 + 页面级**,与 setupComponentManager 实际装配的那张表同一口径
1022
- * (页面同名胜出)。只看 Host 级的话,只在页面资产里注册的组件会被误报成未知组件。
1023
- * 拿不到组件表时(纯预览场景)按设计跳过,不猜。
1024
- */
1025
- private reconcileThemeComponentTokens(theme: SomaThemeInput): void {
1026
- // 只读查找视图,不是组件包合成——重名裁决与告警在 setupComponentManager 里已经做过
1027
- const components = { ...this.hostComponents, ...(this.assets?.components ?? {}) };
1028
- if (Object.keys(components).length === 0) {
1029
- return;
1030
- }
1031
- const issues = validateThemeComponentTokens(theme, components);
1032
- if (issues.length === 0) {
1033
- return;
1034
- }
1035
- const message = `主题的组件令牌段有 ${issues.length} 处对不上组件契约`
1036
- + '(主题照常生效;这些令牌会写进 :root,但当前页没有组件读它们):'
1037
- + `\n${issues.map((issue) => ` · ${issue}`).join('\n')}`;
1038
- console.warn(`[soma-core][主题] ${message}`);
1039
- this.diagnostics.recordValidation('warning', `[主题组件令牌] ${message}`);
1040
- }
1041
-
1042
1485
  /**
1043
1486
  * 组件可见的服务表:页面运行时服务 + data 端口(M-5)。
1044
1487
  *
@@ -1052,46 +1495,131 @@ export class SomaBootstrap {
1052
1495
  // 端口必须是**稳定壳**:组件实例在 activate 时就把 services 抓在手里,
1053
1496
  // 而数据解析器要到 loadDataObjects 之后才存在,且每次重取都换一个新的。
1054
1497
  // 直接注入解析器的话,组件会永久持有第一个(甚至是 null)。
1055
- return { ...base, data: this.createStableDataPort() };
1498
+ return {
1499
+ ...base,
1500
+ data: this.createStableDataPort(),
1501
+ observation: this.observer ?? NOOP_OBSERVATION_CHANNEL,
1502
+ // 异步字段检查器:按名取用应用登记的检查器(组件须在契约 services 声明 validation)
1503
+ validation: this.validationService,
1504
+ // 区域协调:`(scopeId, instanceId) => 端口`,组件管理器按调用实例包成 `(scopeId) => 端口`(filterServices)
1505
+ region: (scopeId: string, instanceId: string) => this.regionScopes.port(scopeId, instanceId),
1506
+ // 格式化器工厂:每次调用读当前显示语言(切换语言后下次取到新语言);缺省语言取应用缺省语言,
1507
+ // 占位与缺省时区取应用配置 `format:`(K1 ①;未配置时占位空串、时区随运行环境)
1508
+ format: () => this.createPageFormatter(),
1509
+ };
1510
+ }
1511
+
1512
+ /** 组件包词条登记(S5):先过形状判据,再按序登记进文案目录(后面的包优先) */
1513
+ private registerPackLocales(packs: readonly PackWithLocales[] | undefined): void {
1514
+ if (packs === undefined || packs.length === 0) return;
1515
+ const issues = packs.flatMap((pack) => pack.locales === undefined
1516
+ ? []
1517
+ : validatePackLocales(pack.locales, `locale.packs[${pack.name}].locales`));
1518
+ if (issues.length > 0) {
1519
+ throw new Error(
1520
+ `[SomaBootstrap] 组件包词条非法:\n${issues.map((issue) => ` · [${issue.code}] ${issue.message}`).join('\n')}`,
1521
+ );
1522
+ }
1523
+ registerComponentPackLocales(this.localeCatalog, packs);
1056
1524
  }
1057
1525
 
1058
1526
  /**
1059
- * 约束布局产物注入(REQ-011 接线 / CL-4)。
1527
+ * 应用配置 `format:`(placeholder / time_zone / week_start)的当前值。装配期已在 createDefaultRuntimeServices
1528
+ * 校验过(越界即 CORE-FORMAT-CONFIG),这里按原值身份缓存;没有页面实例时为空缺省。
1529
+ */
1530
+ private clock(): SomaClockPort {
1531
+ if (this.clockOption !== undefined) return this.clockOption;
1532
+ const zone = this.formatDefaults().timeZone;
1533
+ if (this.derivedClock !== null && this.derivedClock.zone === zone) return this.derivedClock.clock;
1534
+ let clock: SomaClockPort;
1535
+ try {
1536
+ clock = createClock(zone === undefined ? {} : { timeZone: zone });
1537
+ } catch {
1538
+ clock = createClock(); // 时区非法:format 配置自己已报,这里退回 UTC,不让取数链抛
1539
+ }
1540
+ this.derivedClock = { zone, clock };
1541
+ return clock;
1542
+ }
1543
+
1544
+ private formatDefaults(): SomaFormatDefaults {
1545
+ const raw = this.domainInstance?._services?.config.get('format');
1546
+ if (this.formatDefaultsCache !== null && this.formatDefaultsCache.raw === raw) return this.formatDefaultsCache.value;
1547
+ let value: SomaFormatDefaults;
1548
+ try {
1549
+ value = parseFormatAppConfig(raw);
1550
+ } catch (error) {
1551
+ // 装配期没拦住(如热替换途中配置被改坏):不让每次渲染都抛,记一次诊断后按空缺省
1552
+ console.error('[soma-core][引擎] 应用配置 format: 非法,按缺省处理:', error);
1553
+ value = {};
1554
+ }
1555
+ this.formatDefaultsCache = { raw, value };
1556
+ return value;
1557
+ }
1558
+
1559
+ /** 页面格式化器:当前显示语言 + 应用缺省语言 + 应用配置 `format:` 的占位与时区 */
1560
+ private createPageFormatter(): SomaFormatter {
1561
+ const defaults = this.formatDefaults();
1562
+ return createFormatter({
1563
+ locale: this.localeCatalog.currentLocale(),
1564
+ fallbackLocale: this.localeCatalog.applicationDefaultLocale(),
1565
+ placeholder: defaults.placeholder ?? '',
1566
+ ...(defaults.timeZone !== undefined ? { timeZone: defaults.timeZone } : {}),
1567
+ });
1568
+ }
1569
+
1570
+ /**
1571
+ * 页面样式的统一装载点(KC12 序 2 → 序 4):编译样式片、约束布局产物、区域产物样式表。
1060
1572
  *
1061
- * 运行时只认 `layout_css`——构建期解好的 CSS——按宿主类名注入一次。
1062
- * 收到的若是 `layout` 声明本身而没有产物,说明这页没走 `compilePageDeclaration`
1063
- * (直接把源 YAML 喂给了浏览器)。这里**不**代为求解:求解器在 core/build/,
1064
- * 进 client 就等于把「运行期零求解」这条结构性承诺撤回去。只把这件事说出来。
1573
+ * 运行时只认**产物**,逐字节注入,不改写、不排序、不补层、不解释内容;方言声明键(如 `layout`)
1574
+ * 没有产物只告警一次、不代算(KI-8:求解与演绎只在构建期 / 编译端口里发生,运行时零求解)。
1575
+ * 位置固定在组件分片(序 6)之前,级联顺序才稳定。
1065
1576
  */
1066
- private installLayoutCss(uiConfig: UiConfig): void {
1067
- if (uiConfig.layoutCss) {
1068
- injectStyleOnce(
1069
- `layout:${uiConfig.bind.obj}`,
1070
- uiConfig.layoutCss,
1071
- { nonce: this.componentStyleNonce ?? null },
1072
- );
1073
- return;
1577
+ private installPageStyles(assets: SomaPageAssets, uiConfig: UiConfig): void {
1578
+ const options = { nonce: this.componentStyleNonce ?? null };
1579
+ // 序 2:编译样式片(首片为层序声明,产出方义务)
1580
+ installCompiledStyles(assets.compiledStyles, options);
1581
+ // 序 3:约束布局产物,键内容寻址 `layout:<摘要>`(同键不同内容不会静默保留旧页)
1582
+ if (uiConfig.layoutCss !== undefined) {
1583
+ if (typeof uiConfig.layoutCss !== 'string') {
1584
+ throw new SomaUiConfigError('layoutCss 必须是字符串(CORE-STYLE-INVALID)', 'layoutCss');
1585
+ }
1586
+ injectStyleOnce(`layout:${fragmentHtmlFingerprint(uiConfig.layoutCss)}`, uiConfig.layoutCss, options);
1074
1587
  }
1075
- if (uiConfig.layout && Object.keys(uiConfig.layout).length > 0) {
1076
- console.warn(
1077
- `[soma-core][布局] 页面 "${uiConfig.bind.obj}" 声明了 layout: 段但没有构建期产物(layout_css)——`
1078
- + '声明未经 compilePageDeclaration 求解,本页不会产生任何布局样式。'
1079
- + '求解只在构建期发生(Registry 发布 / Host 预编译),运行时不代算。',
1080
- );
1588
+ // 序 4:片段载体样式表,键为产物自带的内容哈希 `<前缀>:<8hex>`(键值是数据,core 不解释)
1589
+ const artifact = uiConfig.fragments;
1590
+ if (artifact?.css && artifact.css_key) {
1591
+ injectStyleOnce(artifact.css_key, artifact.css, options);
1081
1592
  }
1593
+ this.warnUncompiledLayout(assets, uiConfig);
1082
1594
  }
1083
1595
 
1084
1596
  /**
1085
- * OOUI 演绎产物的 DOM 落点(REQ-014 最后一公里)。
1597
+ * 编译期声明键(`layout`)到了运行期却没有对应产物:说明这页没走编译。只告警,不代算(CORE-HOOK-UNCOMPILED)。
1598
+ */
1599
+ private warnUncompiledLayout(assets: SomaPageAssets, uiConfig: UiConfig): void {
1600
+ const declared = uiConfig as unknown as Readonly<Record<string, unknown>>;
1601
+ const layout = declared.layout ?? (typeof assets.uiYaml === "string" && /(?:^|\n)\s*layout\s*:/m.test(assets.uiYaml) ? true : undefined);
1602
+ if (layout !== undefined && layout !== null && (typeof layout !== "object" || Object.keys(layout as object).length > 0)) {
1603
+ if (uiConfig.layoutCss === undefined) {
1604
+ const message = `页面 "${uiConfig.bind?.obj ?? ""}" 的 layout: 声明没有构建期产物`
1605
+ + "——声明未经编译,本页不会产生对应界面或样式。求解与演绎只在构建期(Registry 发布 / Host 预编译)发生,运行时不代算。";
1606
+ console.warn(`[soma-core][引擎] [CORE-HOOK-UNCOMPILED] ${message}`);
1607
+ this.diagnostics.recordValidation("warning", `[CORE-HOOK-UNCOMPILED] ${message}`);
1608
+ }
1609
+ }
1610
+ }
1611
+
1612
+ /**
1613
+ * 编译产物片段的 DOM 落点。
1086
1614
  *
1087
1615
  * ── 为什么"没有这一步"是一种静默失败 ─────────────────────────────
1088
- * 在它之前,整条演绎链止于 `deduce()` 的返回值:六层全绿、`ooui_artifact`
1616
+ * 在它之前,整条演绎链止于 `deduce()` 的返回值:六层全绿、`fragments`
1089
1617
  * 在资产里、样式表也注入了,**页面上什么都没有**。而"锚点空着"与
1090
1618
  * "这块本来就没写内容"在浏览器里长得一模一样——没有异常、没有日志、
1091
1619
  * 截图里也分不开。这是最像成功的那种失败,所以落点必须有断言守着。
1092
1620
  *
1093
1621
  * ── 运行时收到产物就用,收到声明就拒绝代算 ───────────────────────
1094
- * 与 `installLayoutCss` / `installOouiArtifact` 同一条范式:本方法**只搬运**。
1622
+ * 与 `installLayoutCss` / `installFragmentHtml` 同一条范式:本方法**只搬运**。
1095
1623
  * 它不认识形态、不认识候选表、不认识组件契约——那些词汇住在 soma-ui,
1096
1624
  * 浏览器手里根本没有,代算出来的只会是一份猜的界面。
1097
1625
  *
@@ -1103,23 +1631,32 @@ export class SomaBootstrap {
1103
1631
  * `<script>` 虽然不执行,`<img onerror=…>` 却会立刻执行。所以注入前必须再核一道——
1104
1632
  * 这是纵深防御的最后一层,不因门口补齐而省掉。
1105
1633
  *
1106
- * 核的方式是**允许集**不是禁用集:`emitRegionHtml` 今天只产出
1107
- * `div` / `span` 两种标签与四个 `class` / `data-soma-*` 属性,
1108
- * 把这个全集写死,任何多出来的东西一律拒收。禁用集在这种两标签的产物上
1109
- * 严格更差——它只挡得住今天想得到的那几样。发射器哪天真加了新标签,
1110
- * 这里会**当场红**(而不是静默放行),红在写下的那天,这正是要的。
1634
+ * 核的方式是**允许集**不是禁用集:编译产物的 slot 出口会发射
1635
+ * `template[data-soma-slot]`,其余区域结构用 `div`;属性限于实例钩子、
1636
+ * 显隐门、slot 与 class。把这个全集写死,任何多出来的东西一律拒收。
1637
+ * 编译产物哪天真加了新形状,这里会**当场红**(而不是静默放行),红在写下的那天。
1111
1638
  *
1112
1639
  * 解析走 `<template>`:template 的内容是**惰性的**——不加载图片、不跑脚本,
1113
1640
  * 所以"先解析再检查"这个顺序本身不会触发任何东西。检查通过之后才搬进文档。
1114
1641
  */
1115
- private installOouiHtml(container: HTMLElement, uiConfig: UiConfig): void {
1116
- const artifact = uiConfig.oouiArtifact;
1117
- if (!artifact || artifact.regions.length === 0) return;
1642
+ private installFragmentHtml(container: HTMLElement, uiConfig: UiConfig): void {
1643
+ const artifact = uiConfig.fragments;
1644
+ if (!artifact || (artifact.regions.length === 0 && (artifact.degradedRegions?.length ?? 0) === 0)) return;
1118
1645
 
1646
+ const findSlotAnchor = (root: ParentNode, id: string): HTMLElement | null => {
1647
+ for (const anchor of root.querySelectorAll<HTMLElement>('[data-soma-id]')) {
1648
+ if (anchor.getAttribute(SOMA_ID_ATTR) === id) return anchor;
1649
+ }
1650
+ for (const slot of root.querySelectorAll<HTMLTemplateElement>('template[data-soma-slot]')) {
1651
+ const anchor = findSlotAnchor(slot.content, id);
1652
+ if (anchor) return anchor;
1653
+ }
1654
+ return null;
1655
+ };
1119
1656
  const doc = container.ownerDocument ?? (globalThis as { document?: Document }).document ?? null;
1120
1657
  if (!doc || typeof doc.createElement !== 'function') {
1121
1658
  // 非 DOM 容器(小程序 / RN 桥)。**说出来**:静默跳过的表现是
1122
- // "这个平台上演绎区域永远是空的",而那与"这页没写 ooui"分不开。
1659
+ // "这个平台上演绎区域永远是空的",而那与"这页没写片段"分不开。
1123
1660
  console.warn(
1124
1661
  `[soma-core][演绎] 页面 "${uiConfig.bind.obj}" 有 ${artifact.regions.length} 个演绎区域,`
1125
1662
  + '但当前容器没有 document,演绎 DOM 无法落地——'
@@ -1128,10 +1665,18 @@ export class SomaBootstrap {
1128
1665
  return;
1129
1666
  }
1130
1667
 
1668
+ // 访问期降级(KC15「降级产物」):产物带 degradedRegions 时按锚点写不可用标记,与装载期拒收同一渲染
1669
+ const degraded = artifact.degradedRegions ?? [];
1670
+ if (degraded.length > 0) {
1671
+ applyDegradedRegions(container, degraded, this.renderPorts?.regionFallback, this.localeCatalog);
1672
+ }
1673
+ const degradedAnchors = new Set(degraded.map((entry) => entry.anchor));
1674
+
1131
1675
  for (const region of artifact.regions) {
1132
- const host = this.adapter.findAnchor(container, region.anchor);
1676
+ if (degradedAnchors.has(region.anchor)) continue;
1677
+ const host = this.adapter.findAnchor(container, region.anchor) ?? findSlotAnchor(container, region.anchor);
1133
1678
  if (!host) {
1134
- // 构建期已对着锚点索引核过(`OOUI-SEM-ANCHOR-UNKNOWN`),这里还找不到,
1679
+ // 构建期已对着锚点索引核过(锚点未知的编译诊断),这里还找不到,
1135
1680
  // 说明 html 与 _ui.yaml 这两份资产不是同一次编译的产物。
1136
1681
  console.warn(
1137
1682
  `[soma-core][演绎] 演绎区域 "${region.anchor}" 在页面 HTML 里找不到锚点(data-soma-id)——`
@@ -1144,7 +1689,7 @@ export class SomaBootstrap {
1144
1689
  if (html.trim() === '') {
1145
1690
  console.warn(
1146
1691
  `[soma-core][演绎] 演绎区域 "${region.anchor}" 的产物里没有 html——`
1147
- + '这是一份旧格式(或手写)的 ooui_artifact。重新跑一次构建期编译'
1692
+ + '这是一份旧格式(或手写)的 fragments 载体。重新跑一次构建期编译'
1148
1693
  + '(compilePageDeclaration)即可,运行时不代为演绎。',
1149
1694
  );
1150
1695
  continue;
@@ -1154,65 +1699,71 @@ export class SomaBootstrap {
1154
1699
  // 按布尔标记的话,同一个锚点换了一份产物会被当成"已经注入过了"而跳过,
1155
1700
  // 表现是页面继续显示上一版的 DOM——渲染正常、内容是旧的、控制台一行都没有。
1156
1701
  // 与 `css_key` 用内容哈希是同一条理由,只是这一侧的作用域是单个锚点。
1157
- const fingerprint = oouiHtmlFingerprint(html);
1158
- if (host.getAttribute(SOMA_OOUI_REGION_ATTR) === fingerprint) continue;
1702
+ const fingerprint = fragmentHtmlFingerprint(html);
1703
+ if (host.getAttribute(SOMA_FRAGMENT_HOST_ATTR) === fingerprint) continue;
1159
1704
 
1160
1705
  const template = doc.createElement('template');
1161
1706
  // template 内容惰性:解析这一步不会加载资源、不会执行任何东西。
1162
1707
  template.innerHTML = html;
1163
- const offence = findOouiDomOffence(template.content);
1708
+ const offence = findFragmentDomOffence(template.content);
1164
1709
  if (offence !== null) {
1165
1710
  console.error(
1166
1711
  `[soma-core][演绎] 演绎区域 "${region.anchor}" 的产物 DOM 不在允许集内(${offence}),已拒绝注入。`
1167
1712
  + '产物随 _ui.yaml 走,而那份资产可以被手写、被改:发布期的注入面扫描虽然也扫 YAML 面,'
1168
1713
  + '但它只守"写进声明仓库"这个入口,绕过 Registry 的构建与发布后改资产都不经过它。'
1169
1714
  + '所以注入前这道结构闸门是最后一关——放行一次就等于把 innerHTML 交了出去。'
1170
- + '正常产物只含 div/span 与 class/data-soma-node/data-soma-id/data-soma-component。'
1171
- + '若这是发射器新加的合法形状,请同步 soma-bootstrap.ts 的 SOMA_OOUI_ALLOWED_TAGS / _ATTRS;'
1172
- + '否则请重新跑一次 compilePageDeclaration 生成产物,不要手写 ooui_artifact。',
1715
+ + '正常产物只含 div 与 template[data-soma-slot],以及 class、实例/显隐钩子属性。'
1716
+ + '若这是编译产物新加的合法形状,请同步 soma-bootstrap.ts 的 SOMA_FRAGMENT_ALLOWED_TAGS,属性则在 shared/hook-attributes 登记(inArtifact);'
1717
+ + '否则请重新跑一次 compilePageDeclaration 生成产物,不要手写 fragments 载体。',
1173
1718
  );
1174
1719
  continue;
1175
1720
  }
1176
1721
 
1722
+ // 统一寻址(AD-49):片段里的 data-soma-id 与页面(含其他已注入片段)合成一个 id 空间,重名拒绝注入。
1723
+ // 宿主现有子树即将被整块换掉,所以不计入「页面已有」。
1724
+ const clash = this.fragmentIdClashes(container, host, template.content);
1725
+ if (clash.length > 0) {
1726
+ const message = anchorDuplicateMessage(clash[0]!, [SOMA_ANCHOR_SITE_PAGE, anchorSiteOfFragment(region.anchor)])
1727
+ + (clash.length > 1 ? `(另有 ${clash.length - 1} 个重名 id)` : '');
1728
+ console.error(`[soma-core][演绎] 演绎区域 "${region.anchor}" 已拒绝注入:${message}`);
1729
+ this.diagnostics.recordValidation('error', message);
1730
+ continue;
1731
+ }
1732
+
1177
1733
  // 整块换掉而不是追加:锚点是产物的落点,重复挂载不该叠出两份 DOM。
1178
1734
  while (host.firstChild) host.removeChild(host.firstChild);
1179
1735
  host.appendChild(template.content);
1180
- host.setAttribute(SOMA_OOUI_REGION_ATTR, fingerprint);
1736
+ host.setAttribute(SOMA_FRAGMENT_HOST_ATTR, fingerprint);
1737
+ this.observer?.recordActivation({ kind: 'region', name: region.anchor, region: region.anchor });
1181
1738
  }
1182
1739
  }
1183
1740
 
1184
- /**
1185
- * OOUI 演绎产物注入(REQ-014 接线)。
1186
- *
1187
- * 与 `installLayoutCss` 逐点同构:运行时只认**产物**,收到声明本身只告警。
1188
- * 演绎链住在 core/build/ooui/,进 client 就等于把「运行期零演绎」这条
1189
- * 结构性承诺撤回去——而且浏览器手里根本没有候选表与组件契约,
1190
- * 代算出来的只会是一份猜的界面。
1191
- *
1192
- * 注入键用产物自带的**内容哈希**(`ooui:<sha256 前 8 位>`),不用页面名:
1193
- * `injectStyleOnce` 没有内容冲突检测(同键不同内容静默保留第一份),
1194
- * 按页面名命名的话,SPA 内路由切到同名不同产物的页面会继续用上一页的 CSS,
1195
- * 页面看着渲染正常、间距全错、控制台一行都没有。
1196
- * 位置紧接 `installLayoutCss`——都在组件实例挂载**之前**,级联顺序才稳定。
1197
- */
1198
- private installOouiArtifact(uiConfig: UiConfig): void {
1199
- const artifact = uiConfig.oouiArtifact;
1200
- if (artifact?.css && artifact.css_key) {
1201
- injectStyleOnce(
1202
- artifact.css_key,
1203
- artifact.css,
1204
- { nonce: this.componentStyleNonce ?? null },
1205
- );
1206
- return;
1741
+ /** 片段内容里与「页面其余部分」或片段自身重名的 data-soma-id(去重,保序);页面其余部分 = 容器去掉宿主现有子树 */
1742
+ private fragmentIdClashes(container: ParentNode, host: HTMLElement, fragment: ParentNode): string[] {
1743
+ const count = (scope: ParentNode, into: Map<string, number>): void => {
1744
+ for (const el of scope.querySelectorAll<HTMLElement>(`[${SOMA_ID_ATTR}]`)) {
1745
+ const id = el.getAttribute(SOMA_ID_ATTR);
1746
+ if (id) into.set(id, (into.get(id) ?? 0) + 1);
1747
+ }
1748
+ for (const slot of scope.querySelectorAll<HTMLTemplateElement>(`template[${SOMA_SLOT_ATTR}]`)) count(slot.content, into);
1749
+ };
1750
+ const page = new Map<string, number>();
1751
+ count(container, page);
1752
+ const replaced = new Map<string, number>();
1753
+ for (const child of Array.from(host.children)) {
1754
+ const own = child.getAttribute(SOMA_ID_ATTR);
1755
+ if (own) replaced.set(own, (replaced.get(own) ?? 0) + 1);
1756
+ count(child, replaced);
1757
+ if (child.hasAttribute(SOMA_SLOT_ATTR) && (child as HTMLTemplateElement).content) count((child as HTMLTemplateElement).content, replaced);
1207
1758
  }
1208
- if (artifact) return; // 有产物、只是这一版没有样式表(空间层未参与):正常,不吭声
1209
- if (uiConfig.ooui && Object.keys(uiConfig.ooui).length > 0) {
1210
- console.warn(
1211
- `[soma-core][演绎] 页面 "${uiConfig.bind.obj}" 声明了 ooui: 段但没有构建期产物(ooui_artifact)——`
1212
- + '声明未经 compilePageDeclaration 演绎,本页不会产生任何演绎界面。'
1213
- + '演绎只在构建期发生(Registry 发布 / Host 预编译),运行时不代算。',
1214
- );
1759
+ const incoming = new Map<string, number>();
1760
+ count(fragment, incoming);
1761
+ const clashes: string[] = [];
1762
+ for (const [id, times] of incoming) {
1763
+ const outside = (page.get(id) ?? 0) - (replaced.get(id) ?? 0);
1764
+ if (times > 1 || outside > 0) clashes.push(id);
1215
1765
  }
1766
+ return clashes;
1216
1767
  }
1217
1768
 
1218
1769
  /**
@@ -1265,9 +1816,8 @@ export class SomaBootstrap {
1265
1816
  if (config.url === true) {
1266
1817
  instance.onStateUpdated?.((next: SomaPageState) => {
1267
1818
  try {
1268
- const url = new URL(globalThis.location?.href ?? 'http://localhost/');
1269
- url.searchParams.set('s', encodePageState(next));
1270
- globalThis.history?.replaceState?.(null, '', url.toString());
1819
+ // 经 url-state 端口 replace(保留原 history.state:会话历史(REQ-019 S-1)靠它认出"这一项是本会话压的")
1820
+ createUrlStatePort().patch({ s: encodePageState(next) }, 'replace');
1271
1821
  } catch {
1272
1822
  /* 非浏览器环境(SSR / 测试):状态仍在内存里,只是不落 URL */
1273
1823
  }
@@ -1275,6 +1825,45 @@ export class SomaBootstrap {
1275
1825
  }
1276
1826
  }
1277
1827
 
1828
+ /**
1829
+ * 声明面钩子(WP3b-C):`state.query` 命名查询参数 ⇄ 页面路径(S6),应用配置 `a11y.motion` → 容器根
1830
+ * `data-soma-motion`(S7)。实现全在 `url-state/state-query-binding` 与 `a11y/motion-hook`,这里只接线。
1831
+ */
1832
+ private installDeclaredPageHooks(config: SomaPageStateConfig | undefined): void {
1833
+ this.disposeDeclaredPageHooks();
1834
+ const container = this.container;
1835
+ const services = this.domainInstance?._services;
1836
+ if (container && services) {
1837
+ const a11y = parseA11yAppConfig(services.config.get('a11y'));
1838
+ const hook = installMotionHook(container, a11y.motion);
1839
+ this.pageHookDisposers.push(() => hook.dispose());
1840
+ }
1841
+ const resolver = this.runtimeResolver;
1842
+ const watcher = this.propertyWatcher;
1843
+ // 信封 `query` 契约与 `state.query` 合并成一张绑定表(信封的 mode 优先,姊妹稿 §2.4)
1844
+ const queryBindings = queryBindingsFromContract(this.assets?.queryContract, config?.query);
1845
+ if (Object.keys(queryBindings).length > 0 && resolver && watcher) {
1846
+ const dispose = bindStateQuery(
1847
+ queryBindings,
1848
+ {
1849
+ read: (path) => resolver.readFromRoot(resolver.resolvePath(path)),
1850
+ write: (path, value) => { resolver.writeToRoot(path, value); this.renderEngine?.render(); },
1851
+ // 盯顶层段(前缀匹配)再重读整条路径:父对象整体替换(`page.filter = {...}`)也要同步
1852
+ watch: (path, onChange) => {
1853
+ const resolved = resolver.resolvePath(path);
1854
+ return watcher.watch(resolved.split('.')[0], () => onChange(resolver.readFromRoot(resolved)));
1855
+ },
1856
+ },
1857
+ createUrlStatePort(),
1858
+ );
1859
+ this.pageHookDisposers.push(dispose);
1860
+ }
1861
+ }
1862
+
1863
+ private disposeDeclaredPageHooks(): void {
1864
+ for (const dispose of this.pageHookDisposers.splice(0)) dispose();
1865
+ }
1866
+
1278
1867
  /** 当前路由路径;无 router 时回落 location */
1279
1868
  private routerPath(): string {
1280
1869
  const router = this.domainInstance?._services?.router;
@@ -1287,10 +1876,19 @@ export class SomaBootstrap {
1287
1876
  * 为什么在装配期查而不是运行期:运行期查的话,一个拼错的动作名要等到用户
1288
1877
  * 点了那个按钮才暴露,而暴露的形式是"点了没反应"——最难报障也最难复现的一种。
1289
1878
  */
1290
- private assertNamedActionsResolvable(events: readonly ParsedEvent[]): void {
1879
+ private assertNamedActionsResolvable(
1880
+ events: readonly ParsedEvent[],
1881
+ domain: SomaPageRoot | null = this.domainInstance,
1882
+ builtinActions: Readonly<Record<string, unknown>> | null = null,
1883
+ ): void {
1291
1884
  const missing = new Map<string, string[]>();
1292
- const check = (name: string, where: string): void => {
1293
- if (name === '' || this.namedActions[name] !== undefined) return;
1885
+ // 单条 `ACTION | 名字`(非编排)找不到应用具名动作时退到页面 Domain 同名方法(K1 ⑥,与 event-engine 同一查找序);
1886
+ // 编排步骤里的 `do: ACTION | 名字` 只认应用具名动作(step-runner 不回落 Domain)
1887
+ const domainHas = (name: string): boolean =>
1888
+ domain !== null && typeof (domain as unknown as Record<string, unknown>)[name] === 'function';
1889
+ const check = (name: string, where: string, allowDomain = false): void => {
1890
+ if (name === '' || Object.hasOwn(this.namedActions, name) || (builtinActions !== null && Object.hasOwn(builtinActions, name))) return;
1891
+ if (allowDomain && domainHas(name)) return;
1294
1892
  const list = missing.get(name) ?? [];
1295
1893
  list.push(where);
1296
1894
  missing.set(name, list);
@@ -1309,7 +1907,7 @@ export class SomaBootstrap {
1309
1907
  };
1310
1908
  for (const event of events) {
1311
1909
  const where = `${event.somaId}.${event.domEvent}`;
1312
- if (event.type === 'ACTION') check(String(event.funcPath ?? ''), where);
1910
+ if (event.type === 'ACTION') check(String(event.funcPath ?? ''), where, event.steps === undefined);
1313
1911
  if (event.steps) walkSteps(event.steps.steps, where);
1314
1912
  }
1315
1913
  if (missing.size === 0) return;
@@ -1318,9 +1916,10 @@ export class SomaBootstrap {
1318
1916
  .map(([name, wheres]) => ` "${name}" —— 用在 ${wheres.join('、')}`)
1319
1917
  .join('\n');
1320
1918
  throw new Error(
1321
- `[soma-core][引擎] 页面用到了未注册的具名动作:\n${lines}\n`
1919
+ `[SomaBootstrap] 页面用到了未注册的具名动作:\n${lines}\n`
1322
1920
  + ` 已注册:${known}\n`
1323
- + ' 在 configureSomaBootstrap 的 options.actions 里登记它们。'
1921
+ + ' 在 configureSomaBootstrap 的 options.actions(应用 browserMount.actions)里登记它们;'
1922
+ + '单条 ACTION 也可以是页面 Domain 的同名方法(编排步骤里的 ACTION 只认登记表)。'
1324
1923
  + '具名动作是 custom(script) 的替代:实现在 Host 代码里、有名字、可审计。',
1325
1924
  );
1326
1925
  }
@@ -1328,9 +1927,62 @@ export class SomaBootstrap {
1328
1927
  /**
1329
1928
  * 稳定的 data 端口壳:每次调用现取当前解析器(解析器暂缺时的兜底住在 createSomaDataPort 里,
1330
1929
  * 与端口的方法面同一处——测试守的就是这里注入的那一个端口)。
1930
+ *
1931
+ * 生成业务组件的单点命令 `command` / `commandBatch`(REQ-020 F-022 / R-039)走的也是这里的解析器取值函数:
1932
+ * 取值带数据归属代次,上一页(或热替换前)的组件手里的旧端口拿到的是 null,命令以失败结果返回,
1933
+ * 不会在新页面的数据上执行。所以转发就是这一个取值函数,不另写一份方法面。
1331
1934
  */
1332
1935
  private createStableDataPort(): SomaDataPort {
1333
- return createSomaDataPort(() => this.dataResolver);
1936
+ const owner = this.dataOwnerEpoch;
1937
+ const current = (): SomaDataObjectResolver | null => owner === this.dataOwnerEpoch ? this.dataResolver : null;
1938
+ const notReady = (action: string): { ok: false; message: string } => ({
1939
+ ok: false,
1940
+ message: `数据对象尚未就绪,无法${action}(本页可能没有在页面块声明 data:)`,
1941
+ });
1942
+ const port = {
1943
+ getObject: (name: string) => current()?.getObject(name),
1944
+ getObjectStatus: (name: string) => current()?.getObjectStatus(name),
1945
+ getDict: (name: string) => current()?.getDict(name) ?? {},
1946
+ submit: async (name: string, model: Record<string, unknown>, mode: 'create' | 'update', options?: Parameters<SomaDataObjectResolver['submit']>[3]) => {
1947
+ const resolver = current();
1948
+ if (!resolver) return notReady(`提交 "${name}"`);
1949
+ const result = await resolver.submit(name, model, mode, options);
1950
+ this.dataPolling?.arm(); // 写入后的重取可能带来新的进行中记录
1951
+ return result;
1952
+ },
1953
+ remove: async (name: string, target: Parameters<SomaDataObjectResolver['remove']>[1]) => {
1954
+ const resolver = current();
1955
+ return resolver ? resolver.remove(name, target) : notReady(`删除 "${name}" 的记录`);
1956
+ },
1957
+ reload: async (names?: readonly string[]) => {
1958
+ await current()?.reload(names === undefined ? undefined : [...names]);
1959
+ this.dataPolling?.arm();
1960
+ },
1961
+ validate: (name: string, model: Record<string, unknown>, trigger?: Parameters<SomaDataObjectResolver['validate']>[2]) =>
1962
+ current()?.validate(name, model, trigger) ?? {},
1963
+ writeOutcome: (scope: string) => this.writeOutcomeStore.get(scope),
1964
+ onWriteOutcome: (listener: (scope: string) => void) => this.writeOutcomeStore.subscribe(listener),
1965
+ clearWriteOptimistic: (scope: string, key?: string) => this.writeOutcomeStore.clearOptimistic(scope, key),
1966
+ clearOutcome: (scope: string) => this.writeOutcomeStore.clear(scope),
1967
+ };
1968
+ return port as unknown as SomaDataPort;
1969
+ }
1970
+
1971
+ /** 推送失效 → 刷新:对象 reload(依赖它的下游随 DAG 一起重取) */
1972
+ private async refreshDataObjects(owner: number, names: readonly string[]): Promise<void> {
1973
+ if (owner !== this.dataOwnerEpoch) return;
1974
+ const resolver = this.dataResolver;
1975
+ const config = this.dataConfig;
1976
+ if (!resolver || !config) return;
1977
+ const reload = names.filter((name) => config.objects[name] !== undefined);
1978
+ if (reload.length > 0) await resolver.reload(reload);
1979
+ }
1980
+
1981
+ private disposeDataSubscriptions(): void {
1982
+ this.dataSubscriptions?.dispose();
1983
+ this.dataSubscriptions = null;
1984
+ this.dataPolling?.dispose();
1985
+ this.dataPolling = null;
1334
1986
  }
1335
1987
 
1336
1988
  /** 组件管理器装配:无 components 资产时保持 null,组件能力整体旁路 */
@@ -1344,6 +1996,64 @@ export class SomaBootstrap {
1344
1996
  this.componentManager?.destroy();
1345
1997
  this.componentManager = null;
1346
1998
 
1999
+ // 一个定义都没有时组件能力整体旁路(既有行为)。
2000
+ const registry = this.buildComponentRegistry(assets);
2001
+ this.componentRegistry = registry;
2002
+ if (registry === null || registry.names().length === 0) {
2003
+ return;
2004
+ }
2005
+ this.componentManager = new SomaComponentManager({
2006
+ registry,
2007
+ scheduler: this.scheduler,
2008
+ diagnostics: this.diagnostics,
2009
+ pipeRegistry: this.pipeRegistry,
2010
+ componentDefaults: this.componentDefaults,
2011
+ styleOptions: { nonce: this.componentStyleNonce ?? null },
2012
+ treeArtifact: assets.artifact,
2013
+ observer: this.observer ?? undefined,
2014
+ i18n: this.localeCatalog,
2015
+ ...this.confirmGradedOption(),
2016
+ });
2017
+ this.componentManager.prepare(container, uiConfig);
2018
+ }
2019
+
2020
+ /**
2021
+ * 本页组件注册表:Host 级 + 页面级定义,过两道装配期闸门(REQ-009 P0)。一个定义都没有时返回 null。
2022
+ */
2023
+ /**
2024
+ * 按需组件补载:扫描本页引用到的组件名,命中 `lazyComponents` 且尚未在表里的才加载;
2025
+ * 加载出的定义模板里引用的组件名继续扫描,直到闭包补齐。
2026
+ */
2027
+ private async ensureLazyComponents(assets: SomaPageAssets): Promise<void> {
2028
+ if (Object.keys(this.lazyComponents).length === 0) return;
2029
+ const pageComponents = assets.components ?? {};
2030
+ const seen = new Set<string>();
2031
+ const queue = referencedComponentNames(assets);
2032
+ while (queue.length > 0) {
2033
+ const name = queue.pop()!;
2034
+ if (seen.has(name)) continue;
2035
+ seen.add(name);
2036
+ if (Object.hasOwn(this.hostComponents, name) || Object.hasOwn(pageComponents, name)) continue;
2037
+ const make = Object.hasOwn(this.lazyComponents, name) ? this.lazyComponents[name] : undefined;
2038
+ if (make === undefined) continue;
2039
+ let loading = this.lazyLoading.get(name);
2040
+ if (loading === undefined) {
2041
+ loading = make().then((def) => {
2042
+ if (def?.contract?.name !== name) {
2043
+ throw new Error(`[soma-core][组件] 按需组件 "${name}" 的工厂返回的定义契约名为 "${String(def?.contract?.name)}",与登记名不一致`);
2044
+ }
2045
+ return def;
2046
+ });
2047
+ this.lazyLoading.set(name, loading);
2048
+ loading.catch(() => { this.lazyLoading.delete(name); });
2049
+ }
2050
+ const def = await loading;
2051
+ this.hostComponents[name] = def;
2052
+ queue.push(...componentNamesInDefinition(def.templateHtml));
2053
+ }
2054
+ }
2055
+
2056
+ private buildComponentRegistry(assets: SomaPageAssets): SomaComponentRegistry | null {
1347
2057
  // Host 级注册(构造选项)+ 页面级资产。
1348
2058
  //
1349
2059
  // 页面同名仍然胜出(既有行为,不改),但**不再静默**:组件包体系为重名建了三道闸门
@@ -1366,10 +2076,7 @@ export class SomaBootstrap {
1366
2076
  }
1367
2077
  const defs = { ...this.hostComponents, ...pageComponents };
1368
2078
  if (Object.keys(defs).length === 0) {
1369
- // 一个组件都没有的页面不建管理器(展开、注册表、行钩子全是用不上的开销)。
1370
- // 管理器顺带做的那件事不能跟着一起没有:没走上 emit 路由的事件名告警由
1371
- // buildRuntime 里的 warnSubscriptionsWithoutComponents 单独补(见那里的注释)。
1372
- return;
2079
+ return null;
1373
2080
  }
1374
2081
 
1375
2082
  // 两道装配期闸门(REQ-009 P0):都在首屏之前跑,坏声明不进渲染。
@@ -1384,16 +2091,120 @@ export class SomaBootstrap {
1384
2091
 
1385
2092
  const registry = new SomaComponentRegistry();
1386
2093
  registry.registerAll(defs);
1387
- this.componentManager = new SomaComponentManager({
1388
- registry,
1389
- scheduler: this.scheduler,
1390
- diagnostics: this.diagnostics,
1391
- pipeRegistry: this.pipeRegistry,
1392
- componentDefaults: this.componentDefaults,
1393
- styleOptions: { nonce: this.componentStyleNonce ?? null },
1394
- treeArtifact: assets.artifact,
2094
+ return registry;
2095
+ }
2096
+
2097
+ /**
2098
+ * 区域协调作用域的装入(页面级 `scopes:`;`fragments.scopes` 在解析期已并入 `uiConfig.scopes`)。
2099
+ *
2100
+ * 先对账再装:声明自洽、点名的部件都是页面 HTML 直接声明的组件实例、实例 props 的 `region` 字面量与
2101
+ * `SCOPE` 路由点名的作用域都已声明(共享判据 `checkPageScopes`,构建期用同一份)。对不上记 error 诊断、
2102
+ * 控制台报一次,但仍装入——写权按声明核,没登记为 owner / 路径写者的实例一律写不进去,失败方向是拒绝而不是放行。
2103
+ * 无声明的页面 store 保持空,`services.region(...)` 一律取到 null。
2104
+ */
2105
+ private installRegionScopes(container: HTMLElement, uiConfig: UiConfig, events: readonly ParsedEvent[]): void {
2106
+ const scopes = uiConfig.scopes ?? uiConfig.fragments?.scopes;
2107
+ this.regionScopes.install(scopes ?? []);
2108
+ const issues = checkPageScopes({
2109
+ scopes,
2110
+ instances: this.collectPageInstanceIds(container),
2111
+ show: uiConfig.show,
2112
+ events,
2113
+ hooks: this.collectPageHookIds(container),
1395
2114
  });
1396
- this.componentManager.prepare(container, uiConfig);
2115
+ if (issues.length === 0) return;
2116
+ for (const diagnostic of scopeIssueDiagnostics(issues, { code: 'ERR-RUN-001', layer: 'run', file: uiConfig.bind.obj })) {
2117
+ const message = formatGenerationError(diagnostic);
2118
+ console.error(`[soma-core][引擎] ${message}`);
2119
+ this.diagnostics.recordValidation('error', message);
2120
+ }
2121
+ }
2122
+
2123
+ /** 页面 DOM 里全部带 `data-soma-id` 的元素的钩子 id(含 `<template data-soma-slot>` 内容;显隐门的落点集合) */
2124
+ private collectPageHookIds(root: ParentNode): Set<string> {
2125
+ const ids = new Set<string>();
2126
+ const walk = (scope: ParentNode): void => {
2127
+ for (const host of scope.querySelectorAll<HTMLElement>(`[${SOMA_ID_ATTR}]`)) {
2128
+ const id = host.getAttribute(SOMA_ID_ATTR);
2129
+ if (id) ids.add(id);
2130
+ }
2131
+ for (const slot of scope.querySelectorAll<HTMLTemplateElement>(`template[${SOMA_SLOT_ATTR}], template[${SOMA_ROLE_ATTR}]`)) walk(slot.content);
2132
+ };
2133
+ walk(root);
2134
+ return ids;
2135
+ }
2136
+
2137
+ /**
2138
+ * 区域协调的视图绑定:切片镜像写进页面状态(宿主片段里没有 `scope:` 段的组件的 prop 绑定读它),
2139
+ * 显隐门切换元素 `hidden`。在运行时与组件展开都就绪之后建;每次建运行时先解旧绑定再绑新的。
2140
+ */
2141
+ private bindRegionViews(uiConfig: UiConfig): void {
2142
+ this.regionViewsOff?.();
2143
+ this.regionViewsOff = null;
2144
+ const scopes = uiConfig.scopes ?? uiConfig.fragments?.scopes;
2145
+ const resolver = this.runtimeResolver;
2146
+ if (!this.container || !resolver || !scopes || !scopes.some((decl) => (decl.mirrors?.length ?? 0) > 0 || (decl.gates?.length ?? 0) > 0)) return;
2147
+ this.regionViewsOff = bindRegionScopeViews({
2148
+ store: this.regionScopes,
2149
+ decls: scopes,
2150
+ container: this.container,
2151
+ writeState: (path, value) => resolver.writeToRoot(path, value),
2152
+ });
2153
+ }
2154
+
2155
+ /** 页面 DOM 里直接声明的组件实例 id(含 `<template data-soma-slot>` 内容;复合组件定义模板里的子实例不在其中) */
2156
+ private collectPageInstanceIds(root: ParentNode): Set<string> {
2157
+ const ids = new Set<string>();
2158
+ const walk = (scope: ParentNode): void => {
2159
+ for (const host of scope.querySelectorAll<HTMLElement>(`[${SOMA_COMPONENT_ATTR}]`)) {
2160
+ const id = host.getAttribute(SOMA_ID_ATTR);
2161
+ if (id) ids.add(id);
2162
+ }
2163
+ for (const slot of scope.querySelectorAll<HTMLTemplateElement>(`template[${SOMA_SLOT_ATTR}], template[${SOMA_ROLE_ATTR}]`)) walk(slot.content);
2164
+ };
2165
+ walk(root);
2166
+ return ids;
2167
+ }
2168
+
2169
+ /**
2170
+ * 事件类型 `SCOPE` 的执行器:路由发起的切片写 / 窗口重取 / 语义事件。
2171
+ * 写权按发出事件的实例 id 核(与组件端口同一套规则);没有当页数据层时数据类落点报错而不静默。
2172
+ */
2173
+ private createScopeEventHandler(): SomaScopeEventHandler {
2174
+ return async (spec, { writer, payload }) => {
2175
+ switch (spec.verb) {
2176
+ case 'set':
2177
+ this.regionScopes.routeSet(spec, writer, payload);
2178
+ return;
2179
+ case 'semantic':
2180
+ this.regionScopes.emitSemantic(spec.scope, spec.semantic ?? '', payload);
2181
+ return;
2182
+ case 'session-focus':
2183
+ throw new Error(`SCOPE | session-focus | ${spec.scope}:当前不支持`);
2184
+ case 'window-reload': {
2185
+ const resolver = this.dataResolver;
2186
+ if (!resolver) throw new Error(`SCOPE | window-reload | ${spec.scope}:页面没有数据层`);
2187
+ const object = this.regionScopes.declOf(spec.scope)?.object;
2188
+ await resolver.reload(object === undefined ? undefined : [object]);
2189
+ return;
2190
+ }
2191
+ }
2192
+ };
2193
+ }
2194
+
2195
+ /**
2196
+ * 分级确认执行口(R-23),页面级与组件内事件引擎共用同一份:
2197
+ * 只有注入了通知渲染端口才把 typed / consent 交出去;否则引擎回落 plain。
2198
+ */
2199
+ private confirmGradedOption(): { confirmGraded?: (spec: SomaConfirmSpec) => boolean | Promise<boolean> } {
2200
+ if (!this.renderPorts?.notify) return {};
2201
+ return {
2202
+ confirmGraded: (spec: SomaConfirmSpec) => {
2203
+ const notify = this.domainInstance?._services?.notify;
2204
+ // 应用没开 notify.toast 时服务无渲染器(无头恒真):不能让 typed / consent 被它放行,回落 plain
2205
+ return notify?.hasRenderer ? notify.confirm(spec) : this.adapter.confirm(spec.text);
2206
+ },
2207
+ };
1397
2208
  }
1398
2209
 
1399
2210
  private async buildRuntime(parsed: ParsedRuntimeAssets): Promise<void> {
@@ -1410,6 +2221,8 @@ export class SomaBootstrap {
1410
2221
  const runtime = this.runtimeBuilder.build({
1411
2222
  container: this.container,
1412
2223
  adapter: this.adapter,
2224
+ // 分级确认(R-23):只有注入了通知渲染端口才把 typed / consent 交出去;否则引擎回落 plain
2225
+ ...this.confirmGradedOption(),
1413
2226
  uiConfig: parsed.uiConfig,
1414
2227
  eventConfig: parsed.eventConfig,
1415
2228
  triggers: parsed.triggers,
@@ -1421,8 +2234,11 @@ export class SomaBootstrap {
1421
2234
  renderMiddleware: this.renderMiddleware,
1422
2235
  eventMiddleware: this.eventMiddleware,
1423
2236
  pipeRegistry: this.pipeRegistry,
1424
- adaptiveVocabulary: this.adaptiveVocabulary,
1425
2237
  repeatPlans: this.assets?.artifact?.repeatPlans,
2238
+ // 契约 a11y 段 → 页面期地标检查(同页同 landmark 多实例须各有名且不重名);无组件时不检查
2239
+ ...(this.componentRegistry !== null
2240
+ ? { contractA11yOf: (name: string) => this.componentRegistry?.contractA11yOf(name) }
2241
+ : {}),
1426
2242
  });
1427
2243
 
1428
2244
  this.parsedTimers = parsed.timers;
@@ -1431,31 +2247,31 @@ export class SomaBootstrap {
1431
2247
  this.eventEngine = runtime.eventEngine;
1432
2248
  // 具名动作下发 + 装配期对账(AO-3)
1433
2249
  this.eventEngine.setNamedActions(this.namedActions);
1434
- this.assertNamedActionsResolvable(parsed.eventConfig);
2250
+ // MV-EVT-2:写入事件(data.submit / data.orderMove)由 core 内置动作执行并把结构化结果写回数据层
2251
+ const writeEngine = this.eventEngine;
2252
+ const builtinActions = createDataWriteActions({ resolver: () => this.dataResolver, store: this.writeOutcomeStore });
2253
+ writeEngine.setBuiltinActions(builtinActions);
2254
+ this.eventEngine.setScopeHandler(this.createScopeEventHandler());
2255
+ this.eventEngine.setRoleGate((roles) => this.domainInstance?._services?.permission?.hasAnyRole([...roles]) === true);
2256
+ this.assertNamedActionsResolvable(parsed.eventConfig, this.domainInstance, builtinActions);
1435
2257
  this.installPageState(parsed.uiConfig.state);
1436
- this.installLayoutCss(parsed.uiConfig);
1437
- this.installOouiArtifact(parsed.uiConfig);
2258
+ this.bindRegionViews(parsed.uiConfig);
1438
2259
  this.styleBinder = runtime.styleBinder;
1439
2260
  this.propertyWatcher = runtime.propertyWatcher;
2261
+ this.installDeclaredPageHooks(parsed.uiConfig.state);
1440
2262
  this.onChangeEngine = runtime.onChangeEngine;
1441
2263
  this.triggerEngine = runtime.triggerEngine;
1442
2264
  this.timerEngine = runtime.timerEngine;
1443
2265
 
1444
2266
  // 组件实例挂载(页面引擎就绪后:emit 路由标记、props watch、行内钩子)
1445
- if (this.componentManager) {
1446
- this.componentManager.activate({
1447
- container: this.container,
1448
- renderEngine: runtime.renderEngine,
1449
- eventEngine: runtime.eventEngine,
1450
- resolver: runtime.resolver,
1451
- manifest: runtime.manifest,
1452
- services: this.buildComponentServices(),
1453
- });
1454
- } else {
1455
- // 没有注册任何组件的页面:管理器不建,但它顺带做的事件名告警要补上——
1456
- // 否则 `card.reach_limit` 这种笔误在这类页面全程静默(解析期那条只认 33 个 DOM 专有名字)。
1457
- warnSubscriptionsWithoutComponents(runtime.manifest, this.container);
1458
- }
2267
+ this.componentManager?.activate({
2268
+ container: this.container,
2269
+ renderEngine: runtime.renderEngine,
2270
+ eventEngine: runtime.eventEngine,
2271
+ resolver: runtime.resolver,
2272
+ manifest: runtime.manifest,
2273
+ services: this.buildComponentServices(),
2274
+ });
1459
2275
 
1460
2276
  // 界面中途提交接线:Domain 在长任务里调 `this.publishUi()` 时,
1461
2277
  // 把此刻积累的 patch 立刻上屏而不结束事件事务(见 SomaRuntimeServices.ui)
@@ -1495,17 +2311,114 @@ export class SomaBootstrap {
1495
2311
  }
1496
2312
  }
1497
2313
 
2314
+
2315
+ // ─── 多语言(2.2a:词表 → 当前显示语言 → 文案位) ─────────────────
2316
+
2317
+ /** 词表装入文案目录(先清上一页的)并定当前显示语言:用户选定的 > 挂载选项 initial > 词表缺省语言 */
2318
+ private loadLocale(locale: SomaLocaleBundle | Record<string, unknown>): void {
2319
+ this.lastLocale = locale;
2320
+ this.localeCatalog.reset();
2321
+ this.localeCatalog.loadBundle(locale as SomaLocaleBundle | Record<string, string>);
2322
+ if (this.preferredLocale !== undefined) this.localeCatalog.setCurrentLocale(this.preferredLocale);
2323
+ }
2324
+
2325
+ /** 页面 `_locale` 绑定表(`page._locale.<键>`):词表信封取当前显示语言的词条,单字典原样 */
2326
+ private localeTable(locale: SomaLocaleBundle | Record<string, unknown>): Record<string, string> {
2327
+ // @soma-compat core-locale-single-dict
2328
+ return isLocaleBundle(locale)
2329
+ ? this.localeCatalog.dictionary()
2330
+ : locale as Record<string, string>;
2331
+ }
2332
+
2333
+ /** 缺词条回退上报(ERR-LOCALE-001,soma-ui 码表;不抛、不中断渲染) */
2334
+ private reportLocaleMissing(event: SomaLocaleMissingEvent): void {
2335
+ this.diagnostics.recordValidation(
2336
+ 'warning',
2337
+ `[ERR-LOCALE-001] 语言 "${event.locale}" 缺词条 "${event.key}",`
2338
+ + (event.fellBackTo === null ? '已返回键名。' : `已回退到 "${event.fellBackTo}"。`),
2339
+ );
2340
+ }
2341
+
2342
+ /** 文案位登记并首次渲染;之后新增的节点(组件展开、行克隆)由观察器自动登记 */
2343
+ private bindLocaleSlots(container: HTMLElement): void {
2344
+ this.stopLocaleObserver?.();
2345
+ this.localeBinder.collect(container);
2346
+ this.localeBinder.rerender(this.localeCatalog);
2347
+ this.stopLocaleObserver = this.localeBinder.observe(container, this.localeCatalog);
2348
+ }
2349
+
2350
+ private releaseLocaleSlots(): void {
2351
+ this.stopLocaleObserver?.();
2352
+ this.stopLocaleObserver = null;
2353
+ if (this.container) this.localeBinder.release(this.container);
2354
+ }
2355
+
2356
+ /** 切换显示语言后只重渲文案:文案位 + `_locale` 绑定表;不建 / 删节点、不改类名 */
2357
+ private refreshLocaleSurface(): void {
2358
+ this.preferredLocale = this.localeCatalog.currentLocale();
2359
+ this.localeBinder.rerender(this.localeCatalog);
2360
+ // @soma-compat core-locale-single-dict(单字典没有可切换的语言)
2361
+ if (this.domainInstance && isLocaleBundle(this.lastLocale)) {
2362
+ this.domainInstance._locale = this.localeTable(this.lastLocale);
2363
+ applyLocaleMetadata(this.domainInstance);
2364
+ this.renderEngine?.render();
2365
+ this.componentManager?.refreshAll();
2366
+ }
2367
+ }
2368
+
1498
2369
  private wireRouter(raw: SomaPageRoot): void {
1499
2370
  const services = raw._services;
1500
2371
  if (!services) return;
1501
2372
 
1502
2373
  this.routerUnsubscribe?.();
1503
- this.adapter.setNavigateHandler?.((url) => {
1504
- void services.router.navigate(url);
2374
+ this.adapter.setNavigateHandler?.((url, options) => {
2375
+ void services.router.navigate(url, options?.replace === true ? { replace: true } : undefined);
1505
2376
  });
1506
2377
  }
1507
2378
 
2379
+ /** 只读观测快照;未开启观测返回 null(inspect/runtime 的 observe 据此抛可辨认错误) */
2380
+ readObservation(): RuntimeObservation | null {
2381
+ return this.observer ? this.observer.snapshot() : null;
2382
+ }
2383
+
2384
+ /** `observe: true` 时创建采集器并安装浏览器全局(getter:每次读取最新快照);关闭时什么都不做 */
2385
+ private setupObserver(container: HTMLElement): void {
2386
+ if (!this.observeEnabled || this.observer !== null) return;
2387
+ this.observer = createRuntimeObserver(container, this.diagnostics);
2388
+ if (typeof window !== 'undefined') {
2389
+ Object.defineProperty(window, '__somaObserve', {
2390
+ configurable: true,
2391
+ enumerable: false,
2392
+ get: () => this.observer?.snapshot(),
2393
+ });
2394
+ // 测试 / 浏览器自动化切换显示语言的入口:同样只在观测开启时安装(生产不暴露)
2395
+ Object.defineProperty(window, '__somaSetLocale', {
2396
+ configurable: true,
2397
+ enumerable: false,
2398
+ value: (locale: string) => this.setLocale(locale),
2399
+ });
2400
+ }
2401
+ }
2402
+
2403
+ private teardownObserver(): void {
2404
+ this.observer?.dispose();
2405
+ this.observer = null;
2406
+ if (typeof window !== 'undefined' && Object.getOwnPropertyDescriptor(window, '__somaObserve')) {
2407
+ delete (window as unknown as { __somaObserve?: unknown }).__somaObserve;
2408
+ }
2409
+ if (typeof window !== 'undefined' && Object.getOwnPropertyDescriptor(window, '__somaSetLocale')) {
2410
+ delete (window as unknown as { __somaSetLocale?: unknown }).__somaSetLocale;
2411
+ }
2412
+ }
2413
+
1508
2414
  private cleanup(): void {
2415
+ this.teardownObserver();
2416
+ this.releaseLocaleSlots();
2417
+ this.regionViewsOff?.();
2418
+ this.regionViewsOff = null;
2419
+ this.regionScopes.clear();
2420
+ this.dataOwnerEpoch += 1;
2421
+ this.invalidateDataResolver();
1509
2422
  this.scheduler.cancelAll('unmount');
1510
2423
  this.stopDeclarativeTimers();
1511
2424
  this.componentManager?.destroy();
@@ -1520,10 +2433,14 @@ export class SomaBootstrap {
1520
2433
 
1521
2434
  this.routerUnsubscribe?.();
1522
2435
  this.routerUnsubscribe = null;
2436
+ this.componentRegistry = null;
2437
+ this.formatDefaultsCache = null;
2438
+ this.disposeDeclaredPageHooks();
1523
2439
 
1524
2440
  this.errorReporter?.dispose();
1525
2441
  this.errorReporter = null;
1526
2442
 
2443
+ this.disposeDataSubscriptions();
1527
2444
  this.dataConfig = null;
1528
2445
  this.dataReady = null;
1529
2446
  this.dataDicts = {};
@@ -1543,4 +2460,10 @@ export class SomaBootstrap {
1543
2460
  this.assets = null;
1544
2461
  setActiveTelemetry(null);
1545
2462
  }
2463
+
2464
+ private invalidateDataResolver(): void {
2465
+ this.dataLoadEpoch += 1;
2466
+ this.dataResolver?.dispose();
2467
+ this.dataResolver = null;
2468
+ }
1546
2469
  }