soma-core 2.2.4 → 2.2.6

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 (259) hide show
  1. package/README.md +5 -6
  2. package/bin/soma.cjs +2 -2
  3. package/core/build/compiler/flat-page.ts +16 -0
  4. package/core/build/compiler/full-manifest-builder.ts +0 -3
  5. package/core/build/compiler/page-assets.ts +0 -1
  6. package/core/build/compiler/page-closure.ts +245 -0
  7. package/core/build/compiler/page-declaration-compiler.ts +2 -5
  8. package/core/build/compiler/soma-precompile.js +1848 -3244
  9. package/core/build/compiler/soma-precompile.ts +4 -7
  10. package/core/build/component-tree/artifact-codec.ts +4 -8
  11. package/core/build/lsp/soma-declaration.cjs +1 -1
  12. package/core/build/lsp/std-completion.generated.json +3 -3
  13. package/core/client/a11y/a11y-config.ts +2 -1
  14. package/core/client/a11y/dom-id.ts +1 -1
  15. package/core/client/base/SomaHttpClient.ts +11 -3
  16. package/core/client/base/SomaPageRootBase.ts +6 -0
  17. package/core/client/base/defineSomaView.ts +178 -0
  18. package/core/client/base/index.ts +13 -0
  19. package/core/client/base/view-context.ts +328 -0
  20. package/core/client/behavior/adapter-collection.ts +2 -2
  21. package/core/client/compiler/manifest-compiler.ts +5 -36
  22. package/core/client/component/component-definition.types.ts +2 -1
  23. package/core/client/component/component-manager.ts +110 -20
  24. package/core/client/component/structure-adapter.ts +3 -7
  25. package/core/client/container/SomaContainerAdapter.ts +9 -1
  26. package/core/client/data/data-object-resolver.ts +516 -181
  27. package/core/client/data/data-write-actions.ts +79 -15
  28. package/core/client/data/format-config.ts +3 -1
  29. package/core/client/data/region-scope-port.ts +11 -0
  30. package/core/client/engine/asset-resolver.ts +2 -5
  31. package/core/client/engine/dom-renderer.ts +7 -40
  32. package/core/client/engine/event-engine.ts +1 -105
  33. package/core/client/engine/property-watcher.ts +1 -1
  34. package/core/client/engine/reactive-proxy.ts +78 -17
  35. package/core/client/engine/runtime-builder.ts +0 -14
  36. package/core/client/engine/scope-resolver.ts +18 -0
  37. package/core/client/engine/soma-bootstrap.ts +385 -98
  38. package/core/client/engine/style-binder.ts +49 -106
  39. package/core/client/engine/timer-engine.ts +11 -1
  40. package/core/client/host-bridge/load-host-domain-class.ts +2 -1
  41. package/core/client/infra/http/SomaHttpService.ts +15 -4
  42. package/core/client/infra/i18n/pack-locales.ts +2 -2
  43. package/core/client/mount/domain-rule.ts +7 -3
  44. package/core/client/mount/mount-page.ts +38 -5
  45. package/core/client/mount/types.ts +2 -0
  46. package/core/client/parser/confirm-spec.ts +1 -1
  47. package/core/client/parser/data-config-parser.ts +27 -210
  48. package/core/client/parser/pipeline-parser.ts +14 -59
  49. package/core/client/parser/style-config-parser.ts +101 -95
  50. package/core/client/parser/timer-parser.ts +21 -0
  51. package/core/client/parser/ui-config-parser.ts +64 -12
  52. package/core/client/registry/declaration-renderer.ts +1 -1
  53. package/core/client/runtime/SomaRuntimeServices.ts +2 -1
  54. package/core/client/runtime/SomaSnapshotStore.ts +5 -0
  55. package/core/client/security/url-guard.ts +71 -11
  56. package/core/client/validation/async-check-registry.ts +2 -1
  57. package/core/client/validation/contract-validator.ts +2 -6
  58. package/core/client/validation/field-rules.ts +3 -13
  59. package/core/client/validation/object-rules.ts +2 -10
  60. package/core/index.ts +1 -35
  61. package/core/inspect/check-product.ts +5 -5
  62. package/core/inspect/runtime.ts +2 -1
  63. package/core/server/api/dispatch-service-api.ts +35 -36
  64. package/core/server/api/load-host-service.ts +5 -4
  65. package/core/server/compile-port.ts +1 -1
  66. package/core/server/host/app-config-composer.ts +2 -1
  67. package/core/server/host/host-assembly-entry.ts +1 -0
  68. package/core/server/host/host-assembly.ts +47 -3
  69. package/core/server/host/host-caller.ts +2 -1
  70. package/core/server/host/host-dir.ts +9 -0
  71. package/core/server/host/host-response-headers.ts +2 -1
  72. package/core/server/host/invoke-host-request-hook.ts +28 -4
  73. package/core/server/host/published-page-assets.ts +2 -1
  74. package/core/server/host/resolve-host-request-hook.ts +25 -7
  75. package/core/server/host/server-page-assets.ts +4 -4
  76. package/core/server/host/virtual-pages.ts +3 -2
  77. package/core/server/infra/cache/ServerFileCache.ts +79 -9
  78. package/core/server/registry/api-registry-store.ts +3 -1
  79. package/core/server/registry/declaration-precompiler.ts +0 -2
  80. package/core/server/registry/page-registry-repository.ts +2 -1
  81. package/core/server/registry/page-registry-store.ts +2 -1
  82. package/core/server/registry/registry-error.ts +6 -1
  83. package/core/server/registry/registry-file-lock.ts +296 -23
  84. package/core/server/registry/request-body-limit.ts +3 -2
  85. package/core/server/registry/validation/declaration-safety-scan.ts +151 -27
  86. package/core/server/runtime-space/access-gate.ts +21 -7
  87. package/core/server/runtime-space/bindings.ts +3 -6
  88. package/core/server/runtime-space/dynamic-pages.ts +181 -49
  89. package/core/server/runtime-space/errors.ts +3 -0
  90. package/core/server/runtime-space/inject.ts +74 -15
  91. package/core/server/runtime-space/page-grants.ts +7 -1
  92. package/core/server/runtime-space/resolve.ts +66 -19
  93. package/core/server/runtime-space/store.ts +32 -3
  94. package/core/server/runtime-space/submit-steps.ts +2 -1
  95. package/core/server/runtime-space/types.ts +3 -1
  96. package/core/shared/component-tree-errors.ts +2 -1
  97. package/core/shared/contract-a11y.ts +1 -1
  98. package/core/shared/contract-sections.ts +2 -2
  99. package/core/shared/core-diagnostic-codes.ts +8 -0
  100. package/core/shared/declaration-keys.ts +1 -1
  101. package/core/shared/engines/engine-error.ts +2 -1
  102. package/core/shared/generation-error.ts +2 -1
  103. package/core/shared/page-envelope.ts +1 -1
  104. package/core/shared/pure-binding.ts +88 -0
  105. package/core/shared/registry-generated/diagnostic-registry-index.ts +16 -19
  106. package/core/shared/registry-generated/diagnostic-registry.ts +135 -177
  107. package/core/shared/registry-generated/limits.ts +49 -13
  108. package/core/shared/registry-generated/std-grammar-completion.ts +0 -4
  109. package/core/shared/registry-generated/std-grammar-views.ts +40 -10
  110. package/core/shared/registry-generated/std-grammar.ts +42 -20
  111. package/core/shared/soma-error.ts +36 -0
  112. package/core/shared/types/compile-port.types.ts +1 -1
  113. package/core/shared/types/data-config.types.ts +17 -17
  114. package/core/shared/types/engine.types.ts +0 -3
  115. package/core/shared/types/event.types.ts +1 -11
  116. package/core/shared/types/generation-error.types.ts +5 -1
  117. package/core/shared/types/host-assembly.types.ts +7 -1
  118. package/core/shared/types/manifest.types.ts +0 -3
  119. package/core/shared/types/region-scope.types.ts +5 -1
  120. package/core/shared/types/scope-manifest.types.ts +0 -2
  121. package/core/shared/types/style-config.types.ts +21 -21
  122. package/core/shared/types/ui-config.types.ts +4 -5
  123. package/core/shared/types/watcher.types.ts +1 -1
  124. package/dist/browser/runtime-bundle.manifest.json +11 -13
  125. package/dist/browser/soma-runtime.js +2567 -2696
  126. package/dist/core/index.cjs +5446 -5486
  127. package/dist/host-native/aot-builder.cjs +46 -1
  128. package/dist/host-native/native-server.cjs +4879 -4505
  129. package/dist/lsp/component-tree.cjs +5814 -7042
  130. package/dist/types/build/compiler/full-manifest-builder.d.ts +0 -2
  131. package/dist/types/build/compiler/page-closure.d.ts +21 -0
  132. package/dist/types/build/compiler/page-declaration-compiler.d.ts +2 -4
  133. package/dist/types/build/compiler/soma-precompile.d.ts +1 -3
  134. package/dist/types/build/component-tree/artifact-codec.d.ts +0 -2
  135. package/dist/types/client/a11y/a11y-config.d.ts +2 -1
  136. package/dist/types/client/base/SomaHttpClient.d.ts +1 -1
  137. package/dist/types/client/base/SomaPageRootBase.d.ts +5 -0
  138. package/dist/types/client/base/defineSomaView.d.ts +46 -0
  139. package/dist/types/client/base/index.d.ts +2 -0
  140. package/dist/types/client/base/view-context.d.ts +136 -0
  141. package/dist/types/client/behavior/adapter-collection.d.ts +1 -1
  142. package/dist/types/client/compiler/manifest-compiler.d.ts +0 -3
  143. package/dist/types/client/component/component-definition.types.d.ts +2 -1
  144. package/dist/types/client/component/component-manager.d.ts +29 -0
  145. package/dist/types/client/data/data-object-resolver.d.ts +91 -31
  146. package/dist/types/client/data/format-config.d.ts +2 -1
  147. package/dist/types/client/engine/dom-renderer.d.ts +1 -2
  148. package/dist/types/client/engine/event-engine.d.ts +0 -7
  149. package/dist/types/client/engine/reactive-proxy.d.ts +11 -4
  150. package/dist/types/client/engine/runtime-builder.d.ts +0 -4
  151. package/dist/types/client/engine/soma-bootstrap.d.ts +44 -6
  152. package/dist/types/client/engine/style-binder.d.ts +8 -4
  153. package/dist/types/client/host-bridge/load-host-domain-class.d.ts +2 -1
  154. package/dist/types/client/mount/domain-rule.d.ts +2 -0
  155. package/dist/types/client/mount/mount-page.d.ts +2 -1
  156. package/dist/types/client/mount/types.d.ts +2 -0
  157. package/dist/types/client/parser/data-config-parser.d.ts +6 -5
  158. package/dist/types/client/parser/style-config-parser.d.ts +7 -3
  159. package/dist/types/client/parser/timer-parser.d.ts +5 -0
  160. package/dist/types/client/parser/ui-config-parser.d.ts +6 -2
  161. package/dist/types/client/runtime/SomaSnapshotStore.d.ts +2 -0
  162. package/dist/types/client/security/url-guard.d.ts +14 -0
  163. package/dist/types/client/validation/async-check-registry.d.ts +2 -1
  164. package/dist/types/client/validation/object-rules.d.ts +0 -5
  165. package/dist/types/index.d.ts +2 -7
  166. package/dist/types/inspect/runtime.d.ts +2 -1
  167. package/dist/types/server/api/dispatch-service-api.d.ts +5 -0
  168. package/dist/types/server/api/load-host-service.d.ts +1 -1
  169. package/dist/types/server/compile-port.d.ts +1 -1
  170. package/dist/types/server/host/host-assembly-entry.d.ts +1 -1
  171. package/dist/types/server/host/host-assembly.d.ts +2 -0
  172. package/dist/types/server/host/host-dir.d.ts +2 -0
  173. package/dist/types/server/host/invoke-host-request-hook.d.ts +10 -3
  174. package/dist/types/server/host/published-page-assets.d.ts +2 -1
  175. package/dist/types/server/host/resolve-host-request-hook.d.ts +18 -5
  176. package/dist/types/server/host/server-page-assets.d.ts +2 -1
  177. package/dist/types/server/infra/cache/ServerFileCache.d.ts +8 -0
  178. package/dist/types/server/registry/declaration-precompiler.d.ts +0 -1
  179. package/dist/types/server/registry/registry-error.d.ts +5 -1
  180. package/dist/types/server/registry/registry-file-lock.d.ts +30 -0
  181. package/dist/types/server/registry/request-body-limit.d.ts +3 -2
  182. package/dist/types/server/registry/validation/declaration-safety-scan.d.ts +3 -0
  183. package/dist/types/server/runtime-space/access-gate.d.ts +7 -0
  184. package/dist/types/server/runtime-space/bindings.d.ts +3 -2
  185. package/dist/types/server/runtime-space/dynamic-pages.d.ts +6 -1
  186. package/dist/types/server/runtime-space/errors.d.ts +1 -1
  187. package/dist/types/server/runtime-space/resolve.d.ts +2 -0
  188. package/dist/types/server/runtime-space/store.d.ts +8 -1
  189. package/dist/types/server/runtime-space/submit-steps.d.ts +2 -1
  190. package/dist/types/server/runtime-space/types.d.ts +3 -1
  191. package/dist/types/shared/component-tree-errors.d.ts +2 -1
  192. package/dist/types/shared/core-diagnostic-codes.d.ts +1 -1
  193. package/dist/types/shared/declaration-keys.d.ts +1 -1
  194. package/dist/types/shared/engines/engine-error.d.ts +2 -1
  195. package/dist/types/shared/generation-error.d.ts +2 -1
  196. package/dist/types/shared/pure-binding.d.ts +48 -0
  197. package/dist/types/shared/registry-generated/diagnostic-registry.d.ts +119 -158
  198. package/dist/types/shared/registry-generated/limits.d.ts +40 -10
  199. package/dist/types/shared/registry-generated/std-grammar-completion.d.ts +0 -30
  200. package/dist/types/shared/registry-generated/std-grammar-views.d.ts +97 -23
  201. package/dist/types/shared/registry-generated/std-grammar.d.ts +109 -241
  202. package/dist/types/shared/soma-error.d.ts +15 -0
  203. package/dist/types/shared/types/data-config.types.d.ts +14 -16
  204. package/dist/types/shared/types/engine.types.d.ts +0 -3
  205. package/dist/types/shared/types/event.types.d.ts +1 -7
  206. package/dist/types/shared/types/generation-error.types.d.ts +1 -1
  207. package/dist/types/shared/types/host-assembly.types.d.ts +2 -0
  208. package/dist/types/shared/types/manifest.types.d.ts +0 -3
  209. package/dist/types/shared/types/region-scope.types.d.ts +4 -1
  210. package/dist/types/shared/types/scope-manifest.types.d.ts +0 -2
  211. package/dist/types/shared/types/style-config.types.d.ts +17 -19
  212. package/dist/types/shared/types/ui-config.types.d.ts +4 -5
  213. package/host-native/bin/host-native.cjs +22 -1
  214. package/host-native/client/browser-entry.ts +44 -9
  215. package/host-native/src/aot-builder.ts +52 -0
  216. package/host-native/src/host-prepare.ts +39 -5
  217. package/host-native/src/manifest-http.ts +2 -3
  218. package/host-native/src/native-server.ts +812 -174
  219. package/host-native/src/page-http.ts +3 -3
  220. package/host-native/src/public-packages.cjs +0 -1
  221. package/host-native/src/registry-handler.ts +12 -5
  222. package/host-native/src/static-file.ts +203 -53
  223. package/package.json +3 -2
  224. package/core/client/engine/step-runner.ts +0 -212
  225. package/core/client/engine/trigger-engine.ts +0 -55
  226. package/core/client/format/zoned.ts +0 -10
  227. package/core/client/parser/step-parser.ts +0 -359
  228. package/core/client/parser/trigger-parser.ts +0 -90
  229. package/core/client/parser/value-lang.ts +0 -340
  230. package/core/client/time/instant.ts +0 -2
  231. package/core/shared/calc/coerce.ts +0 -2
  232. package/core/shared/calc/errors.ts +0 -40
  233. package/core/shared/calc/evaluator.ts +0 -113
  234. package/core/shared/calc/index.ts +0 -11
  235. package/core/shared/calc/lexer.ts +0 -189
  236. package/core/shared/calc/parser.ts +0 -193
  237. package/core/shared/calc/typer.ts +0 -171
  238. package/core/shared/date-parts.ts +0 -2
  239. package/core/shared/show-when.ts +0 -77
  240. package/core/shared/types/step.types.ts +0 -91
  241. package/core/shared/types/trigger.types.ts +0 -14
  242. package/dist/types/client/engine/step-runner.d.ts +0 -42
  243. package/dist/types/client/engine/trigger-engine.d.ts +0 -16
  244. package/dist/types/client/format/zoned.d.ts +0 -1
  245. package/dist/types/client/parser/step-parser.d.ts +0 -23
  246. package/dist/types/client/parser/trigger-parser.d.ts +0 -13
  247. package/dist/types/client/parser/value-lang.d.ts +0 -63
  248. package/dist/types/client/time/instant.d.ts +0 -1
  249. package/dist/types/shared/calc/coerce.d.ts +0 -1
  250. package/dist/types/shared/calc/errors.d.ts +0 -14
  251. package/dist/types/shared/calc/evaluator.d.ts +0 -2
  252. package/dist/types/shared/calc/index.d.ts +0 -6
  253. package/dist/types/shared/calc/lexer.d.ts +0 -19
  254. package/dist/types/shared/calc/parser.d.ts +0 -43
  255. package/dist/types/shared/calc/typer.d.ts +0 -11
  256. package/dist/types/shared/date-parts.d.ts +0 -1
  257. package/dist/types/shared/show-when.d.ts +0 -21
  258. package/dist/types/shared/types/step.types.d.ts +0 -76
  259. package/dist/types/shared/types/trigger.types.d.ts +0 -12
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # soma-core
2
2
 
