soma-core 1.3.2 → 1.3.4

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 (281) hide show
  1. package/README.md +43 -0
  2. package/app/SomaPageClient.tsx +22 -68
  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/bin/soma-lsp.cjs +1 -4
  13. package/core/build/compiler/full-manifest-builder.ts +19 -23
  14. package/core/build/compiler/html-include-expander.ts +56 -0
  15. package/core/build/compiler/page-assets.ts +26 -0
  16. package/core/build/compiler/page-declaration-compiler.ts +85 -0
  17. package/core/build/compiler/rollup-plugin-soma.ts +4 -13
  18. package/core/build/compiler/route-builder.ts +0 -2
  19. package/core/build/compiler/rspack-plugin-soma.js +1 -10
  20. package/core/build/compiler/soma-manifest-webpack-plugin.js +54 -9
  21. package/core/build/compiler/soma-precompile.js +3581 -2387
  22. package/core/build/compiler/soma-precompile.ts +44 -2
  23. package/core/build/compiler/soma-rspack-yaml-loader.js +5 -8
  24. package/core/build/compiler/soma-webpack-loader.js +6 -15
  25. package/core/build/compiler/vite-plugin-soma.ts +9 -21
  26. package/core/build/component/pack-from-dir.ts +58 -0
  27. package/core/build/component/package-loader.ts +281 -0
  28. package/core/build/eject/apply-eject.ts +133 -0
  29. package/core/build/eject/plan-eject.ts +133 -0
  30. package/core/build/lsp/cross-file-diagnostics.cjs +82 -113
  31. package/core/build/lsp/extra-completion.cjs +14 -8
  32. package/core/build/lsp/lsp-navigation.cjs +50 -43
  33. package/core/build/lsp/soma-declaration.cjs +85 -0
  34. package/core/build/lsp/ui-yaml-completion.cjs +98 -104
  35. package/core/build/v2/block-compile.ts +200 -0
  36. package/core/build/v2/block-loader.ts +33 -0
  37. package/core/build/v2/html-index.ts +120 -0
  38. package/core/build/v2/migrate-v1.ts +370 -0
  39. package/core/build/v2/soma-file-loader.ts +216 -0
  40. package/core/client/adaptive/flush-scheduler.ts +96 -0
  41. package/core/client/adaptive/hysteresis.ts +56 -0
  42. package/core/client/adaptive/index.ts +23 -0
  43. package/core/client/adaptive/observer-pool.ts +90 -0
  44. package/core/client/base/SomaPageRootBase.ts +50 -0
  45. package/core/client/compiler/adaptive-compile.ts +136 -0
  46. package/core/client/compiler/manifest-compiler.ts +155 -27
  47. package/core/client/component/ai-catalog.ts +277 -0
  48. package/core/client/component/component-definition.types.ts +65 -0
  49. package/core/client/component/component-expander.ts +119 -0
  50. package/core/client/component/component-manager.ts +933 -0
  51. package/core/client/component/component-pack.ts +445 -0
  52. package/core/client/component/component-registry.ts +71 -0
  53. package/core/client/component/contract-compat.ts +132 -0
  54. package/core/client/component/example-v2.ts +132 -0
  55. package/core/client/component/pack-styles.ts +94 -0
  56. package/core/client/component/scoped-adapter.ts +85 -0
  57. package/core/client/component/verify-pack.ts +247 -0
  58. package/core/client/container/MiniProgramContainerAdapter.ts +15 -1
  59. package/core/client/container/ReactNativeContainerAdapter.ts +15 -1
  60. package/core/client/container/SomaContainerAdapter.ts +186 -180
  61. package/core/client/data/data-object-resolver.ts +417 -0
  62. package/core/client/diagnostics/SomaDiagnostics.ts +187 -186
  63. package/core/client/diagnostics/boot-timings.ts +152 -0
  64. package/core/client/engine/asset-resolver.ts +12 -2
  65. package/core/client/engine/dom-renderer.ts +249 -24
  66. package/core/client/engine/emit-event.ts +21 -0
  67. package/core/client/engine/event-engine.ts +34 -4
  68. package/core/client/engine/on-change-engine.ts +1 -1
  69. package/core/client/engine/property-watcher.ts +1 -1
  70. package/core/client/engine/reactive-proxy.ts +11 -10
  71. package/core/client/engine/render-engine.ts +39 -4
  72. package/core/client/engine/runtime-builder.ts +23 -0
  73. package/core/client/engine/soma-bootstrap.ts +380 -7
  74. package/core/client/engine/style-binder.ts +47 -1
  75. package/core/client/observability/error-reporter.ts +173 -0
  76. package/core/client/parser/adaptive-parser.ts +264 -0
  77. package/core/client/parser/data-config-parser.ts +396 -0
  78. package/core/client/parser/pipeline-parser.ts +15 -3
  79. package/core/client/parser/style-config-parser.ts +65 -2
  80. package/core/client/parser/ui-config-parser.ts +52 -3
  81. package/core/client/parser/v2/namespace.ts +182 -0
  82. package/core/client/parser/v2/page-parser.ts +359 -0
  83. package/core/client/parser/v2/use-parser.ts +412 -0
  84. package/core/client/parser/value-lang.ts +340 -0
  85. package/core/client/pipes/pipe-registry.ts +249 -0
  86. package/core/client/quality/SomaQualityRegistry.ts +3 -0
  87. package/core/client/registry/declaration-renderer.ts +161 -0
  88. package/core/client/registry/index.ts +28 -0
  89. package/core/client/registry/page-lifecycle.ts +171 -0
  90. package/core/client/registry/remote-page.ts +139 -0
  91. package/core/client/runtime/SomaRuntimeServices.ts +24 -0
  92. package/core/client/security/attribute-presence.ts +70 -0
  93. package/core/client/security/html-sanitizer.ts +113 -0
  94. package/core/client/security/url-guard.ts +0 -0
  95. package/core/client/theme/harmony.ts +307 -0
  96. package/core/client/theme/scene-tokens.ts +134 -0
  97. package/core/client/theme/theme-axes.ts +228 -0
  98. package/core/client/theme/theme-engine.ts +1196 -0
  99. package/core/client/theme/tone-solver.ts +118 -0
  100. package/core/client/typography/typography-base.ts +34 -0
  101. package/core/client/validation/contract-validator.ts +48 -5
  102. package/core/index.ts +262 -2
  103. package/core/server/api/IService.ts +18 -6
  104. package/core/server/api/load-host-service.ts +3 -3
  105. package/core/server/host/content-security-policy.ts +190 -0
  106. package/core/server/host/csp-nonce-metadata.ts +75 -0
  107. package/core/server/host/resolve-host-request-hook.ts +5 -0
  108. package/core/server/host/server-page-assets.ts +34 -7
  109. package/core/server/host/soma-page-compile.ts +33 -0
  110. package/core/server/index.ts +45 -1
  111. package/core/server/infra/cache/ServerFileCache.ts +1 -1
  112. package/core/server/mock/node/cli.mjs +2 -2
  113. package/core/server/registry/api-registry-store.ts +518 -0
  114. package/core/server/registry/conditional-object-store.ts +29 -0
  115. package/core/server/registry/declaration-precompiler.ts +99 -0
  116. package/core/server/registry/in-memory-conditional-object-store.ts +43 -0
  117. package/core/server/registry/index.ts +142 -0
  118. package/core/server/registry/page-registry-repository.ts +373 -0
  119. package/core/server/registry/page-registry-store.ts +932 -0
  120. package/core/server/registry/registry-error.ts +17 -0
  121. package/core/server/registry/registry-file-lock.ts +173 -0
  122. package/core/server/registry/registry-response.ts +71 -0
  123. package/core/server/registry/registry-subjects.ts +194 -0
  124. package/core/server/registry/registry-write-pipeline.ts +240 -0
  125. package/core/server/registry/request-body-limit.ts +99 -0
  126. package/core/server/registry/services/apis/Get.ts +25 -0
  127. package/core/server/registry/services/apis/List.ts +41 -0
  128. package/core/server/registry/services/apis/Register.ts +39 -0
  129. package/core/server/registry/services/apis/Unregister.ts +24 -0
  130. package/core/server/registry/services/index.ts +40 -0
  131. package/core/server/registry/services/pages/Get.ts +96 -0
  132. package/core/server/registry/services/pages/List.ts +53 -0
  133. package/core/server/registry/services/pages/Register.ts +49 -0
  134. package/core/server/registry/services/pages/Rollback.ts +36 -0
  135. package/core/server/registry/services/pages/Unregister.ts +23 -0
  136. package/core/server/registry/services/service-utils.ts +21 -0
  137. package/core/server/registry/validation/compile-gate.ts +54 -0
  138. package/core/server/registry/validation/component-existence.ts +55 -0
  139. package/core/server/registry/validation/credential-ban.ts +86 -0
  140. package/core/server/registry/validation/cross-check.ts +67 -0
  141. package/core/server/registry/validation/declaration-safety-scan.ts +102 -0
  142. package/core/shared/types/adaptive.types.ts +109 -0
  143. package/core/shared/types/component-contract.types.ts +120 -0
  144. package/core/shared/types/data-config.types.ts +105 -0
  145. package/core/shared/types/domain.types.ts +6 -0
  146. package/core/shared/types/engine.types.ts +41 -35
  147. package/core/shared/types/manifest.types.ts +55 -32
  148. package/core/shared/types/scope-manifest.types.ts +96 -0
  149. package/core/shared/types/style-config.types.ts +9 -0
  150. package/core/shared/types/ui-config.types.ts +118 -98
  151. package/dist/cli/soma.js +20 -5
  152. package/dist/core/index.cjs +7811 -1380
  153. package/dist/types/build/compiler/full-manifest-builder.d.ts +6 -2
  154. package/dist/types/build/compiler/html-include-expander.d.ts +19 -0
  155. package/dist/types/build/compiler/page-assets.d.ts +3 -0
  156. package/dist/types/build/compiler/page-declaration-compiler.d.ts +33 -0
  157. package/dist/types/build/compiler/rollup-plugin-soma.d.ts +0 -2
  158. package/dist/types/build/compiler/route-builder.d.ts +0 -1
  159. package/dist/types/build/compiler/soma-precompile.d.ts +17 -0
  160. package/dist/types/build/compiler/vite-plugin-soma.d.ts +2 -7
  161. package/dist/types/build/component/pack-from-dir.d.ts +17 -0
  162. package/dist/types/build/component/package-loader.d.ts +40 -0
  163. package/dist/types/build/eject/apply-eject.d.ts +22 -0
  164. package/dist/types/build/eject/plan-eject.d.ts +32 -0
  165. package/dist/types/build/v2/block-compile.d.ts +28 -0
  166. package/dist/types/build/v2/block-loader.d.ts +9 -0
  167. package/dist/types/build/v2/html-index.d.ts +37 -0
  168. package/dist/types/build/v2/migrate-v1.d.ts +32 -0
  169. package/dist/types/build/v2/soma-file-loader.d.ts +45 -0
  170. package/dist/types/client/adaptive/flush-scheduler.d.ts +13 -0
  171. package/dist/types/client/adaptive/hysteresis.d.ts +16 -0
  172. package/dist/types/client/adaptive/index.d.ts +5 -0
  173. package/dist/types/client/adaptive/observer-pool.d.ts +15 -0
  174. package/dist/types/client/base/SomaPageRootBase.d.ts +33 -0
  175. package/dist/types/client/compiler/adaptive-compile.d.ts +26 -0
  176. package/dist/types/client/compiler/manifest-compiler.d.ts +13 -2
  177. package/dist/types/client/component/ai-catalog.d.ts +73 -0
  178. package/dist/types/client/component/component-definition.types.d.ts +54 -0
  179. package/dist/types/client/component/component-expander.d.ts +25 -0
  180. package/dist/types/client/component/component-manager.d.ts +160 -0
  181. package/dist/types/client/component/component-pack.d.ts +110 -0
  182. package/dist/types/client/component/component-registry.d.ts +12 -0
  183. package/dist/types/client/component/contract-compat.d.ts +16 -0
  184. package/dist/types/client/component/example-v2.d.ts +9 -0
  185. package/dist/types/client/component/pack-styles.d.ts +22 -0
  186. package/dist/types/client/component/scoped-adapter.d.ts +18 -0
  187. package/dist/types/client/component/verify-pack.d.ts +14 -0
  188. package/dist/types/client/data/data-object-resolver.d.ts +71 -0
  189. package/dist/types/client/diagnostics/SomaDiagnostics.d.ts +2 -1
  190. package/dist/types/client/diagnostics/boot-timings.d.ts +30 -0
  191. package/dist/types/client/engine/asset-resolver.d.ts +7 -1
  192. package/dist/types/client/engine/dom-renderer.d.ts +51 -1
  193. package/dist/types/client/engine/emit-event.d.ts +6 -0
  194. package/dist/types/client/engine/event-engine.d.ts +6 -0
  195. package/dist/types/client/engine/render-engine.d.ts +25 -1
  196. package/dist/types/client/engine/runtime-builder.d.ts +7 -0
  197. package/dist/types/client/engine/soma-bootstrap.d.ts +118 -0
  198. package/dist/types/client/observability/error-reporter.d.ts +51 -0
  199. package/dist/types/client/parser/adaptive-parser.d.ts +28 -0
  200. package/dist/types/client/parser/data-config-parser.d.ts +34 -0
  201. package/dist/types/client/parser/pipeline-parser.d.ts +2 -0
  202. package/dist/types/client/parser/style-config-parser.d.ts +5 -3
  203. package/dist/types/client/parser/ui-config-parser.d.ts +22 -1
  204. package/dist/types/client/parser/v2/namespace.d.ts +52 -0
  205. package/dist/types/client/parser/v2/page-parser.d.ts +21 -0
  206. package/dist/types/client/parser/v2/use-parser.d.ts +72 -0
  207. package/dist/types/client/parser/value-lang.d.ts +63 -0
  208. package/dist/types/client/pipes/pipe-registry.d.ts +38 -0
  209. package/dist/types/client/registry/declaration-renderer.d.ts +50 -0
  210. package/dist/types/client/registry/index.d.ts +10 -0
  211. package/dist/types/client/registry/page-lifecycle.d.ts +61 -0
  212. package/dist/types/client/registry/remote-page.d.ts +52 -0
  213. package/dist/types/client/runtime/SomaRuntimeServices.d.ts +16 -0
  214. package/dist/types/client/security/attribute-presence.d.ts +7 -0
  215. package/dist/types/client/security/html-sanitizer.d.ts +37 -0
  216. package/dist/types/client/security/url-guard.d.ts +11 -0
  217. package/dist/types/client/theme/harmony.d.ts +77 -0
  218. package/dist/types/client/theme/scene-tokens.d.ts +25 -0
  219. package/dist/types/client/theme/theme-axes.d.ts +81 -0
  220. package/dist/types/client/theme/theme-engine.d.ts +77 -0
  221. package/dist/types/client/theme/tone-solver.d.ts +47 -0
  222. package/dist/types/client/typography/typography-base.d.ts +15 -0
  223. package/dist/types/client/validation/contract-validator.d.ts +2 -0
  224. package/dist/types/index.d.ts +47 -2
  225. package/dist/types/server/api/IService.d.ts +18 -6
  226. package/dist/types/server/host/content-security-policy.d.ts +53 -0
  227. package/dist/types/server/host/csp-nonce-metadata.d.ts +32 -0
  228. package/dist/types/server/host/resolve-host-request-hook.d.ts +5 -0
  229. package/dist/types/server/host/server-page-assets.d.ts +2 -0
  230. package/dist/types/server/host/soma-page-compile.d.ts +7 -0
  231. package/dist/types/server/index.d.ts +6 -1
  232. package/dist/types/server/registry/api-registry-store.d.ts +141 -0
  233. package/dist/types/server/registry/conditional-object-store.d.ts +27 -0
  234. package/dist/types/server/registry/declaration-precompiler.d.ts +30 -0
  235. package/dist/types/server/registry/in-memory-conditional-object-store.d.ts +8 -0
  236. package/dist/types/server/registry/index.d.ts +29 -0
  237. package/dist/types/server/registry/page-registry-repository.d.ts +58 -0
  238. package/dist/types/server/registry/page-registry-store.d.ts +259 -0
  239. package/dist/types/server/registry/registry-error.d.ts +12 -0
  240. package/dist/types/server/registry/registry-file-lock.d.ts +20 -0
  241. package/dist/types/server/registry/registry-response.d.ts +18 -0
  242. package/dist/types/server/registry/registry-subjects.d.ts +59 -0
  243. package/dist/types/server/registry/registry-write-pipeline.d.ts +48 -0
  244. package/dist/types/server/registry/request-body-limit.d.ts +31 -0
  245. package/dist/types/server/registry/services/apis/Get.d.ts +10 -0
  246. package/dist/types/server/registry/services/apis/List.d.ts +10 -0
  247. package/dist/types/server/registry/services/apis/Register.d.ts +13 -0
  248. package/dist/types/server/registry/services/apis/Unregister.d.ts +12 -0
  249. package/dist/types/server/registry/services/index.d.ts +3 -0
  250. package/dist/types/server/registry/services/pages/Get.d.ts +10 -0
  251. package/dist/types/server/registry/services/pages/List.d.ts +13 -0
  252. package/dist/types/server/registry/services/pages/Register.d.ts +11 -0
  253. package/dist/types/server/registry/services/pages/Rollback.d.ts +9 -0
  254. package/dist/types/server/registry/services/pages/Unregister.d.ts +9 -0
  255. package/dist/types/server/registry/services/service-utils.d.ts +10 -0
  256. package/dist/types/server/registry/validation/compile-gate.d.ts +12 -0
  257. package/dist/types/server/registry/validation/component-existence.d.ts +14 -0
  258. package/dist/types/server/registry/validation/credential-ban.d.ts +15 -0
  259. package/dist/types/server/registry/validation/cross-check.d.ts +16 -0
  260. package/dist/types/server/registry/validation/declaration-safety-scan.d.ts +15 -0
  261. package/dist/types/shared/types/adaptive.types.d.ts +88 -0
  262. package/dist/types/shared/types/component-contract.types.d.ts +78 -0
  263. package/dist/types/shared/types/data-config.types.d.ts +81 -0
  264. package/dist/types/shared/types/domain.types.d.ts +6 -0
  265. package/dist/types/shared/types/engine.types.d.ts +6 -0
  266. package/dist/types/shared/types/manifest.types.d.ts +23 -0
  267. package/dist/types/shared/types/scope-manifest.types.d.ts +82 -0
  268. package/dist/types/shared/types/style-config.types.d.ts +8 -0
  269. package/dist/types/shared/types/ui-config.types.d.ts +20 -0
  270. package/editor/vscode/package.json +1 -24
  271. package/global.d.ts +5 -11
  272. package/next.config.js +85 -28
  273. package/package.json +33 -11
  274. package/proxy.ts +62 -0
  275. package/tailwind.config.ts +0 -1
  276. package/core/build/lsp/event-yaml-completion.cjs +0 -106
  277. package/core/client/engine/theme-variables.ts +0 -37
  278. package/dist/tsconfig.types.tsbuildinfo +0 -1
  279. package/dist/types/client/engine/theme-variables.d.ts +0 -3
  280. package/editor/vscode/syntaxes/soma-event-yaml.tmLanguage.json +0 -30
  281. package/middleware.ts +0 -33
