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
|
@@ -159,12 +159,13 @@ export interface SomaComponentContract {
|
|
|
159
159
|
* 依赖的其它组件(REQ-010 F-46):PascalCase 契约名数组。
|
|
160
160
|
*
|
|
161
161
|
* 两件事靠它:
|
|
162
|
-
* ①
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
162
|
+
* ① **eject 说得出副本还需要谁**——`soma component eject` 一个 TreeSelect 时列出它还要 Tree
|
|
163
|
+
* (仍从 soma-ui 取,要在宿主注册表里可解析),而不是等页面渲染出一堆没样式的节点才发现
|
|
164
|
+
* (这条曾真实发生过:`COMPONENT_CSS_DEPS` 少写一条 `TreeSelect: ['Tree']`,
|
|
165
|
+
* 页面上是无样式的折叠箭头);
|
|
166
|
+
* ② **与 CSS 依赖表对账**——`build/component/component-graph.ts` 按它建图,
|
|
167
|
+
* soma-ui 的 `component-css-deps` 测试拿图与 `COMPONENT_CSS_DEPS` 逐项对账,
|
|
168
|
+
* 漏登记的那一条当场红。
|
|
168
169
|
*
|
|
169
170
|
* 只登记**契约级**依赖(模板里真的嵌了那个组件、或 CSS 分片依赖它),
|
|
170
171
|
* 不登记共享资产(`shared/*` 由构建图自然带上,写进来只会重复一份且会漂)。
|
|
@@ -114,6 +114,91 @@ export interface SomaDataFieldConfig {
|
|
|
114
114
|
* 而"写了没反应"是最难查的一类。
|
|
115
115
|
*/
|
|
116
116
|
calc?: string;
|
|
117
|
+
/**
|
|
118
|
+
* 修饰关系(REQ-014 §15.3 原型实测补入):本字段是**另一个字段的修饰**,
|
|
119
|
+
* 不独立呈现。典型是 `status_tone` 修饰 `status_text`——语气、单位、币种、
|
|
120
|
+
* 图标、趋势方向都属此类。
|
|
121
|
+
*
|
|
122
|
+
* 不声明的后果是静默的:修饰字段会被当成一个普通只读字段各占一格,
|
|
123
|
+
* 页面上出现一排空的 `status_tone: —` `priority_tone: —`。它不报错、
|
|
124
|
+
* 不影响功能,只是"这页看着有点乱"——而这句话没人会当成 bug 报上来。
|
|
125
|
+
* 原型跑出来第一眼看到的就是这个(§15.3 缺口 1)。
|
|
126
|
+
*
|
|
127
|
+
* 约束(解析期强制):目标必须是同一本字典里的**另一个**字段,且目标自己
|
|
128
|
+
* 不能再带 `modifies`——修饰不可级联。级联的话"谁是被呈现的那个"就没有唯一答案,
|
|
129
|
+
* 而这种歧义在渲染期只会表现为"少显示了一格"。
|
|
130
|
+
*/
|
|
131
|
+
modifies?: string;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* 对象级角色(REQ-014 §3.1.2):哪个字段承担什么**语义位**。
|
|
136
|
+
*
|
|
137
|
+
* 它要替换掉的是"靠字段名猜"。今天 `pickField` 一类的做法用别名表匹配
|
|
138
|
+
* (`title` / `name` / `label` …)去猜标题字段,猜错了表现为"标题栏显示订单备注",
|
|
139
|
+
* 而这条猜测既不出现在声明里也不出现在日志里,**没有任何地方可查**。
|
|
140
|
+
* 声明了 `roles` 之后,"谁是标题"是作者写的事实,不是系统的运气。
|
|
141
|
+
*
|
|
142
|
+
* 全部可选、值都是**本对象字段字典里的字段名**(解析期对账,指错当场红)。
|
|
143
|
+
*/
|
|
144
|
+
export interface SomaDataObjectRoles {
|
|
145
|
+
/** 身份:这一行/这个对象的唯一键 */
|
|
146
|
+
id?: string;
|
|
147
|
+
/** 展示这个对象时拿什么当标题 */
|
|
148
|
+
title?: string;
|
|
149
|
+
/** 副标题 */
|
|
150
|
+
subtitle?: string;
|
|
151
|
+
/** 生命周期状态,驱动状态位与语气 */
|
|
152
|
+
status?: string;
|
|
153
|
+
/** 时间轴默认依据 */
|
|
154
|
+
timestamp?: string;
|
|
155
|
+
/** 金额,决定右对齐与货币格式 */
|
|
156
|
+
amount?: string;
|
|
157
|
+
/**
|
|
158
|
+
* 对比基准(§27.3 盲测补入):指向标记基准项的字段(如 `is_control`)。
|
|
159
|
+
*
|
|
160
|
+
* 缺它则对比无锚点——"+12%" 不知道是相对谁。而"相对谁"错了的界面
|
|
161
|
+
* 看起来完全正常:数字在、箭头在、颜色也在,只是符号反了。
|
|
162
|
+
*/
|
|
163
|
+
baseline?: string;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* 全部合法角色名(封闭集),供两条书写路径的解析器共用。
|
|
168
|
+
*
|
|
169
|
+
* **不要在解析器里再手抄一份**——字段类型表已经因为手抄漂成过四份
|
|
170
|
+
* (见本文件 `SomaDataFieldType` 的头注释),角色表没有理由重走一遍。
|
|
171
|
+
*/
|
|
172
|
+
export const SOMA_DATA_OBJECT_ROLES: readonly (keyof SomaDataObjectRoles)[] = [
|
|
173
|
+
'id', 'title', 'subtitle', 'status', 'timestamp', 'amount', 'baseline',
|
|
174
|
+
];
|
|
175
|
+
|
|
176
|
+
/** 关系基数:一对一 / 一对多。封闭集 */
|
|
177
|
+
export type SomaDataRelationCardinality = 'one' | 'many';
|
|
178
|
+
|
|
179
|
+
/** 全部合法基数(封闭集),解析器共用 */
|
|
180
|
+
export const SOMA_DATA_RELATION_CARDINALITIES: readonly SomaDataRelationCardinality[] = [
|
|
181
|
+
'one', 'many',
|
|
182
|
+
];
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* 对象间关系(REQ-014 §3.1.2)。
|
|
186
|
+
*
|
|
187
|
+
* 为什么必须显式声明:`compare` 与 `navigate` 两个动词的作用对象**往往不是主对象**
|
|
188
|
+
* (§27.2 盲测)——要比的是"一个实验内部的多个变体",要导航的必然是关系的另一端。
|
|
189
|
+
* 没有关系声明,这两个动词(占八动词封闭集的 25%)表达不出来;
|
|
190
|
+
* 靠字段名后缀猜关系(`xxx_id` → `xxx`)猜错时表现为"点进去是另一个对象的详情",
|
|
191
|
+
* 而页面本身渲染得好好的。
|
|
192
|
+
*/
|
|
193
|
+
export interface SomaDataObjectRelation {
|
|
194
|
+
/** 关系名(对象内唯一),`through` 按它引用 */
|
|
195
|
+
name: string;
|
|
196
|
+
/** 目标对象名(必须是同一份声明里已声明的数据对象) */
|
|
197
|
+
to: string;
|
|
198
|
+
/** 基数 */
|
|
199
|
+
cardinality: SomaDataRelationCardinality;
|
|
200
|
+
/** 本对象上的外键字段(可选;给了就必须在本对象字典里) */
|
|
201
|
+
via?: string;
|
|
117
202
|
}
|
|
118
203
|
|
|
119
204
|
/**
|
|
@@ -185,6 +270,16 @@ export interface SomaDataObjectConfig {
|
|
|
185
270
|
fields?: Record<string, SomaDataFieldConfig>;
|
|
186
271
|
/** mock 样本:SOMA_MOCK_ENABLED / 接口失败兜底 / 无接口预览 */
|
|
187
272
|
mock?: unknown;
|
|
273
|
+
/**
|
|
274
|
+
* 对象级角色(REQ-014 §3.1.2):哪个字段承担什么语义位。
|
|
275
|
+
* 声明它等于把"谁是标题/状态/金额/基准"从系统的猜测变成作者的事实。
|
|
276
|
+
*/
|
|
277
|
+
roles?: SomaDataObjectRoles;
|
|
278
|
+
/**
|
|
279
|
+
* 与其他对象的关系(REQ-014 §3.1.2)。
|
|
280
|
+
* `SomaSemanticRequest.through` 按 `name` 引用它,`compare` / `navigate` 靠它成立。
|
|
281
|
+
*/
|
|
282
|
+
relations?: SomaDataObjectRelation[];
|
|
188
283
|
/** 写通道声明(§8);不给 = 该对象只读 */
|
|
189
284
|
write?: SomaDataWriteConfig;
|
|
190
285
|
/**
|
|
@@ -84,27 +84,3 @@ export interface ValidationResult {
|
|
|
84
84
|
/** 各字段的错误消息集合 */
|
|
85
85
|
errors: Record<string, string[]>;
|
|
86
86
|
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* 业务事件处理函数签名
|
|
90
|
-
* 所有被 _event.yaml 引用的方法必须符合此签名
|
|
91
|
-
*/
|
|
92
|
-
export interface SomaEventHandler {
|
|
93
|
-
(...args: any[]): Promise<boolean> | boolean | void;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* 常量对象接口
|
|
98
|
-
* 提供静态枚举值或配置项
|
|
99
|
-
*/
|
|
100
|
-
export interface SomaConstant {
|
|
101
|
-
readonly [key: string]: any;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* 可加载常量接口
|
|
106
|
-
* 支持从后端加载动态字典数据
|
|
107
|
-
*/
|
|
108
|
-
export interface SomaLoadableConstant extends SomaConstant {
|
|
109
|
-
loadFromAPI(): Promise<void>;
|
|
110
|
-
}
|
|
@@ -24,6 +24,22 @@ export type SomaSizing = 'fixed' | 'hug' | 'fill';
|
|
|
24
24
|
export const SOMA_LAYOUT_PRIORITIES = [250, 500, 750, 1000] as const;
|
|
25
25
|
export type SomaPriority = typeof SOMA_LAYOUT_PRIORITIES[number];
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
* 尺寸意图三档的闭集:`SomaSizing` 这个**类型**在运行时的样子,全仓只此一份。
|
|
29
|
+
*
|
|
30
|
+
* 此前有两份:`layout:` 解析器自持一个 Set,`ooui:` 那一侧(`shared/ooui-declaration.ts`)另有一份。
|
|
31
|
+
* 两份逐字相同,可漂开的那天不会有任何断言红——解析器与演绎引擎会对同一个 `sizing` 给出不同的裁决。
|
|
32
|
+
* 以 `SomaSizing` 做**编译期对账**(`satisfies`):类型加一档、减一档而这里没跟上,typecheck 当场红。
|
|
33
|
+
* 顺序即文档书写序,也是报错文案里「fixed / hug / fill」的顺序。
|
|
34
|
+
*/
|
|
35
|
+
const SIZING_SET = {
|
|
36
|
+
fixed: true,
|
|
37
|
+
hug: true,
|
|
38
|
+
fill: true,
|
|
39
|
+
} as const satisfies Record<SomaSizing, true>;
|
|
40
|
+
|
|
41
|
+
export const SOMA_LAYOUT_SIZINGS = Object.keys(SIZING_SET) as readonly SomaSizing[];
|
|
42
|
+
|
|
27
43
|
/** 换行策略:不换 / 窄了就竖排 / 横向滚动成一条卷轴 */
|
|
28
44
|
export type SomaWrap = 'none' | 'below' | 'reel';
|
|
29
45
|
|
|
@@ -84,6 +84,156 @@ export interface ExtendedShowValue {
|
|
|
84
84
|
*/
|
|
85
85
|
export type ShowMapping = Record<string, ShowValue>;
|
|
86
86
|
|
|
87
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
88
|
+
// OOUI 演绎(REQ-014):声明 `ooui` 与产物 `oouiArtifact` 的运行时形状
|
|
89
|
+
//
|
|
90
|
+
// ── 为什么这两个类型必须住在 shared,而不是住在引擎里 ────────────────
|
|
91
|
+
// 引擎在 `core/build/ooui/`,运行时永远够不着它(`verify-client-dep-graph`
|
|
92
|
+
// 禁止 client import build)。产物却必须**穿过**运行时资产才能到浏览器:
|
|
93
|
+
// 它随 `_ui.yaml` 一起被 Registry 发布、被 parseUiConfig 读回。
|
|
94
|
+
// 类型若留在引擎里,运行时只能拿 `unknown` 顶着,于是产物字段名改一次、
|
|
95
|
+
// 运行时读旧名字读到 `undefined`——表现是"这页的演绎样式忽然没了",
|
|
96
|
+
// 不报错、不留痕。放 shared 是唯一能让两端共用一份字段名的位置。
|
|
97
|
+
//
|
|
98
|
+
// 与 `layout` / `layoutCss` 是同一条范式:**声明进、产物出、声明不下发**。
|
|
99
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* 一处演绎请求的声明(`ooui:` 段的一条)。键是 HTML 锚点 id。
|
|
103
|
+
*
|
|
104
|
+
* 这是**表层书写形态**,不是语义层的 `SomaSemanticRequest`:
|
|
105
|
+
* `object` 在这里是页面 `data:` 段里的对象**名**,构建期才解析成对象本体。
|
|
106
|
+
* 运行时拿不到 `data:` 的解析结果(它是另一份资产),所以这里只能是名字。
|
|
107
|
+
*
|
|
108
|
+
* `verb` / `form` 保持 `string`:八动词与十九形态的封闭集住在引擎里
|
|
109
|
+
* (`core/build/ooui/**`),运行时 import 不到。**闭集判定归构建期**
|
|
110
|
+
* (`OOUI-SEM-VERB-UNKNOWN` / `OOUI-INT-FORM-UNKNOWN`),
|
|
111
|
+
* 这里若照抄一份闭集,两份必然漂,而漂掉的表现是"某个动词在运行时被判非法、
|
|
112
|
+
* 在构建期却合法"——两处都看着对,只有页面是错的。
|
|
113
|
+
*/
|
|
114
|
+
export interface SomaOouiRequestDeclaration {
|
|
115
|
+
/** 页面 `data:` 段里的对象名 */
|
|
116
|
+
object: string;
|
|
117
|
+
/** 八动词之一(闭集在构建期查) */
|
|
118
|
+
verb: string;
|
|
119
|
+
/** 只演绎这几个字段;省略 = 全部字段 */
|
|
120
|
+
focus?: string[];
|
|
121
|
+
/** 动词的作用路径:对象 `relations` 里的关系名 */
|
|
122
|
+
through?: string;
|
|
123
|
+
/** 逃生门:直接指定根形态,跳过动词分派 */
|
|
124
|
+
form?: string;
|
|
125
|
+
/**
|
|
126
|
+
* 联动来源(REQ-014 §29.1):本区域监听**另一个区域**的哪个语义事件。
|
|
127
|
+
*
|
|
128
|
+
* `{ region: <另一个锚点>, as: <语义事件> }`。它在**编译期**被裁决:
|
|
129
|
+
* 源区域的动词 / 控制模型 / 选中组件三者合起来若产不出那个事件,当场拒收
|
|
130
|
+
* (`OOUI-SEM-BINDING-UNSUPPORTED`)。这道闸门防的正是"点了左边列表右边没反应"——
|
|
131
|
+
* 那件事运行期不报错:两块都渲染正常、事件也确实发出去了,只是没有人接。
|
|
132
|
+
*/
|
|
133
|
+
bound_to?: { region: string; as: string };
|
|
134
|
+
/**
|
|
135
|
+
* 本区域的空间约束(逃生门)。缺省 = 与其余区域等分(`sizing: 'fill'`)。
|
|
136
|
+
*
|
|
137
|
+
* **这是缺省,不是推断**:从 `bound_to` 反推"主区该宽一些"是一个关于视觉设计的
|
|
138
|
+
* 猜测,不是关于信息对象的事实(铁律三不许猜)。要主从不等分就写出来(铁律一)。
|
|
139
|
+
*/
|
|
140
|
+
layout?: { sizing?: string; width?: string; min?: string; max?: string; priority?: number };
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** 演绎出的一个界面节点。`children` 是字段级节点 */
|
|
144
|
+
export interface SomaOouiNode {
|
|
145
|
+
/** 交互形态(§3.2 十九形态之一) */
|
|
146
|
+
form: string;
|
|
147
|
+
/** 选中的组件契约名;`#text` 表示纯文本节点 */
|
|
148
|
+
component: string;
|
|
149
|
+
/** 组件所在层:atom / composite / solution / template / text-node */
|
|
150
|
+
layer: string;
|
|
151
|
+
/** 控制模型:autonomous(自治型)/ controlled(受控型) */
|
|
152
|
+
control_model: string;
|
|
153
|
+
/** 命中的规则名——"为什么是这个组件"的答案 */
|
|
154
|
+
rule: string;
|
|
155
|
+
/** `display` 形态的呈现细分 */
|
|
156
|
+
variant?: string;
|
|
157
|
+
/** 字段级节点指向的字段键;根节点没有 */
|
|
158
|
+
field?: string;
|
|
159
|
+
/** 组件 emit → 语义事件的接线 */
|
|
160
|
+
events?: Array<{ emit: string; kinds: string[] }>;
|
|
161
|
+
children?: SomaOouiNode[];
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* 一个锚点的演绎结果。
|
|
166
|
+
*
|
|
167
|
+
* `html` 是**这一处区域真正要出现在浏览器里的那份 DOM**——没有它,整条演绎链
|
|
168
|
+
* 止于 `deduce()` 的返回值:六层全绿、产物齐全、页面上什么都没有。
|
|
169
|
+
* 那种"通了"最像成功:`ooui_artifact` 在资产里、样式表注入了、
|
|
170
|
+
* 锚点还是空的,而空锚点与"这块本来就没写内容"长得一模一样。
|
|
171
|
+
*
|
|
172
|
+
* ── 为什么 html 挂在 region 上而不是挂在整页产物上 ──────────────────
|
|
173
|
+
* 落点是**逐锚点**的:每份 html 要插进它自己那个 `data-soma-id` 容器里。
|
|
174
|
+
* 挂在页面级只能得到一份拼接串,运行时再去拆——拆的判据就是第二份发射器语法,
|
|
175
|
+
* 而两份语法漂开时页面照样渲染,只是某一块插错了容器。
|
|
176
|
+
*
|
|
177
|
+
* ── 为什么没有 `html_key`(对照 `css_key`)────────────────────────
|
|
178
|
+
* `css` 要进的是**全局**的 `<style>` 去重表(`injectStyleOnce` 同键不同内容
|
|
179
|
+
* 静默保留第一份),所以它必须内容寻址。`html` 的落点是页面里那个锚点元素本身,
|
|
180
|
+
* 天然逐页隔离,没有跨页共用一个键的面。运行时仍按内容变化决定要不要重插
|
|
181
|
+
* (见 `soma-bootstrap.ts` 的 `installOouiHtml`),但那个标记是**运行时的**,
|
|
182
|
+
* 不是产物字段——把它写进产物等于让产物记住某一次挂载的过程。
|
|
183
|
+
*/
|
|
184
|
+
export interface SomaOouiRegion {
|
|
185
|
+
/** HTML 锚点 id(`data-soma-id`) */
|
|
186
|
+
anchor: string;
|
|
187
|
+
/** 演绎所依据的数据对象名 */
|
|
188
|
+
object: string;
|
|
189
|
+
/** 演绎所依据的动词 */
|
|
190
|
+
verb: string;
|
|
191
|
+
root: SomaOouiNode;
|
|
192
|
+
/**
|
|
193
|
+
* 这一处区域发射出的 DOM:`区域外壳 > 根构件` 两层,**到组件边界为止**
|
|
194
|
+
* (架构 D4;字段级落 `root.children` 与构件层的 `bindings.fields`,不摊成基础件拼装)。
|
|
195
|
+
*
|
|
196
|
+
* **不含任何内联事件处理器**(架构 §24.1):事件走 `eventConfig`,不进 DOM 属性。
|
|
197
|
+
* 由 `core/build/ooui/artifact/emit-html.ts` 产出并当场过闸门
|
|
198
|
+
* (`OOUI-ART-INLINE-HANDLER` / `OOUI-ART-CLASS-UNKNOWN`)。
|
|
199
|
+
*
|
|
200
|
+
* 运行时**仍然不信它**:它随 `_ui.yaml` 走,而那份资产可以被手写、被改。
|
|
201
|
+
* 发布期的注入面静态扫描今天**也扫这一面**(`declaration-safety-scan.ts` 把禁用标签 /
|
|
202
|
+
* 内联 on* / srcdoc / 伪协议四条判据一并施加到四个 YAML 面上,按文本扫),
|
|
203
|
+
* 但它守的是"写进声明仓库"这个入口——绕过 Registry 直接构建、或发布后再改资产的路
|
|
204
|
+
* 它一条都拦不到。所以注入前还要再过一道结构闸门:两道是纵深,不是重复,
|
|
205
|
+
* "引擎生成的"与"可信的"不是同一句话。
|
|
206
|
+
*/
|
|
207
|
+
html: string;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* 整页演绎产物。**构建期产物,不手写**。
|
|
212
|
+
*
|
|
213
|
+
* `css` 与 `css_key` 成对出现或成对缺席:
|
|
214
|
+
* 注入键必须是**内容哈希**(`ooui:<sha256 前 8 位>`),不能是语义名。
|
|
215
|
+
* 理由在 `pack-styles.ts` 的 `injectOnce` 里——它没有内容冲突检测:
|
|
216
|
+
*
|
|
217
|
+
* if (!css.trim() || injected.has(key)) return; // 同键不同内容 → 静默保留第一份
|
|
218
|
+
*
|
|
219
|
+
* 按 `(对象, 动词)` 之类的语义名命名,SPA 内路由切到同键不同产物的页面时
|
|
220
|
+
* **会继续用上一页的 CSS**,页面看着渲染正常、间距全错,控制台一行都没有。
|
|
221
|
+
* 内容哈希让"同键"与"同内容"变成同一件事,顺带把内容寻址提前一半。
|
|
222
|
+
*/
|
|
223
|
+
export interface SomaPageOouiArtifact {
|
|
224
|
+
/** 产物格式版本。运行时读到不认识的版本整份忽略并告警,不猜字段 */
|
|
225
|
+
version: 1;
|
|
226
|
+
/** 按锚点名升序——同一份声明必须产出同一份字节(§19.3 幂等) */
|
|
227
|
+
regions: SomaOouiRegion[];
|
|
228
|
+
/**
|
|
229
|
+
* 空间层产物:布局解的容器查询 + 原子类规则,整页合并去重后的一份。
|
|
230
|
+
* 区域一个原子类都没产出时才缺席——那时也不该发一份空 `<style>`。
|
|
231
|
+
*/
|
|
232
|
+
css?: string;
|
|
233
|
+
/** `css` 的注入键:`ooui:<sha256 前 8 位>` */
|
|
234
|
+
css_key?: string;
|
|
235
|
+
}
|
|
236
|
+
|
|
87
237
|
/**
|
|
88
238
|
* UI 配置顶层结构
|
|
89
239
|
* 对应 _ui.yaml 文件的完整结构
|
|
@@ -120,17 +270,17 @@ export interface UiConfig {
|
|
|
120
270
|
layout?: Record<string, SomaLayoutConstraint>;
|
|
121
271
|
/** 构建期求解产物:只含容器查询 + flex 的 CSS(CL-2),运行时按页注入一次 */
|
|
122
272
|
layoutCss?: string;
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
|
|
273
|
+
/**
|
|
274
|
+
* OOUI 演绎声明(REQ-014,保留键,可选):锚点 id → 一处演绎请求。
|
|
275
|
+
*
|
|
276
|
+
* 与 `layout` 同一条纪律:**未声明时编译产物与接线前字节级一致**——
|
|
277
|
+
* 页面不写 `ooui:`,整条演绎链一行都不跑,运行时也拿不到任何新字段。
|
|
278
|
+
*
|
|
279
|
+
* 它的产物是 `oouiArtifact`。演绎只在构建期(`compilePageDeclaration`)发生;
|
|
280
|
+
* 运行时若收到的是声明本身而没有产物,说明这页没走构建期编译——
|
|
281
|
+
* 引擎只告警、不代为演绎(求解器不进 client,与 CL-4 同)。
|
|
282
|
+
*/
|
|
283
|
+
ooui?: Record<string, SomaOouiRequestDeclaration>;
|
|
284
|
+
/** 构建期演绎产物(REQ-014):区域 → 组件 + 事件接线,附空间层样式表 */
|
|
285
|
+
oouiArtifact?: SomaPageOouiArtifact;
|
|
136
286
|
}
|
package/dist/cli/soma.js
CHANGED
|
@@ -9,24 +9,36 @@ const node_fs_1 = __importDefault(require("node:fs"));
|
|
|
9
9
|
const node_path_1 = __importDefault(require("node:path"));
|
|
10
10
|
const args = process.argv.slice(2);
|
|
11
11
|
const command = args[0] || 'dev';
|
|
12
|
-
|
|
12
|
+
// 委派给 bin/soma-inline.cjs 的命令。soma-inline.cjs 不随包发布,所以这一组在装出去的包里
|
|
13
|
+
// 跑不起来——《框架接入指南》一.2 如实标着「当前不可用」。手册里写着可用的命令
|
|
14
|
+
// (component / pack / db / migrate / eject)都在下面各走自己的 bin,不经过这里。
|
|
15
|
+
const delegated = ['doctor', 'sync', 'lsp', 'codegen', 'init', 'package-vscode'];
|
|
13
16
|
const packageRoot = node_path_1.default.resolve(__dirname, '../..');
|
|
14
|
-
// REQ-009 EC-1/2/3
|
|
15
|
-
// 与
|
|
17
|
+
// `soma component eject|diff|upgrade` 与 `soma pack init`(REQ-009 EC-1/2/3 + REQ-010 F-45)。
|
|
18
|
+
// 与 db 同一分派方式:自有 bin、独立进程——它们只读写文件,不需要 Next 工作区那一整套装配。
|
|
19
|
+
// (这一段曾经原样重复了一份,第二份永远走不到。)
|
|
16
20
|
if (command === 'component' || command === 'pack') {
|
|
17
21
|
const child = (0, node_child_process_1.spawnSync)(process.execPath, [node_path_1.default.join(packageRoot, 'bin', 'component.cjs'), ...args], { cwd: process.cwd(), stdio: 'inherit', env: process.env });
|
|
18
22
|
process.exit(child.status === null ? 1 : child.status);
|
|
19
23
|
}
|
|
20
|
-
// `soma component eject|diff` 与 `soma pack init`(REQ-009 EC-1/2/3)。
|
|
21
|
-
// 与 db 同一分派方式:它们有自己的 bin,不走 soma-inline 的页面固化那条线。
|
|
22
|
-
if (command === 'component' || command === 'pack') {
|
|
23
|
-
const child = (0, node_child_process_1.spawnSync)(process.execPath, [node_path_1.default.join(packageRoot, 'bin', 'component.cjs'), command, ...args.slice(1)], { cwd: process.cwd(), stdio: 'inherit', env: process.env });
|
|
24
|
-
process.exit(child.status === null ? 1 : child.status);
|
|
25
|
-
}
|
|
26
24
|
if (command === 'db') {
|
|
27
25
|
const child = (0, node_child_process_1.spawnSync)(process.execPath, [node_path_1.default.join(packageRoot, 'bin', 'soma-db.cjs'), ...args.slice(1)], { cwd: process.cwd(), stdio: 'inherit', env: process.env });
|
|
28
26
|
process.exit(child.status === null ? 1 : child.status);
|
|
29
27
|
}
|
|
28
|
+
// `soma migrate`(平铺 → 块声明)。与 db 同一分派方式:自有 bin、独立进程、只读写页面声明。
|
|
29
|
+
// 曾经只有 soma-inline.cjs 路由它——而发布入口走的是本文件编译出的 dist/cli/soma.js,
|
|
30
|
+
// 装出去的包里 `soma migrate` 直接落进 Usage,手册里写着的命令用户一条都跑不起来。
|
|
31
|
+
if (command === 'migrate') {
|
|
32
|
+
const child = (0, node_child_process_1.spawnSync)(process.execPath, [node_path_1.default.join(packageRoot, 'bin', 'migrate.cjs'), ...args], { cwd: process.cwd(), stdio: 'inherit', env: process.env });
|
|
33
|
+
process.exit(child.status === null ? 1 : child.status);
|
|
34
|
+
}
|
|
35
|
+
// `soma eject <页面名>`(运行态 → 开发态)。曾经委派给 soma-inline.cjs——那个文件不随包发布,
|
|
36
|
+
// 装出去的包里这条命令一跑就 "Cannot find module"。改成与 db / migrate 同一分派方式。
|
|
37
|
+
// eject 作用于"我现在所在的宿主目录":cwd 与 SOMA_INVOKE_CWD 都取调用方的(与委派时同一语义)。
|
|
38
|
+
if (command === 'eject') {
|
|
39
|
+
const child = (0, node_child_process_1.spawnSync)(process.execPath, [node_path_1.default.join(packageRoot, 'bin', 'eject.cjs'), ...args], { cwd: process.cwd(), stdio: 'inherit', env: { ...process.env, SOMA_INVOKE_CWD: process.cwd() } });
|
|
40
|
+
process.exit(child.status === null ? 1 : child.status);
|
|
41
|
+
}
|
|
30
42
|
function lstatIfPresent(filePath) {
|
|
31
43
|
try {
|
|
32
44
|
return node_fs_1.default.lstatSync(filePath);
|
|
@@ -435,8 +447,9 @@ function ensureNextWorkspace(hostDir) {
|
|
|
435
447
|
}
|
|
436
448
|
if (delegated.includes(command)) {
|
|
437
449
|
// 用 packageRoot 而不是 __dirname:编译产物在 dist/cli/ 下,那里没有 soma-inline.cjs,
|
|
438
|
-
// 于是全部 delegated 命令(doctor/sync/lsp/codegen/init
|
|
450
|
+
// 于是全部 delegated 命令(doctor/sync/lsp/codegen/init)一走 dist 就报
|
|
439
451
|
// "Cannot find module"。源码目录跑得通、装出去就坏,是最难发现的一类路径 bug。
|
|
452
|
+
// (bin/soma-inline.cjs 本身也不在 package.json 的 files 里——见 delegated 的注释。)
|
|
440
453
|
const inline = node_path_1.default.join(packageRoot, 'bin', 'soma-inline.cjs');
|
|
441
454
|
const child = (0, node_child_process_1.spawnSync)(process.execPath, [inline, command, ...args.slice(1)], {
|
|
442
455
|
cwd: packageRoot,
|
|
@@ -448,7 +461,7 @@ if (delegated.includes(command)) {
|
|
|
448
461
|
process.exit(child.status === null ? 1 : child.status);
|
|
449
462
|
}
|
|
450
463
|
if (!['dev', 'build', 'start'].includes(command)) {
|
|
451
|
-
console.error(`Usage: soma <dev|build|start|db|component|pack|${delegated.join('|')}> [...args]`);
|
|
464
|
+
console.error(`Usage: soma <dev|build|start|db|component|pack|migrate|eject|${delegated.join('|')}> [...args]`);
|
|
452
465
|
process.exit(1);
|
|
453
466
|
}
|
|
454
467
|
const nextBin = resolveNextBin();
|