soma-core 1.3.1 → 1.3.3

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 (233) hide show
  1. package/README.md +42 -0
  2. package/app/SomaPageClient.tsx +39 -2
  3. package/app/[...path]/page.tsx +7 -6
  4. package/app/api/[...path]/route.ts +3 -3
  5. package/app/api/soma-registry/[...path]/route.ts +67 -0
  6. package/app/components/SomaHostPage.tsx +3 -8
  7. package/app/components/SomaPageClientBoundary.tsx +13 -0
  8. package/app/layout.tsx +6 -1
  9. package/app/page.tsx +3 -3
  10. package/app/soma/manifest/route.ts +1 -0
  11. package/app/soma/page-object/route.ts +1 -1
  12. package/core/build/compiler/full-manifest-builder.ts +6 -1
  13. package/core/build/compiler/rollup-plugin-soma.ts +6 -0
  14. package/core/build/compiler/soma-manifest-webpack-plugin.js +4 -0
  15. package/core/build/compiler/soma-precompile.js +3507 -2387
  16. package/core/build/compiler/soma-precompile.ts +31 -2
  17. package/core/build/compiler/soma-rspack-yaml-loader.js +3 -0
  18. package/core/build/compiler/soma-webpack-loader.js +7 -1
  19. package/core/build/compiler/vite-plugin-soma.ts +11 -1
  20. package/core/build/component/package-loader.ts +135 -0
  21. package/core/build/eject/apply-eject.ts +133 -0
  22. package/core/build/eject/plan-eject.ts +139 -0
  23. package/core/client/adaptive/flush-scheduler.ts +96 -0
  24. package/core/client/adaptive/hysteresis.ts +56 -0
  25. package/core/client/adaptive/index.ts +23 -0
  26. package/core/client/adaptive/observer-pool.ts +90 -0
  27. package/core/client/base/SomaPageRootBase.ts +50 -0
  28. package/core/client/compiler/adaptive-compile.ts +136 -0
  29. package/core/client/compiler/manifest-compiler.ts +155 -27
  30. package/core/client/component/ai-catalog.ts +262 -0
  31. package/core/client/component/component-definition.types.ts +65 -0
  32. package/core/client/component/component-expander.ts +119 -0
  33. package/core/client/component/component-manager.ts +933 -0
  34. package/core/client/component/component-pack.ts +271 -0
  35. package/core/client/component/component-registry.ts +71 -0
  36. package/core/client/component/pack-styles.ts +94 -0
  37. package/core/client/component/scoped-adapter.ts +85 -0
  38. package/core/client/component/verify-pack.ts +247 -0
  39. package/core/client/container/MiniProgramContainerAdapter.ts +15 -1
  40. package/core/client/container/ReactNativeContainerAdapter.ts +15 -1
  41. package/core/client/container/SomaContainerAdapter.ts +186 -180
  42. package/core/client/data/data-object-resolver.ts +417 -0
  43. package/core/client/diagnostics/SomaDiagnostics.ts +187 -186
  44. package/core/client/diagnostics/boot-timings.ts +152 -0
  45. package/core/client/engine/asset-resolver.ts +12 -2
  46. package/core/client/engine/dom-renderer.ts +235 -16
  47. package/core/client/engine/emit-event.ts +21 -0
  48. package/core/client/engine/event-engine.ts +34 -4
  49. package/core/client/engine/on-change-engine.ts +1 -1
  50. package/core/client/engine/property-watcher.ts +1 -1
  51. package/core/client/engine/reactive-proxy.ts +3 -3
  52. package/core/client/engine/render-engine.ts +43 -4
  53. package/core/client/engine/runtime-builder.ts +23 -0
  54. package/core/client/engine/soma-bootstrap.ts +389 -5
  55. package/core/client/engine/style-binder.ts +47 -1
  56. package/core/client/host-bridge/empty-host/data/README.md +17 -0
  57. package/core/client/infra/http/SomaHttpService.ts +5 -0
  58. package/core/client/observability/error-reporter.ts +173 -0
  59. package/core/client/parser/adaptive-parser.ts +264 -0
  60. package/core/client/parser/data-config-parser.ts +396 -0
  61. package/core/client/parser/pipeline-parser.ts +15 -3
  62. package/core/client/parser/style-config-parser.ts +65 -2
  63. package/core/client/parser/ui-config-parser.ts +52 -3
  64. package/core/client/pipes/pipe-registry.ts +249 -0
  65. package/core/client/quality/SomaQualityRegistry.ts +3 -0
  66. package/core/client/registry/declaration-renderer.ts +159 -0
  67. package/core/client/registry/index.ts +28 -0
  68. package/core/client/registry/page-lifecycle.ts +171 -0
  69. package/core/client/registry/remote-page.ts +139 -0
  70. package/core/client/runtime/SomaRuntimeServices.ts +24 -0
  71. package/core/client/scheduler/SomaScheduler.ts +29 -1
  72. package/core/client/security/attribute-presence.ts +70 -0
  73. package/core/client/security/html-sanitizer.ts +113 -0
  74. package/core/client/security/url-guard.ts +0 -0
  75. package/core/client/theme/theme-engine.ts +936 -0
  76. package/core/client/typography/typography-base.ts +34 -0
  77. package/core/client/validation/contract-validator.ts +48 -5
  78. package/core/index.ts +190 -2
  79. package/core/server/api/IService.ts +18 -6
  80. package/core/server/api/load-host-service.ts +3 -3
  81. package/core/server/host/content-security-policy.ts +190 -0
  82. package/core/server/host/csp-nonce-metadata.ts +75 -0
  83. package/core/server/host/resolve-host-request-hook.ts +5 -0
  84. package/core/server/host/server-page-assets.ts +10 -0
  85. package/core/server/index.ts +30 -1
  86. package/core/server/infra/cache/ServerFileCache.ts +1 -1
  87. package/core/server/mock/node/cli.mjs +2 -2
  88. package/core/server/registry/api-registry-store.ts +518 -0
  89. package/core/server/registry/conditional-object-store.ts +29 -0
  90. package/core/server/registry/declaration-precompiler.ts +129 -0
  91. package/core/server/registry/in-memory-conditional-object-store.ts +43 -0
  92. package/core/server/registry/index.ts +142 -0
  93. package/core/server/registry/page-registry-repository.ts +373 -0
  94. package/core/server/registry/page-registry-store.ts +903 -0
  95. package/core/server/registry/registry-error.ts +17 -0
  96. package/core/server/registry/registry-file-lock.ts +173 -0
  97. package/core/server/registry/registry-response.ts +71 -0
  98. package/core/server/registry/registry-subjects.ts +194 -0
  99. package/core/server/registry/registry-write-pipeline.ts +240 -0
  100. package/core/server/registry/request-body-limit.ts +99 -0
  101. package/core/server/registry/services/apis/Get.ts +25 -0
  102. package/core/server/registry/services/apis/List.ts +41 -0
  103. package/core/server/registry/services/apis/Register.ts +39 -0
  104. package/core/server/registry/services/apis/Unregister.ts +24 -0
  105. package/core/server/registry/services/index.ts +40 -0
  106. package/core/server/registry/services/pages/Get.ts +86 -0
  107. package/core/server/registry/services/pages/List.ts +53 -0
  108. package/core/server/registry/services/pages/Register.ts +49 -0
  109. package/core/server/registry/services/pages/Rollback.ts +36 -0
  110. package/core/server/registry/services/pages/Unregister.ts +23 -0
  111. package/core/server/registry/services/service-utils.ts +21 -0
  112. package/core/server/registry/validation/compile-gate.ts +71 -0
  113. package/core/server/registry/validation/component-existence.ts +55 -0
  114. package/core/server/registry/validation/credential-ban.ts +86 -0
  115. package/core/server/registry/validation/cross-check.ts +77 -0
  116. package/core/server/registry/validation/declaration-safety-scan.ts +102 -0
  117. package/core/shared/types/adaptive.types.ts +109 -0
  118. package/core/shared/types/component-contract.types.ts +110 -0
  119. package/core/shared/types/data-config.types.ts +105 -0
  120. package/core/shared/types/domain.types.ts +6 -0
  121. package/core/shared/types/engine.types.ts +41 -35
  122. package/core/shared/types/manifest.types.ts +55 -32
  123. package/core/shared/types/scope-manifest.types.ts +96 -0
  124. package/core/shared/types/style-config.types.ts +9 -0
  125. package/core/shared/types/ui-config.types.ts +118 -98
  126. package/dist/cli/soma.js +20 -5
  127. package/dist/core/index.cjs +5388 -888
  128. package/dist/types/build/compiler/full-manifest-builder.d.ts +4 -0
  129. package/dist/types/build/compiler/rollup-plugin-soma.d.ts +1 -0
  130. package/dist/types/build/compiler/soma-precompile.d.ts +9 -0
  131. package/dist/types/build/compiler/vite-plugin-soma.d.ts +3 -0
  132. package/dist/types/build/component/package-loader.d.ts +9 -0
  133. package/dist/types/build/eject/apply-eject.d.ts +22 -0
  134. package/dist/types/build/eject/plan-eject.d.ts +32 -0
  135. package/dist/types/client/adaptive/flush-scheduler.d.ts +13 -0
  136. package/dist/types/client/adaptive/hysteresis.d.ts +16 -0
  137. package/dist/types/client/adaptive/index.d.ts +5 -0
  138. package/dist/types/client/adaptive/observer-pool.d.ts +15 -0
  139. package/dist/types/client/base/SomaPageRootBase.d.ts +33 -0
  140. package/dist/types/client/compiler/adaptive-compile.d.ts +26 -0
  141. package/dist/types/client/compiler/manifest-compiler.d.ts +13 -2
  142. package/dist/types/client/component/ai-catalog.d.ts +73 -0
  143. package/dist/types/client/component/component-definition.types.d.ts +54 -0
  144. package/dist/types/client/component/component-expander.d.ts +25 -0
  145. package/dist/types/client/component/component-manager.d.ts +160 -0
  146. package/dist/types/client/component/component-pack.d.ts +90 -0
  147. package/dist/types/client/component/component-registry.d.ts +12 -0
  148. package/dist/types/client/component/pack-styles.d.ts +22 -0
  149. package/dist/types/client/component/scoped-adapter.d.ts +18 -0
  150. package/dist/types/client/component/verify-pack.d.ts +14 -0
  151. package/dist/types/client/data/data-object-resolver.d.ts +71 -0
  152. package/dist/types/client/diagnostics/SomaDiagnostics.d.ts +2 -1
  153. package/dist/types/client/diagnostics/boot-timings.d.ts +30 -0
  154. package/dist/types/client/engine/asset-resolver.d.ts +7 -1
  155. package/dist/types/client/engine/dom-renderer.d.ts +49 -1
  156. package/dist/types/client/engine/emit-event.d.ts +6 -0
  157. package/dist/types/client/engine/event-engine.d.ts +6 -0
  158. package/dist/types/client/engine/render-engine.d.ts +26 -1
  159. package/dist/types/client/engine/runtime-builder.d.ts +7 -0
  160. package/dist/types/client/engine/soma-bootstrap.d.ts +122 -0
  161. package/dist/types/client/infra/http/SomaHttpService.d.ts +2 -0
  162. package/dist/types/client/observability/error-reporter.d.ts +51 -0
  163. package/dist/types/client/parser/adaptive-parser.d.ts +28 -0
  164. package/dist/types/client/parser/data-config-parser.d.ts +34 -0
  165. package/dist/types/client/parser/pipeline-parser.d.ts +2 -0
  166. package/dist/types/client/parser/style-config-parser.d.ts +5 -3
  167. package/dist/types/client/parser/ui-config-parser.d.ts +22 -1
  168. package/dist/types/client/pipes/pipe-registry.d.ts +38 -0
  169. package/dist/types/client/registry/declaration-renderer.d.ts +51 -0
  170. package/dist/types/client/registry/index.d.ts +10 -0
  171. package/dist/types/client/registry/page-lifecycle.d.ts +61 -0
  172. package/dist/types/client/registry/remote-page.d.ts +52 -0
  173. package/dist/types/client/runtime/SomaRuntimeServices.d.ts +16 -0
  174. package/dist/types/client/scheduler/SomaScheduler.d.ts +8 -0
  175. package/dist/types/client/security/attribute-presence.d.ts +7 -0
  176. package/dist/types/client/security/html-sanitizer.d.ts +37 -0
  177. package/dist/types/client/security/url-guard.d.ts +11 -0
  178. package/dist/types/client/theme/theme-engine.d.ts +49 -0
  179. package/dist/types/client/typography/typography-base.d.ts +15 -0
  180. package/dist/types/client/validation/contract-validator.d.ts +2 -0
  181. package/dist/types/index.d.ts +36 -2
  182. package/dist/types/server/api/IService.d.ts +18 -6
  183. package/dist/types/server/host/content-security-policy.d.ts +53 -0
  184. package/dist/types/server/host/csp-nonce-metadata.d.ts +32 -0
  185. package/dist/types/server/host/resolve-host-request-hook.d.ts +5 -0
  186. package/dist/types/server/host/server-page-assets.d.ts +5 -0
  187. package/dist/types/server/index.d.ts +4 -1
  188. package/dist/types/server/registry/api-registry-store.d.ts +141 -0
  189. package/dist/types/server/registry/conditional-object-store.d.ts +27 -0
  190. package/dist/types/server/registry/declaration-precompiler.d.ts +30 -0
  191. package/dist/types/server/registry/in-memory-conditional-object-store.d.ts +8 -0
  192. package/dist/types/server/registry/index.d.ts +29 -0
  193. package/dist/types/server/registry/page-registry-repository.d.ts +58 -0
  194. package/dist/types/server/registry/page-registry-store.d.ts +259 -0
  195. package/dist/types/server/registry/registry-error.d.ts +12 -0
  196. package/dist/types/server/registry/registry-file-lock.d.ts +20 -0
  197. package/dist/types/server/registry/registry-response.d.ts +18 -0
  198. package/dist/types/server/registry/registry-subjects.d.ts +59 -0
  199. package/dist/types/server/registry/registry-write-pipeline.d.ts +48 -0
  200. package/dist/types/server/registry/request-body-limit.d.ts +31 -0
  201. package/dist/types/server/registry/services/apis/Get.d.ts +10 -0
  202. package/dist/types/server/registry/services/apis/List.d.ts +10 -0
  203. package/dist/types/server/registry/services/apis/Register.d.ts +13 -0
  204. package/dist/types/server/registry/services/apis/Unregister.d.ts +12 -0
  205. package/dist/types/server/registry/services/index.d.ts +3 -0
  206. package/dist/types/server/registry/services/pages/Get.d.ts +10 -0
  207. package/dist/types/server/registry/services/pages/List.d.ts +13 -0
  208. package/dist/types/server/registry/services/pages/Register.d.ts +11 -0
  209. package/dist/types/server/registry/services/pages/Rollback.d.ts +9 -0
  210. package/dist/types/server/registry/services/pages/Unregister.d.ts +9 -0
  211. package/dist/types/server/registry/services/service-utils.d.ts +10 -0
  212. package/dist/types/server/registry/validation/compile-gate.d.ts +10 -0
  213. package/dist/types/server/registry/validation/component-existence.d.ts +14 -0
  214. package/dist/types/server/registry/validation/credential-ban.d.ts +15 -0
  215. package/dist/types/server/registry/validation/cross-check.d.ts +16 -0
  216. package/dist/types/server/registry/validation/declaration-safety-scan.d.ts +15 -0
  217. package/dist/types/shared/types/adaptive.types.d.ts +88 -0
  218. package/dist/types/shared/types/component-contract.types.d.ts +68 -0
  219. package/dist/types/shared/types/data-config.types.d.ts +81 -0
  220. package/dist/types/shared/types/domain.types.d.ts +6 -0
  221. package/dist/types/shared/types/engine.types.d.ts +6 -0
  222. package/dist/types/shared/types/manifest.types.d.ts +23 -0
  223. package/dist/types/shared/types/scope-manifest.types.d.ts +82 -0
  224. package/dist/types/shared/types/style-config.types.d.ts +8 -0
  225. package/dist/types/shared/types/ui-config.types.d.ts +20 -0
  226. package/global.d.ts +12 -0
  227. package/next.config.js +76 -1
  228. package/package.json +32 -11
  229. package/proxy.ts +62 -0
  230. package/core/client/engine/theme-variables.ts +0 -37
  231. package/dist/tsconfig.types.tsbuildinfo +0 -1
  232. package/dist/types/client/engine/theme-variables.d.ts +0 -3
  233. package/middleware.ts +0 -33