3
3
  SOMA 通用运行时:core 的标准体系 = HTML + 一份 `_ui.yaml` + 组件。页面 = HTML 锚点(Soma Mark)
4
- + 一份 core 标准格式页面声明(四件套:`html/<page>.html` + 平铺 `ui/<page>_ui.yaml`(`soma: 1`)+ `event/<page>_event.yaml` + `style/<page>_style.yaml`;含 Soma Show / Flow / Timer / Data / Scope / State / Envelope / Fragment 等各子 DSL,语法见《soma DSL 语法全书》第一章总表;BDL / LCL 是方言源文件,编译成四件套后交给 core)
5
- + 组件 + 可选 Domain TS —— 声明即数据,落盘即渲染,零构建。core 不认识 BDL / LCL:方言由 soma-ui / soma-lite 在运行期
4
+ + 一份 core 标准格式页面声明(四件套:`html/<page>.html` + 平铺 `ui/<page>_ui.yaml`(`soma: 1`)+ `event/<page>_event.yaml` + `style/<page>_style.yaml`;含 Soma Show / Flow / Timer / Data / Scope / State / Envelope / Fragment 等各子 DSL,语法见《soma DSL 语法全书》第一章总表;BDL / kit 页面源是方言源文件,编译成四件套后交给 core)
5
+ + 组件 + 可选 Domain TS —— 声明即数据,落盘即渲染,零构建。core 不认识 BDL / kit 页面源:方言由 soma-ui / soma-kit 在运行期
6
6
  编译成标准格式后经 `registerSomaPage(s)` 按 URL 注入。
