soma-core 1.4.1 → 1.5.0

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 (221) hide show
  1. package/bin/component.cjs +240 -0
  2. package/bin/eject.cjs +174 -0
  3. package/bin/migrate.cjs +362 -0
  4. package/core/build/blocks/block-compile.ts +143 -17
  5. package/core/build/blocks/migrate-flat.ts +118 -25
  6. package/core/build/compiler/page-declaration-compiler.ts +149 -5
  7. package/core/build/compiler/route-builder.ts +0 -4
  8. package/core/build/compiler/soma-precompile.js +443 -30
  9. package/core/build/component/component-graph.ts +28 -105
  10. package/core/build/component/package-loader.ts +50 -4
  11. package/core/build/eject/component-eject.ts +8 -2
  12. package/core/build/layout/constraint-solver.ts +131 -16
  13. package/core/build/layout/css-emitter.ts +15 -9
  14. package/core/build/ooui/artifact/artifact.types.ts +275 -0
  15. package/core/build/ooui/artifact/emit-artifact.ts +269 -0
  16. package/core/build/ooui/artifact/emit-html.ts +204 -0
  17. package/core/build/ooui/artifact/index.ts +53 -0
  18. package/core/build/ooui/artifact/spatial-tree.ts +268 -0
  19. package/core/build/ooui/artifact/utility-class.ts +83 -0
  20. package/core/build/ooui/composition/candidate.types.ts +323 -0
  21. package/core/build/ooui/composition/control-model.ts +114 -0
  22. package/core/build/ooui/composition/registry.ts +520 -0
  23. package/core/build/ooui/composition/select.ts +232 -0
  24. package/core/build/ooui/diagnostics/codes.ts +230 -0
  25. package/core/build/ooui/diagnostics/error.ts +235 -0
  26. package/core/build/ooui/diagnostics/format.ts +106 -0
  27. package/core/build/ooui/diagnostics/index.ts +62 -0
  28. package/core/build/ooui/diagnostics/issue.types.ts +112 -0
  29. package/core/build/ooui/engine-slot.ts +184 -0
  30. package/core/build/ooui/index.ts +1427 -0
  31. package/core/build/ooui/intent/derive-intent.ts +450 -0
  32. package/core/build/ooui/intent/field-rules.ts +330 -0
  33. package/core/build/ooui/intent/intent.types.ts +476 -0
  34. package/core/build/ooui/intent/verb-events.ts +285 -0
  35. package/core/build/ooui/page/budget.ts +503 -0
  36. package/core/build/ooui/page/compose-page.ts +736 -0
  37. package/core/build/ooui/page/index.ts +66 -0
  38. package/core/build/ooui/page/page.types.ts +402 -0
  39. package/core/build/ooui/page/region-row.ts +241 -0
  40. package/core/build/ooui/semantic/expand-page-surface.ts +180 -0
  41. package/core/build/ooui/semantic/kernel.types.ts +187 -0
  42. package/core/build/ooui/semantic/normalize.ts +784 -0
  43. package/core/build/ooui/semantic/origin.types.ts +211 -0
  44. package/core/build/ooui/semantic/role-alias.ts +154 -0
  45. package/core/build/ooui/semantic/shorthand.ts +233 -0
  46. package/core/build/ooui/semantic/surface.types.ts +78 -0
  47. package/core/build/ooui/semantic/validate-request.ts +267 -0
  48. package/core/build/ooui/spatial/emit-utility.ts +480 -0
  49. package/core/build/ooui/spatial/ir.types.ts +443 -0
  50. package/core/build/ooui/spatial/registry.ts +565 -0
  51. package/core/build/ooui/spatial/solve.ts +769 -0
  52. package/core/build/ooui/spatial/utility.types.ts +242 -0
  53. package/core/build/ooui/trace/index.ts +40 -0
  54. package/core/build/ooui/trace/render.ts +190 -0
  55. package/core/build/ooui/trace/source.types.ts +69 -0
  56. package/core/build/ooui/trace/trace.types.ts +326 -0
  57. package/core/build/pack/pack-init.ts +19 -14
  58. package/core/client/base/SomaHttpClient.ts +34 -1
  59. package/core/client/component/ai-catalog.ts +42 -0
  60. package/core/client/component/example-blocks.ts +1 -7
  61. package/core/client/component/theme-component-tokens.ts +12 -15
  62. package/core/client/component/verify-pack.ts +120 -1
  63. package/core/client/container/SomaContainerAdapter.ts +6 -2
  64. package/core/client/data/data-object-resolver.ts +27 -8
  65. package/core/client/diagnostics/telemetry-context.ts +0 -4
  66. package/core/client/engine/asset-resolver.ts +0 -1
  67. package/core/client/engine/event-engine.ts +7 -3
  68. package/core/client/engine/soma-bootstrap.ts +292 -34
  69. package/core/client/engine/style-binder.ts +0 -1
  70. package/core/client/infra/http/IHttpClient.ts +0 -6
  71. package/core/client/infra/http/SomaHttpService.ts +5 -2
  72. package/core/client/infra/notify/DomNotifyService.ts +1 -1
  73. package/core/client/infra/router/router-path.ts +0 -6
  74. package/core/client/parser/annotation-extractor.ts +1 -1
  75. package/core/client/parser/blocks/namespace.ts +30 -5
  76. package/core/client/parser/blocks/page-parser.ts +44 -1
  77. package/core/client/parser/blocks/use-parser.ts +266 -46
  78. package/core/client/parser/data-config-parser.ts +71 -3
  79. package/core/client/parser/layout-parser.ts +4 -3
  80. package/core/client/parser/reaction-parser.ts +0 -1
  81. package/core/client/parser/ui-config-parser.ts +212 -74
  82. package/core/client/theme/scene-tokens.ts +9 -3
  83. package/core/client/theme/theme-axes.ts +74 -16
  84. package/core/client/theme/theme-engine.ts +280 -69
  85. package/core/client/theme/tone-solver.ts +9 -8
  86. package/core/index.ts +38 -3
  87. package/core/server/api/load-host-service.ts +8 -2
  88. package/core/server/declaration-safety.ts +11 -0
  89. package/core/server/host/page-response-request.ts +0 -2
  90. package/core/server/host/published-page-artifact-cache.ts +244 -0
  91. package/core/server/host/published-page-assets.ts +44 -5
  92. package/core/server/mock/node/cli.mjs +0 -1
  93. package/core/server/mock/node/schema-generator.mjs +0 -1
  94. package/core/server/ooui.ts +34 -0
  95. package/core/server/page-assets.ts +8 -0
  96. package/core/server/page-declaration.ts +18 -0
  97. package/core/server/registry/asset-store.ts +327 -0
  98. package/core/server/registry/declaration-precompiler.ts +49 -6
  99. package/core/server/registry/index.ts +47 -1
  100. package/core/server/registry/page-registry-repository.ts +6 -2
  101. package/core/server/registry/page-registry-store.ts +133 -19
  102. package/core/server/registry/publish-asset-pin.ts +557 -0
  103. package/core/server/registry/services/pages/List.ts +15 -3
  104. package/core/server/registry/validation/compile-gate.ts +180 -8
  105. package/core/server/registry/validation/declaration-safety-scan.ts +113 -23
  106. package/core/shared/component/derive-sample.ts +290 -0
  107. package/core/shared/component/field-lines.ts +563 -0
  108. package/core/shared/container-breakpoints.ts +46 -0
  109. package/core/shared/object-semantics.ts +240 -0
  110. package/core/shared/ooui-declaration.ts +235 -0
  111. package/core/shared/types/component-contract.types.ts +30 -13
  112. package/core/shared/types/data-config.types.ts +95 -0
  113. package/core/shared/types/domain.types.ts +0 -24
  114. package/core/shared/types/engine.types.ts +0 -5
  115. package/core/shared/types/layout-constraint.types.ts +16 -0
  116. package/core/shared/types/ui-config.types.ts +163 -13
  117. package/dist/cli/soma.js +24 -11
  118. package/dist/core/index.cjs +2424 -1098
  119. package/dist/types/build/blocks/block-compile.d.ts +16 -1
  120. package/dist/types/build/blocks/migrate-flat.d.ts +17 -0
  121. package/dist/types/build/compiler/page-declaration-compiler.d.ts +46 -0
  122. package/dist/types/build/compiler/route-builder.d.ts +0 -1
  123. package/dist/types/build/component/component-graph.d.ts +17 -53
  124. package/dist/types/build/component/package-loader.d.ts +8 -1
  125. package/dist/types/build/layout/constraint-solver.d.ts +46 -4
  126. package/dist/types/build/ooui/artifact/artifact.types.d.ts +180 -0
  127. package/dist/types/build/ooui/artifact/emit-artifact.d.ts +58 -0
  128. package/dist/types/build/ooui/artifact/emit-html.d.ts +53 -0
  129. package/dist/types/build/ooui/artifact/index.d.ts +5 -0
  130. package/dist/types/build/ooui/artifact/spatial-tree.d.ts +48 -0
  131. package/dist/types/build/ooui/artifact/utility-class.d.ts +46 -0
  132. package/dist/types/build/ooui/composition/candidate.types.d.ts +206 -0
  133. package/dist/types/build/ooui/composition/control-model.d.ts +37 -0
  134. package/dist/types/build/ooui/composition/registry.d.ts +66 -0
  135. package/dist/types/build/ooui/composition/select.d.ts +63 -0
  136. package/dist/types/build/ooui/diagnostics/codes.d.ts +28 -0
  137. package/dist/types/build/ooui/diagnostics/error.d.ts +135 -0
  138. package/dist/types/build/ooui/diagnostics/format.d.ts +51 -0
  139. package/dist/types/build/ooui/diagnostics/index.d.ts +25 -0
  140. package/dist/types/build/ooui/diagnostics/issue.types.d.ts +56 -0
  141. package/dist/types/build/ooui/engine-slot.d.ts +41 -0
  142. package/dist/types/build/ooui/index.d.ts +286 -0
  143. package/dist/types/build/ooui/intent/derive-intent.d.ts +32 -0
  144. package/dist/types/build/ooui/intent/field-rules.d.ts +99 -0
  145. package/dist/types/build/ooui/intent/intent.types.d.ts +318 -0
  146. package/dist/types/build/ooui/intent/verb-events.d.ts +70 -0
  147. package/dist/types/build/ooui/page/budget.d.ts +28 -0
  148. package/dist/types/build/ooui/page/compose-page.d.ts +41 -0
  149. package/dist/types/build/ooui/page/index.d.ts +4 -0
  150. package/dist/types/build/ooui/page/page.types.d.ts +264 -0
  151. package/dist/types/build/ooui/page/region-row.d.ts +16 -0
  152. package/dist/types/build/ooui/semantic/expand-page-surface.d.ts +33 -0
  153. package/dist/types/build/ooui/semantic/kernel.types.d.ts +125 -0
  154. package/dist/types/build/ooui/semantic/normalize.d.ts +45 -0
  155. package/dist/types/build/ooui/semantic/origin.types.d.ts +95 -0
  156. package/dist/types/build/ooui/semantic/role-alias.d.ts +35 -0
  157. package/dist/types/build/ooui/semantic/shorthand.d.ts +60 -0
  158. package/dist/types/build/ooui/semantic/surface.types.d.ts +16 -0
  159. package/dist/types/build/ooui/semantic/validate-request.d.ts +19 -0
  160. package/dist/types/build/ooui/spatial/emit-utility.d.ts +43 -0
  161. package/dist/types/build/ooui/spatial/ir.types.d.ts +280 -0
  162. package/dist/types/build/ooui/spatial/registry.d.ts +110 -0
  163. package/dist/types/build/ooui/spatial/solve.d.ts +42 -0
  164. package/dist/types/build/ooui/spatial/utility.types.d.ts +191 -0
  165. package/dist/types/build/ooui/trace/index.d.ts +3 -0
  166. package/dist/types/build/ooui/trace/render.d.ts +42 -0
  167. package/dist/types/build/ooui/trace/source.types.d.ts +25 -0
  168. package/dist/types/build/ooui/trace/trace.types.d.ts +143 -0
  169. package/dist/types/client/base/SomaHttpClient.d.ts +8 -0
  170. package/dist/types/client/component/ai-catalog.d.ts +9 -0
  171. package/dist/types/client/component/example-blocks.d.ts +0 -2
  172. package/dist/types/client/component/theme-component-tokens.d.ts +8 -5
  173. package/dist/types/client/component/verify-pack.d.ts +10 -0
  174. package/dist/types/client/data/data-object-resolver.d.ts +10 -2
  175. package/dist/types/client/diagnostics/telemetry-context.d.ts +0 -1
  176. package/dist/types/client/engine/soma-bootstrap.d.ts +123 -10
  177. package/dist/types/client/infra/http/IHttpClient.d.ts +0 -5
  178. package/dist/types/client/infra/http/SomaHttpService.d.ts +1 -1
  179. package/dist/types/client/infra/router/router-path.d.ts +0 -2
  180. package/dist/types/client/parser/blocks/namespace.d.ts +20 -0
  181. package/dist/types/client/parser/blocks/page-parser.d.ts +9 -0
  182. package/dist/types/client/parser/blocks/use-parser.d.ts +38 -4
  183. package/dist/types/client/parser/data-config-parser.d.ts +13 -0
  184. package/dist/types/client/parser/ui-config-parser.d.ts +1 -11
  185. package/dist/types/client/theme/scene-tokens.d.ts +9 -3
  186. package/dist/types/client/theme/theme-axes.d.ts +64 -1
  187. package/dist/types/client/theme/theme-engine.d.ts +13 -8
  188. package/dist/types/client/theme/tone-solver.d.ts +9 -5
  189. package/dist/types/index.d.ts +6 -4
  190. package/dist/types/server/declaration-safety.d.ts +7 -0
  191. package/dist/types/server/host/page-response-request.d.ts +0 -1
  192. package/dist/types/server/host/published-page-artifact-cache.d.ts +64 -0
  193. package/dist/types/server/ooui.d.ts +18 -0
  194. package/dist/types/server/page-assets.d.ts +7 -0
  195. package/dist/types/server/page-declaration.d.ts +14 -0
  196. package/dist/types/server/registry/asset-store.d.ts +112 -0
  197. package/dist/types/server/registry/declaration-precompiler.d.ts +23 -3
  198. package/dist/types/server/registry/index.d.ts +3 -1
  199. package/dist/types/server/registry/page-registry-store.d.ts +57 -4
  200. package/dist/types/server/registry/publish-asset-pin.d.ts +166 -0
  201. package/dist/types/server/registry/services/pages/List.d.ts +9 -3
  202. package/dist/types/server/registry/validation/compile-gate.d.ts +63 -0
  203. package/dist/types/shared/component/derive-sample.d.ts +37 -0
  204. package/dist/types/shared/component/field-lines.d.ts +19 -0
  205. package/dist/types/shared/container-breakpoints.d.ts +42 -0
  206. package/dist/types/shared/object-semantics.d.ts +42 -0
  207. package/dist/types/shared/ooui-declaration.d.ts +135 -0
  208. package/dist/types/shared/types/component-contract.types.d.ts +29 -12
  209. package/dist/types/shared/types/data-config.types.d.ts +86 -0
  210. package/dist/types/shared/types/domain.types.d.ts +0 -21
  211. package/dist/types/shared/types/engine.types.d.ts +0 -4
  212. package/dist/types/shared/types/layout-constraint.types.d.ts +1 -0
  213. package/dist/types/shared/types/ui-config.types.d.ts +157 -12
  214. package/next.config.js +106 -13
  215. package/package.json +28 -2
  216. package/core/client/host-bridge/index.ts +0 -27
  217. package/core/client/parser/yaml-loader.ts +0 -36
  218. package/core/shared/manifest/manifest-contract.ts +0 -12
  219. package/dist/types/client/host-bridge/index.d.ts +0 -9
  220. package/dist/types/client/parser/yaml-loader.d.ts +0 -21
  221. package/dist/types/shared/manifest/manifest-contract.d.ts +0 -4
