soma-kit 0.1.10 → 0.1.12

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 (302) hide show
  1. package/README.md +103 -110
  2. package/bin/soma-kit.mjs +1 -1
  3. package/bin/soma.mjs +22 -0
  4. package/package.json +13 -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 +776 -38
  8. package/spec/generated/kit-page.schema.json +1613 -224
  9. package/spec/kit-grammar.json +770 -529
  10. package/spec/kit-grammar.schema.json +1962 -392
  11. package/src/app/app-config.ts +371 -347
  12. package/src/app/component-gate.ts +12 -15
  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 +174 -31
  16. package/src/app/define-kit-view.ts +100 -0
  17. package/src/app/envelope.ts +1 -161
  18. package/src/app/index.ts +13 -2
  19. package/src/app/kit-view-context.ts +290 -0
  20. package/src/app/notify-renderer.ts +1 -115
  21. package/src/app/paged-list-adapter.ts +1 -240
  22. package/src/app/server-pages.ts +8 -2
  23. package/src/app/server.ts +491 -101
  24. package/src/app/submit.types.ts +1 -1
  25. package/src/app/theme-endpoint.ts +63 -0
  26. package/src/app/theme-runtime-shared.ts +1 -0
  27. package/src/app/theme-runtime.ts +663 -0
  28. package/src/base/action-busy.ts +2 -2
  29. package/src/base/action-gate.ts +4 -255
  30. package/src/base/action-slots.ts +47 -0
  31. package/src/base/alert.ts +5 -3
  32. package/src/base/avatar.ts +2 -2
  33. package/src/base/button.ts +46 -29
  34. package/src/base/cascader.ts +11 -12
  35. package/src/base/check-core.ts +1 -1
  36. package/src/base/choice.ts +28 -26
  37. package/src/base/class-candidates.ts +17 -0
  38. package/src/base/color-picker.ts +6 -6
  39. package/src/base/combobox.ts +5 -3
  40. package/src/base/command-palette.ts +9 -5
  41. package/src/base/countdown.ts +1 -1
  42. package/src/base/date-range.ts +25 -11
  43. package/src/base/date.ts +85 -17
  44. package/src/base/divider.ts +2 -2
  45. package/src/base/fab.ts +11 -4
  46. package/src/base/image.ts +1 -1
  47. package/src/base/index.ts +9 -3
  48. package/src/base/input.ts +42 -13
  49. package/src/base/kbd.ts +3 -1
  50. package/src/base/link.ts +4 -4
  51. package/src/base/listbox-core.ts +50 -30
  52. package/src/base/loading-gate.ts +133 -0
  53. package/src/base/mentions.ts +5 -5
  54. package/src/base/menu-button.ts +6 -1
  55. package/src/base/menu-core.ts +4 -0
  56. package/src/base/motion/aura.ts +2 -2
  57. package/src/base/motion/hover-3d.ts +2 -2
  58. package/src/base/motion/hover-gallery.ts +2 -2
  59. package/src/base/motion/marquee.ts +2 -2
  60. package/src/base/motion/text-rotate.ts +2 -2
  61. package/src/base/number.ts +93 -80
  62. package/src/base/otp.ts +4 -1
  63. package/src/base/permission-gate.ts +6 -0
  64. package/src/base/popover.ts +40 -8
  65. package/src/base/popup.ts +79 -14
  66. package/src/base/price-text.ts +2 -2
  67. package/src/base/progress.ts +2 -2
  68. package/src/base/qr-code.ts +4 -4
  69. package/src/base/qty-stepper.ts +9 -3
  70. package/src/base/range.ts +2 -2
  71. package/src/base/rating.ts +1 -1
  72. package/src/base/segmented.ts +4 -0
  73. package/src/base/select.ts +4 -3
  74. package/src/base/shared.ts +221 -29
  75. package/src/base/swap.ts +4 -1
  76. package/src/base/switch.ts +1 -1
  77. package/src/base/tag-input.ts +14 -10
  78. package/src/base/tag.ts +5 -1
  79. package/src/base/text.ts +39 -6
  80. package/src/base/textarea.ts +37 -11
  81. package/src/base/time-picker.ts +12 -9
  82. package/src/base/tree-select.ts +15 -8
  83. package/src/base/upload.ts +34 -5
  84. package/src/base/virtual-list.ts +107 -1
  85. package/src/biz/approval-desk/compile.ts +23 -41
  86. package/src/biz/auth-panel/compile.ts +37 -52
  87. package/src/biz/auth-panel/index.ts +1 -1
  88. package/src/biz/category-crud/compile.ts +22 -36
  89. package/src/biz/checkout-page/compile.ts +21 -5
  90. package/src/biz/compose.ts +13 -27
  91. package/src/biz/define.ts +5 -4
  92. package/src/biz/import-wizard/compile.ts +22 -26
  93. package/src/biz/import-wizard/hub.ts +126 -61
  94. package/src/biz/import-wizard/shell.ts +3 -3
  95. package/src/biz/index.ts +3 -3
  96. package/src/biz/landing-page/compile.ts +19 -3
  97. package/src/biz/link/hub.ts +49 -20
  98. package/src/biz/link/shared.ts +115 -118
  99. package/src/biz/master-sub/compile.ts +31 -44
  100. package/src/biz/multi-board/compile.ts +34 -49
  101. package/src/biz/multi-board/index.ts +18 -1
  102. package/src/biz/multi-board/shell.ts +24 -15
  103. package/src/biz/notification-center/compile.ts +21 -33
  104. package/src/biz/page-templates/domain-templates.ts +80 -13
  105. package/src/biz/page-templates/result-page/compile.ts +11 -2
  106. package/src/biz/page-templates/shared.ts +34 -36
  107. package/src/biz/record-detail/compile.ts +47 -42
  108. package/src/biz/record-detail/index.ts +11 -1
  109. package/src/biz/settings-center/compile.ts +6 -5
  110. package/src/biz/shared/action-host.ts +91 -211
  111. package/src/biz/shared/compile-helpers.ts +80 -0
  112. package/src/biz/shared/coordinator.ts +486 -83
  113. package/src/biz/shared/index.ts +8 -2
  114. package/src/biz/shared/overlay-shell.ts +80 -0
  115. package/src/biz/shared/pipes.ts +43 -30
  116. package/src/biz/shared/remove-key.ts +6 -0
  117. package/src/biz/shared/remove-wire.ts +29 -0
  118. package/src/biz/shared/runtime-hub.ts +216 -24
  119. package/src/biz/single-form/compile.ts +15 -37
  120. package/src/biz/standard-crud/compile.ts +62 -107
  121. package/src/biz/standard-crud/shell.ts +16 -66
  122. package/src/biz/step-form/compile.ts +26 -97
  123. package/src/biz/step-form/hub.ts +34 -41
  124. package/src/biz/types.ts +4 -3
  125. package/src/cli/core-imports.ts +54 -0
  126. package/src/cli/kit-cli.ts +130 -26
  127. package/src/cli/kit-init.ts +222 -0
  128. package/src/cli/service-endpoint-check.ts +425 -0
  129. package/src/cli/source-path-check.d.mts +17 -0
  130. package/src/cli/source-path-check.mjs +334 -0
  131. package/src/cli/view-writes.ts +752 -0
  132. package/src/compile/action-host-attach.ts +21 -29
  133. package/src/compile/closed-set.ts +509 -0
  134. package/src/compile/compile-page.ts +219 -72
  135. package/src/compile/component-candidates.ts +1 -1
  136. package/src/compile/hints.ts +30 -1
  137. package/src/compile/index.ts +1 -0
  138. package/src/compile/kit-error.ts +1 -0
  139. package/src/compile/locate.ts +21 -1
  140. package/src/compile/parse.ts +370 -41
  141. package/src/compile/redirect.ts +6 -2
  142. package/src/compile/styles.ts +35 -2
  143. package/src/compile/types.ts +18 -2
  144. package/src/compile/view-check.ts +151 -0
  145. package/src/data/amount-breakdown.ts +2 -2
  146. package/src/data/anchor-nav.ts +2 -2
  147. package/src/data/approval-flow.ts +2 -2
  148. package/src/data/assignment-picker.ts +40 -29
  149. package/src/data/async-result-panel.ts +62 -6
  150. package/src/data/breadcrumbs.ts +2 -2
  151. package/src/data/calendar.ts +22 -25
  152. package/src/data/carousel.ts +5 -2
  153. package/src/data/chart.ts +42 -34
  154. package/src/data/checklist.ts +2 -2
  155. package/src/data/code-view.ts +4 -2
  156. package/src/data/comment-thread.ts +5 -2
  157. package/src/data/confirm-dialog.ts +10 -0
  158. package/src/data/context-menu.ts +29 -37
  159. package/src/data/d9-util.ts +2 -18
  160. package/src/data/diff.ts +4 -2
  161. package/src/data/dock.ts +2 -2
  162. package/src/data/embed.ts +2 -1
  163. package/src/data/field-mapper.ts +31 -26
  164. package/src/data/flow-editor-contract.ts +1 -1
  165. package/src/data/flow-editor.ts +89 -100
  166. package/src/data/flow-node-options.ts +90 -0
  167. package/src/data/flow-remote-options.ts +0 -103
  168. package/src/data/footer.ts +2 -2
  169. package/src/data/form-draft-registry.ts +2 -4
  170. package/src/data/gantt.ts +14 -17
  171. package/src/data/hero.ts +2 -2
  172. package/src/data/image-viewer.ts +20 -26
  173. package/src/data/index.ts +0 -2
  174. package/src/data/item-list.ts +31 -22
  175. package/src/data/kanban.ts +43 -42
  176. package/src/data/media-grid.ts +14 -19
  177. package/src/data/menu.ts +2 -2
  178. package/src/data/mockup.ts +2 -2
  179. package/src/data/modal-dialog.ts +22 -18
  180. package/src/data/navbar.ts +7 -2
  181. package/src/data/notify-renderer.ts +235 -0
  182. package/src/data/object-form.ts +1036 -648
  183. package/src/data/pager.ts +65 -29
  184. package/src/data/permission-matrix.ts +20 -21
  185. package/src/data/permission-tree.ts +28 -26
  186. package/src/data/pricing-table.ts +9 -3
  187. package/src/data/reaction-bar.ts +77 -88
  188. package/src/data/read-rollback.ts +73 -0
  189. package/src/data/record-card.ts +3 -3
  190. package/src/data/record-picker.ts +93 -50
  191. package/src/data/redirect.ts +32 -32
  192. package/src/data/remote-options.ts +13 -6
  193. package/src/data/request-console.ts +5 -3
  194. package/src/data/resident.ts +2 -1
  195. package/src/data/result-panel.ts +4 -2
  196. package/src/data/rich-text.ts +45 -55
  197. package/src/data/row-editor.ts +285 -52
  198. package/src/data/rule-builder.ts +18 -12
  199. package/src/data/shape-util.ts +4 -0
  200. package/src/data/stat-group.ts +243 -101
  201. package/src/data/static-registry.ts +22 -11
  202. package/src/data/steps.ts +2 -2
  203. package/src/data/survey.ts +24 -29
  204. package/src/data/system-switcher.ts +2 -2
  205. package/src/data/timeline.ts +2 -2
  206. package/src/data/tour-guide.ts +22 -29
  207. package/src/data/transfer.ts +27 -23
  208. package/src/data/tree-table.ts +96 -48
  209. package/src/data/tree.ts +27 -34
  210. package/src/data/trend-line.ts +6 -24
  211. package/src/data/virtual-rows.ts +118 -76
  212. package/src/data/watermark.ts +2 -2
  213. package/src/data/wrap.ts +63 -38
  214. package/src/frames/blank-frame.ts +1 -0
  215. package/src/frames/index.ts +2 -2
  216. package/src/frames/page-bar.ts +12 -11
  217. package/src/frames/page-header.ts +14 -5
  218. package/src/frames/page-status.ts +2 -2
  219. package/src/frames/shared.ts +23 -17
  220. package/src/frames/single-frame.ts +1 -0
  221. package/src/frames/split-frame/shell.ts +5 -5
  222. package/src/frames/split-frame/wiring.ts +2 -2
  223. package/src/frames/tabs-frame/shell.ts +2 -13
  224. package/src/frames/tabs-frame/wiring.ts +4 -8
  225. package/src/frames/top-main-frame.ts +1 -0
  226. package/src/frames/types.ts +13 -2
  227. package/src/frames/workspace-frame/extras.ts +20 -4
  228. package/src/frames/workspace-frame/index.ts +1 -1
  229. package/src/frames/workspace-frame/shell.ts +1 -0
  230. package/src/frames/workspace-frame/state.ts +13 -6
  231. package/src/frames/workspace-frame/view.ts +119 -25
  232. package/src/generated/kit-grammar-runtime.ts +430 -366
  233. package/src/generated/page-origin.ts +0 -11
  234. package/src/i18n/kit-text.ts +23 -27
  235. package/src/index.ts +2 -1
  236. package/src/object-renderer/action-gate.ts +11 -147
  237. package/src/object-renderer/arrange.ts +71 -77
  238. package/src/object-renderer/collapse-wiring.ts +2 -2
  239. package/src/object-renderer/collection-expand.ts +2 -2
  240. package/src/object-renderer/collection-parts.ts +216 -100
  241. package/src/object-renderer/collection-table.ts +180 -42
  242. package/src/object-renderer/collection.ts +95 -79
  243. package/src/object-renderer/compile-data.ts +85 -100
  244. package/src/object-renderer/crud-bridge.ts +32 -0
  245. package/src/object-renderer/defaults.ts +8 -14
  246. package/src/object-renderer/display-checks.ts +3 -24
  247. package/src/object-renderer/emit-events.ts +186 -172
  248. package/src/object-renderer/emit-object.ts +15 -2
  249. package/src/object-renderer/emit-static.ts +174 -132
  250. package/src/object-renderer/field-value.ts +593 -396
  251. package/src/object-renderer/filter-reload.ts +70 -0
  252. package/src/object-renderer/form-detail.ts +112 -2
  253. package/src/object-renderer/index.ts +26 -0
  254. package/src/object-renderer/key-field.ts +12 -0
  255. package/src/object-renderer/linkage.ts +7 -270
  256. package/src/object-renderer/merge-class.ts +18 -1
  257. package/src/object-renderer/path-pick.ts +27 -0
  258. package/src/object-renderer/render-object.ts +405 -86
  259. package/src/object-renderer/request-actions.ts +230 -249
  260. package/src/object-renderer/table-actions.ts +195 -95
  261. package/src/object-renderer/table-summary.ts +2 -2
  262. package/src/object-renderer/table-tools.ts +418 -84
  263. package/src/object-renderer/types.ts +128 -122
  264. package/src/object-renderer/view-binding.ts +196 -0
  265. package/src/page-target/ai-surface.ts +37 -0
  266. package/src/page-target/compile.ts +48 -8
  267. package/src/page-target/index.ts +8 -1
  268. package/src/page-target/intent-schema.ts +154 -28
  269. package/src/page-target/target.ts +257 -50
  270. package/src/page-target/writer-policy.ts +14 -3
  271. package/src/recipes/container.ts +165 -0
  272. package/src/recipes/control.ts +219 -0
  273. package/src/recipes/index.ts +263 -0
  274. package/src/recipes/overlay.ts +182 -0
  275. package/src/recipes/state.ts +70 -0
  276. package/src/recipes/table-row.ts +51 -0
  277. package/src/recipes/typography.ts +87 -0
  278. package/src/shared/action-field-guard.ts +41 -0
  279. package/src/shared/envelope.ts +207 -0
  280. package/src/shared/escape.ts +57 -0
  281. package/src/shared/kit-error.ts +21 -0
  282. package/src/shared/paged-list-adapter.ts +240 -0
  283. package/src/shared/path-guard.ts +127 -0
  284. package/src/shared/theme-runtime-shared.ts +175 -0
  285. package/src/shared/view-info.ts +10 -0
  286. package/src/theme/index.ts +12 -0
  287. package/src/theme/kit-theme-text.ts +1 -1
  288. package/src/theme/kit-theme.css +38 -1
  289. package/src/theme/kit-theme.tpl +38 -1
  290. package/src/theme/nine-dim-structure.ts +77 -0
  291. package/src/theme/surface-layers.ts +97 -0
  292. package/src/theme/theme-tokens.ts +85 -79
  293. package/src/theme/theme-types.ts +71 -0
  294. package/src/theme/typography.ts +17 -17
  295. package/src/biz/shared/step-values.ts +0 -25
  296. package/src/biz/step-form/steps-ref.ts +0 -112
  297. package/src/data/options-bus.ts +0 -24
  298. package/src/data/prompt-dialog.ts +0 -235
  299. package/src/object-renderer/adopt-gate.ts +0 -333
  300. package/src/object-renderer/field-policy.ts +0 -89
  301. package/src/object-renderer/outcome-draft.ts +0 -61
  302. package/src/theme/nine-dim-palettes.ts +0 -1278