7
7
 
8
8
  Registry 页面以页面名作为公开根路径:注册 `myworkspace` 后直接访问 `/myworkspace`。
@@ -15,11 +15,10 @@ Host 文件页优先,Registry 页面在 Host 404 时兜底;存量 `/pages/<n
15
15
  - **编译管线**:ManifestCompiler 把页面四件套(HTML + `_ui.yaml` + `_event.yaml` + `_style.yaml`)编译为运行时 Manifest;`soma-precompile` 预编译产物
16
16
  由 `verify:precompile` 闸门看守新鲜度(`core/build/`)。
17
17
  - **渲染引擎 + 事件引擎**:Pipeline 四动词(`NAV_STATIC / NAV_ACTION / UI_REFRESH / UI_INTERACT`)
18
- + triggers/timers + confirm 段;格式化管道;作用域清单树与增量刷新
18
+ + timers + confirm 段;格式化管道;作用域清单树与增量刷新
19
19
  (`core/client/engine`、`core/client/runtime`)。
20
20
  - **组件运行时**:实例 = 迷你运行时(作用域隔离/props/emit 路由/插槽/自治生命周期),
21
- `data-soma-component` 声明接入;文件态组件包由 `loadComponentPackFromDir(dir, { name, version })`
22
- 完整装载定义、样式与 provenance,`loadComponentPackages` 仅保留为无样式定义表兼容入口。
21
+ `data-soma-component` 声明接入;组件包经 `composeComponentPacks` 合成,样式与 provenance 随包保留。
23
22
  - **数据对象层**:数据对象解析器(输入是标准格式的数据对象声明、`_ui.yaml` 顶层 `data:`;
24
23
  多接口 DAG 依赖编排/字段字典/类型双态映射/速记列/mock 样本兜底),解析结果注入 `page.data`,支持 `reloadData`(`core/client/data`)。
25
24
  窗口 `block` 缺省不写在 core:Host 装配调 `configureWindowBlockDefaults` 注入(值取 soma-design 限值表 `hostDefaults.windowBlock`),未注入即抛错。
@@ -49,7 +48,7 @@ Host 文件页优先,Registry 页面在 Host 404 时兜底;存量 `/pages/<n
49
48
  - `soma 页面 Registry 详设.md` — 页面 / API 注册中心、发布与回滚