@@ -0,0 +1,72 @@
1
+ import type { ExtendedShowValue } from '../../../shared/types/ui-config.types';
2
+ import { type BlockScope } from './namespace';
3
+ export interface DataObjectDecl {
4
+ localName: string;
5
+ /** 全局身份:块id.名 */
6
+ fullName: string;
7
+ from?: {
8
+ api: string;
9
+ params: Record<string, string>;
10
+ };
11
+ save?: {
12
+ api: string;
13
+ method: string;
14
+ key?: string;
15
+ trigger: string;
16
+ fields?: string[];
17
+ };
18
+ refreshMs?: number;
19
+ reloadOn?: string[];
20
+ fields?: Record<string, FieldDecl>;
21
+ }
22
+ export interface FieldDecl {
23
+ name?: string;
24
+ type: string;
25
+ values?: Record<string, string>;
26
+ permission: 'r' | 'w';
27
+ rules?: Array<Record<string, unknown>>;
28
+ }
29
+ export interface ActionDecl {
30
+ id: string;
31
+ label: string;
32
+ handler?: string;
33
+ change?: string;
34
+ confirm?: string;
35
+ permission?: string;
36
+ tone?: string;
37
+ when?: string;
38
+ disabled_reason?: string;
39
+ }
40
+ export interface UseBlockAst {
41
+ blockId: string;
42
+ /** 声明的期望组件名(与 HTML 对账后的结果) */
43
+ component?: string;
44
+ /** 整块显隐 */
45
+ when?: string;
46
+ /** 数据对象(声明与引入) */
47
+ dataObjects: DataObjectDecl[];
48
+ dataImports: Array<{
49
+ localName: string;
50
+ targetPath: string;
51
+ }>;
52
+ /** ui 段原文(Row 编译在 soma-ui 词汇层,core 只做路径还原与结构校验) */
53
+ uiRaw: Record<string, unknown>;
54
+ /** 动作定义表 */
55
+ actions: Map<string, ActionDecl>;
56
+ /** emit 路由:emit 名 → Pipeline 表达式 */
57
+ emitRoutes: Record<string, string>;
58
+ scope: BlockScope;
59
+ /** 供 v1 编译管线消费的 props 形态 */
60
+ toShowValue(): ExtendedShowValue;
61
+ }
62
+ export interface ParseUseInput {
63
+ blockId: string;
64
+ body: Record<string, unknown>;
65
+ /** HTML 中该实例的组件名(对账用) */
66
+ htmlComponent?: string;
67
+ /** 该实例可见的行变量(由 HTML 位置决定) */
68
+ rowVars?: Iterable<string>;
69
+ }
70
+ export declare function parseUseBlock(input: ParseUseInput): UseBlockAst;
71
+ /** `30s` → 30000;单位封闭 ms/s/m,无单位报错(不猜) */
72
+ export declare function parseDuration(raw: string, where: string, fail: (m: string) => never): number;
@@ -0,0 +1,63 @@
1
+ import type { SomaPipeCall } from '../../shared/types/scope-manifest.types';
2
+ export declare class SomaValueLangError extends Error {
3
+ readonly raw: string;
4
+ constructor(message: string, raw: string);
5
+ }
6
+ /** 值段的指令节点:JSON 可序列化,进清单 */
7
+ export type ValueNode = {
8
+ kind: 'path';
9
+ path: string;
10
+ } | {
11
+ kind: 'lit';
12
+ value: string | number | boolean;
13
+ } | {
14
+ kind: 'neg';
15
+ operand: ValueNode;
16
+ } | {
17
+ kind: 'arith';
18
+ op: '+' | '-' | '*' | '/';
19
+ left: ValueNode;
20
+ right: ValueNode;
21
+ };
22
+ export interface PipedValue {
23
+ seg: ValueNode;
24
+ pipes: SomaPipeCall[];
25
+ /** 值内引用的全部绑定路径(段内 + 管道实参),供 watchPaths 注册 */
26
+ paths: string[];
27
+ }
28
+ /**
29
+ * 值位置。算术与计算管道是**展示位专有**——算出来的值不驱动行为,
30
+ * 业务规则(定价、优惠、判断)留在 Domain 才可测试。
31
+ */
32
+ export type ValuePosition = 'display' | 'condition' | 'key';
33
+ /** 判定一个变量首段是否在当前作用域(与既有 hasVar 同款契约) */
34
+ export type HasVarFn = (segment: string) => boolean;
35
+ /** 段内是否需要走算术解析(出现运算符或括号即是;路径词法不含它们) */
36
+ export declare function isArithSegment(segment: string): boolean;
37
+ /**
38
+ * 解析一个值段(不含管道)。
39
+ *
40
+ * 纯路径与纯字面量走快路径;含运算符时进算术文法。
41
+ */
42
+ export declare function parseValueSegment(segment: string, hasVar: HasVarFn, position?: ValuePosition, source?: string): {
43
+ node: ValueNode;
44
+ paths: string[];
45
+ };
46
+ /** 值段内是否只是一条裸路径(供上层决定是否走既有轻路径) */
47
+ export declare function isPlainPath(node: ValueNode): node is {
48
+ kind: 'path';
49
+ path: string;
50
+ };
51
+ export interface EvalOptions {
52
+ /** dev 下算术遇非数值/除零直接抛错(含表达式原文);prod 返回 null 交由上层占位 */
53
+ dev?: boolean;
54
+ }
55
+ /**
56
+ * 对指令节点求值。
57
+ *
58
+ * 除零与非数值:dev 抛错(点名原文,避免"页面上一个 NaN 查半天"),
59
+ * prod 返回 null——上层渲染占位符,与 role_by 未命中的既有语义一致。
60
+ */
61
+ export declare function evaluateValueNode(node: ValueNode, read: (path: string) => unknown, options?: EvalOptions): unknown;
62
+ /** 把指令节点还原成近似原文,仅用于报错可读性 */
63
+ export declare function describeNode(node: ValueNode): string;
@@ -0,0 +1,38 @@
1
+ import type { SomaPipeCall } from '../../shared/types/scope-manifest.types';
2
+ export interface SomaPipeContext {
3
+ /** 读取绑定路径当前值(页面作用域=根实例;行作用域=行数据语义) */
4
+ read(path: string): unknown;
5
+ /** 当前 locale 表(货币符号、免费文案等本地化取值) */
6
+ locale(): Record<string, unknown> | undefined;
7
+ }
8
+ /** 管道函数:纯函数,入值 + 已求值实参 → 展示字符串 */
9
+ export type SomaPipeFn = (value: unknown, args: Record<string, unknown>, ctx: SomaPipeContext) => string;
10
+ export declare class SomaPipeError extends Error {
11
+ constructor(message: string);
12
+ }
13
+ export interface ParsedPipedValue {
14
+ /** 管道前的绑定路径(原样,未经 resolver) */
15
+ basePath: string;
16
+ pipes: SomaPipeCall[];
17
+ /** 实参中的绑定路径(原样),供 watchPaths 注册 */
18
+ argPaths: string[];
19
+ }
20
+ /** 值是否携带管道(展示位置专用判断) */
21
+ export declare function hasPipes(rawValue: string): boolean;
22
+ /**
23
+ * 解析 `path | pipe1 | pipe2(k: v, 字面量)` 形式的值。
24
+ * 实参判定:首段是已注册 var 的视为绑定路径,其余为字面量(数字/布尔自动转型)。
25
+ * 结果按原始串缓存(编译路径与行内解释路径共享)。
26
+ */
27
+ export declare function parsePipedValue(rawValue: string, hasVar: (seg: string) => boolean): ParsedPipedValue;
28
+ export declare class SomaPipeRegistry {
29
+ private readonly fns;
30
+ constructor(custom?: Record<string, SomaPipeFn>);
31
+ has(name: string): boolean;
32
+ /** 编译期白名单校验:未注册名直接抛错(fail fast) */
33
+ assertKnown(pipes: SomaPipeCall[], where: string): void;
34
+ /** 链式应用(从左到右);单个管道异常时降级为原值字符串并告警,不中断渲染 */
35
+ apply(value: unknown, pipes: SomaPipeCall[], ctx: SomaPipeContext): string;
36
+ }
37
+ /** 默认注册表(仅内置管道),未传自定义管道时全局共享 */
38
+ export declare const defaultPipeRegistry: SomaPipeRegistry;
@@ -0,0 +1,50 @@
1
+ import type { SomaComponentDefinition } from '../component/component-definition.types';
2
+ import type { SomaAdaptiveVocabulary } from '../../shared/types/adaptive.types';
3
+ import type { SomaErrorEvent, SomaPageIdentity } from '../observability/error-reporter';
4
+ /**
5
+ * 服务端编译产物。浏览器不编译 SOMA DSL 源声明,缺失或不完整时明确拒绝。
6
+ */
7
+ export interface PrecompiledDeclarationAssets {
8
+ uiConfig?: unknown;
9
+ eventConfig?: unknown;
10
+ triggerConfig?: unknown;
11
+ timerConfig?: unknown;
12
+ styleConfig?: unknown;
13
+ dataConfig?: unknown;
14
+ }
15
+ export interface GeneratedPageDeclarations {
16
+ html: string;
17
+ uiYaml: string;
18
+ eventYaml?: string;
19
+ styleYaml?: string;
20
+ }
21
+ /**
22
+ * 错误采集开关(默认关闭)。
23
+ * 声明态页面是"注册即生效"的——出错时唯一有价值的问题是"哪个版本引入的"。
24
+ * 页面名与版本号只有渲染通道知道,不在这里盖戳,后面任何一层都补不回来。
25
+ */
26
+ export interface PreviewObservabilityOptions {
27
+ /** 页面身份缺省值;renderPublishedPage 会用真实的 name@version 覆盖 */
28
+ page?: SomaPageIdentity;
29
+ /** 上报通道;缺省走 soma-core 的 console 单行 JSON 通道 */
30
+ report?: (event: SomaErrorEvent) => void;
31
+ /** 同签名错误去重窗口(毫秒) */
32
+ dedupeWindowMs?: number;
33
+ /** 单页上报条数上限 */
34
+ maxEvents?: number;
35
+ }
36
+ export interface GeneratedPagePreviewOptions {
37
+ /** 给了就开启错误采集(`{ observability: {} }` 即为一行开启,用默认通道) */
38
+ observability?: PreviewObservabilityOptions;
39
+ /** 页面声明含 adaptive.ladder 时由 Host 注入的组件词汇。 */
40
+ adaptiveVocabulary?: SomaAdaptiveVocabulary;
41
+ }
42
+ export interface PreviewHandle {
43
+ /**
44
+ * 用新产物重新渲染(先卸载旧页面)。
45
+ * page 传入时覆盖本次渲染的页面身份——发布页拉到版本号后才知道该盖什么戳。
46
+ */
47
+ render(decl: GeneratedPageDeclarations, page?: SomaPageIdentity, compiled?: PrecompiledDeclarationAssets): Promise<void>;
48
+ destroy(): Promise<void>;
49
+ }
50
+ export declare function createGeneratedPagePreview(target: HTMLElement | string, components: Record<string, SomaComponentDefinition>, options?: GeneratedPagePreviewOptions): PreviewHandle;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * 运行时注册中心(客户端桶,'soma-core/registry')。
3
+ *
4
+ * REQ-002:声明 → 运行页面是引擎能力。两条消费路径:
5
+ * - createGeneratedPagePreview:拿着内存里的声明直接渲染(生成即渲、应用自组织的临时页);
6
+ * - renderPublishedPage:按名从注册中心拉取声明再渲染(注册即生效的共享页)。
7
+ */
8
+ export { createGeneratedPagePreview, type GeneratedPageDeclarations, type GeneratedPagePreviewOptions, type PrecompiledDeclarationAssets, type PreviewHandle, type PreviewObservabilityOptions, } from './declaration-renderer';
9
+ export { createSomaPageLifecycle, SomaPageLifecycle, type MountedPageInfo, type RegisterDeclarationOptions, type SomaPageLifecycleOptions, } from './page-lifecycle';
10
+ export { renderPublishedPage, type PublishedPageHandle, type PublishedPageRecord, type RenderPublishedPageOptions, } from './remote-page';
@@ -0,0 +1,61 @@
1
+ import type { SomaComponentDefinition } from '../component/component-definition.types';
2
+ import type { SomaAdaptiveVocabulary } from '../../shared/types/adaptive.types';
3
+ import type { SomaPageIdentity } from '../observability/error-reporter';
4
+ import { type GeneratedPageDeclarations, type PrecompiledDeclarationAssets, type PreviewObservabilityOptions } from './declaration-renderer';
5
+ export interface SomaPageLifecycleOptions {
6
+ /** 组件定义表(通常是 createSomaUiComponents() 加宿主自治组件) */
7
+ components: Record<string, SomaComponentDefinition>;
8
+ /** 页面声明含 adaptive.ladder 时由 Host 注入的组件词汇 */
9
+ adaptiveVocabulary?: SomaAdaptiveVocabulary;
10
+ /** 错误采集(默认关闭);页面身份会自动盖上注册名 */
11
+ observability?: PreviewObservabilityOptions;
12
+ }
13
+ export interface RegisterDeclarationOptions {
14
+ /** 预编译产物(注册中心取页时会带回来),有就省一次解析 */
15
+ compiled?: PrecompiledDeclarationAssets;
16
+ /** 页面身份戳(缺省用注册名);注册中心来的声明应带上真实版本号 */
17
+ page?: SomaPageIdentity;
18
+ }
19
+ export interface MountedPageInfo {
20
+ /** 注册名 */
21
+ name: string;
22
+ /** 挂载点 id */
23
+ mountId: string;
24
+ }
25
+ /**
26
+ * 实例表。**纯内存、纯客户端**:进程内活着,刷新即空——
27
+ * 需要跨刷新存活的声明属于注册中心那一侧的事(按名拉取)。
28
+ */
29
+ export declare class SomaPageLifecycle {
30
+ private readonly options;
31
+ private readonly entries;
32
+ constructor(options: SomaPageLifecycleOptions);
33
+ /**
34
+ * 登记一份声明(同名即替换)。替换时会先把它已有的挂载全部卸掉——
35
+ * 否则屏幕上留着旧内容而表里已是新声明,是最难查的那类不一致。
36
+ */
37
+ register(name: string, declaration: GeneratedPageDeclarations, options?: RegisterDeclarationOptions): Promise<void>;
38
+ /** 这个名字登记过吗 */
39
+ has(name: string): boolean;
40
+ /** 已登记的名字(按登记顺序) */
41
+ names(): string[];
42
+ /** 当前挂着的实例清单(名字 + 挂载点) */
43
+ mounted(): MountedPageInfo[];
44
+ /**
45
+ * 把已登记的声明挂到某个挂载点。
46
+ * 同一挂载点重复 mount 会先卸掉那里的旧实例(挂载点是唯一的,不叠加)。
47
+ */
48
+ mount(name: string, mountId: string): Promise<void>;
49
+ /**
50
+ * 卸载。给 mountId 只卸那一处,不给则卸这个名字的全部实例。
51
+ * 卸载**必须真还内存**:句柄 destroy 会 unmount 引擎并清空挂载点 DOM,
52
+ * 这里再把句柄从表里删掉——表还拿着引用,GC 就收不走。
53
+ */
54
+ unmount(name: string, mountId?: string): Promise<void>;
55
+ /** 注销:先卸全部实例,再把声明从表里丢掉 */
56
+ unregister(name: string): Promise<void>;
57
+ /** 全清:页面离开时调一次,别把整张表连同声明一起漏在内存里 */
58
+ destroyAll(): Promise<void>;
59
+ }
60
+ /** 建一个实例表(与 createSomaUiComponents() 一起用) */
61
+ export declare function createSomaPageLifecycle(options: SomaPageLifecycleOptions): SomaPageLifecycle;
@@ -0,0 +1,52 @@
1
+ import type { SomaComponentDefinition } from '../component/component-definition.types';
2
+ import type { SomaAdaptiveVocabulary } from '../../shared/types/adaptive.types';
3
+ import { type GeneratedPageDeclarations, type PrecompiledDeclarationAssets, type PreviewObservabilityOptions } from './declaration-renderer';
4
+ /** 服务端返回的版本记录(与注册中心 PageVersionRecord 同构) */
5
+ export interface PublishedPageRecord {
6
+ name: string;
7
+ version: number;
8
+ declaration: GeneratedPageDeclarations & {
9
+ notes?: string;
10
+ };
11
+ status: 'published' | 'draft';
12
+ createdAt: number;
13
+ /**
14
+ * 注册期预编译产物(P-a)。服务端已做过版本闸:发下来就是能用的,
15
+ * 没发下来就说明版本对不上或压根没编译过——客户端照常运行时解析。
16
+ */
17
+ compiled?: PrecompiledDeclarationAssets;
18
+ }
19
+ export interface RenderPublishedPageOptions {
20
+ /** 指定版本号;缺省拉最新 published 版本 */
21
+ version?: number;
22
+ /** 可注入 fetch(测试 / 自定义传输),默认 globalThis.fetch */
23
+ http?: typeof globalThis.fetch;
24
+ /** 拉取端点,默认 /api/soma-registry/pages/get */
25
+ endpoint?: string;
26
+ /**
27
+ * 非敏感请求头(例如 Host 的页面来源标识)。用于让服务端能力网关识别调用页面;
28
+ * 禁止放 Authorization、签名密钥或任何长期凭据。
29
+ */
30
+ requestHeaders?: Readonly<Record<string, string>>;
31
+ /**
32
+ * 错误采集(默认关闭;给了就开启,`observability: {}` 即为一行开启)。
33
+ * 页面身份由本函数按拉取结果自动盖戳 `{ name, version, source: 'registry' }`——
34
+ * 声明可以随时注册新版本,只有这里知道渲染的究竟是哪一版。
35
+ */
36
+ observability?: PreviewObservabilityOptions;
37
+ /** 页面声明含 adaptive.ladder 时由 Host 注入的组件词汇。 */
38
+ adaptiveVocabulary?: SomaAdaptiveVocabulary;
39
+ }
40
+ export interface PublishedPageHandle {
41
+ /** 实际渲染的页面名 */
42
+ name: string;
43
+ /** 实际渲染的版本号(缺省拉取时即最新 published 版本) */
44
+ version: number;
45
+ /** 卸载页面并清空挂载点 */
46
+ destroy(): Promise<void>;
47
+ }
48
+ /**
49
+ * 拉取注册页面声明并渲染到 mountId 对应的挂载点。
50
+ * 任何拉取 / 解析失败都会抛出带页面名上下文的 Error(调用方 catch 后兜底展示)。
51
+ */
52
+ export declare function renderPublishedPage(mountId: string, name: string, components: Record<string, SomaComponentDefinition>, options?: RenderPublishedPageOptions): Promise<PublishedPageHandle>;
@@ -27,6 +27,22 @@ export interface SomaRuntimeServices {
27
27
  permission: SomaPermission;
28
28
  i18n: DefaultI18n;
29
29
  realtime: IRealtimeService;
30
+ /**
31
+ * 界面中途提交:把此刻改过的页面状态立刻上屏,**不结束**当前事件事务。
32
+ *
33
+ * 存在的理由:一次事件 = 一次原子提交是刻意的设计(避免中间态闪烁、出错整体回滚),
34
+ * 代价是**长任务里的中途进展播不出去**——实测 AI 生成 P50 约 40 秒,期间 Domain
35
+ * 改多少次状态,界面一次都不动,连"生成中"都看不到。
36
+ *
37
+ * 它是**自愿**的:不调用,行为与过去逐字节一致;调用了,就等于声明
38
+ * "已上屏的这部分不再享有失败回滚"。这个取舍只能由业务自己做。
39
+ * 引擎未接线时(纯 Node 单测、无渲染宿主)为空操作,调用方不必判空。
40
+ */
41
+ ui: SomaUiService;
42
+ }
43
+ /** 界面中途提交服务(见 SomaRuntimeServices.ui) */
44
+ export interface SomaUiService {
45
+ publish(): Promise<void>;
30
46
  }
