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.
Files changed (221) hide show
  1. package/bin/component.cjs +240 -0
  2. package/bin/eject.cjs +174 -0
  3. package/bin/migrate.cjs +362 -0
  4. package/core/build/blocks/block-compile.ts +143 -17
  5. package/core/build/blocks/migrate-flat.ts +118 -25
  6. package/core/build/compiler/page-declaration-compiler.ts +149 -5
  7. package/core/build/compiler/route-builder.ts +0 -4
  8. package/core/build/compiler/soma-precompile.js +443 -30
  9. package/core/build/component/component-graph.ts +28 -105
  10. package/core/build/component/package-loader.ts +50 -4
  11. package/core/build/eject/component-eject.ts +8 -2
  12. package/core/build/layout/constraint-solver.ts +131 -16
  13. package/core/build/layout/css-emitter.ts +15 -9
  14. package/core/build/ooui/artifact/artifact.types.ts +275 -0
  15. package/core/build/ooui/artifact/emit-artifact.ts +269 -0
  16. package/core/build/ooui/artifact/emit-html.ts +204 -0
  17. package/core/build/ooui/artifact/index.ts +53 -0
  18. package/core/build/ooui/artifact/spatial-tree.ts +268 -0
  19. package/core/build/ooui/artifact/utility-class.ts +83 -0
  20. package/core/build/ooui/composition/candidate.types.ts +323 -0
  21. package/core/build/ooui/composition/control-model.ts +114 -0
  22. package/core/build/ooui/composition/registry.ts +520 -0
  23. package/core/build/ooui/composition/select.ts +232 -0
  24. package/core/build/ooui/diagnostics/codes.ts +230 -0
  25. package/core/build/ooui/diagnostics/error.ts +235 -0
  26. package/core/build/ooui/diagnostics/format.ts +106 -0
  27. package/core/build/ooui/diagnostics/index.ts +62 -0
  28. package/core/build/ooui/diagnostics/issue.types.ts +112 -0
  29. package/core/build/ooui/engine-slot.ts +184 -0
  30. package/core/build/ooui/index.ts +1427 -0
  31. package/core/build/ooui/intent/derive-intent.ts +450 -0
  32. package/core/build/ooui/intent/field-rules.ts +330 -0
  33. package/core/build/ooui/intent/intent.types.ts +476 -0
  34. package/core/build/ooui/intent/verb-events.ts +285 -0
  35. package/core/build/ooui/page/budget.ts +503 -0
  36. package/core/build/ooui/page/compose-page.ts +736 -0
  37. package/core/build/ooui/page/index.ts +66 -0
  38. package/core/build/ooui/page/page.types.ts +402 -0
  39. package/core/build/ooui/page/region-row.ts +241 -0
  40. package/core/build/ooui/semantic/expand-page-surface.ts +180 -0
  41. package/core/build/ooui/semantic/kernel.types.ts +187 -0
  42. package/core/build/ooui/semantic/normalize.ts +784 -0
  43. package/core/build/ooui/semantic/origin.types.ts +211 -0
  44. package/core/build/ooui/semantic/role-alias.ts +154 -0
  45. package/core/build/ooui/semantic/shorthand.ts +233 -0
  46. package/core/build/ooui/semantic/surface.types.ts +78 -0
  47. package/core/build/ooui/semantic/validate-request.ts +267 -0
  48. package/core/build/ooui/spatial/emit-utility.ts +480 -0
  49. package/core/build/ooui/spatial/ir.types.ts +443 -0
  50. package/core/build/ooui/spatial/registry.ts +565 -0
  51. package/core/build/ooui/spatial/solve.ts +769 -0
  52. package/core/build/ooui/spatial/utility.types.ts +242 -0
  53. package/core/build/ooui/trace/index.ts +40 -0
  54. package/core/build/ooui/trace/render.ts +190 -0
  55. package/core/build/ooui/trace/source.types.ts +69 -0
  56. package/core/build/ooui/trace/trace.types.ts +326 -0
  57. package/core/build/pack/pack-init.ts +19 -14
  58. package/core/client/base/SomaHttpClient.ts +34 -1
  59. package/core/client/component/ai-catalog.ts +42 -0
  60. package/core/client/component/example-blocks.ts +1 -7
  61. package/core/client/component/theme-component-tokens.ts +12 -15
  62. package/core/client/component/verify-pack.ts +120 -1
  63. package/core/client/container/SomaContainerAdapter.ts +6 -2
  64. package/core/client/data/data-object-resolver.ts +27 -8
  65. package/core/client/diagnostics/telemetry-context.ts +0 -4
  66. package/core/client/engine/asset-resolver.ts +0 -1
  67. package/core/client/engine/event-engine.ts +7 -3
  68. package/core/client/engine/soma-bootstrap.ts +292 -34
  69. package/core/client/engine/style-binder.ts +0 -1
  70. package/core/client/infra/http/IHttpClient.ts +0 -6
  71. package/core/client/infra/http/SomaHttpService.ts +5 -2
  72. package/core/client/infra/notify/DomNotifyService.ts +1 -1
  73. package/core/client/infra/router/router-path.ts +0 -6
  74. package/core/client/parser/annotation-extractor.ts +1 -1
  75. package/core/client/parser/blocks/namespace.ts +30 -5
  76. package/core/client/parser/blocks/page-parser.ts +44 -1
  77. package/core/client/parser/blocks/use-parser.ts +266 -46
  78. package/core/client/parser/data-config-parser.ts +71 -3
  79. package/core/client/parser/layout-parser.ts +4 -3
  80. package/core/client/parser/reaction-parser.ts +0 -1
  81. package/core/client/parser/ui-config-parser.ts +212 -74
  82. package/core/client/theme/scene-tokens.ts +9 -3
  83. package/core/client/theme/theme-axes.ts +74 -16
  84. package/core/client/theme/theme-engine.ts +280 -69
  85. package/core/client/theme/tone-solver.ts +9 -8
  86. package/core/index.ts +38 -3
  87. package/core/server/api/load-host-service.ts +8 -2
  88. package/core/server/declaration-safety.ts +11 -0
  89. package/core/server/host/page-response-request.ts +0 -2
  90. package/core/server/host/published-page-artifact-cache.ts +244 -0
  91. package/core/server/host/published-page-assets.ts +44 -5
  92. package/core/server/mock/node/cli.mjs +0 -1
  93. package/core/server/mock/node/schema-generator.mjs +0 -1
  94. package/core/server/ooui.ts +34 -0
  95. package/core/server/page-assets.ts +8 -0
  96. package/core/server/page-declaration.ts +18 -0
  97. package/core/server/registry/asset-store.ts +327 -0
  98. package/core/server/registry/declaration-precompiler.ts +49 -6
  99. package/core/server/registry/index.ts +47 -1
  100. package/core/server/registry/page-registry-repository.ts +6 -2
  101. package/core/server/registry/page-registry-store.ts +133 -19
  102. package/core/server/registry/publish-asset-pin.ts +557 -0
  103. package/core/server/registry/services/pages/List.ts +15 -3
  104. package/core/server/registry/validation/compile-gate.ts +180 -8
  105. package/core/server/registry/validation/declaration-safety-scan.ts +113 -23
  106. package/core/shared/component/derive-sample.ts +290 -0
  107. package/core/shared/component/field-lines.ts +563 -0
  108. package/core/shared/container-breakpoints.ts +46 -0
  109. package/core/shared/object-semantics.ts +240 -0
  110. package/core/shared/ooui-declaration.ts +235 -0
  111. package/core/shared/types/component-contract.types.ts +30 -13
  112. package/core/shared/types/data-config.types.ts +95 -0
  113. package/core/shared/types/domain.types.ts +0 -24
  114. package/core/shared/types/engine.types.ts +0 -5
  115. package/core/shared/types/layout-constraint.types.ts +16 -0
  116. package/core/shared/types/ui-config.types.ts +163 -13
  117. package/dist/cli/soma.js +24 -11
  118. package/dist/core/index.cjs +2424 -1098
  119. package/dist/types/build/blocks/block-compile.d.ts +16 -1
  120. package/dist/types/build/blocks/migrate-flat.d.ts +17 -0
  121. package/dist/types/build/compiler/page-declaration-compiler.d.ts +46 -0
  122. package/dist/types/build/compiler/route-builder.d.ts +0 -1
  123. package/dist/types/build/component/component-graph.d.ts +17 -53
  124. package/dist/types/build/component/package-loader.d.ts +8 -1
  125. package/dist/types/build/layout/constraint-solver.d.ts +46 -4
  126. package/dist/types/build/ooui/artifact/artifact.types.d.ts +180 -0
  127. package/dist/types/build/ooui/artifact/emit-artifact.d.ts +58 -0
  128. package/dist/types/build/ooui/artifact/emit-html.d.ts +53 -0
  129. package/dist/types/build/ooui/artifact/index.d.ts +5 -0
  130. package/dist/types/build/ooui/artifact/spatial-tree.d.ts +48 -0
  131. package/dist/types/build/ooui/artifact/utility-class.d.ts +46 -0
  132. package/dist/types/build/ooui/composition/candidate.types.d.ts +206 -0
  133. package/dist/types/build/ooui/composition/control-model.d.ts +37 -0
  134. package/dist/types/build/ooui/composition/registry.d.ts +66 -0
  135. package/dist/types/build/ooui/composition/select.d.ts +63 -0
  136. package/dist/types/build/ooui/diagnostics/codes.d.ts +28 -0
  137. package/dist/types/build/ooui/diagnostics/error.d.ts +135 -0
  138. package/dist/types/build/ooui/diagnostics/format.d.ts +51 -0
  139. package/dist/types/build/ooui/diagnostics/index.d.ts +25 -0
  140. package/dist/types/build/ooui/diagnostics/issue.types.d.ts +56 -0
  141. package/dist/types/build/ooui/engine-slot.d.ts +41 -0
  142. package/dist/types/build/ooui/index.d.ts +286 -0
  143. package/dist/types/build/ooui/intent/derive-intent.d.ts +32 -0
  144. package/dist/types/build/ooui/intent/field-rules.d.ts +99 -0
  145. package/dist/types/build/ooui/intent/intent.types.d.ts +318 -0
  146. package/dist/types/build/ooui/intent/verb-events.d.ts +70 -0
  147. package/dist/types/build/ooui/page/budget.d.ts +28 -0
  148. package/dist/types/build/ooui/page/compose-page.d.ts +41 -0
  149. package/dist/types/build/ooui/page/index.d.ts +4 -0
  150. package/dist/types/build/ooui/page/page.types.d.ts +264 -0
  151. package/dist/types/build/ooui/page/region-row.d.ts +16 -0
  152. package/dist/types/build/ooui/semantic/expand-page-surface.d.ts +33 -0
  153. package/dist/types/build/ooui/semantic/kernel.types.d.ts +125 -0
  154. package/dist/types/build/ooui/semantic/normalize.d.ts +45 -0
  155. package/dist/types/build/ooui/semantic/origin.types.d.ts +95 -0
  156. package/dist/types/build/ooui/semantic/role-alias.d.ts +35 -0
  157. package/dist/types/build/ooui/semantic/shorthand.d.ts +60 -0
  158. package/dist/types/build/ooui/semantic/surface.types.d.ts +16 -0
  159. package/dist/types/build/ooui/semantic/validate-request.d.ts +19 -0
  160. package/dist/types/build/ooui/spatial/emit-utility.d.ts +43 -0
  161. package/dist/types/build/ooui/spatial/ir.types.d.ts +280 -0
  162. package/dist/types/build/ooui/spatial/registry.d.ts +110 -0
  163. package/dist/types/build/ooui/spatial/solve.d.ts +42 -0
  164. package/dist/types/build/ooui/spatial/utility.types.d.ts +191 -0
  165. package/dist/types/build/ooui/trace/index.d.ts +3 -0
  166. package/dist/types/build/ooui/trace/render.d.ts +42 -0
  167. package/dist/types/build/ooui/trace/source.types.d.ts +25 -0
  168. package/dist/types/build/ooui/trace/trace.types.d.ts +143 -0
  169. package/dist/types/client/base/SomaHttpClient.d.ts +8 -0
  170. package/dist/types/client/component/ai-catalog.d.ts +9 -0
  171. package/dist/types/client/component/example-blocks.d.ts +0 -2
  172. package/dist/types/client/component/theme-component-tokens.d.ts +8 -5
  173. package/dist/types/client/component/verify-pack.d.ts +10 -0
  174. package/dist/types/client/data/data-object-resolver.d.ts +10 -2
  175. package/dist/types/client/diagnostics/telemetry-context.d.ts +0 -1
  176. package/dist/types/client/engine/soma-bootstrap.d.ts +123 -10
  177. package/dist/types/client/infra/http/IHttpClient.d.ts +0 -5
  178. package/dist/types/client/infra/http/SomaHttpService.d.ts +1 -1
  179. package/dist/types/client/infra/router/router-path.d.ts +0 -2
  180. package/dist/types/client/parser/blocks/namespace.d.ts +20 -0
  181. package/dist/types/client/parser/blocks/page-parser.d.ts +9 -0
  182. package/dist/types/client/parser/blocks/use-parser.d.ts +38 -4
  183. package/dist/types/client/parser/data-config-parser.d.ts +13 -0
  184. package/dist/types/client/parser/ui-config-parser.d.ts +1 -11
  185. package/dist/types/client/theme/scene-tokens.d.ts +9 -3
  186. package/dist/types/client/theme/theme-axes.d.ts +64 -1
  187. package/dist/types/client/theme/theme-engine.d.ts +13 -8
  188. package/dist/types/client/theme/tone-solver.d.ts +9 -5
  189. package/dist/types/index.d.ts +6 -4
  190. package/dist/types/server/declaration-safety.d.ts +7 -0
  191. package/dist/types/server/host/page-response-request.d.ts +0 -1
  192. package/dist/types/server/host/published-page-artifact-cache.d.ts +64 -0
  193. package/dist/types/server/ooui.d.ts +18 -0
  194. package/dist/types/server/page-assets.d.ts +7 -0
  195. package/dist/types/server/page-declaration.d.ts +14 -0
  196. package/dist/types/server/registry/asset-store.d.ts +112 -0
  197. package/dist/types/server/registry/declaration-precompiler.d.ts +23 -3
  198. package/dist/types/server/registry/index.d.ts +3 -1
  199. package/dist/types/server/registry/page-registry-store.d.ts +57 -4
  200. package/dist/types/server/registry/publish-asset-pin.d.ts +166 -0
  201. package/dist/types/server/registry/services/pages/List.d.ts +9 -3
  202. package/dist/types/server/registry/validation/compile-gate.d.ts +63 -0
  203. package/dist/types/shared/component/derive-sample.d.ts +37 -0
  204. package/dist/types/shared/component/field-lines.d.ts +19 -0
  205. package/dist/types/shared/container-breakpoints.d.ts +42 -0
  206. package/dist/types/shared/object-semantics.d.ts +42 -0
  207. package/dist/types/shared/ooui-declaration.d.ts +135 -0
  208. package/dist/types/shared/types/component-contract.types.d.ts +29 -12
  209. package/dist/types/shared/types/data-config.types.d.ts +86 -0
  210. package/dist/types/shared/types/domain.types.d.ts +0 -21
  211. package/dist/types/shared/types/engine.types.d.ts +0 -4
  212. package/dist/types/shared/types/layout-constraint.types.d.ts +1 -0
  213. package/dist/types/shared/types/ui-config.types.d.ts +157 -12
  214. package/next.config.js +106 -13
  215. package/package.json +28 -2
  216. package/core/client/host-bridge/index.ts +0 -27
  217. package/core/client/parser/yaml-loader.ts +0 -36
  218. package/core/shared/manifest/manifest-contract.ts +0 -12
  219. package/dist/types/client/host-bridge/index.d.ts +0 -9
  220. package/dist/types/client/parser/yaml-loader.d.ts +0 -21
  221. package/dist/types/shared/manifest/manifest-contract.d.ts +0 -4