@@ -0,0 +1,90 @@
1
+ import type { SomaComponentDefinition } from './component-definition.types';
2
+ import { type SomaAiCatalog } from './ai-catalog';
3
+ /** 包标识:小写字母/数字/连字符——冲突报错与来源登记都用它 */
4
+ export declare const PACK_NAME_PATTERN: RegExp;
5
+ export interface SomaComponentPackStyles {
6
+ /** 组件名 → 该组件独有的 CSS(首次实例化时按需注入) */
7
+ components?: Record<string, string>;
8
+ /** 共享分片名 → CSS(被多个组件依赖的资产;不要复制进组件分片) */
9
+ shared?: Record<string, string>;
10
+ /** 组件名 → 依赖的共享分片名列表 */
11
+ deps?: Record<string, string[]>;
12
+ /** 包级基座 CSS(恒定注入;克制使用——它是每个页面首屏都要付的钱) */
13
+ base?: string;
14
+ }
15
+ export interface SomaComponentPack {
16
+ /** 包标识(小写字母/数字/连字符) */
17
+ name: string;
18
+ version: string;
19
+ /** 组件名 → 运行时定义,与 createSomaUiComponents() 同构 */
20
+ components: Record<string, SomaComponentDefinition>;
21
+ /** 按需装配的样式资产(可选) */
22
+ styles?: SomaComponentPackStyles;
23
+ /** 并进组件目录的写作规范补充(可选) */
24
+ catalogConventions?: string;
25
+ meta?: {
26
+ description?: string;
27
+ homepage?: string;
28
+ license?: string;
29
+ };
30
+ }
31
+ export declare class ComponentPackError extends Error {
32
+ constructor(message: string);
33
+ }
34
+ export interface ComposePacksOptions {
35
+ /**
36
+ * 显式覆盖:组件名 → 胜出的包名。
37
+ * 不在这张表里的重名一律抛错——默认拒绝,而不是让 spread 顺序决定渲染结果。
38
+ */
39
+ allowOverride?: Record<string, string>;
40
+ /**
41
+ * 按需样式装配(缺省开)。开着时返回的组件定义已经包好——首次实例化才注入 CSS。
42
+ * 关掉只有一种正当理由:宿主自己接管样式注入。**不要因为"在 Node 里跑"而关它**——
43
+ * 包装只在实例化那一刻碰 document,合成本身是纯数据操作。
44
+ */
45
+ lazyStyles?: boolean;
46
+ /** CSP nonce,透传给注入的 <style> */
47
+ styleNonce?: string | null;
48
+ }
49
+ export interface ComposedComponentPacks {
50
+ /** 合成后的组件表,直接喂 bootstrap 的 components */
51
+ components: Record<string, SomaComponentDefinition>;
52
+ /** 组件名 → 来源包名。排障、目录展示、闸门报错都用它 */
53
+ provenance: Record<string, string>;
54
+ /** 合成后的按需装配样式(键已按包做过冲突检查) */
55
+ styles: Required<Omit<SomaComponentPackStyles, 'base'>> & {
56
+ base: string[];
57
+ };
58
+ /** 参与合成的包(顺序保留;目录生成用) */
59
+ packs: SomaComponentPack[];
60
+ /** 被显式覆盖的组件名 → { 胜出包, 被盖掉的包 } */
61
+ overrides: Record<string, {
62
+ winner: string;
63
+ shadowed: string[];
64
+ }>;
65
+ }
66
+ /**
67
+ * 合成多个组件包。
68
+ *
69
+ * 重名默认抛错并点名到两个包;要覆盖就在 allowOverride 里写清楚谁赢。
70
+ * 样式分片同理:两个包提供同名共享分片时也拦下——那通常意味着有人复制了别人的资产。
71
+ */
72
+ export declare function composeComponentPacks(packs: readonly SomaComponentPack[], options?: ComposePacksOptions): ComposedComponentPacks;
73
+ /**
74
+ * 生成带来源标注的组件目录。
75
+ *
76
+ * 复用 generateAiCatalog(单一事实源:目录条目怎么长、ai 段怎么校验只有一处实现),
77
+ * 在它之上补两件包相关的事:
78
+ * - 每个条目盖 `pack` 戳,让人和排障工具知道这个组件是谁提供的;
79
+ * - 把各包的 catalogConventions 并进规范章节——第三方包对自己的组件有话要说时,
80
+ * 那些话必须跟着组件一起进模型的上下文,否则等于没写。
81
+ *
82
+ * 参数是合成结果而不是散装组件表:目录必须与运行时注册的是同一批组件,
83
+ * 中间隔一次手工拼装就迟早漂移。
84
+ */
85
+ export declare function generatePackCatalog(composed: ComposedComponentPacks, options?: {
86
+ conventions?: string;
87
+ strict?: boolean;
88
+ }): SomaAiCatalog & {
89
+ packOf: Record<string, string>;
90
+ };
@@ -0,0 +1,12 @@
1
+ import type { SomaComponentDefinition } from './component-definition.types';
2
+ export declare class SomaComponentRegistryError extends Error {
3
+ constructor(message: string);
4
+ }
5
+ export declare class SomaComponentRegistry {
6
+ private readonly defs;
7
+ register(def: SomaComponentDefinition): void;
8
+ registerAll(defs: Record<string, SomaComponentDefinition> | SomaComponentDefinition[]): void;
9
+ get(name: string): SomaComponentDefinition;
10
+ has(name: string): boolean;
11
+ names(): string[];
12
+ }
@@ -0,0 +1,22 @@
1
+ import type { SomaComponentDefinition } from './component-definition.types';
2
+ import type { ComposedComponentPacks } from './component-pack';
3
+ export interface PackStyleOptions {
4
+ /** CSP nonce;宿主启用严格 CSP 时必须给 */
5
+ nonce?: string | null;
6
+ }
7
+ /** 测试用:清空注入记录(jsdom 之间不共享 document,但模块级 Set 会跨用例残留) */
8
+ export declare function resetPackStyleInjection(): void;
9
+ /**
10
+ * 给合成结果里的每个组件接上按需样式。
11
+ *
12
+ * 注入顺序是**先共享分片、再组件分片**:组件分片经常覆盖共享分片里的默认值,
13
+ * 反过来注入会让覆盖失效——而这种失效只在"共享分片恰好晚注入"时出现,
14
+ * 也就是取决于页面先实例化了哪个组件,是最难复现的一类样式 bug。
15
+ */
16
+ export declare function attachPackStyles(composed: ComposedComponentPacks, options?: PackStyleOptions): Record<string, SomaComponentDefinition>;
17
+ /**
18
+ * 注入包级基座 CSS(恒定注入,不等实例化)。
19
+ * 基座是每个页面首屏都要付的钱,所以接入指南里写着"克制使用";
20
+ * 这里按包分别盖戳,便于排查"这段全局样式是谁带来的"。
21
+ */
22
+ export declare function ensurePackBaseStyles(composed: ComposedComponentPacks, options?: PackStyleOptions): void;
@@ -0,0 +1,18 @@
1
+ import { SomaContainerAdapter } from '../container/SomaContainerAdapter';
2
+ import type { SomaAnchorStats } from '../container/IContainerAdapter';
3
+ export declare const SOMA_SCOPED_ID_ATTR = "data-soma-scoped-id";
4
+ /** 锚点的作用域归属标记(展开器写入,值为该次展开的 scopeId) */
5
+ export declare const SOMA_SCOPE_ATTR = "data-soma-scope";
6
+ export declare class SomaScopedContainerAdapter extends SomaContainerAdapter {
7
+ /** 本适配器认领的作用域;undefined = 认所有 scoped 锚点 */
8
+ private readonly scopeId?;
9
+ /** `[data-soma-scoped-id][data-soma-scope="X"]`,预拼避免每次查询字符串拼接 */
10
+ private readonly anyAnchorSelector;
11
+ constructor(scopeId?: string);
12
+ getScopeId(): string | undefined;
13
+ private anchorSelector;
14
+ findAnchor(root: ParentNode, somaId: string): HTMLElement | null;
15
+ findClosestAnchor(target: EventTarget | null): HTMLElement | null;
16
+ getAnchorId(element: HTMLElement): string | null;
17
+ collectAnchors(container: HTMLElement): SomaAnchorStats;
18
+ }
@@ -0,0 +1,14 @@
1
+ import type { SomaComponentPack } from './component-pack';
2
+ export interface VerifyPackOptions {
3
+ /**
4
+ * 关掉颜色/方向的样式检查(默认开)。
5
+ * 只有在包完全不带样式、或样式由宿主统一提供时才该关——关掉意味着
6
+ * 换肤与 RTL 的正确性没有任何自动保障。
7
+ */
8
+ skipStyleChecks?: boolean;
9
+ }
10
+ /**
11
+ * 自检一个组件包,返回中文问题清单(空数组 = 通过)。
12
+ * 与体系里其它闸门同款约定:命中即拒,清单点名到具体组件与字段。
13
+ */
14
+ export declare function verifyComponentPack(pack: SomaComponentPack, options?: VerifyPackOptions): string[];
@@ -0,0 +1,71 @@
1
+ import { type SomaPipeRegistry } from '../pipes/pipe-registry';
2
+ import type { SomaDataConfig, SomaDataDicts } from '../../shared/types/data-config.types';
3
+ /** 数据对象依赖成环(`$<对象>.<字段>` 引用构成环路,无法拓扑排序) */
4
+ export declare class SomaDataCycleError extends Error {
5
+ /** 环上的对象名列表 */
6
+ readonly cycle: string[];
7
+ constructor(cycle: string[]);
8
+ }
9
+ /**
10
+ * mock 通道开关:`SOMA_MOCK_ENABLED` 环境变量(Node/构建注入)
11
+ * 或全局标记 `globalThis.SOMA_MOCK_ENABLED`(浏览器控制台/宿主注入)。
12
+ */
13
+ export declare function isSomaMockEnabled(): boolean;
14
+ /** 解析器需要的最小 http 能力(结构兼容 IHttpClient / SomaHttpService) */
15
+ export interface SomaDataHttpLike {
16
+ get<T = unknown>(url: string, config?: {
17
+ params?: Record<string, string>;
18
+ }): Promise<T>;
19
+ }
20
+ export interface SomaDataResolverOptions {
21
+ /** 依赖注入的 http 服务(后端接口是唯一数据边界) */
22
+ http: SomaDataHttpLike;
23
+ /**
24
+ * $query 读取器:注入的 query 表或取值函数;
25
+ * 缺省回退 location.search(复用 router-path 的读取逻辑)。
26
+ */
27
+ query?: Record<string, string> | ((key: string) => string);
28
+ /** $page 读取器:Domain 实例(或返回实例的函数,取最新代理引用) */
29
+ page?: object | (() => object | null | undefined);
30
+ /** 格式化管道注册表(缺省为内置管道集;Host 自定义管道经 bootstrap 传入) */
31
+ pipes?: SomaPipeRegistry;
32
+ /** locale 表提供者(money 管道货币符号等本地化取值) */
33
+ locale?: () => Record<string, unknown> | undefined;
34
+ /** mock 通道开关(缺省读 SOMA_MOCK_ENABLED 环境) */
35
+ mockEnabled?: boolean;
36
+ }
37
+ /** 解析产物:数据对象 + 字段字典 */
38
+ export interface SomaDataResolveResult {
39
+ objects: Record<string, unknown>;
40
+ dicts: SomaDataDicts;
41
+ }
42
+ export declare class SomaDataObjectResolver {
43
+ private readonly config;
44
+ private readonly http;
45
+ private readonly queryOption?;
46
+ private readonly pageOption?;
47
+ private readonly pipes;
48
+ private readonly localeProvider?;
49
+ private readonly mockEnabled;
50
+ /** 拓扑执行过程中已解析的对象(供 `$<对象>.<字段>` 引用读取) */
51
+ private objects;
52
+ constructor(config: SomaDataConfig, options: SomaDataResolverOptions);
53
+ /**
54
+ * 执行整份声明的取数编排。
55
+ * 对象按依赖 DAG 拓扑分层:同层对象(互不依赖)并发解析;成环抛 SomaDataCycleError。
56
+ */
57
+ resolve(): Promise<SomaDataResolveResult>;
58
+ /** Kahn 分层拓扑排序:返回逐层对象名(每层内部无依赖,可并发);残留节点即环 */
59
+ private buildTopologicalLayers;
60
+ private resolveObject;
61
+ private fetchSource;
62
+ /** 聚合来源结果:into 写入子键;缺省浅合并进根(非对象结果整体替换) */
63
+ private mergeSource;
64
+ /** 解析 params:`$` 引用替换为实际值 → 展平为 http query 参数表(空值参数省略) */
65
+ private resolveParams;
66
+ private resolveParamValue;
67
+ private readQuery;
68
+ private readPage;
69
+ /** 按 "字段路径 | 管道链" 补派生字段(复用 pipe-registry 链式执行) */
70
+ private applyTransform;
71
+ }
@@ -4,7 +4,8 @@ export interface SomaMutationRecord {
4
4
  timestamp: number;
5
5
  }