@@ -1,226 +1,55 @@
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';
5
6
 
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
- }
7
+ export type {
8
+ KitThemePalette,
9
+ KitThemeColorDepth,
10
+ KitThemeColorSaturation,
11
+ KitThemeFontFamily,
12
+ KitThemeFontScale,
13
+ KitThemeBoundary,
14
+ KitThemeShape,
15
+ KitThemeSurfaceTexture,
16
+ KitThemeDensity,
17
+ KitAppTheme,
18
+ } from '../theme/theme-types';
19
+ export {
20
+ KIT_THEME_PALETTES,
21
+ KIT_THEME_COLOR_DEPTHS,
22
+ KIT_THEME_COLOR_SATURATIONS,
23
+ KIT_THEME_FONT_FAMILIES,
24
+ KIT_THEME_FONT_SCALES,
25
+ KIT_THEME_BOUNDARIES,
26
+ KIT_THEME_SHAPES,
27
+ KIT_THEME_SURFACE_TEXTURES,
28
+ KIT_THEME_DENSITIES,
29
+ } from '../theme/theme-types';
30
+ import {
31
+ KIT_THEME_PALETTES,
32
+ KIT_THEME_COLOR_DEPTHS,
33
+ KIT_THEME_COLOR_SATURATIONS,
34
+ KIT_THEME_FONT_FAMILIES,
35
+ KIT_THEME_FONT_SCALES,
36
+ KIT_THEME_BOUNDARIES,
37
+ KIT_THEME_SHAPES,
38
+ KIT_THEME_SURFACE_TEXTURES,
39
+ KIT_THEME_DENSITIES,
40
+ type KitThemePalette,
41
+ type KitThemeColorDepth,
42
+ type KitThemeColorSaturation,
43
+ type KitThemeFontFamily,
44
+ type KitThemeFontScale,
45
+ type KitThemeBoundary,
46
+ type KitThemeShape,
47
+ type KitThemeSurfaceTexture,
48
+ type KitThemeDensity,
49
+ type KitAppTheme,
50
+ } from '../theme/theme-types';
51
+ import { KIT_THEME_MODES } from '../theme/theme-tokens';
52
+ export { KIT_THEME_MODES };
224
53
 
