soma-kit 0.1.11 → 0.1.13

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 (376) hide show
  1. package/README.md +106 -112
  2. package/bin/soma-kit.mjs +32 -2
  3. package/bin/soma.mjs +22 -0
  4. package/package.json +14 -7
  5. package/packs/finance/reconcile-board.ts +5 -2
  6. package/packs/finance/reconcile-desk/compile.ts +3 -2
  7. package/spec/generated/kit-app.schema.json +929 -37
  8. package/spec/generated/kit-page.schema.json +1684 -161
  9. package/spec/kit-grammar.json +1176 -584
  10. package/spec/kit-grammar.schema.json +1971 -393
  11. package/src/app/app-config.ts +449 -347
  12. package/src/app/component-gate.ts +283 -28
  13. package/src/app/compose-apps.ts +79 -8
  14. package/src/app/define-kit-actions.ts +245 -41
  15. package/src/app/define-kit-app.ts +176 -33
  16. package/src/app/define-kit-view.ts +104 -0
  17. package/src/app/dev-diagnostic.ts +5 -0
  18. package/src/app/envelope.ts +1 -161
  19. package/src/app/index.ts +29 -6
  20. package/src/app/kit-view-context.ts +439 -0
  21. package/src/app/notify-renderer.ts +1 -115
  22. package/src/app/paged-list-adapter.ts +1 -240
  23. package/src/app/render-ports.ts +18 -0
  24. package/src/app/server-pages.ts +11 -3
  25. package/src/app/server.ts +530 -103
  26. package/src/app/submit.types.ts +1 -1
  27. package/src/app/theme-endpoint.ts +63 -0
  28. package/src/app/theme-runtime-shared.ts +1 -0
  29. package/src/app/theme-runtime.ts +667 -0
  30. package/src/base/action-busy.ts +103 -6
  31. package/src/base/action-gate.ts +4 -255
  32. package/src/base/action-slots.ts +58 -0
  33. package/src/base/alert.ts +5 -3
  34. package/src/base/anchored-layer.ts +50 -0
  35. package/src/base/avatar.ts +2 -2
  36. package/src/base/button.ts +99 -37
  37. package/src/base/cascader.ts +11 -12
  38. package/src/base/check-core.ts +9 -1
  39. package/src/base/checkbox.ts +2 -1
  40. package/src/base/choice.ts +49 -28
  41. package/src/base/class-candidates.ts +17 -0
  42. package/src/base/color-picker.ts +16 -11
  43. package/src/base/combobox.ts +5 -3
  44. package/src/base/command-palette.ts +10 -6
  45. package/src/base/context-menu.ts +10 -7
  46. package/src/base/countdown.ts +1 -1
  47. package/src/base/date-range.ts +32 -18
  48. package/src/base/date.ts +135 -28
  49. package/src/base/delta.ts +72 -0
  50. package/src/base/divider.ts +2 -2
  51. package/src/base/end-edge.ts +49 -0
  52. package/src/base/fab.ts +12 -5
  53. package/src/base/gap-value.ts +148 -0
  54. package/src/base/hint-tips.ts +170 -0
  55. package/src/base/icons.ts +8 -0
  56. package/src/base/illustrations.ts +94 -0
  57. package/src/base/image.ts +1 -1
  58. package/src/base/index.ts +35 -11
  59. package/src/base/input.ts +42 -13
  60. package/src/base/kbd.ts +3 -1
  61. package/src/base/link.ts +4 -4
  62. package/src/base/listbox-core.ts +56 -35
  63. package/src/base/loading-gate.ts +186 -0
  64. package/src/base/mentions.ts +7 -6
  65. package/src/base/menu-button.ts +28 -12
  66. package/src/base/menu-core.ts +41 -8
  67. package/src/base/motion/aura.ts +2 -2
  68. package/src/base/motion/hover-3d.ts +3 -3
  69. package/src/base/motion/hover-gallery.ts +2 -2
  70. package/src/base/motion/marquee.ts +3 -3
  71. package/src/base/motion/text-rotate.ts +2 -2
  72. package/src/base/number.ts +93 -80
  73. package/src/base/otp.ts +9 -5
  74. package/src/base/overlay-runtime.ts +235 -0
  75. package/src/base/permission-gate.ts +6 -0
  76. package/src/base/popover.ts +48 -16
  77. package/src/base/popup.ts +143 -19
  78. package/src/base/portal-core.ts +4 -0
  79. package/src/base/price-text.ts +2 -2
  80. package/src/base/progress.ts +2 -2
  81. package/src/base/qr-code.ts +4 -4
  82. package/src/base/qty-stepper.ts +14 -8
  83. package/src/base/radio.ts +2 -1
  84. package/src/base/range.ts +21 -4
  85. package/src/base/rating.ts +12 -7
  86. package/src/base/reason-tip.ts +150 -0
  87. package/src/base/segmented.ts +27 -21
  88. package/src/base/select.ts +4 -3
  89. package/src/base/shared.ts +387 -49
  90. package/src/base/state-panel.ts +346 -0
  91. package/src/base/status-tone.ts +27 -0
  92. package/src/base/sticky-edge.ts +116 -0
  93. package/src/base/swap.ts +10 -7
  94. package/src/base/switch.ts +11 -6
  95. package/src/base/tag-input.ts +20 -16
  96. package/src/base/tag.ts +68 -34
  97. package/src/base/text.ts +80 -18
  98. package/src/base/textarea.ts +37 -11
  99. package/src/base/time-picker.ts +18 -13
  100. package/src/base/tree-select.ts +21 -12
  101. package/src/base/trend-tone.ts +9 -0
  102. package/src/base/upload.ts +48 -14
  103. package/src/base/view-transition.ts +77 -0
  104. package/src/base/virtual-list.ts +107 -1
  105. package/src/biz/approval-desk/compile.ts +23 -41
  106. package/src/biz/approval-desk/shell.ts +11 -8
  107. package/src/biz/auth-panel/compile.ts +37 -52
  108. package/src/biz/auth-panel/index.ts +1 -1
  109. package/src/biz/auth-panel/shell.ts +5 -4
  110. package/src/biz/category-crud/compile.ts +23 -37
  111. package/src/biz/category-crud/shell.ts +2 -1
  112. package/src/biz/checkout-page/compile.ts +22 -5
  113. package/src/biz/checkout-page/shell.ts +4 -3
  114. package/src/biz/compose.ts +13 -27
  115. package/src/biz/define.ts +5 -4
  116. package/src/biz/import-wizard/compile.ts +22 -26
  117. package/src/biz/import-wizard/hub.ts +126 -61
  118. package/src/biz/import-wizard/shell.ts +5 -4
  119. package/src/biz/index.ts +3 -3
  120. package/src/biz/landing-page/compile.ts +19 -3
  121. package/src/biz/link/hub.ts +69 -22
  122. package/src/biz/link/shared.ts +127 -119
  123. package/src/biz/master-sub/compile.ts +127 -48
  124. package/src/biz/master-sub/index.ts +5 -2
  125. package/src/biz/master-sub/shell.ts +95 -18
  126. package/src/biz/multi-board/compile.ts +38 -50
  127. package/src/biz/multi-board/index.ts +18 -1
  128. package/src/biz/multi-board/shell.ts +32 -20
  129. package/src/biz/notification-center/compile.ts +21 -33
  130. package/src/biz/notification-center/shell.ts +6 -4
  131. package/src/biz/page-templates/domain-templates.ts +80 -13
  132. package/src/biz/page-templates/result-page/compile.ts +11 -2
  133. package/src/biz/page-templates/result-page/shell.ts +2 -1
  134. package/src/biz/page-templates/shared.ts +34 -36
  135. package/src/biz/page-templates/sign-in-page/shell.ts +2 -2
  136. package/src/biz/record-detail/compile.ts +48 -43
  137. package/src/biz/record-detail/index.ts +11 -1
  138. package/src/biz/record-detail/shell.ts +8 -6
  139. package/src/biz/settings-center/compile.ts +7 -5
  140. package/src/biz/settings-center/shell.ts +6 -4
  141. package/src/biz/shared/action-host.ts +97 -211
  142. package/src/biz/shared/compile-helpers.ts +98 -0
  143. package/src/biz/shared/coordinator.ts +472 -92
  144. package/src/biz/shared/index.ts +13 -2
  145. package/src/biz/shared/object-aliases.ts +154 -0
  146. package/src/biz/shared/overlay-compile.ts +239 -0
  147. package/src/biz/shared/overlay-shell.ts +209 -0
  148. package/src/biz/shared/pipes.ts +50 -31
  149. package/src/biz/shared/remove-wire.ts +14 -0
  150. package/src/biz/shared/runtime-hub.ts +226 -24
  151. package/src/biz/single-form/compile.ts +16 -37
  152. package/src/biz/single-form/shell.ts +4 -3
  153. package/src/biz/standard-crud/compile.ts +72 -255
  154. package/src/biz/standard-crud/shell.ts +21 -99
  155. package/src/biz/step-form/compile.ts +26 -97
  156. package/src/biz/step-form/hub.ts +34 -41
  157. package/src/biz/step-form/shell.ts +5 -5
  158. package/src/biz/types.ts +4 -3
  159. package/src/cli/core-imports.ts +54 -0
  160. package/src/cli/kit-cli.ts +254 -25
  161. package/src/cli/kit-init.ts +227 -0
  162. package/src/cli/layout-cli.ts +167 -0
  163. package/src/cli/migrate/index.ts +10 -0
  164. package/src/cli/migrate/migrate.ts +248 -0
  165. package/src/cli/migrate/text-utils.ts +306 -0
  166. package/src/cli/migrate/theme-map.ts +104 -0
  167. package/src/cli/migrate/ts-rules.ts +235 -0
  168. package/src/cli/migrate/types.ts +95 -0
  169. package/src/cli/migrate/view-skeleton.ts +159 -0
  170. package/src/cli/migrate/yaml-report.ts +376 -0
  171. package/src/cli/migrate/yaml-rules.ts +465 -0
  172. package/src/cli/service-endpoint-check.ts +425 -0
  173. package/src/cli/source-path-check.d.mts +17 -0
  174. package/src/cli/source-path-check.mjs +334 -0
  175. package/src/cli/view-writes.ts +761 -0
  176. package/src/compile/action-host-attach.ts +21 -29
  177. package/src/compile/closed-set.ts +570 -0
  178. package/src/compile/compile-page.ts +267 -76
  179. package/src/compile/component-candidates.ts +13 -2
  180. package/src/compile/hints.ts +30 -1
  181. package/src/compile/index.ts +1 -0
  182. package/src/compile/kit-error.ts +1 -0
  183. package/src/compile/layout-lint/engine.ts +82 -0
  184. package/src/compile/layout-lint/index.ts +55 -0
  185. package/src/compile/layout-lint/rules-composition.ts +218 -0
  186. package/src/compile/layout-lint/rules-form.ts +192 -0
  187. package/src/compile/layout-lint/rules-table.ts +194 -0
  188. package/src/compile/layout-lint/score.ts +52 -0
  189. package/src/compile/layout-lint/types.ts +51 -0
  190. package/src/compile/locate.ts +21 -1
  191. package/src/compile/parse.ts +370 -41
  192. package/src/compile/redirect.ts +6 -2
  193. package/src/compile/remove-guard.ts +10 -7
  194. package/src/compile/styles.ts +63 -2
  195. package/src/compile/types.ts +31 -3
  196. package/src/compile/view-check.ts +284 -0
  197. package/src/data/amount-breakdown.ts +8 -3
  198. package/src/data/anchor-nav.ts +2 -2
  199. package/src/data/approval-flow.ts +3 -3
  200. package/src/data/assignment-picker.ts +92 -55
  201. package/src/data/async-result-panel.ts +111 -9
  202. package/src/data/breadcrumbs.ts +5 -4
  203. package/src/data/calendar.ts +24 -27
  204. package/src/data/carousel.ts +13 -8
  205. package/src/data/chart.ts +183 -44
  206. package/src/data/checklist.ts +20 -7
  207. package/src/data/code-view.ts +12 -6
  208. package/src/data/comment-thread.ts +7 -4
  209. package/src/data/confirm-dialog.ts +81 -18
  210. package/src/data/context-menu.ts +29 -37
  211. package/src/data/d9-util.ts +2 -18
  212. package/src/data/diff.ts +4 -2
  213. package/src/data/dock.ts +3 -3
  214. package/src/data/embed.ts +233 -30
  215. package/src/data/field-mapper.ts +35 -30
  216. package/src/data/flow-editor-contract.ts +8 -1
  217. package/src/data/flow-editor.ts +113 -108
  218. package/src/data/flow-node-options.ts +120 -0
  219. package/src/data/flow-remote-options.ts +0 -103
  220. package/src/data/footer.ts +2 -2
  221. package/src/data/form-draft-registry.ts +2 -4
  222. package/src/data/gantt.ts +19 -19
  223. package/src/data/hero.ts +4 -3
  224. package/src/data/image-viewer.ts +27 -30
  225. package/src/data/index.ts +5 -2
  226. package/src/data/item-list.ts +48 -31
  227. package/src/data/kanban.ts +82 -52
  228. package/src/data/media-grid.ts +20 -20
  229. package/src/data/mega-menu.ts +6 -4
  230. package/src/data/menu-dom.ts +4 -2
  231. package/src/data/menu.ts +47 -15
  232. package/src/data/mockup.ts +10 -6
  233. package/src/data/modal-dialog.ts +49 -25
  234. package/src/data/navbar.ts +12 -7
  235. package/src/data/notice-list.ts +268 -0
  236. package/src/data/notify-renderer.ts +250 -0
  237. package/src/data/object-form.ts +1360 -666
  238. package/src/data/outcome-watch.ts +61 -2
  239. package/src/data/pager.ts +80 -34
  240. package/src/data/permission-matrix.ts +52 -31
  241. package/src/data/permission-tree.ts +71 -44
  242. package/src/data/pricing-table.ts +30 -14
  243. package/src/data/prompt-dialog.ts +124 -194
  244. package/src/data/reaction-bar.ts +83 -92
  245. package/src/data/read-rollback.ts +73 -0
  246. package/src/data/record-card.ts +26 -5
  247. package/src/data/record-picker.ts +104 -55
  248. package/src/data/redirect.ts +32 -32
  249. package/src/data/remote-options.ts +13 -6
  250. package/src/data/request-console.ts +5 -3
  251. package/src/data/resident.ts +2 -1
  252. package/src/data/result-panel.ts +8 -4
  253. package/src/data/rich-text.ts +61 -55
  254. package/src/data/row-editor.ts +362 -76
  255. package/src/data/rule-builder.ts +26 -20
  256. package/src/data/shape-util.ts +27 -9
  257. package/src/data/stat-group.ts +392 -109
  258. package/src/data/static-lazy.ts +1 -0
  259. package/src/data/static-registry.ts +24 -11
  260. package/src/data/steps.ts +10 -5
  261. package/src/data/survey.ts +27 -32
  262. package/src/data/system-switcher.ts +3 -3
  263. package/src/data/text-action-button.ts +17 -0
  264. package/src/data/timeline.ts +19 -8
  265. package/src/data/tour-guide.ts +23 -30
  266. package/src/data/transfer.ts +62 -38
  267. package/src/data/tree-table.ts +152 -78
  268. package/src/data/tree.ts +49 -36
  269. package/src/data/trend-line.ts +6 -24
  270. package/src/data/virtual-rows.ts +133 -82
  271. package/src/data/watermark.ts +2 -2
  272. package/src/data/wrap.ts +63 -38
  273. package/src/data/wrapped-candidates.ts +10 -0
  274. package/src/frames/blank-frame.ts +1 -0
  275. package/src/frames/index.ts +2 -2
  276. package/src/frames/page-bar.ts +26 -24
  277. package/src/frames/page-header.ts +14 -5
  278. package/src/frames/page-status.ts +9 -7
  279. package/src/frames/shared.ts +36 -25
  280. package/src/frames/single-frame.ts +1 -0
  281. package/src/frames/split-frame/shell.ts +6 -6
  282. package/src/frames/split-frame/wiring.ts +2 -2
  283. package/src/frames/tabs-frame/shell.ts +4 -14
  284. package/src/frames/tabs-frame/wiring.ts +5 -8
  285. package/src/frames/top-main-frame.ts +3 -2
  286. package/src/frames/types.ts +13 -2
  287. package/src/frames/workspace-frame/extras.ts +21 -5
  288. package/src/frames/workspace-frame/index.ts +1 -1
  289. package/src/frames/workspace-frame/shell.ts +3 -2
  290. package/src/frames/workspace-frame/state.ts +13 -6
  291. package/src/frames/workspace-frame/view.ts +250 -48
  292. package/src/generated/kit-grammar-runtime.ts +645 -397
  293. package/src/generated/page-origin.ts +0 -11
  294. package/src/i18n/kit-text.ts +84 -29
  295. package/src/i18n/resolve-text-refs.ts +22 -6
  296. package/src/index.ts +2 -1
  297. package/src/object-renderer/action-gate.ts +11 -147
  298. package/src/object-renderer/arrange.ts +112 -84
  299. package/src/object-renderer/collapse-wiring.ts +2 -2
  300. package/src/object-renderer/collection-expand.ts +2 -2
  301. package/src/object-renderer/collection-parts.ts +401 -104
  302. package/src/object-renderer/collection-table.ts +287 -45
  303. package/src/object-renderer/collection.ts +258 -104
  304. package/src/object-renderer/compile-data.ts +112 -102
  305. package/src/object-renderer/crud-bridge.ts +32 -0
  306. package/src/object-renderer/defaults.ts +38 -16
  307. package/src/object-renderer/display-checks.ts +4 -25
  308. package/src/object-renderer/emit-events.ts +224 -176
  309. package/src/object-renderer/emit-object.ts +15 -2
  310. package/src/object-renderer/emit-static.ts +533 -151
  311. package/src/object-renderer/field-value.ts +593 -396
  312. package/src/object-renderer/filter-reload.ts +70 -0
  313. package/src/object-renderer/form-detail.ts +111 -2
  314. package/src/object-renderer/form-notify.ts +45 -0
  315. package/src/object-renderer/index.ts +26 -0
  316. package/src/object-renderer/key-field.ts +12 -0
  317. package/src/object-renderer/layout-facts.ts +386 -0
  318. package/src/object-renderer/layout-plan.ts +132 -0
  319. package/src/object-renderer/layout-plan.types.ts +22 -0
  320. package/src/object-renderer/linkage.ts +7 -270
  321. package/src/object-renderer/merge-class.ts +18 -1
  322. package/src/object-renderer/parts.ts +252 -1
  323. package/src/object-renderer/path-pick.ts +27 -0
  324. package/src/object-renderer/render-object.ts +456 -89
  325. package/src/object-renderer/request-actions.ts +232 -249
  326. package/src/object-renderer/skeleton.ts +58 -19
  327. package/src/object-renderer/table-actions.ts +319 -111
  328. package/src/object-renderer/table-summary.ts +2 -2
  329. package/src/object-renderer/table-tools.ts +429 -94
  330. package/src/object-renderer/types.ts +204 -127
  331. package/src/object-renderer/view-binding.ts +393 -0
  332. package/src/page-target/ai-surface.ts +37 -0
  333. package/src/page-target/compile.ts +48 -8
  334. package/src/page-target/index.ts +8 -1
  335. package/src/page-target/intent-schema.ts +165 -28
  336. package/src/page-target/target.ts +262 -51
  337. package/src/page-target/writer-policy.ts +14 -3
  338. package/src/recipes/container.ts +210 -0
  339. package/src/recipes/control.ts +277 -0
  340. package/src/recipes/index.ts +312 -0
  341. package/src/recipes/nowrap.ts +16 -0
  342. package/src/recipes/overlay.ts +240 -0
  343. package/src/recipes/placeholder.ts +79 -0
  344. package/src/recipes/rail-grid.ts +45 -0
  345. package/src/recipes/slot-align.ts +56 -0
  346. package/src/recipes/state.ts +99 -0
  347. package/src/recipes/status.ts +139 -0
  348. package/src/recipes/surface.ts +40 -0
  349. package/src/recipes/table-row.ts +88 -0
  350. package/src/recipes/title-row.ts +37 -0
  351. package/src/recipes/typography.ts +99 -0
  352. package/src/shared/action-field-guard.ts +41 -0
  353. package/src/shared/confirm-decl.ts +118 -0
  354. package/src/shared/envelope.ts +207 -0
  355. package/src/shared/escape.ts +57 -0
  356. package/src/shared/kit-error.ts +21 -0
  357. package/src/shared/paged-list-adapter.ts +15 -0
  358. package/src/shared/path-guard.ts +127 -0
  359. package/src/shared/theme-runtime-shared.ts +180 -0
  360. package/src/shared/view-info.ts +10 -0
  361. package/src/theme/index.ts +13 -0
  362. package/src/theme/kit-theme-text.ts +1 -1
  363. package/src/theme/kit-theme.css +407 -10
  364. package/src/theme/kit-theme.tpl +407 -10
  365. package/src/theme/nine-dim-structure.ts +247 -0
  366. package/src/theme/surface-layers.ts +101 -0
  367. package/src/theme/theme-tokens.ts +130 -84
  368. package/src/theme/theme-types.ts +103 -0
  369. package/src/theme/typography.ts +17 -17
  370. package/src/biz/shared/step-values.ts +0 -25
  371. package/src/biz/step-form/steps-ref.ts +0 -112
  372. package/src/data/options-bus.ts +0 -24
  373. package/src/object-renderer/adopt-gate.ts +0 -333
  374. package/src/object-renderer/field-policy.ts +0 -89
  375. package/src/object-renderer/outcome-draft.ts +0 -61
  376. package/src/theme/nine-dim-palettes.ts +0 -1473