6
6
  export interface SomaRenderRecord {
7
- phase: 'full-render' | 'patch' | 'commit';
7
+ /** publish = 事务中途的自愿提交(长任务播进展) */
8
+ phase: 'full-render' | 'patch' | 'commit' | 'publish';
8
9
  path?: string;
9
10
  bindingCount: number;
10
11
  affectedCount: number;
@@ -0,0 +1,30 @@
1
+ /** 三段的终点标记;起点由 startBootTimings 打下 */
2
+ export type SomaBootPhase = 'assetsReady' | 'compiled' | 'rendered';
3
+ export interface SomaBootTimings {
4
+ /** 段一 资产就绪:引导开始 → 页面资产到手(ms);未走到该段为 null */
5
+ assetsMs: number | null;
6
+ /** 段二 编译完成:资产到手 → 运行时清单编译完毕(ms);未走到该段为 null */
7
+ compileMs: number | null;
8
+ /** 段三 首次渲染完成:清单编译完毕 → 首帧 DOM 写完(ms);未走到该段为 null */
9
+ renderMs: number | null;
10
+ /** 引导开始 → 首次渲染完成的总耗时(ms);未走完为 null */
11
+ totalMs: number | null;
12
+ /** 三段是否都已走完(未走完的数字不可用于 p95 统计) */
13
+ complete: boolean;
14
+ }
15
+ /** 开启打点并落下起点标记(重复调用即重新计时;供单测与手工排查直接使用) */
16
+ export declare function startBootTimings(): void;
17
+ /**
18
+ * 按需开启:仅当宿主显式置了 `globalThis.__SOMA_BOOT_TIMINGS__ = true` 才计时。
19
+ * 已在计时(含首屏已计完)时不重置——首屏只有一次,SPA 后续换页不应覆盖首屏数字;
20
+ * 要量后续页面请显式 resetBootTimings() + startBootTimings()。
21
+ */
22
+ export declare function maybeStartBootTimings(): void;
23
+ /** 落下一段的终点。未开启、首屏已计完、同段重复打点,三种情况都直接返回 */
24
+ export declare function markBootPhase(phase: SomaBootPhase): void;
25
+ /** 读取三段耗时;从未开启过打点时返回 null(调用方据此区分「没量」和「量出来是 0」) */
26
+ export declare function readBootTimings(): SomaBootTimings | null;
27
+ /** 关闭打点并清空状态,回到零开销状态(单测隔离、以及要重新量一次时使用) */
28
+ export declare function resetBootTimings(): void;
29
+ /** 当前是否在计时(宿主可据此决定要不要上报) */
30
+ export declare function isBootTimingsEnabled(): boolean;
@@ -1,4 +1,5 @@
1
1
  import type { ICache } from '../infra/cache/ICache';
2
+ import type { SomaAdaptiveVocabulary } from '../../shared/types/adaptive.types';
2
3
  import type { SomaPageAssets, ParsedRuntimeAssets } from './soma-bootstrap';
3
4
  /**
4
5
  * 资产解析器:将 SomaPageAssets 解析为引擎可消费的 ParsedRuntimeAssets。
@@ -7,9 +8,14 @@ import type { SomaPageAssets, ParsedRuntimeAssets } from './soma-bootstrap';
7
8
  * - 预编译模式:assets 中已有 uiConfig/eventConfig,直接使用,零开销
8
9
  * - 字符串模式:assets 中是 yaml 字符串,运行时解析,带 LRU 缓存
9
10
  */
11
+ export interface SomaAssetResolverOptions {
12
+ /** 阶梯词汇表(F-09):随 bootstrap 注入,用于 `_ui.yaml` 的 adaptive 校验 */
13
+ adaptiveVocabulary?: SomaAdaptiveVocabulary;
14
+ }
10
15
  export declare class SomaAssetResolver {
11
16
  private cache;
12
- constructor(cache?: ICache<ParsedRuntimeAssets>);
17
+ private readonly adaptiveVocabulary?;
18
+ constructor(cache?: ICache<ParsedRuntimeAssets>, options?: SomaAssetResolverOptions);
13
19
  resolve(assets: SomaPageAssets): ParsedRuntimeAssets;
14
20
  private parseLocale;
15
21
  private parseAppConfig;
@@ -2,7 +2,25 @@ import type { IContainerAdapter } from '../container/IContainerAdapter';
2
2
  import type { SomaCompiledBinding } from '../../shared/types/manifest.types';
3
3
  import type { BindingEntry } from '../../shared/types/engine.types';
4
4
  import type { SomaScopeResolver } from './scope-resolver';
5
+ import { type SomaPipeRegistry } from '../pipes/pipe-registry';
5
6
  export type ModelWriteBack = (path: string, value: string) => void;
7
+ /**
8
+ * 行内组件钩子:列表/对象作用域渲染遇到带 props 的锚点时回调。
9
+ * 组件管理器据此在行克隆上按需展开/更新组件实例(scopeData 为行数据)。
10
+ */
11
+ export type SomaRowComponentHook = (element: HTMLElement, propsDecl: Record<string, unknown>, scopeData: any) => void;
12
+ /**
13
+ * 行内组件释放钩子:一段**已渲染产物**即将离开 DOM 时回调(入参是被摘除的子树根)。
14
+ *
15
+ * 为什么必须有它:渲染器删行只做 DOM 层的 `remove()` / `clearRenderedChildren()`,
16
+ * 而行里可能住着组件实例(组件管理器的强引用 Set + 各自的事件引擎/控制器)。
17
+ * 没有这条通道,删掉的行会留下:onUnmount 不触发(焦点陷阱/滚动锁/定时器不回收)、
18
+ * 实例表随重渲线性膨胀、事件监听留在游离 DOM 上仍能派发 emit(幽灵行)。
19
+ * 三者都不报错——正是"静默失败"那一类。
20
+ *
21
+ * 约定:钩子在节点**还挂在树上**时调用(实现方可以再查子树),调用后渲染器才真的摘除。
22
+ */
23
+ export type SomaRowComponentReleaseHook = (removedRoot: HTMLElement) => void;
6
24
  export declare class SomaDomRenderer {
7
25
  private adapter;
8
26
  private resolver;
@@ -10,7 +28,33 @@ export declare class SomaDomRenderer {
10
28
  private modelWriteBack;
11
29
  private modelListeners;
12
30
  private modelAbort;
13
- init(adapter: IContainerAdapter, resolver: SomaScopeResolver, scopeTracker: WeakMap<HTMLElement, any>): void;
31
+ private componentHook;
32
+ private componentReleaseHook;
33
+ private pipeRegistry;
34
+ setComponentHook(hook: SomaRowComponentHook | null): void;
35
+ setComponentReleaseHook(hook: SomaRowComponentReleaseHook | null): void;
36
+ /** 摘除单个已渲染节点:先放行释放钩子,再离开 DOM(顺序不可颠倒——查子树需要它还在树上) */
37
+ private removeRendered;
38
+ /**
39
+ * 清空容器内的渲染产物(保留 <template>)。
40
+ * 与 `adapter.clearRenderedChildren` 的唯一区别:逐个放行释放钩子。
41
+ * 无钩子时(非组件页面)零额外开销,直接走适配器原路径。
42
+ */
43
+ private clearRendered;
44
+ init(adapter: IContainerAdapter, resolver: SomaScopeResolver, scopeTracker: WeakMap<HTMLElement, any>, pipeRegistry?: SomaPipeRegistry): void;
45
+ /**
46
+ * 行/对象作用域内查找锚点(经适配器,页面 data-soma-id 与实例 data-soma-scoped-id 同构):
47
+ * 行模板根元素自身就是锚点时也要命中(querySelector 只搜后代,
48
+ * 此前根自身锚点会静默失配,如 cart_row@title)。
49
+ */
50
+ private findScopedAnchor;
51
+ /** 收集列表容器的变体模板:'item' 默认 + 'item:变体'(异构列表 role_by 用) */
52
+ private collectRoleTemplates;
53
+ /** 异构列表:按行数据取模板与变体名;同构列表回落默认模板 */
54
+ private pickRowTemplate;
55
+ /** 页面作用域的管道上下文(编译路径 text/attr 用) */
56
+ private rootPipeContext;
57
+ private applyPipes;
14
58
  setModelWriteBack(fn: ModelWriteBack): void;
15
59
  bindEntry(binding: SomaCompiledBinding, container: HTMLElement): BindingEntry | null;
16
60
  /**
@@ -32,8 +76,12 @@ export declare class SomaDomRenderer {
32
76
  private renderObj;
33
77
  private applyShowConfig;
34
78
  private applyNestedShowConfig;
79
+ /** 嵌套列表的按行选模板:role_by 命中 item:<值> 变体,否则回落默认模板 */
80
+ private pickNestedTemplate;
35
81
  private appendNestedTemplateItem;
36
82
  private applyExtendedShowConfig;
83
+ /** 行作用域展示值:透明处理管道(`item.price | money`),无管道走原路径 */
84
+ private resolveRowValue;
37
85
  private resolveShowValue;
38
86
  private parseConditionalPath;
39
87
  private isNestedShowMapping;
@@ -0,0 +1,6 @@
1
+ export declare class SomaEmitEvent extends Event {
2
+ readonly emitName: string;
3
+ readonly payload: unknown;
4
+ constructor(emitName: string, payload?: unknown);
5
+ }
6
+ export declare function isSomaEmitEvent(event: Event): event is SomaEmitEvent;
@@ -53,6 +53,12 @@ export declare class SomaEventEngine<TContext extends Record<string, unknown> =
53
53
  * 避免点击 product_name 等子节点时,closest 停在无事件的子 id 上。
54
54
  */
55
55
  private resolveEventBinding;
56
+ /**
57
+ * 从候选里挑与本次按键匹配的那条。
58
+ * 没有候选列表(绝大多数绑定)时原样返回,不产生任何额外判断成本。
59
+ * 一条都不匹配时返回 undefined —— 按了无关按键就该什么都不发生。
60
+ */
61
+ private pickKeyVariant;
56
62
  execute(config: SomaCompiledEvent, element: HTMLElement, originalEvent: Event): Promise<void>;
57
63
  destroy(): void;
58
64
  private executeNow;
@@ -17,9 +17,12 @@ export interface SomaRenderEngineOptions {
17
17
  diagnostics?: SomaDiagnostics;
18
18
  middleware?: SomaMiddlewareChain<SomaRenderMiddlewareContext>;
19
19
  propertyWatcher?: SomaPropertyWatcher;
20
+ /** 格式化管道注册表(缺省内置管道集) */
21
+ pipeRegistry?: import('../pipes/pipe-registry').SomaPipeRegistry;
20
22
  }
21
23
  export interface SomaRenderMiddlewareContext {
22
- phase: 'full-render' | 'patch' | 'commit';
24
+ /** publish = 事务中途的自愿提交(长任务播进展),其余含义见 render-engine 各方法 */
25
+ phase: 'full-render' | 'patch' | 'commit' | 'publish';
23
26
  path?: string;
24
27
  changedPaths: string[];
25
28
  bindings: BindingEntry[];
@@ -44,6 +47,14 @@ export declare class SomaRenderEngine {
44
47
  private initProps;
45
48
  constructor(options: SomaRenderEngineOptions);
46
49
  getScopeTracker(): WeakMap<HTMLElement, any>;
50
+ getRegisteredSomaIds(): string[];
51
+ /** 装配行内组件钩子(组件管理器调用,见 dom-renderer.SomaRowComponentHook) */
52
+ setComponentHook(hook: import('./dom-renderer').SomaRowComponentHook | null): void;
53
+ /**
54
+ * 装配行内组件**释放**钩子:删行/清空产物前放行,组件管理器据此销毁行内实例。
55
+ * 与 setComponentHook 成对存在——只有挂载没有卸载,就是泄漏。
56
+ */
57
+ setComponentReleaseHook(hook: import('./dom-renderer').SomaRowComponentReleaseHook | null): void;
47
58
  /** 注册属性监听器(文档 §10.2 watch API) */
48
59
  watch(path: string, callback: WatchCallback, options?: WatcherOptions): () => void;
49
60
  getPropertyWatcher(): SomaPropertyWatcher;
@@ -57,6 +68,20 @@ export declare class SomaRenderEngine {
57
68
  endTransaction(): void;
58
69
  /** 一次性提交事务内积累的 dirty path(Phase 2 commit 点) */
59
70
  commit(): Promise<void>;
71
+ /**
72
+ * 事务**中途**的自愿提交点:把此刻积累的 patch 立刻上屏,事务不结束。
73
+ *
74
+ * 为什么需要它:一次事件 = 一次原子提交,是这套事务语义刻意的设计(避免中间态闪烁、
75
+ * 出错时 discardPendingPatches 能整体回滚)。但它有个代价——**长任务里的中途进展
76
+ * 播不出去**:实测 AI 生成一次 P50 约 40 秒,期间 Domain 改了多少次 statusText,
77
+ * 界面一次都不会动,连"生成中"都看不到;用户分不清"在想"还是"卡死"。
78
+ *
79
+ * 这里给的是**自愿**的中途提交,而不是把事务拆掉:
80
+ * - 不调用它 → 行为与过去逐字节一致(原子提交 + 失败回滚),存量页面零影响;
81
+ * - 调用它 → 调用方明确知道:**已经上屏的这部分不再享有失败回滚**。
82
+ * 这个取舍必须由业务自己做——它才知道"这一帧值不值得让用户看见"。
83
+ */
84
+ publishInTransaction(): Promise<void>;
60
85
  /** force 全量 render 前丢弃 pending patch(避免 commit + render 双写) */
61
86
  discardPendingPatches(): void;
62
87
  isInTransaction(): boolean;
@@ -1,3 +1,4 @@
1
+ import type { SomaAdaptiveVocabulary } from '../../shared/types/adaptive.types';
1
2
  import type { IContainerAdapter } from '../container/IContainerAdapter';
2
3
  import type { SomaDiagnostics } from '../diagnostics/SomaDiagnostics';
3
4
  import type { SomaMiddlewareChain } from '../middleware/SomaMiddlewareChain';
@@ -31,6 +32,10 @@ export interface RuntimeBuildInput {
31
32
  diagnostics: SomaDiagnostics;
32
33
  renderMiddleware?: SomaMiddlewareChain<SomaRenderMiddlewareContext>;
33
34
  eventMiddleware?: SomaMiddlewareChain<SomaEventMiddlewareContext>;
35
+ /** 格式化管道注册表(缺省内置管道集) */
36
+ pipeRegistry?: import('../pipes/pipe-registry').SomaPipeRegistry;
37
+ /** 阶梯词汇表(F-09),经宿主 bootstrap 注入;无 adaptive 声明的页面用不到 */
38
+ adaptiveVocabulary?: SomaAdaptiveVocabulary;
34
39
  }
35
40
  export interface SomaRuntime {
36
41
  renderEngine: SomaRenderEngine;
@@ -41,6 +46,8 @@ export interface SomaRuntime {
41
46
  triggerEngine: SomaTriggerEngine;
42
47
  timerEngine: SomaTimerEngine;
43
48
  resolver: SomaScopeResolver;
49
+ /** 页面运行时清单(组件管理器标记 emit 路由用) */
50
+ manifest: import('../../shared/types/manifest.types').SomaRuntimeManifest;
44
51
  }
45
52
  /**
46
53
  * 运行时构建器:将配置 + 实例 + DOM 组装为可运行的引擎组。
@@ -8,12 +8,17 @@ import type { PropertyTrigger } from '../../shared/types/trigger.types';
8
8
  import type { ParsedTimer } from '../../shared/types/timer.types';
9
9
  import type { StyleConfig } from '../../shared/types/style-config.types';
10
10
  import type { UiConfig } from '../../shared/types/ui-config.types';
11
+ import type { SomaAdaptiveVocabulary } from '../../shared/types/adaptive.types';
11
12
  import type { SomaPageRoot } from '../../shared/types/domain.types';
12
13
  import { SomaAssetResolver } from './asset-resolver';
13
14
  import type { SomaEventMiddlewareContext } from './event-engine';
14
15
  import type { SomaRenderEngine, SomaRenderMiddlewareContext } from './render-engine';
15
16
  import type { SomaStyleBinder } from './style-binder';
17
+ import type { SomaDataConfig, SomaDataDicts } from '../../shared/types/data-config.types';
16
18
  import type { WatchCallback, WatcherOptions } from '../../shared/types/watcher.types';
19
+ import type { SomaComponentDefinition } from '../component/component-definition.types';
20
+ import { type SomaPipeFn } from '../pipes/pipe-registry';
21
+ import { type SomaErrorEvent, type SomaPageIdentity } from '../observability/error-reporter';
17
22
  export interface SomaPageAssets {
18
23
  html: string;
19
24
  includes?: Record<string, string>;
@@ -23,6 +28,13 @@ export interface SomaPageAssets {
23
28
  styleYaml?: string;
24
29
  localeYaml?: string;
25
30
  appConfigYaml?: string;
31
+ /**
32
+ * 数据对象层声明(*_data.yaml,五件套可选件)。
33
+ * 提供后 bootstrap 在首渲前解析声明、异步取数并注入 page.data,
34
+ * 完成后触发一次全量渲染;解析/取数失败不阻塞页面(data 保持空对象 + console.error)。
35
+ * 不提供时加载路径零变化。
36
+ */
37
+ dataYaml?: string;
26
38
  uiConfig?: UiConfig;
27
39
  eventConfig?: ParsedEvent[];
28
40
  triggerConfig?: PropertyTrigger[];
@@ -30,8 +42,36 @@ export interface SomaPageAssets {
30
42
  styleConfig?: StyleConfig;
31
43
  locale?: Record<string, unknown>;
32
44
  appConfig?: unknown;
45
+ /** 数据对象层声明的预编译形态(构建阶段已解析校验,优先于 dataYaml) */
46
+ dataConfig?: SomaDataConfig;
33
47
  /** Full router path including query string (e.g. /items/detail?id=1) */
34
48
  routerPath?: string;
49
+ /**
50
+ * 组件运行时定义(组件体系模块 7,可选)。
51
+ * 键为契约名;页面 HTML 中 data-soma-component 引用的组件必须在此提供。
52
+ * 不提供时组件能力整体旁路,页面走既有路径。
53
+ */
54
+ components?: Record<string, SomaComponentDefinition>;
55
+ }
56
+ /**
57
+ * 错误采集接线声明(可观测性,默认关闭)。
58
+ *
59
+ * 为什么放在 bootstrap 而不是让 Host 自己 install:采集器本身只会记"出了什么错",
60
+ * 记不住"这是哪个页面的哪个版本"——而页面身份只有挂载时点知道。挂在生命周期
61
+ * 编排器上,身份随挂载自动盖戳、随卸载自动摘监听,Host 不需要维护任何状态。
62
+ */
63
+ export interface SomaBootstrapErrorReporting {
64
+ /** 页面身份:错误归因到「页面名@版本」的唯一依据(声明态页面必须带 version) */
65
+ page: SomaPageIdentity;
66
+ /**
67
+ * 上报通道。缺省走 console.error 单行 JSON——宿主一行开启就先有数据,
68
+ * 等接了真通道(sendBeacon / 第三方 SDK)再替换,不必为"先看看"写胶水。
69
+ */
70
+ report?: (event: SomaErrorEvent) => void;
71
+ /** 同签名错误去重窗口(毫秒),透传采集器 */
72
+ dedupeWindowMs?: number;
73
+ /** 单页上报条数上限,透传采集器 */
74
+ maxEvents?: number;
35
75
  }
36
76
  export interface SomaBootstrapOptions {
37
77
  adapter?: IContainerAdapter;
@@ -39,6 +79,25 @@ export interface SomaBootstrapOptions {
39
79
  diagnostics?: SomaDiagnostics;
40
80
  telemetry?: SomaTelemetry;
41
81
  assetResolver?: SomaAssetResolver;
82
+ /**
83
+ * Host 级组件注册(组件体系模块 7)。
84
+ * 经 `@soma-host/bootstrap/soma-bootstrap.ts` 的 configureSomaBootstrap 注入,
85
+ * 对该 Host 的所有页面生效;页面资产 components 同名时覆盖 Host 级定义。
86
+ */
87
+ components?: Record<string, SomaComponentDefinition>;
88
+ /**
89
+ * Host 自定义格式化管道(模块 7 U4):{ 管道名: 纯函数 },与内置管道合并。
90
+ * 内置:money / tpl / date / percent / plural。
91
+ */
92
+ pipes?: Record<string, SomaPipeFn>;
93
+ /**
94
+ * 阶梯词汇注册位(F-09 / 契约 C5),与组件注册同点:
95
+ * `adaptiveVocabulary: createSomaUiAdaptiveVocabulary()`。
96
+ *
97
+ * core **不内置任何级语义**——语法归语言、词汇归组件。不注册而页面声明了
98
+ * `adaptive.ladder` 时按"词汇未知"快速失败,而不是静默忽略那些级。
99
+ */
100
+ adaptiveVocabulary?: SomaAdaptiveVocabulary;
42
101
  /** Render-engine middleware chain (opt-in) */
43
102
  renderMiddleware?: SomaMiddlewareChain<SomaRenderMiddlewareContext>;
44
103
  /**
@@ -46,6 +105,11 @@ export interface SomaBootstrapOptions {
46
105
  * Use `createPermissionMiddleware` when events declare `permission:code` in pipeline.
47
106
  */
48
107
  eventMiddleware?: SomaMiddlewareChain<SomaEventMiddlewareContext>;
108
+ /**
109
+ * 错误采集接线(默认关闭:不给就一个全局监听都不装)。
110
+ * 库不该擅自劫持 window 的错误钩子,是否采集由 Host 显式决定。
111
+ */
112
+ errorReporting?: SomaBootstrapErrorReporting;
49
113
  }
50
114
  export interface ParsedRuntimeAssets {
51
115
  uiConfig: UiConfig;
@@ -73,13 +137,29 @@ export declare class SomaBootstrap {
73
137
  private triggerEngine;
74
138
  private timerEngine;
75
139
  private parsedTimers;
140
+ private runtimeResolver;
76
141
  private proxy;
77
142
  private domainInstance;
143
+ private componentManager;
144
+ private hostComponents;
145
+ private pipeRegistry;
146
+ /** 阶梯词汇表:Host 级注册,对该 Host 全部页面生效;未注册时恒为 undefined */
147
+ private readonly adaptiveVocabulary?;
148
+ /** 数据对象层:当前页面的声明(无 *_data.yaml 时为 null,整条路径旁路) */
149
+ private dataConfig;
150
+ /** 数据对象层:最近一次取数任务(whenDataReady 暴露给测试/调试) */
151
+ private dataReady;
152
+ /** 数据对象层:字段字典产物(soma-ui 双态映射消费) */
153
+ private dataDicts;
78
154
  private mounted;
79
155
  private diagnostics;
80
156
  private readonly telemetry;
81
157
  private container;
82
158
  private assets;
159
+ /** 错误采集配置(null = 未开启,整条路径旁路) */
160
+ private readonly errorReporting;
161
+ /** 错误采集句柄:mount 时装、cleanup 时摘,生命周期与页面严格同寿 */
162
+ private errorReporter;
83
163
  constructor(options?: SomaBootstrapOptions);
84
164
  mount(container: HTMLElement, assets: SomaPageAssets): Promise<void>;
85
165
  hotSwap(overrides: Partial<SomaPageAssets>, options?: {
@@ -99,11 +179,53 @@ export declare class SomaBootstrap {
99
179
  switchTheme(themeName: string | null): void;
100
180
  /** 获取当前挂载的业务实例(测试 / 调试) */
101
181
  getDomainInstance(): SomaPageRoot | null;
182
+ isInitialized(): boolean;
183
+ isSettled(): boolean;
184
+ whenSettled(): Promise<void>;
185
+ getDomainValue(path: string): unknown;
186
+ getRegisteredSomaIds(): string[];
187
+ /** 数据对象层字段字典产物(对象名 → 字段名 → 字典条目;无声明时为空对象) */
188
+ getDataDicts(): SomaDataDicts;
189
+ /** 等待当前数据对象取数任务完成(测试 / 调试;无声明时立即 resolve) */
190
+ whenDataReady(): Promise<void>;
102
191
  /** 获取渲染引擎(测试 / 调试) */
103
192
  getRenderEngine(): SomaRenderEngine | null;
104
193
  /** 监听属性变更(委托 RenderEngine.watch) */
105
194
  watch(path: string, callback: WatchCallback, options?: WatcherOptions): () => void;
195
+ /**
196
+ * 更新错误采集的页面身份。
197
+ * 声明态页面"发布新版本 → 原地重渲"时调用,后续错误立刻落在新版本上——
198
+ * 这一个调用就是"哪个版本引入的错误"这个问题的全部答案。
199
+ * 未开启采集时是安全的空操作。
200
+ */
201
+ setErrorReportingPage(page: SomaPageIdentity): void;
202
+ /** 装(或复用)错误采集器;未配置时整条路径旁路,一个全局监听都不装 */
203
+ private setupErrorReporting;
204
+ /**
205
+ * 引擎自身捕获的异常进同一采集通道。
206
+ * 全局 error 监听抓不到这些——它们已经被引擎 catch 住了(页面不崩,但确实错了),
207
+ * 不显式补一条,可观测数据就会漏掉最该看的那类问题。
208
+ */
209
+ private captureEngineError;
106
210
  private createDomainInstance;
211
+ /**
212
+ * 首渲前解析数据对象声明并向 Domain 实例注入 reloadData 钩子。
213
+ * 无声明(dataConfig/dataYaml 均缺省)时整条路径旁路,加载零变化;
214
+ * 声明非法只 console.error,页面继续以空 data 挂载(不阻塞)。
215
+ */
216
+ private prepareDataLayer;
217
+ /**
218
+ * 执行数据对象取数:解析完成后注入 page.data、缓存字段字典并触发一次全量渲染。
219
+ * 任何失败均不阻塞页面:data 置空对象 + console.error。
220
+ */
221
+ private loadDataObjects;
222
+ /**
223
+ * 主题派生注入:app.config 声明 theme.brand 时全库换装;配置非法只告警不阻断挂载。
224
+ * 主题是引擎内建路径,不是 bootstrap 可注册能力。
225
+ */
226
+ private applyHostTheme;
227
+ /** 组件管理器装配:无 components 资产时保持 null,组件能力整体旁路 */
228
+ private setupComponentManager;
107
229
  private buildRuntime;
108
230
  private startDeclarativeTimers;
109
231
  private stopDeclarativeTimers;