@@ -0,0 +1,64 @@
1
+ /**
2
+ * 参与编译、因而必须参与哈希的声明字段闭集。
3
+ * `notes` 等元信息不进编译器,也不进键——把它算进去只会让相同产物反复重算。
4
+ */
5
+ export interface PublishedPageDeclaration {
6
+ html: string;
7
+ uiYaml: string;
8
+ eventYaml?: string;
9
+ styleYaml?: string;
10
+ dataYaml?: string;
11
+ }
12
+ /** 浏览器最终收到的运行时资产。缓存条目一律冻结:共享对象被就地改写是另一种静默污染。 */
13
+ export interface PublishedPageArtifact {
14
+ readonly uiYaml: string;
15
+ readonly eventYaml: string;
16
+ readonly dataYaml?: string;
17
+ }
18
+ export interface PublishedPageArtifactResult {
19
+ artifact: PublishedPageArtifact;
20
+ /** true = 命中缓存,本次没有重新编译。调用方据此决定要不要打漂移日志。 */
21
+ cached: boolean;
22
+ /** 缓存键(编译身份 + 声明指纹),排障时可直接比对。 */
23
+ key: string;
24
+ }
25
+ export interface PublishedPageArtifactCacheStats {
26
+ size: number;
27
+ capacity: number;
28
+ hits: number;
29
+ misses: number;
30
+ evictions: number;
31
+ compilerVersion: string;
32
+ }
33
+ /**
34
+ * 声明指纹。逐字段**带长度前缀**地喂哈希:直接拼接会让
35
+ * `{uiYaml:'ab', dataYaml:''}` 与 `{uiYaml:'a', dataYaml:'b'}` 落到同一个键——
36
+ * 那种碰撞不会抛错,只会让 A 页面拿到 B 页面的产物。
37
+ */
38
+ export declare function declarationFingerprint(declaration: PublishedPageDeclaration): string;
39
+ /**
40
+ * 缓存键 = 编译身份 + 声明指纹。任一变化都必然换键,也就必然重算。
41
+ *
42
+ * `identity` 缺省现算;`resolvePublishedPageArtifact` 传入它已算好的那一份——
43
+ * 同一次取页里键与条目核对用的必须是同一个身份,也不必把宿主的供货来源问两遍。
44
+ */
45
+ export declare function publishedPageArtifactKey(declaration: PublishedPageDeclaration, compilerVersion?: string, identity?: string): string;
46
+ /**
47
+ * 无缓存编译:把统一声明编成运行时资产。
48
+ * 传给编译器的字段与参与哈希的字段是同一个闭集——只有这样,
49
+ * 「键相同」才真的等价于「编译输入相同」。
50
+ */
51
+ export declare function compilePublishedPageArtifact(declaration: PublishedPageDeclaration): PublishedPageArtifact;
52
+ /**
53
+ * 取产物:命中缓存直接返回,否则编译并落缓存。
54
+ *
55
+ * 编译抛错**不缓存**:失败面必须在每次请求上如实复现,
56
+ * 把一次失败钉进缓存等于把偶发问题变成常驻问题。
57
+ */
58
+ export declare function resolvePublishedPageArtifact(declaration: PublishedPageDeclaration, options?: {
59
+ compilerVersion?: string;
60
+ }): PublishedPageArtifactResult;
61
+ /** 测试与排障用:清空缓存与计数。生产路径不调用。 */
62
+ export declare function resetPublishedPageArtifactCache(): void;
63
+ /** 观测点:没有这个,「缓存到底有没有生效」只能靠猜。 */
64
+ export declare function publishedPageArtifactCacheStats(): PublishedPageArtifactCacheStats;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Server-only OOUI assembly entry.
3
+ *
4
+ * Component libraries provide the vocabulary; soma-core only owns the
5
+ * process-level slot and compiler-facing engine. Hosts that still use OOUI
6
+ * can register their composed pack through this public subpath without
7
+ * reaching into `core/build`.
8
+ *
9
+ * `contractView` is exported here because a Host has to turn the component
10
+ * table it actually registered into `SomaOouiPack.contracts`
11
+ * (`createSomaUiOouiPack({ contracts })` in soma-ui requires exactly that).
12
+ * Without it a third-party Host could only deep-import the composition layer
13
+ * or re-implement the conversion — a second copy that drifts silently.
14
+ */
15
+ import 'server-only';
16
+ export { registerOouiPacks, resolveOouiEngine, registeredOouiPackNames, resetOouiEngineSlot, type RegisterOouiPacksOptions, } from '../build/ooui/engine-slot';
17
+ export { contractView } from '../build/ooui';
18
+ export type { SomaComponentContractView, SomaEnvironment, SomaOouiEngine, SomaOouiHatch, SomaOouiPack, SomaOouiFragment, } from '../build/ooui';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Server-only compilation entry used by preview and smoke-test hosts.
3
+ *
4
+ * 刻意不 `import 'server-only'`:soma-ai 的冒烟探测器在经 jiti 加载的宿主服务里
5
+ * 动态 import 本入口,server-only 在纯 Node 语境下会抛错(理由同 `server/page-declaration.ts`)。
6
+ */
7
+ export { compilePageAssets } from '../build/compiler/page-assets';
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Server-only page declaration compiler entry.
3
+ *
4
+ * Hosts and server packages must import this public subpath rather than reach
5
+ * into `core/build`. Keeping it separate from the root barrel prevents the
6
+ * Node-only OOUI compiler dependencies from entering browser bundles.
7
+ *
8
+ * 刻意不 `import 'server-only'`(与 `server/registry/index.ts` 同一理由):宿主的
9
+ * `api/service/*` 由服务加载器经 jiti 在纯 Node 语境加载(`core/server/api/load-host-service.ts`),
10
+ * 而 soma-web 的发布服务、soma-ai 的页面生成服务都从这里 import 编译器——
11
+ * server-only 在那里按 default 条件解析到会抛错的那一份,整个服务类加载失败、端点 404。
12
+ * soma-core 自己的客户端依赖图够不到 core/server,由 verify:client-dep-graph 看守。
13
+ */
14
+ export { compilePageDeclaration, type CompiledPageDeclaration, type SomaPageDeclarationInput, } from '../build/compiler/page-declaration-compiler';
@@ -0,0 +1,112 @@
1
+ /** 摘要算法。只增不改:换算法要新起前缀,老摘要仍按老前缀能读回来。 */
2
+ export declare const SOMA_ASSET_DIGEST_ALGO = "sha256";
3
+ /** 摘要形状:`sha256-<64 位小写十六进制>`。校验用它,不用 `startsWith`。 */
4
+ export declare const SOMA_ASSET_DIGEST_PATTERN: RegExp;
5
+ /**
6
+ * 单份资产体积上限 = 2,097,152 字节(2MiB)。
7
+ *
8
+ * 依据(实测,2026-09-10,`soma-ui/src/styles.ts`):
9
+ * - **全库** `SOMA_UI_CSS` = 1,351,112 字节(1319.4KB)。这是"某页引用了全部 325 个
10
+ * 组件"时组件 CSS 闭包的物理上界,任何合法闭包都必须能进来,所以上限必须高于它;
11
+ * - 325 个组件分片合计 1,303,452 字节,单片中位 4,197 / p90 6,251 / 最大 7,558;
12
+ * 13 个共享分片合计 33,376;基座 + 换肤抑制 14,284;
13
+ * - 实测五个真实页面(`soma-web/html/*.html`)的组件 CSS 闭包:
14
+ * assets 14,465 / index 18,607 / components 25,344 / generate 31,097 /
15
+ * architecture 40,785 字节——离全库上界还有 32 倍余量。
16
+ *
17
+ * 2MiB = 全库上界的 1.55 倍。比全库还大的"组件 CSS 闭包"在物理上不可能,
18
+ * 撞到这条线的只能是喂错了东西(把图片 base64、把整个 npm 包塞进来),那正是要拒的。
19
+ * 上限卡在入库这一刀,因为入库之后每次对账都要为它付一遍哈希代价。
20
+ */
21
+ export declare const REGISTRY_ASSET_MAX_BYTES = 2097152;
22
+ /**
23
+ * 资产类型。**只增不改**——它是引用方(钉子)的分类,不进摘要、不进路径。
24
+ * 同一份字节在两个类型下必须是同一个对象,否则内容寻址就有了两个真值。
25
+ */
26
+ export type SomaAssetKind = 'component-css';
27
+ /** 一份入库资产的引用:摘要 + 字节数 + 类型。页面版本存的就是这个,不存字节。 */
28
+ export interface SomaAssetRef {
29
+ kind: SomaAssetKind;
30
+ /** `sha256-<64 hex>` */
31
+ digest: string;
32
+ /** UTF-8 字节数(对账时"少了多少"看得见,不必读回字节) */
33
+ bytes: number;
34
+ }
35
+ /**
36
+ * 资产库。**同步 API**——`createPageVersionRecord` 是同步的,
37
+ * 而钉住资产必须与产生版本记录在同一步完成:分成两步就有了"版本已落库、
38
+ * 资产还没落库"的中间态,而那个中间态崩一次就留下一个指向不存在字节的钉子。
39
+ */
40
+ export interface RegistryAssetStore {
41
+ /** 入库并返回引用。同摘要已在库中即复用,不重写。 */
42
+ put(kind: SomaAssetKind, content: string): SomaAssetRef;
43
+ /**
44
+ * 按摘要读回字节;不在库中返回 null。读回时**重算摘要**,不符即抛;
45
+ * 在库里却读不出来(权限、IO)同样抛——"读不到"不等于"不在"。
46
+ */
47
+ read(digest: string): string | null;
48
+ /** 摘要是否在库中(对账判"这次漂移还能不能恢复");查询本身失败即抛,不答 false */
49
+ has(digest: string): boolean;
50
+ }
51
+ /** 算一段文本的资产摘要。UTF-8 计,与 `Buffer.byteLength` 同一口径。 */
52
+ export declare function somaAssetDigest(content: string): string;
53
+ /** 摘要形状校验。形状不对一律当"不是摘要"处理,不去猜。 */
54
+ export declare function isSomaAssetDigest(value: unknown): value is string;
55
+ /**
56
+ * 入库前的体积/内容闸门。返回中文问题清单(空数组 = 可入库)。
57
+ *
58
+ * 条目不带域前缀:两个调用方(`put` 抛错、`pinPublishedAssets` 告警)各自已写
59
+ * `[soma-core][注册中心]`,条目再带一个 `[注册中心]` 就成了一行里两遍同一个域。
60
+ */
61
+ export declare function assetIntakeIssues(content: unknown): string[];
62
+ /**
63
+ * 摘要 → 相对路径。`sha256/<前 2 位>/<后 62 位>`。
64
+ *
65
+ * 分两级目录是为了别让一个目录里堆几万个条目(ext4 单目录线性查找会变慢,
66
+ * 而变慢不报错)。**不带类型后缀**:同一份字节在两个类型下必须是同一个文件,
67
+ * 后缀会把它变成两个,内容寻址随即有了两个真值。
68
+ */
69
+ export declare function assetRelativePath(digest: string): string;
70
+ /** 共享文件系统资产库。写用原子落盘(临时文件 + rename),写一半被杀不留半个对象。 */
71
+ export declare class FileRegistryAssetStore implements RegistryAssetStore {
72
+ private readonly baseDir;
73
+ constructor(baseDir: string);
74
+ directory(): string;
75
+ put(kind: SomaAssetKind, content: string): SomaAssetRef;
76
+ read(digest: string): string | null;
77
+ has(digest: string): boolean;
78
+ /** 落盘字节数;不在库中返回 null。判据与 `read` 同一条:只有 ENOENT 算"不在" */
79
+ private sizeOf;
80
+ }
81
+ /**
82
+ * 内存资产库。测试用,也给"页面走对象存储 CAS、资产还没接后端"的部署当显式占位——
83
+ * 它是**进程内**的,重启即空,所以对账会如实报"钉住的字节不在库中"而不是假装齐全。
84
+ */
85
+ export declare class InMemoryRegistryAssetStore implements RegistryAssetStore {
86
+ private readonly objects;
87
+ put(kind: SomaAssetKind, content: string): SomaAssetRef;
88
+ read(digest: string): string | null;
89
+ has(digest: string): boolean;
90
+ /** 测试与巡检用:库里有多少个对象 */
91
+ size(): number;
92
+ }
93
+ /**
94
+ * 缺省资产目录。
95
+ *
96
+ * 取 `SOMA_REGISTRY_ASSET_DIR`;没配就取**页面目录的同级 `assets`**。
97
+ * 为什么要跟着页面目录走:宿主把 `SOMA_PAGE_REGISTRY_DIR` 挪到共享卷上,资产若仍落在
98
+ * 进程本地的 `data/soma-runtime/assets`,表现是"发布成功、钉子有摘要、
99
+ * 另一个实例对账时说字节不在库中"——而那台机器上确实不在。
100
+ * 两份存储必须一起挪,所以缺省就绑在一起。
101
+ *
102
+ * **页面走对象存储 CAS 的部署必须显式换库**:那条路径
103
+ * (`ConditionalPageRegistryRepository`)的页面数据在对象存储里,而这里的缺省后端是
104
+ * 本地文件系统——多实例部署下每台机器各写一份局部资产,对账在"没写过这份"的实例上
105
+ * 一律报不可恢复。这条缺省不会报错,所以写在这里:
106
+ * 那种部署要 `setRegistryAssetStore(自己的对象存储后端)`。
107
+ */
108
+ export declare function defaultRegistryAssetDir(): string;
109
+ /** 共享资产库(缺省文件后端;目录见 `defaultRegistryAssetDir`) */
110
+ export declare function getRegistryAssetStore(): RegistryAssetStore;
111
+ /** 替换 / 复位共享资产库(测试与自定义后端;不传参即复位,下次访问按当前环境重建) */
112
+ export declare function setRegistryAssetStore(store?: RegistryAssetStore | null): void;
@@ -1,3 +1,4 @@
1
+ import { type CompiledPageDeclaration } from '../../build/compiler/page-declaration-compiler';
1
2
  import type { PageRegistryDeclaration } from './page-registry-store';
