soma-core 1.4.1 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/component.cjs +240 -0
- package/bin/eject.cjs +174 -0
- package/bin/migrate.cjs +362 -0
- package/core/build/blocks/block-compile.ts +143 -17
- package/core/build/blocks/migrate-flat.ts +118 -25
- package/core/build/compiler/page-declaration-compiler.ts +149 -5
- package/core/build/compiler/route-builder.ts +0 -4
- package/core/build/compiler/soma-precompile.js +443 -30
- package/core/build/component/component-graph.ts +28 -105
- package/core/build/component/package-loader.ts +50 -4
- package/core/build/eject/component-eject.ts +8 -2
- package/core/build/layout/constraint-solver.ts +131 -16
- package/core/build/layout/css-emitter.ts +15 -9
- package/core/build/ooui/artifact/artifact.types.ts +275 -0
- package/core/build/ooui/artifact/emit-artifact.ts +269 -0
- package/core/build/ooui/artifact/emit-html.ts +204 -0
- package/core/build/ooui/artifact/index.ts +53 -0
- package/core/build/ooui/artifact/spatial-tree.ts +268 -0
- package/core/build/ooui/artifact/utility-class.ts +83 -0
- package/core/build/ooui/composition/candidate.types.ts +323 -0
- package/core/build/ooui/composition/control-model.ts +114 -0
- package/core/build/ooui/composition/registry.ts +520 -0
- package/core/build/ooui/composition/select.ts +232 -0
- package/core/build/ooui/diagnostics/codes.ts +230 -0
- package/core/build/ooui/diagnostics/error.ts +235 -0
- package/core/build/ooui/diagnostics/format.ts +106 -0
- package/core/build/ooui/diagnostics/index.ts +62 -0
- package/core/build/ooui/diagnostics/issue.types.ts +112 -0
- package/core/build/ooui/engine-slot.ts +184 -0
- package/core/build/ooui/index.ts +1427 -0
- package/core/build/ooui/intent/derive-intent.ts +450 -0
- package/core/build/ooui/intent/field-rules.ts +330 -0
- package/core/build/ooui/intent/intent.types.ts +476 -0
- package/core/build/ooui/intent/verb-events.ts +285 -0
- package/core/build/ooui/page/budget.ts +503 -0
- package/core/build/ooui/page/compose-page.ts +736 -0
- package/core/build/ooui/page/index.ts +66 -0
- package/core/build/ooui/page/page.types.ts +402 -0
- package/core/build/ooui/page/region-row.ts +241 -0
- package/core/build/ooui/semantic/expand-page-surface.ts +180 -0
- package/core/build/ooui/semantic/kernel.types.ts +187 -0
- package/core/build/ooui/semantic/normalize.ts +784 -0
- package/core/build/ooui/semantic/origin.types.ts +211 -0
- package/core/build/ooui/semantic/role-alias.ts +154 -0
- package/core/build/ooui/semantic/shorthand.ts +233 -0
- package/core/build/ooui/semantic/surface.types.ts +78 -0
- package/core/build/ooui/semantic/validate-request.ts +267 -0
- package/core/build/ooui/spatial/emit-utility.ts +480 -0
- package/core/build/ooui/spatial/ir.types.ts +443 -0
- package/core/build/ooui/spatial/registry.ts +565 -0
- package/core/build/ooui/spatial/solve.ts +769 -0
- package/core/build/ooui/spatial/utility.types.ts +242 -0
- package/core/build/ooui/trace/index.ts +40 -0
- package/core/build/ooui/trace/render.ts +190 -0
- package/core/build/ooui/trace/source.types.ts +69 -0
- package/core/build/ooui/trace/trace.types.ts +326 -0
- package/core/build/pack/pack-init.ts +19 -14
- package/core/client/base/SomaHttpClient.ts +34 -1
- package/core/client/component/ai-catalog.ts +42 -0
- package/core/client/component/example-blocks.ts +1 -7
- package/core/client/component/theme-component-tokens.ts +12 -15
- package/core/client/component/verify-pack.ts +120 -1
- package/core/client/container/SomaContainerAdapter.ts +6 -2
- package/core/client/data/data-object-resolver.ts +27 -8
- package/core/client/diagnostics/telemetry-context.ts +0 -4
- package/core/client/engine/asset-resolver.ts +0 -1
- package/core/client/engine/event-engine.ts +7 -3
- package/core/client/engine/soma-bootstrap.ts +292 -34
- package/core/client/engine/style-binder.ts +0 -1
- package/core/client/infra/http/IHttpClient.ts +0 -6
- package/core/client/infra/http/SomaHttpService.ts +5 -2
- package/core/client/infra/notify/DomNotifyService.ts +1 -1
- package/core/client/infra/router/router-path.ts +0 -6
- package/core/client/parser/annotation-extractor.ts +1 -1
- package/core/client/parser/blocks/namespace.ts +30 -5
- package/core/client/parser/blocks/page-parser.ts +44 -1
- package/core/client/parser/blocks/use-parser.ts +266 -46
- package/core/client/parser/data-config-parser.ts +71 -3
- package/core/client/parser/layout-parser.ts +4 -3
- package/core/client/parser/reaction-parser.ts +0 -1
- package/core/client/parser/ui-config-parser.ts +212 -74
- package/core/client/theme/scene-tokens.ts +9 -3
- package/core/client/theme/theme-axes.ts +74 -16
- package/core/client/theme/theme-engine.ts +280 -69
- package/core/client/theme/tone-solver.ts +9 -8
- package/core/index.ts +38 -3
- package/core/server/api/load-host-service.ts +8 -2
- package/core/server/declaration-safety.ts +11 -0
- package/core/server/host/page-response-request.ts +0 -2
- package/core/server/host/published-page-artifact-cache.ts +244 -0
- package/core/server/host/published-page-assets.ts +44 -5
- package/core/server/mock/node/cli.mjs +0 -1
- package/core/server/mock/node/schema-generator.mjs +0 -1
- package/core/server/ooui.ts +34 -0
- package/core/server/page-assets.ts +8 -0
- package/core/server/page-declaration.ts +18 -0
- package/core/server/registry/asset-store.ts +327 -0
- package/core/server/registry/declaration-precompiler.ts +49 -6
- package/core/server/registry/index.ts +47 -1
- package/core/server/registry/page-registry-repository.ts +6 -2
- package/core/server/registry/page-registry-store.ts +133 -19
- package/core/server/registry/publish-asset-pin.ts +557 -0
- package/core/server/registry/services/pages/List.ts +15 -3
- package/core/server/registry/validation/compile-gate.ts +180 -8
- package/core/server/registry/validation/declaration-safety-scan.ts +113 -23
- package/core/shared/component/derive-sample.ts +290 -0
- package/core/shared/component/field-lines.ts +563 -0
- package/core/shared/container-breakpoints.ts +46 -0
- package/core/shared/object-semantics.ts +240 -0
- package/core/shared/ooui-declaration.ts +235 -0
- package/core/shared/types/component-contract.types.ts +30 -13
- package/core/shared/types/data-config.types.ts +95 -0
- package/core/shared/types/domain.types.ts +0 -24
- package/core/shared/types/engine.types.ts +0 -5
- package/core/shared/types/layout-constraint.types.ts +16 -0
- package/core/shared/types/ui-config.types.ts +163 -13
- package/dist/cli/soma.js +24 -11
- package/dist/core/index.cjs +2424 -1098
- package/dist/types/build/blocks/block-compile.d.ts +16 -1
- package/dist/types/build/blocks/migrate-flat.d.ts +17 -0
- package/dist/types/build/compiler/page-declaration-compiler.d.ts +46 -0
- package/dist/types/build/compiler/route-builder.d.ts +0 -1
- package/dist/types/build/component/component-graph.d.ts +17 -53
- package/dist/types/build/component/package-loader.d.ts +8 -1
- package/dist/types/build/layout/constraint-solver.d.ts +46 -4
- package/dist/types/build/ooui/artifact/artifact.types.d.ts +180 -0
- package/dist/types/build/ooui/artifact/emit-artifact.d.ts +58 -0
- package/dist/types/build/ooui/artifact/emit-html.d.ts +53 -0
- package/dist/types/build/ooui/artifact/index.d.ts +5 -0
- package/dist/types/build/ooui/artifact/spatial-tree.d.ts +48 -0
- package/dist/types/build/ooui/artifact/utility-class.d.ts +46 -0
- package/dist/types/build/ooui/composition/candidate.types.d.ts +206 -0
- package/dist/types/build/ooui/composition/control-model.d.ts +37 -0
- package/dist/types/build/ooui/composition/registry.d.ts +66 -0
- package/dist/types/build/ooui/composition/select.d.ts +63 -0
- package/dist/types/build/ooui/diagnostics/codes.d.ts +28 -0
- package/dist/types/build/ooui/diagnostics/error.d.ts +135 -0
- package/dist/types/build/ooui/diagnostics/format.d.ts +51 -0
- package/dist/types/build/ooui/diagnostics/index.d.ts +25 -0
- package/dist/types/build/ooui/diagnostics/issue.types.d.ts +56 -0
- package/dist/types/build/ooui/engine-slot.d.ts +41 -0
- package/dist/types/build/ooui/index.d.ts +286 -0
- package/dist/types/build/ooui/intent/derive-intent.d.ts +32 -0
- package/dist/types/build/ooui/intent/field-rules.d.ts +99 -0
- package/dist/types/build/ooui/intent/intent.types.d.ts +318 -0
- package/dist/types/build/ooui/intent/verb-events.d.ts +70 -0
- package/dist/types/build/ooui/page/budget.d.ts +28 -0
- package/dist/types/build/ooui/page/compose-page.d.ts +41 -0
- package/dist/types/build/ooui/page/index.d.ts +4 -0
- package/dist/types/build/ooui/page/page.types.d.ts +264 -0
- package/dist/types/build/ooui/page/region-row.d.ts +16 -0
- package/dist/types/build/ooui/semantic/expand-page-surface.d.ts +33 -0
- package/dist/types/build/ooui/semantic/kernel.types.d.ts +125 -0
- package/dist/types/build/ooui/semantic/normalize.d.ts +45 -0
- package/dist/types/build/ooui/semantic/origin.types.d.ts +95 -0
- package/dist/types/build/ooui/semantic/role-alias.d.ts +35 -0
- package/dist/types/build/ooui/semantic/shorthand.d.ts +60 -0
- package/dist/types/build/ooui/semantic/surface.types.d.ts +16 -0
- package/dist/types/build/ooui/semantic/validate-request.d.ts +19 -0
- package/dist/types/build/ooui/spatial/emit-utility.d.ts +43 -0
- package/dist/types/build/ooui/spatial/ir.types.d.ts +280 -0
- package/dist/types/build/ooui/spatial/registry.d.ts +110 -0
- package/dist/types/build/ooui/spatial/solve.d.ts +42 -0
- package/dist/types/build/ooui/spatial/utility.types.d.ts +191 -0
- package/dist/types/build/ooui/trace/index.d.ts +3 -0
- package/dist/types/build/ooui/trace/render.d.ts +42 -0
- package/dist/types/build/ooui/trace/source.types.d.ts +25 -0
- package/dist/types/build/ooui/trace/trace.types.d.ts +143 -0
- package/dist/types/client/base/SomaHttpClient.d.ts +8 -0
- package/dist/types/client/component/ai-catalog.d.ts +9 -0
- package/dist/types/client/component/example-blocks.d.ts +0 -2
- package/dist/types/client/component/theme-component-tokens.d.ts +8 -5
- package/dist/types/client/component/verify-pack.d.ts +10 -0
- package/dist/types/client/data/data-object-resolver.d.ts +10 -2
- package/dist/types/client/diagnostics/telemetry-context.d.ts +0 -1
- package/dist/types/client/engine/soma-bootstrap.d.ts +123 -10
- package/dist/types/client/infra/http/IHttpClient.d.ts +0 -5
- package/dist/types/client/infra/http/SomaHttpService.d.ts +1 -1
- package/dist/types/client/infra/router/router-path.d.ts +0 -2
- package/dist/types/client/parser/blocks/namespace.d.ts +20 -0
- package/dist/types/client/parser/blocks/page-parser.d.ts +9 -0
- package/dist/types/client/parser/blocks/use-parser.d.ts +38 -4
- package/dist/types/client/parser/data-config-parser.d.ts +13 -0
- package/dist/types/client/parser/ui-config-parser.d.ts +1 -11
- package/dist/types/client/theme/scene-tokens.d.ts +9 -3
- package/dist/types/client/theme/theme-axes.d.ts +64 -1
- package/dist/types/client/theme/theme-engine.d.ts +13 -8
- package/dist/types/client/theme/tone-solver.d.ts +9 -5
- package/dist/types/index.d.ts +6 -4
- package/dist/types/server/declaration-safety.d.ts +7 -0
- package/dist/types/server/host/page-response-request.d.ts +0 -1
- package/dist/types/server/host/published-page-artifact-cache.d.ts +64 -0
- package/dist/types/server/ooui.d.ts +18 -0
- package/dist/types/server/page-assets.d.ts +7 -0
- package/dist/types/server/page-declaration.d.ts +14 -0
- package/dist/types/server/registry/asset-store.d.ts +112 -0
- package/dist/types/server/registry/declaration-precompiler.d.ts +23 -3
- package/dist/types/server/registry/index.d.ts +3 -1
- package/dist/types/server/registry/page-registry-store.d.ts +57 -4
- package/dist/types/server/registry/publish-asset-pin.d.ts +166 -0
- package/dist/types/server/registry/services/pages/List.d.ts +9 -3
- package/dist/types/server/registry/validation/compile-gate.d.ts +63 -0
- package/dist/types/shared/component/derive-sample.d.ts +37 -0
- package/dist/types/shared/component/field-lines.d.ts +19 -0
- package/dist/types/shared/container-breakpoints.d.ts +42 -0
- package/dist/types/shared/object-semantics.d.ts +42 -0
- package/dist/types/shared/ooui-declaration.d.ts +135 -0
- package/dist/types/shared/types/component-contract.types.d.ts +29 -12
- package/dist/types/shared/types/data-config.types.d.ts +86 -0
- package/dist/types/shared/types/domain.types.d.ts +0 -21
- package/dist/types/shared/types/engine.types.d.ts +0 -4
- package/dist/types/shared/types/layout-constraint.types.d.ts +1 -0
- package/dist/types/shared/types/ui-config.types.d.ts +157 -12
- package/next.config.js +106 -13
- package/package.json +28 -2
- package/core/client/host-bridge/index.ts +0 -27
- package/core/client/parser/yaml-loader.ts +0 -36
- package/core/shared/manifest/manifest-contract.ts +0 -12
- package/dist/types/client/host-bridge/index.d.ts +0 -9
- package/dist/types/client/parser/yaml-loader.d.ts +0 -21
- package/dist/types/shared/manifest/manifest-contract.d.ts +0 -4
|
@@ -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',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "soma-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "SOMA — Semantic Oriented Modular Architecture. A declarative frontend framework runtime built on Next.js 16 App Router.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"soma",
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"default": "./core/client/adaptive/index.ts"
|
|
54
54
|
},
|
|
55
55
|
"./adaptive-vocabulary": "./core/shared/types/adaptive.types.ts",
|
|
56
|
+
"./responsive-vocabulary": "./core/shared/container-breakpoints.ts",
|
|
56
57
|
"./compiler/vite": "./core/build/compiler/vite-plugin-soma.ts",
|
|
57
58
|
"./compiler/precompile": "./core/build/compiler/soma-precompile.ts",
|
|
58
59
|
"./compiler/webpack-loader": "./core/build/compiler/soma-webpack-loader.js",
|
|
@@ -77,6 +78,26 @@
|
|
|
77
78
|
"import": "./core/server/registry/index.ts",
|
|
78
79
|
"default": "./core/server/registry/index.ts"
|
|
79
80
|
},
|
|
81
|
+
"./server/page-declaration": {
|
|
82
|
+
"types": "./dist/types/server/page-declaration.d.ts",
|
|
83
|
+
"import": "./core/server/page-declaration.ts",
|
|
84
|
+
"default": "./core/server/page-declaration.ts"
|
|
85
|
+
},
|
|
86
|
+
"./server/page-assets": {
|
|
87
|
+
"types": "./dist/types/server/page-assets.d.ts",
|
|
88
|
+
"import": "./core/server/page-assets.ts",
|
|
89
|
+
"default": "./core/server/page-assets.ts"
|
|
90
|
+
},
|
|
91
|
+
"./server/ooui": {
|
|
92
|
+
"types": "./dist/types/server/ooui.d.ts",
|
|
93
|
+
"import": "./core/server/ooui.ts",
|
|
94
|
+
"default": "./core/server/ooui.ts"
|
|
95
|
+
},
|
|
96
|
+
"./server/declaration-safety": {
|
|
97
|
+
"types": "./dist/types/server/declaration-safety.d.ts",
|
|
98
|
+
"import": "./core/server/declaration-safety.ts",
|
|
99
|
+
"default": "./core/server/declaration-safety.ts"
|
|
100
|
+
},
|
|
80
101
|
"./mock/node": {
|
|
81
102
|
"types": "./core/server/mock/node/public.d.mts",
|
|
82
103
|
"import": "./core/server/mock/node/public.mjs",
|
|
@@ -97,6 +118,9 @@
|
|
|
97
118
|
"files": [
|
|
98
119
|
"bin/soma.cjs",
|
|
99
120
|
"bin/soma-db.cjs",
|
|
121
|
+
"bin/migrate.cjs",
|
|
122
|
+
"bin/component.cjs",
|
|
123
|
+
"bin/eject.cjs",
|
|
100
124
|
"bin/soma-lsp.cjs",
|
|
101
125
|
"bin/soma-sync.cjs",
|
|
102
126
|
"bin/soma-mock.mjs",
|
|
@@ -129,6 +153,8 @@
|
|
|
129
153
|
"verify:mock-pack": "node scripts/verify-mock-pack.mjs",
|
|
130
154
|
"verify:client-boundary": "node scripts/verify-client-boundary.mjs",
|
|
131
155
|
"verify:client-dep-graph": "node scripts/verify-client-dep-graph.mjs",
|
|
156
|
+
"verify:ooui-dep-graph": "node scripts/verify-ooui-dep-graph.mjs",
|
|
157
|
+
"verify:ooui-closure": "node scripts/verify-ooui-closure.mjs",
|
|
132
158
|
"test:watch": "vitest",
|
|
133
159
|
"typecheck": "tsc --noEmit",
|
|
134
160
|
"verify:precompile": "node scripts/verify-precompile-fresh.mjs",
|
|
@@ -138,6 +164,7 @@
|
|
|
138
164
|
"ajv": "8.20.0",
|
|
139
165
|
"dompurify": "^3.4.12",
|
|
140
166
|
"jiti": "^1.21.7",
|
|
167
|
+
"js-yaml": "^4.3.2",
|
|
141
168
|
"msw": "2.15.0",
|
|
142
169
|
"reflect-metadata": "^0.2.1",
|
|
143
170
|
"server-only": "^0.0.1"
|
|
@@ -157,7 +184,6 @@
|
|
|
157
184
|
"@vitest/coverage-v8": "^3.2.7",
|
|
158
185
|
"ajv-formats": "3.0.1",
|
|
159
186
|
"esbuild": "^0.25.12",
|
|
160
|
-
"js-yaml": "^4.3.1",
|
|
161
187
|
"jsdom": "^26.1.0",
|
|
162
188
|
"next": "16.3.1",
|
|
163
189
|
"playwright": "^1.62.1",
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Browser-safe Host bridges used by the SOMA client entry.
|
|
3
|
-
*
|
|
4
|
-
* These modules may be imported from `'use client'` code.
|
|
5
|
-
* They must not pull Node fs/jiti/server-only modules.
|
|
6
|
-
*/
|
|
7
|
-
export {
|
|
8
|
-
SomaDomainLoadError,
|
|
9
|
-
loadHostDomainClass,
|
|
10
|
-
resolveSomaDomainConstructor,
|
|
11
|
-
type SomaDomainConstructor,
|
|
12
|
-
} from './load-host-domain-class';
|
|
13
|
-
export {
|
|
14
|
-
resolveHostBootstrapOptions,
|
|
15
|
-
type SomaBootstrapConfigurator,
|
|
16
|
-
} from './resolve-host-bootstrap';
|
|
17
|
-
export {
|
|
18
|
-
createSomaDomainLoaderKey,
|
|
19
|
-
findSomaDomainLoader,
|
|
20
|
-
loadSomaDomainModuleFromRegistry,
|
|
21
|
-
type SomaDomainLoadContext,
|
|
22
|
-
type SomaDomainLoader,
|
|
23
|
-
type SomaDomainLoaderMap,
|
|
24
|
-
type SomaDomainLoaderModule,
|
|
25
|
-
type SomaDomainModule,
|
|
26
|
-
type SomaDomainModuleResolver,
|
|
27
|
-
} from './soma-domain-loaders';
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
// core/client/parser/yaml-loader.ts — YAML 文件加载和解析封装
|
|
2
|
-
// 封装 js-yaml 库,提供异步文件加载和同步字符串解析
|
|
3
|
-
|
|
4
|
-
import yaml from 'js-yaml';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* 异步加载并解析 YAML 文件
|
|
8
|
-
*
|
|
9
|
-
* 使用 fetch API 获取文件内容,然后通过 js-yaml 解析为 JavaScript 对象。
|
|
10
|
-
* 适用于浏览器环境中加载 YAML 配置文件。
|
|
11
|
-
*
|
|
12
|
-
* @param path - YAML 文件的 URL 路径
|
|
13
|
-
* @returns 解析后的 JavaScript 对象
|
|
14
|
-
* @throws Error 文件加载失败或 YAML 解析错误时抛出
|
|
15
|
-
*/
|
|
16
|
-
export async function loadYamlFile(path: string): Promise<any> {
|
|
17
|
-
const res = await fetch(path);
|
|
18
|
-
if (!res.ok) {
|
|
19
|
-
throw new Error(`Failed to load YAML: ${path} (${res.status})`);
|
|
20
|
-
}
|
|
21
|
-
const text = await res.text();
|
|
22
|
-
return yaml.load(text);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* 同步解析 YAML 字符串
|
|
27
|
-
*
|
|
28
|
-
* 将 YAML 格式的文本直接解析为 JavaScript 对象。
|
|
29
|
-
*
|
|
30
|
-
* @param text - YAML 格式的字符串
|
|
31
|
-
* @returns 解析后的 JavaScript 对象
|
|
32
|
-
* @throws YAMLException YAML 语法错误时抛出
|
|
33
|
-
*/
|
|
34
|
-
export function parseYamlString(text: string): any {
|
|
35
|
-
return yaml.load(text);
|
|
36
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/** SOMA runtime manifest version contract */
|
|
2
|
-
export const SOMA_MANIFEST_VERSION = '1.0.0' as const;
|
|
3
|
-
|
|
4
|
-
export type SomaManifestVersion = typeof SOMA_MANIFEST_VERSION;
|
|
5
|
-
|
|
6
|
-
export function assertManifestVersion(version: string): void {
|
|
7
|
-
if (version !== SOMA_MANIFEST_VERSION) {
|
|
8
|
-
throw new Error(
|
|
9
|
-
`[SOMA] Incompatible manifest version: expected ${SOMA_MANIFEST_VERSION}, got ${version}`,
|
|
10
|
-
);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Browser-safe Host bridges used by the SOMA client entry.
|
|
3
|
-
*
|
|
4
|
-
* These modules may be imported from `'use client'` code.
|
|
5
|
-
* They must not pull Node fs/jiti/server-only modules.
|
|
6
|
-
*/
|
|
7
|
-
export { SomaDomainLoadError, loadHostDomainClass, resolveSomaDomainConstructor, type SomaDomainConstructor, } from './load-host-domain-class';
|
|
8
|
-
export { resolveHostBootstrapOptions, type SomaBootstrapConfigurator, } from './resolve-host-bootstrap';
|
|
9
|
-
export { createSomaDomainLoaderKey, findSomaDomainLoader, loadSomaDomainModuleFromRegistry, type SomaDomainLoadContext, type SomaDomainLoader, type SomaDomainLoaderMap, type SomaDomainLoaderModule, type SomaDomainModule, type SomaDomainModuleResolver, } from './soma-domain-loaders';
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 异步加载并解析 YAML 文件
|
|
3
|
-
*
|
|
4
|
-
* 使用 fetch API 获取文件内容,然后通过 js-yaml 解析为 JavaScript 对象。
|
|
5
|
-
* 适用于浏览器环境中加载 YAML 配置文件。
|
|
6
|
-
*
|
|
7
|
-
* @param path - YAML 文件的 URL 路径
|
|
8
|
-
* @returns 解析后的 JavaScript 对象
|
|
9
|
-
* @throws Error 文件加载失败或 YAML 解析错误时抛出
|
|
10
|
-
*/
|
|
11
|
-
export declare function loadYamlFile(path: string): Promise<any>;
|
|
12
|
-
/**
|
|
13
|
-
* 同步解析 YAML 字符串
|
|
14
|
-
*
|
|
15
|
-
* 将 YAML 格式的文本直接解析为 JavaScript 对象。
|
|
16
|
-
*
|
|
17
|
-
* @param text - YAML 格式的字符串
|
|
18
|
-
* @returns 解析后的 JavaScript 对象
|
|
19
|
-
* @throws YAMLException YAML 语法错误时抛出
|
|
20
|
-
*/
|
|
21
|
-
export declare function parseYamlString(text: string): any;
|