50
49
  - `soma Runtime 扩展内部设计.md` — Runtime 扩展与跨端接入
51
50
  - `soma CLI 与 Host 工作区.md` — CLI 与 Next Host 实施方案
52
- - `soma DSL 语法全书.md` — core 标准格式与 `std-grammar` 的实现级语法参考,自成一册(对外入口是 `external-docs/soma-core原生手册.md`;BDL 归 soma-ui、LCL 归 soma-lite)
51
+ - `soma DSL 语法全书.md` — core 标准格式与 `std-grammar` 的实现级语法参考,自成一册(对外入口是 `external-docs/soma-core原生手册.md`;BDL 归 soma-ui、kit 页面源归 soma-kit)
53
52
 
54
53
  全局架构见仓库 `docs/02-系统架构/SOMA全局系统架构.md`,模块类设计见 `docs/03-类与模块/soma-core类与模块设计.md`。
55
54
 
package/bin/soma.cjs CHANGED
@@ -11,7 +11,7 @@
11
11
  *
12
12
  * 扩展命令表(Host 工程里的 `package.json` 或已装的 `soma-*` 包的 `package.json`):
13
13
  * { "soma": { "commands": { "<命令名>": "<相对该 package.json 所在目录的入口文件>" } } }
14
- * · 表由方言包(soma-ui / soma-lite 等)安装时带上,core 不在代码里点名任何方言命令;
14
+ * · 表由方言包(soma-ui / soma-kit 等)安装时带上,core 不在代码里点名任何方言命令;
15
15
  * · 这里从 Host 工程(`SOMA_HOST_DIR`,其次当前目录及其各级父目录)按命令名查表,
16
16
  * 以**子进程**执行入口文件并透传退出码——不经任何 import / require 说明符,所以 core 对方言包零依赖;
17
17
  * · 环境变量 `SOMA_EXTENSION_CLI` 显式指定一个入口文件,对所有扩展命令生效,优先于查表;