225
54
  export interface KitAppLayoutNavItem {
226
55
  id: string;
@@ -250,6 +79,15 @@ export interface KitAppLayout {
250
79
  };
251
80
  }
252
81
 
82
+ export interface KitDictOption {
83
+ value: string | number | boolean;
84
+ label: string;
85
+ tone?: string;
86
+ }
87
+
88
+ export type KitAppDicts = Record<string, KitDictOption[]>;
89
+ export type KitAppEntities = Record<string, Record<string, unknown>>;
90
+
253
91
  export interface KitAppConfig {
254
92
  /** 主题:9 维正交页面主题 DSL 规格或基础方案 */
255
93
  theme?: KitAppTheme;
@@ -263,10 +101,17 @@ export interface KitAppConfig {
263
101
  staticObjectComponents: Record<string, { accept: 'single' | 'list'; desc: string }>;
264
102
  /** 业务信封约定(失败判定 / 业务文案位置 / 数据位置):声明一次,编译与运行时共读;页面 page.envelope 可覆写 */
265
103
  envelope?: KitEnvelope;
104
+ /** 应用级共享枚举字典(供页面 schema 字段 options: '$dict.<name>' 编译期静态展开) */
105
+ dicts?: KitAppDicts;
106
+ /** 应用级共享实体字段定义(供页面对象 schema: '$entity.<name>' 或 { $ref: '$entity.<name>', pick?, omit?, override? } 编译期静态展开) */
107
+ entities?: KitAppEntities;
266
108
  }
267
109
 
268
110
  const APP_NAME = /^App[A-Z][A-Za-z0-9]*$/;
269
- const TOP_KEYS = ['style', 'theme', 'layout', 'baseComponents', 'staticObjectComponents', 'envelope'];
111
+ const TOP_KEYS = ['style', 'theme', 'layout', 'baseComponents', 'staticObjectComponents', 'envelope', 'dicts', 'entities', 'app'];
112
+ const APP_SUB_KEYS = ['style', 'theme', 'layout', 'envelope', 'dicts', 'entities'];
113
+ const DICT_OPTION_KEYS = ['value', 'label', 'tone'];
114
+ const ENTITY_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
270
115
  const THEME_KEYS = [
271
116
  'palette',
272
117
  'color_depth',
@@ -282,23 +127,54 @@ const THEME_KEYS = [
282
127
  'surface_texture',
283
128
  'surfaceTexture',
284
129
  'density',
285
- 'preset',
286
- 'polarity',
287
- 'radius',
288
130
  '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
131
  ];
132
+ /**
133
+ * 已删除的旧主题链键(库配色方案、库字体方案、品牌色号与旧布局/样式键):只用于报 KIT-APP-002 迁移诊断,不再解析、不留兼容。
134
+ * 键 -> 迁移指引(改用九维对应维度)。
135
+ */
136
+ export const REMOVED_THEME_KEYS: Readonly<Record<string, string>> = {
137
+ palette_scheme: `改用九维 palette(行业配色枚举,如 ${KIT_THEME_PALETTES[0]}),配色深浅与饱和度用 color_depth / color_saturation`,
138
+ paletteScheme: `改用九维 palette(行业配色枚举,如 ${KIT_THEME_PALETTES[0]}),配色深浅与饱和度用 color_depth / color_saturation`,
139
+ font_scheme: `改用九维 font_family(字体枚举,如 ${KIT_THEME_FONT_FAMILIES[0]})与 font_scale(字号行距档)`,
140
+ fontScheme: `改用九维 font_family(字体枚举,如 ${KIT_THEME_FONT_FAMILIES[0]})与 font_scale(字号行距档)`,
141
+ color: '品牌色号不再支持:改用九维 palette 选一套人工精调配色,配合 color_depth / color_saturation 调深浅与饱和度',
142
+ polarity: '改用 mode(light / dark / soft / system)',
143
+ radius: '改用九维 shape',
144
+ preset: '改用九维 palette 配合 color_depth / color_saturation',
145
+ color_scheme: '改用九维 palette 配合 color_depth / color_saturation',
146
+ colorScheme: '改用九维 palette 配合 color_depth / color_saturation',
147
+ tone: '改用九维 palette 配合 color_depth / color_saturation',
148
+ typography_scheme: '改用九维 font_family 与 font_scale',
149
+ typographyScheme: '改用九维 font_family 与 font_scale',
150
+ component_style: '改用九维 boundary 与 surface_texture',
151
+ componentStyle: '改用九维 boundary 与 surface_texture',
152
+ };
153
+
154
+ /**
155
+ * 校验主题对象中的已删除旧键(palette_scheme/paletteScheme/font_scheme/fontScheme/color 等),
156
+ * 命中即推入 KIT-APP-002 迁移诊断。
157
+ */
158
+ export function checkRemovedThemeKeys(
159
+ rawTheme: unknown,
160
+ pathPrefix: string = 'theme',
161
+ diagnostics: KitDiagnostic[] = [],
162
+ keyPathResolver?: (key: string) => string,
163
+ ): KitDiagnostic[] {
164
+ if (rawTheme === null || typeof rawTheme !== 'object' || Array.isArray(rawTheme)) return diagnostics;
165
+ for (const k of Object.keys(rawTheme)) {
166
+ const removedHint = Object.prototype.hasOwnProperty.call(REMOVED_THEME_KEYS, k) ? REMOVED_THEME_KEYS[k] : undefined;
167
+ if (removedHint !== undefined) {
168
+ const kp = keyPathResolver !== undefined ? keyPathResolver(k) : (pathPrefix !== '' ? `${pathPrefix}.${k}` : k);
169
+ diagnostics.push({
170
+ code: 'KIT-APP-002',
171
+ path: kp,
172
+ message: `theme.${k} 已删除(kit 主题只支持九维 palette / color_depth / color_saturation / font_family / font_scale / boundary / shape / surface_texture / density + mode):${removedHint}`,
173
+ });
174
+ }
175
+ }
176
+ return diagnostics;
177
+ }
302
178
  const STATIC_KEYS = ['accept', 'desc'];
303
179
  const LAYOUT_TOP_KEYS = ['frame', 'max_width', 'sticky_header', 'header', 'sidebar', 'footer'];
304
180
  const MAX_WIDTH_VALUES = ['narrow', 'medium', 'wide', 'full'] as const;
@@ -317,6 +193,45 @@ function bad(path: string, message: string, out: KitDiagnostic[]): void {
317
193
  out.push({ code: 'KIT-APP-001', path, message });
318
194
  }
319
195
 
196
+ function resolveAppSection(
197
+ raw: Record<string, unknown>,
198
+ appBlock: Record<string, unknown> | undefined,
199
+ key: (typeof APP_SUB_KEYS)[number],
200
+ ): { value: unknown; pathPrefix: string; keyPathOf: (subKey: string) => string } {
201
+ const topVal = raw[key];
202
+ const appVal = appBlock?.[key];
203
+ if (isRecord(topVal) && isRecord(appVal)) {
204
+ return {
205
+ value: { ...topVal, ...appVal },
206
+ pathPrefix: `kit.app.yaml.app.${key}`,
207
+ keyPathOf: (subKey: string) =>
208
+ Object.prototype.hasOwnProperty.call(appVal, subKey)
209
+ ? `kit.app.yaml.app.${key}.${subKey}`
210
+ : `kit.app.yaml.${key}.${subKey}`,
211
+ };
212
+ }
213
+ if (topVal === undefined && appVal !== undefined) {
214
+ return {
215
+ value: appVal,
216
+ pathPrefix: `kit.app.yaml.app.${key}`,
217
+ keyPathOf: (subKey: string) => `kit.app.yaml.app.${key}.${subKey}`,
218
+ };
219
+ }
220
+ if (appVal !== undefined && !isRecord(appVal) && isRecord(topVal)) {
221
+ return {
222
+ value: appVal,
223
+ pathPrefix: `kit.app.yaml.app.${key}`,
224
+ keyPathOf: (subKey: string) => `kit.app.yaml.app.${key}.${subKey}`,
225
+ };
226
+ }
227
+ return {
228
+ value: topVal !== undefined ? topVal : appVal,
229
+ pathPrefix: topVal !== undefined ? `kit.app.yaml.${key}` : `kit.app.yaml.app.${key}`,
230
+ keyPathOf: (subKey: string) =>
231
+ topVal !== undefined ? `kit.app.yaml.${key}.${subKey}` : `kit.app.yaml.app.${key}.${subKey}`,
232
+ };
233
+ }
234
+
320
235
  function parseNavItem(raw: unknown, path: string, diagnostics: KitDiagnostic[]): KitAppLayoutNavItem | undefined {
321
236
  if (!isRecord(raw)) {
322
237
  bad(path, `${path} 必须是对象 { id, label, href?, url?, icon? }`, diagnostics);
@@ -334,13 +249,23 @@ function parseNavItem(raw: unknown, path: string, diagnostics: KitDiagnostic[]):
334
249
  return undefined;
335
250
  }
336
251
  const item: KitAppLayoutNavItem = { id: raw.id.trim(), label: raw.label.trim() };
252
+ if (raw.path !== undefined) {
253
+ if (typeof raw.path === 'string') checkNoRelativeOrSystemPath(raw.path, `${path}.path`, diagnostics, 'KIT-APP-001');
254
+ else bad(`${path}.path`, 'path 必须是字符串', diagnostics);
255
+ }
337
256
  if (raw.href !== undefined) {
338
- if (typeof raw.href === 'string') item.href = raw.href;
339
- else bad(`${path}.href`, 'href 必须是字符串', diagnostics);
257
+ if (typeof raw.href === 'string') {
258
+ if (checkNoRelativeOrSystemPath(raw.href, `${path}.href`, diagnostics, 'KIT-APP-001', { allowExternalHref: true })) {
259
+ item.href = raw.href;
260
+ }
261
+ } else bad(`${path}.href`, 'href 必须是字符串', diagnostics);
340
262
  }
341
263
  if (raw.url !== undefined) {
342
- if (typeof raw.url === 'string') item.url = raw.url;
343
- else bad(`${path}.url`, 'url 必须是字符串', diagnostics);
264
+ if (typeof raw.url === 'string') {
265
+ if (checkNoRelativeOrSystemPath(raw.url, `${path}.url`, diagnostics, 'KIT-APP-001')) {
266
+ item.url = raw.url;
267
+ }
268
+ } else bad(`${path}.url`, 'url 必须是字符串', diagnostics);
344
269
  }
345
270
  if (raw.icon !== undefined) {
346
271
  if (typeof raw.icon === 'string') item.icon = raw.icon;
@@ -360,178 +285,189 @@ export function parseAppConfig(raw: unknown, diagnostics: KitDiagnostic[]): KitA
360
285
  for (const k of Object.keys(raw)) {
361
286
  if (!TOP_KEYS.includes(k)) bad(`kit.app.yaml.${k}`, `未知键 ${k}(允许:${TOP_KEYS.join(' / ')})`, diagnostics);
362
287
  }
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);
288
+ if (raw.app !== undefined) {
289
+ if (!isRecord(raw.app)) {
290
+ bad('kit.app.yaml.app', 'app 必须是对象', diagnostics);
291
+ } else {
292
+ for (const k of Object.keys(raw.app)) {
293
+ if (!APP_SUB_KEYS.includes(k)) bad(`kit.app.yaml.app.${k}`, `未知键 ${k}(允许:${APP_SUB_KEYS.join(' / ')})`, diagnostics);
294
+ }
295
+ }
296
+ }
297
+ const appBlock = isRecord(raw.app) ? raw.app : undefined;
298
+ const { value: rawStyle, pathPrefix: stylePath } = resolveAppSection(raw, appBlock, 'style');
299
+ if (rawStyle !== undefined) {
300
+ if (typeof rawStyle === 'string' && rawStyle !== '') {
301
+ if (checkNoRelativeOrSystemPath(rawStyle, stylePath, diagnostics, 'KIT-APP-001', { allowConfigSubpath: true })) {
302
+ cfg.style = rawStyle;
303
+ }
304
+ } else bad(stylePath, 'style 必须是主题头文件路径', diagnostics);
366
305
  }
367
- if (raw.envelope !== undefined) {
368
- const envelope = parseKitEnvelope(raw.envelope, 'kit.app.yaml.envelope', 'KIT-APP-001', diagnostics);
306
+ const { value: rawEnvelope, pathPrefix: envelopePath } = resolveAppSection(raw, appBlock, 'envelope');
307
+ if (rawEnvelope !== undefined) {
308
+ const envelope = parseKitEnvelope(rawEnvelope, envelopePath, 'KIT-APP-001', diagnostics);
369
309
  if (envelope !== undefined) cfg.envelope = envelope;
370
310
  }
371
- if (raw.theme !== undefined) {
372
- if (!isRecord(raw.theme)) bad('kit.app.yaml.theme', 'theme 必须是对象', diagnostics);
311
+ const { value: rawTheme, pathPrefix: themePath, keyPathOf: themeKeyPath } = resolveAppSection(raw, appBlock, 'theme');
312
+ if (rawTheme !== undefined) {
313
+ if (!isRecord(rawTheme)) bad(themePath, 'theme 必须是对象', diagnostics);
373
314
  else {
315
+ checkRemovedThemeKeys(rawTheme, themePath, diagnostics, themeKeyPath);
374
316
  const theme: KitAppTheme = {};
375
- for (const [k, v] of Object.entries(raw.theme)) {
317
+ for (const [k, v] of Object.entries(rawTheme)) {
318
+ if (Object.prototype.hasOwnProperty.call(REMOVED_THEME_KEYS, k)) {
319
+ continue;
320
+ }
321
+ const kp = themeKeyPath(k);
376
322
  if (!THEME_KEYS.includes(k)) {
377
- bad(`kit.app.yaml.theme.${k}`, `未知键 ${k}(允许:${THEME_KEYS.join(' / ')})`, diagnostics);
323
+ bad(kp, `未知键 ${k}(允许:${THEME_KEYS.join(' / ')})`, diagnostics);
378
324
  } else if (typeof v !== 'string' || v.trim() === '') {
379
- bad(`kit.app.yaml.theme.${k}`, `${k} 必须是非空字符串`, diagnostics);
325
+ bad(kp, `${k} 必须是非空字符串`, diagnostics);
380
326
  } else {
381
327
  const val = v.trim();
382
328
  if (k === 'palette') {
383
329
  if (!(KIT_THEME_PALETTES as readonly string[]).includes(val)) {
384
- bad('kit.app.yaml.theme.palette', `palette「${val}」只能是 ${KIT_THEME_PALETTES.join(' / ')}`, diagnostics);
330
+ bad(kp, `palette「${val}」只能是 ${KIT_THEME_PALETTES.join(' / ')}`, diagnostics);
385
331
  } else {
386
332
  theme.palette = val as KitThemePalette;
387
333
  }
388
334
  } else if (k === 'color_depth' || k === 'colorDepth') {
389
335
  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);
336
+ bad(kp, `${k}「${val}」只能是 ${KIT_THEME_COLOR_DEPTHS.join(' / ')}`, diagnostics);
391
337
  } else {
392
338
  theme.color_depth = val as KitThemeColorDepth;
393
339
  theme.colorDepth = val as KitThemeColorDepth;
394
340
  }
395
341
  } else if (k === 'color_saturation' || k === 'colorSaturation') {
396
342
  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);
343
+ bad(kp, `${k}「${val}」只能是 ${KIT_THEME_COLOR_SATURATIONS.join(' / ')}`, diagnostics);
398
344
  } else {
399
345
  theme.color_saturation = val as KitThemeColorSaturation;
400
346
  theme.colorSaturation = val as KitThemeColorSaturation;
401
347
  }
402
348
  } else if (k === 'font_family' || k === 'fontFamily') {
403
349
  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);
350
+ bad(kp, `${k}「${val}」只能是 ${KIT_THEME_FONT_FAMILIES.join(' / ')}`, diagnostics);
405
351
  } else {
406
352
  theme.font_family = val as KitThemeFontFamily;
407
353
  theme.fontFamily = val as KitThemeFontFamily;
408
354
  }
409
355
  } else if (k === 'font_scale' || k === 'fontScale') {
410
356
  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);
357
+ bad(kp, `${k}「${val}」只能是 ${KIT_THEME_FONT_SCALES.join(' / ')}`, diagnostics);
412
358
  } else {
413
359
  theme.font_scale = val as KitThemeFontScale;
414
360
  theme.fontScale = val as KitThemeFontScale;
415
361
  }
416
362
  } else if (k === 'boundary') {
417
363
  if (!(KIT_THEME_BOUNDARIES as readonly string[]).includes(val)) {
418
- bad('kit.app.yaml.theme.boundary', `boundary「${val}」只能是 ${KIT_THEME_BOUNDARIES.join(' / ')}`, diagnostics);
364
+ bad(kp, `boundary「${val}」只能是 ${KIT_THEME_BOUNDARIES.join(' / ')}`, diagnostics);
419
365
  } else {
420
366
  theme.boundary = val as KitThemeBoundary;
421
367
  }
422
368
  } else if (k === 'shape') {
423
369
  if (!(KIT_THEME_SHAPES as readonly string[]).includes(val)) {
424
- bad('kit.app.yaml.theme.shape', `shape「${val}」只能是 ${KIT_THEME_SHAPES.join(' / ')}`, diagnostics);
370
+ bad(kp, `shape「${val}」只能是 ${KIT_THEME_SHAPES.join(' / ')}`, diagnostics);
425
371
  } else {
426
372
  theme.shape = val as KitThemeShape;
427
373
  }
428
374
  } else if (k === 'surface_texture' || k === 'surfaceTexture') {
429
375
  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);
376
+ bad(kp, `${k}「${val}」只能是 ${KIT_THEME_SURFACE_TEXTURES.join(' / ')}`, diagnostics);
431
377
  } else {
432
378
  theme.surface_texture = val as KitThemeSurfaceTexture;
433
379
  theme.surfaceTexture = val as KitThemeSurfaceTexture;
434
380
  }
435
381
  } else if (k === 'density') {
436
382
  if (!(KIT_THEME_DENSITIES as readonly string[]).includes(val)) {
437
- bad('kit.app.yaml.theme.density', `density「${val}」只能是 ${KIT_THEME_DENSITIES.join(' / ')}`, diagnostics);
383
+ bad(kp, `density「${val}」只能是 ${KIT_THEME_DENSITIES.join(' / ')}`, diagnostics);
438
384
  } else {
439
385
  theme.density = val as KitThemeDensity;
440
386
  }
441
- } 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;
461
387
  } else if (k === 'mode') {
462
- theme.mode = val;
388
+ if (!(KIT_THEME_MODES as readonly string[]).includes(val)) {
389
+ bad(kp, `mode「${val}」只能是 ${KIT_THEME_MODES.join(' / ')}`, diagnostics);
390
+ } else {
391
+ theme.mode = val;
392
+ }
463
393
  }
