soma-core 1.4.2 → 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 +431 -26
- package/core/build/component/component-graph.ts +28 -105
- package/core/build/component/package-loader.ts +18 -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/client/component/example-blocks.ts +1 -7
- package/core/client/component/theme-component-tokens.ts +12 -15
- 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 +4 -1
- 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 +18 -4
- 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 +201 -16
- package/core/shared/component/field-lines.ts +98 -8
- 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 +7 -6
- 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 +1563 -800
- 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/component/example-blocks.d.ts +0 -2
- package/dist/types/client/component/theme-component-tokens.d.ts +8 -5
- 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 +4 -5
- 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 +14 -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 +7 -6
- 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,5 +1,3 @@
|
|
|
1
|
-
/** Strip query/hash for router utilities */
|
|
2
|
-
export declare function pathOnly(url: string): string;
|
|
3
1
|
/** Browser location pathname + search (includes ?id= etc.) */
|
|
4
2
|
export declare function getBrowserUrlPath(): string;
|
|
5
3
|
/** Read a query parameter from router path or the browser address bar */
|
|
@@ -11,6 +11,12 @@ export interface BlockScope {
|
|
|
11
11
|
blockId: string;
|
|
12
12
|
/** 本块 data 段声明或引入的对象名 */
|
|
13
13
|
dataNames: ReadonlySet<string>;
|
|
14
|
+
/**
|
|
15
|
+
* 本块 data 名 → 运行时绑定路径前缀。组件块由 use-parser 填:
|
|
16
|
+
* 声明 → `page.data.<块id__名>`,引入 → 引入目标路径。
|
|
17
|
+
* 缺省时回落 `块id.名`——那是 page 块沿用的既有口径,组件块不走这条。
|
|
18
|
+
*/
|
|
19
|
+
dataPaths?: ReadonlyMap<string, string>;
|
|
14
20
|
/** 块作用域别名 */
|
|
15
21
|
aliases: ReadonlyMap<string, AliasEntry>;
|
|
16
22
|
/** 按 HTML 位置可见的行变量(行内组件才有) */
|
|
@@ -18,6 +24,20 @@ export interface BlockScope {
|
|
|
18
24
|
/** 页面变量固定名 */
|
|
19
25
|
pageVar: string;
|
|
20
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* 块私有数据对象的全局身份:扁平名 `块id__名`(标识符,不带点)。
|
|
29
|
+
*
|
|
30
|
+
* 为什么不是 `块id.名`:数据对象层的对象名是标识符(data-config-parser 的
|
|
31
|
+
* IDENTIFIER_PATTERN),`$` 引用与 `relations[].to` 也按标识符切;运行时
|
|
32
|
+
* `page.data.<对象>.<字段>` 的绑定按点号逐段下钻。带点的对象名在这几处各断一次——
|
|
33
|
+
* 页面要么发布不了,要么发布了取不到值、只剩一片空白。扁平名让块私有对象与页面级对象
|
|
34
|
+
* 走同一条解析、同一条取数、同一条绑定,下游一行不改。
|
|
35
|
+
*
|
|
36
|
+
* 规则只在这里定义一次:use-parser(对象键与绑定路径)与 block-compile(撞名检查、
|
|
37
|
+
* `relations[].to`)都调它,不各拼一遍。撞名(`a` 的 `b__c` 与 `a__b` 的 `c`)
|
|
38
|
+
* 由 block-compile 在合表时拦下。
|
|
39
|
+
*/
|
|
40
|
+
export declare function blockDataObjectName(blockId: string, localName: string): string;
|
|
21
41
|
export interface BuildScopeInput {
|
|
22
42
|
blockId: string;
|
|
23
43
|
dataNames?: Iterable<string>;
|
|
@@ -7,6 +7,15 @@ export interface PageBlockAst {
|
|
|
7
7
|
eventRaw: Record<string, unknown>;
|
|
8
8
|
/** 数据段原文(页面级共享对象,交数据对象层) */
|
|
9
9
|
dataRaw?: Record<string, unknown>;
|
|
10
|
+
/**
|
|
11
|
+
* 表层对象声明原文(REQ-014 §38.5 断线 ②)。
|
|
12
|
+
*
|
|
13
|
+
* 与 `dataRaw` 是**同一件事的两种书写形态**,不是两套对象:构建期由
|
|
14
|
+
* `normalizeSurfaceObject()` 展开成核心层后并进 `data` 段,之后一路走
|
|
15
|
+
* 同一个数据解析器、同一份 API 白名单校验、同一份运行时资产。
|
|
16
|
+
* 分成两个字段只到编译期为止——再往下游只有核心层(§2.3 判据 3:转换只发生一次)。
|
|
17
|
+
*/
|
|
18
|
+
surfaceRaw?: Record<string, unknown>;
|
|
10
19
|
scope: BlockScope;
|
|
11
20
|
}
|
|
12
21
|
export interface ParsePageInput {
|
|
@@ -1,32 +1,61 @@
|
|
|
1
1
|
import type { ExtendedShowValue } from '../../../shared/types/ui-config.types';
|
|
2
2
|
import { parseDuration } from '../duration';
|
|
3
3
|
export { parseDuration };
|
|
4
|
+
import type { SomaDataObjectRelation, SomaDataObjectRoles } from '../../../shared/types/data-config.types';
|
|
4
5
|
import { type BlockScope } from './namespace';
|
|
6
|
+
/**
|
|
7
|
+
* 块声明的**对象级封闭键集**。导出是为了让"两条书写路径的键集差异"有一处可断言的地方
|
|
8
|
+
* ——平铺 `_data.yaml` 那侧是 `SOMA_DATA_OBJECT_KEYS`,两份键集此前只活在各自的
|
|
9
|
+
* `if/else` 里,谁多谁少没有任何东西看得见。差集本身由测试盯着,只减不增。
|
|
10
|
+
*
|
|
11
|
+
* `roles` / `relations` 随 REQ-014 期 2'.1 进表:不进的话,写 `roles:` 会当场报
|
|
12
|
+
* 「data.X 不支持键 "roles"」,而这个错经 `dryRunCompile` 被压成一句
|
|
13
|
+
* 「声明未通过编译闸门」,发布期直接拒收——报错离原因很远。
|
|
14
|
+
*
|
|
15
|
+
* `refresh` / `reload_on` 已移出:数据对象层没有对应物(不轮询、不监听路径),
|
|
16
|
+
* 收着它们就是「解析了、引擎不消费」——写了 `refresh: 30s` 的对象永远不会重取,且不报错。
|
|
17
|
+
* 现在写它们由 RETIRED_DATA_OBJECT_KEYS 当场拒收并指路。
|
|
18
|
+
*/
|
|
19
|
+
export declare const USE_BLOCK_DATA_OBJECT_KEYS: readonly string[];
|
|
20
|
+
/** 块声明的**字段级封闭键集**(导出理由同上) */
|
|
21
|
+
export declare const USE_BLOCK_FIELD_KEYS: readonly string[];
|
|
5
22
|
export interface DataObjectDecl {
|
|
6
23
|
localName: string;
|
|
7
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* 全局身份:扁平名 `块id__名`(blockDataObjectName)。
|
|
26
|
+
* 它就是数据对象层的对象名,也是运行时 `page.data` 的键。
|
|
27
|
+
*/
|
|
8
28
|
fullName: string;
|
|
29
|
+
/** 取数来源(块里只有一个);params 已换成数据对象层的 `$` 引用或字面量 */
|
|
9
30
|
from?: {
|
|
10
31
|
api: string;
|
|
11
32
|
params: Record<string, string>;
|
|
12
33
|
};
|
|
34
|
+
/** 写通道(block-compile 归一为 `write`) */
|
|
13
35
|
save?: {
|
|
14
36
|
api: string;
|
|
15
37
|
method: string;
|
|
16
38
|
key?: string;
|
|
17
|
-
trigger: string;
|
|
18
39
|
fields?: string[];
|
|
19
40
|
};
|
|
20
|
-
refreshMs?: number;
|
|
21
|
-
reloadOn?: string[];
|
|
22
41
|
fields?: Record<string, FieldDecl>;
|
|
42
|
+
/** 对象级角色(REQ-014 §3.1.2):哪个字段是标题 / 状态 / 金额 / 对比基准 */
|
|
43
|
+
roles?: SomaDataObjectRoles;
|
|
44
|
+
/**
|
|
45
|
+
* 对象间关系(REQ-014 §3.1.2):compare / navigate 的作用路径。
|
|
46
|
+
* `to` 保留块内短名,block-compile 把指向本块对象的那些换成扁平名。
|
|
47
|
+
*/
|
|
48
|
+
relations?: SomaDataObjectRelation[];
|
|
23
49
|
}
|
|
24
50
|
export interface FieldDecl {
|
|
25
51
|
name?: string;
|
|
26
52
|
type: string;
|
|
53
|
+
/** 值 → 显示文案(块拼写;block-compile 编成数据对象层的 `options` 数组) */
|
|
27
54
|
values?: Record<string, string>;
|
|
28
55
|
permission: 'r' | 'w';
|
|
29
56
|
rules?: Array<Record<string, unknown>>;
|
|
57
|
+
/** 修饰关系(REQ-014 §15.3):本字段是另一个字段的语气 / 单位 / 图标,不独立占格 */
|
|
58
|
+
modifies?: string;
|
|
30
59
|
}
|
|
31
60
|
export interface ActionDecl {
|
|
32
61
|
id: string;
|
|
@@ -68,5 +97,10 @@ export interface ParseUseInput {
|
|
|
68
97
|
htmlComponent?: string;
|
|
69
98
|
/** 该实例可见的行变量(由 HTML 位置决定) */
|
|
70
99
|
rowVars?: Iterable<string>;
|
|
100
|
+
/**
|
|
101
|
+
* 该实例是否位于列表行模板内(由 HTML 位置决定)。
|
|
102
|
+
* 行内实例不得声明私有数据对象:每行渲染一个实例,而数据对象层没有「每行一个对象」。
|
|
103
|
+
*/
|
|
104
|
+
inRowTemplate?: boolean;
|
|
71
105
|
}
|
|
72
106
|
export declare function parseUseBlock(input: ParseUseInput): UseBlockAst;
|
|
@@ -3,6 +3,19 @@ export declare class SomaDataConfigError extends Error {
|
|
|
3
3
|
readonly path: string;
|
|
4
4
|
constructor(message: string, path?: string);
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* 平铺 `_data.yaml` 的**对象级封闭键集**。导出是为了让"两条书写路径的键集差异"
|
|
8
|
+
* 有一处可断言的地方——SOMA 有两条声明路径(块声明与平铺 YAML),
|
|
9
|
+
* 而它们的键集此前只存在于各自的 `if/else` 里,谁多谁少没有任何东西看得见。
|
|
10
|
+
*
|
|
11
|
+
* 未知键在这里被拒收,是因为拼错的键在 YAML 里**长得像生效了**:
|
|
12
|
+
* 写 `role:`(少个 s)不会有任何提示,只是那个对象永远没有角色。
|
|
13
|
+
* 而这个错经 `dryRunCompile` 会被压成一句"声明未通过编译闸门",发布期直接拒收——
|
|
14
|
+
* 报错离原因很远,所以这里的消息必须自己把可用键列全。
|
|
15
|
+
*/
|
|
16
|
+
export declare const SOMA_DATA_OBJECT_KEYS: readonly string[];
|
|
17
|
+
/** 平铺 `_data.yaml` 的**字段级封闭键集**(导出理由同上) */
|
|
18
|
+
export declare const SOMA_DATA_FIELD_KEYS: readonly string[];
|
|
6
19
|
/** 解析后的 `$` 引用:三源之一 + 字段路径段 */
|
|
7
20
|
export interface SomaDataRef {
|
|
8
21
|
/** query:URL 参数;page:Domain 字段;object:已解析数据对象 */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { UiConfig
|
|
1
|
+
import type { UiConfig } from '../../shared/types/ui-config.types';
|
|
2
2
|
import type { SomaAdaptiveVocabulary } from '../../shared/types/adaptive.types';
|
|
3
3
|
/**
|
|
4
4
|
* UI 配置解析错误
|
|
@@ -48,13 +48,3 @@ export interface SomaUiConfigParseOptions {
|
|
|
48
48
|
* @throws SomaAdaptiveConfigError adaptive 声明不合法时抛出
|
|
49
49
|
*/
|
|
50
50
|
export declare function parseUiConfig(raw: any, options?: SomaUiConfigParseOptions): UiConfig;
|
|
51
|
-
/**
|
|
52
|
-
* 解析 show 键中的 somaId@attr 语法
|
|
53
|
-
*
|
|
54
|
-
* 遍历 ShowMapping 中的所有键,将 `somaId@attr` 拆分为 somaId + attrName。
|
|
55
|
-
* 用于引擎在绑定时判断是设置 textContent 还是 setAttribute。
|
|
56
|
-
*
|
|
57
|
-
* @param show - 已解析的 ShowMapping
|
|
58
|
-
* @returns ParsedShowEntry 数组
|
|
59
|
-
*/
|
|
60
|
-
export declare function parseShowKeys(show: ShowMapping): ParsedShowEntry[];
|
|
@@ -2,11 +2,17 @@ import type { SomaResolvedAxes } from './theme-axes';
|
|
|
2
2
|
/**
|
|
3
3
|
* S5:不含颜色的场景结构参数。
|
|
4
4
|
*
|
|
5
|
-
* 玻璃三档的 rgba
|
|
6
|
-
*
|
|
5
|
+
* 玻璃三档的 rgba 与它同族、住在下面的 `glassTokens`(值一个没改,引擎主体的亮/暗两处
|
|
6
|
+
* 都经它取值)——它们是材质的结构属性,与 field/material 轴同族,
|
|
7
|
+
* 散在派生链中间只会让人以为它们是色板的一部分。
|
|
7
8
|
*/
|
|
8
9
|
export declare function sceneStructureTokens(axes: SomaResolvedAxes): Record<string, string>;
|
|
9
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* 玻璃三档(面 / 强面 / 弱面)。theme-engine 的亮、暗两套变量表都从这里取,值只此一份。
|
|
12
|
+
*
|
|
13
|
+
* 暗色下仍是白,但 alpha 只有 4%~10%(亮色 52%~88%)——高 alpha 的白玻璃压在深底上
|
|
14
|
+
* 会变成一块发光板,层级反而糊掉。
|
|
15
|
+
*/
|
|
10
16
|
export declare function glassTokens(dark: boolean): Record<string, string>;
|
|
11
17
|
/**
|
|
12
18
|
* S7′:场景颜色——吃 overrides 合并后的**最终**变量表。
|
|
@@ -56,7 +56,7 @@ export interface SomaAxisParams {
|
|
|
56
56
|
readonly chromaMul: number;
|
|
57
57
|
readonly targets: SomaContrastTargets;
|
|
58
58
|
readonly darkTargets: SomaContrastTargets;
|
|
59
|
-
/** contrast:soft
|
|
59
|
+
/** contrast:soft 的粉彩明度带(**亮色侧专用**);null = 不约束 */
|
|
60
60
|
readonly softLightnessBand: readonly [number, number] | null;
|
|
61
61
|
/** 环境光三团的 alpha;null = flat(产 transparent) */
|
|
62
62
|
readonly fieldAlphas: readonly [number, number, number] | null;
|
|
@@ -67,6 +67,69 @@ export interface SomaAxisParams {
|
|
|
67
67
|
export declare class SomaThemeAxisError extends Error {
|
|
68
68
|
constructor(message: string);
|
|
69
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* 目标对比度组(Leonardo 路线:明度是解出来的,不是写死的)。
|
|
72
|
+
*
|
|
73
|
+
* ── 三个目标分属两层 ────────────────────────────────────────────────
|
|
74
|
+
* fgOnTone / textOnPage **硬保障**:AA 底线,用户关不掉
|
|
75
|
+
* (《soma 设计令牌与主题》§10.3 原则 4「硬保障不是输入」)。
|
|
76
|
+
* toneOnPage **气质目标**:语气实心底相对页面底有多沉。尽力而为,
|
|
77
|
+
* 被硬保障顶掉不报错;与粉彩带冲突时带让位(记 meta.bandBroken)。
|
|
78
|
+
*
|
|
79
|
+
* ── toneOnPage 三档怎么定的(下一个人照这条链复算) ──────────────────
|
|
80
|
+
*
|
|
81
|
+
* 1) 页面底的相对亮度(OKLab 对灰阶恒有 Y = L³):
|
|
82
|
+
* 亮档 `--soma-bg-page` = gray(0.965) → Y = 0.8986
|
|
83
|
+
* 暗档 `--soma-bg-page` = gray(0.18) → Y = 0.005832
|
|
84
|
+
* → 亮档 toneOnPage = 0.9486 / (Y_tone + 0.05)
|
|
85
|
+
* 暗档 toneOnPage = (Y_tone + 0.05) / 0.055832
|
|
86
|
+
* 彩色的 Y 由 OKLab 逆变换算:
|
|
87
|
+
* Y = -0.040794·l'³ + 1.112492·m'³ - 0.071718·s'³
|
|
88
|
+
* l' = L + 0.3963378a + 0.2158038b
|
|
89
|
+
* m' = L - 0.1055613a - 0.0638542b
|
|
90
|
+
* s' = L - 0.0894842a - 1.2914855b (a = c·cos h,b = c·sin h)
|
|
91
|
+
*
|
|
92
|
+
* 2) 求解器检查的是**种子**(banded / separatedL 之后、AA 之前),所以下界由
|
|
93
|
+
* 各语气的种子明度**上限**决定;明度越高(亮档)离页面底越近,对比度越低:
|
|
94
|
+
*
|
|
95
|
+
* 语气 亮档种子明度上限 该明度全色域最差 toneOnPage
|
|
96
|
+
* accent min(0.78, …) = 0.78 1.666 ← 亮档绑定项
|
|
97
|
+
* secondary min(0.72, …) = 0.72 2.08
|
|
98
|
+
* warning 0.72 2.27
|
|
99
|
+
* success 0.58(分离最多上推到 0.72) 2.15
|
|
100
|
+
* danger 0.60(分离最多上推到 0.74) 2.24
|
|
101
|
+
* info 0.60(固定) 3.48
|
|
102
|
+
*
|
|
103
|
+
* 暗档绑定项是 secondary:暗色种子 = min(0.78, 亮色成品 L + 0.08),
|
|
104
|
+
* 而亮色 secondary 的 L ≥ 0.45(0.45 处白字实测 7.5,AA 用不到推),
|
|
105
|
+
* 故暗档种子下限 0.53 → 该明度全色域最差 3.084。
|
|
106
|
+
* 暗色四个语义色常量(0.68/0.66/0.76/0.68)实测 6.2~8.8,不是绑定项。
|
|
107
|
+
*
|
|
108
|
+
* 3) 三档各取在谁之下:
|
|
109
|
+
* standard 1.6 / 3.0 取在**结构下界** 1.666 / 3.084 之下 ——
|
|
110
|
+
* 缺省档因此对任何品牌的正常派生都"一个语气都不推",
|
|
111
|
+
* 产出与接线前逐字节一致(theme-snapshot 闸门看守)。
|
|
112
|
+
* 它不是空转:分离闸把某个语气上推到 0.86 一带时
|
|
113
|
+
* (实测可掉到 1.27),这条线会把它压回可见范围。
|
|
114
|
+
* soft 1.2 / 2.8 亮档取在**粉彩带上界** L=0.86 处的最差值 1.271 之下,
|
|
115
|
+
* 带 [0.70, 0.86] 因此全区间达标、不会被目标顶穿。
|
|
116
|
+
* 柔光 = 语气浅、对页面底反差小,所以 soft 的目标**低于**
|
|
117
|
+
* standard,而不是高于——把它调高会让 soft 比 standard 还跳。
|
|
118
|
+
* 暗档不传带(见 softLightnessBand 的说明),2.8 是纯下界。
|
|
119
|
+
* strong 5.5 / 5.0 显式切换档,改变观感是预期内的。实算:fgOnTone 7.0 会把
|
|
120
|
+
* 走 AA 求解的五个语气推到 Y ≤ 0.10(toneOnPage 顺带 ≈6.3),
|
|
121
|
+
* 5.5 精确绑住**亮档唯一不过 AA 循环的 danger**(fg 恒白);
|
|
122
|
+
* 暗档 5.0 绑住**没有 AA 循环的 secondary/accent**
|
|
123
|
+
* (今天实测只有 3.1~3.8)。两个目标各管一半,覆盖完整。
|
|
124
|
+
*
|
|
125
|
+
* fgOnTone 4.5 是既有 `enforceContrastPairs` 的硬保障值;textOnPage 4.5 是既有 ④.2
|
|
126
|
+
* 的保障值;strong 的 7.0 是 AAA。这三个数不是新口径。
|
|
127
|
+
*
|
|
128
|
+
* 导出是为了让验收用例读真值而不是抄一份数字(与 SEPARATION_THRESHOLD 同一条纪律)。
|
|
129
|
+
*/
|
|
130
|
+
export declare const CONTRAST_TARGETS: Record<SomaContrast, SomaContrastTargets>;
|
|
131
|
+
/** 暗色目标:页面底 Y=0.005832,方向相反(语气越亮反差越大)。推导同上 */
|
|
132
|
+
export declare const DARK_CONTRAST_TARGETS: Record<SomaContrast, SomaContrastTargets>;
|
|
70
133
|
/**
|
|
71
134
|
* 轴解析:词元 → 确定轴位 + 数值参数。
|
|
72
135
|
*
|
|
@@ -41,7 +41,7 @@ export interface SomaThemeInput {
|
|
|
41
41
|
* (页面永不可寻址组件内部,`scopeAnchors()` 的既定边界)。
|
|
42
42
|
*
|
|
43
43
|
* 引擎不认识组件,所以这里只做展平;「组件名 / 令牌名是否存在」由装配层的
|
|
44
|
-
* `validateThemeComponentTokens` 在 bootstrap
|
|
44
|
+
* `validateThemeComponentTokens` 在 bootstrap 期核对契约(对不上只告警,不阻断换装)。
|
|
45
45
|
*/
|
|
46
46
|
components?: Record<string, Record<string, string>>;
|
|
47
47
|
/** 组件令牌的暗色专属覆盖:与 `darkOverrides` 同一纪律,只并进 darkCssVars */
|
|
@@ -54,6 +54,18 @@ export interface SomaThemeMeta {
|
|
|
54
54
|
readonly separationApplied: boolean;
|
|
55
55
|
/** 被推开的语气 */
|
|
56
56
|
readonly pushed: readonly SomaToneName[];
|
|
57
|
+
/**
|
|
58
|
+
* `contrast:soft` 的粉彩明度带被 toneOnPage 目标顶穿的语气(按名排序)。
|
|
59
|
+
*
|
|
60
|
+
* 不报错只上报:带是气质偏好,目标对比度是无障碍口径,冲突时对比度赢
|
|
61
|
+
* (《soma 设计令牌与主题》§10.3 原则 4「硬保障不是输入」)。留这条旁路是为了
|
|
62
|
+
* 让"带没生效"可观测——否则调参的人只看到颜色不对、不知道是谁让的位。
|
|
63
|
+
*
|
|
64
|
+
* 当前参数下它应当恒为空:soft 的 toneOnPage 1.2 取在带上界 L=0.86 处的
|
|
65
|
+
* 最差实测值 1.271 之下,带全区间达标。它变成非空 = 有人动了带或目标而没对齐。
|
|
66
|
+
* 暗色侧不参与(带只作用于亮色,暗色求解恒传 null)。
|
|
67
|
+
*/
|
|
68
|
+
readonly bandBroken: readonly SomaToneName[];
|
|
57
69
|
/** 本次写出的组件级令牌变量名(M-1)——快照与闸门的观测面 */
|
|
58
70
|
readonly componentTokens: readonly string[];
|
|
59
71
|
}
|
|
@@ -82,13 +94,6 @@ export declare function hexToOklch(hex: string): Oklch;
|
|
|
82
94
|
export declare function oklchToHex(color: Oklch): string;
|
|
83
95
|
export declare function contrastRatio(hexA: string, hexB: string): number;
|
|
84
96
|
export declare function deriveTheme(input: SomaThemeInput): SomaDerivedTheme;
|
|
85
|
-
/**
|
|
86
|
-
* 引擎会写出的令牌名全集(静态令牌 + 派生令牌),不跑派生。
|
|
87
|
-
*
|
|
88
|
-
* 给 soma-ui 的 `token-existence-lint` 用:契约 `tokens.default` 引用的语义令牌
|
|
89
|
-
* 必须真的存在,否则组件令牌指向一个空变量,回退值一路生效而没人发现。
|
|
90
|
-
*/
|
|
91
|
-
export declare function listThemeTokenNames(): readonly string[];
|
|
92
97
|
/**
|
|
93
98
|
* 派生结果 → 根元素属性。
|
|
94
99
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SomaContrastTargets } from './theme-axes';
|
|
2
2
|
export interface Oklch {
|
|
3
3
|
l: number;
|
|
4
4
|
c: number;
|
|
@@ -36,12 +36,16 @@ export declare function ensureContrast(bg: string, deps: ToneSolverDeps, minRati
|
|
|
36
36
|
* 前景(-fg)仍由既有 ④ 系代码解——那部分是实测校准过的 AA 保障,不在此重复。
|
|
37
37
|
*
|
|
38
38
|
* **裁决**:粉彩带约束与对比度目标冲突时**对比度赢**(AA 底线不随 contrast 档
|
|
39
|
-
*
|
|
40
|
-
*
|
|
39
|
+
* 移动,是《soma 设计令牌与主题》§10.3 原则 4「硬保障不是输入」的承诺)。
|
|
40
|
+
* 带被突破时通过返回值旁路上报,由编排者收进 `meta.bandBroken`,供观测——
|
|
41
|
+
* 不报错,因为"带"是气质偏好不是硬约束。
|
|
42
|
+
*
|
|
43
|
+
* **编排者的责任**(theme-engine 的 `solveOnPage`):本函数排在 AA 求解与分离闸
|
|
44
|
+
* 夹子的**上游**,那两条是硬保障、永远说了算;本函数解出的 toneOnPage 是气质
|
|
45
|
+
* 目标,被它们顶掉不报错。调用点还要把下游 `ensureContrast` 的方向钉在
|
|
46
|
+
* 「远离页面底」一侧,否则缺省启发会把刚解好的语气朝页面底推回去。
|
|
41
47
|
*/
|
|
42
48
|
export declare function solveTone(seed: Oklch, pageHex: string, target: SomaContrastTargets, band: readonly [number, number] | null, deps: ToneSolverDeps): {
|
|
43
49
|
tone: Oklch;
|
|
44
50
|
bandBroken: boolean;
|
|
45
51
|
};
|
|
46
|
-
/** 彩度个性:把 chroma 轴的乘数应用到一个种子彩度上(下限护栏防止推成死灰) */
|
|
47
|
-
export declare function applyChroma(baseChroma: number, params: SomaAxisParams): number;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -18,8 +18,8 @@ export { SomaDataObjectResolver, SomaDataCycleError, isSomaMockEnabled, } from '
|
|
|
18
18
|
export type { SomaDataHttpLike, SomaDataResolverOptions, SomaDataResolveResult, } from './client/data/data-object-resolver';
|
|
19
19
|
export { parseDataConfig, parseDataYaml, parseDataRef, normalizeDataPipeValue, SomaDataConfigError, } from './client/parser/data-config-parser';
|
|
20
20
|
export type { SomaDataRef } from './client/parser/data-config-parser';
|
|
21
|
-
export type { SomaDataConfig, SomaDataObjectConfig, SomaDataSourceConfig, SomaDataFieldConfig, SomaDataFieldRule, SomaDataFieldOption, SomaDataFieldType, SomaDataFieldPermission, SomaDataDicts, SomaDataWriteConfig, SomaDataWriteEndpoint, SomaDataSubmitResult, SomaDataPort, } from './shared/types/data-config.types';
|
|
22
|
-
export { SOMA_DATA_FIELD_TYPES, SOMA_DATA_FIELD_TYPE_ALIASES, } from './shared/types/data-config.types';
|
|
21
|
+
export type { SomaDataConfig, SomaDataObjectConfig, SomaDataSourceConfig, SomaDataFieldConfig, SomaDataFieldRule, SomaDataFieldOption, SomaDataFieldType, SomaDataFieldPermission, SomaDataDicts, SomaDataWriteConfig, SomaDataWriteEndpoint, SomaDataSubmitResult, SomaDataPort, SomaDataObjectRoles, SomaDataObjectRelation, SomaDataRelationCardinality, } from './shared/types/data-config.types';
|
|
22
|
+
export { SOMA_DATA_FIELD_TYPES, SOMA_DATA_FIELD_TYPE_ALIASES, SOMA_DATA_OBJECT_ROLES, SOMA_DATA_RELATION_CARDINALITIES, } from './shared/types/data-config.types';
|
|
23
23
|
export { SOMA_FIELD_PREDICATE_OPS, evaluatePredicate, validatePredicate, validateNamedPredicates, collectPredicateFields, } from './shared/predicates';
|
|
24
24
|
export type { SomaFieldPredicateOp, SomaFieldCondition, SomaFieldPredicateRef, SomaFieldPredicateAllOf, SomaFieldPredicateAnyOf, SomaFieldPredicateNoneOf, SomaFieldPredicate, SomaNamedPredicates, SomaPredicateValidateOptions, } from './shared/predicates';
|
|
25
25
|
export { parseCalc, collectCalcRefs, inferCalcType, assertCalcResultType, evaluateCalc, SomaCalcSyntaxError, SomaCalcTypeError, CALC_FUNCTIONS, } from './shared/calc';
|
|
@@ -62,8 +62,8 @@ export type { SomaComponentDefinition, SomaComponentControllerContext, SomaCompo
|
|
|
62
62
|
export type { SomaComponentContract, SomaComponentLayer, SomaGeometryFamily, SomaContractField, SomaContractProp, SomaContractEmit, SomaContractSlot, SomaContractKeyboard, SomaContractOverlay, SomaContractToken, } from './shared/types/component-contract.types';
|
|
63
63
|
export { findNestedMutableContractDefault } from './shared/types/component-contract.types';
|
|
64
64
|
export { parseFieldLines, parseEmitLines, parseSlotLines, renderFieldLines, somaFields, somaEmits, somaSlots, SomaFieldLinesError, } from './shared/component/field-lines';
|
|
65
|
-
export { deriveContractSample, deriveFieldSample, hasRenderableSample, } from './shared/component/derive-sample';
|
|
66
|
-
export type { DeriveSampleResult, SampleGap } from './shared/component/derive-sample';
|
|
65
|
+
export { deriveContractSample, deriveContractPreviewSample, deriveFieldSample, hasRenderableSample, } from './shared/component/derive-sample';
|
|
66
|
+
export type { DerivePreviewSampleResult, DeriveSampleResult, SampleGap, } from './shared/component/derive-sample';
|
|
67
67
|
export { componentTokenPrefix, componentTokenVar, COMPONENT_TOKEN_KEY_PATTERN, } from './shared/types/component-contract.types';
|
|
68
68
|
export { createDefaultRuntimeServices } from './client/runtime/SomaRuntimeServices';
|
|
69
69
|
export type { SomaRuntimeServices } from './client/runtime/SomaRuntimeServices';
|
|
@@ -108,7 +108,6 @@ export { verifyComponentPack, type VerifyPackOptions } from './client/component/
|
|
|
108
108
|
export { parseValueSegment, evaluateValueNode, isArithSegment, isPlainPath, describeNode, SomaValueLangError, type ValueNode, type PipedValue, type ValuePosition, type HasVarFn, type EvalOptions, } from './client/parser/value-lang';
|
|
109
109
|
export { loadSomaFile, SomaBlockParseError, PAGE_BLOCK_ID, type RawBlock, type SomaFileLoadInput, } from './build/blocks/block-container';
|
|
110
110
|
export { buildHtmlAnchorIndex, type HtmlAnchorIndex, type HtmlAnchorInfo, } from './build/blocks/html-index';
|
|
111
|
-
export { compilePageAssets } from './build/compiler/page-assets';
|
|
112
111
|
export { compileSomaBlocks, type CompiledSomaBlocks, type CompileSomaBlocksInput, } from './build/blocks/block-compile';
|
|
113
112
|
export { parsePageBlock, type PageBlockAst, } from './client/parser/blocks/page-parser';
|
|
114
113
|
export { parseUseBlock, type UseBlockAst, type DataObjectDecl, type FieldDecl, type ActionDecl, } from './client/parser/blocks/use-parser';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-only declaration injection scanner public entry.
|
|
3
|
+
*
|
|
4
|
+
* 刻意不 `import 'server-only'`:soma-ai 的声明校验器在经 jiti 加载的宿主服务里
|
|
5
|
+
* import 本入口,server-only 在纯 Node 语境下会抛错(理由同 `server/page-declaration.ts`)。
|
|
6
|
+
*/
|
|
7
|
+
export { scanDeclarationSafety, type ScannableDeclaration, } from './registry/validation/declaration-safety-scan';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export type SomaPageResponseMode = 'html' | 'json';
|
|
2
1
|
export declare const SOMA_PAGE_REQUEST_URL_HEADER = "x-soma-page-request-url";
|
|
3
2
|
export declare function isJsonPageResponseMode(mode: string | undefined): boolean;
|
|
4
3
|
export declare function isSomaPageRequestPath(pathname: string): boolean;
|
|
@@ -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;
|