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.
- package/bin/component.cjs +240 -0
- package/bin/eject.cjs +174 -0
- package/bin/migrate.cjs +362 -0
- package/core/build/blocks/block-compile.ts +143 -17
- package/core/build/blocks/migrate-flat.ts +118 -25
- package/core/build/compiler/page-declaration-compiler.ts +149 -5
- package/core/build/compiler/route-builder.ts +0 -4
- package/core/build/compiler/soma-precompile.js +443 -30
- package/core/build/component/component-graph.ts +28 -105
- package/core/build/component/package-loader.ts +50 -4
- package/core/build/eject/component-eject.ts +8 -2
- package/core/build/layout/constraint-solver.ts +131 -16
- package/core/build/layout/css-emitter.ts +15 -9
- package/core/build/ooui/artifact/artifact.types.ts +275 -0
- package/core/build/ooui/artifact/emit-artifact.ts +269 -0
- package/core/build/ooui/artifact/emit-html.ts +204 -0
- package/core/build/ooui/artifact/index.ts +53 -0
- package/core/build/ooui/artifact/spatial-tree.ts +268 -0
- package/core/build/ooui/artifact/utility-class.ts +83 -0
- package/core/build/ooui/composition/candidate.types.ts +323 -0
- package/core/build/ooui/composition/control-model.ts +114 -0
- package/core/build/ooui/composition/registry.ts +520 -0
- package/core/build/ooui/composition/select.ts +232 -0
- package/core/build/ooui/diagnostics/codes.ts +230 -0
- package/core/build/ooui/diagnostics/error.ts +235 -0
- package/core/build/ooui/diagnostics/format.ts +106 -0
- package/core/build/ooui/diagnostics/index.ts +62 -0
- package/core/build/ooui/diagnostics/issue.types.ts +112 -0
- package/core/build/ooui/engine-slot.ts +184 -0
- package/core/build/ooui/index.ts +1427 -0
- package/core/build/ooui/intent/derive-intent.ts +450 -0
- package/core/build/ooui/intent/field-rules.ts +330 -0
- package/core/build/ooui/intent/intent.types.ts +476 -0
- package/core/build/ooui/intent/verb-events.ts +285 -0
- package/core/build/ooui/page/budget.ts +503 -0
- package/core/build/ooui/page/compose-page.ts +736 -0
- package/core/build/ooui/page/index.ts +66 -0
- package/core/build/ooui/page/page.types.ts +402 -0
- package/core/build/ooui/page/region-row.ts +241 -0
- package/core/build/ooui/semantic/expand-page-surface.ts +180 -0
- package/core/build/ooui/semantic/kernel.types.ts +187 -0
- package/core/build/ooui/semantic/normalize.ts +784 -0
- package/core/build/ooui/semantic/origin.types.ts +211 -0
- package/core/build/ooui/semantic/role-alias.ts +154 -0
- package/core/build/ooui/semantic/shorthand.ts +233 -0
- package/core/build/ooui/semantic/surface.types.ts +78 -0
- package/core/build/ooui/semantic/validate-request.ts +267 -0
- package/core/build/ooui/spatial/emit-utility.ts +480 -0
- package/core/build/ooui/spatial/ir.types.ts +443 -0
- package/core/build/ooui/spatial/registry.ts +565 -0
- package/core/build/ooui/spatial/solve.ts +769 -0
- package/core/build/ooui/spatial/utility.types.ts +242 -0
- package/core/build/ooui/trace/index.ts +40 -0
- package/core/build/ooui/trace/render.ts +190 -0
- package/core/build/ooui/trace/source.types.ts +69 -0
- package/core/build/ooui/trace/trace.types.ts +326 -0
- package/core/build/pack/pack-init.ts +19 -14
- package/core/client/base/SomaHttpClient.ts +34 -1
- package/core/client/component/ai-catalog.ts +42 -0
- package/core/client/component/example-blocks.ts +1 -7
- package/core/client/component/theme-component-tokens.ts +12 -15
- package/core/client/component/verify-pack.ts +120 -1
- package/core/client/container/SomaContainerAdapter.ts +6 -2
- package/core/client/data/data-object-resolver.ts +27 -8
- package/core/client/diagnostics/telemetry-context.ts +0 -4
- package/core/client/engine/asset-resolver.ts +0 -1
- package/core/client/engine/event-engine.ts +7 -3
- package/core/client/engine/soma-bootstrap.ts +292 -34
- package/core/client/engine/style-binder.ts +0 -1
- package/core/client/infra/http/IHttpClient.ts +0 -6
- package/core/client/infra/http/SomaHttpService.ts +5 -2
- package/core/client/infra/notify/DomNotifyService.ts +1 -1
- package/core/client/infra/router/router-path.ts +0 -6
- package/core/client/parser/annotation-extractor.ts +1 -1
- package/core/client/parser/blocks/namespace.ts +30 -5
- package/core/client/parser/blocks/page-parser.ts +44 -1
- package/core/client/parser/blocks/use-parser.ts +266 -46
- package/core/client/parser/data-config-parser.ts +71 -3
- package/core/client/parser/layout-parser.ts +4 -3
- package/core/client/parser/reaction-parser.ts +0 -1
- package/core/client/parser/ui-config-parser.ts +212 -74
- package/core/client/theme/scene-tokens.ts +9 -3
- package/core/client/theme/theme-axes.ts +74 -16
- package/core/client/theme/theme-engine.ts +280 -69
- package/core/client/theme/tone-solver.ts +9 -8
- package/core/index.ts +38 -3
- package/core/server/api/load-host-service.ts +8 -2
- package/core/server/declaration-safety.ts +11 -0
- package/core/server/host/page-response-request.ts +0 -2
- package/core/server/host/published-page-artifact-cache.ts +244 -0
- package/core/server/host/published-page-assets.ts +44 -5
- package/core/server/mock/node/cli.mjs +0 -1
- package/core/server/mock/node/schema-generator.mjs +0 -1
- package/core/server/ooui.ts +34 -0
- package/core/server/page-assets.ts +8 -0
- package/core/server/page-declaration.ts +18 -0
- package/core/server/registry/asset-store.ts +327 -0
- package/core/server/registry/declaration-precompiler.ts +49 -6
- package/core/server/registry/index.ts +47 -1
- package/core/server/registry/page-registry-repository.ts +6 -2
- package/core/server/registry/page-registry-store.ts +133 -19
- package/core/server/registry/publish-asset-pin.ts +557 -0
- package/core/server/registry/services/pages/List.ts +15 -3
- package/core/server/registry/validation/compile-gate.ts +180 -8
- package/core/server/registry/validation/declaration-safety-scan.ts +113 -23
- package/core/shared/component/derive-sample.ts +290 -0
- package/core/shared/component/field-lines.ts +563 -0
- package/core/shared/container-breakpoints.ts +46 -0
- package/core/shared/object-semantics.ts +240 -0
- package/core/shared/ooui-declaration.ts +235 -0
- package/core/shared/types/component-contract.types.ts +30 -13
- package/core/shared/types/data-config.types.ts +95 -0
- package/core/shared/types/domain.types.ts +0 -24
- package/core/shared/types/engine.types.ts +0 -5
- package/core/shared/types/layout-constraint.types.ts +16 -0
- package/core/shared/types/ui-config.types.ts +163 -13
- package/dist/cli/soma.js +24 -11
- package/dist/core/index.cjs +2424 -1098
- package/dist/types/build/blocks/block-compile.d.ts +16 -1
- package/dist/types/build/blocks/migrate-flat.d.ts +17 -0
- package/dist/types/build/compiler/page-declaration-compiler.d.ts +46 -0
- package/dist/types/build/compiler/route-builder.d.ts +0 -1
- package/dist/types/build/component/component-graph.d.ts +17 -53
- package/dist/types/build/component/package-loader.d.ts +8 -1
- package/dist/types/build/layout/constraint-solver.d.ts +46 -4
- package/dist/types/build/ooui/artifact/artifact.types.d.ts +180 -0
- package/dist/types/build/ooui/artifact/emit-artifact.d.ts +58 -0
- package/dist/types/build/ooui/artifact/emit-html.d.ts +53 -0
- package/dist/types/build/ooui/artifact/index.d.ts +5 -0
- package/dist/types/build/ooui/artifact/spatial-tree.d.ts +48 -0
- package/dist/types/build/ooui/artifact/utility-class.d.ts +46 -0
- package/dist/types/build/ooui/composition/candidate.types.d.ts +206 -0
- package/dist/types/build/ooui/composition/control-model.d.ts +37 -0
- package/dist/types/build/ooui/composition/registry.d.ts +66 -0
- package/dist/types/build/ooui/composition/select.d.ts +63 -0
- package/dist/types/build/ooui/diagnostics/codes.d.ts +28 -0
- package/dist/types/build/ooui/diagnostics/error.d.ts +135 -0
- package/dist/types/build/ooui/diagnostics/format.d.ts +51 -0
- package/dist/types/build/ooui/diagnostics/index.d.ts +25 -0
- package/dist/types/build/ooui/diagnostics/issue.types.d.ts +56 -0
- package/dist/types/build/ooui/engine-slot.d.ts +41 -0
- package/dist/types/build/ooui/index.d.ts +286 -0
- package/dist/types/build/ooui/intent/derive-intent.d.ts +32 -0
- package/dist/types/build/ooui/intent/field-rules.d.ts +99 -0
- package/dist/types/build/ooui/intent/intent.types.d.ts +318 -0
- package/dist/types/build/ooui/intent/verb-events.d.ts +70 -0
- package/dist/types/build/ooui/page/budget.d.ts +28 -0
- package/dist/types/build/ooui/page/compose-page.d.ts +41 -0
- package/dist/types/build/ooui/page/index.d.ts +4 -0
- package/dist/types/build/ooui/page/page.types.d.ts +264 -0
- package/dist/types/build/ooui/page/region-row.d.ts +16 -0
- package/dist/types/build/ooui/semantic/expand-page-surface.d.ts +33 -0
- package/dist/types/build/ooui/semantic/kernel.types.d.ts +125 -0
- package/dist/types/build/ooui/semantic/normalize.d.ts +45 -0
- package/dist/types/build/ooui/semantic/origin.types.d.ts +95 -0
- package/dist/types/build/ooui/semantic/role-alias.d.ts +35 -0
- package/dist/types/build/ooui/semantic/shorthand.d.ts +60 -0
- package/dist/types/build/ooui/semantic/surface.types.d.ts +16 -0
- package/dist/types/build/ooui/semantic/validate-request.d.ts +19 -0
- package/dist/types/build/ooui/spatial/emit-utility.d.ts +43 -0
- package/dist/types/build/ooui/spatial/ir.types.d.ts +280 -0
- package/dist/types/build/ooui/spatial/registry.d.ts +110 -0
- package/dist/types/build/ooui/spatial/solve.d.ts +42 -0
- package/dist/types/build/ooui/spatial/utility.types.d.ts +191 -0
- package/dist/types/build/ooui/trace/index.d.ts +3 -0
- package/dist/types/build/ooui/trace/render.d.ts +42 -0
- package/dist/types/build/ooui/trace/source.types.d.ts +25 -0
- package/dist/types/build/ooui/trace/trace.types.d.ts +143 -0
- package/dist/types/client/base/SomaHttpClient.d.ts +8 -0
- package/dist/types/client/component/ai-catalog.d.ts +9 -0
- package/dist/types/client/component/example-blocks.d.ts +0 -2
- package/dist/types/client/component/theme-component-tokens.d.ts +8 -5
- package/dist/types/client/component/verify-pack.d.ts +10 -0
- package/dist/types/client/data/data-object-resolver.d.ts +10 -2
- package/dist/types/client/diagnostics/telemetry-context.d.ts +0 -1
- package/dist/types/client/engine/soma-bootstrap.d.ts +123 -10
- package/dist/types/client/infra/http/IHttpClient.d.ts +0 -5
- package/dist/types/client/infra/http/SomaHttpService.d.ts +1 -1
- package/dist/types/client/infra/router/router-path.d.ts +0 -2
- package/dist/types/client/parser/blocks/namespace.d.ts +20 -0
- package/dist/types/client/parser/blocks/page-parser.d.ts +9 -0
- package/dist/types/client/parser/blocks/use-parser.d.ts +38 -4
- package/dist/types/client/parser/data-config-parser.d.ts +13 -0
- package/dist/types/client/parser/ui-config-parser.d.ts +1 -11
- package/dist/types/client/theme/scene-tokens.d.ts +9 -3
- package/dist/types/client/theme/theme-axes.d.ts +64 -1
- package/dist/types/client/theme/theme-engine.d.ts +13 -8
- package/dist/types/client/theme/tone-solver.d.ts +9 -5
- package/dist/types/index.d.ts +6 -4
- package/dist/types/server/declaration-safety.d.ts +7 -0
- package/dist/types/server/host/page-response-request.d.ts +0 -1
- package/dist/types/server/host/published-page-artifact-cache.d.ts +64 -0
- package/dist/types/server/ooui.d.ts +18 -0
- package/dist/types/server/page-assets.d.ts +7 -0
- package/dist/types/server/page-declaration.d.ts +14 -0
- package/dist/types/server/registry/asset-store.d.ts +112 -0
- package/dist/types/server/registry/declaration-precompiler.d.ts +23 -3
- package/dist/types/server/registry/index.d.ts +3 -1
- package/dist/types/server/registry/page-registry-store.d.ts +57 -4
- package/dist/types/server/registry/publish-asset-pin.d.ts +166 -0
- package/dist/types/server/registry/services/pages/List.d.ts +9 -3
- package/dist/types/server/registry/validation/compile-gate.d.ts +63 -0
- package/dist/types/shared/component/derive-sample.d.ts +37 -0
- package/dist/types/shared/component/field-lines.d.ts +19 -0
- package/dist/types/shared/container-breakpoints.d.ts +42 -0
- package/dist/types/shared/object-semantics.d.ts +42 -0
- package/dist/types/shared/ooui-declaration.d.ts +135 -0
- package/dist/types/shared/types/component-contract.types.d.ts +29 -12
- package/dist/types/shared/types/data-config.types.d.ts +86 -0
- package/dist/types/shared/types/domain.types.d.ts +0 -21
- package/dist/types/shared/types/engine.types.d.ts +0 -4
- package/dist/types/shared/types/layout-constraint.types.d.ts +1 -0
- package/dist/types/shared/types/ui-config.types.d.ts +157 -12
- package/next.config.js +106 -13
- package/package.json +28 -2
- package/core/client/host-bridge/index.ts +0 -27
- package/core/client/parser/yaml-loader.ts +0 -36
- package/core/shared/manifest/manifest-contract.ts +0 -12
- package/dist/types/client/host-bridge/index.d.ts +0 -9
- package/dist/types/client/parser/yaml-loader.d.ts +0 -21
- package/dist/types/shared/manifest/manifest-contract.d.ts +0 -4
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { SomaOouiError } from '../diagnostics';
|
|
2
|
+
import type { SomaOouiIssue } from '../diagnostics';
|
|
3
|
+
import type { SomaSource } from '../trace/source.types';
|
|
4
|
+
/**
|
|
5
|
+
* 声明位置。**已不再是独立定义**:它就是横切层的 `SomaSource`。
|
|
6
|
+
*
|
|
7
|
+
* 别名保留而不是全仓改名,是因为改名会波及 `registry.ts` 十余处而收益为零——
|
|
8
|
+
* 收敛要解决的是"两份结构各自漂开",别名之后物理上只剩一份结构,漂不了。
|
|
9
|
+
* 新代码请直接用 `SomaSource`。
|
|
10
|
+
*
|
|
11
|
+
* 为什么真源在 `trace/` 而不是 `semantic/`:管线是
|
|
12
|
+
* semantic → intent → composition → spatial → artifact,spatial 回头 import semantic
|
|
13
|
+
* 隔了两层,`verify-ooui-dep-graph` 判 `SKIP-BACK` 当场红;而 trace 是横切,
|
|
14
|
+
* 任意管线层都可以 import。详见 `../trace/source.types.ts` 的头注释。
|
|
15
|
+
*/
|
|
16
|
+
export type SomaSpatialSource = SomaSource;
|
|
17
|
+
export type { SomaSource };
|
|
18
|
+
/**
|
|
19
|
+
* 令牌:一个具名的空间值,永远指向一个 `--soma-*` 变量。
|
|
20
|
+
*
|
|
21
|
+
* 表里只放**变量名**,不放数值——数值归主题引擎。这条是"颜色/尺寸只能来自令牌"
|
|
22
|
+
* 在空间层的兑现方式:词表物理上没有地方写 `16px`。
|
|
23
|
+
*/
|
|
24
|
+
export interface SomaSpatialToken {
|
|
25
|
+
/** CSS 自定义属性名,必须以 `--soma-` 开头 */
|
|
26
|
+
varName: string;
|
|
27
|
+
/**
|
|
28
|
+
* 兜底值,发射成 `var(--soma-space-4, 1rem)`。
|
|
29
|
+
*
|
|
30
|
+
* 只允许长度/数值字面量(注册期校验):兜底是给"令牌还没定义"留的余量,
|
|
31
|
+
* 不是给魔数开的后门,更不是给颜色开的后门。
|
|
32
|
+
*/
|
|
33
|
+
fallback?: string;
|
|
34
|
+
src?: SomaSpatialSource;
|
|
35
|
+
}
|
|
36
|
+
/** 解析后交给 `emit` 的值:要么是令牌,要么是 utility 闭集里的关键字 */
|
|
37
|
+
export type SomaSpatialValue = {
|
|
38
|
+
kind: 'token';
|
|
39
|
+
token: SomaSpatialToken;
|
|
40
|
+
/** 候选串里的值段,如 `soma-pad-4` 的 `4` */
|
|
41
|
+
key: string;
|
|
42
|
+
/** 可直接写进 CSS 的值,如 `var(--soma-space-4)` */
|
|
43
|
+
css: string;
|
|
44
|
+
} | {
|
|
45
|
+
kind: 'keyword';
|
|
46
|
+
/** 候选串里的值段,如 `soma-cols-3` 的 `3` */
|
|
47
|
+
key: string;
|
|
48
|
+
/** 可直接写进 CSS 的值,与 key 同源但可由词表映射(如 `autofit` → `auto-fit`) */
|
|
49
|
+
css: string;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* 原子类词条:一个 root 就是一族类名(`pad` → `soma-pad-0` … `soma-pad-10`)。
|
|
53
|
+
*
|
|
54
|
+
* 取值来源二选一,注册期强制:
|
|
55
|
+
* - `namespace`:值查令牌表,`namespace + '-' + 值段` 拼出变量名;
|
|
56
|
+
* - `keywords` :值查本词条自带的**闭合关键字集**。
|
|
57
|
+
* 两个都给或都不给都是拒收——"值从哪来"必须只有一个答案。
|
|
58
|
+
*/
|
|
59
|
+
export interface SomaUtility {
|
|
60
|
+
/** 类名里 `soma-` 之后、值段之前的部分,如 `pad` / `gap` / `grid-cols` */
|
|
61
|
+
root: string;
|
|
62
|
+
/** 令牌命名空间,如 `--soma-space`。与 keywords 二选一 */
|
|
63
|
+
namespace?: string;
|
|
64
|
+
/**
|
|
65
|
+
* 闭合关键字集,如 `['1','2','3','4','6','12']` 或 `['block','inline']`。
|
|
66
|
+
* 与 namespace 二选一。**这就是"任意值写不出来"的地方**——不在表里就是错。
|
|
67
|
+
*/
|
|
68
|
+
keywords?: readonly string[];
|
|
69
|
+
/** 关键字 → CSS 值的映射(可选)。用于 `autofit` → `auto-fit` 这类不能进类名的写法 */
|
|
70
|
+
keywordCss?: Readonly<Record<string, string>>;
|
|
71
|
+
/** 值 → CSS 声明。返回 [属性, 值] 数组,允许一个类发多条声明 */
|
|
72
|
+
emit(value: SomaSpatialValue): Array<[property: string, value: string]>;
|
|
73
|
+
/**
|
|
74
|
+
* 级联序:产物按它排序,**不靠书写顺序**。
|
|
75
|
+
*
|
|
76
|
+
* 靠书写顺序的层叠是另一个静默失败:两条规则谁在后面谁赢,而"后面"取决于
|
|
77
|
+
* 候选串的收集顺序,收集顺序又取决于组件树遍历顺序——改一句无关的模板就可能
|
|
78
|
+
* 翻转视觉结果,且没有任何测试会红。
|
|
79
|
+
*/
|
|
80
|
+
order: number;
|
|
81
|
+
src?: SomaSpatialSource;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* 变体:目前**只有容器查询**,没有视口断点。
|
|
85
|
+
*
|
|
86
|
+
* 视口断点在这套体系里是被明确拒绝的(见 `build/layout/css-emitter.ts` 的论证):
|
|
87
|
+
* 一个组件该多宽取决于它所在容器有多宽,而不是窗口有多宽;同一个组件放进抽屉里
|
|
88
|
+
* 和放在主区里,视口相同而可用宽差三倍,用视口断点写的布局在其中一侧必然错,
|
|
89
|
+
* 错法还是"在某些页面上看着怪"这种没人会报的形态。
|
|
90
|
+
*
|
|
91
|
+
* `minRem` 必须来自 `shared/container-breakpoints` 唯一真源(注册期校验)。
|
|
92
|
+
*/
|
|
93
|
+
export interface SomaVariant {
|
|
94
|
+
/** 变体名,写在候选串的 `@` 之后,如 `cqLg` */
|
|
95
|
+
name: string;
|
|
96
|
+
/** 生效下限(rem)。唯一真源,产物排序也按它 */
|
|
97
|
+
minRem: number;
|
|
98
|
+
/** 把一条完整的 CSS 规则包进 `@container (min-width: …)` */
|
|
99
|
+
wrap(css: string): string;
|
|
100
|
+
src?: SomaSpatialSource;
|
|
101
|
+
}
|
|
102
|
+
/** 错误分层。**已不再是独立定义**:它是 `SomaOouiErrorLayer`(架构 §20.1)里本层用到的两个取值 */
|
|
103
|
+
export type SomaSpatialErrorLayer = 'assembly' | 'spatial';
|
|
104
|
+
/**
|
|
105
|
+
* 空间层错误:装配期(词表)与编译期(候选串)共用。
|
|
106
|
+
*
|
|
107
|
+
* **已收敛为横切层 `SomaOouiError` 的窄化子类**(架构 §20.1)。
|
|
108
|
+
* 此前它与构件层的 `SomaCompositionError` 各自复写了一遍逐字相同的 message 拼装;
|
|
109
|
+
* 两份拼装不会一起坏,只会一份一份地漂,而漂开时两层错误的抬头长得不一样,
|
|
110
|
+
* 按行首切段的下游(soma-ai 自修复提示词)切出来的仍然是合法文本,没有断言会红。
|
|
111
|
+
*
|
|
112
|
+
* 子类只保留两件事:`name`(既有的 `instanceof` 与错误名断言按它读)
|
|
113
|
+
* 与窄化的 `layer`(本层只可能是这两个值,宽成六层等于让类型不再拦错值)。
|
|
114
|
+
*
|
|
115
|
+
* `code` 是**公开契约**(架构 §20.2,全量登记在 `../diagnostics/codes.ts`),
|
|
116
|
+
* 闸门与外部文档按它匹配,不随重构改名。
|
|
117
|
+
* `remedy` 是硬要求:错误必须回答"我该改哪一行",不是"发生了什么"。
|
|
118
|
+
*/
|
|
119
|
+
export declare class SomaSpatialError extends SomaOouiError {
|
|
120
|
+
readonly layer: SomaSpatialErrorLayer;
|
|
121
|
+
constructor(input: {
|
|
122
|
+
layer: SomaSpatialErrorLayer;
|
|
123
|
+
code: string;
|
|
124
|
+
/** 现状:发生了什么、涉及谁 */
|
|
125
|
+
situation: string;
|
|
126
|
+
/** 问题:为什么这不能放行 */
|
|
127
|
+
problem: string;
|
|
128
|
+
/** 建议:能直接抄的修法,多条用换行分隔 */
|
|
129
|
+
remedy: string;
|
|
130
|
+
src?: SomaSpatialSource;
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* 非抛出形态的问题记录:闸门与批量校验用。
|
|
135
|
+
*
|
|
136
|
+
* 照 `verifyTypeTable` 的先例——返回 `issues[]` 而不是抛,让调用方决定措辞与位置。
|
|
137
|
+
* 纯数据,可 `yaml.dump`。
|
|
138
|
+
*
|
|
139
|
+
* **已不再是独立形状**:它就是横切层的 `SomaOouiIssue`,候选串落在 `path` 上。
|
|
140
|
+
* 收敛前它是 `{candidate, code, message, remedy}`——`message` 把"现状/问题/建议"
|
|
141
|
+
* 三段拍扁成一个字符串,于是闸门想单取"现状"或想只把 `remedy` 喂给 soma-ai 自修复时,
|
|
142
|
+
* 唯一能做的是正则切字符串;而正则一旦因为换行改动而切错位,
|
|
143
|
+
* **切出来的仍然是一段合法文本**,没有任何断言会红。
|
|
144
|
+
* 三段分开存放之后,取哪一段是字段访问,不是字符串解析。
|
|
145
|
+
*/
|
|
146
|
+
export type SomaSpatialIssue = SomaOouiIssue;
|
|
147
|
+
/** 一条发射结果。**纯数据**:无函数、无 Map/Set、无循环引用,可直接 `yaml.dump` */
|
|
148
|
+
export interface SomaEmittedUtility {
|
|
149
|
+
/** 写进 HTML `class` 属性的原样类名,如 `soma-cols-3@cqLg` */
|
|
150
|
+
className: string;
|
|
151
|
+
/** CSS 选择器(`@` 已转义),如 `.soma-cols-3\@cqLg` */
|
|
152
|
+
selector: string;
|
|
153
|
+
root: string;
|
|
154
|
+
/** 值段,如 `4` / `3` / `block` */
|
|
155
|
+
value: string;
|
|
156
|
+
/** 变体名;无变体为 null(不是 undefined——undefined 在 yaml.dump 后会消失) */
|
|
157
|
+
variant: string | null;
|
|
158
|
+
/** 变体生效下限(rem);无变体为 null */
|
|
159
|
+
variantMinRem: number | null;
|
|
160
|
+
/** 级联序,来自 utility.order */
|
|
161
|
+
order: number;
|
|
162
|
+
/** 发射出的声明,[属性, 值] 对 */
|
|
163
|
+
declarations: Array<[property: string, value: string]>;
|
|
164
|
+
/** 完整规则文本(含 `@container` 包裹),不含尾换行 */
|
|
165
|
+
css: string;
|
|
166
|
+
/** 本条用到的 `--soma-*` 变量名,升序去重 */
|
|
167
|
+
tokens: string[];
|
|
168
|
+
/** 提供本 utility 的词表名 */
|
|
169
|
+
from: string;
|
|
170
|
+
}
|
|
171
|
+
/** 一批候选的合成产物。**纯数据**,同输入必然逐字节相同 */
|
|
172
|
+
export interface SomaUtilityStylesheet {
|
|
173
|
+
/** 全部规则拼成的样式表,规则间以空行分隔,不含尾换行 */
|
|
174
|
+
css: string;
|
|
175
|
+
/** 按级联序排好的规则 */
|
|
176
|
+
rules: SomaEmittedUtility[];
|
|
177
|
+
/** 出现的类名,升序去重 —— class 存在性闸门的供给侧 */
|
|
178
|
+
classNames: string[];
|
|
179
|
+
/** 用到的 `--soma-*` 变量名,升序去重 —— 令牌存在性闸门的供给侧 */
|
|
180
|
+
tokens: string[];
|
|
181
|
+
/** 类名 → 提供方词表名(架构 §3.5 的 selectorProvenance) */
|
|
182
|
+
provenance: Record<string, string>;
|
|
183
|
+
/** 规模数字:成功输出要带上,防"跑了个空集也叫绿" */
|
|
184
|
+
stats: {
|
|
185
|
+
/** 去重前的候选数 */
|
|
186
|
+
candidates: number;
|
|
187
|
+
/** 去重后的规则数 */
|
|
188
|
+
rules: number;
|
|
189
|
+
tokens: number;
|
|
190
|
+
};
|
|
191
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { formatSomaSource, type SomaSource } from './source.types';
|
|
2
|
+
export { SOMA_TRACE_LAYERS, TRACE_MAX_DEPTH, formatTraceLine, linkTrace, pushTrace, traceAtLayer, traceChain, traceDefects, traceLink, traceRoot, tracesForPath, type SomaTrace, type SomaTraceDefectOptions, type SomaTraceInput, type SomaTraceLayer, type SomaTraceOrigin, } from './trace.types';
|
|
3
|
+
export { renderTrace, renderTraceNotes, renderTraces, type SomaRenderTraceOptions, } from './render';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { SomaTrace } from './trace.types';
|
|
2
|
+
export interface SomaRenderTraceOptions {
|
|
3
|
+
/**
|
|
4
|
+
* 报告首行的结论。缺省取传入 trace 自己的 `conclusion`——
|
|
5
|
+
* 报告是"为什么会有这个结果",第一行就该是那个结果。
|
|
6
|
+
*/
|
|
7
|
+
readonly headline?: string;
|
|
8
|
+
/**
|
|
9
|
+
* 来历台账转成的 trace(语义层 `originTraces(ledger)` 的产物)。
|
|
10
|
+
*
|
|
11
|
+
* **这是报告比原始链更有用的地方**(§5.1 末段):它能区分"你写的"与"系统补的"。
|
|
12
|
+
* 不给则末尾那一段不印——**不假装台账是空的**,也不编造一句"全部为显式声明"。
|
|
13
|
+
*/
|
|
14
|
+
readonly notes?: readonly SomaTrace[];
|
|
15
|
+
/** 每行缩进。缺省两格 */
|
|
16
|
+
readonly indent?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 把一条 trace(连同整条链)渲染成给人读的诊断报告(架构 §5.1)。
|
|
20
|
+
*
|
|
21
|
+
* **它要回答的不是"发生了什么",而是"我该改哪一行"**,所以:
|
|
22
|
+
* · 每一跳都带 `[声明处]`——那就是"哪一行";
|
|
23
|
+
* · `caveat` 用 `⚠` 单独起行——"这次成立"与"永远成立"必须分得开;
|
|
24
|
+
* · 末段逐条点名系统替作者做的决定,并给出**能直接抄的**显式写法。
|
|
25
|
+
*/
|
|
26
|
+
export declare function renderTrace(trace: SomaTrace, options?: SomaRenderTraceOptions): string;
|
|
27
|
+
/**
|
|
28
|
+
* 来历台账那一段(§5.1 末行)。**只印系统替作者做的决定**——
|
|
29
|
+
* `declared` 的那些是他自己写的,全印出来只会把要复核的两行推到第二屏。
|
|
30
|
+
*
|
|
31
|
+
* 每一行都以**能直接抄的显式写法**收尾:报告的判据是"我该改哪一行",
|
|
32
|
+
* 一行说清了来历却不说怎么改,读者只能再去查文档,那就等于没说。
|
|
33
|
+
*/
|
|
34
|
+
export declare function renderTraceNotes(notes: readonly SomaTrace[]): string;
|
|
35
|
+
/**
|
|
36
|
+
* 一批 trace 的报告(每条之间空一行)。
|
|
37
|
+
*
|
|
38
|
+
* `notes` 只在**第一条**后面印一次:来历台账是整次演绎的,不是每条结论各一份,
|
|
39
|
+
* 逐条重复的话报告里同一句"title 是猜的"会出现十几遍,读者会开始跳过它们——
|
|
40
|
+
* 而跳过的那一天,真正该被复核的那一条也一起被跳过了。
|
|
41
|
+
*/
|
|
42
|
+
export declare function renderTraces(traces: readonly SomaTrace[], options?: SomaRenderTraceOptions): string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 声明位置:错误、诊断与 trace 靠它回答"我该改哪一行"。
|
|
3
|
+
*
|
|
4
|
+
* `file` / `path` 必填是刻意的——**错误消息永远要有地方可指**。
|
|
5
|
+
* 合成来源(词表、默认值规则、推断规则)没有真实文件时,用
|
|
6
|
+
* `<vocabulary:soma-ui>` / `<rule:role-alias>` 这样的尖括号形态占位,
|
|
7
|
+
* 而不是留空:留空的那一刻,"这条是谁给的"就永久丢失了。
|
|
8
|
+
*/
|
|
9
|
+
export interface SomaSource {
|
|
10
|
+
/** 声明所在文件(仓库相对路径),或 `<vocabulary:名字>` 这样的合成来源 */
|
|
11
|
+
file: string;
|
|
12
|
+
/** 文件内的定位路径,如 `data.order.roles.title`、utility 的 root、令牌变量名 */
|
|
13
|
+
path: string;
|
|
14
|
+
/** SOMA DSL 块标识(块声明路径才有) */
|
|
15
|
+
blockId?: string;
|
|
16
|
+
/** 块内行号(1 起;拿不到就不给,不要填 0 冒充"没有") */
|
|
17
|
+
line?: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* 把声明位置格成一行人话,供三段式错误的"声明处"那一行用。
|
|
21
|
+
*
|
|
22
|
+
* 格式固定为 `file#path`,块与行号以 `@块` / `:行` 追加——
|
|
23
|
+
* 消费方(闸门、soma-ai 自修复提示词)按这个形状匹配,不要随重构改。
|
|
24
|
+
*/
|
|
25
|
+
export declare function formatSomaSource(src: SomaSource | undefined): string;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import type { SomaSource } from './source.types';
|
|
2
|
+
/**
|
|
3
|
+
* 五层管线的层名。**与 `verify-ooui-dep-graph.mjs` 的 `PIPELINE` 同序**——
|
|
4
|
+
* 下标即上下游次序,`traceDefects` 靠它判"链条有没有倒流"。
|
|
5
|
+
*
|
|
6
|
+
* 分发层 ⑥ 不在其中:它不做推导,只做版本与寻址(架构 §3.6)。
|
|
7
|
+
*/
|
|
8
|
+
export declare const SOMA_TRACE_LAYERS: readonly ["semantic", "intent", "composition", "spatial", "artifact"];
|
|
9
|
+
export type SomaTraceLayer = typeof SOMA_TRACE_LAYERS[number];
|
|
10
|
+
/**
|
|
11
|
+
* 一条结论是怎么来的。**前三个与语义层 `SomaValueOrigin` 逐字对齐**
|
|
12
|
+
* (`declared` / `defaulted` / `inferred`,见 `semantic/origin.types.ts` 的判据),
|
|
13
|
+
* 第四个 `declined` 是"想猜但没敢猜"——它在语义层是另一个类型
|
|
14
|
+
* (`SomaOriginDecline`),到了 trace 这里两者都只是"一条结论",故并成一个轴。
|
|
15
|
+
*
|
|
16
|
+
* **为什么不 import 语义层那个联合类型**:横切不许认识业务层(见文件头)。
|
|
17
|
+
* 抄本漂移由**转换函数**挡:`originTraces()` 把 `SomaValueOrigin` 赋给本类型,
|
|
18
|
+
* 语义层哪天加了第四种来历,那一行当场编译红——
|
|
19
|
+
* 这比"两份联合类型碰巧一样"要硬,后者漂开时没有任何东西会红。
|
|
20
|
+
*/
|
|
21
|
+
export type SomaTraceOrigin = 'declared' | 'defaulted' | 'inferred' | 'declined';
|
|
22
|
+
/** 链条最大深度。超过即判定成环——五层管线的真实链条不会超过它 */
|
|
23
|
+
export declare const TRACE_MAX_DEPTH = 64;
|
|
24
|
+
/**
|
|
25
|
+
* 一条推导记录(架构 §5)。
|
|
26
|
+
*
|
|
27
|
+
* 前五个字段是架构原文的,后四个是落地时补的,各有不可省的理由:
|
|
28
|
+
*
|
|
29
|
+
* · `path` —— 结论**落在哪**(节点路径 / 选择器 / 核心层路径)。
|
|
30
|
+
* 与 `from.path` 是两件事:`from` 指的是**依据**在哪一行,`path` 指的是
|
|
31
|
+
* **结论**作用在哪个东西上。合成一个字段的话,"按 order.yaml 第 12 行
|
|
32
|
+
* 推出了 detail.amount 的形态"这句话就只剩一半,而剩下哪一半取决于谁先写。
|
|
33
|
+
* · `origin` —— 铁律三:写的 / 补的 / 猜的 / 没敢猜,必须可区分。
|
|
34
|
+
* 诊断报告最有用的那一行(§5.1 末行)正是从它来的。
|
|
35
|
+
* · `note` —— 一句人话,报告直接印。conclusion 是"得出了什么",
|
|
36
|
+
* note 是"顺便你该知道的"(如落选候选的原因),两者混写会让报告第一行变成一段。
|
|
37
|
+
* · `caveat` —— **这条结论在什么条件下会变**。铁律四(编译期决策对运行时可变量
|
|
38
|
+
* 取保守边界)的可读形态:§5.1 那行 `⚠ 若窄于 18rem 将降级为 Select` 就是它。
|
|
39
|
+
* 没有这个字段的话,"这次成立"与"永远成立"在报告里长得一模一样。
|
|
40
|
+
*/
|
|
41
|
+
export interface SomaTrace {
|
|
42
|
+
/** 哪一层得出的 */
|
|
43
|
+
readonly layer: SomaTraceLayer;
|
|
44
|
+
/** 得出了什么 */
|
|
45
|
+
readonly conclusion: string;
|
|
46
|
+
/** 依据哪条规则。作者显式声明时写 `declared`(声明本身就是理由) */
|
|
47
|
+
readonly rule: string;
|
|
48
|
+
/** 依据哪句声明。合成来源用 `<rule:…>` / `<vocabulary:…>` 形态,**不留空** */
|
|
49
|
+
readonly from: SomaSource;
|
|
50
|
+
/** 上一层的 trace,构成完整链条 */
|
|
51
|
+
readonly parent?: SomaTrace;
|
|
52
|
+
/** 结论落在哪个路径上(节点路径 / 选择器 / 核心层路径) */
|
|
53
|
+
readonly path?: string;
|
|
54
|
+
/** 写的 / 补的 / 猜的 / 没敢猜 */
|
|
55
|
+
readonly origin?: SomaTraceOrigin;
|
|
56
|
+
/** 一句人话,诊断报告直接印 */
|
|
57
|
+
readonly note?: string;
|
|
58
|
+
/** 这条结论在什么条件下会变(运行时可变量的保守边界) */
|
|
59
|
+
readonly caveat?: string;
|
|
60
|
+
}
|
|
61
|
+
/** `traceLink` 的入参:与 `SomaTrace` 同形,可选字段给 `undefined` 即视为不给 */
|
|
62
|
+
export interface SomaTraceInput {
|
|
63
|
+
readonly layer: SomaTraceLayer;
|
|
64
|
+
readonly conclusion: string;
|
|
65
|
+
readonly rule: string;
|
|
66
|
+
readonly from: SomaSource;
|
|
67
|
+
readonly parent?: SomaTrace | undefined;
|
|
68
|
+
readonly path?: string | undefined;
|
|
69
|
+
readonly origin?: SomaTraceOrigin | undefined;
|
|
70
|
+
readonly note?: string | undefined;
|
|
71
|
+
readonly caveat?: string | undefined;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* 造一条 trace。
|
|
75
|
+
*
|
|
76
|
+
* **可选字段为 `undefined` 时整个键都不写进对象**,而不是留一个 `key: undefined`:
|
|
77
|
+
* 产物要按内容寻址(§19.3 幂等 + §22.2 缓存键),而 `JSON.stringify` 会丢掉
|
|
78
|
+
* `undefined` 值的键——同一份输入若一次带键一次不带,序列化出来的字节相同、
|
|
79
|
+
* 对象却不 `toEqual`,于是"幂等"这件事在断言里与在缓存里得出相反的结论。
|
|
80
|
+
*
|
|
81
|
+
* 本函数**不校验**(不抛):校验是闸门的活,见 `traceDefects`。
|
|
82
|
+
* 构造点当场抛的话,一条写歪的 trace 会把整次编译变成一次崩溃——
|
|
83
|
+
* 而 trace 是解释推导的,不该自己成为新的失败面。
|
|
84
|
+
*/
|
|
85
|
+
export declare function traceLink(input: SomaTraceInput): SomaTrace;
|
|
86
|
+
/**
|
|
87
|
+
* 造一条 trace 并追加进收集数组,返回它本身(好接着当下一条的 `parent`)。
|
|
88
|
+
*
|
|
89
|
+
* 各层的用法就是依赖闸门在 `CROSSCUT-DOWNWARD` 那条建议里写的那一句:
|
|
90
|
+
*
|
|
91
|
+
* import { pushTrace } from '../trace/trace.types';
|
|
92
|
+
* const head = pushTrace(traces, { layer: 'spatial', conclusion: …, rule: …, from: … });
|
|
93
|
+
*/
|
|
94
|
+
export declare function pushTrace(into: SomaTrace[], input: SomaTraceInput): SomaTrace;
|
|
95
|
+
/**
|
|
96
|
+
* 给一条已经造好的 trace 换上 parent(**返回新对象,不改原对象**)。
|
|
97
|
+
*
|
|
98
|
+
* 为什么需要它:跨层接线发生在编排层(`ooui/index.ts`),而各层自己产 trace 时
|
|
99
|
+
* 看不见上一层的实例。层内造链、编排层挂链,是唯一不违反依赖方向的分工。
|
|
100
|
+
* `parent` 为 `undefined` 时原样返回——不制造一个"内容相同但引用不同"的副本,
|
|
101
|
+
* 那会让按引用比较的断言无谓地失手。
|
|
102
|
+
*/
|
|
103
|
+
export declare function linkTrace(trace: SomaTrace, parent: SomaTrace | undefined): SomaTrace;
|
|
104
|
+
/**
|
|
105
|
+
* 整条链,**根在前**(语义层在数组第 0 位)——报告与闸门都按这个方向读。
|
|
106
|
+
*
|
|
107
|
+
* 成环时在环处停下并**只返回已走过的部分**,不抛:一条坏链不该让诊断本身崩掉。
|
|
108
|
+
* 环这件事由 `traceDefects` 点名(它是闸门的判据),不由这里。
|
|
109
|
+
*/
|
|
110
|
+
export declare function traceChain(trace: SomaTrace): SomaTrace[];
|
|
111
|
+
/** 链条的根(最上游的那一条)。`traceChain(trace)[0]` 的快捷式 */
|
|
112
|
+
export declare function traceRoot(trace: SomaTrace): SomaTrace;
|
|
113
|
+
/** 链条里属于某一层的那些条(根在前) */
|
|
114
|
+
export declare function traceAtLayer(trace: SomaTrace, layer: SomaTraceLayer): SomaTrace[];
|
|
115
|
+
/** 一批 trace 里落在某个路径上的那些条。`path` 精确匹配,不做前缀猜测 */
|
|
116
|
+
export declare function tracesForPath(traces: readonly SomaTrace[], path: string): SomaTrace[];
|
|
117
|
+
/** `traceDefects` 的判据开关 */
|
|
118
|
+
export interface SomaTraceDefectOptions {
|
|
119
|
+
/**
|
|
120
|
+
* 链条必须上溯到哪一层。缺省 `'semantic'`——架构 §5 的硬要求是
|
|
121
|
+
* "能从一个 CSS 规则**一路回溯到某句对象声明**",止于中途的链条不算数。
|
|
122
|
+
* 传 `null` 关掉这一条(只在单层单测里用)。
|
|
123
|
+
*/
|
|
124
|
+
readonly requireRoot?: SomaTraceLayer | null;
|
|
125
|
+
/** 这条 trace 是干什么的,进缺陷文案好定位。缺省用 `path` 或 `conclusion` */
|
|
126
|
+
readonly label?: string;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* 一条 trace(连同它的整条链)的缺陷清单。**闸门的判据就是它**,
|
|
130
|
+
* 返回空数组表示这条链可解释。
|
|
131
|
+
*
|
|
132
|
+
* 为什么是"返回清单"而不是"抛异常":§8 那道闸门要一次列全所有不可解释的结论,
|
|
133
|
+
* 抛异常只能报第一条,而作者会因此以为改完这一条就好了,跑一轮再看见第二条。
|
|
134
|
+
* 三段式错误由调用方(闸门)按这份清单拼,本函数只出判据。
|
|
135
|
+
*/
|
|
136
|
+
export declare function traceDefects(trace: SomaTrace | undefined, options?: SomaTraceDefectOptions): string[];
|
|
137
|
+
/**
|
|
138
|
+
* 一条 trace 的单行摘要:`[层] 结论 ← 规则 @ 声明处`。
|
|
139
|
+
*
|
|
140
|
+
* 给闸门失败输出与日志用。**给人读的因果叙述是 `renderTrace`**(§5.1 的报告形态),
|
|
141
|
+
* 两者是按消费方分的两个形态,不要把其中一个改成另一个的样子。
|
|
142
|
+
*/
|
|
143
|
+
export declare function formatTraceLine(trace: SomaTrace): string;
|
|
@@ -9,6 +9,14 @@ export interface SomaHttpClientConfig {
|
|
|
9
9
|
/** Generic headers supplied by the host runtime, such as page context. */
|
|
10
10
|
defaultHeaders?: Record<string, string> | (() => Record<string, string>);
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* 从错误响应正文里提炼一句可读文案。
|
|
14
|
+
*
|
|
15
|
+
* 服务端精心写的结构化错误(`{ ok: false, error: "未知组件:X" }`)才是调用方要的信息,
|
|
16
|
+
* 只留 statusText 等于把它整条丢掉。正文也可能是 HTML 错误页或空串,
|
|
17
|
+
* 因此 JSON 解析必须容错——解析失败只是"没有结构化字段",不该把请求变成另一种崩法。
|
|
18
|
+
*/
|
|
19
|
+
export declare function describeHttpErrorBody(body: string, statusText: string): string;
|
|
12
20
|
/**
|
|
13
21
|
* SomaHttpClient — API 请求封装
|
|
14
22
|
*
|
|
@@ -59,6 +59,15 @@ export interface SomaAiCatalogEntry {
|
|
|
59
59
|
example: string;
|
|
60
60
|
antiPatterns?: string[];
|
|
61
61
|
};
|
|
62
|
+
/**
|
|
63
|
+
* 字段行原文(REQ-012):对象 / 数组 prop 的逐字段形状与示例。
|
|
64
|
+
*
|
|
65
|
+
* 只在契约真写了嵌套形状或示例时出现——否则它与上面的 props 表逐字重复。
|
|
66
|
+
* 目录直接打印它,不另生成第二张字段表:作者写的和读者读到的是同一份东西。
|
|
67
|
+
*/
|
|
68
|
+
spec?: string;
|
|
69
|
+
/** 派生样张(REQ-012):展示页与视觉矩阵喂给组件的那份 props */
|
|
70
|
+
sample?: Record<string, unknown>;
|
|
62
71
|
}
|
|
63
72
|
/**
|
|
64
73
|
* 旧组件契约的迁移归族。
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import type { SomaComponentDefinition } from './component-definition.types';
|
|
2
|
-
export declare class SomaThemeComponentTokenError extends Error {
|
|
3
|
-
constructor(message: string);
|
|
4
|
-
}
|
|
5
2
|
/**
|
|
6
|
-
* 校验主题输入的 `components` / `darkComponents`
|
|
3
|
+
* 校验主题输入的 `components` / `darkComponents` 段是否与契约对得上。返回问题清单(空 = 对得上)。
|
|
7
4
|
* Host 在调 `applyTheme` 之前调用;不给组件表时(纯预览场景)跳过。
|
|
5
|
+
*
|
|
6
|
+
* 返回清单而不是抛(与同文件 `validateContractTokens` 同一形态):主题是 app 级的一份声明,
|
|
7
|
+
* 被该 Host 的全部页面共享,而组件表是「这个 Host + 这一页」的——共享主题里写了 `SomeCard`
|
|
8
|
+
* 的令牌、某一页没注册 `SomeCard` 是正常的。曾经这里抛,被主题注入的兜底接住,
|
|
9
|
+
* 结果是**整份品牌主题一起丢掉**(全页回落默认令牌),代价与「一个组件令牌没人读」完全不成比例。
|
|
10
|
+
* 对不上的令牌写进 :root 也只是没人读,所以调用方的正确处置是「照常换装 + 点名告警」。
|
|
8
11
|
*/
|
|
9
12
|
export declare function validateThemeComponentTokens(input: {
|
|
10
13
|
components?: Record<string, Record<string, string>>;
|
|
11
14
|
darkComponents?: Record<string, Record<string, string>>;
|
|
12
|
-
}, components: Record<string, SomaComponentDefinition>):
|
|
15
|
+
}, components: Record<string, SomaComponentDefinition>): string[];
|
|
13
16
|
/** 契约自检:令牌键名格式 + default 必须引用语义令牌。返回问题清单 */
|
|
14
17
|
export declare function validateContractTokens(definition: SomaComponentDefinition): string[];
|
|
@@ -6,6 +6,16 @@ export interface VerifyPackOptions {
|
|
|
6
6
|
* 换肤与 RTL 的正确性没有任何自动保障。
|
|
7
7
|
*/
|
|
8
8
|
skipStyleChecks?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* 要求 solution 层组件带得出样张(REQ-012,默认开)。
|
|
11
|
+
*
|
|
12
|
+
* 没有示例值的业务组件在展示页上只有一个空壳,在视觉矩阵里量不出真实高度,
|
|
13
|
+
* 在 AI 那边只剩一句 desc——三处都不报错,所以要在这里拦。
|
|
14
|
+
* 存量组件用 samplePending 豁免,清单只减不增。
|
|
15
|
+
*/
|
|
16
|
+
requireSamples?: boolean;
|
|
17
|
+
/** 样张待补清单(组件名):只减不增 */
|
|
18
|
+
samplePending?: readonly string[];
|
|
9
19
|
}
|
|
10
20
|
/**
|
|
11
21
|
* 自检一个组件包,返回中文问题清单(空数组 = 通过)。
|
|
@@ -171,6 +171,14 @@ export declare class SomaDataObjectResolver {
|
|
|
171
171
|
* 把解析器包成注入给自治组件的 data 端口(§8.4)。
|
|
172
172
|
*
|
|
173
173
|
* 为什么是包一层而不是直接注入解析器:解析器还有 resolve / 内部拓扑等大量能力,
|
|
174
|
-
*
|
|
174
|
+
* 组件不该看得见。端口是刻意收窄的六个方法——读态、字典、反应图、窗口、提交、重取。
|
|
175
|
+
*
|
|
176
|
+
* 收的是**取当前解析器的函数**,不是解析器本身:组件实例在 activate 时就把端口抓在手里,
|
|
177
|
+
* 而解析器要到 loadDataObjects 之后才存在、且每次重取都换一个新的——直接收解析器,
|
|
178
|
+
* 组件会永久持有第一个(甚至是 null)。解析器暂缺时每个方法各有一个不抛的兜底:
|
|
179
|
+
* 组件在数据对象就绪之前调它是正常时序,不是错误。
|
|
180
|
+
*
|
|
181
|
+
* soma-bootstrap 注入给组件的就是这一个端口(`createStableDataPort`)——
|
|
182
|
+
* 「只暴露六个方法」的测试守的因此正是实际注入的那一面,而不是一份平行的抄本。
|
|
175
183
|
*/
|
|
176
|
-
export declare function createSomaDataPort(
|
|
184
|
+
export declare function createSomaDataPort(currentResolver: () => SomaDataObjectResolver | null | undefined): SomaDataPort;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { SomaTelemetry } from './SomaTelemetry';
|
|
2
2
|
export declare function setActiveTelemetry(telemetry: SomaTelemetry | null): void;
|
|
3
|
-
export declare function getActiveTelemetry(): SomaTelemetry | null;
|
|
4
3
|
export declare function recordMetric(name: string, value: number, unit?: string): void;
|