@@ -116,7 +116,7 @@ function runExtensionCommand(name, argv) {
116
116
  * 已下线的子命令 → 替代做法。入口在这里集中拦截:stderr 写明替代命令,退出码 2(与「命令不存在」的 1 区分)。
117
117
  */
118
118
  const RETIRED_COMMANDS = {
119
- init: '应用工程请在 Host 根配置 soma.app.ts(应用配置按所用方言的约定);新建组件包请使用 soma pack init <包名> [--dir <目录>]',
119
+ init: '应用工程请在 Host 根配置 soma.app.ts(应用配置按所用方言的约定);新建组件包请使用 soma pack init <包名> [--dir <目录>];soma-kit 应用请用 `npx soma-kit init <目录>`',
120
120
  'package-vscode': '请直接通过 soma lsp(或 soma-lsp)以 stdio 协议接入编辑器',
121
121
  };
122
122
 
@@ -31,6 +31,7 @@ import type { OnChangeRule } from '../../shared/types/watcher.types';
31
31
  import type { SomaPageEnvelope } from '../../shared/types/page-envelope.types';
32
32
  import type { StyleConfig } from '../../shared/types/style-config.types';
33
33
  import type { BindDeclaration, ShowMapping, UiConfig } from '../../shared/types/ui-config.types';
34
+ import { formatPageClosureIssues, inspectPageClosure } from './page-closure';
34
35
  import { buildHtmlAnchorIndex, buildUnifiedAnchorIndex, type HtmlAnchorIndex } from './html-index';
35
36
 
36
37
  /** 四件套中的一份声明:平铺 YAML 文本,或已解析对象 */
@@ -164,6 +165,16 @@ export function compileFlatPage(input: FlatPageInput): CompiledFlatPage {
164
165
  }
165
166
  }
166
167
 
168
+ // 逻辑写法与闭集外写法:同注入口一套判据(页面不留逻辑,不降级放行)
169
+ {
170
+ const closureIssues = inspectPageClosure({
171
+ ui: uiDoc,
172
+ event: readFlatDoc(input.eventYaml, 'event'),
173
+ style: readFlatDoc(input.styleYaml, 'style'),
174
+ });
175
+ if (closureIssues.length > 0) fail(formatPageClosureIssues(closureIssues));
176
+ }
177
+
167
178
  const versionProblem = checkPageFormatVersion(uiDoc[SOMA_PAGE_FORMAT_VERSION_KEY]);
168
179
  if (versionProblem !== undefined) fail(versionProblem, SOMA_PAGE_FORMAT_VERSION_KEY);
169
180
 