31
47
  export declare function createDefaultRuntimeServices(options?: {
32
48
  appConfig?: unknown;
@@ -0,0 +1,7 @@
1
+ /** 空串是否意味着「删除该属性」 */
2
+ export declare function isAbsentWhenEmpty(attrName: string): boolean;
3
+ /**
4
+ * 属性写入前的存在性判定。
5
+ * 返回 true = 应删除属性(而非写入空串)。
6
+ */
7
+ export declare function shouldRemoveAttribute(attrName: string, value: string): boolean;
@@ -0,0 +1,37 @@
1
+ /** 宿主可注入的净化器最小面:一个纯函数级的 sanitize */
2
+ export interface SomaHtmlSanitizer {
3
+ sanitize(html: string): string;
4
+ }
5
+ /**
6
+ * 统一 sanitize 策略:全站一份,不许各页面自配。
7
+ *
8
+ * 取舍说明:
9
+ * - `script` / `style` 一律剔除——声明态页面的样式走 `_style.yaml` 与主题令牌,
10
+ * 富文本里出现 `<style>` 只可能是越权改版面(模板纯度闸门在手写侧也是这条规矩);
11
+ * - `style` 属性剔除:内联样式既是 CSP `style-src` 的敌人,也是颜色纪律的漏口;
12
+ * - 表单/框架类标签剔除:富文本没有合法理由携带 `<form>` / `<iframe>` / `<base>`;
13
+ * - `ALLOW_DATA_ATTR: false`:data-soma-* 是引擎的锚点命名空间,不能被内容伪造。
14
+ * DOMPurify 默认已剔除 on* 事件属性与 `javascript:` URL,此处不重复声明,只做加严。
15
+ */
16
+ export declare const SOMA_PURIFY_PROFILE: Record<string, unknown>;
17
+ /**
18
+ * 宿主注入净化器(在 bootstrap 里调用一次)。
19
+ * 传 null 复位为「未注入」,便于测试与运行期关停。
20
+ */
21
+ export declare function setSomaHtmlSanitizer(sanitizer: SomaHtmlSanitizer | null): void;
22
+ /** 当前生效的净化器;返回 null 表示将走转义降级 */
23
+ export declare function resolveSomaHtmlSanitizer(): SomaHtmlSanitizer | null;
24
+ /** 纯字符串转义,不经 DOM——降级路径与非 Web 容器共用 */
25
+ export declare function escapeSomaHtml(value: string): string;
26
+ /** 净化结果:`sanitized=false` 表示走了转义降级(内容以纯文本呈现) */
27
+ export interface SomaHtmlSanitizeResult {
28
+ html: string;
29
+ sanitized: boolean;
30
+ }
31
+ /**
32
+ * `@html` 落地前的统一净化。
33
+ *
34
+ * 降级时给一次 console.warn(只警告一次,避免长列表刷屏):
35
+ * 静默降级会让富文本页面「显示成源码」而没人知道为什么,这是实测最难排查的一类困惑。
36
+ */
37
+ export declare function sanitizeSomaHtml(value: string): SomaHtmlSanitizeResult;
@@ -0,0 +1,11 @@
1
+ /** 拦截后写入的安全占位值 */
2
+ export declare const BLOCKED_URL_PLACEHOLDER = "about:blank";
3
+ /** 事件处理器属性(onclick/onerror/…):DSL 永不允许通过绑定写入 */
4
+ export declare function isEventHandlerAttribute(attrName: string): boolean;
5
+ /** 该属性值是否含危险 scheme */
6
+ export declare function hasBlockedScheme(attrName: string, value: string): boolean;
7
+ /**
8
+ * 属性写入前的统一净化。
9
+ * 返回 null = 该属性禁止写入(事件处理器);否则返回应写入的值(可能被替换为占位值)。
10
+ */
11
+ export declare function sanitizeAttributeWrite(attrName: string, value: string): string | null;
@@ -0,0 +1,77 @@
1
+ import type { SomaAxisParams, SomaResolvedAxes, SomaSemantics } from './theme-axes';
2
+ export type SomaToneName = 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'danger';
3
+ export interface SomaHueAnchors {
4
+ /** 各语气的色相锚(度,0–360) */
5
+ readonly tones: Readonly<Record<SomaToneName, number>>;
6
+ /** 图表序列 8 锚 */
7
+ readonly chart: readonly number[];
8
+ /** 色相带宽 < 120° 时为 true:序列区分改以明度阶梯为主 */
9
+ readonly chartLightnessLadder: boolean;
10
+ }
11
+ /**
12
+ * 功能色相:danger 偏红、success 偏绿、warning 偏琥珀、info 偏蓝。
13
+ *
14
+ * 这四个数从现状引擎 ④.1 的字面常量迁来,**取值一个没改**——
15
+ * functional 档(缺省)下产出与重构前完全一致。
16
+ */
17
+ export declare const FUNCTIONAL_HUES: {
18
+ readonly info: 230;
19
+ readonly success: 150;
20
+ readonly warning: 75;
21
+ readonly danger: 27;
22
+ };
23
+ /** 表达性语气相对品牌的色相偏移(自现状 ④.1b 迁来,取值不改) */
24
+ export declare const EXPRESSIVE_OFFSETS: {
25
+ readonly secondary: 48;
26
+ readonly accent: 160;
27
+ };
28
+ /**
29
+ * 判撞阈值:色相与明度**同时**低于阈值才算撞。
30
+ *
31
+ * 只看色相不够——深红按钮配亮红徽标是可辨的;只看明度更不够。
32
+ * 阈值以 cartoonPop 病例(Δh 10.5°、ΔL 0.05)为下界校准。
33
+ * 导出是为了让棘轮测试直接引用,不在测试里抄一遍数字。
34
+ */
35
+ export declare const SEPARATION_THRESHOLD: {
36
+ readonly hue: 30;
37
+ readonly lightness: 0.12;
38
+ };
39
+ /** 最短弧角差,返回 (-180, 180] */
40
+ export declare function angDiff(a: number, b: number): number;
41
+ /**
42
+ * 色相压缩:把目标色相朝品牌色相压缩 k 倍。
43
+ * k=0 原值不动(功能优先);k=1 完全归一(单色系)。走最短弧,不绕远路。
44
+ */
45
+ export declare function compress(hue: number, brandHue: number, k: number): number;
46
+ /**
47
+ * S1:解出全部色相锚。
48
+ *
49
+ * 作用域与优先序(《架构设计》§3 的表):
50
+ * accents 显式锁位 > semantics 决定语义三色 > harmony 决定其余 > 缺省
51
+ */
52
+ export declare function resolveHueAnchors(brandHue: number, axes: SomaResolvedAxes, params: SomaAxisParams, accentHues?: readonly number[]): SomaHueAnchors;
53
+ /** 一组色相的极差(考虑环绕:取覆盖全部点的最小弧长) */
54
+ export declare function hueBandwidth(hues: readonly number[]): number;
55
+ export interface SeparationResult {
56
+ readonly anchors: SomaHueAnchors;
57
+ readonly applied: boolean;
58
+ readonly pushed: readonly ('success' | 'warning' | 'danger')[];
59
+ /**
60
+ * 色相区内推不出安全距离的语气:分离改由**明度**承担。
61
+ * 值是相对品牌明度需要的最小偏移方向与幅度,由编排者施加到该语气的明度上。
62
+ */
63
+ readonly lightnessSeparation: Readonly<Partial<Record<'success' | 'warning' | 'danger', {
64
+ direction: 1 | -1;
65
+ minGap: number;
66
+ }>>>;
67
+ }
68
+ /**
69
+ * S3 语义分离闸:品牌与语义色撞了就**推开语义色**,不动品牌。
70
+ *
71
+ * 为什么推语义色不推品牌:品牌是宿主给的身份,引擎无权改;
72
+ * 而语义色本来就是派生物,移动它只需保证仍在自己的语义区间内可辨。
73
+ *
74
+ * immersive 档下闸退场——那一档的可辨性责任已移交信号通道,
75
+ * 此时再推色相等于既要色相编码又要动效编码,两头不讨好。
76
+ */
77
+ export declare function applySeparationGuard(anchors: SomaHueAnchors, brandHue: number, brandLightness: number, toneLightness: Readonly<Record<SomaToneName, number>>, semantics: SomaSemantics): SeparationResult;
@@ -0,0 +1,25 @@
1
+ import type { SomaResolvedAxes } from './theme-axes';
2
+ /**
3
+ * S5:不含颜色的场景结构参数。
4
+ *
5
+ * 玻璃三档的 rgba 从引擎主体迁到这里(值一个没改)——它们是材质的结构属性,
6
+ * 与 field/material 轴同族,散在派生链中间只会让人以为它们是色板的一部分。
7
+ */
8
+ export declare function sceneStructureTokens(axes: SomaResolvedAxes): Record<string, string>;
9
+ /** 暗色下的玻璃:半透明**黑**而不是白——白玻璃压在深底上会变成发光板 */
10
+ export declare function glassTokens(dark: boolean): Record<string, string>;
11
+ /**
12
+ * S7′:场景颜色——吃 overrides 合并后的**最终**变量表。
13
+ *
14
+ * 三团环境光取自最终色板的 300/500/400 三档:宿主用 overrides 改了主色,
15
+ * 光球会跟着改,不会出现表面与场分属两个色系。
16
+ */
17
+ export declare function sceneColorTokens(finalVars: Readonly<Record<string, string>>, axes: SomaResolvedAxes, alphas: readonly [number, number, number] | null, hexWithAlpha: (hex: string, alpha: number) => string,
18
+ /** 品牌色阶:三团光的缺省取色源(G1 用的就是 300/500/400 三档) */
19
+ scale: Readonly<Record<string, string>>,
20
+ /**
21
+ * 覆盖后的色阶重建器:宿主用 overrides 换掉了主色时,
22
+ * 光球必须跟着换色系,否则 daisy × aurora 会"表面一个色系、光球另一个色系"。
23
+ * 传 null 表示主色未被覆盖,直接用原色阶。
24
+ */
25
+ rescale: ((primaryHex: string) => Record<string, string>) | null): Record<string, string>;
@@ -0,0 +1,81 @@
1
+ export type SomaHarmony = 'functional' | 'analogous' | 'monochrome' | 'complementary';
2
+ export type SomaSemantics = 'faithful' | 'tinted' | 'immersive';
3
+ export type SomaChroma = 'muted' | 'balanced' | 'vivid';
4
+ export type SomaContrast = 'soft' | 'standard' | 'strong';
5
+ export type SomaField = 'flat' | 'tinted' | 'aurora';
6
+ export type SomaIntensity = 'whisper' | 'soft' | 'bold';
7
+ export type SomaMaterial = 'solid' | 'glass';
8
+ export interface SomaPaletteAxes {
9
+ /** 色相编排:语义色与品牌的色相关系 */
10
+ harmony?: SomaHarmony;
11
+ /** 语义色忠实度:success/warning/danger 允许被 harmony 带走多远 */
12
+ semantics?: SomaSemantics;
13
+ /** 彩度个性:素净 ↔ 浓烈 */
14
+ chroma?: SomaChroma;
15
+ /** 明度反差:柔光粉彩 ↔ 高反差;AA 底线不随档移动 */
16
+ contrast?: SomaContrast;
17
+ /** 显式辅色(≤3):点名代替派生,依次锁 secondary/accent/info 的色相锚 */
18
+ accents?: string[];
19
+ }
20
+ export interface SomaSceneAxes {
21
+ /** 背景场:页面的"底"是平色、染色还是环境光场 */
22
+ field?: SomaField;
23
+ /** 场强三档(flat 下无义) */
24
+ intensity?: SomaIntensity;
25
+ /** 材质缺省档;组件级 surface prop 仍可逐个覆盖 */
26
+ material?: SomaMaterial;
27
+ }
28
+ /** 缺省回落后的确定轴位——meta 观测面与全部下游阶段的输入 */
29
+ export interface SomaResolvedAxes {
30
+ readonly palette: {
31
+ readonly harmony: SomaHarmony;
32
+ readonly semantics: SomaSemantics;
33
+ readonly chroma: SomaChroma;
34
+ readonly contrast: SomaContrast;
35
+ readonly accents: readonly string[];
36
+ };
37
+ readonly scene: {
38
+ readonly field: SomaField;
39
+ readonly intensity: SomaIntensity;
40
+ readonly material: SomaMaterial;
41
+ };
42
+ }
43
+ /** 三个目标对比度:语气底对页面底、前景对语气底、正文对页面底 */
44
+ export interface SomaContrastTargets {
45
+ readonly toneOnPage: number;
46
+ readonly fgOnTone: number;
47
+ readonly textOnPage: number;
48
+ }
49
+ /** 档位解析出的数值参数 */
50
+ export interface SomaAxisParams {
51
+ /** 色相压缩系数:0 = 功能色相原值,1 = 完全归一到品牌色相 */
52
+ readonly harmonyK: number;
53
+ /** complementary 专用:accent 先跳到品牌对侧再压缩 */
54
+ readonly accentComplement: boolean;
55
+ /** 彩度乘数,乘在既有彩度算式上 */
56
+ readonly chromaMul: number;
57
+ readonly targets: SomaContrastTargets;
58
+ readonly darkTargets: SomaContrastTargets;
59
+ /** contrast:soft 的粉彩明度带;null = 不约束(现状) */
60
+ readonly softLightnessBand: readonly [number, number] | null;
61
+ /** 环境光三团的 alpha;null = flat(产 transparent) */
62
+ readonly fieldAlphas: readonly [number, number, number] | null;
63
+ readonly glassEnabled: boolean;
64
+ /** = semantics === 'immersive':信号通道令牌是否产出生效值 */
65
+ readonly signalEnabled: boolean;
66
+ }
67
+ export declare class SomaThemeAxisError extends Error {
68
+ constructor(message: string);
69
+ }
70
+ /**
71
+ * 轴解析:词元 → 确定轴位 + 数值参数。
72
+ *
73
+ * 纯函数,不读全局、不碰 DOM。全部轴省略时返回的参数即现状行为。
74
+ */
75
+ export declare function resolveAxes(input: {
76
+ palette?: SomaPaletteAxes;
77
+ scene?: SomaSceneAxes;
78
+ }): {
79
+ axes: SomaResolvedAxes;
80
+ params: SomaAxisParams;
81
+ };