@@ -1,226 +1,76 @@
1
1
  // kit.app.yaml 的解析后形状与检查(纯函数,只验形状;与 soma.app.ts 的代码登记对账在 server 面做)。
2
2
 
3
3
  import type { KitDiagnostic } from '../object-renderer/types';
4
+ import { checkNoRelativeOrSystemPath } from '../shared/path-guard';
4
5
  import { parseKitEnvelope, type KitEnvelope } from './envelope';
6
+ import { KIT_LAYOUT_VERSIONS, normalizeLayoutPin } from '../object-renderer/layout-plan';
5
7
 
6
- /** 01 · 主题配色枚举(24 套全行业主题配色) */
7
- export type KitThemePalette =
8
- | 'CLASSIC_TECH_BLUE'
9
- | 'BUSINESS_INDIGO_BLUE'
10
- | 'FAR_MOUNTAIN_SKY'
11
- | 'GLACIER_STEEL_BLUE'
12
- | 'GOVERNMENT_RED'
13
- | 'PROSPEROUS_CHINA_RED'
14
- | 'AMBER_TERRACOTTA'
15
- | 'GILT_BUSINESS_BROWN'
16
- | 'FINANCIAL_EMERALD'
17
- | 'BAMBOO_FOREST_CYAN'
18
- | 'TURQUOISE_LAKE'
19
- | 'OLIVE_EARTH_GREEN'
20
- | 'INNOVATIVE_VIOLET'
21
- | 'LILAC_TWILIGHT'
22
- | 'CORAL_PEACH_PINK'
23
- | 'NEBULA_PLUM_PURPLE'
24
- | 'MINIMAL_MONOCHROME'
25
- | 'INDUSTRIAL_STEEL_GRAY'
26
- | 'WARM_XUAN_PAPER'
27
- | 'MATCHA_EYE_CARE'
28
- | 'DEEP_OCEAN_DARK'
29
- | 'GEEK_VIOLET_DARK'
30
- | 'OBSIDIAN_NIGHT_DARK'
31
- | 'FOREST_PINE_DARK';
32
-
33
- export const KIT_THEME_PALETTES: readonly KitThemePalette[] = [
34
- 'CLASSIC_TECH_BLUE',
35
- 'BUSINESS_INDIGO_BLUE',
36
- 'FAR_MOUNTAIN_SKY',
37
- 'GLACIER_STEEL_BLUE',
38
- 'GOVERNMENT_RED',
39
- 'PROSPEROUS_CHINA_RED',
40
- 'AMBER_TERRACOTTA',
41
- 'GILT_BUSINESS_BROWN',
42
- 'FINANCIAL_EMERALD',
43
- 'BAMBOO_FOREST_CYAN',
44
- 'TURQUOISE_LAKE',
45
- 'OLIVE_EARTH_GREEN',
46
- 'INNOVATIVE_VIOLET',
47
- 'LILAC_TWILIGHT',
48
- 'CORAL_PEACH_PINK',
49
- 'NEBULA_PLUM_PURPLE',
50
- 'MINIMAL_MONOCHROME',
51
- 'INDUSTRIAL_STEEL_GRAY',
52
- 'WARM_XUAN_PAPER',
53
- 'MATCHA_EYE_CARE',
54
- 'DEEP_OCEAN_DARK',
55
- 'GEEK_VIOLET_DARK',
56
- 'OBSIDIAN_NIGHT_DARK',
57
- 'FOREST_PINE_DARK',
58
- ];
59
-
60
- /** 02 · 颜色深浅枚举(5 档,在当前主题配色基础上调淡或调深) */
61
- export type KitThemeColorDepth =
62
- | 'NORMAL'
63
- | 'LIGHTENED'
64
- | 'DARKENED'
65
- | 'VERY_LIGHT'
66
- | 'SLIGHTLY_LIGHT'
67
- | 'STANDARD_DEPTH'
68
- | 'SLIGHTLY_DEEP'
69
- | 'VERY_DEEP';
70
-
71
- export const KIT_THEME_COLOR_DEPTHS: readonly KitThemeColorDepth[] = [
72
- 'NORMAL',
73
- 'LIGHTENED',
74
- 'DARKENED',
75
- 'VERY_LIGHT',
76
- 'SLIGHTLY_LIGHT',
77
- 'STANDARD_DEPTH',
78
- 'SLIGHTLY_DEEP',
79
- 'VERY_DEEP',
80
- ];
81
-
82
- /** 03 · 颜色鲜艳度枚举(4 档) */
83
- export type KitThemeColorSaturation =
84
- | 'VIVID'
85
- | 'STANDARD_SATURATION'
86
- | 'SOFT_MUTED'
87
- | 'LOW_COLOR';
88
-
89
- export const KIT_THEME_COLOR_SATURATIONS: readonly KitThemeColorSaturation[] = [
90
- 'VIVID',
91
- 'STANDARD_SATURATION',
92
- 'SOFT_MUTED',
93
- 'LOW_COLOR',
94
- ];
95
-
96
- /** 04 · 字体类型枚举(6 种) */
97
- export type KitThemeFontFamily =
98
- | 'SYSTEM_SANS'
99
- | 'GEOMETRIC_ROUNDED'
100
- | 'INDUSTRIAL_REPORT'
101
- | 'EDITORIAL_SERIF'
102
- | 'GEEK_MONO'
103
- | 'BOLD_DISPLAY';
104
-
105
- export const KIT_THEME_FONT_FAMILIES: readonly KitThemeFontFamily[] = [
106
- 'SYSTEM_SANS',
107
- 'GEOMETRIC_ROUNDED',
108
- 'INDUSTRIAL_REPORT',
109
- 'EDITORIAL_SERIF',
110
- 'GEEK_MONO',
111
- 'BOLD_DISPLAY',
112
- ];
113
-
114
- /** 05 · 字体大小与行距枚举(4 档) */
115
- export type KitThemeFontScale =
116
- | 'SMALL_COMPACT'
117
- | 'MEDIUM_STANDARD'
118
- | 'LARGE_LOOSE'
119
- | 'XLARGE_DISPLAY';
120
-
121
- export const KIT_THEME_FONT_SCALES: readonly KitThemeFontScale[] = [
122
- 'SMALL_COMPACT',
123
- 'MEDIUM_STANDARD',
124
- 'LARGE_LOOSE',
125
- 'XLARGE_DISPLAY',
126
- ];
127
-
128
- /** 06 · 组件边界方案枚举(严格二选一) */
129
- export type KitThemeBoundary =
130
- | 'HAIRLINE_BORDER'
131
- | 'BORDERLESS_SHADOW';
132
-
133
- export const KIT_THEME_BOUNDARIES: readonly KitThemeBoundary[] = [
134
- 'HAIRLINE_BORDER',
135
- 'BORDERLESS_SHADOW',
136
- ];
137
-
138
- /** 07 · 组件圆角与形状枚举(4 档) */
139
- export type KitThemeShape =
140
- | 'STANDARD_ROUNDED'
141
- | 'SMALL_SHARP'
142
- | 'PILL_CAPSULE'
143
- | 'PURE_SQUARE';
144
-
145
- export const KIT_THEME_SHAPES: readonly KitThemeShape[] = [
146
- 'STANDARD_ROUNDED',
147
- 'SMALL_SHARP',
148
- 'PILL_CAPSULE',
149
- 'PURE_SQUARE',
150
- ];
151
-
152
- /** 08 · 组件表面质感枚举(3 档) */
153
- export type KitThemeSurfaceTexture =
154
- | 'SOLID_MATTE'
155
- | 'FROSTED_GLASS'
156
- | 'SUBTLE_RELIEF';
157
-
158
- export const KIT_THEME_SURFACE_TEXTURES: readonly KitThemeSurfaceTexture[] = [
159
- 'SOLID_MATTE',
160
- 'FROSTED_GLASS',
161
- 'SUBTLE_RELIEF',
162
- ];
163
-
164
- /** 09 · 空间松紧度枚举(3 档,兼容旧值) */
165
- export type KitThemeDensity =
166
- | 'COMPACT_DENSE'
167
- | 'STANDARD_BALANCED'
168
- | 'SPACIOUS_AIRY'
169
- | 'compact'
170
- | 'comfortable'
171
- | 'spacious'
172
- | 'standard';
173
-
174
- export const KIT_THEME_DENSITIES: readonly KitThemeDensity[] = [
175
- 'COMPACT_DENSE',
176
- 'STANDARD_BALANCED',
177
- 'SPACIOUS_AIRY',
178
- 'compact',
179
- 'comfortable',
180
- 'spacious',
181
- 'standard',
182
- ];
183
-
184
- /** kit.app.yaml 的 theme 段(9 维正交页面主题 DSL 规格 + 基础编译可选兼容字段) */
185
- export interface KitAppTheme {
186
- /** 01 · 主题配色枚举(24 套全行业主题配色) */
187
- palette?: KitThemePalette;
188
- /** 02 · 颜色深浅枚举(5 档) */
189
- color_depth?: KitThemeColorDepth;
190
- colorDepth?: KitThemeColorDepth;
191
- /** 03 · 颜色鲜艳度枚举(4 档) */
192
- color_saturation?: KitThemeColorSaturation;
193
- colorSaturation?: KitThemeColorSaturation;
194
- /** 04 · 字体类型枚举(6 种) */
195
- font_family?: KitThemeFontFamily;
196
- fontFamily?: KitThemeFontFamily;
197
- /** 05 · 字体大小与行距枚举(4 档) */
198
- font_scale?: KitThemeFontScale;
199
- fontScale?: KitThemeFontScale;
200
- /** 06 · 组件边界方案枚举(严格二选一) */
201
- boundary?: KitThemeBoundary;
202
- /** 07 · 组件圆角与形状枚举(4 档) */
203
- shape?: KitThemeShape;
204
- /** 08 · 组件表面质感枚举(3 档) */
205
- surface_texture?: KitThemeSurfaceTexture;
206
- surfaceTexture?: KitThemeSurfaceTexture;
207
- /** 09 · 空间松紧度枚举(3 档,兼容旧值) */
208
- density?: KitThemeDensity;
209
-
210
-
211
- /** 保留基础 preset/polarity/density/radius 作为底层编译可选兼容字段 */
212
- preset?: string;
213
- polarity?: string;
214
- radius?: string;
215
- mode?: string;
216
- color?: string;
217
- paletteScheme?: string;
218
- fontScheme?: string;
219
- colorScheme?: string;
220
- tone?: string;
221
- typographyScheme?: string;
222
- componentStyle?: string;
223
- }
8
+ export type {
9
+ KitThemePalette,
10
+ KitThemeColorDepth,
11
+ KitThemeColorSaturation,
12
+ KitThemeFontFamily,
13
+ KitThemeFontScale,
14
+ KitThemeBoundary,
15
+ KitThemeShape,
16
+ KitThemeSurfaceTexture,
17
+ KitThemeDensity,
18
+ KitThemeMotion,
19
+ KitThemeTableStyle,
20
+ KitThemeContrast,
21
+ KitThemeAccentUsage,
22
+ KitThemePreset,
23
+ KitAppTheme,
24
+ } from '../theme/theme-types';
25
+ export {
26
+ KIT_THEME_PALETTES,
27
+ KIT_THEME_COLOR_DEPTHS,
28
+ KIT_THEME_COLOR_SATURATIONS,
29
+ KIT_THEME_FONT_FAMILIES,
30
+ KIT_THEME_FONT_SCALES,
31
+ KIT_THEME_BOUNDARIES,
32
+ KIT_THEME_SHAPES,
33
+ KIT_THEME_SURFACE_TEXTURES,
34
+ KIT_THEME_DENSITIES,
35
+ KIT_THEME_MOTIONS,
36
+ KIT_THEME_TABLE_STYLES,
37
+ KIT_THEME_CONTRASTS,
38
+ KIT_THEME_ACCENT_USAGES,
39
+ KIT_THEME_PRESETS,
40
+ } from '../theme/theme-types';
41
+ import {
42
+ KIT_THEME_PALETTES,
43
+ KIT_THEME_COLOR_DEPTHS,
44
+ KIT_THEME_COLOR_SATURATIONS,
45
+ KIT_THEME_FONT_FAMILIES,
46
+ KIT_THEME_FONT_SCALES,
47
+ KIT_THEME_BOUNDARIES,
48
+ KIT_THEME_SHAPES,
49
+ KIT_THEME_SURFACE_TEXTURES,
50
+ KIT_THEME_DENSITIES,
51
+ KIT_THEME_MOTIONS,
52
+ KIT_THEME_TABLE_STYLES,
53
+ KIT_THEME_CONTRASTS,
54
+ KIT_THEME_ACCENT_USAGES,
55
+ KIT_THEME_PRESETS,
56
+ type KitThemeAccentUsage,
57
+ type KitThemePreset,
58
+ type KitThemeMotion,
59
+ type KitThemeTableStyle,
60
+ type KitThemeContrast,
61
+ type KitThemePalette,
62
+ type KitThemeColorDepth,
63
+ type KitThemeColorSaturation,
64
+ type KitThemeFontFamily,
65
+ type KitThemeFontScale,
66
+ type KitThemeBoundary,
67
+ type KitThemeShape,
68
+ type KitThemeSurfaceTexture,
69
+ type KitThemeDensity,
70
+ type KitAppTheme,
71
+ } from '../theme/theme-types';
72
+ import { KIT_THEME_MODES } from '../theme/theme-tokens';
73
+ export { KIT_THEME_MODES };
224
74
 