@@ -249,6 +260,11 @@ export function compileFlatPage(input: FlatPageInput): CompiledFlatPage {
249
260
  for (const item of uiDoc.watch as unknown[]) {
250
261
  if (!isRecord(item)) fail('watch 项必须是映射', 'watch');
251
262
  const entry = item as Record<string, unknown>;
263
+ for (const key of Object.keys(entry)) {
264
+ if (!['path', 'call', 'debounce', 'refresh'].includes(key)) {
265
+ fail(`watch 项有未知键 "${key}"(支持: path / call / debounce / refresh);watch 只把路径变化绑到 Domain 方法,条件判断归 Domain`, 'watch');
266
+ }
267
+ }
252
268
  if (typeof entry.path !== 'string' || entry.path.trim() === '') fail('watch 项缺少 path', 'watch');
253
269
  if (typeof entry.call !== 'string' || entry.call.trim() === '') fail('watch 项缺少 call', 'watch');
254
270
  const call = entry.call as string;
@@ -3,7 +3,6 @@
3
3
 
4
4
  import type { UiConfig } from '../../shared/types/ui-config.types';
5
5
  import type { ParsedEvent } from '../../shared/types/event.types';
6
- import type { PropertyTrigger } from '../../shared/types/trigger.types';
7
6
  import type { ParsedTimer } from '../../shared/types/timer.types';
8
7
  import type { StyleConfig } from '../../shared/types/style-config.types';
9
8
  import type { SomaDataConfig } from '../../shared/types/data-config.types';
@@ -28,7 +27,6 @@ export interface SomaPrecompiledPage {
28
27
  artifact?: TreeArtifact;
29
28
  uiConfig: UiConfig;
30
29
  eventConfig: ParsedEvent[];
31
- triggers: PropertyTrigger[];
32
30
  timers: ParsedTimer[];
33
31
  styleConfig?: StyleConfig;
34
32
  appConfig?: unknown;
@@ -122,7 +120,6 @@ export function precompilePage(
122
120
  ...(page.runtimeAssets.artifact ? { artifact: page.runtimeAssets.artifact } : {}),
123
121
  uiConfig: page.uiConfig,
124
122
  eventConfig: page.eventConfig,
125
- triggers: page.triggers,
126
123
  timers: page.timers,
127
124
  styleConfig: page.styleConfig,
128
125
  dataConfig: page.dataConfig,
@@ -47,7 +47,6 @@ export function compilePageAssets(
47
47
  includes: undefined,
48
48
  uiConfig: compiled.uiConfig,
49
49
  eventConfig: compiled.eventConfig,
50
- triggerConfig: compiled.triggers,
51
50
  timerConfig: compiled.timers,
52
51
  styleConfig: compiled.styleConfig,
53
52
  dataConfig: compiled.dataConfig,
@@ -0,0 +1,245 @@
1
+ // 注入口闭集守门(四件套:_ui.yaml / _event.yaml / _style.yaml)。
2
+ //
3
+ // core 是所有方言的最终执行层:不论页面来自 native / soma-ui / soma-kit / ai,只要走注册(registerSomaPage(s)、
4
+ // runtime submit、编译平铺页),就在这里按白名单过一遍。出现逻辑写法一律拒收,不降级放行:
5
+ // · CORE-INJECT-PAGE-LOGIC 命中语法真源 `std-grammar.json#pageForbiddenLogicKeys` 的逻辑键
6
+ // (对象谓词 when / rules[].when / predicates / transform / calc / derive / steps / triggers …);
7
+ // `forbiddenShape: 'object'` 的键(when)只禁对象 / 列表形,纯路径字符串是绑定,放行。
8
+ // 纯绑定违规同按此码拒收(消息带各自的细码,见 `pageForbiddenLogicKeys.pureBinding`):
9
+ // `!path` 取反(CORE-PAGE-NEGATE-FORBIDDEN)、_style states / active_state 的 condition + value 比较形
10
+ // (CORE-STYLE-COMPARE-FORBIDDEN)、bind.role_by 非纯路径(CORE-PAGE-ROLE-BY-INVALID)。
11
+ // · CORE-INJECT-PAGE-CLOSURE 其余越出闭集:顶层键、show 值形状、data 对象 / 字段 / 规则 / 来源 / 写通道键、
12
+ // 事件声明形态、样式形状(由各自既有 parser 的闭集判,本模块把它们的报错收成带码问题)。
13
+ // 页面语法里不留逻辑:业务逻辑归业务对象,交互逻辑归展示对象(Domain 页面类),页面只做视觉翻译与纯绑定。
14
+ //
15
+ // 纯函数,无 DOM、无 Node 专属 API。禁用键表读语法真源生成物,本文件不写键名字面量。
16
+
17
+ import { SOMA_STD_PAGE_FORBIDDEN_LOGIC_KEYS } from '../../shared/registry-generated/std-grammar-views';
18
+ import { parseDataConfig } from '../../client/parser/data-config-parser';
19
+ import { parseEventConfig } from '../../client/parser/pipeline-parser';
20
+ import { splitEventConfigRaw } from '../../client/parser/timer-parser';
21
+ import { parseStyleConfig } from '../../client/parser/style-config-parser';
22
+ import { parseUiConfig } from '../../client/parser/ui-config-parser';
23
+ import { SOMA_PURE_BINDING } from '../../shared/pure-binding';
24
+ import { SOMA_STANDARD_PAGE_KEYS } from '../../shared/declaration-keys';
25
+
26
+ export type SomaPageClosureCode = 'CORE-INJECT-PAGE-LOGIC' | 'CORE-INJECT-PAGE-CLOSURE';
27
+
28
+ export interface SomaPageClosureIssue {
29
+ readonly code: SomaPageClosureCode;
30
+ /** 声明内路径,形如 `ui:show.title.when` / `event:triggers` / `style:states` */
31
+ readonly path: string;
32
+ readonly message: string;
33
+ }
34
+
35
+ interface ForbiddenEntry {
36
+ readonly key: string;
37
+ readonly was: string;
38
+ readonly forbiddenShape?: string;
39
+ }
40
+
41
+ const FORBIDDEN: ReadonlyMap<string, ForbiddenEntry> = new Map(
42
+ (SOMA_STD_PAGE_FORBIDDEN_LOGIC_KEYS.keys as readonly ForbiddenEntry[]).map((entry) => [entry.key, entry]),
43
+ );
44
+
45
+ /** 纯绑定违规码:取自语法真源(negatedPath / styleComparison / roleBy 三节的 code),本文件不写字面量 */
46
+ const PURE_BINDING_CODES: ReadonlySet<string> = new Set(
47
+ [SOMA_PURE_BINDING.negatedPath.code, SOMA_PURE_BINDING.styleComparison.code, SOMA_PURE_BINDING.roleBy.code],
48
+ );
49
+
50
+ const isRecord = (value: unknown): value is Record<string, unknown> =>
51
+ value !== null && typeof value === 'object' && !Array.isArray(value);
52
+
53
+ /** 该键在该值上是不是逻辑写法:无形态限定 = 出现即是;`object` 形态 = 值不是字符串(对象 / 列表)才是 */
54
+ function isLogicKey(key: string, value: unknown): ForbiddenEntry | undefined {
55
+ const entry = FORBIDDEN.get(key);
56
+ if (entry === undefined) return undefined;
57
+ if (entry.forbiddenShape === 'object' && typeof value === 'string') return undefined;
58
+ return entry;
59
+ }
60
+
61
+ const REMEDY = '逻辑归展示对象(Domain 页面类的属性 / 方法,页面只绑定它给出的布尔值或状态)或业务对象(业务计算 / 接口)';
62
+
63
+ function logic(issues: SomaPageClosureIssue[], path: string, key: string, entry: ForbiddenEntry): void {
64
+ issues.push({
65
+ code: 'CORE-INJECT-PAGE-LOGIC',
66
+ path,
67
+ message: `页面含逻辑写法 "${key}"(${entry.was});${REMEDY}`,
68
+ });
69
+ }
70
+
71
+ /** 扫一层映射的键 */
72
+ function scanKeys(issues: SomaPageClosureIssue[], node: unknown, path: string): void {
73
+ if (!isRecord(node)) return;
74
+ for (const [key, value] of Object.entries(node)) {
75
+ const entry = isLogicKey(key, value);
76
+ if (entry !== undefined) logic(issues, `${path}.${key}`, key, entry);
77
+ }
78
+ }
79
+
80
+ /** show 树:逐层扫键;`props`(组件入参)、`class`(类名 → 路径)、`bind` 内不当作逻辑位置 */
81
+ function scanShow(issues: SomaPageClosureIssue[], mapping: unknown, path: string): void {
82
+ if (!isRecord(mapping)) return;
83
+ for (const [anchor, value] of Object.entries(mapping)) {
84
+ if (!isRecord(value)) continue;
85
+ const at = `${path}.${anchor}`;
86
+ const isGroup = /^item:.+/.test(anchor) && !('bind' in value) && !('text' in value) && !('model' in value)
87
+ && !('when' in value) && !('class' in value) && !('show' in value) && !('props' in value);
88
+ if (isGroup) {
89
+ scanShow(issues, value, at);
90
+ continue;
91
+ }
92
+ scanKeys(issues, value, at);
93
+ if (isRecord(value.show)) scanShow(issues, value.show, `${at}.show`);
94
+ }
95
+ }
96
+
97
+ function scanData(issues: SomaPageClosureIssue[], data: unknown): void {
98
+ if (!isRecord(data)) return;
99
+ for (const [name, object] of Object.entries(data)) {
100
+ const at = `ui:data.${name}`;
101
+ if (!isRecord(object)) continue;
102
+ scanKeys(issues, object, at);
103
+ if (Array.isArray(object.from)) object.from.forEach((source, i) => scanKeys(issues, source, `${at}.from[${i}]`));
104
+ if (isRecord(object.write)) {
105
+ scanKeys(issues, object.write, `${at}.write`);
106
+ for (const endpoint of ['create', 'update', 'delete']) scanKeys(issues, (object.write as Record<string, unknown>)[endpoint], `${at}.write.${endpoint}`);
107
+ }
108
+ if (isRecord(object.poll)) scanKeys(issues, object.poll, `${at}.poll`);
109
+ if (isRecord(object.fields)) {
110
+ for (const [fieldName, field] of Object.entries(object.fields)) {
111
+ scanKeys(issues, field, `${at}.fields.${fieldName}`);
112
+ if (isRecord(field) && Array.isArray(field.rules)) {
113
+ field.rules.forEach((rule, i) => scanKeys(issues, rule, `${at}.fields.${fieldName}.rules[${i}]`));
114
+ }
115
+ }
116
+ }
117
+ }
118
+ }
119
+
120
+ /**
121
+ * 事件文件:锚点名可以和逻辑键同名(如 `steps` 组件),所以这里不按名字判,按形态判——
122
+ * 逻辑键的值是数组(`triggers: [...]`、`steps: [...]`、`switch: [...]`)或对象谓词(`when: {...}`)才算;
123
+ * 嵌套映射层继续往下找;timers 条目按键判。
124
+ */
125
+ function scanEvent(issues: SomaPageClosureIssue[], node: unknown, path: string): void {
126
+ if (Array.isArray(node)) {
127
+ node.forEach((item, i) => scanEvent(issues, item, `${path}[${i}]`));
128
+ return;
129
+ }
130
+ if (!isRecord(node)) return;
131
+ for (const [key, value] of Object.entries(node)) {
132
+ const at = `${path}.${key}`;
133
+ if (key === 'timers' && Array.isArray(value)) {
134
+ value.forEach((item, i) => scanKeys(issues, item, `${at}[${i}]`));
135
+ continue;
136
+ }
137
+ const entry = FORBIDDEN.get(key);
138
+ if (entry !== undefined && (Array.isArray(value) || (entry.forbiddenShape === 'object' && typeof value !== 'string'))) {
139
+ logic(issues, at, key, entry);
140
+ continue;
141
+ }
142
+ if (typeof value === 'object' && value !== null) scanEvent(issues, value, at);
143
+ }
144
+ }
145
+
146
+ function scanStyle(issues: SomaPageClosureIssue[], style: Record<string, unknown>): void {
147
+ scanKeys(issues, style, 'style:');
148
+ for (const section of ['states', 'transitions'] as const) {
149
+ const group = style[section];
150
+ if (!isRecord(group)) continue;
151
+ for (const [anchor, rules] of Object.entries(group)) {
152
+ if (Array.isArray(rules)) rules.forEach((rule, i) => scanKeys(issues, rule, `style:${section}.${anchor}[${i}]`));
153
+ else scanKeys(issues, rules, `style:${section}.${anchor}`);
154
+ }
155
+ }
156
+ }
157
+
158
+ function closure(issues: SomaPageClosureIssue[], path: string, run: () => void): void {
159
+ try {
160
+ run();
161
+ } catch (error) {
162
+ // 纯绑定违规(`!path` 取反 / _style 比较形 / role_by 非纯路径)带自己的码:它们是页面里的逻辑写法,按 LOGIC 拒收
163
+ const pureCode = (error as { code?: unknown } | null)?.code;
164
+ issues.push({
165
+ code: typeof pureCode === 'string' && PURE_BINDING_CODES.has(pureCode) ? 'CORE-INJECT-PAGE-LOGIC' : 'CORE-INJECT-PAGE-CLOSURE',
166
+ path,
167
+ message: error instanceof Error ? error.message : String(error),
168
+ });
169
+ }
170
+ }
171
+
172
+ export interface SomaPageDocs {
173
+ readonly ui: Record<string, unknown>;
174
+ readonly event?: Record<string, unknown>;
175
+ readonly style?: Record<string, unknown>;
176
+ }
177
+
178
+ /**
179
+ * 对一页四件套(已读成映射)做闭集校验,返回全部问题(空 = 通过)。
180
+ * 先扫逻辑键(带码、带「原来是什么」),再跑各 parser 的严格闭集;两类问题分开报,调用方按 `code` 判。
181
+ */
182
+ export function inspectPageClosure(docs: SomaPageDocs): SomaPageClosureIssue[] {
183
+ const issues: SomaPageClosureIssue[] = [];
184
+ const { ui } = docs;
185
+
186
+ // 1. 逻辑键位置扫描
187
+ scanKeys(issues, ui, 'ui:');
188
+ scanShow(issues, ui.show, 'ui:show');
189
+ scanData(issues, ui.data);
190
+ if (Array.isArray(ui.watch)) ui.watch.forEach((item, i) => scanKeys(issues, item, `ui:watch[${i}]`));
191
+ scanKeys(issues, ui.bind, 'ui:bind');
192
+ scanKeys(issues, ui.state, 'ui:state');
193
+ if (docs.event !== undefined) scanEvent(issues, docs.event, 'event:');
194
+ if (docs.style !== undefined) scanStyle(issues, docs.style);
195
+
196
+ // 2. 顶层键闭集(逻辑键已在上面带码报过,不再重复)
197
+ const logicTop = new Set(issues.filter((i) => i.path.startsWith('ui:.')).map((i) => i.path.slice(4)));
198
+ for (const key of Object.keys(ui)) {
199
+ if (ui[key] === undefined) continue;
200
+ if (!(SOMA_STANDARD_PAGE_KEYS as readonly string[]).includes(key) && !logicTop.has(key)) {
201
+ issues.push({ code: 'CORE-INJECT-PAGE-CLOSURE', path: `ui:${key}`, message: `_ui.yaml 顶层不支持键 "${key}"(可用:${SOMA_STANDARD_PAGE_KEYS.join('/')})` });
202
+ }
203
+ }
204
+ if (Array.isArray(ui.watch)) {
205
+ ui.watch.forEach((item, i) => {
206
+ if (!isRecord(item)) return;
207
+ for (const key of Object.keys(item)) {
208
+ if (!['path', 'call', 'debounce', 'refresh'].includes(key) && isLogicKey(key, item[key]) === undefined) {
209
+ issues.push({ code: 'CORE-INJECT-PAGE-CLOSURE', path: `ui:watch[${i}].${key}`, message: `watch 项有未知键 "${key}"(支持: path / call / debounce / refresh)` });
210
+ }
211
+ }
212
+ });
213
+ }
214
+
215
+ // 3. 各 parser 的严格闭集(show 值形状 / bind / data / 事件 / 样式)
216
+ if (ui.show !== undefined) {
217
+ closure(issues, 'ui:show', () => {
218
+ const bind = isRecord(ui.bind) ? { obj: 'Page', var: 'page', ...ui.bind } : { obj: 'Page', var: 'page' };
219
+ const raw: Record<string, unknown> = { bind, show: ui.show };
220
+ if (ui.initProps !== undefined) raw.initProps = ui.initProps;
221
+ parseUiConfig(raw);
222
+ });
223
+ }
224
+ if (ui.data !== undefined) closure(issues, 'ui:data', () => { parseDataConfig({ data: ui.data }); });
225
+ if (docs.event !== undefined) {
226
+ closure(issues, 'event:', () => {
227
+ const { eventsRaw } = splitEventConfigRaw(docs.event);
228
+ parseEventConfig(eventsRaw as never);
229
+ });
230
+ }
231
+ if (docs.style !== undefined && Object.keys(docs.style).length > 0) {
232
+ closure(issues, 'style:', () => { parseStyleConfig(docs.style); });
233
+ }
234
+ return issues;
235
+ }
236
+
237
+ /** 把问题收成一条人读文案(码 + 路径 + 说明,逐条一行) */
238
+ export function formatPageClosureIssues(issues: readonly SomaPageClosureIssue[]): string {
239
+ return issues.map((issue) => `[${issue.code}] ${issue.path}:${issue.message}`).join(';');
240
+ }
241
+
242
+ /** 取问题里的主码:有逻辑写法报 LOGIC,否则 CLOSURE */
243
+ export function primaryPageClosureCode(issues: readonly SomaPageClosureIssue[]): SomaPageClosureCode {
244
+ return issues.some((issue) => issue.code === 'CORE-INJECT-PAGE-LOGIC') ? 'CORE-INJECT-PAGE-LOGIC' : 'CORE-INJECT-PAGE-CLOSURE';
245
+ }
@@ -5,7 +5,6 @@ import { anchorDuplicateMessage } from '../../shared/anchor-space';
5
5
  import { expandSomaHtmlIncludes } from './html-include-expander';
6
6
  import type { SomaDataConfig } from '../../shared/types/data-config.types';
7
7
  import type { ParsedEvent } from '../../shared/types/event.types';
8
- import type { PropertyTrigger } from '../../shared/types/trigger.types';
9
8
  import type { StyleConfig } from '../../shared/types/style-config.types';
10
9
  import type { ParsedTimer } from '../../shared/types/timer.types';
11
10
  import type {
@@ -45,7 +44,7 @@ import type {
45
44
 
46
45
  /**
47
46
  * 页面级装配输入:四件套。
48
- * `html` + `uiYaml`(平铺,含顶层保留键)+ `eventYaml`(事件管道 / triggers / timers)+ `styleYaml`(状态样式 / 过渡 / 页面级主题)。
47
+ * `html` + `uiYaml`(平铺,含顶层保留键)+ `eventYaml`(事件管道 / timers)+ `styleYaml`(状态样式 / 过渡 / 页面级主题)。
49
48
  * 三份声明都可以是平铺文本或已解析对象;`eventYaml` / `styleYaml` 缺省 = 该件不存在。
50
49
  */
51
50
  export interface SomaPageSource {
@@ -102,7 +101,6 @@ export interface SomaCompiledPageAssets {
102
101
  treeTrace?: ComponentTreeTrace;
103
102
  uiConfig: UiConfig;
104
103
  eventConfig: ParsedEvent[];
105
- triggers: PropertyTrigger[];
106
104
  timers: ParsedTimer[];
107
105
  styleConfig?: StyleConfig;
108
106
  dataConfig?: SomaDataConfig;
@@ -146,7 +144,7 @@ const DEFAULT_OPTIONS: SomaPageCompileOptions = { purpose: 'static' };
146
144
  * 编译一整页四件套(html + 平铺 uiYaml + eventYaml? + styleYaml?,只认 core 标准格式)。块声明、非白名单顶层键、形状不合法的侧车在唯一入口直接拒绝。
147
145
  *
148
146
  * include 展开、组件树标记、运行期 DSL 解析留在 core;page 块里白名单之外的键(方言声明)由块解析当场拒收——
149
- * 方言(soma-ui / soma-lite)在运行期把自己的页面编译成标准格式,再按 URL 注入 core。
147
+ * 方言(soma-ui / soma-kit)在运行期把自己的页面编译成标准格式,再按 URL 注入 core。
150
148
  */
151
149
  export function compilePageDeclaration(
152
150
  source: SomaPageSource,
@@ -337,7 +335,6 @@ function compilePageDeclarationInternal(
337
335
  ...(fragments ? { fragments } : {}),
338
336
  },
339
337
  eventConfig: eventBundle.events,
340
- triggers: eventBundle.triggers,
341
338
  timers: eventBundle.timers,
342
339
  ...(compiled.style !== undefined ? { styleConfig: compiled.style } : {}),
343
340
  ...(dataConfig ? { dataConfig } : {}),