2
3
  /**
3
4
  * 编译器版本。与 soma-core 的包版本对齐——语义变更必然伴随版本号变化,
@@ -11,6 +12,11 @@ export declare const DECLARATION_COMPILER_VERSION: string;
11
12
  /** 落库的完整运行时产物。 */
12
13
  export interface CompiledDeclaration {
13
14
  compilerVersion: string;
15
+ /**
16
+ * 供货指纹(词表版本那一维,可选)。缺席 = 编译那一刻宿主没报供货版本,
17
+ * 此时第三道闸**不判**——见文件头。只增不改:老产物没有这个键,判据自动降级为原来两条。
18
+ */
19
+ assetSupplyKey?: string;
14
20
  uiConfig?: unknown;
15
21
  eventConfig?: unknown;
16
22
  triggerConfig?: unknown;
@@ -21,10 +27,24 @@ export interface CompiledDeclaration {
21
27
  /**
22
28
  * 把统一声明一次编译成运行时可直接消费的完整配置对象。
23
29
  * 编译失败返回 null,不产生可被误用的半成品。
30
+ *
31
+ * `compiledPage`:调用方手里已经有**这同一份** `declaration` 的编译结果时传进来
32
+ * (发布路径上编译闸门那一次,见 `page-registry-store` 的 `normalizeDeclaration`),
33
+ * 这里就不再编第二遍。产物由下面同一段映射得出,与自己编出来的逐字相同;
34
+ * 供货指纹仍在此刻读取,与自己编时同一时点。保证它编的是同一份声明,是传入方的责任。
24
35
  */
25
- export declare function precompileDeclaration(declaration: PageRegistryDeclaration): CompiledDeclaration | null;
36
+ export declare function precompileDeclaration(declaration: PageRegistryDeclaration, compiledPage?: CompiledPageDeclaration): CompiledDeclaration | null;
26
37
  /**
27
- * 消费端的版本闸:编译器版本对不上就整份丢弃。
38
+ * 消费端的版本闸:编译器版本或供货版本对不上就整份丢弃。
28
39
  * 这是"缓存不是真理"那条纪律的执行点。
40
+ *
41
+ * 三条判据:
42
+ * 1. 编译器版本(引擎那一维)必须逐字相同;
43
+ * 2. 结构必须齐(`uiConfig` / `eventConfig` 都在);
44
+ * 3. **供货指纹(词表那一维)不许相左**——但只在**两侧都有键**时才判。
45
+ * 单侧有键就不判是刻意的:老产物没有这个键,一律判假会让每次取页都重编译一遍
46
+ * (功能全对、只有耗时在涨,正是这条路径上最典型的静默退化);
47
+ * 而运行时问不到自己的供货版本时判假,等于拿"我不知道"当"不一致"。
48
+ * 失败方向仍然安全:第三道闸判假只导致**重新编译**,不导致拒绝。
29
49
  */
30
- export declare function isCompiledUsable(compiled: CompiledDeclaration | null | undefined, runtimeVersion?: string): boolean;
50
+ export declare function isCompiledUsable(compiled: CompiledDeclaration | null | undefined, runtimeVersion?: string, runtimeSupplyKey?: string | undefined): boolean;
@@ -19,11 +19,13 @@ export { hasConfiguredCredentials, isRegistryDemoOpenDoor, looksLikeProduction,
19
19
  export { setRegistryLockBackend, withRegistryLock, writeFileAtomic, type RegistryLockBackend, } from './registry-file-lock';
20
20
  export { readJsonWithLimit, RequestBodyTooLargeError, REGISTRY_WRITE_MAX_BYTES, type BodyLimitedRequest, } from './request-body-limit';
21
21
  export { precompileDeclaration, isCompiledUsable, DECLARATION_COMPILER_VERSION, type CompiledDeclaration, } from './declaration-precompiler';
22
+ export { assetIntakeIssues, assetRelativePath, defaultRegistryAssetDir, FileRegistryAssetStore, getRegistryAssetStore, InMemoryRegistryAssetStore, isSomaAssetDigest, REGISTRY_ASSET_MAX_BYTES, setRegistryAssetStore, somaAssetDigest, SOMA_ASSET_DIGEST_ALGO, SOMA_ASSET_DIGEST_PATTERN, type RegistryAssetStore, type SomaAssetKind, type SomaAssetRef, } from './asset-store';
23
+ export { ASSET_PIN_VERSION, assembleComponentCss, assetPinByteSize, assetSupplyDriftNotice, currentAssetSupply, currentAssetSupplyKey, pinnedAssetMembers, pinPublishedAssets, reconcilePinnedAssets, setPublishedAssetSource, type AssembledComponentCss, type PinnableDeclaration, type PinPublishedAssetsOptions, type PublishedAssetSource, type PublishedAssetSupply, type ReconcilableRecord, type SomaAssetPin, type SomaAssetReconciliation, type SomaAssetReconcileStatus, type SomaPinnedAsset, } from './publish-asset-pin';
22
24
  export { scanDeclarationSafety, type ScannableDeclaration } from './validation/declaration-safety-scan';
23
25
  export { RegistryError } from './registry-error';
24
26
  export { ApiRegistryStore, ApiRegistryError, ApiRegistryErrorCodes, API_NAME_PATTERN, API_APP_PATTERN, API_METHODS, API_RECORD_MAX_BYTES, getApiRegistryStore, resetApiRegistryStore, type ApiMethod, type ApiRecord, type ApiRegisterInput, type ApiRegistryErrorCode, type ApiRegistryListItem, type ApiRegistryListOptions, type ApiRegistryListResult, type ApiRegistryStoreOptions, } from './api-registry-store';
25
27
  export { scanCredentialLeak, type CredentialScannable } from './validation/credential-ban';
26
- export { dryRunCompile, type CompilableDeclaration } from './validation/compile-gate';
28
+ export { dryRunCompile, dryRunCompileWithDiagnostics, type CompilableDeclaration, type CompileGateResult, type SomaCompileDiagnostic, type SomaCompileDiagnosticSource, } from './validation/compile-gate';
27
29
  export { collectReferencedComponents, scanUnknownComponents, setKnownComponentsResolver, type KnownComponentsResolver, } from './validation/component-existence';
28
30
  export { collectDeclaredApiPaths, crossCheckDeclaredApis, normalizeApiPath, setRegisteredPathsResolver, type RegisteredPathsResolver, } from './validation/cross-check';
29
31
  export { resolveRegistryService } from './services/index';
@@ -1,5 +1,8 @@
1
+ import type { CompiledPageDeclaration } from '../../build/compiler/page-declaration-compiler';
1
2
  import { type CompiledDeclaration } from './declaration-precompiler';
3
+ import { type SomaAssetPin } from './publish-asset-pin';
2
4
  import { RegistryError } from './registry-error';
5
+ import { type SomaCompileDiagnostic } from './validation/compile-gate';
3
6
  /** 页面名约束:小写字母 / 数字 / 连字符,1~64 位(可直接用作文件名与 URL 片段) */
4
7
  export declare const PAGE_NAME_PATTERN: RegExp;
5
8
  /** 应用命名空间约束:与页面名同形(略短),缺省 'default' */
@@ -50,7 +53,15 @@ export declare const PageRegistryErrorCodes: {
50
53
  export type PageRegistryErrorCode = (typeof PageRegistryErrorCodes)[keyof typeof PageRegistryErrorCodes];
51
54
  export declare class PageRegistryError extends RegistryError {
52
55
  readonly code: PageRegistryErrorCode;
53
- constructor(code: PageRegistryErrorCode, message: string);
56
+ /**
57
+ * 结构化诊断(可选):编译闸门命中时带上 `code` / `src` / `trace` / `remedy`。
58
+ *
59
+ * 为什么挂在错误上而不是只发字符串:`message` 是给人读的终点,
60
+ * 而这条错误的真实消费者是 AI 修订链——它要按 `remedy` 改哪一行。
61
+ * 字段可选、纯数据,现有 `catch (e) { e.message }` 的调用方一律不受影响。
62
+ */
63
+ readonly diagnostics?: readonly SomaCompileDiagnostic[];
64
+ constructor(code: PageRegistryErrorCode, message: string, diagnostics?: readonly SomaCompileDiagnostic[]);
54
65
  }
55
66
  /** 页面声明本体:与 /api/ai-page/generate 的产物同构(dataYaml 为数据对象绑定拓展位) */
56
67
  export interface PageRegistryDeclaration {
@@ -96,6 +107,18 @@ export interface PageVersionRecord {
96
107
  * 由服务端从统一源声明重新编译(见 DeclarationPrecompiler.isCompiledUsable)。
97
108
  */
98
109
  compiled?: CompiledDeclaration;
110
+ /**
111
+ * 资产钉子(可选):这一版**是对着哪一份组件 CSS 发布的**(内容摘要)。
112
+ *
113
+ * 与 `compiled` 平级而不是它的子键,因为两者性质相反:`compiled` 是缓存
114
+ * (编译失败即缺席,重编即可),钉子是真理(发布那一刻的事实,过后无从重建)。
115
+ * 塞进 `compiled` 会让一次编译失败连带丢掉钉子,而丢掉之后对账只会说"未钉住"——
116
+ * 通过,静默。详见 `publish-asset-pin.ts` 文件头。
117
+ *
118
+ * 缺席是正常状态:宿主没接样式供货来源(`setPublishedAssetSource`)、页面没引用构件、
119
+ * 或字节没能落库时都不钉。**钉子宁可缺席,不可说谎。**
120
+ */
121
+ assets?: SomaAssetPin;
99
122
  }
100
123
  /** publish 的可选项(第三参也兼容旧的裸 status 字符串写法) */
101
124
  export interface PageRegistryPublishOptions {
@@ -118,6 +141,12 @@ export interface PageVersionFields {
118
141
  tags: string[];
119
142
  meta?: PageRegistryMeta;
120
143
  operator?: string;
144
+ /**
145
+ * 编译闸门对**这同一份** `declaration` 的编译结果(发布路径专用,可选)。
146
+ * 给了就直接复用,`createPageVersionRecord` 不再编第二遍;不给(rollback / archive
147
+ * 复制旧声明时没有闸门那一次)照旧自己编。它只是编译输入,不进版本记录。
148
+ */
149
+ compiledPage?: CompiledPageDeclaration;
121
150
  }
122
151
  /** list() 返回的摘要条目(速记列直接可渲:状态 / 应用 / 标签 / 标题齐备) */
123
152
  export interface PageRegistryListItem {
@@ -138,6 +167,19 @@ export interface PageRegistryListOptions {
138
167
  keyword?: string;
139
168
  /** 是否包含已归档页面(缺省 false:归档页从清单消失) */
140
169
  includeArchived?: boolean;
170
+ /**
171
+ * 精确只看这一种状态——比 includeArchived 更具体的筛选。
172
+ *
173
+ * 与 includeArchived 的关系:includeArchived 只是"要不要把 archived 混进缺省清单"
174
+ * 的粗粒度开关;显式传了 status 就按它精筛,覆盖 includeArchived 的缺省收窄行为
175
+ * (例如 status: 'archived' 时无需再传 includeArchived: true)。不传 status 时,
176
+ * 行为完全由 includeArchived 决定,不受影响。
177
+ *
178
+ * 与 publishedOnly 的关系:**publishedOnly 是不可越权的可见性铁律,永远先于 status
179
+ * 生效**——非特权主体(publishedOnly: true)传 status: 'archived' 依旧看不到任何
180
+ * 已下架页面。这个可选查询参数不能绕开按主体分层的访问控制(见 publishedOnly 注释)。
181
+ */
182
+ status?: Extract<PageRegistryStatus, 'published' | 'archived'>;
141
183
  /**
142
184
  * 只列已发布页面(匿名调用方的缺省视角)。
143
185
  *
@@ -190,7 +232,8 @@ export declare class PageRegistryStore {
190
232
  get(name: string, version?: number): PageVersionRecord;
191
233
  /**
192
234
  * 页面摘要清单(按页面名排序,分页协议 { pages, total })。
193
- * 缺省排除已归档页面;支持 app / 关键词过滤与 limit/offset 分页。
235
+ * 缺省排除已归档页面;支持 app / 关键词 / status 精筛与 limit/offset 分页;
236
+ * status 语义见 PageRegistryListOptions.status 注释。
194
237
  */
195
238
  list(options?: PageRegistryListOptions): PageRegistryListResult;
196
239
  /** 回滚:把指定旧版本(声明 + 元数据 + app/tags)复制为新的 published 版本 */
@@ -245,8 +288,18 @@ export declare function assertPageName(name: unknown): string;
245
288
  export declare function assertVersionNumber(version: unknown): asserts version is number;
246
289
  /** publish 第三参归一化:裸 status 字符串(旧写法)或选项对象,逐字段校验 */
247
290
  export declare function normalizePublishOptions(options: PageRegistryStatus | PageRegistryPublishOptions): PageRegistryPublishOptions;
248
- /** 声明归一化:HTML + 统一 SOMA DSL 必填;页面侧车字段只允许缺省或空串。 */
249
- export declare function normalizeDeclaration(declaration: unknown): PageRegistryDeclaration;
291
+ /**
292
+ * 声明归一化:HTML + 统一 SOMA DSL 必填;页面侧车字段只允许缺省或空串。
293
+ *
294
+ * 除了归一化后的声明,还把编译闸门那一次的编译结果(`compiledPage`)一并交出来,
295
+ * 供 `createPageVersionRecord` 落预编译产物时复用。闸门编的与预编译要编的是
296
+ * **同一份归一化声明**、同一个纯函数,发布路径上相邻两步——第二遍只是重付一次编译代价
297
+ * (演绎链接进来之后这笔代价随声明规模长),而落库结果逐字相同,多编一遍不会让任何东西红。
298
+ */
299
+ export declare function normalizeDeclaration(declaration: unknown): {
300
+ declaration: PageRegistryDeclaration;
301
+ compiledPage: CompiledPageDeclaration;
302
+ };
250
303
  /** 声明总字节数:UTF-8 计,涵盖 declaration 的全部字符串字段 */
251
304
  export declare function declarationByteSize(declaration: PageRegistryDeclaration): number;
252
305
  /** 存量 JSON 记录归一化:只补元数据;旧页面语法必须离线迁移,不在读取时自动转换。 */
@@ -0,0 +1,166 @@
1
+ import { type RegistryAssetStore, type SomaAssetKind } from './asset-store';
2
+ import type { SomaPageOouiArtifact } from '../../shared/types/ui-config.types';
3
+ /** 钉子格式版本。读到不认识的版本整份当"未钉住",不猜字段。 */
4
+ export declare const ASSET_PIN_VERSION = 1;
5
+ /**
6
+ * 供货方交出来的样式表分片。字段名与 `ComposedComponentPacks.styles`
7
+ * (`core/client/component/component-pack.ts`)一一对应,宿主接线是把已有的
8
+ * 合成结果原样递进来,不必再造一份形状。
9
+ */
10
+ export interface PublishedAssetSupply {
11
+ /** 组件名 → 该组件的 CSS 分片(`styles.components`) */
12
+ components: Readonly<Record<string, string>>;
13
+ /** 共享资产名 → 分片(`styles.shared`) */
14
+ shared?: Readonly<Record<string, string>>;
15
+ /** 组件名 → 依赖的共享资产名(`styles.deps`) */
16
+ dependencies?: Readonly<Record<string, readonly string[]>>;
17
+ /** 包级基座分片(`styles.base`)。**次序即身份**——注入键是 `base:<下标>`,这里不重排 */
18
+ base?: readonly string[];
19
+ /** 组件名 → 令牌规则(`renderComponentTokenRule` 的产出;core 不代算,见下) */
20
+ tokens?: Readonly<Record<string, string>>;
21
+ /** 组件补丁(`composed.patches`) */
22
+ patches?: readonly {
23
+ target: string;
24
+ patchedBy: string;
25
+ css: string;
26
+ }[];
27
+ /**
28
+ * 供货包名 → 版本(如 `{ 'soma-ui': '1.4.2' }`)。
29
+ * 这是**词表版本**那一维的载体,也是 `isCompiledUsable` 第三道闸的判据来源
30
+ * (见 `currentAssetSupplyKey`)。参照 SDUI 的能力协商:各方把自己"是哪个版本"
31
+ * 报上来,而不是让对面去猜。不给就那道闸不判。
32
+ */
33
+ packs?: Readonly<Record<string, string>>;
34
+ }
35
+ /** 供货来源;返回 null / undefined 表示"宿主没告诉我",此时不钉、不判 */
36
+ export type PublishedAssetSource = () => PublishedAssetSupply | null | undefined;
37
+ /**
38
+ * 注入样式供货来源(宿主服务端接线;传 null 复位为"不钉")。
39
+ * 与组件清单同款:**每次都重新问一次,不缓存**——供货可随宿主热更新,
40
+ * 缓存住的表现是"换了组件库版本,钉子还钉着旧摘要"。
41
+ */
42
+ export declare function setPublishedAssetSource(next: PublishedAssetSource | null): void;
43
+ /** 当前供货(没有则 undefined)。对账与钉住共用同一个入口,不各问一次。 */
44
+ export declare function currentAssetSupply(): PublishedAssetSupply | undefined;
45
+ /**
46
+ * 供货指纹:`packs` 的 `名字@版本` 逐行摘要。缺 `packs` 返回 undefined(不判)。
47
+ *
48
+ * 为什么不去哈希 1.3MB 的全库字节:这个键会挂在**每次取页**都要过的
49
+ * `isCompiledUsable` 上。哈希全库每次约数毫秒,而"每次取页多几毫秒"是这条路径上
50
+ * 最典型的静默退化(功能全对、监控全绿,只有耗时在涨——`published-page-assets.ts`
51
+ * 的文件头就是为同一件事写的)。版本号是**声明出来的**能力协商,微秒级。
52
+ * 代价是宿主必须如实报版本;不报就不判,而不是拿一个猜的键去判。
53
+ */
54
+ export declare function currentAssetSupplyKey(): string | undefined;
55
+ /** 钉住的一份资产 */
56
+ export interface SomaPinnedAsset {
57
+ kind: SomaAssetKind;
58
+ /** `sha256-<64 hex>` */
59
+ digest: string;
60
+ bytes: number;
61
+ /** 参与这份资产的构件名(升序)。对账要按同一份名单重算,"少了谁"才看得见 */
62
+ members: string[];
63
+ }
64
+ /** 一个页面版本的资产钉子 */
65
+ export interface SomaAssetPin {
66
+ pinVersion: typeof ASSET_PIN_VERSION;
67
+ /** 与 `compiled` 同一道版本闸(`DECLARATION_COMPILER_VERSION`) */
68
+ compilerVersion: string;
69
+ /** 供货包版本(词表版本那一维;供货方没报就缺席) */
70
+ packs?: Record<string, string>;
71
+ /** 资产清单(按 kind 升序) */
72
+ assets: SomaPinnedAsset[];
73
+ /**
74
+ * 本次**没能覆盖到**的东西。空则整个键不写。
75
+ * 它是"钉子宁可缺席不可说谎"的第二层:钉住了一部分,就必须写清哪一部分没钉住。
76
+ */
77
+ caveats?: string[];
78
+ }
79
+ /** 钉住资产时需要的最小声明形状(只用 html;不引 page-registry-store 免得成环) */
80
+ export interface PinnableDeclaration {
81
+ html: string;
82
+ }
83
+ export interface PinPublishedAssetsOptions {
84
+ /** 演绎产物。演绎选出的组件不在 `html` 里,不带上就会漏钉恰好是演绎选中的那些 */
85
+ artifact?: SomaPageOouiArtifact | undefined;
86
+ /** 资产库(缺省取进程共享库) */
87
+ store?: RegistryAssetStore;
88
+ /** 编译器版本。由调用方传入,与 `compiled.compilerVersion` 同一个值 */
89
+ compilerVersion: string;
90
+ }
91
+ /**
92
+ * 收集这一版真正会用到的构件名(升序去重)。
93
+ *
94
+ * 两个来源都要:
95
+ * - `html` 里的 `data-soma-component`(手写编排);
96
+ * - 演绎产物每个区域的构件树(REQ-014)。**漏掉后者的表现最阴**:
97
+ * 页面开出来,手写那部分有样式,演绎出来那一块光秃秃,而两者都"渲染成功"。
98
+ */
99
+ export declare function pinnedAssetMembers(html: string, artifact?: SomaPageOouiArtifact | undefined): string[];
100
+ /** 拼装结果:规范次序的样式表 + 没找到分片的构件名 */
101
+ export interface AssembledComponentCss {
102
+ css: string;
103
+ missing: string[];
104
+ }
105
+ /**
106
+ * 按**规范次序**拼一份组件 CSS 闭包。幂等的全部要求都在这个函数里:
107
+ * 同一份构件名单 + 同一份供货 ⇒ 逐字节相同的字符串。
108
+ *
109
+ * 次序 = 基座 → 共享 → 令牌 → 组件 → 补丁,与 `pack-styles.ts` 的注入次序同层同序。
110
+ * 差别只有一处,写在这里免得下一个人以为是随手拉平的:运行时是**逐组件**注入
111
+ * (组件 A 的共享 → A 的令牌 → A 的分片 → 组件 B 的共享 → …),这里拉平成分层。
112
+ * 两者只在"某个组件分片去改共享类"时级联结果不同——而那本身违反分片纪律
113
+ * (分片只该碰自己的 `.soma-<组件>`)。钉子不为它兜底,但也不假装两者永远等价。
114
+ *
115
+ * `tokens` 由供货方交,core 不代算:令牌规则要读组件契约(`contract.tokens`),
116
+ * 契约住在组件库,core 自己算就等于在 core 里养第二份派生实现——两份必然漂,
117
+ * 而漂掉的表现是"钉子的字节与真实注入的字节差一条规则",对账天天报假漂移。
118
+ */
119
+ export declare function assembleComponentCss(supply: PublishedAssetSupply, members: readonly string[]): AssembledComponentCss;
120
+ /**
121
+ * 钉住这一版的资产。返回 null = 这一版没有可钉的资产(宿主没供货 / 页面没引用构件 /
122
+ * 供货里这些构件一片 CSS 都没有 / 字节没能落库)。**返回 null 不阻断发布**。
123
+ */
124
+ export declare function pinPublishedAssets(declaration: PinnableDeclaration, options: PinPublishedAssetsOptions): SomaAssetPin | null;
125
+ /** 钉子自身的 JSON 字节数(报体积用;它是**除声明与产物之外**新增在版本记录上的那一份) */
126
+ export declare function assetPinByteSize(pin: SomaAssetPin | undefined): number;
127
+ /**
128
+ * 发布时的漂移告示:上一版与这一版**构件名单一模一样、字节却不同** ⇒ 组件库在两次发布
129
+ * 之间换了。返回一句话,没漂返回 null。
130
+ *
131
+ * 为什么必须在发布这一刻说,而不是等回滚时再说:回滚是**故障现场**,那时候
132
+ * "样式也跟着变了"这条信息来得太晚,而且与故障本身混在一起分不开。
133
+ * 发布时说出来,操作者当场就知道"这次上线不只改了声明,还换了一整套样式基线"。
134
+ *
135
+ * 判据严格卡在"名单相同"上,因为名单不同本来就该产出不同字节(页面自己改了),
136
+ * 那时候报漂移是假警报——而假警报几次之后,真警报也没人看了。
137
+ */
138
+ export declare function assetSupplyDriftNotice(previous: SomaAssetPin | undefined, current: SomaAssetPin | undefined, who: string): string | null;
139
+ /** 对账判定 */
140
+ export type SomaAssetReconcileStatus = 'match' | 'drift' | 'unpinned' | 'unavailable';
141
+ export interface SomaAssetReconciliation {
142
+ status: SomaAssetReconcileStatus;
143
+ /** 三段式(现状 / 问题 / 建议)问题清单;`match` 时为空 */
144
+ issues: string[];
145
+ /** 钉住的摘要(有钉子时) */
146
+ pinned?: string;
147
+ /** 按同一份名单、用今天的供货重算出的摘要(能算时) */
148
+ current?: string;
149
+ /** 漂移时:钉住的字节还在资产库里吗(在 ⇒ 这次漂移可恢复) */
150
+ recoverable?: boolean;
151
+ }
152
+ /** 对账所需的最小记录形状 */
153
+ export interface ReconcilableRecord {
154
+ name?: string;
155
+ version?: number;
156
+ assets?: unknown;
157
+ }
158
+ /**
159
+ * 拿这一版的钉子对今天的供货。这是"回滚只回滚了一半"第一次可判定的地方:
160
+ * `reconcilePinnedAssets(v3 记录)` 回答"今天部署的组件 CSS 与 v3 发布那天是否一致"。
161
+ *
162
+ * 判定只有四种,且**都不抛**:对账是读路径上的诊断,它自己绝不能成为新的失败面。
163
+ */
164
+ export declare function reconcilePinnedAssets(record: ReconcilableRecord, options?: {
165
+ store?: RegistryAssetStore;
166
+ }): SomaAssetReconciliation;
@@ -1,12 +1,18 @@
1
1
  import type { IService, SomaServiceRequest } from '../../../api/IService';
2
2
  /**
3
3
  * GET /api/soma-registry/pages/list — 页面摘要清单(分页协议)。
4
- * 查询参数(全部可选):app / keyword / includeArchived=1(需 read-private)/ limit / offset。
4
+ * 查询参数(全部可选):app / keyword / status(published/archived,闭集外的值按未提供
5
+ * 处理)/ includeArchived=1(需 read-private)/ limit / offset。
5
6
  * 响应:{ schemaVersion, pages: [{ name, latestVersion, updatedAt, status, app, tags, title? }], total }。
6
7
  *
7
- * **可见性按主体分层**:无 `read-private` 作用域的调用方只看得到 published 页面。
8
- * 草稿名与已下架页面同样是信息——按主体过滤而不是整端点鉴权:
8
+ * **可见性按主体分层**:无 `read-private` 作用域的调用方只看得到 published 页面——这条
9
+ * 铁律不受 `status` 影响:非特权主体传 status=archived 依旧看不到任何已下架页面(可见性
10
+ * 过滤先于 status 精筛生效)。草稿名与已下架页面同样是信息——按主体过滤而不是整端点鉴权:
9
11
  * 画廊跑在浏览器里、拿不到管理凭据,端点一鉴权它就瞎了。
12
+ *
13
+ * `status` 与 `includeArchived` 的关系:`status` 更具体,选定后覆盖 `includeArchived`
14
+ * 的缺省收窄行为(例如 status=archived 无需再传 includeArchived=1);不传 `status`
15
+ * 时行为不受影响。
10
16
  */
11
17
  export default class ListService implements IService {
12
18
  get(req: SomaServiceRequest): Promise<Response>;