@@ -6,7 +6,6 @@ import type { IContainerAdapter } from '../container/IContainerAdapter';
6
6
  import type {
7
7
  StyleConfig,
8
8
  StyleStateRule,
9
- StyleTransition,
10
9
  ThemeConfig,
11
10
  } from '../../shared/types/style-config.types';
12
11
 
@@ -14,12 +14,6 @@ export interface UploadOptions {
14
14
  fields?: Record<string, string>;
15
15
  }
16
16
 
17
- export interface HttpResponse<T = any> {
18
- data: T;
19
- status: number;
20
- headers: Record<string, string>;
21
- }
22
-
23
17
  export interface IHttpClient {
24
18
  get<T>(url: string, config?: HttpRequestConfig): Promise<T>;
25
19
  post<T>(url: string, data?: any, config?: HttpRequestConfig): Promise<T>;
@@ -1,4 +1,7 @@
1
- import { SomaHttpClient, SomaHttpClientConfig } from '@/core/client/base/SomaHttpClient';
1
+ // Use the package's public self-reference rather than the repository-only
2
+ // `@/` alias. This import is preserved in emitted declarations, so an
3
+ // internal alias here would leak into every Host's typecheck.
4
+ import { SomaHttpClient, SomaHttpClientConfig, describeHttpErrorBody } from 'soma-core/base';
2
5
  import { IHttpClient, HttpRequestConfig, UploadOptions } from './IHttpClient';
3
6
 
4
7
  /**
@@ -195,7 +198,7 @@ export class SomaHttpService implements IHttpClient {
195
198
  ? await res.text().catch(() => '')
196
199
  : '';
197
200
  this.onHttpError?.(res.status, body || res.statusText);
198
- throw new Error(`HTTP ${res.status}: ${res.statusText}`);
201
+ throw new Error(`HTTP ${res.status}: ${describeHttpErrorBody(body, res.statusText)}`);
199
202
  }
200
203
 
201
204
  return (await res.json()) as T;
@@ -1,5 +1,5 @@
1
1
  import { DefaultNotifyService } from './DefaultNotifyService';
2
- import type { NotifyLevel, NotifyOptions } from './INotifyService';
2
+ import type { NotifyOptions } from './INotifyService';
3
3
  import type { ToastTheme } from './INotifyTheme';
4
4
 
5
5
  const ROOT_ID = 'soma-toast-root';
@@ -1,9 +1,3 @@
1
- /** Strip query/hash for router utilities */
2
- export function pathOnly(url: string): string {
3
- const raw = url.split('?')[0]?.split('#')[0] || '/';
4
- return raw.replace(/\/$/, '') || '/';
5
- }
6
-
7
1
  /** Browser location pathname + search (includes ?id= etc.) */
8
2
  export function getBrowserUrlPath(): string {
9
3
  if (typeof globalThis === 'undefined' || !('location' in globalThis)) {
@@ -4,7 +4,7 @@ import {
4
4
  getShowListMetadata,
5
5
  getEventMetadata,
6
6
  } from '../base/decorators';
7
- import type { UiConfig, ShowMapping, ShowValue } from '../../shared/types/ui-config.types';
7
+ import type { UiConfig, ShowMapping } from '../../shared/types/ui-config.types';
8
8
  import type { ParsedEvent } from '../../shared/types/event.types';
9
9
  import { parsePipeline } from './pipeline-parser';
10
10
 
@@ -1,7 +1,8 @@
1
1
  // 块解析 · 块作用域与命名空间(REQ-005 F1.3 / F1.4)。
2
2
  //
3
- // 块即命名空间:块内 `data:` 声明的对象名,全局身份自动是 `块id.名`——
4
- // 书写零前缀,跨块显式全名。两个组件都叫 `orders` 因此互不相干。
3
+ // 块即命名空间:块内 `data:` 声明的对象名,全局身份自动是扁平名 `块id__名`
4
+ // (见 blockDataObjectName)——书写零前缀,跨块写 `page.data.块id__名`。
5
+ // 两个组件都叫 `orders` 因此互不相干。
5
6
  //
6
7
  // alias 是块作用域的短名:`queryOrders: /api/admin/orders` 或 `buyer: order.buyer`。
7
8
  // 两类按**词法**分流(值以 `/` 开头即 API 别名),不靠猜;编译期整体展开,
@@ -28,6 +29,12 @@ export interface BlockScope {
28
29
  blockId: string;
29
30
  /** 本块 data 段声明或引入的对象名 */
30
31
  dataNames: ReadonlySet<string>;
32
+ /**
33
+ * 本块 data 名 → 运行时绑定路径前缀。组件块由 use-parser 填:
34
+ * 声明 → `page.data.<块id__名>`,引入 → 引入目标路径。
35
+ * 缺省时回落 `块id.名`——那是 page 块沿用的既有口径,组件块不走这条。
36
+ */
37
+ dataPaths?: ReadonlyMap<string, string>;
31
38
  /** 块作用域别名 */
32
39
  aliases: ReadonlyMap<string, AliasEntry>;
33
40
  /** 按 HTML 位置可见的行变量(行内组件才有) */
@@ -40,6 +47,23 @@ export interface BlockScope {
40
47
  const RESERVED = new Set(['page', 'p', 'ctrl']);
41
48
  const NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
42
49
 
50
+ /**
51
+ * 块私有数据对象的全局身份:扁平名 `块id__名`(标识符,不带点)。
52
+ *
53
+ * 为什么不是 `块id.名`:数据对象层的对象名是标识符(data-config-parser 的
54
+ * IDENTIFIER_PATTERN),`$` 引用与 `relations[].to` 也按标识符切;运行时
55
+ * `page.data.<对象>.<字段>` 的绑定按点号逐段下钻。带点的对象名在这几处各断一次——
56
+ * 页面要么发布不了,要么发布了取不到值、只剩一片空白。扁平名让块私有对象与页面级对象
57
+ * 走同一条解析、同一条取数、同一条绑定,下游一行不改。
58
+ *
59
+ * 规则只在这里定义一次:use-parser(对象键与绑定路径)与 block-compile(撞名检查、
60
+ * `relations[].to`)都调它,不各拼一遍。撞名(`a` 的 `b__c` 与 `a__b` 的 `c`)
61
+ * 由 block-compile 在合表时拦下。
62
+ */
63
+ export function blockDataObjectName(blockId: string, localName: string): string {
64
+ return `${blockId}__${localName}`;
65
+ }
66
+
43
67
  export interface BuildScopeInput {
44
68
  blockId: string;
45
69
  dataNames?: Iterable<string>;
@@ -131,7 +155,7 @@ export function resolvePath(raw: string, scope: BlockScope): ResolvedPath {
131
155
  const hits = [inData, inRow, isPage].filter(Boolean).length;
132
156
  if (hits > 1) {
133
157
  const candidates = [
134
- inData ? `data 对象 ${scope.blockId}.${head}` : '',
158
+ inData ? `本块 data 名 ${head}` : '',
135
159
  inRow ? `行变量 ${head}` : '',
136
160
  isPage ? '页面变量 page' : '',
137
161
  ].filter(Boolean);
@@ -142,8 +166,9 @@ export function resolvePath(raw: string, scope: BlockScope): ResolvedPath {
142
166
  }
143
167
 
144
168
  if (inData) {
145
- // 块内零前缀 → 全局身份 块id.名
146
- return { kind: 'data', full: [`${scope.blockId}.${head}`, ...segments.slice(1)].join('.') };
169
+ // 块内零前缀 → 运行时绑定路径(组件块:声明 → page.data.块id__名,引入 → 引入目标)
170
+ const base = scope.dataPaths?.get(head) ?? `${scope.blockId}.${head}`;
171
+ return { kind: 'data', full: [base, ...segments.slice(1)].join('.') };
147
172
  }
148
173
  if (inRow) return { kind: 'row', full: text };
149
174
  if (isPage) return { kind: 'page', full: text };
@@ -38,6 +38,28 @@ const PAGE_KEYS = new Set([
38
38
  // 这里只直通原文;形状校验在 parseUiConfig(运行时)与 compilePageDeclaration(构建期)各做一次。
39
39
  'state',
40
40
  'layout',
41
+ // ooui(REQ-014 演绎接线):第三个平铺 UiConfig 保留键的直通。
42
+ //
43
+ // 少了这一条,块声明页写 `ooui:` 会当场收到「page 块不支持键 "ooui"」——
44
+ // 而**真实发布的页面只有块声明这一条路**(compilePageDeclaration 只收块声明),
45
+ // 于是整条演绎链只在"直接喂平铺 YAML"的测试路径上活着,生产页面一次都用不上。
46
+ // 这与上面 state / layout 那次踩的是同一个坑,不再重踩第三次。
47
+ // 这里只直通原文;形状校验在 parseUiConfig(运行时)与 compilePageDeclaration(构建期)各做一次。
48
+ 'ooui',
49
+ // objects(REQ-014 表层语义,§38.5 断线 ②):**面向人书写的那一层对象声明**。
50
+ //
51
+ // `data:` 是核心层——完备、显式、机器好翻译(`{ type: text, rules: [{ required: true }] }`)。
52
+ // 表层是同一件事的人写形态(`no: text!`)。两层的转换点只有一个
53
+ // (`build/ooui/semantic/normalize.ts`),而在此之前**它一个生产调用者都没有**:
54
+ // 表层类型、展开器、台账三样都写完了,页面上却没有任何地方能写出表层来。
55
+ //
56
+ // 不接这一条的后果不是"少个语法糖",是**来历台账永远是空的**:
57
+ // 系统按默认补的值(如 `permission: r`)与作者显式写的值在产物里长得一模一样,
58
+ // 于是 `OOUI-SEM-EDIT-ALL-READONLY` 只能说"你写错了",说不出"我按默认补的、
59
+ // 你需要显式写 permission: w"——同一条错误,两种修法,指向两个人(§34.2)。
60
+ //
61
+ // 这里只直通原文;展开与校验在 compilePageDeclaration(构建期)做一次。
62
+ 'objects',
41
63
  ]);
42
64
  /** 后缀键:平铺书写的高级绑定 */
43
65
  const SUFFIXES = ['when', 'model', 'class'] as const;
@@ -50,6 +72,15 @@ export interface PageBlockAst {
50
72
  eventRaw: Record<string, unknown>;
51
73
  /** 数据段原文(页面级共享对象,交数据对象层) */
52
74
  dataRaw?: Record<string, unknown>;
75
+ /**
76
+ * 表层对象声明原文(REQ-014 §38.5 断线 ②)。
77
+ *
78
+ * 与 `dataRaw` 是**同一件事的两种书写形态**,不是两套对象:构建期由
79
+ * `normalizeSurfaceObject()` 展开成核心层后并进 `data` 段,之后一路走
80
+ * 同一个数据解析器、同一份 API 白名单校验、同一份运行时资产。
81
+ * 分成两个字段只到编译期为止——再往下游只有核心层(§2.3 判据 3:转换只发生一次)。
82
+ */
83
+ surfaceRaw?: Record<string, unknown>;
53
84
  scope: BlockScope;
54
85
  }
55
86
 
@@ -80,9 +111,17 @@ export function parsePageBlock(input: ParsePageInput): PageBlockAst {
80
111
  fail('page 块缺少 domain(页面 Domain 类名,必填)');
81
112
  }
82
113
 
114
+ // 表层对象与核心层对象共用一个命名空间:它们在构建期会并成一份 `data`,
115
+ // 所以作用域这里就得两份都认。少认表层的那一半时,`ui:` 里绑到表层对象的路径
116
+ // 会被判成"未知对象"——而那条错误指向的是绑定那一行,不是漏登记这件事。
117
+ // 撞名不在这里判(这里只有原文、没有展开结果):由 compilePageDeclaration 当场拒收,
118
+ // 那里能同时说清"两处都声明了同一个名字"以及各自写在哪。
83
119
  const scope = buildBlockScope({
84
120
  blockId: 'page',
85
- dataNames: Object.keys((body.data as Record<string, unknown>) ?? {}),
121
+ dataNames: [...new Set([
122
+ ...Object.keys((body.data as Record<string, unknown>) ?? {}),
123
+ ...Object.keys((body.objects as Record<string, unknown>) ?? {}),
124
+ ])],
86
125
  aliasRaw: body.alias as Record<string, unknown> | undefined,
87
126
  });
88
127
 
@@ -148,6 +187,9 @@ export function parsePageBlock(input: ParsePageInput): PageBlockAst {
148
187
  if (body.layout !== undefined) {
149
188
  ui.layout = body.layout as UiConfig['layout'];
150
189
  }
190
+ if (body.ooui !== undefined) {
191
+ ui.ooui = body.ooui as UiConfig['ooui'];
192
+ }
151
193
 
152
194
  // ── event 段:面向 DOM ─────────────────────────────────────────────────
153
195
  const eventRaw = normalizeEventSection(body.event, input, fail);
@@ -156,6 +198,7 @@ export function parsePageBlock(input: ParsePageInput): PageBlockAst {
156
198
  ui,
157
199
  eventRaw,
158
200
  ...(body.data ? { dataRaw: body.data as Record<string, unknown> } : {}),
201
+ ...(body.objects ? { surfaceRaw: body.objects as Record<string, unknown> } : {}),
159
202
  scope,
160
203
  };
161
204
  }