464
394
  }
465
395
  }
466
396
  cfg.theme = theme;
467
397
  }
468
398
  }
469
- if (raw.layout !== undefined) {
470
- if (!isRecord(raw.layout)) {
471
- bad('kit.app.yaml.layout', 'layout 必须是对象', diagnostics);
399
+ const { value: rawLayout, pathPrefix: layoutPath, keyPathOf: layoutKeyPath } = resolveAppSection(raw, appBlock, 'layout');
400
+ if (rawLayout !== undefined) {
401
+ if (!isRecord(rawLayout)) {
402
+ bad(layoutPath, 'layout 必须是对象', diagnostics);
472
403
  } 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);
404
+ for (const k of Object.keys(rawLayout)) {
405
+ if (!LAYOUT_TOP_KEYS.includes(k)) bad(layoutKeyPath(k), `未知键 ${k}(允许:${LAYOUT_TOP_KEYS.join(' / ')})`, diagnostics);
475
406
  }
476
407
  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);
408
+ if (rawLayout.frame !== undefined) {
409
+ if (typeof rawLayout.frame === 'string' && rawLayout.frame.trim() !== '') layout.frame = rawLayout.frame.trim();
410
+ else bad(layoutKeyPath('frame'), 'frame 必须是非空字符串', diagnostics);
480
411
  }
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);
412
+ if (rawLayout.max_width !== undefined) {
413
+ const mw = typeof rawLayout.max_width === 'string' ? rawLayout.max_width.trim() : '';
414
+ 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
415
  else layout.maxWidth = mw as 'narrow' | 'medium' | 'wide' | 'full';
485
416
  }
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);
417
+ if (rawLayout.sticky_header !== undefined) {
418
+ if (typeof rawLayout.sticky_header === 'boolean') layout.stickyHeader = rawLayout.sticky_header;
419
+ else bad(layoutKeyPath('sticky_header'), 'sticky_header 必须是布尔值', diagnostics);
489
420
  }
