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
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OOUI 声明与产物的共享字面量:全体系唯一真源(REQ-014)。
|
|
3
|
+
*
|
|
4
|
+
* ── 为什么单独一个模块 ─────────────────────────────────────────────
|
|
5
|
+
* 这里的每一样东西都被**隔着依赖闸门的几方**同时消费:
|
|
6
|
+
*
|
|
7
|
+
* · 运行时解析器 `client/parser/ui-config-parser.ts`——client 不许 import `core/build`
|
|
8
|
+
* (`verify:client-dep-graph`);
|
|
9
|
+
* · 构建期引擎 `build/ooui/**` 的编排层、页面组合层、空间层与产物层——
|
|
10
|
+
* 层与层之间只许单向看(`verify-ooui-dep-graph`),产物层够不着构件层,
|
|
11
|
+
* 空间层与产物层谁都够不着页面组合层。
|
|
12
|
+
*
|
|
13
|
+
* 此前的结果是同一件事在各处各抄一份,且抄本宽严不一:锚点文法抄成三份
|
|
14
|
+
* (`1list` 过得了页面组合、到产物层才红;`_list` 过得了解析器、到页面组合才红),
|
|
15
|
+
* 演绎请求的键闭集抄成两份(解析器那份收下 `bound_to` / `layout` 却不搬进声明),
|
|
16
|
+
* `'#text'` 在构件层是常量、在产物层是两处字面量。每一份单看都对,
|
|
17
|
+
* 只是报错总落在比写错那一行晚一两层的地方——或者干脆不报。
|
|
18
|
+
*
|
|
19
|
+
* `core/shared/**` 是唯一几方都 import 得到的位置(与 `container-breakpoints.ts` 同一形态):
|
|
20
|
+
* 纯字面量与纯函数,除同在 `core/shared` 的纯字面量闭集(`SOMA_LAYOUT_SIZINGS`)外只 import 类型,
|
|
21
|
+
* 不牵连任何运行时模块。
|
|
22
|
+
*/
|
|
23
|
+
import { type SomaSizing } from './types/layout-constraint.types';
|
|
24
|
+
import type { SomaOouiRequestDeclaration } from './types/ui-config.types';
|
|
25
|
+
/**
|
|
26
|
+
* `ooui:` 的锚点名 = 页面组合的区域名 = 空间 IR 的节点 id。**三处是同一个名字,所以是同一条文法。**
|
|
27
|
+
*
|
|
28
|
+
* 锚点名就是区域名(`compilePageOoui` 拿锚点当区域名),区域名就是 IR 叶子的 id
|
|
29
|
+
* (`solvePageBudget` 原样放进去),产物层再按它派生 `<锚点>-shell` / `<锚点>-root`。
|
|
30
|
+
* 它会原样进 DOM 属性与 CSS 属性选择器:放开引号、括号、空格等于给选择器注入留门,
|
|
31
|
+
* 而注入成功的表现是页面照常渲染。
|
|
32
|
+
*
|
|
33
|
+
* 取「字母或下划线开头」:与运行时解析器一直收的、`layout:` 段锚点键用的是同一条
|
|
34
|
+
* (SOMA 标识符的通行写法);数字开头不收——`data-soma-id="1"` 是合法 HTML,
|
|
35
|
+
* 但读不出它指的是什么。
|
|
36
|
+
*/
|
|
37
|
+
export declare const SOMA_OOUI_ANCHOR_PATTERN: RegExp;
|
|
38
|
+
/**
|
|
39
|
+
* 同一条文法的人话版本。错误消息只引用它,不各写一句——
|
|
40
|
+
* 此前三份消息分别写着「字母开头」「字母或数字开头」,与各自的正则一起漂开。
|
|
41
|
+
*/
|
|
42
|
+
export declare const SOMA_OOUI_ANCHOR_GRAMMAR = "\u5B57\u6BCD\u6216\u4E0B\u5212\u7EBF\u5F00\u5934\uFF0C\u5176\u4F59\u53EF\u542B\u5B57\u6BCD\u3001\u6570\u5B57\u3001- \u4E0E _";
|
|
43
|
+
/**
|
|
44
|
+
* 一条演绎请求允许的键——闭集,写错一个字母必须当场红。
|
|
45
|
+
*
|
|
46
|
+
* 运行时解析器与构建期编译器各校一次形状(前者服务直接喂源 YAML 的路径,
|
|
47
|
+
* 后者是发布主路径),两处用的**是这一份**。顺序即书写顺序,错误消息按它列出可用键。
|
|
48
|
+
*/
|
|
49
|
+
export declare const SOMA_OOUI_REQUEST_KEYS: readonly (keyof SomaOouiRequestDeclaration)[];
|
|
50
|
+
/** 声明里 `layout` 的形状(区域的空间约束逃生门) */
|
|
51
|
+
export type SomaOouiLayoutDeclaration = NonNullable<SomaOouiRequestDeclaration['layout']>;
|
|
52
|
+
/**
|
|
53
|
+
* `layout` 允许的键——**白名单**。
|
|
54
|
+
*
|
|
55
|
+
* 为什么必须是白名单而不是"原样摊进去":区域的约束会被摊进空间 IR 的叶子节点,
|
|
56
|
+
* 而叶子节点上还有 `id` / `kind` / `anchor` / `classes` 这些**结构键**。
|
|
57
|
+
* 放行一个 `layout: { id: x }`,叶子就被改了名,求解结果里再也找不到这个区域——
|
|
58
|
+
* 此前那里读成 0rem,于是这个区域静默降到最窄的候选,页面照常渲染。
|
|
59
|
+
*/
|
|
60
|
+
export declare const SOMA_OOUI_LAYOUT_KEYS: readonly (keyof SomaOouiLayoutDeclaration)[];
|
|
61
|
+
/**
|
|
62
|
+
* 尺寸意图三档(`fixed` 就这么宽 / `hug` 内容多宽我多宽 / `fill` 剩下的给我)。顺序即文档书写序。
|
|
63
|
+
*
|
|
64
|
+
* 此前没有任何一层核 `ooui:` 区域的 sizing——解析器、编译器、页面组合层都只核"是不是字符串",
|
|
65
|
+
* 空间层求解器拿到什么就摊进约束。写成 `sizing: fil` 的区域既不是 fixed 也不是 fill,
|
|
66
|
+
* 求解器按"从 min 起步、不参与分余量"处理,于是它**静默缩到下界**(没写 min 就是 0rem),
|
|
67
|
+
* 一路喂进构件选型——这一块降到最窄的候选,页面照常渲染。
|
|
68
|
+
*
|
|
69
|
+
* 三方都要用它:运行时解析器(client 不许 import `core/build`)、编译器与页面组合层
|
|
70
|
+
* (声明期就指着写错的那一行报)、空间层求解器(IR 树的最后一道)。
|
|
71
|
+
* **它不是一份抄本,是 `SOMA_LAYOUT_SIZINGS` 本身**(`shared/types/layout-constraint.types.ts`,
|
|
72
|
+
* 在那里以 `SomaSizing` 做 `satisfies` 对账):`layout:` 段的解析器认的也是那一份。
|
|
73
|
+
* 此前这里自持一份、解析器又自持一份,两份逐字相同,漂开的那天没有断言会红。
|
|
74
|
+
*/
|
|
75
|
+
export declare const SOMA_OOUI_SIZINGS: readonly SomaSizing[];
|
|
76
|
+
/** 值是不是三档之一。非字符串一律不是——`sizing: 1` 不该被 `String()` 顶成 `'1'` 再比 */
|
|
77
|
+
export declare function isOouiSizing(value: unknown): value is SomaSizing;
|
|
78
|
+
/** `layout` 里第一处不合形状的键:闭集之外的键、值的原始类型不对,或 sizing 不在三档里 */
|
|
79
|
+
export interface SomaOouiLayoutProblem {
|
|
80
|
+
readonly key: string;
|
|
81
|
+
readonly kind: 'unknown-key' | 'value-type' | 'sizing-unknown';
|
|
82
|
+
/** `value-type` 时:这个键要的原始类型 */
|
|
83
|
+
readonly expected?: 'string' | 'number';
|
|
84
|
+
}
|
|
85
|
+
/** 映射(非 null、非数组的对象)。YAML 里 `~` / 列表 / 标量都不是 */
|
|
86
|
+
export declare function isOouiMap(value: unknown): value is Record<string, unknown>;
|
|
87
|
+
/** 非空白字符串:`object` / `verb` / `through` / `form` 与 `bound_to` 两项的形状判据 */
|
|
88
|
+
export declare function isOouiText(value: unknown): value is string;
|
|
89
|
+
/**
|
|
90
|
+
* `focus`:非空、且每一项都是非空白字段名。
|
|
91
|
+
*
|
|
92
|
+
* 空数组单独拦:`focus: []` 读起来像"不限",实际演绎出一个没有字段的界面——
|
|
93
|
+
* 框架在、标题在、空白在,是最像成功的失败。"全部字段"的写法是省略 focus。
|
|
94
|
+
*/
|
|
95
|
+
export declare function isOouiFocus(value: unknown): value is string[];
|
|
96
|
+
/** 声明里 `bound_to` 的形状(区域间联动的来源) */
|
|
97
|
+
export type SomaOouiBindingDeclaration = NonNullable<SomaOouiRequestDeclaration['bound_to']>;
|
|
98
|
+
/** `bound_to` 允许的键。解析器与编译器的"未知键"错误都按它列出可用键 */
|
|
99
|
+
export declare const SOMA_OOUI_BINDING_KEYS: readonly (keyof SomaOouiBindingDeclaration)[];
|
|
100
|
+
/**
|
|
101
|
+
* `bound_to` 里第一个闭集之外的键(按书写序);没有则 undefined。
|
|
102
|
+
*
|
|
103
|
+
* 收 `object` 而不是映射类型:页面组合层拿到的是已经带类型的 `SomaRegionBinding`,
|
|
104
|
+
* 那里多出来的键同样要报,而接口类型不能直接当 `Record<string, unknown>` 用。
|
|
105
|
+
*/
|
|
106
|
+
export declare function findOouiBindingUnknownKey(binding: object): string | undefined;
|
|
107
|
+
/**
|
|
108
|
+
* `bound_to`:恰好 `{ region, as }` 两项、且都是非空白字符串的映射。
|
|
109
|
+
*
|
|
110
|
+
* 多一个键也不算合形状——判据若只看两项齐不齐,多出来的键就会一路被当成"合法、只是没用上"。
|
|
111
|
+
* 调用方要报**哪个键**多了时先调 `findOouiBindingUnknownKey`(与 `findOouiLayoutProblem` 同一形态)。
|
|
112
|
+
*/
|
|
113
|
+
export declare function isOouiBinding(value: unknown): value is SomaOouiBindingDeclaration;
|
|
114
|
+
/**
|
|
115
|
+
* 找 `layout` 里第一处不合形状的键。合形状返回 undefined。
|
|
116
|
+
*
|
|
117
|
+
* 核三件:**键**在白名单里、**值的原始类型**对、**sizing 在三档里**。
|
|
118
|
+
* priority 的四档与长度单位仍由空间层的求解器核(长度要拿到容器宽才折算得出来)。
|
|
119
|
+
*
|
|
120
|
+
* sizing 的闭集此前刻意不在这里核("闭集归空间层"),结果是**哪一层都没核**:
|
|
121
|
+
* 空间层求解器也只是把它摊进约束。现在它是 `SOMA_OOUI_SIZINGS` 这一份——类型的运行时镜像;
|
|
122
|
+
* 解析器、编译器、页面组合层都经本函数判,空间层求解器按同一份常量兜 IR 树的最后一道。
|
|
123
|
+
*/
|
|
124
|
+
export declare function findOouiLayoutProblem(layout: Readonly<Record<string, unknown>>): SomaOouiLayoutProblem | undefined;
|
|
125
|
+
/** `layout` 合形状:映射、键全在白名单里、值的原始类型对、sizing 在三档里 */
|
|
126
|
+
export declare function isOouiLayout(value: unknown): value is SomaOouiLayoutDeclaration;
|
|
127
|
+
/**
|
|
128
|
+
* 纯文本节点的组件名占位:**不是组件**(`SomaOouiNode.component` 的一个取值)。
|
|
129
|
+
*
|
|
130
|
+
* 构件层选型时产出它,产物层发射时按它分支(落成 `<span>`、不写 `data-soma-component`)。
|
|
131
|
+
* 两层之间隔着依赖闸门(产物层回看构件层判 `SKIP-BACK`),所以常量住在两边都够得着的这里。
|
|
132
|
+
* 各写一个 `'#text'` 字面量的话,改名那天只改了一边,另一边的判断静默失配——
|
|
133
|
+
* 纯文本字段被当成一个叫 `#text` 的组件去挂载,查不到契约就跳过,那一格永远空着。
|
|
134
|
+
*/
|
|
135
|
+
export declare const SOMA_TEXT_NODE = "#text";
|
|
@@ -116,12 +116,13 @@ export interface SomaComponentContract {
|
|
|
116
116
|
* 依赖的其它组件(REQ-010 F-46):PascalCase 契约名数组。
|
|
117
117
|
*
|
|
118
118
|
* 两件事靠它:
|
|
119
|
-
* ①
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
119
|
+
* ① **eject 说得出副本还需要谁**——`soma component eject` 一个 TreeSelect 时列出它还要 Tree
|
|
120
|
+
* (仍从 soma-ui 取,要在宿主注册表里可解析),而不是等页面渲染出一堆没样式的节点才发现
|
|
121
|
+
* (这条曾真实发生过:`COMPONENT_CSS_DEPS` 少写一条 `TreeSelect: ['Tree']`,
|
|
122
|
+
* 页面上是无样式的折叠箭头);
|
|
123
|
+
* ② **与 CSS 依赖表对账**——`build/component/component-graph.ts` 按它建图,
|
|
124
|
+
* soma-ui 的 `component-css-deps` 测试拿图与 `COMPONENT_CSS_DEPS` 逐项对账,
|
|
125
|
+
* 漏登记的那一条当场红。
|
|
125
126
|
*
|
|
126
127
|
* 只登记**契约级**依赖(模板里真的嵌了那个组件、或 CSS 分片依赖它),
|
|
127
128
|
* 不登记共享资产(`shared/*` 由构建图自然带上,写进来只会重复一份且会漂)。
|
|
@@ -77,6 +77,82 @@ export interface SomaDataFieldConfig {
|
|
|
77
77
|
* 而"写了没反应"是最难查的一类。
|
|
78
78
|
*/
|
|
79
79
|
calc?: string;
|
|
80
|
+
/**
|
|
81
|
+
* 修饰关系(REQ-014 §15.3 原型实测补入):本字段是**另一个字段的修饰**,
|
|
82
|
+
* 不独立呈现。典型是 `status_tone` 修饰 `status_text`——语气、单位、币种、
|
|
83
|
+
* 图标、趋势方向都属此类。
|
|
84
|
+
*
|
|
85
|
+
* 不声明的后果是静默的:修饰字段会被当成一个普通只读字段各占一格,
|
|
86
|
+
* 页面上出现一排空的 `status_tone: —` `priority_tone: —`。它不报错、
|
|
87
|
+
* 不影响功能,只是"这页看着有点乱"——而这句话没人会当成 bug 报上来。
|
|
88
|
+
* 原型跑出来第一眼看到的就是这个(§15.3 缺口 1)。
|
|
89
|
+
*
|
|
90
|
+
* 约束(解析期强制):目标必须是同一本字典里的**另一个**字段,且目标自己
|
|
91
|
+
* 不能再带 `modifies`——修饰不可级联。级联的话"谁是被呈现的那个"就没有唯一答案,
|
|
92
|
+
* 而这种歧义在渲染期只会表现为"少显示了一格"。
|
|
93
|
+
*/
|
|
94
|
+
modifies?: string;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* 对象级角色(REQ-014 §3.1.2):哪个字段承担什么**语义位**。
|
|
98
|
+
*
|
|
99
|
+
* 它要替换掉的是"靠字段名猜"。今天 `pickField` 一类的做法用别名表匹配
|
|
100
|
+
* (`title` / `name` / `label` …)去猜标题字段,猜错了表现为"标题栏显示订单备注",
|
|
101
|
+
* 而这条猜测既不出现在声明里也不出现在日志里,**没有任何地方可查**。
|
|
102
|
+
* 声明了 `roles` 之后,"谁是标题"是作者写的事实,不是系统的运气。
|
|
103
|
+
*
|
|
104
|
+
* 全部可选、值都是**本对象字段字典里的字段名**(解析期对账,指错当场红)。
|
|
105
|
+
*/
|
|
106
|
+
export interface SomaDataObjectRoles {
|
|
107
|
+
/** 身份:这一行/这个对象的唯一键 */
|
|
108
|
+
id?: string;
|
|
109
|
+
/** 展示这个对象时拿什么当标题 */
|
|
110
|
+
title?: string;
|
|
111
|
+
/** 副标题 */
|
|
112
|
+
subtitle?: string;
|
|
113
|
+
/** 生命周期状态,驱动状态位与语气 */
|
|
114
|
+
status?: string;
|
|
115
|
+
/** 时间轴默认依据 */
|
|
116
|
+
timestamp?: string;
|
|
117
|
+
/** 金额,决定右对齐与货币格式 */
|
|
118
|
+
amount?: string;
|
|
119
|
+
/**
|
|
120
|
+
* 对比基准(§27.3 盲测补入):指向标记基准项的字段(如 `is_control`)。
|
|
121
|
+
*
|
|
122
|
+
* 缺它则对比无锚点——"+12%" 不知道是相对谁。而"相对谁"错了的界面
|
|
123
|
+
* 看起来完全正常:数字在、箭头在、颜色也在,只是符号反了。
|
|
124
|
+
*/
|
|
125
|
+
baseline?: string;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* 全部合法角色名(封闭集),供两条书写路径的解析器共用。
|
|
129
|
+
*
|
|
130
|
+
* **不要在解析器里再手抄一份**——字段类型表已经因为手抄漂成过四份
|
|
131
|
+
* (见本文件 `SomaDataFieldType` 的头注释),角色表没有理由重走一遍。
|
|
132
|
+
*/
|
|
133
|
+
export declare const SOMA_DATA_OBJECT_ROLES: readonly (keyof SomaDataObjectRoles)[];
|
|
134
|
+
/** 关系基数:一对一 / 一对多。封闭集 */
|
|
135
|
+
export type SomaDataRelationCardinality = 'one' | 'many';
|
|
136
|
+
/** 全部合法基数(封闭集),解析器共用 */
|
|
137
|
+
export declare const SOMA_DATA_RELATION_CARDINALITIES: readonly SomaDataRelationCardinality[];
|
|
138
|
+
/**
|
|
139
|
+
* 对象间关系(REQ-014 §3.1.2)。
|
|
140
|
+
*
|
|
141
|
+
* 为什么必须显式声明:`compare` 与 `navigate` 两个动词的作用对象**往往不是主对象**
|
|
142
|
+
* (§27.2 盲测)——要比的是"一个实验内部的多个变体",要导航的必然是关系的另一端。
|
|
143
|
+
* 没有关系声明,这两个动词(占八动词封闭集的 25%)表达不出来;
|
|
144
|
+
* 靠字段名后缀猜关系(`xxx_id` → `xxx`)猜错时表现为"点进去是另一个对象的详情",
|
|
145
|
+
* 而页面本身渲染得好好的。
|
|
146
|
+
*/
|
|
147
|
+
export interface SomaDataObjectRelation {
|
|
148
|
+
/** 关系名(对象内唯一),`through` 按它引用 */
|
|
149
|
+
name: string;
|
|
150
|
+
/** 目标对象名(必须是同一份声明里已声明的数据对象) */
|
|
151
|
+
to: string;
|
|
152
|
+
/** 基数 */
|
|
153
|
+
cardinality: SomaDataRelationCardinality;
|
|
154
|
+
/** 本对象上的外键字段(可选;给了就必须在本对象字典里) */
|
|
155
|
+
via?: string;
|
|
80
156
|
}
|
|
81
157
|
/**
|
|
82
158
|
* 单个取数来源:一个后端接口 + 参数 + 聚合位置。
|
|
@@ -144,6 +220,16 @@ export interface SomaDataObjectConfig {
|
|
|
144
220
|
fields?: Record<string, SomaDataFieldConfig>;
|
|
145
221
|
/** mock 样本:SOMA_MOCK_ENABLED / 接口失败兜底 / 无接口预览 */
|
|
146
222
|
mock?: unknown;
|
|
223
|
+
/**
|
|
224
|
+
* 对象级角色(REQ-014 §3.1.2):哪个字段承担什么语义位。
|
|
225
|
+
* 声明它等于把"谁是标题/状态/金额/基准"从系统的猜测变成作者的事实。
|
|
226
|
+
*/
|
|
227
|
+
roles?: SomaDataObjectRoles;
|
|
228
|
+
/**
|
|
229
|
+
* 与其他对象的关系(REQ-014 §3.1.2)。
|
|
230
|
+
* `SomaSemanticRequest.through` 按 `name` 引用它,`compare` / `navigate` 靠它成立。
|
|
231
|
+
*/
|
|
232
|
+
relations?: SomaDataObjectRelation[];
|
|
147
233
|
/** 写通道声明(§8);不给 = 该对象只读 */
|
|
148
234
|
write?: SomaDataWriteConfig;
|
|
149
235
|
/**
|
|
@@ -77,24 +77,3 @@ export interface ValidationResult {
|
|
|
77
77
|
/** 各字段的错误消息集合 */
|
|
78
78
|
errors: Record<string, string[]>;
|
|
79
79
|
}
|
|
80
|
-
/**
|
|
81
|
-
* 业务事件处理函数签名
|
|
82
|
-
* 所有被 _event.yaml 引用的方法必须符合此签名
|
|
83
|
-
*/
|
|
84
|
-
export interface SomaEventHandler {
|
|
85
|
-
(...args: any[]): Promise<boolean> | boolean | void;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* 常量对象接口
|
|
89
|
-
* 提供静态枚举值或配置项
|
|
90
|
-
*/
|
|
91
|
-
export interface SomaConstant {
|
|
92
|
-
readonly [key: string]: any;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* 可加载常量接口
|
|
96
|
-
* 支持从后端加载动态字典数据
|
|
97
|
-
*/
|
|
98
|
-
export interface SomaLoadableConstant extends SomaConstant {
|
|
99
|
-
loadFromAPI(): Promise<void>;
|
|
100
|
-
}
|
|
@@ -10,6 +10,7 @@ export type SomaSizing = 'fixed' | 'hug' | 'fill';
|
|
|
10
10
|
*/
|
|
11
11
|
export declare const SOMA_LAYOUT_PRIORITIES: readonly [250, 500, 750, 1000];
|
|
12
12
|
export type SomaPriority = typeof SOMA_LAYOUT_PRIORITIES[number];
|
|
13
|
+
export declare const SOMA_LAYOUT_SIZINGS: readonly SomaSizing[];
|
|
13
14
|
/** 换行策略:不换 / 窄了就竖排 / 横向滚动成一条卷轴 */
|
|
14
15
|
export type SomaWrap = 'none' | 'below' | 'reel';
|
|
15
16
|
export declare const SOMA_LAYOUT_ALIGNS: readonly ["start", "center", "end", "baseline", "space_between", "space_evenly", "space_around"];
|
|
@@ -72,6 +72,150 @@ export interface ExtendedShowValue {
|
|
|
72
72
|
* - "somaId@html" — HTML 内容注入
|
|
73
73
|
*/
|
|
74
74
|
export type ShowMapping = Record<string, ShowValue>;
|
|
75
|
+
/**
|
|
76
|
+
* 一处演绎请求的声明(`ooui:` 段的一条)。键是 HTML 锚点 id。
|
|
77
|
+
*
|
|
78
|
+
* 这是**表层书写形态**,不是语义层的 `SomaSemanticRequest`:
|
|
79
|
+
* `object` 在这里是页面 `data:` 段里的对象**名**,构建期才解析成对象本体。
|
|
80
|
+
* 运行时拿不到 `data:` 的解析结果(它是另一份资产),所以这里只能是名字。
|
|
81
|
+
*
|
|
82
|
+
* `verb` / `form` 保持 `string`:八动词与十九形态的封闭集住在引擎里
|
|
83
|
+
* (`core/build/ooui/**`),运行时 import 不到。**闭集判定归构建期**
|
|
84
|
+
* (`OOUI-SEM-VERB-UNKNOWN` / `OOUI-INT-FORM-UNKNOWN`),
|
|
85
|
+
* 这里若照抄一份闭集,两份必然漂,而漂掉的表现是"某个动词在运行时被判非法、
|
|
86
|
+
* 在构建期却合法"——两处都看着对,只有页面是错的。
|
|
87
|
+
*/
|
|
88
|
+
export interface SomaOouiRequestDeclaration {
|
|
89
|
+
/** 页面 `data:` 段里的对象名 */
|
|
90
|
+
object: string;
|
|
91
|
+
/** 八动词之一(闭集在构建期查) */
|
|
92
|
+
verb: string;
|
|
93
|
+
/** 只演绎这几个字段;省略 = 全部字段 */
|
|
94
|
+
focus?: string[];
|
|
95
|
+
/** 动词的作用路径:对象 `relations` 里的关系名 */
|
|
96
|
+
through?: string;
|
|
97
|
+
/** 逃生门:直接指定根形态,跳过动词分派 */
|
|
98
|
+
form?: string;
|
|
99
|
+
/**
|
|
100
|
+
* 联动来源(REQ-014 §29.1):本区域监听**另一个区域**的哪个语义事件。
|
|
101
|
+
*
|
|
102
|
+
* `{ region: <另一个锚点>, as: <语义事件> }`。它在**编译期**被裁决:
|
|
103
|
+
* 源区域的动词 / 控制模型 / 选中组件三者合起来若产不出那个事件,当场拒收
|
|
104
|
+
* (`OOUI-SEM-BINDING-UNSUPPORTED`)。这道闸门防的正是"点了左边列表右边没反应"——
|
|
105
|
+
* 那件事运行期不报错:两块都渲染正常、事件也确实发出去了,只是没有人接。
|
|
106
|
+
*/
|
|
107
|
+
bound_to?: {
|
|
108
|
+
region: string;
|
|
109
|
+
as: string;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* 本区域的空间约束(逃生门)。缺省 = 与其余区域等分(`sizing: 'fill'`)。
|
|
113
|
+
*
|
|
114
|
+
* **这是缺省,不是推断**:从 `bound_to` 反推"主区该宽一些"是一个关于视觉设计的
|
|
115
|
+
* 猜测,不是关于信息对象的事实(铁律三不许猜)。要主从不等分就写出来(铁律一)。
|
|
116
|
+
*/
|
|
117
|
+
layout?: {
|
|
118
|
+
sizing?: string;
|
|
119
|
+
width?: string;
|
|
120
|
+
min?: string;
|
|
121
|
+
max?: string;
|
|
122
|
+
priority?: number;
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
/** 演绎出的一个界面节点。`children` 是字段级节点 */
|
|
126
|
+
export interface SomaOouiNode {
|
|
127
|
+
/** 交互形态(§3.2 十九形态之一) */
|
|
128
|
+
form: string;
|
|
129
|
+
/** 选中的组件契约名;`#text` 表示纯文本节点 */
|
|
130
|
+
component: string;
|
|
131
|
+
/** 组件所在层:atom / composite / solution / template / text-node */
|
|
132
|
+
layer: string;
|
|
133
|
+
/** 控制模型:autonomous(自治型)/ controlled(受控型) */
|
|
134
|
+
control_model: string;
|
|
135
|
+
/** 命中的规则名——"为什么是这个组件"的答案 */
|
|
136
|
+
rule: string;
|
|
137
|
+
/** `display` 形态的呈现细分 */
|
|
138
|
+
variant?: string;
|
|
139
|
+
/** 字段级节点指向的字段键;根节点没有 */
|
|
140
|
+
field?: string;
|
|
141
|
+
/** 组件 emit → 语义事件的接线 */
|
|
142
|
+
events?: Array<{
|
|
143
|
+
emit: string;
|
|
144
|
+
kinds: string[];
|
|
145
|
+
}>;
|
|
146
|
+
children?: SomaOouiNode[];
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* 一个锚点的演绎结果。
|
|
150
|
+
*
|
|
151
|
+
* `html` 是**这一处区域真正要出现在浏览器里的那份 DOM**——没有它,整条演绎链
|
|
152
|
+
* 止于 `deduce()` 的返回值:六层全绿、产物齐全、页面上什么都没有。
|
|
153
|
+
* 那种"通了"最像成功:`ooui_artifact` 在资产里、样式表注入了、
|
|
154
|
+
* 锚点还是空的,而空锚点与"这块本来就没写内容"长得一模一样。
|
|
155
|
+
*
|
|
156
|
+
* ── 为什么 html 挂在 region 上而不是挂在整页产物上 ──────────────────
|
|
157
|
+
* 落点是**逐锚点**的:每份 html 要插进它自己那个 `data-soma-id` 容器里。
|
|
158
|
+
* 挂在页面级只能得到一份拼接串,运行时再去拆——拆的判据就是第二份发射器语法,
|
|
159
|
+
* 而两份语法漂开时页面照样渲染,只是某一块插错了容器。
|
|
160
|
+
*
|
|
161
|
+
* ── 为什么没有 `html_key`(对照 `css_key`)────────────────────────
|
|
162
|
+
* `css` 要进的是**全局**的 `<style>` 去重表(`injectStyleOnce` 同键不同内容
|
|
163
|
+
* 静默保留第一份),所以它必须内容寻址。`html` 的落点是页面里那个锚点元素本身,
|
|
164
|
+
* 天然逐页隔离,没有跨页共用一个键的面。运行时仍按内容变化决定要不要重插
|
|
165
|
+
* (见 `soma-bootstrap.ts` 的 `installOouiHtml`),但那个标记是**运行时的**,
|
|
166
|
+
* 不是产物字段——把它写进产物等于让产物记住某一次挂载的过程。
|
|
167
|
+
*/
|
|
168
|
+
export interface SomaOouiRegion {
|
|
169
|
+
/** HTML 锚点 id(`data-soma-id`) */
|
|
170
|
+
anchor: string;
|
|
171
|
+
/** 演绎所依据的数据对象名 */
|
|
172
|
+
object: string;
|
|
173
|
+
/** 演绎所依据的动词 */
|
|
174
|
+
verb: string;
|
|
175
|
+
root: SomaOouiNode;
|
|
176
|
+
/**
|
|
177
|
+
* 这一处区域发射出的 DOM:`区域外壳 > 根构件` 两层,**到组件边界为止**
|
|
178
|
+
* (架构 D4;字段级落 `root.children` 与构件层的 `bindings.fields`,不摊成基础件拼装)。
|
|
179
|
+
*
|
|
180
|
+
* **不含任何内联事件处理器**(架构 §24.1):事件走 `eventConfig`,不进 DOM 属性。
|
|
181
|
+
* 由 `core/build/ooui/artifact/emit-html.ts` 产出并当场过闸门
|
|
182
|
+
* (`OOUI-ART-INLINE-HANDLER` / `OOUI-ART-CLASS-UNKNOWN`)。
|
|
183
|
+
*
|
|
184
|
+
* 运行时**仍然不信它**:它随 `_ui.yaml` 走,而那份资产可以被手写、被改。
|
|
185
|
+
* 发布期的注入面静态扫描今天**也扫这一面**(`declaration-safety-scan.ts` 把禁用标签 /
|
|
186
|
+
* 内联 on* / srcdoc / 伪协议四条判据一并施加到四个 YAML 面上,按文本扫),
|
|
187
|
+
* 但它守的是"写进声明仓库"这个入口——绕过 Registry 直接构建、或发布后再改资产的路
|
|
188
|
+
* 它一条都拦不到。所以注入前还要再过一道结构闸门:两道是纵深,不是重复,
|
|
189
|
+
* "引擎生成的"与"可信的"不是同一句话。
|
|
190
|
+
*/
|
|
191
|
+
html: string;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* 整页演绎产物。**构建期产物,不手写**。
|
|
195
|
+
*
|
|
196
|
+
* `css` 与 `css_key` 成对出现或成对缺席:
|
|
197
|
+
* 注入键必须是**内容哈希**(`ooui:<sha256 前 8 位>`),不能是语义名。
|
|
198
|
+
* 理由在 `pack-styles.ts` 的 `injectOnce` 里——它没有内容冲突检测:
|
|
199
|
+
*
|
|
200
|
+
* if (!css.trim() || injected.has(key)) return; // 同键不同内容 → 静默保留第一份
|
|
201
|
+
*
|
|
202
|
+
* 按 `(对象, 动词)` 之类的语义名命名,SPA 内路由切到同键不同产物的页面时
|
|
203
|
+
* **会继续用上一页的 CSS**,页面看着渲染正常、间距全错,控制台一行都没有。
|
|
204
|
+
* 内容哈希让"同键"与"同内容"变成同一件事,顺带把内容寻址提前一半。
|
|
205
|
+
*/
|
|
206
|
+
export interface SomaPageOouiArtifact {
|
|
207
|
+
/** 产物格式版本。运行时读到不认识的版本整份忽略并告警,不猜字段 */
|
|
208
|
+
version: 1;
|
|
209
|
+
/** 按锚点名升序——同一份声明必须产出同一份字节(§19.3 幂等) */
|
|
210
|
+
regions: SomaOouiRegion[];
|
|
211
|
+
/**
|
|
212
|
+
* 空间层产物:布局解的容器查询 + 原子类规则,整页合并去重后的一份。
|
|
213
|
+
* 区域一个原子类都没产出时才缺席——那时也不该发一份空 `<style>`。
|
|
214
|
+
*/
|
|
215
|
+
css?: string;
|
|
216
|
+
/** `css` 的注入键:`ooui:<sha256 前 8 位>` */
|
|
217
|
+
css_key?: string;
|
|
218
|
+
}
|
|
75
219
|
/**
|
|
76
220
|
* UI 配置顶层结构
|
|
77
221
|
* 对应 _ui.yaml 文件的完整结构
|
|
@@ -108,16 +252,17 @@ export interface UiConfig {
|
|
|
108
252
|
layout?: Record<string, SomaLayoutConstraint>;
|
|
109
253
|
/** 构建期求解产物:只含容器查询 + flex 的 CSS(CL-2),运行时按页注入一次 */
|
|
110
254
|
layoutCss?: string;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
255
|
+
/**
|
|
256
|
+
* OOUI 演绎声明(REQ-014,保留键,可选):锚点 id → 一处演绎请求。
|
|
257
|
+
*
|
|
258
|
+
* 与 `layout` 同一条纪律:**未声明时编译产物与接线前字节级一致**——
|
|
259
|
+
* 页面不写 `ooui:`,整条演绎链一行都不跑,运行时也拿不到任何新字段。
|
|
260
|
+
*
|
|
261
|
+
* 它的产物是 `oouiArtifact`。演绎只在构建期(`compilePageDeclaration`)发生;
|
|
262
|
+
* 运行时若收到的是声明本身而没有产物,说明这页没走构建期编译——
|
|
263
|
+
* 引擎只告警、不代为演绎(求解器不进 client,与 CL-4 同)。
|
|
264
|
+
*/
|
|
265
|
+
ooui?: Record<string, SomaOouiRequestDeclaration>;
|
|
266
|
+
/** 构建期演绎产物(REQ-014):区域 → 组件 + 事件接线,附空间层样式表 */
|
|
267
|
+
oouiArtifact?: SomaPageOouiArtifact;
|
|
123
268
|
}
|
package/next.config.js
CHANGED
|
@@ -47,6 +47,96 @@ function readJson(filePath) {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
/**
|
|
51
|
+
* The generated Next workspace is intentionally isolated from a Host's
|
|
52
|
+
* node_modules. Resolve source-linked packages from their public exports map,
|
|
53
|
+
* never from a broad package-root alias: the latter makes unexported deep
|
|
54
|
+
* imports appear valid locally and fail after publication.
|
|
55
|
+
*
|
|
56
|
+
* Webpack aliases do not model package-export wildcards. Never map a wildcard
|
|
57
|
+
* to a directory-prefix alias: Webpack normalises `..` after that replacement,
|
|
58
|
+
* which can turn an exported namespace into an escape hatch. Instead, expand
|
|
59
|
+
* matching files into individual `$` exact aliases alongside concrete entries.
|
|
60
|
+
*/
|
|
61
|
+
function isSafePackageChild(packageRoot, candidate) {
|
|
62
|
+
return candidate === packageRoot || candidate.startsWith(`${packageRoot}${path.sep}`);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function collectFiles(root) {
|
|
66
|
+
if (!fs.existsSync(root) || !fs.statSync(root).isDirectory()) return [];
|
|
67
|
+
const files = [];
|
|
68
|
+
for (const entry of fs.readdirSync(root, { withFileTypes: true })) {
|
|
69
|
+
const fullPath = path.join(root, entry.name);
|
|
70
|
+
if (entry.isDirectory()) files.push(...collectFiles(fullPath));
|
|
71
|
+
else if (entry.isFile()) files.push(fullPath);
|
|
72
|
+
}
|
|
73
|
+
return files;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function isSafeExportWildcardValue(value) {
|
|
77
|
+
return value.length > 0
|
|
78
|
+
&& !path.isAbsolute(value)
|
|
79
|
+
&& value.split(/[\\/]/).every((segment) => segment !== '' && segment !== '.' && segment !== '..');
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function expandWildcardExportAliases(packageName, packageRoot, entry, target) {
|
|
83
|
+
if ((entry.match(/\*/g) ?? []).length !== 1 || (target.match(/\*/g) ?? []).length !== 1) return {};
|
|
84
|
+
const entryStar = entry.indexOf('*');
|
|
85
|
+
const targetStar = target.indexOf('*');
|
|
86
|
+
const entryPrefix = entry.slice(0, entryStar);
|
|
87
|
+
const entrySuffix = entry.slice(entryStar + 1);
|
|
88
|
+
const targetPrefix = target.slice(0, targetStar);
|
|
89
|
+
const targetSuffix = target.slice(targetStar + 1);
|
|
90
|
+
const sourceRoot = path.resolve(packageRoot, targetPrefix);
|
|
91
|
+
if (!isSafePackageChild(packageRoot, sourceRoot)) return {};
|
|
92
|
+
|
|
93
|
+
const aliases = {};
|
|
94
|
+
for (const filePath of collectFiles(sourceRoot)) {
|
|
95
|
+
const relative = path.relative(sourceRoot, filePath).split(path.sep).join('/');
|
|
96
|
+
if (!relative.endsWith(targetSuffix)) continue;
|
|
97
|
+
const wildcardValue = relative.slice(0, relative.length - targetSuffix.length);
|
|
98
|
+
if (!isSafeExportWildcardValue(wildcardValue)) continue;
|
|
99
|
+
const publicPath = `${entryPrefix.slice(2)}${wildcardValue}${entrySuffix}`;
|
|
100
|
+
if (!isSafeExportWildcardValue(publicPath)) continue;
|
|
101
|
+
aliases[`${packageName}/${publicPath}$`] = filePath;
|
|
102
|
+
}
|
|
103
|
+
return aliases;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function readPublicWebpackAliases(packageName, packageRoot) {
|
|
107
|
+
const exportsMap = readJson(path.join(packageRoot, 'package.json'))?.exports;
|
|
108
|
+
if (!exportsMap || typeof exportsMap !== 'object') return {};
|
|
109
|
+
|
|
110
|
+
const exactAliases = {};
|
|
111
|
+
const wildcardAliases = {};
|
|
112
|
+
for (const [entry, descriptor] of Object.entries(exportsMap)) {
|
|
113
|
+
if (entry !== '.' && !entry.startsWith('./')) continue;
|
|
114
|
+
const target = typeof descriptor === 'string'
|
|
115
|
+
? descriptor
|
|
116
|
+
: descriptor?.import ?? descriptor?.default;
|
|
117
|
+
if (typeof target !== 'string' || !target.startsWith('./')) continue;
|
|
118
|
+
|
|
119
|
+
const isWildcard = entry.includes('*') || target.includes('*');
|
|
120
|
+
if (entry.includes('*') !== target.includes('*')) continue;
|
|
121
|
+
if (isWildcard) {
|
|
122
|
+
Object.assign(wildcardAliases, expandWildcardExportAliases(packageName, packageRoot, entry, target));
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const resolved = path.resolve(packageRoot, target);
|
|
127
|
+
if (!isSafePackageChild(packageRoot, resolved) || !fs.existsSync(resolved)) continue;
|
|
128
|
+
const publicPath = entry === '.' ? '' : entry.slice(2);
|
|
129
|
+
const specifier = publicPath ? `${packageName}/${publicPath}` : packageName;
|
|
130
|
+
exactAliases[`${specifier}$`] = resolved;
|
|
131
|
+
}
|
|
132
|
+
// A concrete export wins if it overlaps an expanded wildcard pattern.
|
|
133
|
+
return { ...wildcardAliases, ...exactAliases };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function readCorePublicWebpackAliases() {
|
|
137
|
+
return readPublicWebpackAliases('soma-core', __dirname);
|
|
138
|
+
}
|
|
139
|
+
|
|
50
140
|
function resolveSafeChildRoot(parent, relativePath) {
|
|
51
141
|
const trimmed = typeof relativePath === 'string' ? relativePath.trim() : '';
|
|
52
142
|
if (!trimmed) return parent;
|
|
@@ -225,17 +315,12 @@ const nextConfig = {
|
|
|
225
315
|
};
|
|
226
316
|
}
|
|
227
317
|
config.resolve.alias['@'] = __dirname;
|
|
228
|
-
config.resolve.alias
|
|
229
|
-
// Webpack 不会对指向源码 `.ts` 的 package-export 子路径稳定做条件解析;
|
|
230
|
-
// 自适应布局词汇是 soma-ui 唯一需要的纯共享模块,显式落到同一份 core 源文件,
|
|
231
|
-
// 避免宿主开发服务器在首次编译时把 `soma-core/adaptive-vocabulary` 判成缺失。
|
|
232
|
-
config.resolve.alias['soma-core/adaptive-vocabulary$'] = path.resolve(
|
|
233
|
-
__dirname,
|
|
234
|
-
'core/shared/types/adaptive.types.ts',
|
|
235
|
-
);
|
|
236
|
-
config.resolve.alias['soma-core/base$'] = path.resolve(__dirname, 'core/client/base/index.ts');
|
|
318
|
+
Object.assign(config.resolve.alias, readCorePublicWebpackAliases());
|
|
237
319
|
config.resolve.alias['@core'] = path.resolve(__dirname, 'core');
|
|
238
320
|
for (const entry of hostFileDependencyEntries) {
|
|
321
|
+
// soma-core is resolved above from its own exports map. Other source
|
|
322
|
+
// linked packages get the same treatment instead of a broad root alias.
|
|
323
|
+
if (entry.name === 'soma-core') continue;
|
|
239
324
|
const packageJson = readJson(path.join(entry.root, 'package.json'));
|
|
240
325
|
if (packageJson?.soma?.configRoot) {
|
|
241
326
|
config.resolve.alias[`${entry.name}/config`] = resolveSafeChildRoot(
|
|
@@ -243,10 +328,18 @@ const nextConfig = {
|
|
|
243
328
|
packageJson.soma.configRoot,
|
|
244
329
|
);
|
|
245
330
|
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
331
|
+
const publicAliases = readPublicWebpackAliases(entry.name, entry.root);
|
|
332
|
+
if (Object.keys(publicAliases).length > 0) {
|
|
333
|
+
Object.assign(config.resolve.alias, publicAliases);
|
|
334
|
+
} else {
|
|
335
|
+
// Compatibility for legacy source packages that have not declared an
|
|
336
|
+
// exports map yet. First-party packages must declare exports and never
|
|
337
|
+
// take this branch.
|
|
338
|
+
config.resolve.alias[entry.name] = resolveSafeChildRoot(
|
|
339
|
+
entry.root,
|
|
340
|
+
packageJson?.soma?.hostRoot,
|
|
341
|
+
);
|
|
342
|
+
}
|
|
250
343
|
}
|
|
251
344
|
config.resolve.alias['@soma-host/bootstrap/soma-bootstrap'] = resolveOptionalHostSourceFile(
|
|
252
345
|
'bootstrap/soma-bootstrap.ts',
|