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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type CompiledPageDeclaration } from '../../../build/compiler/page-declaration-compiler';
|
|
1
2
|
export interface CompilableDeclaration {
|
|
2
3
|
html: string;
|
|
3
4
|
uiYaml: string;
|
|
@@ -5,8 +6,70 @@ export interface CompilableDeclaration {
|
|
|
5
6
|
styleYaml?: string;
|
|
6
7
|
dataYaml?: string;
|
|
7
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* 声明位置。与架构 §3.1 的 `SomaSource`、空间层的 `SomaSpatialSource` 同构,
|
|
11
|
+
* 另收 `SomaBlockParseError` 的块标识与行号——两种定位方式都要能落地。
|
|
12
|
+
*/
|
|
13
|
+
export interface SomaCompileDiagnosticSource {
|
|
14
|
+
/** 声明所在文件(仓库相对路径),或 `<vocabulary:名字>` 这样的合成来源 */
|
|
15
|
+
file?: string;
|
|
16
|
+
/** 文件内的定位路径,如 `page.state`、utility 的 root */
|
|
17
|
+
path?: string;
|
|
18
|
+
/** SOMA DSL 块标识 */
|
|
19
|
+
blockId?: string;
|
|
20
|
+
/** 块内行号(1 起) */
|
|
21
|
+
line?: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 一条编译诊断。**纯数据**:无函数、无 Map/Set、无循环引用,可直接 JSON/YAML 序列化——
|
|
25
|
+
* 它要跨进程(HTTP 响应)与跨包(soma-ai 自修复提示词)传,带不动活对象。
|
|
26
|
+
*
|
|
27
|
+
* 字段全部可选是刻意的:演绎链抛的 `SomaOouiError`(及其子类)带 `code` / `layer` /
|
|
28
|
+
* `remedy`,`src` 与 `trace` 视抛出点而定;解析器与块编译抛的多是普通 `Error` /
|
|
29
|
+
* `SomaBlockParseError`,只有 `message`(后者另有 `blockId` / `line`)。
|
|
30
|
+
* 同一个结构几种来源都装得下,消费者不必按来源分形状。
|
|
31
|
+
*/
|
|
32
|
+
export interface SomaCompileDiagnostic {
|
|
33
|
+
/** 与 `issues[]` 同序、逐字相同的那句中文(消费者可用它对账) */
|
|
34
|
+
message: string;
|
|
35
|
+
/** 解析器原话,不含 `[编译] …` 前缀 */
|
|
36
|
+
detail: string;
|
|
37
|
+
/** 错误类名,如 `SomaBlockParseError`;拿不到就是 `Error` */
|
|
38
|
+
name: string;
|
|
39
|
+
/** 稳定错误码(架构 §20.2 的公开契约),如 `OOUI-INT-NO-RULE` */
|
|
40
|
+
code?: string;
|
|
41
|
+
/** 出错的层,如 `spatial` / `intent` */
|
|
42
|
+
layer?: string;
|
|
43
|
+
/** 可操作的修法——AI 自修复真正要读的那一段 */
|
|
44
|
+
remedy?: string;
|
|
45
|
+
/** 指回声明位置 */
|
|
46
|
+
src?: SomaCompileDiagnosticSource;
|
|
47
|
+
/** 到失败点为止的推导链;只在原样可序列化时带出 */
|
|
48
|
+
trace?: readonly unknown[];
|
|
49
|
+
}
|
|
50
|
+
/** 干跑编译的完整结果:判定 + 结构化诊断 + 可复用的编译产物 */
|
|
51
|
+
export interface CompileGateResult {
|
|
52
|
+
/** 中文问题清单(空数组 = 通过);格式与 `dryRunCompile()` 逐字一致 */
|
|
53
|
+
issues: string[];
|
|
54
|
+
/** 与 `issues` 同序的结构化诊断;通过时为空数组 */
|
|
55
|
+
diagnostics: SomaCompileDiagnostic[];
|
|
56
|
+
/**
|
|
57
|
+
* 编译产物。**只有 `issues` 为空时才可能非 null**;
|
|
58
|
+
* 调用方复用它之前必须判空(拿不到就拒,不能跳过后续闸门)。
|
|
59
|
+
*/
|
|
60
|
+
compiled: CompiledPageDeclaration | null;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* 干跑编译的完整形态:判定 + 结构化诊断 + 编译产物。
|
|
64
|
+
*
|
|
65
|
+
* `issues` 与 `dryRunCompile()` 逐字一致——两者是同一条判定,不是两套规则。
|
|
66
|
+
*/
|
|
67
|
+
export declare function dryRunCompileWithDiagnostics(declaration: CompilableDeclaration): CompileGateResult;
|
|
8
68
|
/**
|
|
9
69
|
* 干跑编译,返回中文问题清单(空数组 = 通过)。
|
|
10
70
|
* 与安全扫描同款约定:命中即拒,清单点名到具体哪一件、解析器原话是什么。
|
|
71
|
+
*
|
|
72
|
+
* 需要 `code` / `src` / `trace` / `remedy` 或想复用编译产物的调用方,
|
|
73
|
+
* 改用 `dryRunCompileWithDiagnostics()`——本函数是它的字符串投影,判定完全相同。
|
|
11
74
|
*/
|
|
12
75
|
export declare function dryRunCompile(declaration: CompilableDeclaration): string[];
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { SomaComponentContract, SomaContractField } from '../types/component-contract.types';
|
|
2
|
+
export interface SampleGap {
|
|
3
|
+
/** 缺口路径,如 `order.items[].sku_id` */
|
|
4
|
+
path: string;
|
|
5
|
+
reason: string;
|
|
6
|
+
}
|
|
7
|
+
export interface DeriveSampleResult {
|
|
8
|
+
/** 可直接喂给组件的 props */
|
|
9
|
+
props: Record<string, unknown>;
|
|
10
|
+
/** 必填却既无 example 也无 default 的字段 */
|
|
11
|
+
gaps: SampleGap[];
|
|
12
|
+
}
|
|
13
|
+
/** 从契约派生一份样张 props */
|
|
14
|
+
export declare function deriveContractSample(contract: SomaComponentContract): DeriveSampleResult;
|
|
15
|
+
/**
|
|
16
|
+
* 组件目录的交互式预览不能因作者还没补 example 而退化成空态。
|
|
17
|
+
*
|
|
18
|
+
* 这份值仍以契约为唯一输入:example/default/enum 永远优先;只有契约没有给出
|
|
19
|
+
* 内容时,才按字段类型和名称补一个确定的「预览基线」。它只用于开发者橱窗,
|
|
20
|
+
* 不回写目录样张、更不进入业务页面或生成链。
|
|
21
|
+
*/
|
|
22
|
+
export interface DerivePreviewSampleResult {
|
|
23
|
+
props: Record<string, unknown>;
|
|
24
|
+
/** 使用了预览基线的字段路径,供调用方如实标注来源。 */
|
|
25
|
+
synthesized: string[];
|
|
26
|
+
}
|
|
27
|
+
/** 从完整契约派生开发者橱窗的可运行预览基线。 */
|
|
28
|
+
export declare function deriveContractPreviewSample(contract: SomaComponentContract): DerivePreviewSampleResult;
|
|
29
|
+
/** 单个字段的样张值(组件内部或工具按需调用) */
|
|
30
|
+
export declare function deriveFieldSample(field: SomaContractField): unknown;
|
|
31
|
+
/**
|
|
32
|
+
* 这份契约够不够渲染一张有内容的样张。
|
|
33
|
+
*
|
|
34
|
+
* 判据是「至少有一个 prop 写了 example,或有嵌套字段写了 example」——
|
|
35
|
+
* 全靠 default 派生出来的是空态,展示页放上去只有一个空壳。
|
|
36
|
+
*/
|
|
37
|
+
export declare function hasRenderableSample(contract: SomaComponentContract): boolean;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { SomaContractEmit, SomaContractField, SomaContractProp, SomaContractSlot } from '../types/component-contract.types';
|
|
2
|
+
export declare class SomaFieldLinesError extends Error {
|
|
3
|
+
readonly line: number;
|
|
4
|
+
constructor(message: string, line: number);
|
|
5
|
+
}
|
|
6
|
+
/** props 文本块 → 契约 props */
|
|
7
|
+
export declare function parseFieldLines(text: string): Record<string, SomaContractProp>;
|
|
8
|
+
/** emits 文本块 → 契约 emits。事件行是 `名: 描述`,下一级是载荷行 `名: 类型, 描述` */
|
|
9
|
+
export declare function parseEmitLines(text: string): Record<string, SomaContractEmit>;
|
|
10
|
+
/** slots 文本块 → 契约 slots。插槽行是 `名: 描述, 必填`(必填可省) */
|
|
11
|
+
export declare function parseSlotLines(text: string): Record<string, SomaContractSlot>;
|
|
12
|
+
/** 契约 props(或任意字段表)→ 字段行文本块 */
|
|
13
|
+
export declare function renderFieldLines(fields: Record<string, SomaContractField>): string;
|
|
14
|
+
/** TS 组件里写同一段文本:`props: somaFields\`…\`` */
|
|
15
|
+
export declare function somaFields(strings: TemplateStringsArray, ...values: unknown[]): Record<string, SomaContractProp>;
|
|
16
|
+
/** TS 组件里写事件文本块 */
|
|
17
|
+
export declare function somaEmits(strings: TemplateStringsArray, ...values: unknown[]): Record<string, SomaContractEmit>;
|
|
18
|
+
/** TS 组件里写插槽文本块 */
|
|
19
|
+
export declare function somaSlots(strings: TemplateStringsArray, ...values: unknown[]): Record<string, SomaContractSlot>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 容器断点:全体系唯一真源。
|
|
3
|
+
*
|
|
4
|
+
* ── 为什么单独一个模块 ─────────────────────────────────────────────
|
|
5
|
+
* 此前同一组值有**三份**副本:构建期求解器的元组表、soma-ui 的对象表、
|
|
6
|
+
* 视觉矩阵脚本里的硬编码数组。三处靠注释"同源同值"与人工同步维系,
|
|
7
|
+
* 而它们坏起来是**零报错**的——改一处漏一处,表现为构建期求解出的
|
|
8
|
+
* CSS 与组件 CSS 在不同宽度上折断,只有把窗口拖到那一档才看得见。
|
|
9
|
+
*
|
|
10
|
+
* ── 为什么不直接从求解器导出 ───────────────────────────────────────
|
|
11
|
+
* `build/layout/constraint-solver.ts` 带着 `SomaLayoutConstraintError`
|
|
12
|
+
* 与整个求解算法。soma-ui 若 import 它,等于把**构建期求解器拖进客户端
|
|
13
|
+
* 依赖图**,并会撞 `verify:client-boundary` / `verify:client-dep-graph`
|
|
14
|
+
* 的 build-only 规则。
|
|
15
|
+
*
|
|
16
|
+
* 因此本模块是**纯字面量**:不 import 任何东西,也不牵连任何运行时资产,
|
|
17
|
+
* 可以安全地被 soma-ui、生成链与构建期求解器同时消费——与
|
|
18
|
+
* `"./adaptive-vocabulary"` 子路径同一形态。
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* 容器断点八档(rem;16px 根字号下为 320/384/448/576/640/768/896/1024px)。
|
|
22
|
+
*
|
|
23
|
+
* 键序即档序,从窄到宽。`CONTAINER_STEPS` 依赖这个顺序。
|
|
24
|
+
*/
|
|
25
|
+
export declare const CONTAINER_BREAKPOINTS: {
|
|
26
|
+
readonly cqXs: 20;
|
|
27
|
+
readonly cqSm: 24;
|
|
28
|
+
readonly cqMd: 28;
|
|
29
|
+
readonly cqLg: 36;
|
|
30
|
+
readonly cqXl: 40;
|
|
31
|
+
readonly cq2xl: 48;
|
|
32
|
+
readonly cq3xl: 56;
|
|
33
|
+
readonly cq4xl: 64;
|
|
34
|
+
};
|
|
35
|
+
export type ContainerBreakpoint = keyof typeof CONTAINER_BREAKPOINTS;
|
|
36
|
+
/**
|
|
37
|
+
* 元组形态:构建期求解器按档序遍历时用(`solveLayout` 逐档各解一次,
|
|
38
|
+
* `css-emitter` 按 index 取 rem 值发 `@container (min-width: Nrem)`)。
|
|
39
|
+
*
|
|
40
|
+
* **由上表派生,不另写一份**——这正是本模块要消灭的那种双写。
|
|
41
|
+
*/
|
|
42
|
+
export declare const CONTAINER_STEPS: ReadonlyArray<readonly [ContainerBreakpoint, number]>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type SomaDataObjectRelation, type SomaDataObjectRoles } from './types/data-config.types';
|
|
2
|
+
/**
|
|
3
|
+
* 校验 `roles:` 段。返回空数组即合法。
|
|
4
|
+
*
|
|
5
|
+
* `fieldKeys` 是本对象字段字典的键。**字典为空时直接拒收整段**:
|
|
6
|
+
* 角色的值就是字段名,没有字典就没有任何东西能对账,
|
|
7
|
+
* 放行等于把"指错字段"这类错推迟到渲染期,而渲染期它只会表现为一处空白。
|
|
8
|
+
*/
|
|
9
|
+
export declare function validateObjectRoles(raw: unknown, fieldKeys: readonly string[]): string[];
|
|
10
|
+
/** `validateObjectRelations` 的上下文 */
|
|
11
|
+
export interface ObjectRelationsContext {
|
|
12
|
+
/** 本对象字段字典的键(校验 `via`) */
|
|
13
|
+
fieldKeys: readonly string[];
|
|
14
|
+
/**
|
|
15
|
+
* 本次声明里全部已知的对象名(校验 `to`)。
|
|
16
|
+
*
|
|
17
|
+
* 传 `undefined` 表示**调用方拿不到这份名单**(块声明路径就是如此:块内私有对象
|
|
18
|
+
* 的全局身份要等 block-compile 合并之后才成形)。这时跳过 `to` 的存在性检查,
|
|
19
|
+
* 但**仍校验它是不是合法标识符**——放行未知名字与放行乱码是两件事。
|
|
20
|
+
*/
|
|
21
|
+
objectNames?: readonly string[];
|
|
22
|
+
/** 本对象名(`to` 指向自己是合法的:树形自关联) */
|
|
23
|
+
selfName?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 校验 `relations:` 段。返回空数组即合法。
|
|
27
|
+
*/
|
|
28
|
+
export declare function validateObjectRelations(raw: unknown, ctx: ObjectRelationsContext): string[];
|
|
29
|
+
/**
|
|
30
|
+
* 校验字段字典里的 `modifies:` 修饰关系。返回空数组即合法。
|
|
31
|
+
*
|
|
32
|
+
* 三条判据,都拦"能跑但看着不对"的错法:
|
|
33
|
+
* ① 目标必须在同一本字典里——指错则修饰字段并不进被修饰者,自己占一格;
|
|
34
|
+
* ② 不能指自己——自指的语义是"我修饰我",没有可执行含义;
|
|
35
|
+
* ③ 目标自己不能再带 `modifies`——**修饰不可级联**。级联时"谁是被呈现的那个"
|
|
36
|
+
* 没有唯一答案,而这种歧义只会表现为"少显示了一格"。
|
|
37
|
+
*/
|
|
38
|
+
export declare function validateFieldModifies(fields: Readonly<Record<string, {
|
|
39
|
+
modifies?: string;
|
|
40
|
+
}>>): string[];
|
|
41
|
+
/** 供解析器复用的类型别名出口,避免消费方再从两处 import */
|
|
42
|
+
export type { SomaDataObjectRelation, SomaDataObjectRoles };
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OOUI 声明与产物的共享字面量:全体系唯一真源(REQ-014)。
|
|
3
|
+
*
|
|
4
|
+
* ── 为什么单独一个模块 ─────────────────────────────────────────────
|
|
5
|
+
* 这里的每一样东西都被**隔着依赖闸门的几方**同时消费:
|
|
6
|
+
*
|
|
7
|
+
* · 运行时解析器 `client/parser/ui-config-parser.ts`——client 不许 import `core/build`
|
|
8
|
+
* (`verify:client-dep-graph`);
|
|
9
|
+
* · 构建期引擎 `build/ooui/**` 的编排层、页面组合层、空间层与产物层——
|
|
10
|
+
* 层与层之间只许单向看(`verify-ooui-dep-graph`),产物层够不着构件层,
|
|
11
|
+
* 空间层与产物层谁都够不着页面组合层。
|
|
12
|
+
*
|
|
13
|
+
* 此前的结果是同一件事在各处各抄一份,且抄本宽严不一:锚点文法抄成三份
|
|
14
|
+
* (`1list` 过得了页面组合、到产物层才红;`_list` 过得了解析器、到页面组合才红),
|
|
15
|
+
* 演绎请求的键闭集抄成两份(解析器那份收下 `bound_to` / `layout` 却不搬进声明),
|
|
16
|
+
* `'#text'` 在构件层是常量、在产物层是两处字面量。每一份单看都对,
|
|
17
|
+
* 只是报错总落在比写错那一行晚一两层的地方——或者干脆不报。
|
|
18
|
+
*
|
|
19
|
+
* `core/shared/**` 是唯一几方都 import 得到的位置(与 `container-breakpoints.ts` 同一形态):
|
|
20
|
+
* 纯字面量与纯函数,除同在 `core/shared` 的纯字面量闭集(`SOMA_LAYOUT_SIZINGS`)外只 import 类型,
|
|
21
|
+
* 不牵连任何运行时模块。
|
|
22
|
+
*/
|
|
23
|
+
import { type SomaSizing } from './types/layout-constraint.types';
|
|
24
|
+
import type { SomaOouiRequestDeclaration } from './types/ui-config.types';
|
|
25
|
+
/**
|
|
26
|
+
* `ooui:` 的锚点名 = 页面组合的区域名 = 空间 IR 的节点 id。**三处是同一个名字,所以是同一条文法。**
|
|
27
|
+
*
|
|
28
|
+
* 锚点名就是区域名(`compilePageOoui` 拿锚点当区域名),区域名就是 IR 叶子的 id
|
|
29
|
+
* (`solvePageBudget` 原样放进去),产物层再按它派生 `<锚点>-shell` / `<锚点>-root`。
|
|
30
|
+
* 它会原样进 DOM 属性与 CSS 属性选择器:放开引号、括号、空格等于给选择器注入留门,
|
|
31
|
+
* 而注入成功的表现是页面照常渲染。
|
|
32
|
+
*
|
|
33
|
+
* 取「字母或下划线开头」:与运行时解析器一直收的、`layout:` 段锚点键用的是同一条
|
|
34
|
+
* (SOMA 标识符的通行写法);数字开头不收——`data-soma-id="1"` 是合法 HTML,
|
|
35
|
+
* 但读不出它指的是什么。
|
|
36
|
+
*/
|
|
37
|
+
export declare const SOMA_OOUI_ANCHOR_PATTERN: RegExp;
|
|
38
|
+
/**
|
|
39
|
+
* 同一条文法的人话版本。错误消息只引用它,不各写一句——
|
|
40
|
+
* 此前三份消息分别写着「字母开头」「字母或数字开头」,与各自的正则一起漂开。
|
|
41
|
+
*/
|
|
42
|
+
export declare const SOMA_OOUI_ANCHOR_GRAMMAR = "\u5B57\u6BCD\u6216\u4E0B\u5212\u7EBF\u5F00\u5934\uFF0C\u5176\u4F59\u53EF\u542B\u5B57\u6BCD\u3001\u6570\u5B57\u3001- \u4E0E _";
|
|
43
|
+
/**
|
|
44
|
+
* 一条演绎请求允许的键——闭集,写错一个字母必须当场红。
|
|
45
|
+
*
|
|
46
|
+
* 运行时解析器与构建期编译器各校一次形状(前者服务直接喂源 YAML 的路径,
|
|
47
|
+
* 后者是发布主路径),两处用的**是这一份**。顺序即书写顺序,错误消息按它列出可用键。
|
|
48
|
+
*/
|
|
49
|
+
export declare const SOMA_OOUI_REQUEST_KEYS: readonly (keyof SomaOouiRequestDeclaration)[];
|
|
50
|
+
/** 声明里 `layout` 的形状(区域的空间约束逃生门) */
|
|
51
|
+
export type SomaOouiLayoutDeclaration = NonNullable<SomaOouiRequestDeclaration['layout']>;
|
|
52
|
+
/**
|
|
53
|
+
* `layout` 允许的键——**白名单**。
|
|
54
|
+
*
|
|
55
|
+
* 为什么必须是白名单而不是"原样摊进去":区域的约束会被摊进空间 IR 的叶子节点,
|
|
56
|
+
* 而叶子节点上还有 `id` / `kind` / `anchor` / `classes` 这些**结构键**。
|
|
57
|
+
* 放行一个 `layout: { id: x }`,叶子就被改了名,求解结果里再也找不到这个区域——
|
|
58
|
+
* 此前那里读成 0rem,于是这个区域静默降到最窄的候选,页面照常渲染。
|
|
59
|
+
*/
|
|
60
|
+
export declare const SOMA_OOUI_LAYOUT_KEYS: readonly (keyof SomaOouiLayoutDeclaration)[];
|
|
61
|
+
/**
|
|
62
|
+
* 尺寸意图三档(`fixed` 就这么宽 / `hug` 内容多宽我多宽 / `fill` 剩下的给我)。顺序即文档书写序。
|
|
63
|
+
*
|
|
64
|
+
* 此前没有任何一层核 `ooui:` 区域的 sizing——解析器、编译器、页面组合层都只核"是不是字符串",
|
|
65
|
+
* 空间层求解器拿到什么就摊进约束。写成 `sizing: fil` 的区域既不是 fixed 也不是 fill,
|
|
66
|
+
* 求解器按"从 min 起步、不参与分余量"处理,于是它**静默缩到下界**(没写 min 就是 0rem),
|
|
67
|
+
* 一路喂进构件选型——这一块降到最窄的候选,页面照常渲染。
|
|
68
|
+
*
|
|
69
|
+
* 三方都要用它:运行时解析器(client 不许 import `core/build`)、编译器与页面组合层
|
|
70
|
+
* (声明期就指着写错的那一行报)、空间层求解器(IR 树的最后一道)。
|
|
71
|
+
* **它不是一份抄本,是 `SOMA_LAYOUT_SIZINGS` 本身**(`shared/types/layout-constraint.types.ts`,
|
|
72
|
+
* 在那里以 `SomaSizing` 做 `satisfies` 对账):`layout:` 段的解析器认的也是那一份。
|
|
73
|
+
* 此前这里自持一份、解析器又自持一份,两份逐字相同,漂开的那天没有断言会红。
|
|
74
|
+
*/
|
|
75
|
+
export declare const SOMA_OOUI_SIZINGS: readonly SomaSizing[];
|
|
76
|
+
/** 值是不是三档之一。非字符串一律不是——`sizing: 1` 不该被 `String()` 顶成 `'1'` 再比 */
|
|
77
|
+
export declare function isOouiSizing(value: unknown): value is SomaSizing;
|
|
78
|
+
/** `layout` 里第一处不合形状的键:闭集之外的键、值的原始类型不对,或 sizing 不在三档里 */
|
|
79
|
+
export interface SomaOouiLayoutProblem {
|
|
80
|
+
readonly key: string;
|
|
81
|
+
readonly kind: 'unknown-key' | 'value-type' | 'sizing-unknown';
|
|
82
|
+
/** `value-type` 时:这个键要的原始类型 */
|
|
83
|
+
readonly expected?: 'string' | 'number';
|
|
84
|
+
}
|
|
85
|
+
/** 映射(非 null、非数组的对象)。YAML 里 `~` / 列表 / 标量都不是 */
|
|
86
|
+
export declare function isOouiMap(value: unknown): value is Record<string, unknown>;
|
|
87
|
+
/** 非空白字符串:`object` / `verb` / `through` / `form` 与 `bound_to` 两项的形状判据 */
|
|
88
|
+
export declare function isOouiText(value: unknown): value is string;
|
|
89
|
+
/**
|
|
90
|
+
* `focus`:非空、且每一项都是非空白字段名。
|
|
91
|
+
*
|
|
92
|
+
* 空数组单独拦:`focus: []` 读起来像"不限",实际演绎出一个没有字段的界面——
|
|
93
|
+
* 框架在、标题在、空白在,是最像成功的失败。"全部字段"的写法是省略 focus。
|
|
94
|
+
*/
|
|
95
|
+
export declare function isOouiFocus(value: unknown): value is string[];
|
|
96
|
+
/** 声明里 `bound_to` 的形状(区域间联动的来源) */
|
|
97
|
+
export type SomaOouiBindingDeclaration = NonNullable<SomaOouiRequestDeclaration['bound_to']>;
|
|
98
|
+
/** `bound_to` 允许的键。解析器与编译器的"未知键"错误都按它列出可用键 */
|
|
99
|
+
export declare const SOMA_OOUI_BINDING_KEYS: readonly (keyof SomaOouiBindingDeclaration)[];
|
|
100
|
+
/**
|
|
101
|
+
* `bound_to` 里第一个闭集之外的键(按书写序);没有则 undefined。
|
|
102
|
+
*
|
|
103
|
+
* 收 `object` 而不是映射类型:页面组合层拿到的是已经带类型的 `SomaRegionBinding`,
|
|
104
|
+
* 那里多出来的键同样要报,而接口类型不能直接当 `Record<string, unknown>` 用。
|
|
105
|
+
*/
|
|
106
|
+
export declare function findOouiBindingUnknownKey(binding: object): string | undefined;
|
|
107
|
+
/**
|
|
108
|
+
* `bound_to`:恰好 `{ region, as }` 两项、且都是非空白字符串的映射。
|
|
109
|
+
*
|
|
110
|
+
* 多一个键也不算合形状——判据若只看两项齐不齐,多出来的键就会一路被当成"合法、只是没用上"。
|
|
111
|
+
* 调用方要报**哪个键**多了时先调 `findOouiBindingUnknownKey`(与 `findOouiLayoutProblem` 同一形态)。
|
|
112
|
+
*/
|
|
113
|
+
export declare function isOouiBinding(value: unknown): value is SomaOouiBindingDeclaration;
|
|
114
|
+
/**
|
|
115
|
+
* 找 `layout` 里第一处不合形状的键。合形状返回 undefined。
|
|
116
|
+
*
|
|
117
|
+
* 核三件:**键**在白名单里、**值的原始类型**对、**sizing 在三档里**。
|
|
118
|
+
* priority 的四档与长度单位仍由空间层的求解器核(长度要拿到容器宽才折算得出来)。
|
|
119
|
+
*
|
|
120
|
+
* sizing 的闭集此前刻意不在这里核("闭集归空间层"),结果是**哪一层都没核**:
|
|
121
|
+
* 空间层求解器也只是把它摊进约束。现在它是 `SOMA_OOUI_SIZINGS` 这一份——类型的运行时镜像;
|
|
122
|
+
* 解析器、编译器、页面组合层都经本函数判,空间层求解器按同一份常量兜 IR 树的最后一道。
|
|
123
|
+
*/
|
|
124
|
+
export declare function findOouiLayoutProblem(layout: Readonly<Record<string, unknown>>): SomaOouiLayoutProblem | undefined;
|
|
125
|
+
/** `layout` 合形状:映射、键全在白名单里、值的原始类型对、sizing 在三档里 */
|
|
126
|
+
export declare function isOouiLayout(value: unknown): value is SomaOouiLayoutDeclaration;
|
|
127
|
+
/**
|
|
128
|
+
* 纯文本节点的组件名占位:**不是组件**(`SomaOouiNode.component` 的一个取值)。
|
|
129
|
+
*
|
|
130
|
+
* 构件层选型时产出它,产物层发射时按它分支(落成 `<span>`、不写 `data-soma-component`)。
|
|
131
|
+
* 两层之间隔着依赖闸门(产物层回看构件层判 `SKIP-BACK`),所以常量住在两边都够得着的这里。
|
|
132
|
+
* 各写一个 `'#text'` 字面量的话,改名那天只改了一边,另一边的判断静默失配——
|
|
133
|
+
* 纯文本字段被当成一个叫 `#text` 的组件去挂载,查不到契约就跳过,那一格永远空着。
|
|
134
|
+
*/
|
|
135
|
+
export declare const SOMA_TEXT_NODE = "#text";
|
|
@@ -8,15 +8,33 @@ export type SomaComponentLayer = 'atom' | 'composite' | 'solution' | 'template';
|
|
|
8
8
|
*/
|
|
9
9
|
export type SomaGeometryFamily = 'control' | 'surface' | 'message' | 'data' | 'overlay' | 'layout' | 'display';
|
|
10
10
|
export type SomaContractPropType = 'number' | 'string' | 'boolean' | 'enum' | 'object' | 'array';
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* 字段(REQ-012)。
|
|
13
|
+
*
|
|
14
|
+
* prop、对象里的字段、数组元素、事件载荷是同一种东西,所以只有这一个形状,递归到底:
|
|
15
|
+
* `type: object` 用 `fields` 继续描述,`type: array` 用 `items` 描述元素。
|
|
16
|
+
*
|
|
17
|
+
* 为什么要 `example` 而不是靠 `default`:规则 C4 要求可选 prop 有默认值,而默认值按
|
|
18
|
+
* C4a 必须是空串 / 空数组这类浅结构——拿它渲染出来的永远是空态。展示页、视觉矩阵与
|
|
19
|
+
* AI 需要的是「这个字段真实长什么样」,那是另一个值,必须另有一处写。
|
|
20
|
+
*/
|
|
21
|
+
export interface SomaContractField {
|
|
12
22
|
type: SomaContractPropType;
|
|
23
|
+
desc?: string;
|
|
13
24
|
required?: boolean;
|
|
14
25
|
/** 非 required 的 prop 必须有默认值(契约规则 C4:零 props 可渲染) */
|
|
15
26
|
default?: unknown;
|
|
16
|
-
|
|
27
|
+
/** 示例值(REQ-012):样张与展示页的数据来源;不参与运行时,只被派生与目录消费 */
|
|
28
|
+
example?: unknown;
|
|
17
29
|
/** type === 'enum' 时的取值集合 */
|
|
18
30
|
values?: (string | number)[];
|
|
19
|
-
/**
|
|
31
|
+
/** type === 'object' 时的子字段(REQ-012) */
|
|
32
|
+
fields?: Record<string, SomaContractField>;
|
|
33
|
+
/** type === 'array' 时的元素形状(REQ-012) */
|
|
34
|
+
items?: SomaContractField;
|
|
35
|
+
}
|
|
36
|
+
export interface SomaContractProp extends SomaContractField {
|
|
37
|
+
/** 绑定模式:oneway(默认)| model(双向,一个组件最多一个)。只在 prop 一层有意义 */
|
|
20
38
|
mode?: 'oneway' | 'model';
|
|
21
39
|
}
|
|
22
40
|
/**
|
|
@@ -29,9 +47,7 @@ export interface SomaContractProp {
|
|
|
29
47
|
* 返回相对 default 的首个违规路径;`null` 表示最外层浅拷贝已足够隔离。
|
|
30
48
|
*/
|
|
31
49
|
export declare function findNestedMutableContractDefault(value: unknown): string | null;
|
|
32
|
-
export interface SomaContractEmitPayloadField {
|
|
33
|
-
type: SomaContractPropType;
|
|
34
|
-
desc?: string;
|
|
50
|
+
export interface SomaContractEmitPayloadField extends SomaContractField {
|
|
35
51
|
}
|
|
36
52
|
export interface SomaContractEmit {
|
|
37
53
|
payload?: Record<string, SomaContractEmitPayloadField>;
|
|
@@ -100,12 +116,13 @@ export interface SomaComponentContract {
|
|
|
100
116
|
* 依赖的其它组件(REQ-010 F-46):PascalCase 契约名数组。
|
|
101
117
|
*
|
|
102
118
|
* 两件事靠它:
|
|
103
|
-
* ①
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
119
|
+
* ① **eject 说得出副本还需要谁**——`soma component eject` 一个 TreeSelect 时列出它还要 Tree
|
|
120
|
+
* (仍从 soma-ui 取,要在宿主注册表里可解析),而不是等页面渲染出一堆没样式的节点才发现
|
|
121
|
+
* (这条曾真实发生过:`COMPONENT_CSS_DEPS` 少写一条 `TreeSelect: ['Tree']`,
|
|
122
|
+
* 页面上是无样式的折叠箭头);
|
|
123
|
+
* ② **与 CSS 依赖表对账**——`build/component/component-graph.ts` 按它建图,
|
|
124
|
+
* soma-ui 的 `component-css-deps` 测试拿图与 `COMPONENT_CSS_DEPS` 逐项对账,
|
|
125
|
+
* 漏登记的那一条当场红。
|
|
109
126
|
*
|
|
110
127
|
* 只登记**契约级**依赖(模板里真的嵌了那个组件、或 CSS 分片依赖它),
|
|
111
128
|
* 不登记共享资产(`shared/*` 由构建图自然带上,写进来只会重复一份且会漂)。
|
|
@@ -77,6 +77,82 @@ export interface SomaDataFieldConfig {
|
|
|
77
77
|
* 而"写了没反应"是最难查的一类。
|
|
78
78
|
*/
|
|
79
79
|
calc?: string;
|
|
80
|
+
/**
|
|
81
|
+
* 修饰关系(REQ-014 §15.3 原型实测补入):本字段是**另一个字段的修饰**,
|
|
82
|
+
* 不独立呈现。典型是 `status_tone` 修饰 `status_text`——语气、单位、币种、
|
|
83
|
+
* 图标、趋势方向都属此类。
|
|
84
|
+
*
|
|
85
|
+
* 不声明的后果是静默的:修饰字段会被当成一个普通只读字段各占一格,
|
|
86
|
+
* 页面上出现一排空的 `status_tone: —` `priority_tone: —`。它不报错、
|
|
87
|
+
* 不影响功能,只是"这页看着有点乱"——而这句话没人会当成 bug 报上来。
|
|
88
|
+
* 原型跑出来第一眼看到的就是这个(§15.3 缺口 1)。
|
|
89
|
+
*
|
|
90
|
+
* 约束(解析期强制):目标必须是同一本字典里的**另一个**字段,且目标自己
|
|
91
|
+
* 不能再带 `modifies`——修饰不可级联。级联的话"谁是被呈现的那个"就没有唯一答案,
|
|
92
|
+
* 而这种歧义在渲染期只会表现为"少显示了一格"。
|
|
93
|
+
*/
|
|
94
|
+
modifies?: string;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* 对象级角色(REQ-014 §3.1.2):哪个字段承担什么**语义位**。
|
|
98
|
+
*
|
|
99
|
+
* 它要替换掉的是"靠字段名猜"。今天 `pickField` 一类的做法用别名表匹配
|
|
100
|
+
* (`title` / `name` / `label` …)去猜标题字段,猜错了表现为"标题栏显示订单备注",
|
|
101
|
+
* 而这条猜测既不出现在声明里也不出现在日志里,**没有任何地方可查**。
|
|
102
|
+
* 声明了 `roles` 之后,"谁是标题"是作者写的事实,不是系统的运气。
|
|
103
|
+
*
|
|
104
|
+
* 全部可选、值都是**本对象字段字典里的字段名**(解析期对账,指错当场红)。
|
|
105
|
+
*/
|
|
106
|
+
export interface SomaDataObjectRoles {
|
|
107
|
+
/** 身份:这一行/这个对象的唯一键 */
|
|
108
|
+
id?: string;
|
|
109
|
+
/** 展示这个对象时拿什么当标题 */
|
|
110
|
+
title?: string;
|
|
111
|
+
/** 副标题 */
|
|
112
|
+
subtitle?: string;
|
|
113
|
+
/** 生命周期状态,驱动状态位与语气 */
|
|
114
|
+
status?: string;
|
|
115
|
+
/** 时间轴默认依据 */
|
|
116
|
+
timestamp?: string;
|
|
117
|
+
/** 金额,决定右对齐与货币格式 */
|
|
118
|
+
amount?: string;
|
|
119
|
+
/**
|
|
120
|
+
* 对比基准(§27.3 盲测补入):指向标记基准项的字段(如 `is_control`)。
|
|
121
|
+
*
|
|
122
|
+
* 缺它则对比无锚点——"+12%" 不知道是相对谁。而"相对谁"错了的界面
|
|
123
|
+
* 看起来完全正常:数字在、箭头在、颜色也在,只是符号反了。
|
|
124
|
+
*/
|
|
125
|
+
baseline?: string;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* 全部合法角色名(封闭集),供两条书写路径的解析器共用。
|
|
129
|
+
*
|
|
130
|
+
* **不要在解析器里再手抄一份**——字段类型表已经因为手抄漂成过四份
|
|
131
|
+
* (见本文件 `SomaDataFieldType` 的头注释),角色表没有理由重走一遍。
|
|
132
|
+
*/
|
|
133
|
+
export declare const SOMA_DATA_OBJECT_ROLES: readonly (keyof SomaDataObjectRoles)[];
|
|
134
|
+
/** 关系基数:一对一 / 一对多。封闭集 */
|
|
135
|
+
export type SomaDataRelationCardinality = 'one' | 'many';
|
|
136
|
+
/** 全部合法基数(封闭集),解析器共用 */
|
|
137
|
+
export declare const SOMA_DATA_RELATION_CARDINALITIES: readonly SomaDataRelationCardinality[];
|
|
138
|
+
/**
|
|
139
|
+
* 对象间关系(REQ-014 §3.1.2)。
|
|
140
|
+
*
|
|
141
|
+
* 为什么必须显式声明:`compare` 与 `navigate` 两个动词的作用对象**往往不是主对象**
|
|
142
|
+
* (§27.2 盲测)——要比的是"一个实验内部的多个变体",要导航的必然是关系的另一端。
|
|
143
|
+
* 没有关系声明,这两个动词(占八动词封闭集的 25%)表达不出来;
|
|
144
|
+
* 靠字段名后缀猜关系(`xxx_id` → `xxx`)猜错时表现为"点进去是另一个对象的详情",
|
|
145
|
+
* 而页面本身渲染得好好的。
|
|
146
|
+
*/
|
|
147
|
+
export interface SomaDataObjectRelation {
|
|
148
|
+
/** 关系名(对象内唯一),`through` 按它引用 */
|
|
149
|
+
name: string;
|
|
150
|
+
/** 目标对象名(必须是同一份声明里已声明的数据对象) */
|
|
151
|
+
to: string;
|
|
152
|
+
/** 基数 */
|
|
153
|
+
cardinality: SomaDataRelationCardinality;
|
|
154
|
+
/** 本对象上的外键字段(可选;给了就必须在本对象字典里) */
|
|
155
|
+
via?: string;
|
|
80
156
|
}
|
|
81
157
|
/**
|
|
82
158
|
* 单个取数来源:一个后端接口 + 参数 + 聚合位置。
|
|
@@ -144,6 +220,16 @@ export interface SomaDataObjectConfig {
|
|
|
144
220
|
fields?: Record<string, SomaDataFieldConfig>;
|
|
145
221
|
/** mock 样本:SOMA_MOCK_ENABLED / 接口失败兜底 / 无接口预览 */
|
|
146
222
|
mock?: unknown;
|
|
223
|
+
/**
|
|
224
|
+
* 对象级角色(REQ-014 §3.1.2):哪个字段承担什么语义位。
|
|
225
|
+
* 声明它等于把"谁是标题/状态/金额/基准"从系统的猜测变成作者的事实。
|
|
226
|
+
*/
|
|
227
|
+
roles?: SomaDataObjectRoles;
|
|
228
|
+
/**
|
|
229
|
+
* 与其他对象的关系(REQ-014 §3.1.2)。
|
|
230
|
+
* `SomaSemanticRequest.through` 按 `name` 引用它,`compare` / `navigate` 靠它成立。
|
|
231
|
+
*/
|
|
232
|
+
relations?: SomaDataObjectRelation[];
|
|
147
233
|
/** 写通道声明(§8);不给 = 该对象只读 */
|
|
148
234
|
write?: SomaDataWriteConfig;
|
|
149
235
|
/**
|
|
@@ -77,24 +77,3 @@ export interface ValidationResult {
|
|
|
77
77
|
/** 各字段的错误消息集合 */
|
|
78
78
|
errors: Record<string, string[]>;
|
|
79
79
|
}
|
|
80
|
-
/**
|
|
81
|
-
* 业务事件处理函数签名
|
|
82
|
-
* 所有被 _event.yaml 引用的方法必须符合此签名
|
|
83
|
-
*/
|
|
84
|
-
export interface SomaEventHandler {
|
|
85
|
-
(...args: any[]): Promise<boolean> | boolean | void;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* 常量对象接口
|
|
89
|
-
* 提供静态枚举值或配置项
|
|
90
|
-
*/
|
|
91
|
-
export interface SomaConstant {
|
|
92
|
-
readonly [key: string]: any;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* 可加载常量接口
|
|
96
|
-
* 支持从后端加载动态字典数据
|
|
97
|
-
*/
|
|
98
|
-
export interface SomaLoadableConstant extends SomaConstant {
|
|
99
|
-
loadFromAPI(): Promise<void>;
|
|
100
|
-
}
|
|
@@ -10,6 +10,7 @@ export type SomaSizing = 'fixed' | 'hug' | 'fill';
|
|
|
10
10
|
*/
|
|
11
11
|
export declare const SOMA_LAYOUT_PRIORITIES: readonly [250, 500, 750, 1000];
|
|
12
12
|
export type SomaPriority = typeof SOMA_LAYOUT_PRIORITIES[number];
|
|
13
|
+
export declare const SOMA_LAYOUT_SIZINGS: readonly SomaSizing[];
|
|
13
14
|
/** 换行策略:不换 / 窄了就竖排 / 横向滚动成一条卷轴 */
|
|
14
15
|
export type SomaWrap = 'none' | 'below' | 'reel';
|
|
15
16
|
export declare const SOMA_LAYOUT_ALIGNS: readonly ["start", "center", "end", "baseline", "space_between", "space_evenly", "space_around"];
|