490
- if (raw.layout.header !== undefined) {
491
- if (!isRecord(raw.layout.header)) {
492
- bad('kit.app.yaml.layout.header', 'header 必须是对象', diagnostics);
421
+ if (rawLayout.header !== undefined) {
422
+ const hp = layoutKeyPath('header');
423
+ if (!isRecord(rawLayout.header)) {
424
+ bad(hp, 'header 必须是对象', diagnostics);
493
425
  } 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);
426
+ for (const k of Object.keys(rawLayout.header)) {
427
+ if (!LAYOUT_HEADER_KEYS.includes(k)) bad(`${hp}.${k}`, `未知键 ${k}(允许:${LAYOUT_HEADER_KEYS.join(' / ')})`, diagnostics);
496
428
  }
497
429
  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);
430
+ if (rawLayout.header.brand !== undefined) {
431
+ const bp = `${hp}.brand`;
432
+ if (!isRecord(rawLayout.header.brand)) {
433
+ bad(bp, 'brand 必须是对象', diagnostics);
501
434
  } 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);
435
+ for (const k of Object.keys(rawLayout.header.brand)) {
436
+ if (!BRAND_KEYS.includes(k)) bad(`${bp}.${k}`, `未知键 ${k}(允许:${BRAND_KEYS.join(' / ')})`, diagnostics);
504
437
  }
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);
438
+ if (typeof rawLayout.header.brand.text !== 'string' || rawLayout.header.brand.text.trim() === '') {
439
+ bad(`${bp}.text`, 'brand.text 必须是非空字符串', diagnostics);
507
440
  } 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);