225
75
  export interface KitAppLayoutNavItem {
226
76
  id: string;
@@ -250,11 +100,22 @@ export interface KitAppLayout {
250
100
  };
251
101
  }
252
102
 
103
+ export interface KitDictOption {
104
+ value: string | number | boolean;
105
+ label: string;
106
+ tone?: string;
107
+ }
108
+
109
+ export type KitAppDicts = Record<string, KitDictOption[]>;
110
+ export type KitAppEntities = Record<string, Record<string, unknown>>;
111
+
253
112
  export interface KitAppConfig {
254
113
  /** 主题:9 维正交页面主题 DSL 规格或基础方案 */
255
114
  theme?: KitAppTheme;
256
115
  /** 默认页面布局配置:继承给子页面 */
257
116
  layout?: KitAppLayout;
117
+ /** 布局规则版本钉(`layout.rules`,RV-1117):缺省 0 = 现状 12 份均分,输出逐字节不变;只写 rules 不算启用外框继承 */
118
+ layoutRules?: number;
258
119
  /** 主题头文件路径(相对应用根);缺省用内置 kit-theme.css */
259
120
  style?: string;
260
121
  /** 应用扩展的基础组件:名字 -> 说明 */
@@ -263,10 +124,17 @@ export interface KitAppConfig {
263
124
  staticObjectComponents: Record<string, { accept: 'single' | 'list'; desc: string }>;
264
125
  /** 业务信封约定(失败判定 / 业务文案位置 / 数据位置):声明一次,编译与运行时共读;页面 page.envelope 可覆写 */
265
126
  envelope?: KitEnvelope;
127
+ /** 应用级共享枚举字典(供页面 schema 字段 options: '$dict.<name>' 编译期静态展开) */
128
+ dicts?: KitAppDicts;
129
+ /** 应用级共享实体字段定义(供页面对象 schema: '$entity.<name>' 或 { $ref: '$entity.<name>', pick?, omit?, override? } 编译期静态展开) */
130
+ entities?: KitAppEntities;
266
131
  }
267
132
 
268
133
  const APP_NAME = /^App[A-Z][A-Za-z0-9]*$/;
269
- const TOP_KEYS = ['style', 'theme', 'layout', 'baseComponents', 'staticObjectComponents', 'envelope'];
134
+ const TOP_KEYS = ['style', 'theme', 'layout', 'baseComponents', 'staticObjectComponents', 'envelope', 'dicts', 'entities', 'app'];
135
+ const APP_SUB_KEYS = ['style', 'theme', 'layout', 'envelope', 'dicts', 'entities'];
136
+ const DICT_OPTION_KEYS = ['value', 'label', 'tone'];
137
+ const ENTITY_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
270
138
  const THEME_KEYS = [
271
139
  'palette',
272
140
  'color_depth',
@@ -282,25 +150,69 @@ const THEME_KEYS = [
282
150
  'surface_texture',
283
151
  'surfaceTexture',
284
152
  'density',
153
+ 'motion',
154
+ 'table_style',
155
+ 'tableStyle',
156
+ 'contrast',
157
+ 'accent_usage',
158
+ 'accentUsage',
285
159
  'preset',
286
- 'polarity',
287
- 'radius',
288
160
  'mode',
289
- 'color',
290
- 'palette_scheme',
291
- 'paletteScheme',
292
- 'font_scheme',
293
- 'fontScheme',
294
- 'color_scheme',
295
- 'colorScheme',
296
- 'tone',
297
- 'typography_scheme',
298
- 'typographyScheme',
299
- 'component_style',
300
- 'componentStyle',
301
161
  ];
162
+ /**
163
+ * 已删除的旧主题链键(库配色方案、库字体方案、品牌色号与旧布局/样式键):只用于报 KIT-APP-002 迁移诊断,不再解析、不留兼容。
164
+ * 键 -> 迁移指引(改用九维对应维度)。
165
+ */
166
+ export const REMOVED_THEME_KEYS: Readonly<Record<string, string>> = {
167
+ palette_scheme: `改用九维 palette(行业配色枚举,如 ${KIT_THEME_PALETTES[0]}),配色深浅与饱和度用 color_depth / color_saturation`,
168
+ paletteScheme: `改用九维 palette(行业配色枚举,如 ${KIT_THEME_PALETTES[0]}),配色深浅与饱和度用 color_depth / color_saturation`,
169
+ font_scheme: `改用九维 font_family(字体枚举,如 ${KIT_THEME_FONT_FAMILIES[0]})与 font_scale(字号行距档)`,
170
+ fontScheme: `改用九维 font_family(字体枚举,如 ${KIT_THEME_FONT_FAMILIES[0]})与 font_scale(字号行距档)`,
171
+ color: '品牌色号不再支持:改用九维 palette 选一套人工精调配色,配合 color_depth / color_saturation 调深浅与饱和度',
172
+ polarity: '改用 mode(light / dark / soft / system)',
173
+ radius: '改用九维 shape',
174
+ color_scheme: '改用九维 palette 配合 color_depth / color_saturation',
175
+ colorScheme: '改用九维 palette 配合 color_depth / color_saturation',
176
+ tone: '改用九维 palette 配合 color_depth / color_saturation',
177
+ typography_scheme: '改用九维 font_family 与 font_scale',
178
+ typographyScheme: '改用九维 font_family 与 font_scale',
179
+ component_style: '改用九维 boundary 与 surface_texture',
180
+ componentStyle: '改用九维 boundary 与 surface_texture',
181
+ };
182
+
183
+ /**
184
+ * 已删除的主题取值(维度 -> 旧值 -> 迁移指引):取值域校验命中时给出清晰的迁移诊断,不留兼容别名。
185
+ */
186
+ export const REMOVED_THEME_VALUES: Readonly<Record<string, Readonly<Record<string, string>>>> = {
187
+ surface_texture: { FROSTED_CHROME: '已合并为 GLASS_CHROME(顶栏与悬浮层毛玻璃,带不透明回退),请改写 GLASS_CHROME' },
188
+ };
189
+
190
+ /**
191
+ * 校验主题对象中的已删除旧键(palette_scheme/paletteScheme/font_scheme/fontScheme/color 等),
192
+ * 命中即推入 KIT-APP-002 迁移诊断。
193
+ */
194
+ export function checkRemovedThemeKeys(
195
+ rawTheme: unknown,
196
+ pathPrefix: string = 'theme',
197
+ diagnostics: KitDiagnostic[] = [],
198
+ keyPathResolver?: (key: string) => string,
199
+ ): KitDiagnostic[] {
200
+ if (rawTheme === null || typeof rawTheme !== 'object' || Array.isArray(rawTheme)) return diagnostics;
201
+ for (const k of Object.keys(rawTheme)) {
202
+ const removedHint = Object.prototype.hasOwnProperty.call(REMOVED_THEME_KEYS, k) ? REMOVED_THEME_KEYS[k] : undefined;
203
+ if (removedHint !== undefined) {
204
+ const kp = keyPathResolver !== undefined ? keyPathResolver(k) : (pathPrefix !== '' ? `${pathPrefix}.${k}` : k);
205
+ diagnostics.push({
206
+ code: 'KIT-APP-002',
207
+ path: kp,
208
+ message: `theme.${k} 已删除(kit 主题只支持九维 palette / color_depth / color_saturation / font_family / font_scale / boundary / shape / surface_texture / density + 扩展维度 motion / table_style / contrast / accent_usage + 预设 preset + mode):${removedHint}`,
209
+ });
210
+ }
211
+ }
212
+ return diagnostics;
213
+ }
302
214
  const STATIC_KEYS = ['accept', 'desc'];
303
- const LAYOUT_TOP_KEYS = ['frame', 'max_width', 'sticky_header', 'header', 'sidebar', 'footer'];
215
+ const LAYOUT_TOP_KEYS = ['frame', 'max_width', 'sticky_header', 'header', 'sidebar', 'footer', 'rules'];
304
216
  const MAX_WIDTH_VALUES = ['narrow', 'medium', 'wide', 'full'] as const;
305
217
  const LAYOUT_HEADER_KEYS = ['brand', 'nav', 'actions'];
306
218
  const LAYOUT_SIDEBAR_KEYS = ['title', 'width', 'menu'];
@@ -317,6 +229,45 @@ function bad(path: string, message: string, out: KitDiagnostic[]): void {
317
229
  out.push({ code: 'KIT-APP-001', path, message });
318
230
  }
319
231
 
232
+ function resolveAppSection(
233
+ raw: Record<string, unknown>,
234
+ appBlock: Record<string, unknown> | undefined,
235
+ key: (typeof APP_SUB_KEYS)[number],
236
+ ): { value: unknown; pathPrefix: string; keyPathOf: (subKey: string) => string } {
237
+ const topVal = raw[key];
238
+ const appVal = appBlock?.[key];
239
+ if (isRecord(topVal) && isRecord(appVal)) {
240
+ return {
241
+ value: { ...topVal, ...appVal },
242
+ pathPrefix: `kit.app.yaml.app.${key}`,
243
+ keyPathOf: (subKey: string) =>
244
+ Object.prototype.hasOwnProperty.call(appVal, subKey)
245
+ ? `kit.app.yaml.app.${key}.${subKey}`
246
+ : `kit.app.yaml.${key}.${subKey}`,
247
+ };
248
+ }
249
+ if (topVal === undefined && appVal !== undefined) {
250
+ return {
251
+ value: appVal,
252
+ pathPrefix: `kit.app.yaml.app.${key}`,
253
+ keyPathOf: (subKey: string) => `kit.app.yaml.app.${key}.${subKey}`,
254
+ };
255
+ }
256
+ if (appVal !== undefined && !isRecord(appVal) && isRecord(topVal)) {
257
+ return {
258
+ value: appVal,
259
+ pathPrefix: `kit.app.yaml.app.${key}`,
260
+ keyPathOf: (subKey: string) => `kit.app.yaml.app.${key}.${subKey}`,
261
+ };
262
+ }
263
+ return {
264
+ value: topVal !== undefined ? topVal : appVal,
265
+ pathPrefix: topVal !== undefined ? `kit.app.yaml.${key}` : `kit.app.yaml.app.${key}`,
266
+ keyPathOf: (subKey: string) =>
267
+ topVal !== undefined ? `kit.app.yaml.${key}.${subKey}` : `kit.app.yaml.app.${key}.${subKey}`,
268
+ };
269
+ }
270
+
320
271
  function parseNavItem(raw: unknown, path: string, diagnostics: KitDiagnostic[]): KitAppLayoutNavItem | undefined {
321
272
  if (!isRecord(raw)) {
322
273
  bad(path, `${path} 必须是对象 { id, label, href?, url?, icon? }`, diagnostics);
@@ -334,13 +285,23 @@ function parseNavItem(raw: unknown, path: string, diagnostics: KitDiagnostic[]):
334
285
  return undefined;
335
286
  }
336
287
  const item: KitAppLayoutNavItem = { id: raw.id.trim(), label: raw.label.trim() };
288
+ if (raw.path !== undefined) {
289
+ if (typeof raw.path === 'string') checkNoRelativeOrSystemPath(raw.path, `${path}.path`, diagnostics, 'KIT-APP-001');
290
+ else bad(`${path}.path`, 'path 必须是字符串', diagnostics);
291
+ }
337
292
  if (raw.href !== undefined) {
338
- if (typeof raw.href === 'string') item.href = raw.href;
339
- else bad(`${path}.href`, 'href 必须是字符串', diagnostics);
293
+ if (typeof raw.href === 'string') {
294
+ if (checkNoRelativeOrSystemPath(raw.href, `${path}.href`, diagnostics, 'KIT-APP-001', { allowExternalHref: true })) {
295
+ item.href = raw.href;
296
+ }
297
+ } else bad(`${path}.href`, 'href 必须是字符串', diagnostics);
340
298
  }
341
299
  if (raw.url !== undefined) {
342
- if (typeof raw.url === 'string') item.url = raw.url;
343
- else bad(`${path}.url`, 'url 必须是字符串', diagnostics);
300
+ if (typeof raw.url === 'string') {
301
+ if (checkNoRelativeOrSystemPath(raw.url, `${path}.url`, diagnostics, 'KIT-APP-001')) {
302
+ item.url = raw.url;
303
+ }
304
+ } else bad(`${path}.url`, 'url 必须是字符串', diagnostics);
344
305
  }
345
306
  if (raw.icon !== undefined) {
346
307
  if (typeof raw.icon === 'string') item.icon = raw.icon;
@@ -360,178 +321,230 @@ export function parseAppConfig(raw: unknown, diagnostics: KitDiagnostic[]): KitA
360
321
  for (const k of Object.keys(raw)) {
361
322
  if (!TOP_KEYS.includes(k)) bad(`kit.app.yaml.${k}`, `未知键 ${k}(允许:${TOP_KEYS.join(' / ')})`, diagnostics);
362
323
  }
363
- if (raw.style !== undefined) {
364
- if (typeof raw.style === 'string' && raw.style !== '') cfg.style = raw.style;
365
- else bad('kit.app.yaml.style', 'style 必须是主题头文件路径', diagnostics);
324
+ if (raw.app !== undefined) {
325
+ if (!isRecord(raw.app)) {
326
+ bad('kit.app.yaml.app', 'app 必须是对象', diagnostics);
327
+ } else {
328
+ for (const k of Object.keys(raw.app)) {
329
+ if (!APP_SUB_KEYS.includes(k)) bad(`kit.app.yaml.app.${k}`, `未知键 ${k}(允许:${APP_SUB_KEYS.join(' / ')})`, diagnostics);
330
+ }
331
+ }
332
+ }
333
+ const appBlock = isRecord(raw.app) ? raw.app : undefined;
334
+ const { value: rawStyle, pathPrefix: stylePath } = resolveAppSection(raw, appBlock, 'style');
335
+ if (rawStyle !== undefined) {
336
+ if (typeof rawStyle === 'string' && rawStyle !== '') {
337
+ if (checkNoRelativeOrSystemPath(rawStyle, stylePath, diagnostics, 'KIT-APP-001', { allowConfigSubpath: true })) {
338
+ cfg.style = rawStyle;
339
+ }
340
+ } else bad(stylePath, 'style 必须是主题头文件路径', diagnostics);
366
341
  }
367
- if (raw.envelope !== undefined) {
368
- const envelope = parseKitEnvelope(raw.envelope, 'kit.app.yaml.envelope', 'KIT-APP-001', diagnostics);
342
+ const { value: rawEnvelope, pathPrefix: envelopePath } = resolveAppSection(raw, appBlock, 'envelope');
343
+ if (rawEnvelope !== undefined) {
344
+ const envelope = parseKitEnvelope(rawEnvelope, envelopePath, 'KIT-APP-001', diagnostics);
369
345
  if (envelope !== undefined) cfg.envelope = envelope;
370
346
  }
371
- if (raw.theme !== undefined) {
372
- if (!isRecord(raw.theme)) bad('kit.app.yaml.theme', 'theme 必须是对象', diagnostics);
347
+ const { value: rawTheme, pathPrefix: themePath, keyPathOf: themeKeyPath } = resolveAppSection(raw, appBlock, 'theme');
348
+ if (rawTheme !== undefined) {
349
+ if (!isRecord(rawTheme)) bad(themePath, 'theme 必须是对象', diagnostics);
373
350
  else {
351
+ checkRemovedThemeKeys(rawTheme, themePath, diagnostics, themeKeyPath);
374
352
  const theme: KitAppTheme = {};
375
- for (const [k, v] of Object.entries(raw.theme)) {
353
+ for (const [k, v] of Object.entries(rawTheme)) {
354
+ if (Object.prototype.hasOwnProperty.call(REMOVED_THEME_KEYS, k)) {
355
+ continue;
356
+ }
357
+ const kp = themeKeyPath(k);
376
358
  if (!THEME_KEYS.includes(k)) {
377
- bad(`kit.app.yaml.theme.${k}`, `未知键 ${k}(允许:${THEME_KEYS.join(' / ')})`, diagnostics);
359
+ bad(kp, `未知键 ${k}(允许:${THEME_KEYS.join(' / ')})`, diagnostics);
378
360
  } else if (typeof v !== 'string' || v.trim() === '') {
379
- bad(`kit.app.yaml.theme.${k}`, `${k} 必须是非空字符串`, diagnostics);
361
+ bad(kp, `${k} 必须是非空字符串`, diagnostics);
380
362
  } else {
381
363
  const val = v.trim();
382
364
  if (k === 'palette') {
383
365
  if (!(KIT_THEME_PALETTES as readonly string[]).includes(val)) {
384
- bad('kit.app.yaml.theme.palette', `palette「${val}」只能是 ${KIT_THEME_PALETTES.join(' / ')}`, diagnostics);
366
+ bad(kp, `palette「${val}」只能是 ${KIT_THEME_PALETTES.join(' / ')}`, diagnostics);
385
367
  } else {
386
368
  theme.palette = val as KitThemePalette;
387
369
  }
388
370
  } else if (k === 'color_depth' || k === 'colorDepth') {
389
371
  if (!(KIT_THEME_COLOR_DEPTHS as readonly string[]).includes(val)) {
390
- bad(`kit.app.yaml.theme.${k}`, `${k}「${val}」只能是 ${KIT_THEME_COLOR_DEPTHS.join(' / ')}`, diagnostics);
372
+ bad(kp, `${k}「${val}」只能是 ${KIT_THEME_COLOR_DEPTHS.join(' / ')}`, diagnostics);
391
373
  } else {
392
374
  theme.color_depth = val as KitThemeColorDepth;
393
375
  theme.colorDepth = val as KitThemeColorDepth;
394
376
  }
395
377
  } else if (k === 'color_saturation' || k === 'colorSaturation') {
396
378
  if (!(KIT_THEME_COLOR_SATURATIONS as readonly string[]).includes(val)) {
397
- bad(`kit.app.yaml.theme.${k}`, `${k}「${val}」只能是 ${KIT_THEME_COLOR_SATURATIONS.join(' / ')}`, diagnostics);
379
+ bad(kp, `${k}「${val}」只能是 ${KIT_THEME_COLOR_SATURATIONS.join(' / ')}`, diagnostics);
398
380
  } else {
399
381
  theme.color_saturation = val as KitThemeColorSaturation;
400
382
  theme.colorSaturation = val as KitThemeColorSaturation;
401
383
  }
402
384
  } else if (k === 'font_family' || k === 'fontFamily') {
403
385
  if (!(KIT_THEME_FONT_FAMILIES as readonly string[]).includes(val)) {
404
- bad(`kit.app.yaml.theme.${k}`, `${k}「${val}」只能是 ${KIT_THEME_FONT_FAMILIES.join(' / ')}`, diagnostics);
386
+ bad(kp, `${k}「${val}」只能是 ${KIT_THEME_FONT_FAMILIES.join(' / ')}`, diagnostics);
405
387
  } else {
406
388
  theme.font_family = val as KitThemeFontFamily;
407
389
  theme.fontFamily = val as KitThemeFontFamily;
408
390
  }
409
391
  } else if (k === 'font_scale' || k === 'fontScale') {
410
392
  if (!(KIT_THEME_FONT_SCALES as readonly string[]).includes(val)) {
411
- bad(`kit.app.yaml.theme.${k}`, `${k}「${val}」只能是 ${KIT_THEME_FONT_SCALES.join(' / ')}`, diagnostics);
393
+ bad(kp, `${k}「${val}」只能是 ${KIT_THEME_FONT_SCALES.join(' / ')}`, diagnostics);
412
394
  } else {
413
395
  theme.font_scale = val as KitThemeFontScale;
414
396
  theme.fontScale = val as KitThemeFontScale;
415
397
  }
416
398
  } else if (k === 'boundary') {
417
399
  if (!(KIT_THEME_BOUNDARIES as readonly string[]).includes(val)) {
418
- bad('kit.app.yaml.theme.boundary', `boundary「${val}」只能是 ${KIT_THEME_BOUNDARIES.join(' / ')}`, diagnostics);
400
+ bad(kp, `boundary「${val}」只能是 ${KIT_THEME_BOUNDARIES.join(' / ')}`, diagnostics);
419
401
  } else {
420
402
  theme.boundary = val as KitThemeBoundary;
421
403
  }
422
404
  } else if (k === 'shape') {
423
405
  if (!(KIT_THEME_SHAPES as readonly string[]).includes(val)) {
424
- bad('kit.app.yaml.theme.shape', `shape「${val}」只能是 ${KIT_THEME_SHAPES.join(' / ')}`, diagnostics);
406
+ bad(kp, `shape「${val}」只能是 ${KIT_THEME_SHAPES.join(' / ')}`, diagnostics);
425
407
  } else {
426
408
  theme.shape = val as KitThemeShape;
427
409
  }
428
410
  } else if (k === 'surface_texture' || k === 'surfaceTexture') {
429
411
  if (!(KIT_THEME_SURFACE_TEXTURES as readonly string[]).includes(val)) {
430
- bad(`kit.app.yaml.theme.${k}`, `${k}「${val}」只能是 ${KIT_THEME_SURFACE_TEXTURES.join(' / ')}`, diagnostics);
412
+ const removed = Object.hasOwn(REMOVED_THEME_VALUES.surface_texture, val) ? REMOVED_THEME_VALUES.surface_texture[val] : undefined;
413
+ bad(kp, `${k}「${val}」${removed !== undefined ? `已删除:${removed};` : ''}只能是 ${KIT_THEME_SURFACE_TEXTURES.join(' / ')}`, diagnostics);
431
414
  } else {
432
415
  theme.surface_texture = val as KitThemeSurfaceTexture;
433
416
  theme.surfaceTexture = val as KitThemeSurfaceTexture;
434
417
  }
435
418
  } else if (k === 'density') {
436
419
  if (!(KIT_THEME_DENSITIES as readonly string[]).includes(val)) {
437
- bad('kit.app.yaml.theme.density', `density「${val}」只能是 ${KIT_THEME_DENSITIES.join(' / ')}`, diagnostics);
420
+ bad(kp, `density「${val}」只能是 ${KIT_THEME_DENSITIES.join(' / ')}`, diagnostics);
438
421
  } else {
439
422
  theme.density = val as KitThemeDensity;
440
423
  }
424
+ } else if (k === 'motion') {
425
+ if (!(KIT_THEME_MOTIONS as readonly string[]).includes(val)) {
426
+ bad(kp, `motion「${val}」只能是 ${KIT_THEME_MOTIONS.join(' / ')}`, diagnostics);
427
+ } else {
428
+ theme.motion = val as KitThemeMotion;
429
+ }
430
+ } else if (k === 'table_style' || k === 'tableStyle') {
431
+ if (!(KIT_THEME_TABLE_STYLES as readonly string[]).includes(val)) {
432
+ bad(kp, `${k}「${val}」只能是 ${KIT_THEME_TABLE_STYLES.join(' / ')}`, diagnostics);
433
+ } else {
434
+ theme.table_style = val as KitThemeTableStyle;
435
+ theme.tableStyle = val as KitThemeTableStyle;
436
+ }
437
+ } else if (k === 'contrast') {
438
+ if (!(KIT_THEME_CONTRASTS as readonly string[]).includes(val)) {
439
+ bad(kp, `contrast「${val}」只能是 ${KIT_THEME_CONTRASTS.join(' / ')}`, diagnostics);
440
+ } else {
441
+ theme.contrast = val as KitThemeContrast;
442
+ }
443
+ } else if (k === 'accent_usage' || k === 'accentUsage') {
444
+ if (!(KIT_THEME_ACCENT_USAGES as readonly string[]).includes(val)) {
445
+ bad(kp, `${k}「${val}」只能是 ${KIT_THEME_ACCENT_USAGES.join(' / ')}`, diagnostics);
446
+ } else {
447
+ theme.accent_usage = val as KitThemeAccentUsage;
448
+ theme.accentUsage = val as KitThemeAccentUsage;
449
+ }
441
450
  } else if (k === 'preset') {
442
- theme.preset = val;
443
- } else if (k === 'polarity') {
444
- theme.polarity = val;
445
- } else if (k === 'radius') {
446
- theme.radius = val;
447
- } else if (k === 'palette_scheme' || k === 'paletteScheme') {
448
- theme.paletteScheme = val;
449
- } else if (k === 'font_scheme' || k === 'fontScheme') {
450
- theme.fontScheme = val;
451
- } else if (k === 'color') {
452
- theme.color = val;
453
- } else if (k === 'color_scheme' || k === 'colorScheme') {
454
- theme.colorScheme = val;
455
- } else if (k === 'tone') {
456
- theme.tone = val;
457
- } else if (k === 'typography_scheme' || k === 'typographyScheme') {
458
- theme.typographyScheme = val;
459
- } else if (k === 'component_style' || k === 'componentStyle') {
460
- theme.componentStyle = val;
451
+ // 未知预设名按主题取值域错误报 KIT-APP-002(与求解端 solveKitTheme 同码同路径),不写入 cfg.theme
452
+ if (!(KIT_THEME_PRESETS as readonly string[]).includes(val)) {
453
+ diagnostics.push({ code: 'KIT-APP-002', path: kp, message: `preset「${val}」不是已知主题预设,只能是 ${KIT_THEME_PRESETS.join(' / ')}` });
454
+ } else {
455
+ theme.preset = val as KitThemePreset;
456
+ }
461
457
  } else if (k === 'mode') {
462
- theme.mode = val;
458
+ if (!(KIT_THEME_MODES as readonly string[]).includes(val)) {
459
+ bad(kp, `mode「${val}」只能是 ${KIT_THEME_MODES.join(' / ')}`, diagnostics);
460
+ } else {
461
+ theme.mode = val;
462
+ }
463
463
  }
464
464
  }
465
465
  }
466
466
  cfg.theme = theme;
467
467
  }
468
468
  }
469
- if (raw.layout !== undefined) {
470
- if (!isRecord(raw.layout)) {
471
- bad('kit.app.yaml.layout', 'layout 必须是对象', diagnostics);
469
+ const { value: rawLayout, pathPrefix: layoutPath, keyPathOf: layoutKeyPath } = resolveAppSection(raw, appBlock, 'layout');
470
+ if (rawLayout !== undefined) {
471
+ if (!isRecord(rawLayout)) {
472
+ bad(layoutPath, 'layout 必须是对象', diagnostics);
472
473
  } else {
473
- for (const k of Object.keys(raw.layout)) {
474
- if (!LAYOUT_TOP_KEYS.includes(k)) bad(`kit.app.yaml.layout.${k}`, `未知键 ${k}(允许:${LAYOUT_TOP_KEYS.join(' / ')})`, diagnostics);
474
+ for (const k of Object.keys(rawLayout)) {
475
+ if (!LAYOUT_TOP_KEYS.includes(k)) bad(layoutKeyPath(k), `未知键 ${k}(允许:${LAYOUT_TOP_KEYS.join(' / ')})`, diagnostics);
475
476
  }
476
477
  const layout: KitAppLayout = {};
477
- if (raw.layout.frame !== undefined) {
478
- if (typeof raw.layout.frame === 'string' && raw.layout.frame.trim() !== '') layout.frame = raw.layout.frame.trim();
479
- else bad('kit.app.yaml.layout.frame', 'frame 必须是非空字符串', diagnostics);
478
+ // 布局规则版本钉(RV-1117 T09):缺省 0 = 现状,输出逐字节不变;新应用 / AI 页钉最新版。
479
+ // 它不是「外框继承」配置,不进 cfg.layout(否则只写 rules 的应用会被当成启用了继承外框而多包一层)
480
+ if (rawLayout.rules !== undefined) {
481
+ const pin = typeof rawLayout.rules === 'number' ? normalizeLayoutPin(rawLayout.rules) : undefined;
482
+ if (pin === undefined) bad(layoutKeyPath('rules'), `rules 必须是已存在的布局规则版本号(整数,${KIT_LAYOUT_VERSIONS.join(' / ')};缺省 0 = 现状)`, diagnostics);
483
+ else cfg.layoutRules = pin;
484
+ }
485
+ if (rawLayout.frame !== undefined) {
486
+ if (typeof rawLayout.frame === 'string' && rawLayout.frame.trim() !== '') layout.frame = rawLayout.frame.trim();
487
+ else bad(layoutKeyPath('frame'), 'frame 必须是非空字符串', diagnostics);
480
488
  }
481
- if (raw.layout.max_width !== undefined) {
482
- const mw = typeof raw.layout.max_width === 'string' ? raw.layout.max_width.trim() : '';
483
- if (!(MAX_WIDTH_VALUES as readonly string[]).includes(mw)) bad('kit.app.yaml.layout.max_width', `max_width「${String(raw.layout.max_width)}」只能是 ${MAX_WIDTH_VALUES.join(' / ')}`, diagnostics);
489
+ if (rawLayout.max_width !== undefined) {
490
+ const mw = typeof rawLayout.max_width === 'string' ? rawLayout.max_width.trim() : '';
491
+ if (!(MAX_WIDTH_VALUES as readonly string[]).includes(mw)) bad(layoutKeyPath('max_width'), `max_width「${String(rawLayout.max_width)}」只能是 ${MAX_WIDTH_VALUES.join(' / ')}`, diagnostics);
484
492
  else layout.maxWidth = mw as 'narrow' | 'medium' | 'wide' | 'full';
485
493
  }
486
- if (raw.layout.sticky_header !== undefined) {
487
- if (typeof raw.layout.sticky_header === 'boolean') layout.stickyHeader = raw.layout.sticky_header;
488
- else bad('kit.app.yaml.layout.sticky_header', 'sticky_header 必须是布尔值', diagnostics);
494
+ if (rawLayout.sticky_header !== undefined) {
495
+ if (typeof rawLayout.sticky_header === 'boolean') layout.stickyHeader = rawLayout.sticky_header;
496
+ else bad(layoutKeyPath('sticky_header'), 'sticky_header 必须是布尔值', diagnostics);
489
497
  }
490
- if (raw.layout.header !== undefined) {
491
- if (!isRecord(raw.layout.header)) {
492
- bad('kit.app.yaml.layout.header', 'header 必须是对象', diagnostics);
498
+ if (rawLayout.header !== undefined) {
499
+ const hp = layoutKeyPath('header');
500
+ if (!isRecord(rawLayout.header)) {
501
+ bad(hp, 'header 必须是对象', diagnostics);
493
502
  } else {
494
- for (const k of Object.keys(raw.layout.header)) {
495
- if (!LAYOUT_HEADER_KEYS.includes(k)) bad(`kit.app.yaml.layout.header.${k}`, `未知键 ${k}(允许:${LAYOUT_HEADER_KEYS.join(' / ')})`, diagnostics);
503
+ for (const k of Object.keys(rawLayout.header)) {
504
+ if (!LAYOUT_HEADER_KEYS.includes(k)) bad(`${hp}.${k}`, `未知键 ${k}(允许:${LAYOUT_HEADER_KEYS.join(' / ')})`, diagnostics);
496
505
  }
497
506
  const header: NonNullable<KitAppLayout['header']> = {};
498
- if (raw.layout.header.brand !== undefined) {
499
- if (!isRecord(raw.layout.header.brand)) {
500
- bad('kit.app.yaml.layout.header.brand', 'brand 必须是对象', diagnostics);
507
+ if (rawLayout.header.brand !== undefined) {
508
+ const bp = `${hp}.brand`;
509
+ if (!isRecord(rawLayout.header.brand)) {
510
+ bad(bp, 'brand 必须是对象', diagnostics);
501
511
  } else {
502
- for (const k of Object.keys(raw.layout.header.brand)) {
503
- if (!BRAND_KEYS.includes(k)) bad(`kit.app.yaml.layout.header.brand.${k}`, `未知键 ${k}(允许:${BRAND_KEYS.join(' / ')})`, diagnostics);
512
+ for (const k of Object.keys(rawLayout.header.brand)) {
513
+ if (!BRAND_KEYS.includes(k)) bad(`${bp}.${k}`, `未知键 ${k}(允许:${BRAND_KEYS.join(' / ')})`, diagnostics);
504
514
  }
505
- if (typeof raw.layout.header.brand.text !== 'string' || raw.layout.header.brand.text.trim() === '') {
506
- bad('kit.app.yaml.layout.header.brand.text', 'brand.text 必须是非空字符串', diagnostics);
515
+ if (typeof rawLayout.header.brand.text !== 'string' || rawLayout.header.brand.text.trim() === '') {
516
+ bad(`${bp}.text`, 'brand.text 必须是非空字符串', diagnostics);
507
517
  } else {
508
- header.brand = { text: raw.layout.header.brand.text.trim() };
509
- if (raw.layout.header.brand.href !== undefined) {
510
- if (typeof raw.layout.header.brand.href === 'string') header.brand.href = raw.layout.header.brand.href;
511
- else bad('kit.app.yaml.layout.header.brand.href', 'brand.href 必须是字符串', diagnostics);
518
+ header.brand = { text: rawLayout.header.brand.text.trim() };
519
+ if (rawLayout.header.brand.href !== undefined) {
520
+ if (typeof rawLayout.header.brand.href === 'string') {
521
+ if (checkNoRelativeOrSystemPath(rawLayout.header.brand.href, `${bp}.href`, diagnostics, 'KIT-APP-001', { allowExternalHref: true })) {
522
+ header.brand.href = rawLayout.header.brand.href;
523
+ }
524
+ } else bad(`${bp}.href`, 'brand.href 必须是字符串', diagnostics);
512
525
  }
513
526
  }
514
527
  }
515
528
  }
516
- if (raw.layout.header.nav !== undefined) {
517
- if (!Array.isArray(raw.layout.header.nav)) {
518
- bad('kit.app.yaml.layout.header.nav', 'nav 必须是数组', diagnostics);
529
+ if (rawLayout.header.nav !== undefined) {
530
+ if (!Array.isArray(rawLayout.header.nav)) {
531
+ bad(`${hp}.nav`, 'nav 必须是数组', diagnostics);
519
532
  } else {
520
533
  const nav: KitAppLayoutNavItem[] = [];
521
- raw.layout.header.nav.forEach((it, i) => {
522
- const parsed = parseNavItem(it, `kit.app.yaml.layout.header.nav[${i}]`, diagnostics);
534
+ rawLayout.header.nav.forEach((it, i) => {
535
+ const parsed = parseNavItem(it, `${hp}.nav[${i}]`, diagnostics);
523
536
  if (parsed) nav.push(parsed);
524
537
  });
525
538
  header.nav = nav;
526
539
  }
527
540
  }
528
- if (raw.layout.header.actions !== undefined) {
529
- if (!Array.isArray(raw.layout.header.actions)) {
530
- bad('kit.app.yaml.layout.header.actions', 'actions 必须是数组', diagnostics);
541
+ if (rawLayout.header.actions !== undefined) {
542
+ if (!Array.isArray(rawLayout.header.actions)) {
543
+ bad(`${hp}.actions`, 'actions 必须是数组', diagnostics);
531
544
  } else {
532
545
  const actions: KitAppLayoutNavItem[] = [];
533
- raw.layout.header.actions.forEach((it, i) => {
534
- const parsed = parseNavItem(it, `kit.app.yaml.layout.header.actions[${i}]`, diagnostics);
546
+ rawLayout.header.actions.forEach((it, i) => {
547
+ const parsed = parseNavItem(it, `${hp}.actions[${i}]`, diagnostics);
535
548
  if (parsed) actions.push(parsed);
536
549
  });
537
550
  header.actions = actions;
@@ -540,29 +553,30 @@ export function parseAppConfig(raw: unknown, diagnostics: KitDiagnostic[]): KitA
540
553
  layout.header = header;
541
554
  }
542
555
  }
543
- if (raw.layout.sidebar !== undefined) {
544
- if (!isRecord(raw.layout.sidebar)) {
545
- bad('kit.app.yaml.layout.sidebar', 'sidebar 必须是对象', diagnostics);
556
+ if (rawLayout.sidebar !== undefined) {
557
+ const sp = layoutKeyPath('sidebar');
558
+ if (!isRecord(rawLayout.sidebar)) {
559
+ bad(sp, 'sidebar 必须是对象', diagnostics);
546
560
  } else {
547
- for (const k of Object.keys(raw.layout.sidebar)) {
548
- if (!LAYOUT_SIDEBAR_KEYS.includes(k)) bad(`kit.app.yaml.layout.sidebar.${k}`, `未知键 ${k}(允许:${LAYOUT_SIDEBAR_KEYS.join(' / ')})`, diagnostics);
561
+ for (const k of Object.keys(rawLayout.sidebar)) {
562
+ if (!LAYOUT_SIDEBAR_KEYS.includes(k)) bad(`${sp}.${k}`, `未知键 ${k}(允许:${LAYOUT_SIDEBAR_KEYS.join(' / ')})`, diagnostics);
549
563
  }
550
564
  const sidebar: NonNullable<KitAppLayout['sidebar']> = {};
551
- if (raw.layout.sidebar.title !== undefined) {
552
- if (typeof raw.layout.sidebar.title === 'string') sidebar.title = raw.layout.sidebar.title;
553
- else bad('kit.app.yaml.layout.sidebar.title', 'sidebar.title 必须是字符串', diagnostics);
565
+ if (rawLayout.sidebar.title !== undefined) {
566
+ if (typeof rawLayout.sidebar.title === 'string') sidebar.title = rawLayout.sidebar.title;
567
+ else bad(`${sp}.title`, 'sidebar.title 必须是字符串', diagnostics);
554
568
  }
555
- if (raw.layout.sidebar.width !== undefined) {
556
- if (typeof raw.layout.sidebar.width === 'number' && !Number.isNaN(raw.layout.sidebar.width)) sidebar.width = raw.layout.sidebar.width;
557
- else bad('kit.app.yaml.layout.sidebar.width', 'sidebar.width 必须是数字', diagnostics);
569
+ if (rawLayout.sidebar.width !== undefined) {
570
+ if (typeof rawLayout.sidebar.width === 'number' && !Number.isNaN(rawLayout.sidebar.width)) sidebar.width = rawLayout.sidebar.width;
571
+ else bad(`${sp}.width`, 'sidebar.width 必须是数字', diagnostics);
558
572
  }
559
- if (raw.layout.sidebar.menu !== undefined) {
560
- if (!Array.isArray(raw.layout.sidebar.menu)) {
561
- bad('kit.app.yaml.layout.sidebar.menu', 'sidebar.menu 必须是数组', diagnostics);
573
+ if (rawLayout.sidebar.menu !== undefined) {
574
+ if (!Array.isArray(rawLayout.sidebar.menu)) {
575
+ bad(`${sp}.menu`, 'sidebar.menu 必须是数组', diagnostics);
562
576
  } else {
563
577
  const menu: KitAppLayoutNavItem[] = [];
564
- raw.layout.sidebar.menu.forEach((it, i) => {
565
- const parsed = parseNavItem(it, `kit.app.yaml.layout.sidebar.menu[${i}]`, diagnostics);
578
+ rawLayout.sidebar.menu.forEach((it, i) => {
579
+ const parsed = parseNavItem(it, `${sp}.menu[${i}]`, diagnostics);
566
580
  if (parsed) menu.push(parsed);
567
581
  });
568
582
  sidebar.menu = menu;
@@ -571,25 +585,26 @@ export function parseAppConfig(raw: unknown, diagnostics: KitDiagnostic[]): KitA
571
585
  layout.sidebar = sidebar;
572
586
  }
573
587
  }
574
- if (raw.layout.footer !== undefined) {
575
- if (!isRecord(raw.layout.footer)) {
576
- bad('kit.app.yaml.layout.footer', 'footer 必须是对象', diagnostics);
588
+ if (rawLayout.footer !== undefined) {
589
+ const fp = layoutKeyPath('footer');
590
+ if (!isRecord(rawLayout.footer)) {
591
+ bad(fp, 'footer 必须是对象', diagnostics);
577
592
  } else {
578
- for (const k of Object.keys(raw.layout.footer)) {
579
- if (!LAYOUT_FOOTER_KEYS.includes(k)) bad(`kit.app.yaml.layout.footer.${k}`, `未知键 ${k}(允许:${LAYOUT_FOOTER_KEYS.join(' / ')})`, diagnostics);
593
+ for (const k of Object.keys(rawLayout.footer)) {
594
+ if (!LAYOUT_FOOTER_KEYS.includes(k)) bad(`${fp}.${k}`, `未知键 ${k}(允许:${LAYOUT_FOOTER_KEYS.join(' / ')})`, diagnostics);
580
595
  }
581
596
  const footer: NonNullable<KitAppLayout['footer']> = {};
582
- if (raw.layout.footer.text !== undefined) {
583
- if (typeof raw.layout.footer.text === 'string') footer.text = raw.layout.footer.text;
584
- else bad('kit.app.yaml.layout.footer.text', 'footer.text 必须是字符串', diagnostics);
597
+ if (rawLayout.footer.text !== undefined) {
598
+ if (typeof rawLayout.footer.text === 'string') footer.text = rawLayout.footer.text;
599
+ else bad(`${fp}.text`, 'footer.text 必须是字符串', diagnostics);
585
600
  }
586
- if (raw.layout.footer.links !== undefined) {
587
- if (!Array.isArray(raw.layout.footer.links)) {
588
- bad('kit.app.yaml.layout.footer.links', 'footer.links 必须是数组', diagnostics);
601
+ if (rawLayout.footer.links !== undefined) {
602
+ if (!Array.isArray(rawLayout.footer.links)) {
603
+ bad(`${fp}.links`, 'footer.links 必须是数组', diagnostics);
589
604
  } else {
590
605
  const links: Array<{ label: string; href: string }> = [];
591
- raw.layout.footer.links.forEach((link, i) => {
592
- const lp = `kit.app.yaml.layout.footer.links[${i}]`;
606
+ rawLayout.footer.links.forEach((link, i) => {
607
+ const lp = `${fp}.links[${i}]`;
593
608
  if (!isRecord(link)) {
594
609
  bad(lp, `${lp} 必须是对象 { label, href }`, diagnostics);
595
610
  return;
@@ -605,6 +620,9 @@ export function parseAppConfig(raw: unknown, diagnostics: KitDiagnostic[]): KitA
605
620
  bad(`${lp}.href`, 'href 必须是非空字符串', diagnostics);
606
621
  return;
607
622
  }
623
+ if (!checkNoRelativeOrSystemPath(link.href, `${lp}.href`, diagnostics, 'KIT-APP-001', { allowExternalHref: true })) {
624
+ return;
625
+ }
608
626
  links.push({ label: link.label.trim(), href: link.href.trim() });
609
627
  });
610
628
  footer.links = links;
@@ -613,7 +631,8 @@ export function parseAppConfig(raw: unknown, diagnostics: KitDiagnostic[]): KitA
613
631
  layout.footer = footer;
614
632
  }
615
633
  }
616
- cfg.layout = layout;
634
+ // 只写了 rules 的 layout 块不是外框继承配置(见上),不进 cfg.layout,存量应用输出不变
635
+ if (!(Object.keys(rawLayout).length === 1 && rawLayout.rules !== undefined)) cfg.layout = layout;
617
636
  }
618
637
  }
619
638
  if (raw.baseComponents !== undefined) {
@@ -649,5 +668,88 @@ export function parseAppConfig(raw: unknown, diagnostics: KitDiagnostic[]): KitA
649
668
  }
650
669
  }
651
670
  }
671
+ const { value: rawDicts, pathPrefix: dictsPathPrefix, keyPathOf: dictsKeyPath } = resolveAppSection(raw, appBlock, 'dicts');
672
+ if (rawDicts !== undefined) {
673
+ if (!isRecord(rawDicts)) {
674
+ bad(dictsPathPrefix, "dicts 必须是 { 字典名: [{ value, label, tone? }] }", diagnostics);
675
+ } else {
676
+ const dicts: KitAppDicts = {};
677
+ for (const [dictName, items] of Object.entries(rawDicts)) {
678
+ const dp = dictsKeyPath(dictName);
679
+ if (!ENTITY_NAME_RE.test(dictName)) {
680
+ bad(dp, `字典名 ${dictName} 必须是合法标识符`, diagnostics);
681
+ continue;
682
+ }
683
+ if (!Array.isArray(items) || items.length === 0) {
684
+ bad(dp, "字典项必须是非空选项数组 [{ value, label, tone? }]", diagnostics);
685
+ continue;
686
+ }
687
+ const parsedItems: KitDictOption[] = [];
688
+ items.forEach((it, idx) => {
689
+ const ip = `${dp}[${idx}]`;
690
+ if (!isRecord(it)) {
691
+ bad(ip, "字典选项必须是 { value, label, tone? } 对象", diagnostics);
692
+ return;
693
+ }
694
+ for (const k of Object.keys(it)) {
695
+ if (!DICT_OPTION_KEYS.includes(k)) bad(`${ip}.${k}`, `未知键 ${k}(允许:${DICT_OPTION_KEYS.join(" / ")})`, diagnostics);
696
+ }
697
+ if (typeof it.value !== "string" && typeof it.value !== "number" && typeof it.value !== "boolean") {
698
+ bad(`${ip}.value`, "value 必须是字符串、数字或布尔值", diagnostics);
699
+ return;
700
+ }
701
+ if (typeof it.label !== "string" || it.label.trim() === "") {
702
+ bad(`${ip}.label`, "label 必须是非空字符串", diagnostics);
703
+ return;
704
+ }
705
+ const opt: KitDictOption = { value: it.value, label: it.label };
706
+ if (it.tone !== undefined) {
707
+ if (typeof it.tone !== "string" || it.tone.trim() === "") {
708
+ bad(`${ip}.tone`, "tone 必须是非空字符串", diagnostics);
709
+ } else {
710
+ opt.tone = it.tone;
711
+ }
712
+ }
713
+ parsedItems.push(opt);
714
+ });
715
+ dicts[dictName] = parsedItems;
716
+ }
717
+ cfg.dicts = dicts;
718
+ }
719
+ }
720
+ const { value: rawEntities, pathPrefix: entitiesPathPrefix, keyPathOf: entitiesKeyPath } = resolveAppSection(raw, appBlock, 'entities');
721
+ if (rawEntities !== undefined) {
722
+ if (!isRecord(rawEntities)) {
723
+ bad(entitiesPathPrefix, "entities 必须是 { 实体名: { 字段名: 字段声明 } }", diagnostics);
724
+ } else {
725
+ const entities: KitAppEntities = {};
726
+ for (const [entityName, entityVal] of Object.entries(rawEntities)) {
727
+ const ep = entitiesKeyPath(entityName);
728
+ if (!ENTITY_NAME_RE.test(entityName)) {
729
+ bad(ep, `实体名 ${entityName} 必须是合法标识符`, diagnostics);
730
+ continue;
731
+ }
732
+ if (!isRecord(entityVal)) {
733
+ bad(ep, "实体定义必须是字段声明映射对象", diagnostics);
734
+ continue;
735
+ }
736
+ const fieldMap = isRecord(entityVal.fields) && typeof entityVal.fields.type !== "string"
737
+ ? entityVal.fields
738
+ : isRecord(entityVal.schema) && typeof entityVal.schema.type !== "string"
739
+ ? entityVal.schema
740
+ : entityVal;
741
+ const resolvedFields: Record<string, unknown> = {};
742
+ for (const [fName, fDef] of Object.entries(fieldMap)) {
743
+ if (!isRecord(fDef)) {
744
+ bad(`${ep}.${fName}`, `实体 ${entityName} 的字段 ${fName} 必须是对象`, diagnostics);
745
+ continue;
746
+ }
747
+ resolvedFields[fName] = { ...fDef };
748
+ }
749
+ entities[entityName] = resolvedFields;
750
+ }
751
+ cfg.entities = entities;
752
+ }
753
+ }
652
754
  return cfg;
653
755
  }