soma-core 2.2.5 → 2.2.7

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 (283) 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 +1972 -3312
  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/IContainerAdapter.ts +4 -0
  26. package/core/client/container/SomaContainerAdapter.ts +52 -3
  27. package/core/client/data/data-object-resolver.ts +523 -184
  28. package/core/client/data/data-write-actions.ts +79 -15
  29. package/core/client/data/format-config.ts +3 -1
  30. package/core/client/data/region-scope-port.ts +11 -0
  31. package/core/client/engine/asset-resolver.ts +2 -5
  32. package/core/client/engine/dom-renderer.ts +7 -40
  33. package/core/client/engine/event-engine.ts +29 -108
  34. package/core/client/engine/property-watcher.ts +1 -1
  35. package/core/client/engine/reactive-proxy.ts +78 -17
  36. package/core/client/engine/runtime-builder.ts +0 -14
  37. package/core/client/engine/scope-resolver.ts +18 -0
  38. package/core/client/engine/soma-bootstrap.ts +387 -99
  39. package/core/client/engine/style-binder.ts +49 -106
  40. package/core/client/engine/timer-engine.ts +11 -1
  41. package/core/client/host-bridge/load-host-domain-class.ts +2 -1
  42. package/core/client/infra/http/SomaHttpService.ts +15 -4
  43. package/core/client/infra/i18n/pack-locales.ts +2 -2
  44. package/core/client/infra/notify/DefaultNotifyService.ts +2 -2
  45. package/core/client/mount/domain-rule.ts +7 -3
  46. package/core/client/mount/mount-page.ts +38 -5
  47. package/core/client/mount/types.ts +2 -0
  48. package/core/client/parser/confirm-spec.ts +100 -7
  49. package/core/client/parser/data-config-parser.ts +28 -211
  50. package/core/client/parser/pipeline-parser.ts +16 -60
  51. package/core/client/parser/style-config-parser.ts +101 -95
  52. package/core/client/parser/timer-parser.ts +21 -0
  53. package/core/client/parser/ui-config-parser.ts +64 -12
  54. package/core/client/registry/declaration-renderer.ts +1 -1
  55. package/core/client/render-ports/hide-transition.ts +9 -0
  56. package/core/client/render-ports/index.ts +4 -0
  57. package/core/client/render-ports/notify-renderer.ts +2 -1
  58. package/core/client/runtime/SomaRuntimeServices.ts +2 -1
  59. package/core/client/runtime/SomaSnapshotStore.ts +5 -0
  60. package/core/client/security/url-guard.ts +71 -11
  61. package/core/client/validation/async-check-registry.ts +2 -1
  62. package/core/client/validation/contract-validator.ts +2 -6
  63. package/core/client/validation/field-rules.ts +3 -13
  64. package/core/client/validation/object-rules.ts +2 -10
  65. package/core/index.ts +17 -39
  66. package/core/inspect/check-product.ts +5 -5
  67. package/core/inspect/runtime.ts +2 -1
  68. package/core/server/api/dispatch-service-api.ts +35 -36
  69. package/core/server/api/load-host-service.ts +8 -4
  70. package/core/server/api/paged-list.ts +259 -0
  71. package/core/server/compile-port.ts +1 -1
  72. package/core/server/host/app-config-composer.ts +2 -1
  73. package/core/server/host/empty-host-bootstrap.mjs +3 -0
  74. package/core/server/host/host-assembly-entry.ts +1 -0
  75. package/core/server/host/host-assembly.ts +50 -3
  76. package/core/server/host/host-caller.ts +2 -1
  77. package/core/server/host/host-dir.ts +9 -0
  78. package/core/server/host/host-response-headers.ts +2 -1
  79. package/core/server/host/invoke-host-request-hook.ts +28 -4
  80. package/core/server/host/published-page-assets.ts +2 -1
  81. package/core/server/host/resolve-host-request-hook.ts +25 -7
  82. package/core/server/host/server-page-assets.ts +4 -4
  83. package/core/server/host/source-aliases.cjs +345 -0
  84. package/core/server/host/source-aliases.ts +32 -0
  85. package/core/server/host/source-packages.cjs +1 -0
  86. package/core/server/host/virtual-pages.ts +3 -2
  87. package/core/server/infra/cache/ServerFileCache.ts +83 -10
  88. package/core/server/node.ts +10 -0
  89. package/core/server/registry/api-registry-store.ts +3 -1
  90. package/core/server/registry/declaration-precompiler.ts +0 -2
  91. package/core/server/registry/page-registry-repository.ts +2 -1
  92. package/core/server/registry/page-registry-store.ts +2 -1
  93. package/core/server/registry/registry-error.ts +6 -1
  94. package/core/server/registry/registry-file-lock.ts +296 -23
  95. package/core/server/registry/request-body-limit.ts +3 -2
  96. package/core/server/registry/validation/declaration-safety-scan.ts +151 -27
  97. package/core/server/runtime-space/access-gate.ts +21 -7
  98. package/core/server/runtime-space/bindings.ts +3 -6
  99. package/core/server/runtime-space/dynamic-pages.ts +181 -49
  100. package/core/server/runtime-space/errors.ts +3 -0
  101. package/core/server/runtime-space/inject.ts +78 -16
  102. package/core/server/runtime-space/page-grants.ts +7 -1
  103. package/core/server/runtime-space/resolve.ts +66 -19
  104. package/core/server/runtime-space/store.ts +32 -3
  105. package/core/server/runtime-space/submit-steps.ts +2 -1
  106. package/core/server/runtime-space/types.ts +3 -1
  107. package/core/shared/component-tree-errors.ts +2 -1
  108. package/core/shared/contract-a11y.ts +1 -1
  109. package/core/shared/contract-sections.ts +2 -2
  110. package/core/shared/core-diagnostic-codes.ts +14 -0
  111. package/core/shared/data-declaration-checks.ts +29 -3
  112. package/core/shared/declaration-keys.ts +1 -1
  113. package/core/shared/engines/engine-error.ts +2 -1
  114. package/core/shared/generation-error.ts +2 -1
  115. package/core/shared/page-envelope.ts +1 -1
  116. package/core/shared/pure-binding.ts +88 -0
  117. package/core/shared/registry-generated/diagnostic-registry-index.ts +21 -19
  118. package/core/shared/registry-generated/diagnostic-registry.ts +170 -177
  119. package/core/shared/registry-generated/limits.ts +65 -13
  120. package/core/shared/registry-generated/std-grammar-completion.ts +0 -4
  121. package/core/shared/registry-generated/std-grammar-views.ts +40 -10
  122. package/core/shared/registry-generated/std-grammar.ts +43 -21
  123. package/core/shared/soma-error.ts +36 -0
  124. package/core/shared/types/compile-port.types.ts +1 -1
  125. package/core/shared/types/data-config.types.ts +20 -18
  126. package/core/shared/types/engine.types.ts +0 -3
  127. package/core/shared/types/event.types.ts +10 -11
  128. package/core/shared/types/generation-error.types.ts +5 -1
  129. package/core/shared/types/host-assembly.types.ts +7 -1
  130. package/core/shared/types/manifest.types.ts +0 -3
  131. package/core/shared/types/region-scope.types.ts +5 -1
  132. package/core/shared/types/scope-manifest.types.ts +0 -2
  133. package/core/shared/types/style-config.types.ts +21 -21
  134. package/core/shared/types/ui-config.types.ts +4 -5
  135. package/core/shared/types/watcher.types.ts +1 -1
  136. package/dist/browser/runtime-bundle.manifest.json +11 -13
  137. package/dist/browser/soma-runtime.js +2733 -2712
  138. package/dist/core/index.cjs +5665 -5534
  139. package/dist/host-native/aot-builder.cjs +330 -1
  140. package/dist/host-native/native-server.cjs +5434 -4726
  141. package/dist/lsp/component-tree.cjs +5868 -7040
  142. package/dist/types/build/compiler/full-manifest-builder.d.ts +0 -2
  143. package/dist/types/build/compiler/page-closure.d.ts +21 -0
  144. package/dist/types/build/compiler/page-declaration-compiler.d.ts +2 -4
  145. package/dist/types/build/compiler/soma-precompile.d.ts +1 -3
  146. package/dist/types/build/component-tree/artifact-codec.d.ts +0 -2
  147. package/dist/types/client/a11y/a11y-config.d.ts +2 -1
  148. package/dist/types/client/base/SomaHttpClient.d.ts +1 -1
  149. package/dist/types/client/base/SomaPageRootBase.d.ts +5 -0
  150. package/dist/types/client/base/defineSomaView.d.ts +46 -0
  151. package/dist/types/client/base/index.d.ts +2 -0
  152. package/dist/types/client/base/view-context.d.ts +136 -0
  153. package/dist/types/client/behavior/adapter-collection.d.ts +1 -1
  154. package/dist/types/client/compiler/manifest-compiler.d.ts +0 -3
  155. package/dist/types/client/component/component-definition.types.d.ts +2 -1
  156. package/dist/types/client/component/component-manager.d.ts +29 -0
  157. package/dist/types/client/container/IContainerAdapter.d.ts +3 -0
  158. package/dist/types/client/container/SomaContainerAdapter.d.ts +5 -0
  159. package/dist/types/client/data/data-object-resolver.d.ts +93 -31
  160. package/dist/types/client/data/format-config.d.ts +2 -1
  161. package/dist/types/client/engine/dom-renderer.d.ts +1 -2
  162. package/dist/types/client/engine/event-engine.d.ts +0 -7
  163. package/dist/types/client/engine/reactive-proxy.d.ts +11 -4
  164. package/dist/types/client/engine/runtime-builder.d.ts +0 -4
  165. package/dist/types/client/engine/soma-bootstrap.d.ts +44 -6
  166. package/dist/types/client/engine/style-binder.d.ts +8 -4
  167. package/dist/types/client/host-bridge/load-host-domain-class.d.ts +2 -1
  168. package/dist/types/client/mount/domain-rule.d.ts +2 -0
  169. package/dist/types/client/mount/mount-page.d.ts +2 -1
  170. package/dist/types/client/mount/types.d.ts +2 -0
  171. package/dist/types/client/parser/confirm-spec.d.ts +27 -3
  172. package/dist/types/client/parser/data-config-parser.d.ts +6 -5
  173. package/dist/types/client/parser/style-config-parser.d.ts +7 -3
  174. package/dist/types/client/parser/timer-parser.d.ts +5 -0
  175. package/dist/types/client/parser/ui-config-parser.d.ts +6 -2
  176. package/dist/types/client/render-ports/hide-transition.d.ts +9 -0
  177. package/dist/types/client/render-ports/index.d.ts +4 -0
  178. package/dist/types/client/render-ports/notify-renderer.d.ts +2 -1
  179. package/dist/types/client/runtime/SomaSnapshotStore.d.ts +2 -0
  180. package/dist/types/client/security/url-guard.d.ts +14 -0
  181. package/dist/types/client/validation/async-check-registry.d.ts +2 -1
  182. package/dist/types/client/validation/object-rules.d.ts +0 -5
  183. package/dist/types/index.d.ts +6 -11
  184. package/dist/types/inspect/runtime.d.ts +2 -1
  185. package/dist/types/server/api/dispatch-service-api.d.ts +5 -0
  186. package/dist/types/server/api/load-host-service.d.ts +1 -1
  187. package/dist/types/server/api/paged-list.d.ts +101 -0
  188. package/dist/types/server/compile-port.d.ts +1 -1
  189. package/dist/types/server/host/host-assembly-entry.d.ts +1 -1
  190. package/dist/types/server/host/host-assembly.d.ts +2 -0
  191. package/dist/types/server/host/host-dir.d.ts +2 -0
  192. package/dist/types/server/host/invoke-host-request-hook.d.ts +10 -3
  193. package/dist/types/server/host/published-page-assets.d.ts +2 -1
  194. package/dist/types/server/host/resolve-host-request-hook.d.ts +18 -5
  195. package/dist/types/server/host/server-page-assets.d.ts +2 -1
  196. package/dist/types/server/host/source-aliases.d.cts +53 -0
  197. package/dist/types/server/host/source-aliases.d.ts +30 -0
  198. package/dist/types/server/host/source-packages.d.cts +2 -0
  199. package/dist/types/server/infra/cache/ServerFileCache.d.ts +8 -0
  200. package/dist/types/server/node.d.ts +1 -0
  201. package/dist/types/server/registry/declaration-precompiler.d.ts +0 -1
  202. package/dist/types/server/registry/registry-error.d.ts +5 -1
  203. package/dist/types/server/registry/registry-file-lock.d.ts +30 -0
  204. package/dist/types/server/registry/request-body-limit.d.ts +3 -2
  205. package/dist/types/server/registry/validation/declaration-safety-scan.d.ts +3 -0
  206. package/dist/types/server/runtime-space/access-gate.d.ts +7 -0
  207. package/dist/types/server/runtime-space/bindings.d.ts +3 -2
  208. package/dist/types/server/runtime-space/dynamic-pages.d.ts +6 -1
  209. package/dist/types/server/runtime-space/errors.d.ts +1 -1
  210. package/dist/types/server/runtime-space/resolve.d.ts +2 -0
  211. package/dist/types/server/runtime-space/store.d.ts +8 -1
  212. package/dist/types/server/runtime-space/submit-steps.d.ts +2 -1
  213. package/dist/types/server/runtime-space/types.d.ts +3 -1
  214. package/dist/types/shared/component-tree-errors.d.ts +2 -1
  215. package/dist/types/shared/core-diagnostic-codes.d.ts +1 -1
  216. package/dist/types/shared/declaration-keys.d.ts +1 -1
  217. package/dist/types/shared/engines/engine-error.d.ts +2 -1
  218. package/dist/types/shared/generation-error.d.ts +2 -1
  219. package/dist/types/shared/pure-binding.d.ts +48 -0
  220. package/dist/types/shared/registry-generated/diagnostic-registry.d.ts +149 -158
  221. package/dist/types/shared/registry-generated/limits.d.ts +54 -10
  222. package/dist/types/shared/registry-generated/std-grammar-completion.d.ts +0 -30
  223. package/dist/types/shared/registry-generated/std-grammar-views.d.ts +97 -23
  224. package/dist/types/shared/registry-generated/std-grammar.d.ts +110 -242
  225. package/dist/types/shared/soma-error.d.ts +15 -0
  226. package/dist/types/shared/types/data-config.types.d.ts +17 -17
  227. package/dist/types/shared/types/engine.types.d.ts +0 -3
  228. package/dist/types/shared/types/event.types.d.ts +9 -7
  229. package/dist/types/shared/types/generation-error.types.d.ts +1 -1
  230. package/dist/types/shared/types/host-assembly.types.d.ts +2 -0
  231. package/dist/types/shared/types/manifest.types.d.ts +0 -3
  232. package/dist/types/shared/types/region-scope.types.d.ts +4 -1
  233. package/dist/types/shared/types/scope-manifest.types.d.ts +0 -2
  234. package/dist/types/shared/types/style-config.types.d.ts +17 -19
  235. package/dist/types/shared/types/ui-config.types.d.ts +4 -5
  236. package/host-native/bin/host-native.cjs +22 -1
  237. package/host-native/client/browser-entry.ts +21 -172
  238. package/host-native/src/aot-builder.ts +75 -0
  239. package/host-native/src/host-prepare.ts +39 -5
  240. package/host-native/src/manifest-http.ts +2 -3
  241. package/host-native/src/native-server.ts +812 -174
  242. package/host-native/src/page-http.ts +3 -3
  243. package/host-native/src/public-packages.cjs +0 -1
  244. package/host-native/src/registry-handler.ts +12 -5
  245. package/host-native/src/static-file.ts +203 -53
  246. package/host-native/styles/globals.css +30 -28
  247. package/package.json +14 -2
  248. package/core/client/engine/step-runner.ts +0 -212
  249. package/core/client/engine/trigger-engine.ts +0 -55
  250. package/core/client/format/zoned.ts +0 -10
  251. package/core/client/parser/step-parser.ts +0 -359
  252. package/core/client/parser/trigger-parser.ts +0 -90
  253. package/core/client/parser/value-lang.ts +0 -340
  254. package/core/client/time/instant.ts +0 -2
  255. package/core/shared/calc/coerce.ts +0 -2
  256. package/core/shared/calc/errors.ts +0 -40
  257. package/core/shared/calc/evaluator.ts +0 -113
  258. package/core/shared/calc/index.ts +0 -11
  259. package/core/shared/calc/lexer.ts +0 -189
  260. package/core/shared/calc/parser.ts +0 -193
  261. package/core/shared/calc/typer.ts +0 -171
  262. package/core/shared/date-parts.ts +0 -2
  263. package/core/shared/show-when.ts +0 -77
  264. package/core/shared/types/step.types.ts +0 -91
  265. package/core/shared/types/trigger.types.ts +0 -14
  266. package/dist/types/client/engine/step-runner.d.ts +0 -42
  267. package/dist/types/client/engine/trigger-engine.d.ts +0 -16
  268. package/dist/types/client/format/zoned.d.ts +0 -1
  269. package/dist/types/client/parser/step-parser.d.ts +0 -23
  270. package/dist/types/client/parser/trigger-parser.d.ts +0 -13
  271. package/dist/types/client/parser/value-lang.d.ts +0 -63
  272. package/dist/types/client/time/instant.d.ts +0 -1
  273. package/dist/types/shared/calc/coerce.d.ts +0 -1
  274. package/dist/types/shared/calc/errors.d.ts +0 -14
  275. package/dist/types/shared/calc/evaluator.d.ts +0 -2
  276. package/dist/types/shared/calc/index.d.ts +0 -6
  277. package/dist/types/shared/calc/lexer.d.ts +0 -19
  278. package/dist/types/shared/calc/parser.d.ts +0 -43
  279. package/dist/types/shared/calc/typer.d.ts +0 -11
  280. package/dist/types/shared/date-parts.d.ts +0 -1
  281. package/dist/types/shared/show-when.d.ts +0 -21
  282. package/dist/types/shared/types/step.types.d.ts +0 -76
  283. package/dist/types/shared/types/trigger.types.d.ts +0 -12
