soma-core 1.4.2 → 1.5.1
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 +29 -10
- 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/component-expander.ts +18 -3
- package/core/client/component/component-manager.ts +4 -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 +43 -0
- 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 +341 -70
- package/core/client/theme/tone-solver.ts +9 -8
- package/core/index.ts +24 -5
- 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 +1829 -1028
- 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/component-expander.d.ts +1 -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 -6
- 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 +29 -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
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
// 等价——迁移前后作用域清单树一致(由 verifyEquivalence 比对,不靠肉眼)。
|
|
9
9
|
//
|
|
10
10
|
// 不迁移的部分照直报告,不静默丢弃:_style.yaml 的 transitions 需要人工并进
|
|
11
|
-
// HTML class
|
|
11
|
+
// HTML class,迁移器只给出清单;带着这类残留的侧车在 `sidecars` 里标 manual,
|
|
12
|
+
// 调用方不许删它——人工清单里提了一句、文件却没了,等于还是静默丢弃。
|
|
12
13
|
|
|
13
14
|
import type { BindDeclaration, UiConfig } from '../../shared/types/ui-config.types';
|
|
14
15
|
|
|
@@ -19,6 +20,16 @@ export interface FlatPageFiles {
|
|
|
19
20
|
dataYaml?: Record<string, unknown>;
|
|
20
21
|
}
|
|
21
22
|
|
|
23
|
+
/** 平铺侧车(`_ui.yaml` 之外的三件) */
|
|
24
|
+
export type FlatSidecar = 'eventYaml' | 'styleYaml' | 'dataYaml';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 一份侧车的去留:
|
|
28
|
+
* migrated —— 内容**完整**并进了块声明(或本来就没有内容),可以删;
|
|
29
|
+
* manual —— 有迁移器没迁的内容(明细在 report.manual),**不许删**。
|
|
30
|
+
*/
|
|
31
|
+
export type SidecarDisposition = 'migrated' | 'manual';
|
|
32
|
+
|
|
22
33
|
export interface MigrationReport {
|
|
23
34
|
/** 逐条变换记录(可读,用于 review 迁移结果) */
|
|
24
35
|
changes: string[];
|
|
@@ -32,6 +43,15 @@ export interface MigrationResult {
|
|
|
32
43
|
/** 结构形态(便于测试与等价比对) */
|
|
33
44
|
blocks: Record<string, unknown>;
|
|
34
45
|
report: MigrationReport;
|
|
46
|
+
/**
|
|
47
|
+
* 每份给了的侧车的去留(没给的不出现)。`soma migrate --write` 只删 migrated 的,
|
|
48
|
+
* 有 manual 的页整页不写盘。
|
|
49
|
+
*
|
|
50
|
+
* 这张表存在的理由:曾经 `--write` 不分青红皂白删 `_style.yaml`——而迁移器
|
|
51
|
+
* 从来不迁它的 base / states / transitions,那些内容只在人工清单里提了一句,
|
|
52
|
+
* 文件就没了。「迁没迁完」只有迁移器自己知道,所以由它给出,调用方不猜。
|
|
53
|
+
*/
|
|
54
|
+
sidecars: Partial<Record<FlatSidecar, SidecarDisposition>>;
|
|
35
55
|
}
|
|
36
56
|
|
|
37
57
|
/** 把一页平铺声明迁移为块结构 */
|
|
@@ -81,28 +101,69 @@ export function migrateFlatToBlocks(files: FlatPageFiles): MigrationResult {
|
|
|
81
101
|
}
|
|
82
102
|
if (Object.keys(pageUi).length > 0) pageBlock.ui = pageUi;
|
|
83
103
|
|
|
84
|
-
|
|
85
|
-
if (files.eventYaml) {
|
|
86
|
-
migrateEvents(files.eventYaml, pageBlock, componentBlocks, report);
|
|
87
|
-
}
|
|
104
|
+
const sidecars: Partial<Record<FlatSidecar, SidecarDisposition>> = {};
|
|
88
105
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
106
|
+
// 事件:DOM 事件留 page.event.on;emit 路由迁进对应组件块。
|
|
107
|
+
// 事件侧车逐键搬运(含 timers / triggers 与列表作用域嵌套),搬完即迁完。
|
|
108
|
+
if (files.eventYaml !== undefined && files.eventYaml !== null) {
|
|
109
|
+
if (isPlainRecord(files.eventYaml)) {
|
|
110
|
+
migrateEvents(files.eventYaml, pageBlock, componentBlocks, report);
|
|
111
|
+
sidecars.eventYaml = 'migrated';
|
|
93
112
|
} else {
|
|
94
|
-
|
|
95
|
-
|
|
113
|
+
report.manual.push('_event.yaml 顶层不是映射,迁移器无从解读;未并入块声明');
|
|
114
|
+
sidecars.eventYaml = 'manual';
|
|
96
115
|
}
|
|
97
116
|
}
|
|
98
117
|
|
|
118
|
+
if (files.dataYaml !== undefined && files.dataYaml !== null) {
|
|
119
|
+
sidecars.dataYaml = migrateData(files.dataYaml, pageBlock, report);
|
|
120
|
+
}
|
|
121
|
+
|
|
99
122
|
// 样式:唯一声明不再接受独立样式侧车;迁移时必须显式并入页面结构。
|
|
100
|
-
|
|
101
|
-
|
|
123
|
+
// 迁移器一条都不迁(照直进人工清单),所以只有「本来就没有内容」的样式侧车算迁完。
|
|
124
|
+
if (files.styleYaml !== undefined && files.styleYaml !== null) {
|
|
125
|
+
sidecars.styleYaml = reportStyleMigration(files.styleYaml, report);
|
|
102
126
|
}
|
|
103
127
|
|
|
104
128
|
const blocks: Record<string, unknown> = { page: pageBlock, ...componentBlocks };
|
|
105
|
-
return { somaText: renderSoma(blocks), blocks, report };
|
|
129
|
+
return { somaText: renderSoma(blocks), blocks, report, sidecars };
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function isPlainRecord(value: unknown): value is Record<string, unknown> {
|
|
133
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* `_data.yaml` → page.data。
|
|
138
|
+
*
|
|
139
|
+
* 数据解析器只读顶层 `data` 映射,迁移器也只搬这一段;顶层还有别的键时
|
|
140
|
+
* 迁移器不猜它是什么(笔误?别的工具的配置?),报人工、侧车留着。
|
|
141
|
+
*/
|
|
142
|
+
function migrateData(
|
|
143
|
+
dataYaml: Record<string, unknown>,
|
|
144
|
+
pageBlock: Record<string, unknown>,
|
|
145
|
+
report: MigrationReport,
|
|
146
|
+
): SidecarDisposition {
|
|
147
|
+
if (!isPlainRecord(dataYaml)) {
|
|
148
|
+
report.manual.push('_data.yaml 顶层不是映射,迁移器无从解读;未并入 page.data');
|
|
149
|
+
return 'manual';
|
|
150
|
+
}
|
|
151
|
+
if (Object.keys(dataYaml).length === 0) return 'migrated';
|
|
152
|
+
|
|
153
|
+
const data = dataYaml.data;
|
|
154
|
+
if (!isPlainRecord(data)) {
|
|
155
|
+
report.manual.push('_data.yaml 必须含 data 映射;未自动并入 page.data,避免生成不可运行的声明');
|
|
156
|
+
return 'manual';
|
|
157
|
+
}
|
|
158
|
+
pageBlock.data = data;
|
|
159
|
+
report.changes.push(`data(${Object.keys(data).length} 个对象)→ page.data`);
|
|
160
|
+
|
|
161
|
+
const extra = Object.keys(dataYaml).filter((key) => key !== 'data');
|
|
162
|
+
if (extra.length > 0) {
|
|
163
|
+
report.manual.push(`_data.yaml 顶层除 data 外还有 ${extra.join('、')}:迁移器只并入 data 段,其余不猜`);
|
|
164
|
+
return 'manual';
|
|
165
|
+
}
|
|
166
|
+
return 'migrated';
|
|
106
167
|
}
|
|
107
168
|
|
|
108
169
|
/** show 树 → 平铺 page.ui + 组件块(实例分离是块声明的核心形状变化) */
|
|
@@ -220,28 +281,60 @@ function migrateEvents(
|
|
|
220
281
|
}
|
|
221
282
|
}
|
|
222
283
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
284
|
+
const STYLE_SECTIONS = ['base', 'states', 'transitions', 'themes'] as const;
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* `_style.yaml` 的四段(base / states / transitions / themes)迁移器一段都不迁,照直进人工清单。
|
|
288
|
+
* 返回 migrated 仅当它**本来就没有内容**:四段全空,除 `host` 外没有别的键
|
|
289
|
+
* (`host` 只是 HTML 里 `data-soma-host` 的回声,解析器校验它、运行时不读它)。
|
|
290
|
+
*/
|
|
291
|
+
function reportStyleMigration(styleYaml: Record<string, unknown>, report: MigrationReport): SidecarDisposition {
|
|
292
|
+
if (!isPlainRecord(styleYaml)) {
|
|
293
|
+
report.manual.push('_style.yaml 顶层不是映射,迁移器无从解读');
|
|
294
|
+
return 'manual';
|
|
295
|
+
}
|
|
296
|
+
const manualBefore = report.manual.length;
|
|
297
|
+
const sectionKeys = (key: (typeof STYLE_SECTIONS)[number]): string[] => {
|
|
298
|
+
const value = styleYaml[key];
|
|
299
|
+
if (value === undefined || value === null) return [];
|
|
300
|
+
if (isPlainRecord(value)) return Object.keys(value);
|
|
301
|
+
// 非映射(如 `base: 某个字符串`)不是"空":迁移器无从解读,照直交给人
|
|
302
|
+
report.manual.push(`_style.yaml ${key} 不是映射,迁移器无从解读`);
|
|
303
|
+
return [];
|
|
304
|
+
};
|
|
305
|
+
const base = sectionKeys('base');
|
|
306
|
+
const transitions = sectionKeys('transitions');
|
|
307
|
+
const states = sectionKeys('states');
|
|
308
|
+
const themes = sectionKeys('themes');
|
|
227
309
|
|
|
228
|
-
if (base
|
|
310
|
+
if (base.length > 0) {
|
|
229
311
|
report.manual.push(
|
|
230
|
-
`_style.yaml base(${
|
|
231
|
-
+ `(锚点:${
|
|
312
|
+
`_style.yaml base(${base.length} 项):类名并进 HTML 的 class 属性`
|
|
313
|
+
+ `(锚点:${base.join('、')})`,
|
|
232
314
|
);
|
|
233
315
|
}
|
|
234
|
-
if (transitions
|
|
316
|
+
if (transitions.length > 0) {
|
|
235
317
|
report.manual.push(
|
|
236
|
-
`_style.yaml transitions(${
|
|
318
|
+
`_style.yaml transitions(${transitions.length} 项):`
|
|
237
319
|
+ '改写为 HTML class 的 CSS 变体(hover: / focus:;具体实现由宿主样式系统提供)',
|
|
238
320
|
);
|
|
239
321
|
}
|
|
240
|
-
if (states
|
|
322
|
+
if (states.length > 0) {
|
|
241
323
|
report.manual.push(
|
|
242
|
-
`_style.yaml states(${
|
|
324
|
+
`_style.yaml states(${states.length} 项):改写为 ui 段的 锚点.class 条件映射`,
|
|
243
325
|
);
|
|
244
326
|
}
|
|
327
|
+
if (themes.length > 0) {
|
|
328
|
+
report.manual.push(
|
|
329
|
+
`_style.yaml themes(${themes.join('、')}):按主题的类名 / 状态 / 变量覆盖,迁移器不迁,需人工改写`,
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
const unknown = Object.keys(styleYaml)
|
|
333
|
+
.filter((key) => key !== 'host' && !(STYLE_SECTIONS as readonly string[]).includes(key));
|
|
334
|
+
if (unknown.length > 0) {
|
|
335
|
+
report.manual.push(`_style.yaml 还有迁移器不认识的键 ${unknown.join('、')}:不猜,需人工处理`);
|
|
336
|
+
}
|
|
337
|
+
return report.manual.length > manualBefore ? 'manual' : 'migrated';
|
|
245
338
|
}
|
|
246
339
|
|
|
247
340
|
/** 块结构 → 块声明文本(YAML 风格,两空格缩进) */
|
|
@@ -12,6 +12,15 @@ import {
|
|
|
12
12
|
compileEventConfigFromRaw,
|
|
13
13
|
} from './soma-precompile';
|
|
14
14
|
import { compilePageLayout } from '../layout/page-layout';
|
|
15
|
+
import {
|
|
16
|
+
compilePageOoui,
|
|
17
|
+
expandPageSurface,
|
|
18
|
+
SomaOouiError,
|
|
19
|
+
type SomaEnvironment,
|
|
20
|
+
type SomaOouiEngine,
|
|
21
|
+
type SomaTrace,
|
|
22
|
+
} from '../ooui';
|
|
23
|
+
import { resolveOouiEngine } from '../ooui/engine-slot';
|
|
15
24
|
import { parsePageState } from '../../client/parser/page-state-parser';
|
|
16
25
|
|
|
17
26
|
export interface SomaPageDeclarationInput {
|
|
@@ -23,6 +32,24 @@ export interface SomaPageDeclarationInput {
|
|
|
23
32
|
externalBlocks?: ReadonlyMap<string, string>;
|
|
24
33
|
/** 与浏览器运行时一致的共享 HTML 片段;仅在构建锚点校验前展开。 */
|
|
25
34
|
includes?: Readonly<Record<string, string>>;
|
|
35
|
+
/**
|
|
36
|
+
* OOUI 演绎引擎(REQ-014)。由**宿主**装配。
|
|
37
|
+
*
|
|
38
|
+
* 它不能由本模块自己造:候选表与空间词汇住在组件库(soma-ui / 业务包),
|
|
39
|
+
* 而 core 不许 import 它们(`verify-ooui-dep-graph` 的 `CORE-IMPORTS-UI`)。
|
|
40
|
+
*
|
|
41
|
+
* 缺省不传时回落到**进程级槽位**(`../ooui/engine-slot`)——本函数在生产上有八个
|
|
42
|
+
* 调用点分属五个进程,其中六个住在 core 里面,没有任何办法自己拿到 soma-ui 的词汇。
|
|
43
|
+
* 要求每一层调用方都开一个 `ooui` 口子一路透传,代价是"任何一层忘了透传都不报错",
|
|
44
|
+
* 而"这条路没透传"与"这页没写 ooui"在错误消息里长得一模一样。
|
|
45
|
+
* 显式传参优先于槽位,供单测与"同进程要用两份不同词表"的场景使用。
|
|
46
|
+
*
|
|
47
|
+
* 两处都取不到 = 本次编译不具备演绎能力;页面若声明了 `ooui:` 段,**当场拒收**,
|
|
48
|
+
* 不静默跳过——静默跳过的表现是"发布成功但那一块永远是空的"。
|
|
49
|
+
*/
|
|
50
|
+
ooui?: SomaOouiEngine;
|
|
51
|
+
/** 演绎环境(可用宽度档、已装配组件清单)。缺省 = 不限宽、不筛候选 */
|
|
52
|
+
oouiEnv?: SomaEnvironment;
|
|
26
53
|
}
|
|
27
54
|
|
|
28
55
|
export interface SomaRuntimeDeclarationAssets {
|
|
@@ -41,6 +68,33 @@ export interface CompiledPageDeclaration {
|
|
|
41
68
|
dataConfig?: SomaDataConfig;
|
|
42
69
|
/** `layout:` 段的构建期产物:只含容器查询 + flex(CL-2);没声明就没有 */
|
|
43
70
|
layoutCss?: string;
|
|
71
|
+
/** `ooui:` 段的构建期演绎产物(REQ-014);没声明就没有 */
|
|
72
|
+
oouiArtifact?: UiConfig['oouiArtifact'];
|
|
73
|
+
/**
|
|
74
|
+
* `objects:` 段的**来历台账**(REQ-014 §38.5 断线 ②):哪些值是作者写的、
|
|
75
|
+
* 哪些是系统按默认补的、哪些是按规则猜的。没写 `objects:` 就没有。
|
|
76
|
+
*
|
|
77
|
+
* **编译期诊断,不进 `runtimeAssets`。** 进产物的话每次取页都要多传一份
|
|
78
|
+
* 只有人会读的东西,而它对渲染没有任何影响;更要紧的是它会让内容寻址把
|
|
79
|
+
* "报告措辞改了一个字"当成一次产物变更。
|
|
80
|
+
*
|
|
81
|
+
* 消费方是发布闸门与 soma-ai 的自修复回路:有了它,
|
|
82
|
+
* `OOUI-SEM-EDIT-ALL-READONLY` 才能从"你写错了"升级成
|
|
83
|
+
* "**我按默认补的** permission: r,你需要显式写 w"——同一条错误,
|
|
84
|
+
* 两种修法,指向两个人(§34.2)。
|
|
85
|
+
*/
|
|
86
|
+
oouiOrigins?: readonly SomaTrace[];
|
|
87
|
+
/**
|
|
88
|
+
* `ooui:` 段**页面这一层**的推导链(REQ-014 §5):空间预算的决策(每个区域按什么约束分宽、
|
|
89
|
+
* sizing / gap / wrap 取了缺省、预算 CSS 落在哪个区域行上或为什么没发)与演绎之后那一遍联动裁决(每条 `bound_to` 依据哪个动词、
|
|
90
|
+
* 哪种控制模型成立,带不带 caveat)。没写 `ooui:` 就没有。
|
|
91
|
+
*
|
|
92
|
+
* 与 `oouiOrigins` 同一条纪律:**编译期诊断,不进 `runtimeAssets`**,产物一个字节都不变。
|
|
93
|
+
* 此前这两项推导算完就被丢掉,报告说得出"这个组件为什么被选中",
|
|
94
|
+
* 说不出"这个区域为什么只分到这么宽"、"这条联动凭什么成立"——
|
|
95
|
+
* 而 §5 的原话是"没有 trace 的推导不允许进主路径"。
|
|
96
|
+
*/
|
|
97
|
+
oouiPageTraces?: readonly SomaTrace[];
|
|
44
98
|
runtimeAssets: SomaRuntimeDeclarationAssets;
|
|
45
99
|
}
|
|
46
100
|
|
|
@@ -65,12 +119,32 @@ export function compilePageDeclaration(input: SomaPageDeclarationInput): Compile
|
|
|
65
119
|
);
|
|
66
120
|
}
|
|
67
121
|
|
|
122
|
+
// include 只展开一次:锚点索引(compileSomaBlocks 内建)与演绎的区域行判定(compilePageOoui)
|
|
123
|
+
// 必须看同一份 HTML。各展开一次的话两份在今天逐字节相同,展开器哪天改了其中一处调用的参数,
|
|
124
|
+
// 就会出现"锚点在索引里、却不在区域行判定看到的那棵树里"——预算 CSS 静默不发。
|
|
125
|
+
const html = expandSomaHtmlIncludes(input.html, input.includes);
|
|
68
126
|
const compiled = compileSomaBlocks({
|
|
69
|
-
html
|
|
127
|
+
html,
|
|
70
128
|
uiYamlRaw: input.uiYaml,
|
|
71
129
|
...(input.externalBlocks ? { externalBlocks: input.externalBlocks } : {}),
|
|
72
130
|
});
|
|
73
131
|
const eventBundle = compileEventConfigFromRaw(compiled.event);
|
|
132
|
+
|
|
133
|
+
// objects:表层对象声明(REQ-014 §38.5 断线 ②)——**展开一次,然后就只有核心层**。
|
|
134
|
+
//
|
|
135
|
+
// 这一段必须在 `embeddedDataYaml` 之前:展开结果要并进 `data`,之后才能一路走
|
|
136
|
+
// 同一个数据解析器(`compileDataConfig`)、同一份 API 白名单校验、同一份运行时资产。
|
|
137
|
+
// 另开一条对象通道的代价是那三样各要重做一份,而两份校验必然漂——
|
|
138
|
+
// 漂开那天的表现是"某条路上的对象没过白名单"。
|
|
139
|
+
const expanded = compiled.surface !== undefined
|
|
140
|
+
? expandPageSurface({
|
|
141
|
+
surface: compiled.surface,
|
|
142
|
+
kernelNames: Object.keys(compiled.data),
|
|
143
|
+
hostClass: compiled.ui.bind.obj,
|
|
144
|
+
})
|
|
145
|
+
: null;
|
|
146
|
+
if (expanded) Object.assign(compiled.data, expanded.objects);
|
|
147
|
+
|
|
74
148
|
const embeddedDataYaml = Object.keys(compiled.data).length > 0 ? dump({ data: compiled.data }) : '';
|
|
75
149
|
|
|
76
150
|
// state:这里两份资产都在手(数据对象名 + HTML 锚点),做完整校验。
|
|
@@ -93,16 +167,53 @@ export function compilePageDeclaration(input: SomaPageDeclarationInput): Compile
|
|
|
93
167
|
? compilePageLayout({ raw: compiled.ui.layout, htmlIndex: compiled.htmlIndex, hostClass: compiled.ui.bind.obj })
|
|
94
168
|
: null;
|
|
95
169
|
if (layout) compiled.ui.layout = layout.constraints;
|
|
96
|
-
|
|
97
|
-
const
|
|
170
|
+
|
|
171
|
+
const dataConfig = embeddedDataYaml ? compileDataConfig(embeddedDataYaml) : undefined;
|
|
172
|
+
|
|
173
|
+
// ooui:构建期演绎(REQ-014),与 layout 同一条范式——**声明进、产物出、声明不下发**。
|
|
174
|
+
// 演绎链住在 core/build/ooui/,浏览器一行都不跑;运行时收到的只有产物。
|
|
175
|
+
const ooui = compiled.ui.ooui !== undefined
|
|
176
|
+
? compilePageOoui({
|
|
177
|
+
raw: compiled.ui.ooui,
|
|
178
|
+
htmlIndex: compiled.htmlIndex,
|
|
179
|
+
// 预算 CSS 要挂在各区域锚点的共同父元素上,那得看元素结构(锚点索引只有"有没有")。
|
|
180
|
+
html,
|
|
181
|
+
objects: dataConfig?.objects ?? {},
|
|
182
|
+
engine: requireOouiEngine(input.ooui ?? resolveOouiEngine()),
|
|
183
|
+
hostClass: compiled.ui.bind.obj,
|
|
184
|
+
// 整页 show 一起传进去:`ooui:` 的锚点若同时是 show 的绑定目标,
|
|
185
|
+
// 运行时会先插演绎 DOM、再被 setText 整块擦成一行文本
|
|
186
|
+
// (渲染正常、控制台一行都没有)。判据两份声明都在手上,归编译期
|
|
187
|
+
// (`OOUI-SEM-ANCHOR-SHOW-CONFLICT`)。
|
|
188
|
+
show: compiled.ui.show,
|
|
189
|
+
...(input.oouiEnv ? { env: input.oouiEnv } : {}),
|
|
190
|
+
})
|
|
191
|
+
: null;
|
|
192
|
+
if (ooui) compiled.ui.ooui = ooui.declarations;
|
|
193
|
+
|
|
194
|
+
const { layout: _layoutDecl, ooui: _oouiDecl, ...runtimeUi } = compiled.ui;
|
|
195
|
+
const runtimeUiWithCss = {
|
|
196
|
+
...runtimeUi,
|
|
197
|
+
...(layout ? { layout_css: layout.css } : {}),
|
|
198
|
+
...(ooui ? { ooui_artifact: ooui.artifact } : {}),
|
|
199
|
+
};
|
|
98
200
|
|
|
99
201
|
return {
|
|
100
|
-
uiConfig:
|
|
202
|
+
uiConfig: {
|
|
203
|
+
...compiled.ui,
|
|
204
|
+
...(layout ? { layoutCss: layout.css } : {}),
|
|
205
|
+
...(ooui ? { oouiArtifact: ooui.artifact } : {}),
|
|
206
|
+
},
|
|
101
207
|
eventConfig: eventBundle.events,
|
|
102
208
|
triggers: eventBundle.triggers,
|
|
103
209
|
timers: eventBundle.timers,
|
|
104
|
-
...(
|
|
210
|
+
...(dataConfig ? { dataConfig } : {}),
|
|
105
211
|
...(layout ? { layoutCss: layout.css } : {}),
|
|
212
|
+
...(ooui ? { oouiArtifact: ooui.artifact } : {}),
|
|
213
|
+
// 台账只挂在编译结果上,**不进 runtimeAssets**(理由见字段注释)。
|
|
214
|
+
...(expanded && expanded.origins.length > 0 ? { oouiOrigins: expanded.origins } : {}),
|
|
215
|
+
// 页面层的推导链同上:只进编译结果,不进产物。
|
|
216
|
+
...(ooui && ooui.traces.length > 0 ? { oouiPageTraces: ooui.traces } : {}),
|
|
106
217
|
runtimeAssets: {
|
|
107
218
|
uiYaml: dump(runtimeUiWithCss),
|
|
108
219
|
eventYaml: Object.keys(compiled.event).length > 0 ? dump(compiled.event) : '',
|
|
@@ -111,3 +222,36 @@ export function compilePageDeclaration(input: SomaPageDeclarationInput): Compile
|
|
|
111
222
|
},
|
|
112
223
|
};
|
|
113
224
|
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* 页面声明了 `ooui:` 却没人给引擎——**当场拒收,不降级**。
|
|
228
|
+
*
|
|
229
|
+
* 降级成"跳过演绎"的表现是:发布成功、页面打开、那一块永远是空的,
|
|
230
|
+
* 而空着的区域与"这块本来就没内容"长得一模一样,没有任何日志区分得开。
|
|
231
|
+
* 这与 REQ-011 之前 `layout:` 被编译链原样丢弃是同一种坏法,不再重演一次。
|
|
232
|
+
*/
|
|
233
|
+
function requireOouiEngine(engine: SomaOouiEngine | undefined): SomaOouiEngine {
|
|
234
|
+
if (engine) return engine;
|
|
235
|
+
throw new SomaOouiError({
|
|
236
|
+
layer: 'assembly',
|
|
237
|
+
code: 'OOUI-ASM-ENGINE-MISSING',
|
|
238
|
+
situation: '页面声明了 ooui: 段,但本次编译没有装配演绎引擎。',
|
|
239
|
+
problem: '演绎所需的组件候选与空间词汇住在组件库(soma-ui / 业务包),'
|
|
240
|
+
+ 'core 不许 import 它们,只能由宿主反向注册进来。缺引擎时跳过演绎,'
|
|
241
|
+
+ '表现是"发布成功但那一块永远是空的"——而空区域和"本来就没写内容"分不开。',
|
|
242
|
+
// 修法只指**公开入口**:`soma-core/server/ooui`(注册与契约视图)+ `soma-ui`(词汇包)。
|
|
243
|
+
// 此前这里写的是 `soma-core/core/build/ooui/engine-slot` 与 `assembleOoui`——
|
|
244
|
+
// 前者是内部路径(发包后 deep-import 不稳定),后者公开子路径根本不导出,照抄即编译失败。
|
|
245
|
+
remedy: '在宿主服务端启动时注册一次(与组件注册同点、用同一张组件表):\n'
|
|
246
|
+
+ " import { composeComponentPacks } from 'soma-core';\n"
|
|
247
|
+
+ " import { contractView, registerOouiPacks } from 'soma-core/server/ooui';\n"
|
|
248
|
+
+ " import { createSomaUiOouiPack, createSomaUiPack } from 'soma-ui';\n"
|
|
249
|
+
+ ' const components = composeComponentPacks([createSomaUiPack(), ...business]).components;\n'
|
|
250
|
+
+ ' const contracts = Object.values(components).map((d) => contractView(d.contract));\n'
|
|
251
|
+
+ ' registerOouiPacks([createSomaUiOouiPack({ contracts })]);\n'
|
|
252
|
+
+ ' 本进程的每个编译点随后自动取到它,不必逐层透传。\n'
|
|
253
|
+
+ ' 单测里要换一份词表:registerOouiPacks(packs, { override: true });'
|
|
254
|
+
+ '回到未注册:resetOouiEngineSlot()。',
|
|
255
|
+
src: { file: '<host:compile>', path: 'page.ooui' },
|
|
256
|
+
});
|
|
257
|
+
}
|