441
+ header.brand = { text: rawLayout.header.brand.text.trim() };
442
+ if (rawLayout.header.brand.href !== undefined) {
443
+ if (typeof rawLayout.header.brand.href === 'string') {
444
+ if (checkNoRelativeOrSystemPath(rawLayout.header.brand.href, `${bp}.href`, diagnostics, 'KIT-APP-001', { allowExternalHref: true })) {
445
+ header.brand.href = rawLayout.header.brand.href;
446
+ }
447
+ } else bad(`${bp}.href`, 'brand.href 必须是字符串', diagnostics);
512
448
  }
513
449
  }
514
450
  }
515
451
  }
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);
452
+ if (rawLayout.header.nav !== undefined) {
453
+ if (!Array.isArray(rawLayout.header.nav)) {
454
+ bad(`${hp}.nav`, 'nav 必须是数组', diagnostics);
519
455
  } else {
520
456
  const nav: KitAppLayoutNavItem[] = [];
521
- raw.layout.header.nav.forEach((it, i) => {
522
- const parsed = parseNavItem(it, `kit.app.yaml.layout.header.nav[${i}]`, diagnostics);
457
+ rawLayout.header.nav.forEach((it, i) => {
458
+ const parsed = parseNavItem(it, `${hp}.nav[${i}]`, diagnostics);
523
459
  if (parsed) nav.push(parsed);
524
460
  });
525
461
  header.nav = nav;
526
462
  }
527
463
  }
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);
464
+ if (rawLayout.header.actions !== undefined) {
465
+ if (!Array.isArray(rawLayout.header.actions)) {
466
+ bad(`${hp}.actions`, 'actions 必须是数组', diagnostics);
531
467
  } else {
532
468
  const actions: KitAppLayoutNavItem[] = [];
533
- raw.layout.header.actions.forEach((it, i) => {
534
- const parsed = parseNavItem(it, `kit.app.yaml.layout.header.actions[${i}]`, diagnostics);
469
+ rawLayout.header.actions.forEach((it, i) => {
470
+ const parsed = parseNavItem(it, `${hp}.actions[${i}]`, diagnostics);
535
471
  if (parsed) actions.push(parsed);
536
472
  });
537
473
  header.actions = actions;
@@ -540,29 +476,30 @@ export function parseAppConfig(raw: unknown, diagnostics: KitDiagnostic[]): KitA
540
476
  layout.header = header;
541
477
  }
542
478
  }
543
- if (raw.layout.sidebar !== undefined) {
544
- if (!isRecord(raw.layout.sidebar)) {
545
- bad('kit.app.yaml.layout.sidebar', 'sidebar 必须是对象', diagnostics);
479
+ if (rawLayout.sidebar !== undefined) {
480
+ const sp = layoutKeyPath('sidebar');
481
+ if (!isRecord(rawLayout.sidebar)) {
482
+ bad(sp, 'sidebar 必须是对象', diagnostics);
546
483
  } 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);
484
+ for (const k of Object.keys(rawLayout.sidebar)) {
485
+ if (!LAYOUT_SIDEBAR_KEYS.includes(k)) bad(`${sp}.${k}`, `未知键 ${k}(允许:${LAYOUT_SIDEBAR_KEYS.join(' / ')})`, diagnostics);
549
486
  }
550
487
  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);
488
+ if (rawLayout.sidebar.title !== undefined) {
489
+ if (typeof rawLayout.sidebar.title === 'string') sidebar.title = rawLayout.sidebar.title;
490
+ else bad(`${sp}.title`, 'sidebar.title 必须是字符串', diagnostics);
554
491
  }
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);
492
+ if (rawLayout.sidebar.width !== undefined) {
493
+ if (typeof rawLayout.sidebar.width === 'number' && !Number.isNaN(rawLayout.sidebar.width)) sidebar.width = rawLayout.sidebar.width;
494
+ else bad(`${sp}.width`, 'sidebar.width 必须是数字', diagnostics);
558
495
  }
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);
496
+ if (rawLayout.sidebar.menu !== undefined) {
497
+ if (!Array.isArray(rawLayout.sidebar.menu)) {
498
+ bad(`${sp}.menu`, 'sidebar.menu 必须是数组', diagnostics);
562
499
  } else {
563
500
  const menu: KitAppLayoutNavItem[] = [];
564
- raw.layout.sidebar.menu.forEach((it, i) => {
565
- const parsed = parseNavItem(it, `kit.app.yaml.layout.sidebar.menu[${i}]`, diagnostics);
501
+ rawLayout.sidebar.menu.forEach((it, i) => {
502
+ const parsed = parseNavItem(it, `${sp}.menu[${i}]`, diagnostics);
566
503
  if (parsed) menu.push(parsed);
567
504
  });
568
505
  sidebar.menu = menu;
@@ -571,25 +508,26 @@ export function parseAppConfig(raw: unknown, diagnostics: KitDiagnostic[]): KitA
571
508
  layout.sidebar = sidebar;
572
509
  }
573
510
  }
574
- if (raw.layout.footer !== undefined) {
575
- if (!isRecord(raw.layout.footer)) {
576
- bad('kit.app.yaml.layout.footer', 'footer 必须是对象', diagnostics);
511
+ if (rawLayout.footer !== undefined) {
512
+ const fp = layoutKeyPath('footer');
513
+ if (!isRecord(rawLayout.footer)) {
514
+ bad(fp, 'footer 必须是对象', diagnostics);
577
515
  } 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);
516
+ for (const k of Object.keys(rawLayout.footer)) {
517
+ if (!LAYOUT_FOOTER_KEYS.includes(k)) bad(`${fp}.${k}`, `未知键 ${k}(允许:${LAYOUT_FOOTER_KEYS.join(' / ')})`, diagnostics);
580
518
  }
581
519
  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);
520
+ if (rawLayout.footer.text !== undefined) {
521
+ if (typeof rawLayout.footer.text === 'string') footer.text = rawLayout.footer.text;
522
+ else bad(`${fp}.text`, 'footer.text 必须是字符串', diagnostics);
585
523
  }
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);
524
+ if (rawLayout.footer.links !== undefined) {
525
+ if (!Array.isArray(rawLayout.footer.links)) {
526
+ bad(`${fp}.links`, 'footer.links 必须是数组', diagnostics);
589
527
  } else {
590
528
  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}]`;
529
+ rawLayout.footer.links.forEach((link, i) => {
530
+ const lp = `${fp}.links[${i}]`;
593
531
  if (!isRecord(link)) {
594
532
  bad(lp, `${lp} 必须是对象 { label, href }`, diagnostics);
595
533
  return;
@@ -605,6 +543,9 @@ export function parseAppConfig(raw: unknown, diagnostics: KitDiagnostic[]): KitA
605
543
  bad(`${lp}.href`, 'href 必须是非空字符串', diagnostics);
606
544
  return;
607
545
  }
546
+ if (!checkNoRelativeOrSystemPath(link.href, `${lp}.href`, diagnostics, 'KIT-APP-001', { allowExternalHref: true })) {
547
+ return;
548
+ }
608
549
  links.push({ label: link.label.trim(), href: link.href.trim() });
609
550
  });
610
551
  footer.links = links;
@@ -649,5 +590,88 @@ export function parseAppConfig(raw: unknown, diagnostics: KitDiagnostic[]): KitA
649
590
  }
650
591
  }
651
592
  }
593
+ const { value: rawDicts, pathPrefix: dictsPathPrefix, keyPathOf: dictsKeyPath } = resolveAppSection(raw, appBlock, 'dicts');
594
+ if (rawDicts !== undefined) {
595
+ if (!isRecord(rawDicts)) {
596
+ bad(dictsPathPrefix, "dicts 必须是 { 字典名: [{ value, label, tone? }] }", diagnostics);
597
+ } else {
598
+ const dicts: KitAppDicts = {};
599
+ for (const [dictName, items] of Object.entries(rawDicts)) {
600
+ const dp = dictsKeyPath(dictName);
601
+ if (!ENTITY_NAME_RE.test(dictName)) {
602
+ bad(dp, `字典名 ${dictName} 必须是合法标识符`, diagnostics);
603
+ continue;
604
+ }
605
+ if (!Array.isArray(items) || items.length === 0) {
606
+ bad(dp, "字典项必须是非空选项数组 [{ value, label, tone? }]", diagnostics);
607
+ continue;
608
+ }
609
+ const parsedItems: KitDictOption[] = [];
610
+ items.forEach((it, idx) => {
611
+ const ip = `${dp}[${idx}]`;
612
+ if (!isRecord(it)) {
613
+ bad(ip, "字典选项必须是 { value, label, tone? } 对象", diagnostics);
614
+ return;
615
+ }
616
+ for (const k of Object.keys(it)) {
617
+ if (!DICT_OPTION_KEYS.includes(k)) bad(`${ip}.${k}`, `未知键 ${k}(允许:${DICT_OPTION_KEYS.join(" / ")})`, diagnostics);
618
+ }
619
+ if (typeof it.value !== "string" && typeof it.value !== "number" && typeof it.value !== "boolean") {
620
+ bad(`${ip}.value`, "value 必须是字符串、数字或布尔值", diagnostics);
621
+ return;
622
+ }
623
+ if (typeof it.label !== "string" || it.label.trim() === "") {
624
+ bad(`${ip}.label`, "label 必须是非空字符串", diagnostics);
625
+ return;
626
+ }
627
+ const opt: KitDictOption = { value: it.value, label: it.label };
628
+ if (it.tone !== undefined) {
629
+ if (typeof it.tone !== "string" || it.tone.trim() === "") {
630
+ bad(`${ip}.tone`, "tone 必须是非空字符串", diagnostics);
631
+ } else {
632
+ opt.tone = it.tone;
633
+ }
634
+ }
635
+ parsedItems.push(opt);
636
+ });
637
+ dicts[dictName] = parsedItems;
638
+ }
639
+ cfg.dicts = dicts;
640
+ }
641
+ }
642
+ const { value: rawEntities, pathPrefix: entitiesPathPrefix, keyPathOf: entitiesKeyPath } = resolveAppSection(raw, appBlock, 'entities');
643
+ if (rawEntities !== undefined) {
644
+ if (!isRecord(rawEntities)) {
645
+ bad(entitiesPathPrefix, "entities 必须是 { 实体名: { 字段名: 字段声明 } }", diagnostics);
646
+ } else {
647
+ const entities: KitAppEntities = {};
648
+ for (const [entityName, entityVal] of Object.entries(rawEntities)) {
649
+ const ep = entitiesKeyPath(entityName);
650
+ if (!ENTITY_NAME_RE.test(entityName)) {
651
+ bad(ep, `实体名 ${entityName} 必须是合法标识符`, diagnostics);
652
+ continue;
653
+ }
654
+ if (!isRecord(entityVal)) {
655
+ bad(ep, "实体定义必须是字段声明映射对象", diagnostics);
656
+ continue;
657
+ }
658
+ const fieldMap = isRecord(entityVal.fields) && typeof entityVal.fields.type !== "string"
659
+ ? entityVal.fields
660
+ : isRecord(entityVal.schema) && typeof entityVal.schema.type !== "string"
661
+ ? entityVal.schema
662
+ : entityVal;
663
+ const resolvedFields: Record<string, unknown> = {};
664
+ for (const [fName, fDef] of Object.entries(fieldMap)) {
665
+ if (!isRecord(fDef)) {
666
+ bad(`${ep}.${fName}`, `实体 ${entityName} 的字段 ${fName} 必须是对象`, diagnostics);
667
+ continue;
668
+ }
669
+ resolvedFields[fName] = { ...fDef };
670
+ }
671
+ entities[entityName] = resolvedFields;
672
+ }
673
+ cfg.entities = entities;
674
+ }
675
+ }
652
676
  return cfg;
653
677
  }