@@ -1,5 +1,5 @@
1
1
  import type { SomaSource } from './source.types';
2
- export declare const SOMA_GENERATION_ERROR_CODES: readonly ["ERR-BIZ-001", "ERR-BIZ-002", "ERR-BIZ-003", "ERR-BIZ-004", "ERR-BIZ-005", "ERR-BIZ-006", "ERR-BIZ-007", "ERR-BIZ-008", "ERR-BIZ-009", "ERR-BIZ-010", "ERR-BIZ-011", "ERR-BIZ-012", "ERR-BIZ-013", "ERR-BIZ-014", "ERR-BIZ-015", "ERR-BIZ-016", "ERR-BIZ-017", "ERR-BIZ-018", "ERR-BIZ-019", "ERR-PAGE-001", "ERR-PAGE-002", "ERR-PAGE-003", "ERR-GEN-001", "ERR-GEN-002", "ERR-GEN-003", "ERR-GEN-004", "ERR-GEN-005", "ERR-GEN-006", "ERR-GEN-007", "ERR-GEN-008", "ERR-GEN-009", "ERR-GEN-010", "ERR-GEN-011", "ERR-PAGE-004", "ERR-GEN-015", "ERR-GEN-016", "ERR-PAGE-005", "ERR-PAGE-006", "ERR-PAGE-007", "ERR-PAGE-008", "ERR-PAGE-009", "ERR-UNIT-001", "ERR-UNIT-002", "ERR-UNIT-003", "ERR-RUN-001", "ERR-RUN-002", "ERR-RUN-003", "ERR-PUB-001", "ERR-PUB-002", "ERR-PUB-003", "ERR-AI-001", "ERR-AI-002", "ERR-AI-003", "ERR-AI-004", "ERR-APP-001", "ERR-APP-002", "ERR-APP-003", "ERR-APP-004", "ERR-APP-005", "ERR-APP-006", "ERR-APP-007", "ERR-APP-008", "ERR-APP-009", "ERR-APP-010", "ERR-APP-011", "ERR-APP-012", "ERR-APP-013", "ERR-APP-014", "ERR-APP-015", "ERR-LOCALE-001", "ERR-LOCALE-002", "ERR-LOCALE-003"];
2
+ export declare const SOMA_GENERATION_ERROR_CODES: readonly ["ERR-BIZ-001", "ERR-BIZ-002", "ERR-BIZ-003", "ERR-BIZ-004", "ERR-BIZ-005", "ERR-BIZ-006", "ERR-BIZ-007", "ERR-BIZ-008", "ERR-BIZ-009", "ERR-BIZ-010", "ERR-BIZ-011", "ERR-BIZ-012", "ERR-BIZ-013", "ERR-BIZ-014", "ERR-BIZ-015", "ERR-BIZ-016", "ERR-BIZ-017", "ERR-BIZ-018", "ERR-PAGE-001", "ERR-PAGE-002", "ERR-PAGE-003", "ERR-GEN-001", "ERR-GEN-002", "ERR-GEN-003", "ERR-GEN-004", "ERR-GEN-005", "ERR-GEN-006", "ERR-GEN-007", "ERR-GEN-008", "ERR-GEN-009", "ERR-GEN-010", "ERR-GEN-011", "ERR-PAGE-004", "ERR-GEN-015", "ERR-GEN-016", "ERR-PAGE-005", "ERR-PAGE-006", "ERR-PAGE-007", "ERR-PAGE-008", "ERR-PAGE-009", "ERR-PAGE-010", "ERR-PAGE-011", "ERR-PAGE-012", "ERR-PAGE-013", "ERR-PAGE-014", "ERR-PAGE-015", "ERR-PAGE-016", "ERR-UNIT-001", "ERR-UNIT-002", "ERR-UNIT-003", "ERR-RUN-001", "ERR-RUN-002", "ERR-RUN-003", "ERR-PUB-001", "ERR-PUB-002", "ERR-PUB-003", "ERR-AI-001", "ERR-AI-002", "ERR-AI-003", "ERR-AI-004", "ERR-APP-001", "ERR-APP-002", "ERR-APP-003", "ERR-APP-004", "ERR-APP-005", "ERR-APP-006", "ERR-APP-007", "ERR-APP-008", "ERR-APP-009", "ERR-APP-010", "ERR-APP-011", "ERR-APP-012", "ERR-APP-013", "ERR-APP-014", "ERR-APP-015", "ERR-APP-016", "ERR-APP-017", "ERR-APP-018", "ERR-APP-019", "ERR-LOCALE-001", "ERR-LOCALE-002", "ERR-LOCALE-003"];
3
3
  export type SomaGenerationErrorCode = (typeof SOMA_GENERATION_ERROR_CODES)[number];
