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
@@ -84,6 +84,11 @@ export interface SomaComponentManagerOptions {
84
84
  styleOptions?: PackStyleOptions;
85
85
  /** 分级确认执行口(typed / consent;与页面级事件引擎同一个,缺省则组件内回落 plain) */
86
86
  confirmGraded?: (spec: SomaConfirmSpec) => boolean | Promise<boolean>;
87
+ /**
88
+ * 旁路事件窥口:任何实例上抛契约 emit 时先调它(不要求页面 `_event` 订阅)。展示对象经 ctx.component(id).on 订阅,
89
+ * 订阅表由 bootstrap 持有(组件管理器换新、组件重新挂载后订阅仍有效)。回调抛错已隔离。
90
+ */
91
+ emitTap?: (instanceId: string, emitName: string, payload: unknown) => void;
87
92
  }
88
93
 
89
94
  /** 作用域读取器:绑定路径求值 + var 判定(页面作用域 / 行作用域两种实现) */
@@ -111,6 +116,7 @@ export class SomaComponentManager {
111
116
  private readonly observer?: Pick<SomaRuntimeObserver, 'recordActivation' | 'recordEmit'>;
112
117
  private readonly i18n?: Pick<import('../infra/i18n/II18n').II18n, 't'>;
113
118
  private readonly confirmGraded?: (spec: SomaConfirmSpec) => boolean | Promise<boolean>;
119
+ private readonly emitTap?: (instanceId: string, emitName: string, payload: unknown) => void;
114
120
  private readonly expander = new SomaComponentExpander();
115
121
  private readonly treeArtifact?: TreeArtifact;
116
122
  private readonly preparedDefinitions = new Map<string, SomaComponentDefinition>();
@@ -120,6 +126,8 @@ export class SomaComponentManager {
120
126
  private readonly instances = new Set<SomaComponentInstance>();
121
127
  private readonly hostInstances = new WeakMap<HTMLElement, SomaComponentInstance>();
122
128
  private readonly watchDisposers: Array<() => void> = [];
129
+ /** 页面级实例的「源路径 + 重推 props 闭包」;与 watchDisposers 同生同灭(destroy 整体清空,实例释放时摘除) */
130
+ private propBindings: Array<{ instance: SomaComponentInstance; sourcePaths: readonly string[]; push: () => void }> = [];
123
131
  private page: SomaComponentPageRuntime | null = null;
124
132
 
125
133
  constructor(options: SomaComponentManagerOptions) {
@@ -133,6 +141,25 @@ export class SomaComponentManager {
133
141
  this.observer = options.observer;
134
142
  this.i18n = options.i18n;
135
143
  this.confirmGraded = options.confirmGraded;
144
+ this.emitTap = options.emitTap;
145
+ }
146
+
147
+ private tap(instanceId: string, emitName: string, payload: unknown): void {
148
+ if (this.emitTap === undefined) return;
149
+ try {
150
+ this.emitTap(instanceId, emitName, payload);
151
+ } catch (error) {
152
+ console.error('[soma-core][组件] emit 窥口回调抛错(已隔离):', error);
153
+ }
154
+ }
155
+
156
+ /** 按页面 data-soma-id 或静态子组件 id 找存活实例(展示对象的组件句柄用);找不到 undefined */
157
+ findInstance(id: string): SomaComponentInstance | undefined {
158
+ for (const instance of this.instances) {
159
+ const host = instance.getHost();
160
+ if (host.getAttribute('data-soma-id') === id || host.getAttribute(SOMA_CHILD_COMPONENT_ID_ATTR) === id) return instance;
161
+ }
162
+ return undefined;
136
163
  }
137
164
 
138
165
  /**
@@ -219,8 +246,36 @@ export class SomaComponentManager {
219
246
  * 组件的 ctrl 派生 getter 本来就是幂等的纯读,重算一遍是安全的。
220
247
  */
221
248
  refreshAll(): void {
222
- for (const instance of this.instances) {
223
- instance.refresh();
249
+ for (const instance of [...this.instances]) {
250
+ try {
251
+ instance.refresh();
252
+ } catch (error) {
253
+ console.error('[soma-core][组件] refresh 抛错(已隔离,继续下一个实例):', error);
254
+ }
255
+ }
256
+ }
257
+
258
+ /**
259
+ * 这些源路径下的数据对象没有被替换、但其上的非响应式信息变了(如读状态以不可枚举属性改写):
260
+ * 给绑定到这些路径(相同、之下、或绑定了更上层对象)的页面级实例重新解析并下推一次 props。
261
+ * 只重推 props,不触发页面渲染,也不触发响应式监听;行内实例不在此列。
262
+ * `prefixes` 是已归一的源路径(如 `data.<对象名>`)。
263
+ */
264
+ refreshPropsBoundTo(prefixes: readonly string[]): void {
265
+ if (prefixes.length === 0) return;
266
+ for (const binding of [...this.propBindings]) {
267
+ if (!this.instances.has(binding.instance)) continue;
268
+ const hit = binding.sourcePaths.some((p) => prefixes.some((prefix) =>
269
+ p === prefix
270
+ || p.startsWith(`${prefix}.`) || prefix.startsWith(`${p}.`)
271
+ // 带方括号下标的路径(如 data.orders[0].x)同样按层级前缀命中
272
+ || p.startsWith(`${prefix}[`) || prefix.startsWith(`${p}[`)));
273
+ if (!hit) continue;
274
+ try {
275
+ binding.push();
276
+ } catch (error) {
277
+ console.error('[soma-core][组件] 重推 props 抛错(已隔离,继续下一个实例):', error);
278
+ }
224
279
  }
225
280
  }
226
281
 
@@ -246,9 +301,14 @@ export class SomaComponentManager {
246
301
  if (pageRoot) revokeSomaProjections(pageRoot);
247
302
  for (const root of roots) revokeSomaProjections(root);
248
303
  for (const dispose of this.watchDisposers) {
249
- dispose();
304
+ try {
305
+ dispose();
306
+ } catch (error) {
307
+ console.warn('[soma-core][组件] watch 释放失败(已隔离):', error);
308
+ }
250
309
  }
251
310
  this.watchDisposers.length = 0;
311
+ this.propBindings = [];
252
312
  if (pageRoot) this.releaseSubtree(pageRoot);
253
313
  for (const root of roots) this.releaseSubtree(root);
254
314
  const ordered = [...this.instances].map(instance => {
@@ -257,7 +317,11 @@ export class SomaComponentManager {
257
317
  return { instance, depth };
258
318
  }).sort((first, second) => second.depth - first.depth);
259
319
  for (const { instance } of ordered) {
260
- this.releaseHost(instance.getHost());
320
+ try {
321
+ this.releaseHost(instance.getHost());
322
+ } catch (error) {
323
+ console.warn('[soma-core][组件] 宿主释放失败(已隔离):', error);
324
+ }
261
325
  }
262
326
  for (const { host } of this.staticDecls) {
263
327
  host.removeAttribute(SOMA_COMPONENT_ATTR);
@@ -290,7 +354,11 @@ export class SomaComponentManager {
290
354
  }
291
355
  // 被摘除的行根元素自己就可能是组件宿主(行模板根 = 组件)
292
356
  for (const host of hosts) {
293
- this.releaseHost(host);
357
+ try {
358
+ this.releaseHost(host);
359
+ } catch (error) {
360
+ console.warn('[soma-core][组件] 宿主释放失败(已隔离):', error);
361
+ }
294
362
  }
295
363
  }
296
364
 
@@ -301,6 +369,7 @@ export class SomaComponentManager {
301
369
  }
302
370
  this.hostInstances.delete(host);
303
371
  this.instances.delete(instance);
372
+ if (this.propBindings.length > 0) this.propBindings = this.propBindings.filter((b) => b.instance !== instance);
304
373
  instance.destroy();
305
374
  }
306
375
 
@@ -416,7 +485,10 @@ export class SomaComponentManager {
416
485
  mountChild: (owner, childHost, childProps, nestedRow) =>
417
486
  this.applyChildComponent(owner, childHost, childProps, nestedRow),
418
487
  releaseSubtree: (removedRoot) => this.releaseSubtree(removedRoot),
419
- dispatchEmit: (emitName, payload) => parent.dispatchChildEmit(childId, element, emitName, payload),
488
+ dispatchEmit: (emitName, payload) => {
489
+ this.tap(childId, emitName, payload);
490
+ parent.dispatchChildEmit(childId, element, emitName, payload);
491
+ },
420
492
  });
421
493
  this.instances.add(child);
422
494
  this.hostInstances.set(element, child);
@@ -561,6 +633,7 @@ export class SomaComponentManager {
561
633
 
562
634
  /** 页面订阅了的契约 emit → 走页面 Pipeline;未订阅静默丢弃(契约规范第 4 章) */
563
635
  private dispatchEmit(instanceId: string, host: HTMLElement, emitName: string, payload: unknown): void {
636
+ this.tap(instanceId, emitName, payload);
564
637
  this.observer?.recordEmit({ component: this.hostInstances.get(host)?.def.contract.name ?? instanceId, event: emitName });
565
638
  const config = this.page?.manifest.eventIndex.get(`${emitName}:${instanceId}`);
566
639
  if (!config?.emitRoute || !this.page) {
@@ -664,10 +737,12 @@ export class SomaComponentManager {
664
737
  if (!watchedPaths.has(ancestor)) watchedPaths.set(ancestor, false);
665
738
  }
666
739
  }
740
+ const push = (): void => {
741
+ instance.setProps(withPreparedStructureProps(decl.host, resolveProps(decl.propsDecl, reader, decl.def), decl.propsDecl));
742
+ };
743
+ if (sourcePaths.length > 0) this.propBindings.push({ instance, sourcePaths, push });
667
744
  for (const [path, prefix] of watchedPaths) {
668
- const dispose = page.renderEngine.watch(path, () => {
669
- instance.setProps(withPreparedStructureProps(decl.host, resolveProps(decl.propsDecl, reader, decl.def), decl.propsDecl));
670
- }, { prefix });
745
+ const dispose = page.renderEngine.watch(path, push, { prefix });
671
746
  this.watchDisposers.push(dispose);
672
747
  }
673
748
  }
@@ -955,6 +1030,17 @@ export class SomaComponentInstance {
955
1030
  }
956
1031
  }
957
1032
 
1033
+ /**
1034
+ * 展示对象的调用口:调控制器以 `handle` 公开的方法。
1035
+ * 组件把「可被上层对象调用」的方法放在 ctrl.handle 上(对象 { 方法名: 函数 }),不公开的内部方法不可达。
1036
+ */
1037
+ callHandle(method: string, args: readonly unknown[]): { readonly found: true; readonly result?: unknown } | { readonly found: true; readonly missing: true } {
1038
+ const ctrl = this.scopeRoot[SOMA_COMPONENT_CTRL_KEY] as { handle?: Record<string, unknown> } | undefined;
1039
+ const fn = ctrl?.handle?.[method];
1040
+ if (typeof fn !== 'function') return { found: true, missing: true };
1041
+ return { found: true, result: (fn as (...a: unknown[]) => unknown).apply(ctrl!.handle, [...args]) };
1042
+ }
1043
+
958
1044
  getScopeRoot(): Record<string, unknown> {
959
1045
  return this.scopeRoot;
960
1046
  }
@@ -1061,10 +1147,18 @@ export class SomaComponentInstance {
1061
1147
  } catch (error) {
1062
1148
  console.warn('[soma-core][组件] onUnmount 失败:', error);
1063
1149
  }
1064
- this.eventEngine.destroy();
1065
- this.renderEngine.setComponentHook(null);
1066
- this.renderEngine.setComponentReleaseHook(null);
1067
- this.renderEngine.destroy();
1150
+ try {
1151
+ this.eventEngine.destroy();
1152
+ } catch (error) {
1153
+ console.warn('[soma-core][组件] eventEngine 销毁失败(已隔离):', error);
1154
+ }
1155
+ try {
1156
+ this.renderEngine.setComponentHook(null);
1157
+ this.renderEngine.setComponentReleaseHook(null);
1158
+ this.renderEngine.destroy();
1159
+ } catch (error) {
1160
+ console.warn('[soma-core][组件] renderEngine 销毁失败(已隔离):', error);
1161
+ }
1068
1162
  this.staticChildren.length = 0;
1069
1163
  }
1070
1164
  }
@@ -1079,15 +1173,12 @@ function collectRowScopes(rowData: unknown): SomaRowScope[] {
1079
1173
 
1080
1174
  /**
1081
1175
  * prop 声明值求值规则(DSL 扩展规范第 2 章):
1082
- * - 字符串:`!path` → 布尔取反;首段是已注册 var → 绑定路径;否则字面量字符串
1176
+ * - 字符串:首段是已注册 var → 绑定路径(纯读取,页面不取反);否则字面量字符串
1083
1177
  * - number / boolean → 字面量
1084
1178
  * - 数组 / 普通对象 → 逐项递归
1085
1179
  */
1086
1180
  function resolvePropValue(value: unknown, reader: ScopeReader): unknown {
1087
1181
  if (typeof value === 'string') {
1088
- if (value.startsWith('!')) {
1089
- return !reader.read(value.slice(1));
1090
- }
1091
1182
  if (reader.hasVar(value.split('.')[0])) {
1092
1183
  return reader.read(value);
1093
1184
  }
@@ -1207,9 +1298,8 @@ function collectBindingPaths(
1207
1298
  into: Set<string>,
1208
1299
  ): void {
1209
1300
  if (typeof value === 'string') {
1210
- const raw = value.startsWith('!') ? value.slice(1) : value;
1211
- if (resolver.hasVar(raw.split('.')[0])) {
1212
- into.add(raw);
1301
+ if (resolver.hasVar(value.split('.')[0])) {
1302
+ into.add(value);
1213
1303
  }
1214
1304
  return;
1215
1305
  }
@@ -167,7 +167,6 @@ interface VisibleTitleNameBinding {
167
167
  readonly titleIdProp: string;
168
168
  readonly titleProp: string;
169
169
  readonly whenProp?: string;
170
- readonly whenNegated: boolean;
171
170
  }
172
171
 
173
172
  const visibleTitleNameBindings = new WeakMap<SomaComponentDefinition, VisibleTitleNameBinding | null>();
@@ -178,8 +177,7 @@ function hasVisibleTitleReference(definition: SomaComponentDefinition, props: Re
178
177
  const titleId = props[binding.titleIdProp];
179
178
  if (!isNonEmptyText(titleId) || /\s/.test(titleId) || !isNonEmptyText(props[binding.titleProp])) return false;
180
179
  if (!binding.whenProp) return true;
181
- const visible = Boolean(props[binding.whenProp]);
182
- return binding.whenNegated ? !visible : visible;
180
+ return Boolean(props[binding.whenProp]);
183
181
  }
184
182
 
185
183
  function visibleTitleBindingOf(definition: SomaComponentDefinition): VisibleTitleNameBinding | undefined {
@@ -216,14 +214,12 @@ function visibleTitleBindingOf(definition: SomaComponentDefinition): VisibleTitl
216
214
  const titleProp = propNameOf(titleConfig.props?.text);
217
215
  if (!titleProp) return invalid();
218
216
  let whenProp: string | undefined;
219
- let whenNegated = false;
220
217
  if (titleConfig.when !== undefined) {
221
218
  if (typeof titleConfig.when !== 'string') return invalid();
222
- whenNegated = titleConfig.when.startsWith('!');
223
- whenProp = propNameOf(whenNegated ? titleConfig.when.slice(1) : titleConfig.when);
219
+ whenProp = propNameOf(titleConfig.when);
224
220
  if (!whenProp) return invalid();
225
221
  }
226
- const binding: VisibleTitleNameBinding = { titleIdProp, titleProp, whenProp, whenNegated };
222
+ const binding: VisibleTitleNameBinding = { titleIdProp, titleProp, whenProp };
227
223
  visibleTitleNameBindings.set(definition, binding);
228
224
  return binding;
229
225
  }
@@ -1,5 +1,5 @@
1
1
  import type { IContainerAdapter, SomaAnchorStats } from './IContainerAdapter';
2
- import { sanitizeAttributeWrite } from '../security/url-guard';
2
+ import { hasBlockedScheme, sanitizeAttributeWrite } from '../security/url-guard';
3
3
  import { shouldRemoveAttribute } from '../security/attribute-presence';
4
4
  import { sanitizeSomaHtml } from '../security/html-sanitizer';
5
5
  import { SOMA_ID_ATTR, SOMA_INCLUDE_ATTR, SOMA_ROLE_ATTR } from '../../shared/hook-attributes';
@@ -158,6 +158,14 @@ export class SomaContainerAdapter implements IContainerAdapter {
158
158
  }
159
159
 
160
160
  navigate(url: string, options?: { replace?: boolean }): void {
161
+ if (typeof url !== 'string' || url.trim() === '') {
162
+ return;
163
+ }
164
+ const trimmed = url.trim();
165
+ if (/[\u0000-\u001f\u007f]/.test(trimmed) || /^[\/\\]{2}/.test(trimmed) || trimmed.startsWith('\\') || hasBlockedScheme('href', trimmed)) {
166
+ console.warn(`[soma-core][安全] 拦截危险或非法导航目标: "${url.slice(0, 80)}"`);
167
+ return;
168
+ }
161
169
  if (this.navigateHandler) {
162
170
  this.navigateHandler(url, options);
163
171
  return;