4
4
  /** 错误发生在哪一层(与错误码前缀一一对应,另加 `page` 表示页面编译层) */
5
5
  export type SomaGenerationLayer = 'biz' | 'page' | 'need' | 'generate' | 'unit' | 'certify' | 'run' | 'publish' | 'ai' | 'app' | 'locale';
@@ -4,6 +4,8 @@ export type SomaHostAssemblyRequestHook = (request: Request, context: {
4
4
  readonly kind: 'page' | 'api';
5
5
  readonly path: string;
6
6
  readonly pageHref?: string;
7
+ /** 原生宿主可选惰性读取入口;返回副本,限流并响应客户端断连。 */
8
+ readonly readBody?: () => Promise<Uint8Array>;
7
9
  }) => Response | undefined | Promise<Response | undefined>;
8
10
  /** 虚拟页登记项(形状同 `SomaVirtualPageRegistration`) */
9
11
  export interface SomaHostAssemblyVirtualPage {
@@ -10,9 +10,6 @@ export interface SomaCompiledBinding {
10
10
  dataPath: string;
11
11
  watchPaths: string[];
12
12
  attrName?: string;
13
- negate?: boolean;
14
- /** `when` 对象谓词(type 为 when 时;路径在 dataPath);缺省 = 字符串形的真值判定 */
15
- whenTest?: import('../show-when').SomaShowWhenTest;
16
13
  classRules?: Record<string, string>;
17
14
  childShowConfig?: ShowMapping;
18
15
  /** 静态提升标记:值在初始化后不会变化,不需要注册 watchPaths */
@@ -1,3 +1,4 @@
1
+ import { SomaError } from '../soma-error';
1
2
  /** 切片名闭集(至多 8 个;真源 soma-design `pipeline/region-scope#/spec/slices/names`) */
2
3
  export declare const SOMA_REGION_SLICE_NAMES: readonly ["filter", "view", "selection", "focus", "results", "navigation", "monitor", "pending"];
3
4
  export type SomaRegionSliceName = (typeof SOMA_REGION_SLICE_NAMES)[number];
@@ -119,6 +120,8 @@ export interface SomaRegionPort {
119
120
  slice(name: SomaRegionSliceName): SomaRegionSliceHandle | null;
120
121
  /** 订阅路由上抛的语义事件(事件类型 `SCOPE | semantic`);返回退订函数 */
121
122
  onSemantic(listener: (name: string, payload: Readonly<Record<string, unknown>>) => void): () => void;
123
+ /** 发语义事件(与 `SCOPE | semantic` 管道同一条通道,订阅方是同一批);组件 / 展示对象在代码里按顺序编排时用 */
124
+ emit(name: string, payload?: Readonly<Record<string, unknown>>): void;
122
125
  }
123
126
  /** 组件端 `ctx.services.region`:按作用域 id 取端口;作用域未声明、端口已失效返回 null */
124
127
  export type SomaRegionServices = (scopeId: string) => SomaRegionPort | null;
@@ -137,7 +140,7 @@ export interface SomaScopeEventSpec {
137
140
  }
138
141
  export declare const SOMA_REGION_SCOPE_ERROR: "ERR-RUN-001";
139
142
  /** 区域协调的运行期缺陷(非 owner / 非路径写者写切片等);与 ERR-RUN-001 同级,只影响该区域 */
140
- export declare class SomaRegionScopeError extends Error {
143
+ export declare class SomaRegionScopeError extends SomaError {
141
144
  readonly code: "ERR-RUN-001";
142
145
  readonly scopeId: string;
143
146
  readonly slice: string;
@@ -29,8 +29,6 @@ export interface SomaPropBinding {
29
29
  /** 已解析的绑定路径;与 literal 二选一 */
30
30
  source?: string;
31
31
  literal?: unknown;
32
- /** 布尔 prop 的 `!` 前缀(沿用 when 语义,不引入其他运算) */
33
- negate?: boolean;
34
32
  mode: SomaPropMode;
35
33
  pipes?: SomaPipeCall[];
36
34
  }
@@ -7,16 +7,15 @@
7
7
  */
8
8
  export type SomaStyleViolationKind = 'layout-class';
9
9
  /**
10
- * 状态驱动的样式规则
11
- * 当 condition 路径的值等于 value 时,将 apply 中的类名应用到对应 DOM 节点
10
+ * 类名档位绑定(纯绑定):`bind` 路径指向展示对象的成员,成员的值就是档位名;
11
+ * 档位名命中 `tiers` 的键时,应用该档位的类名,其余档位的类名一律移除;不在闭集内时不加任何类。
12
+ * 页面不写「等于某值」的比较;档位名闭集形态与个数上限见 std-grammar.json#pageForbiddenLogicKeys.pureBinding.styleTier。
12
13
  */
13
- export interface StyleStateRule {
14
- /** 数据路径(纯属性路径,禁止逻辑表达式) */
15
- condition: string;
16
- /** 目标值(基础类型:string | number | boolean | null) */
17
- value: string | number | boolean | null;
18
- /** 匹配时应用的 CSS 类名;具体样式由宿主样式系统提供 */
19
- apply: string;
14
+ export interface StyleTierBinding {
15
+ /** 展示对象成员的纯路径(点分标识符,无取反 / 管道 / 运算符) */
16
+ bind: string;
17
+ /** 档位名 → 类名串;具体样式由宿主样式系统提供 */
18
+ tiers: Record<string, string>;
20
19
  }
21
20
  /**
22
21
  * 过渡/动画触发器类型
@@ -25,16 +24,15 @@ export type TransitionTrigger = 'hover' | 'focus' | 'active' | 'enter' | 'leave'
25
24
  /**
26
25
  * 过渡/动画配置
27
26
  */
28
- export interface StyleTransition {
29
- /** 触发方式 */
30
- trigger: TransitionTrigger;
27
+ export type StyleTransition = {
28
+ /** DOM 事件 / 入离场触发 */
29
+ trigger: Exclude<TransitionTrigger, 'active_state'>;
31
30
  /** 应用的 CSS 动画/过渡类名;具体样式由宿主样式系统提供 */
32
31
  apply: string;
33
- /** active_state 类型时的条件路径 */
34
- condition?: string;
35
- /** active_state 类型时的目标值 */
36
- value?: string | number | boolean | null;
37
- }
32
+ } | ({
33
+ /** 状态驱动:纯绑定,成员的值就是档位名 */
34
+ trigger: 'active_state';
35
+ } & StyleTierBinding);
38
36
  /**
39
37
  * 样式配置顶层结构
40
38
  * 对应 _style.yaml 文件的完整结构
@@ -44,8 +42,8 @@ export interface StyleConfig {
44
42
  host: string;
45
43
  /** 基础静态样式映射:somaId → CSS 类名 */
46
44
  base: Record<string, string>;
47
- /** 状态驱动样式:somaId → 规则数组 */
48
- states: Record<string, StyleStateRule[]>;
45
+ /** 状态驱动样式:somaId → 类名档位绑定 */
46
+ states: Record<string, StyleTierBinding>;
49
47
  /** 动态交互与动画:somaId → 过渡配置 */
50
48
  transitions: Record<string, StyleTransition>;
51
49
  }
@@ -1,7 +1,6 @@
1
1
  import type { OnChangeRule } from './watcher.types';
2
2
  import type { SomaPageStateConfig } from './page-state.types';
3
3
  import type { SomaScopeDecl } from './region-scope.types';
4
- import type { SomaShowWhen } from '../show-when';
5
4
  /**
6
5
  * 作用域声明
7
6
  * 定义数据源路径和当前作用域别名
@@ -45,8 +44,8 @@ export interface NestedShowMapping {
45
44
  bind: BindDeclaration;
46
45
  /** 子级展示映射 */
47
46
  show: ShowMapping;
48
- /** 整块显隐:与 bind 同处一个配置对象(另起同名键会覆盖列表绑定);字符串形或对象谓词 */
49
- when?: SomaShowWhen;
47
+ /** 整块显隐:与 bind 同处一个配置对象(另起同名键会覆盖列表绑定);纯路径字符串("!path" 取反),值由展示对象给出 */
48
+ when?: string;
50
49
  }
51
50
  /**
52
51
  * 扩展绑定值
@@ -57,8 +56,8 @@ export interface ExtendedShowValue {
57
56
  text?: string;
58
57
  /** 双向绑定路径(表单控件) */
59
58
  model?: string;
60
- /** 条件渲染:路径字符串(truthy 显示,"!path" 取反),或对象谓词 `{ field, op, value? }`(`present` / `blank` 判有无值,0 与 false 算有值) */
61
- when?: SomaShowWhen;
59
+ /** 条件渲染:纯路径字符串(truthy 显示,"!path" 取反),布尔值由展示对象 / 业务对象给出 */
60
+ when?: string;
62
61
  /** CSS 类名动态绑定 { "class-names": "condition-path" } */
63
62
  class?: Record<string, string>;
64
63
  /** 子级展示映射 */
@@ -3,8 +3,13 @@
3
3
 
4
4
  const path = require('node:path');
5
5
  const fs = require('node:fs');
6
+ const os = require('node:os');
6
7
  const { spawn } = require('node:child_process');
7
8
 
9
+ process.on('unhandledRejection', (reason) => {
10
+ console.error('[soma-native][unhandledRejection]', reason);
11
+ });
12
+
8
13
  const args = process.argv.slice(2);
9
14
  const command = args[0];
10
15
 
@@ -43,7 +48,12 @@ if (!process.env.SOMA_NATIVE_HEAP_APPLIED && !process.env.SOMA_DISABLE_HEAP_CAP)
43
48
  process.on('SIGINT', () => forward('SIGINT'));
44
49
  process.on('SIGTERM', () => forward('SIGTERM'));
45
50
  child.on('exit', (code, signal) => {
46
- process.exit(code ?? (signal ? 0 : 0));
51
+ if (typeof code === 'number') {
52
+ process.exit(code);
53
+ } else {
54
+ const sigNum = signal && os.constants && os.constants.signals ? os.constants.signals[signal] : undefined;
55
+ process.exit(typeof sigNum === 'number' ? 128 + sigNum : 1);
56
+ }
47
57
  });
48
58
  return;
49
59
  }
@@ -159,8 +169,15 @@ async function run() {
159
169
  const nativeServer = (!isDev && fs.existsSync(precompiledServerPath))
160
170
  ? require(precompiledServerPath)
161
171
  : loadJiti()(path.resolve(__dirname, '../src/native-server.ts'));
172
+ const targetPort = port ?? (process.env.PORT ? parseInt(process.env.PORT, 10) : 3000);
173
+ const targetHost = hostname ?? process.env.SOMA_HOST ?? process.env.HOST ?? '0.0.0.0';
174
+ if (await nativeServer.isPortInUse(targetPort, targetHost)) {
175
+ console.error(`[soma-native][server] 端口 ${targetPort} 已被其他进程占用,请使用 --port 指定其他端口`);
176
+ process.exit(1);
177
+ }
162
178
 
163
179
  if (isDev) {
180
+ process.env.SOMA_DEV_SERVER = '1';
164
181
  const hostPrepare = loadJiti()(path.resolve(__dirname, '../src/host-prepare.ts'));
165
182
  try {
166
183
  await hostPrepare.prewarmHostPages(hostDir, process.env);
@@ -180,6 +197,10 @@ async function run() {
180
197
  });
181
198
 
182
199
  const { url, port: actualPort } = await instance.start();
200
+ // 只警告不退出:纯四件套原生工程没有 soma.app.ts 是合法的。装配代码只认文件名 soma.app.ts(应用根或源码根下,见 host-assembly.ts)。
201
+ if (![hostDir, webRoot].some((dir) => fs.existsSync(path.join(dir, 'soma.app.ts')))) {
202
+ console.warn(`[soma-native] 未找到 soma.app.ts,当前目录:${hostDir};若这是 soma-kit / 应用工程,请确认在工程根目录运行`);
203
+ }
183
204
  const modeText = isDev ? '开发态 (增量热更新)' : '生产态 (极速 AOT)';
184
205
 
185
206
  console.log(`\n SOMA 极速原生内核已就绪 [${modeText}]`);
@@ -14,7 +14,6 @@ import type {
14
14
  SomaRuntimeServices,
15
15
  } from 'soma-core/runtime';
16
16
  import { assertRuntimeArtifact, maybeStartBootTimings, readBootTimings, SomaBootstrap } from 'soma-core/runtime';
17
- import { SomaLocaleOnlyPageRoot } from 'soma-core/base';
18
17
  import { loadHostDomainClass, resolveHostBootstrapOptions } from 'soma-core/host-bridge';
19
18
  import { designChunkLoadBackoffMs } from 'soma-foundation/layout';
20
19
  import {
@@ -32,6 +31,14 @@ declare global {
32
31
 
33
32
  const isDev = process.env.NODE_ENV !== 'production';
34
33
 
34
+ export function isBindingMatch(
35
+ cachedBinding?: { digest?: string; generation?: number },
36
+ incomingBinding?: { digest?: string; generation?: number },
37
+ ): boolean {
38
+ return (cachedBinding?.digest ?? '') === (incomingBinding?.digest ?? '') &&
39
+ (cachedBinding?.generation ?? 0) === (incomingBinding?.generation ?? 0);
40
+ }
41
+
35
42
  export function forbiddenText(language?: string): string {
36
43
  return language && language.toLowerCase().startsWith('en')
37
44
  ? SOMA_PAGE_FORBIDDEN_TEXT_EN
@@ -69,6 +76,13 @@ type PagePayload = ComponentTreeRuntimeEnvelope & {
69
76
  query?: SomaPageAssets['pageQuery'];
70
77
  queryContract?: SomaPageAssets['queryContract'];
71
78
  nav?: SomaPageAssets['nav'];
79
+ binding?: {
80
+ digest?: string;
81
+ generation?: number;
82
+ kind?: string;
83
+ owner?: string;
84
+ version?: string;
85
+ };
72
86
  };
73
87
 
74
88
  type PrecompiledAssets = Pick<
@@ -78,7 +92,6 @@ type PrecompiledAssets = Pick<
78
92
  | 'artifact'
79
93
  | 'uiConfig'
80
94
  | 'eventConfig'
81
- | 'triggerConfig'
82
95
  | 'timerConfig'
83
96
  | 'styleConfig'
84
97
  | 'locale'
@@ -97,7 +110,6 @@ async function loadPrecompiledFromManifest(
97
110
  const res = await fetch(`/soma/manifest?path=${encodeURIComponent(path)}`);
98
111
  if (!res.ok) return null;
99
112
  const data: PrecompiledAssets & {
100
- triggers?: SomaPageAssets['triggerConfig'];
101
113
  timers?: SomaPageAssets['timerConfig'];
102
114
  } = await res.json();
103
115
  assertRuntimeArtifact(data);
@@ -115,7 +127,6 @@ async function loadPrecompiledFromManifest(
115
127
  artifact: data.artifact,
116
128
  uiConfig: data.uiConfig,
117
129
  eventConfig: data.eventConfig,
118
- triggerConfig: data.triggers ?? [],
119
130
  timerConfig: data.timers ?? [],
120
131
  styleConfig: data.styleConfig,
121
132
  locale: data.locale ?? {},
@@ -128,168 +139,10 @@ async function loadPrecompiledFromManifest(
128
139
  }
129
140
  }
130
141
 
131
- // 9 维主题与视觉方案跨页实时同步(支持工作台用户操作记忆与多窗口协同)
132
- function applyVisualSchemeToHost(hostEl: HTMLElement, state: Record<string, unknown>): void {
133
- const palette = (state.palette || state.colorEnum || "CLASSIC_TECH_BLUE") as string;
134
- const colorDepth = (state.colorDepth || state.depth || "NORMAL") as string;
135
- const colorSaturation = (state.colorSaturation || state.sat || "STANDARD_SATURATION") as string;
136
- const fontFamily = (state.fontFamily || state.family || "SYSTEM_SANS") as string;
137
- const fontScale = (state.fontScale || state.scale || state.typoEnum || "MEDIUM_STANDARD") as string;
138
- const boundary = (state.boundary || state.boundaryScheme || "HAIRLINE_BORDER") as string;
139
- const shape = (state.shape || state.componentShape || state.styleEnum || "STANDARD_ROUNDED") as string;
140
- const surfaceTexture = (state.surfaceTexture || state.texture || "SOLID_MATTE") as string;
141
- const density = (state.density || state.spatialDensity || "STANDARD_BALANCED") as string;
142
-
143
- const normDepth = (colorDepth === "LIGHTENED" || colorDepth === "SLIGHTLY_LIGHT" || colorDepth === "VERY_LIGHT" || colorDepth === "soft")
144
- ? "LIGHTENED"
145
- : (colorDepth === "DARKENED" || colorDepth === "SLIGHTLY_DEEP" || colorDepth === "VERY_DEEP" || colorDepth === "dimmed" || colorDepth === "dark")
146
- ? "DARKENED"
147
- : "NORMAL";
148
- hostEl.setAttribute("data-kit-palette", palette);
149
- hostEl.setAttribute("data-kit-depth", normDepth);
150
- hostEl.setAttribute("data-kit-boundary", boundary);
151
- hostEl.setAttribute("data-kit-shape", shape);
152
- hostEl.setAttribute("data-kit-texture", surfaceTexture);
153
- hostEl.setAttribute("data-kit-density", density);
154
- document.documentElement.setAttribute("data-kit-palette", palette);
155
- document.documentElement.setAttribute("data-kit-depth", normDepth);
156
- document.documentElement.setAttribute("data-kit-boundary", boundary);
157
- document.documentElement.setAttribute("data-kit-shape", shape);
158
- document.documentElement.setAttribute("data-kit-texture", surfaceTexture);
159
- document.documentElement.setAttribute("data-kit-density", density);
160
-
161
- const s = document.documentElement.style;
162
- s.setProperty("--soma-theme-palette", palette);
163
- s.setProperty("--soma-theme-color-depth", colorDepth);
164
- s.setProperty("--soma-theme-color-saturation", colorSaturation);
165
- s.setProperty("--soma-theme-font-family", fontFamily);
166
- s.setProperty("--soma-theme-font-scale", fontScale);
167
- s.setProperty("--soma-theme-boundary", boundary);
168
- s.setProperty("--soma-theme-shape", shape);
169
- s.setProperty("--soma-theme-surface-texture", surfaceTexture);
170
- s.setProperty("--soma-theme-density", density);
171
-
172
- const isBorderless = boundary === "BORDERLESS_SHADOW";
173
- s.setProperty("--soma-border-width", isBorderless ? "0px" : "0.5px");
174
-
175
- let radiusCard = "8px";
176
- let radiusControl = "6px";
177
- let radiusSm = "6px";
178
- let radiusMd = "8px";
179
- let radiusLg = "10px";
180
- let radiusXl = "14px";
181
- let radiusFull = "9999px";
182
-
183
- if (shape === "SMALL_SHARP") {
184
- radiusCard = "4px";
185
- radiusControl = "2px";
186
- radiusSm = "2px";
187
- radiusMd = "4px";
188
- radiusLg = "4px";
189
- radiusXl = "6px";
190
- } else if (shape === "PILL_CAPSULE") {
191
- radiusCard = "16px";
192
- radiusControl = "9999px";
193
- radiusSm = "9999px";
194
- radiusMd = "12px";
195
- radiusLg = "16px";
196
- radiusXl = "20px";
197
- } else if (shape === "PURE_SQUARE") {
198
- radiusCard = "0px";
199
- radiusControl = "0px";
200
- radiusSm = "0px";
201
- radiusMd = "0px";
202
- radiusLg = "0px";
203
- radiusXl = "0px";
204
- radiusFull = "0px";
205
- }
206
-
207
- s.setProperty("--soma-radius-card", radiusCard);
208
- s.setProperty("--soma-radius-control", radiusControl);
209
- s.setProperty("--soma-radius-sm", radiusSm);
210
- s.setProperty("--soma-radius-md", radiusMd);
211
- s.setProperty("--soma-radius-lg", radiusLg);
212
- s.setProperty("--soma-radius-xl", radiusXl);
213
- s.setProperty("--soma-radius-full", radiusFull);
214
-
215
- let controlHeight = "32px";
216
- let space1 = "0.25rem";
217
- if (density === "COMPACT_DENSE" || density === "compact") {
218
- controlHeight = "28px";
219
- space1 = "0.22rem";
220
- } else if (density === "SPACIOUS_AIRY" || density === "spacious") {
221
- controlHeight = "40px";
222
- space1 = "0.3rem";
223
- }
224
- s.setProperty("--soma-control-height", controlHeight);
225
- s.setProperty("--soma-space-1", space1);
226
-
227
- s.setProperty("--soma-shadow-step-0", isBorderless ? "0 1px 3px 0 rgba(0, 0, 0, 0.06), 0 4px 12px 0 rgba(0, 0, 0, 0.05)" : "none");
228
- }
229
-
230
- function setupVisualSchemeSync(containerEl: HTMLElement): () => void {
231
- const syncFromStorage = () => {
232
- try {
233
- const kitHost = containerEl.querySelector('[data-soma-host="SomaLocaleOnlyPageRoot"]') as HTMLElement | null;
234
- if (!kitHost) return;
235
- if (typeof localStorage === "undefined") return;
236
- const raw = localStorage.getItem("soma-visual-scheme-state-v1") || localStorage.getItem("soma-visual-scheme-state");
237
- if (!raw) return;
238
- const parsed = JSON.parse(raw);
239
- if (parsed && typeof parsed === "object") {
240
- applyVisualSchemeToHost(kitHost, parsed);
241
- }
242
- } catch {}
243
- };
244
-
245
- syncFromStorage();
246
-
247
- const onMessage = (ev: MessageEvent) => {
248
- try {
249
- const kitHost = containerEl.querySelector('[data-soma-host="SomaLocaleOnlyPageRoot"]') as HTMLElement | null;
250
- if (!kitHost) return;
251
- if (ev.data && typeof ev.data === "object") {
252
- applyVisualSchemeToHost(kitHost, ev.data);
253
- }
254
- } catch {}
255
- };
256
-
257
- const onStorage = (ev: StorageEvent) => {
258
- if ((ev.key === "soma-visual-scheme-state-v1" || ev.key === "soma-visual-scheme-state") && ev.newValue) {
259
- try {
260
- const kitHost = containerEl.querySelector('[data-soma-host="SomaLocaleOnlyPageRoot"]') as HTMLElement | null;
261
- if (!kitHost) return;
262
- const parsed = JSON.parse(ev.newValue);
263
- if (parsed && typeof parsed === "object") {
264
- applyVisualSchemeToHost(kitHost, parsed);
265
- }
266
- } catch {}
267
- }
268
- };
269
-
270
- let channel: BroadcastChannel | null = null;
271
- try {
272
- if (typeof BroadcastChannel !== "undefined") {
273
- channel = new BroadcastChannel("soma-visual-scheme-sync");
274
- channel.addEventListener("message", onMessage);
275
- }
276
- } catch {}
277
-
278
- window.addEventListener("storage", onStorage);
279
-
280
- return () => {
281
- try {
282
- channel?.close();
283
- } catch {}
284
- window.removeEventListener("storage", onStorage);
285
- };
286
- }
287
-
288
142
  class NativePageClient {
289
143
 
290
144
  private bootstrap: SomaBootstrapType | null = null;
291
145
  private routerBridgeUnsub: (() => void) | null = null;
292
- private visualSchemeUnsub: (() => void) | null = null;
293
146
  private currentRunId = 0;
294
147
  private appRoot: HTMLElement;
295
148
  private hydrationShell: HTMLElement;
@@ -448,9 +301,10 @@ class NativePageClient {
448
301
 
449
302
  const base = (data.base as string) || urlPathToPageBase(pagePath);
450
303
  const sourcePackage = typeof data.sourcePackage === 'string' ? data.sourcePackage : null;
304
+ // 动态页 / 组件树页不走静态 Domain 加载;页面根由引擎按 `domain:` 名查 Host 的 pageRoots 类表(没登记 = 缺省根)
451
305
  const DomainClass =
452
306
  data.sourceMarkup === 'component-tree' || base.startsWith('dynamic-')
453
- ? SomaLocaleOnlyPageRoot
307
+ ? undefined
454
308
  : await loadHostDomainClass({ base, sourcePackage });
455
309
  const routeAssets = {
456
310
  routerPath,
@@ -475,15 +329,17 @@ class NativePageClient {
475
329
  }
476
330
 
477
331
  const cached = pageAssetCache.get(routerPath);
332
+ const bindingMatch = isBindingMatch(cached?.binding, data.binding);
478
333
  if (
479
334
  cached &&
335
+ bindingMatch &&
480
336
  (cached.sourceMarkup ?? 'legacy-html') === (data.sourceMarkup ?? 'legacy-html') &&
481
337
  (data.sourceMarkup !== 'component-tree' ||
482
338
  cached.artifact?.artifactDigest === data.artifact?.artifactDigest)
483
339
  ) {
484
340
  const CachedClass =
485
341
  cached.sourceMarkup === 'component-tree' || cached.base.startsWith('dynamic-')
486
- ? SomaLocaleOnlyPageRoot
342
+ ? undefined
487
343
  : await loadHostDomainClass({
488
344
  base: cached.base,
489
345
  sourcePackage: cached.sourcePackage,
@@ -528,6 +384,7 @@ class NativePageClient {
528
384
  appConfigYaml: data.appConfigYaml ?? '',
529
385
  compiledStyles: data.compiledStyles,
530
386
  colorScheme: data.colorScheme,
387
+ binding: data.binding,
531
388
  };
532
389
 
533
390
  if (!isDev) {
@@ -585,11 +442,6 @@ class NativePageClient {
585
442
  await this.bootstrap.unmount();
586
443
  this.bootstrap = null;
587
444
  }
588
- const prevVisualSchemeUnsub = this.visualSchemeUnsub;
589
- if (prevVisualSchemeUnsub) {
590
- prevVisualSchemeUnsub();
591
- this.visualSchemeUnsub = null;
592
- }
593
445
  if (runId !== this.currentRunId) return;
594
446
 
595
447
  const getServices = () =>
@@ -614,9 +466,6 @@ class NativePageClient {
614
466
 
615
467
  this.showContainer();
616
468
 
617
- if (this.visualSchemeUnsub) { (this.visualSchemeUnsub as () => void)(); }
618
- this.visualSchemeUnsub = setupVisualSchemeSync(this.containerEl);
619
-
620
469
  if (typeof window !== 'undefined') {
621
470
  window.__SOMA_DIAGNOSTICS__ = {
622
471
  isSettled: () => bs.isSettled(),
@@ -5,6 +5,25 @@ import esbuild, { type BuildContext, type Plugin } from 'esbuild';
5
5
  import { readAllSomaPublicAliases } from './public-packages.cjs';
6
6
  import { toPascalCase } from '../../core/server/api/service-path';
7
7
  import { getSomaHostSourceRoot, getSomaHostApiRoot } from '../../core/server/host/source-packages.cjs';
8
+ import { getSomaSourceRootAliases, matchSomaSourceRoot, somaSourceRootFilter } from '../../core/server/host/source-aliases.cjs';
9
+
10
+ /**
11
+ * 源码根别名(soma.sourceRoots)的 esbuild 钩子:与 jiti 别名同一份实现,只认带斜杠的整段前缀。
12
+ * 只处理宿主自己代码的 import(importer 不在 node_modules 内),不改写依赖包内部的同名子路径。
13
+ * 未声明 → 不注册(零影响)。放在 resolveModuleFile 之后定义,调用时才解析。
14
+ */
15
+ function registerSourceRootResolve(build: Parameters<Plugin['setup']>[0], hostDir: string, env?: NodeJS.ProcessEnv): void {
16
+ const aliases = getSomaSourceRootAliases(hostDir, env) as Record<string, string>;
17
+ const filter = somaSourceRootFilter(aliases);
18
+ if (!filter) return;
19
+ const nodeModulesSegment = `${path.sep}node_modules${path.sep}`;
20
+ build.onResolve({ filter }, (args) => {
21
+ if (args.importer.includes(nodeModulesSegment)) return undefined;
22
+ const hit = matchSomaSourceRoot(aliases, args.path);
23
+ if (!hit) return undefined;
24
+ return { path: resolveModuleFile(hit.dir, hit.subpath) };
25
+ });
26
+ }
8
27
 
9
28
  export interface BuildBrowserClientOptions {
10
29
  readonly hostDir: string;
@@ -154,6 +173,9 @@ function createBrowserClientPlugin(options: {
154
173
  return { path: target };
155
174
  });
156
175
 
176
+ // 5b. 源码根别名(soma.sourceRoots)
177
+ registerSourceRootResolve(build, hostDir);
178
+
157
179
  // 6. 拦截内部 engine 模块私有深导入(RT4 守卫)
158
180
  build.onResolve({ filter: /core\/client\/engine\// }, (args) => {
159
181
  if (!args.importer.includes('soma-core')) {
@@ -172,6 +194,58 @@ function createBrowserClientPlugin(options: {
172
194
  }
173
195
  return undefined;
174
196
  });
197
+
198
+ // 8. 可选 peer 依赖 echarts:仅当包 `echarts` 本身无法解析(未安装)时才回落轻量无头桩模块,
199
+ // 防未装 echarts 的应用在 soma dev / build 时崩溃;已安装 echarts 但某个子路径解析失败(版本不符、路径写错)
200
+ // 属于真实错误,原样上抛,不静默吞成桩。
201
+ build.onResolve({ filter: /^echarts(?:\/.*)?$/ }, async (args) => {
202
+ if (args.pluginData?.skipEchartsStub) return undefined;
203
+ const resolveOpts = {
204
+ resolveDir: args.resolveDir,
205
+ kind: args.kind,
206
+ importer: args.importer,
207
+ pluginData: { skipEchartsStub: true },
208
+ };
209
+ const resolved = await build.resolve(args.path, resolveOpts);
210
+ if (resolved.errors.length === 0 && resolved.path) {
211
+ return { path: resolved.path };
212
+ }
213
+ // 子路径失败时再探包根:包根可解析 = 已安装,子路径错误原样抛出
214
+ const bare = args.path === 'echarts' ? resolved : await build.resolve('echarts', resolveOpts);
215
+ if (bare.errors.length === 0 && bare.path) {
216
+ return { errors: resolved.errors };
217
+ }
218
+ return {
219
+ path: args.path,
220
+ namespace: 'soma-optional-echarts-stub',
221
+ };
222
+ });
223
+
224
+ build.onLoad({ filter: /.*/, namespace: 'soma-optional-echarts-stub' }, () => ({
225
+ contents: `
226
+ // 未安装可选依赖 echarts 时的无头桩:首次 init() 提示一次,图表不渲染
227
+ let warned = false;
228
+ export const SVGRenderer = {};
229
+ export function use() {}
230
+ export function init() {
231
+ if (!warned) {
232
+ warned = true;
233
+ console.warn('未安装可选依赖 echarts,图表不会渲染:npm i echarts');
234
+ }
235
+ return {
236
+ setOption() {},
237
+ dispatchAction() {},
238
+ on() {},
239
+ off() {},
240
+ resize() {},
241
+ dispose() {},
242
+ getModel() { return { getSeriesByIndex() { return undefined; } }; },
243
+ };
244
+ }
245
+ export default { SVGRenderer, use, init };
246
+ `,
247
+ loader: 'js',
248
+ }));
175
249
  },
176
250
  };
177
251
  }
@@ -392,6 +466,7 @@ export async function buildServerAot(
392
466
  const subpath = args.path.replace(/^@soma-host\/?/, '');
393
467
  return { path: resolveModuleFile(webRoot, subpath) };
394
468
  });
469
+ registerSourceRootResolve(build, hostDir, options.env);
395
470
  build.onResolve({ filter: /^@soma-api(?:\/.*)?$/ }, (args) => {
396
471
  const subpath = args.path.replace(/^@soma-api\/?/, '');
397
472
  return { path: resolveModuleFile(apiRoot, subpath) };