soma-kit 0.1.12 → 0.1.14

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 (300) hide show
  1. package/README.md +5 -4
  2. package/bin/soma-kit.mjs +31 -1
  3. package/bin/soma.mjs +0 -0
  4. package/package.json +5 -4
  5. package/spec/generated/kit-app.schema.json +172 -4
  6. package/spec/generated/kit-page.schema.json +164 -5
  7. package/spec/kit-grammar.json +598 -96
  8. package/spec/kit-grammar.schema.json +12 -6
  9. package/src/app/app-config.ts +92 -8
  10. package/src/app/component-gate.ts +271 -13
  11. package/src/app/define-kit-app.ts +2 -2
  12. package/src/app/define-kit-view.ts +9 -5
  13. package/src/app/dev-diagnostic.ts +5 -0
  14. package/src/app/index.ts +29 -5
  15. package/src/app/kit-view-context.ts +181 -15
  16. package/src/app/render-ports.ts +18 -0
  17. package/src/app/server-pages.ts +8 -2
  18. package/src/app/server.ts +55 -8
  19. package/src/app/theme-runtime.ts +4 -0
  20. package/src/base/action-busy.ts +101 -4
  21. package/src/base/action-slots.ts +13 -2
  22. package/src/base/anchored-layer.ts +50 -0
  23. package/src/base/button.ts +62 -15
  24. package/src/base/check-core.ts +8 -0
  25. package/src/base/checkbox.ts +2 -1
  26. package/src/base/choice.ts +21 -2
  27. package/src/base/color-picker.ts +10 -5
  28. package/src/base/command-palette.ts +1 -1
  29. package/src/base/context-menu.ts +10 -7
  30. package/src/base/date-range.ts +7 -7
  31. package/src/base/date.ts +55 -16
  32. package/src/base/delta.ts +72 -0
  33. package/src/base/end-edge.ts +61 -0
  34. package/src/base/fab.ts +1 -1
  35. package/src/base/gap-value.ts +168 -0
  36. package/src/base/hint-tips.ts +170 -0
  37. package/src/base/icons.ts +8 -0
  38. package/src/base/illustrations.ts +95 -0
  39. package/src/base/index.ts +32 -9
  40. package/src/base/listbox-core.ts +6 -5
  41. package/src/base/loading-gate.ts +140 -87
  42. package/src/base/mentions.ts +2 -1
  43. package/src/base/menu-button.ts +16 -18
  44. package/src/base/menu-core.ts +37 -8
  45. package/src/base/motion/hover-3d.ts +1 -1
  46. package/src/base/motion/marquee.ts +1 -1
  47. package/src/base/otp.ts +5 -4
  48. package/src/base/overlay-runtime.ts +235 -0
  49. package/src/base/popover.ts +10 -9
  50. package/src/base/popup.ts +67 -8
  51. package/src/base/portal-core.ts +4 -0
  52. package/src/base/qty-stepper.ts +5 -5
  53. package/src/base/radio.ts +2 -1
  54. package/src/base/range.ts +19 -2
  55. package/src/base/rating.ts +11 -6
  56. package/src/base/reason-tip.ts +150 -0
  57. package/src/base/segmented.ts +36 -24
  58. package/src/base/shared.ts +180 -36
  59. package/src/base/state-panel.ts +367 -0
  60. package/src/base/status-tone.ts +27 -0
  61. package/src/base/sticky-edge.ts +116 -0
  62. package/src/base/swap.ts +6 -6
  63. package/src/base/switch.ts +10 -5
  64. package/src/base/tag-input.ts +6 -6
  65. package/src/base/tag.ts +76 -41
  66. package/src/base/text.ts +43 -14
  67. package/src/base/time-picker.ts +7 -5
  68. package/src/base/tree-select.ts +6 -4
  69. package/src/base/trend-tone.ts +9 -0
  70. package/src/base/upload.ts +15 -9
  71. package/src/base/view-transition.ts +77 -0
  72. package/src/biz/approval-desk/shell.ts +15 -11
  73. package/src/biz/auth-panel/shell.ts +9 -7
  74. package/src/biz/category-crud/compile.ts +5 -4
  75. package/src/biz/category-crud/shell.ts +5 -3
  76. package/src/biz/checkout-page/compile.ts +2 -1
  77. package/src/biz/checkout-page/shell.ts +10 -8
  78. package/src/biz/compose.ts +2 -2
  79. package/src/biz/data-components.ts +4 -0
  80. package/src/biz/import-wizard/shell.ts +13 -10
  81. package/src/biz/landing-page/shell.ts +2 -2
  82. package/src/biz/link/hub.ts +23 -5
  83. package/src/biz/link/shared.ts +23 -12
  84. package/src/biz/master-sub/compile.ts +207 -16
  85. package/src/biz/master-sub/detail-head.ts +61 -0
  86. package/src/biz/master-sub/index.ts +7 -3
  87. package/src/biz/master-sub/shell.ts +133 -24
  88. package/src/biz/multi-board/compile.ts +167 -9
  89. package/src/biz/multi-board/composition.ts +58 -0
  90. package/src/biz/multi-board/index.ts +1 -1
  91. package/src/biz/multi-board/prose-fold.ts +143 -0
  92. package/src/biz/multi-board/shell.ts +94 -23
  93. package/src/biz/notification-center/shell.ts +10 -7
  94. package/src/biz/page-templates/domain-templates.ts +2 -2
  95. package/src/biz/page-templates/result-page/shell.ts +4 -3
  96. package/src/biz/page-templates/sign-in-page/shell.ts +16 -16
  97. package/src/biz/record-detail/compile.ts +2 -2
  98. package/src/biz/record-detail/shell.ts +13 -10
  99. package/src/biz/settings-center/compile.ts +2 -1
  100. package/src/biz/settings-center/shell.ts +12 -9
  101. package/src/biz/shared/action-host.ts +6 -0
  102. package/src/biz/shared/compile-helpers.ts +97 -0
  103. package/src/biz/shared/coordinator.ts +7 -30
  104. package/src/biz/shared/index.ts +5 -0
  105. package/src/biz/shared/object-aliases.ts +154 -0
  106. package/src/biz/shared/overlay-compile.ts +281 -0
  107. package/src/biz/shared/overlay-shell.ts +142 -11
  108. package/src/biz/shared/pipes.ts +11 -5
  109. package/src/biz/shared/remove-wire.ts +4 -19
  110. package/src/biz/shared/runtime-hub.ts +10 -0
  111. package/src/biz/single-form/compile.ts +3 -2
  112. package/src/biz/single-form/shell.ts +9 -6
  113. package/src/biz/standard-crud/compile.ts +36 -161
  114. package/src/biz/standard-crud/shell.ts +23 -60
  115. package/src/biz/standard-crud/summary.ts +40 -0
  116. package/src/biz/step-form/shell.ts +15 -13
  117. package/src/biz/types.ts +6 -1
  118. package/src/cli/kit-cli.ts +138 -13
  119. package/src/cli/kit-init.ts +6 -1
  120. package/src/cli/layout-cli.ts +167 -0
  121. package/src/cli/migrate/index.ts +10 -0
  122. package/src/cli/migrate/migrate.ts +248 -0
  123. package/src/cli/migrate/text-utils.ts +306 -0
  124. package/src/cli/migrate/theme-map.ts +104 -0
  125. package/src/cli/migrate/ts-rules.ts +235 -0
  126. package/src/cli/migrate/types.ts +95 -0
  127. package/src/cli/migrate/view-skeleton.ts +159 -0
  128. package/src/cli/migrate/yaml-report.ts +376 -0
  129. package/src/cli/migrate/yaml-rules.ts +465 -0
  130. package/src/cli/view-writes.ts +69 -60
  131. package/src/compile/access-gate-attach.ts +27 -0
  132. package/src/compile/closed-set.ts +65 -4
  133. package/src/compile/compile-page.ts +66 -11
  134. package/src/compile/component-candidates.ts +14 -1
  135. package/src/compile/fragment.ts +11 -0
  136. package/src/compile/layout-lint/engine.ts +82 -0
  137. package/src/compile/layout-lint/index.ts +55 -0
  138. package/src/compile/layout-lint/rules-composition.ts +267 -0
  139. package/src/compile/layout-lint/rules-form.ts +191 -0
  140. package/src/compile/layout-lint/rules-table.ts +278 -0
  141. package/src/compile/layout-lint/score.ts +52 -0
  142. package/src/compile/layout-lint/types.ts +51 -0
  143. package/src/compile/page-composition.ts +189 -0
  144. package/src/compile/parse.ts +4 -0
  145. package/src/compile/producer-fingerprint.ts +56 -0
  146. package/src/compile/remove-guard.ts +10 -7
  147. package/src/compile/styles.ts +46 -8
  148. package/src/compile/types.ts +16 -2
  149. package/src/compile/view-check.ts +149 -16
  150. package/src/data/access-gate.ts +112 -0
  151. package/src/data/amount-breakdown.ts +9 -2
  152. package/src/data/approval-flow.ts +5 -2
  153. package/src/data/assignment-picker.ts +59 -28
  154. package/src/data/async-result-panel.ts +49 -3
  155. package/src/data/breadcrumbs.ts +3 -2
  156. package/src/data/calendar.ts +8 -3
  157. package/src/data/carousel.ts +10 -6
  158. package/src/data/chart.ts +744 -46
  159. package/src/data/checklist.ts +22 -6
  160. package/src/data/code-view.ts +8 -4
  161. package/src/data/comment-thread.ts +3 -2
  162. package/src/data/confirm-dialog.ts +72 -25
  163. package/src/data/context-menu.ts +3 -3
  164. package/src/data/dock.ts +1 -1
  165. package/src/data/embed.ts +231 -29
  166. package/src/data/field-mapper.ts +7 -4
  167. package/src/data/flow-editor-contract.ts +7 -0
  168. package/src/data/flow-editor.ts +26 -9
  169. package/src/data/flow-node-options.ts +33 -3
  170. package/src/data/footer.ts +2 -0
  171. package/src/data/gantt.ts +192 -27
  172. package/src/data/hero.ts +4 -1
  173. package/src/data/image-viewer.ts +7 -4
  174. package/src/data/index.ts +16 -4
  175. package/src/data/item-list.ts +27 -12
  176. package/src/data/kanban.ts +41 -10
  177. package/src/data/matrix.ts +391 -0
  178. package/src/data/media-grid.ts +6 -1
  179. package/src/data/mega-menu.ts +6 -4
  180. package/src/data/menu-dom.ts +4 -2
  181. package/src/data/menu.ts +60 -16
  182. package/src/data/mockup.ts +5 -1
  183. package/src/data/modal-dialog.ts +146 -26
  184. package/src/data/navbar.ts +8 -6
  185. package/src/data/notice-list.ts +301 -0
  186. package/src/data/notify-renderer.ts +21 -6
  187. package/src/data/object-form.ts +409 -87
  188. package/src/data/outcome-watch.ts +61 -2
  189. package/src/data/pager.ts +19 -8
  190. package/src/data/panel-head.ts +406 -0
  191. package/src/data/permission-matrix.ts +36 -11
  192. package/src/data/permission-tree.ts +52 -23
  193. package/src/data/pricing-table.ts +22 -11
  194. package/src/data/prompt-dialog.ts +165 -0
  195. package/src/data/reaction-bar.ts +6 -4
  196. package/src/data/record-card.ts +40 -7
  197. package/src/data/record-picker.ts +13 -7
  198. package/src/data/resident.ts +8 -0
  199. package/src/data/result-panel.ts +4 -2
  200. package/src/data/rich-text.ts +17 -1
  201. package/src/data/row-editor.ts +77 -24
  202. package/src/data/rule-builder.ts +14 -9
  203. package/src/data/shape-util.ts +27 -12
  204. package/src/data/stat-group.ts +459 -74
  205. package/src/data/static-lazy.ts +5 -0
  206. package/src/data/static-registry.ts +8 -0
  207. package/src/data/steps.ts +8 -3
  208. package/src/data/survey.ts +7 -4
  209. package/src/data/system-switcher.ts +3 -2
  210. package/src/data/text-action-button.ts +17 -0
  211. package/src/data/timeline.ts +17 -6
  212. package/src/data/tour-guide.ts +3 -2
  213. package/src/data/transfer.ts +40 -16
  214. package/src/data/tree-table.ts +65 -37
  215. package/src/data/tree.ts +22 -2
  216. package/src/data/virtual-rows.ts +21 -11
  217. package/src/data/wrapped-candidates.ts +32 -1
  218. package/src/frames/index.ts +1 -0
  219. package/src/frames/list-summary.ts +100 -0
  220. package/src/frames/page-bar.ts +7 -14
  221. package/src/frames/page-status.ts +7 -5
  222. package/src/frames/shared.ts +34 -13
  223. package/src/frames/split-frame/shell.ts +1 -1
  224. package/src/frames/tabs-frame/shell.ts +9 -6
  225. package/src/frames/tabs-frame/wiring.ts +1 -0
  226. package/src/frames/top-main-frame.ts +3 -3
  227. package/src/frames/types.ts +3 -1
  228. package/src/frames/workspace-frame/extras.ts +1 -1
  229. package/src/frames/workspace-frame/shell.ts +4 -4
  230. package/src/frames/workspace-frame/tab-scroll.ts +28 -0
  231. package/src/frames/workspace-frame/view.ts +168 -44
  232. package/src/generated/kit-grammar-runtime.ts +390 -59
  233. package/src/i18n/kit-text.ts +90 -4
  234. package/src/i18n/resolve-text-refs.ts +22 -6
  235. package/src/object-renderer/action-group.ts +139 -0
  236. package/src/object-renderer/action-more.ts +144 -0
  237. package/src/object-renderer/arrange.ts +71 -7
  238. package/src/object-renderer/candidates.ts +4 -0
  239. package/src/object-renderer/collection-parts.ts +264 -62
  240. package/src/object-renderer/collection-table.ts +177 -5
  241. package/src/object-renderer/collection.ts +188 -37
  242. package/src/object-renderer/compile-data.ts +28 -3
  243. package/src/object-renderer/defaults.ts +27 -2
  244. package/src/object-renderer/display-checks.ts +1 -1
  245. package/src/object-renderer/emit-events.ts +43 -9
  246. package/src/object-renderer/emit-object.ts +4 -0
  247. package/src/object-renderer/emit-static.ts +434 -41
  248. package/src/object-renderer/filter-plan.ts +84 -0
  249. package/src/object-renderer/form-detail.ts +1 -2
  250. package/src/object-renderer/form-notify.ts +45 -0
  251. package/src/object-renderer/index.ts +5 -0
  252. package/src/object-renderer/layout-facts.ts +394 -0
  253. package/src/object-renderer/layout-plan.ts +225 -0
  254. package/src/object-renderer/layout-plan.types.ts +59 -0
  255. package/src/object-renderer/parts.ts +6 -7
  256. package/src/object-renderer/render-object.ts +107 -46
  257. package/src/object-renderer/request-actions.ts +4 -2
  258. package/src/object-renderer/skeleton.ts +58 -19
  259. package/src/object-renderer/table-actions.ts +172 -32
  260. package/src/object-renderer/table-gap.ts +37 -0
  261. package/src/object-renderer/table-tools.ts +62 -30
  262. package/src/object-renderer/types.ts +84 -13
  263. package/src/object-renderer/view-binding.ts +205 -8
  264. package/src/page-target/intent-schema.ts +11 -0
  265. package/src/page-target/target.ts +5 -1
  266. package/src/recipes/container.ts +77 -1
  267. package/src/recipes/control.ts +76 -116
  268. package/src/recipes/emphasis.ts +56 -0
  269. package/src/recipes/frame-bleed.ts +33 -0
  270. package/src/recipes/index.ts +72 -0
  271. package/src/recipes/nowrap.ts +16 -0
  272. package/src/recipes/overlay.ts +120 -17
  273. package/src/recipes/placeholder.ts +95 -0
  274. package/src/recipes/rail-grid.ts +48 -0
  275. package/src/recipes/slot-align.ts +56 -0
  276. package/src/recipes/stat-state.ts +65 -0
  277. package/src/recipes/state.ts +40 -21
  278. package/src/recipes/status.ts +147 -0
  279. package/src/recipes/surface-edge.ts +16 -0
  280. package/src/recipes/surface.ts +40 -0
  281. package/src/recipes/table-gap.ts +80 -0
  282. package/src/recipes/table-native-edit.ts +242 -0
  283. package/src/recipes/table-row.ts +146 -3
  284. package/src/recipes/tabs.ts +49 -0
  285. package/src/recipes/title-row.ts +37 -0
  286. package/src/recipes/typography.ts +30 -37
  287. package/src/shared/confirm-decl.ts +118 -0
  288. package/src/shared/envelope.ts +2 -2
  289. package/src/shared/paged-list-adapter.ts +15 -240
  290. package/src/shared/theme-runtime-shared.ts +6 -1
  291. package/src/theme/index.ts +1 -0
  292. package/src/theme/kit-theme-text.ts +1 -1
  293. package/src/theme/kit-theme.css +384 -13
  294. package/src/theme/kit-theme.tpl +384 -13
  295. package/src/theme/nine-dim-structure.ts +244 -7
  296. package/src/theme/surface-layers.ts +10 -1
  297. package/src/theme/theme-tokens.ts +63 -16
  298. package/src/theme/theme-types.ts +32 -0
  299. package/src/theme/typography.ts +21 -17
  300. package/src/biz/shared/remove-key.ts +0 -6
@@ -211,9 +211,7 @@
211
211
  "groupsAs": {
212
212
  "type": "object",
213
213
  "required": [
214
- "values",
215
- "barClass",
216
- "tabClass"
214
+ "values"
217
215
  ]
218
216
  },
219
217
  "fieldValue": {
@@ -534,9 +532,6 @@
534
532
  "batchActionKeys": {
535
533
  "$ref": "#/$defs/strings"
536
534
  },
537
- "batchConfirmCount": {
538
- "type": "string"
539
- },
540
535
  "selectScopes": {
541
536
  "$ref": "#/$defs/strings"
542
537
  },
@@ -1416,6 +1411,17 @@
1416
1411
  "actionKeys": {
1417
1412
  "$ref": "#/$defs/strings"
1418
1413
  },
1414
+ "actionConfirm": {
1415
+ "type": "object",
1416
+ "properties": {
1417
+ "note": {
1418
+ "type": "string"
1419
+ },
1420
+ "keys": {
1421
+ "$ref": "#/$defs/strings"
1422
+ }
1423
+ }
1424
+ },
1419
1425
  "actionBuiltins": {
1420
1426
  "type": "object",
1421
1427
  "properties": {
@@ -3,6 +3,7 @@
3
3
  import type { KitDiagnostic } from '../object-renderer/types';
4
4
  import { checkNoRelativeOrSystemPath } from '../shared/path-guard';
5
5
  import { parseKitEnvelope, type KitEnvelope } from './envelope';
6
+ import { KIT_LAYOUT_VERSIONS, normalizeLayoutPin } from '../object-renderer/layout-plan';
6
7
 
7
8
  export type {
8
9
  KitThemePalette,
@@ -14,6 +15,11 @@ export type {
14
15
  KitThemeShape,
15
16
  KitThemeSurfaceTexture,
16
17
  KitThemeDensity,
18
+ KitThemeMotion,
19
+ KitThemeTableStyle,
20
+ KitThemeContrast,
21
+ KitThemeAccentUsage,
22
+ KitThemePreset,
17
23
  KitAppTheme,
18
24
  } from '../theme/theme-types';
19
25
  export {
@@ -26,6 +32,11 @@ export {
26
32
  KIT_THEME_SHAPES,
27
33
  KIT_THEME_SURFACE_TEXTURES,
28
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,
29
40
  } from '../theme/theme-types';
30
41
  import {
31
42
  KIT_THEME_PALETTES,
@@ -37,6 +48,16 @@ import {
37
48
  KIT_THEME_SHAPES,
38
49
  KIT_THEME_SURFACE_TEXTURES,
39
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,
40
61
  type KitThemePalette,
41
62
  type KitThemeColorDepth,
42
63
  type KitThemeColorSaturation,
@@ -61,8 +82,10 @@ export interface KitAppLayoutNavItem {
61
82
 
62
83
  export interface KitAppLayout {
63
84
  frame?: string;
64
- maxWidth?: 'narrow' | 'medium' | 'wide' | 'full';
85
+ maxWidth?: 'narrow' | 'medium' | 'wide' | 'xwide' | 'full';
65
86
  stickyHeader?: boolean;
87
+ /** 默认内容区通栏(页面级 `frame.bleed` 覆盖);只继承给不自管整页布局的页面框 */
88
+ bleed?: boolean;
66
89
  header?: {
67
90
  brand?: { text: string; href?: string };
68
91
  nav?: KitAppLayoutNavItem[];
@@ -93,6 +116,8 @@ export interface KitAppConfig {
93
116
  theme?: KitAppTheme;
94
117
  /** 默认页面布局配置:继承给子页面 */
95
118
  layout?: KitAppLayout;
119
+ /** 布局规则版本钉(`layout.rules`,RV-1117):缺省 0 = 现状 12 份均分,输出逐字节不变;只写 rules 不算启用外框继承 */
120
+ layoutRules?: number;
96
121
  /** 主题头文件路径(相对应用根);缺省用内置 kit-theme.css */
97
122
  style?: string;
98
123
  /** 应用扩展的基础组件:名字 -> 说明 */
@@ -127,6 +152,13 @@ const THEME_KEYS = [
127
152
  'surface_texture',
128
153
  'surfaceTexture',
129
154
  'density',
155
+ 'motion',
156
+ 'table_style',
157
+ 'tableStyle',
158
+ 'contrast',
159
+ 'accent_usage',
160
+ 'accentUsage',
161
+ 'preset',
130
162
  'mode',
131
163
  ];
132
164
  /**
@@ -141,7 +173,6 @@ export const REMOVED_THEME_KEYS: Readonly<Record<string, string>> = {
141
173
  color: '品牌色号不再支持:改用九维 palette 选一套人工精调配色,配合 color_depth / color_saturation 调深浅与饱和度',
142
174
  polarity: '改用 mode(light / dark / soft / system)',
143
175
  radius: '改用九维 shape',
144
- preset: '改用九维 palette 配合 color_depth / color_saturation',
145
176
  color_scheme: '改用九维 palette 配合 color_depth / color_saturation',
146
177
  colorScheme: '改用九维 palette 配合 color_depth / color_saturation',
147
178
  tone: '改用九维 palette 配合 color_depth / color_saturation',
@@ -151,6 +182,13 @@ export const REMOVED_THEME_KEYS: Readonly<Record<string, string>> = {
151
182
  componentStyle: '改用九维 boundary 与 surface_texture',
152
183
  };
153
184
 
185
+ /**
186
+ * 已删除的主题取值(维度 -> 旧值 -> 迁移指引):取值域校验命中时给出清晰的迁移诊断,不留兼容别名。
187
+ */
188
+ export const REMOVED_THEME_VALUES: Readonly<Record<string, Readonly<Record<string, string>>>> = {
189
+ surface_texture: { FROSTED_CHROME: '已合并为 GLASS_CHROME(顶栏与悬浮层毛玻璃,带不透明回退),请改写 GLASS_CHROME' },
190
+ };
191
+
154
192
  /**
155
193
  * 校验主题对象中的已删除旧键(palette_scheme/paletteScheme/font_scheme/fontScheme/color 等),
156
194
  * 命中即推入 KIT-APP-002 迁移诊断。
@@ -169,15 +207,15 @@ export function checkRemovedThemeKeys(
169
207
  diagnostics.push({
170
208
  code: 'KIT-APP-002',
171
209
  path: kp,
172
- message: `theme.${k} 已删除(kit 主题只支持九维 palette / color_depth / color_saturation / font_family / font_scale / boundary / shape / surface_texture / density + mode):${removedHint}`,
210
+ 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}`,
173
211
  });
174
212
  }
175
213
  }
176
214
  return diagnostics;
177
215
  }
178
216
  const STATIC_KEYS = ['accept', 'desc'];
179
- const LAYOUT_TOP_KEYS = ['frame', 'max_width', 'sticky_header', 'header', 'sidebar', 'footer'];
180
- const MAX_WIDTH_VALUES = ['narrow', 'medium', 'wide', 'full'] as const;
217
+ const LAYOUT_TOP_KEYS = ['frame', 'max_width', 'sticky_header', 'bleed', 'header', 'sidebar', 'footer', 'rules'];
218
+ const MAX_WIDTH_VALUES = ['narrow', 'medium', 'wide', 'xwide', 'full'] as const;
181
219
  const LAYOUT_HEADER_KEYS = ['brand', 'nav', 'actions'];
182
220
  const LAYOUT_SIDEBAR_KEYS = ['title', 'width', 'menu'];
183
221
  const LAYOUT_FOOTER_KEYS = ['text', 'links'];
@@ -373,7 +411,8 @@ export function parseAppConfig(raw: unknown, diagnostics: KitDiagnostic[]): KitA
373
411
  }
374
412
  } else if (k === 'surface_texture' || k === 'surfaceTexture') {
375
413
  if (!(KIT_THEME_SURFACE_TEXTURES as readonly string[]).includes(val)) {
376
- bad(kp, `${k}「${val}」只能是 ${KIT_THEME_SURFACE_TEXTURES.join(' / ')}`, diagnostics);
414
+ const removed = Object.hasOwn(REMOVED_THEME_VALUES.surface_texture, val) ? REMOVED_THEME_VALUES.surface_texture[val] : undefined;
415
+ bad(kp, `${k}「${val}」${removed !== undefined ? `已删除:${removed};` : ''}只能是 ${KIT_THEME_SURFACE_TEXTURES.join(' / ')}`, diagnostics);
377
416
  } else {
378
417
  theme.surface_texture = val as KitThemeSurfaceTexture;
379
418
  theme.surfaceTexture = val as KitThemeSurfaceTexture;
@@ -384,6 +423,39 @@ export function parseAppConfig(raw: unknown, diagnostics: KitDiagnostic[]): KitA
384
423
  } else {
385
424
  theme.density = val as KitThemeDensity;
386
425
  }
426
+ } else if (k === 'motion') {
427
+ if (!(KIT_THEME_MOTIONS as readonly string[]).includes(val)) {
428
+ bad(kp, `motion「${val}」只能是 ${KIT_THEME_MOTIONS.join(' / ')}`, diagnostics);
429
+ } else {
430
+ theme.motion = val as KitThemeMotion;
431
+ }
432
+ } else if (k === 'table_style' || k === 'tableStyle') {
433
+ if (!(KIT_THEME_TABLE_STYLES as readonly string[]).includes(val)) {
434
+ bad(kp, `${k}「${val}」只能是 ${KIT_THEME_TABLE_STYLES.join(' / ')}`, diagnostics);
435
+ } else {
436
+ theme.table_style = val as KitThemeTableStyle;
437
+ theme.tableStyle = val as KitThemeTableStyle;
438
+ }
439
+ } else if (k === 'contrast') {
440
+ if (!(KIT_THEME_CONTRASTS as readonly string[]).includes(val)) {
441
+ bad(kp, `contrast「${val}」只能是 ${KIT_THEME_CONTRASTS.join(' / ')}`, diagnostics);
442
+ } else {
443
+ theme.contrast = val as KitThemeContrast;
444
+ }
445
+ } else if (k === 'accent_usage' || k === 'accentUsage') {
446
+ if (!(KIT_THEME_ACCENT_USAGES as readonly string[]).includes(val)) {
447
+ bad(kp, `${k}「${val}」只能是 ${KIT_THEME_ACCENT_USAGES.join(' / ')}`, diagnostics);
448
+ } else {
449
+ theme.accent_usage = val as KitThemeAccentUsage;
450
+ theme.accentUsage = val as KitThemeAccentUsage;
451
+ }
452
+ } else if (k === 'preset') {
453
+ // 未知预设名按主题取值域错误报 KIT-APP-002(与求解端 solveKitTheme 同码同路径),不写入 cfg.theme
454
+ if (!(KIT_THEME_PRESETS as readonly string[]).includes(val)) {
455
+ diagnostics.push({ code: 'KIT-APP-002', path: kp, message: `preset「${val}」不是已知主题预设,只能是 ${KIT_THEME_PRESETS.join(' / ')}` });
456
+ } else {
457
+ theme.preset = val as KitThemePreset;
458
+ }
387
459
  } else if (k === 'mode') {
388
460
  if (!(KIT_THEME_MODES as readonly string[]).includes(val)) {
389
461
  bad(kp, `mode「${val}」只能是 ${KIT_THEME_MODES.join(' / ')}`, diagnostics);
@@ -405,6 +477,13 @@ export function parseAppConfig(raw: unknown, diagnostics: KitDiagnostic[]): KitA
405
477
  if (!LAYOUT_TOP_KEYS.includes(k)) bad(layoutKeyPath(k), `未知键 ${k}(允许:${LAYOUT_TOP_KEYS.join(' / ')})`, diagnostics);
406
478
  }
407
479
  const layout: KitAppLayout = {};
480
+ // 布局规则版本钉(RV-1117 T09):缺省 0 = 现状,输出逐字节不变;新应用 / AI 页钉最新版。
481
+ // 它不是「外框继承」配置,不进 cfg.layout(否则只写 rules 的应用会被当成启用了继承外框而多包一层)
482
+ if (rawLayout.rules !== undefined) {
483
+ const pin = typeof rawLayout.rules === 'number' ? normalizeLayoutPin(rawLayout.rules) : undefined;
484
+ if (pin === undefined) bad(layoutKeyPath('rules'), `rules 必须是已存在的布局规则版本号(整数,${KIT_LAYOUT_VERSIONS.join(' / ')};缺省 0 = 现状)`, diagnostics);
485
+ else cfg.layoutRules = pin;
486
+ }
408
487
  if (rawLayout.frame !== undefined) {
409
488
  if (typeof rawLayout.frame === 'string' && rawLayout.frame.trim() !== '') layout.frame = rawLayout.frame.trim();
410
489
  else bad(layoutKeyPath('frame'), 'frame 必须是非空字符串', diagnostics);
@@ -412,12 +491,16 @@ export function parseAppConfig(raw: unknown, diagnostics: KitDiagnostic[]): KitA
412
491
  if (rawLayout.max_width !== undefined) {
413
492
  const mw = typeof rawLayout.max_width === 'string' ? rawLayout.max_width.trim() : '';
414
493
  if (!(MAX_WIDTH_VALUES as readonly string[]).includes(mw)) bad(layoutKeyPath('max_width'), `max_width「${String(rawLayout.max_width)}」只能是 ${MAX_WIDTH_VALUES.join(' / ')}`, diagnostics);
415
- else layout.maxWidth = mw as 'narrow' | 'medium' | 'wide' | 'full';
494
+ else layout.maxWidth = mw as KitAppLayout['maxWidth'];
416
495
  }
417
496
  if (rawLayout.sticky_header !== undefined) {
418
497
  if (typeof rawLayout.sticky_header === 'boolean') layout.stickyHeader = rawLayout.sticky_header;
419
498
  else bad(layoutKeyPath('sticky_header'), 'sticky_header 必须是布尔值', diagnostics);
420
499
  }
500
+ if (rawLayout.bleed !== undefined) {
501
+ if (typeof rawLayout.bleed === 'boolean') layout.bleed = rawLayout.bleed;
502
+ else bad(layoutKeyPath('bleed'), 'bleed 必须是布尔值', diagnostics);
503
+ }
421
504
  if (rawLayout.header !== undefined) {
422
505
  const hp = layoutKeyPath('header');
423
506
  if (!isRecord(rawLayout.header)) {
@@ -554,7 +637,8 @@ export function parseAppConfig(raw: unknown, diagnostics: KitDiagnostic[]): KitA
554
637
  layout.footer = footer;
555
638
  }
556
639
  }
557
- cfg.layout = layout;
640
+ // 只写了 rules 的 layout 块不是外框继承配置(见上),不进 cfg.layout,存量应用输出不变
641
+ if (!(Object.keys(rawLayout).length === 1 && rawLayout.rules !== undefined)) cfg.layout = layout;
558
642
  }
559
643
  }
560
644
  if (raw.baseComponents !== undefined) {
@@ -4,10 +4,11 @@
4
4
  // 1) KIT-APP-004:所有登记进 baseComponents / staticObjectComponents 的 App* 组件,必须经
5
5
  // wrapKitDataComponent、composeKitDataComponents 或 declareKitUses 显式登记依赖组件与候选类元数据;
6
6
  // 声明的 uses 必须是真实存在的内置组件名,own 候选类必须通过 checkClasses 校验(禁方括号任意值)。
7
- // 2) KIT-APP-005:严禁应用组件在 templateHtml、控制器或 components/ 辅助模块中私自拼写已被 soma-kit
7
+ // 2) KIT-APP-005:严禁应用组件在 templateHtml、控制器或源码中私自拼写已被 soma-kit
8
8
  // 标准组件接管的原生表单控件(原生 <select>、原生 <input type="range">、原生 <input type="date|datetime-local|time|month|week">),
9
- // 也严禁在 templateHtml 中书写内联 style 属性。下拉一律走 Select / Combobox / mountKitSelectField,
10
- // 滑块一律走 Range,日期时间一律走 Date / DateRange / TimePicker。
9
+ // 严禁在 TS/HTML 中书写内联 style / 操作 .style / setAttribute('style', ...),
10
+ // 也严禁在非组件 TS(views/actions/api/soma.app.ts 等)中操作 .className / .classList 或手绑 addEventListener 等 DOM 事件。
11
+ // 下拉一律走 Select / Combobox / mountKitSelectField,滑块一律走 Range,日期时间一律走 Date / DateRange / TimePicker。
11
12
 
12
13
  import type { SomaComponentDefinition } from 'soma-core';
13
14
  import { KIT_BASE_COMPONENTS } from '../base/index';
@@ -46,6 +47,13 @@ interface ForbiddenRule {
46
47
  readonly message: string;
47
48
  }
48
49
 
50
+ const MSG_STYLE_PROP = '禁止在 TS 中操作 .style 修改内联样式;要么在组件模板写好标准类,要么通过 DSL 传入或使用 data-* 状态属性 / SVG 几何属性';
51
+ const MSG_SET_ATTR_STYLE = '禁止调用 setAttribute("style", ...) 注入内联样式;请统一使用 Tailwind 候选类与 --soma-* 设计令牌';
52
+ const MSG_INLINE_STYLE_HTML = '禁止在模板或 HTML 片段中使用内联 style="..." 属性;请统一使用 Tailwind 候选类与 --soma-* 设计令牌';
53
+ const MSG_INLINE_ON_EVENT = '禁止使用内联 on* 事件或 .on* = 赋值;业务交互请预埋到组件事件槽位并通过 DSL 绑定';
54
+ const MSG_NON_COMP_CLASS = '业务与展示对象 TS(非 components/)禁止直接操作 DOM 样式类(.className / .classList);样式要么在组件模板写好,要么由 *.kit.yaml DSL 传入';
55
+ const MSG_NON_COMP_EVENT = '业务与展示对象 TS(非 components/)禁止直接调用 addEventListener 手绑 DOM 事件;动态事件应预埋在业务组件槽位中,由 *.kit.yaml 的 behavior.actions / view.on 传入并路由至展示对象方法';
56
+
49
57
  const FORBIDDEN_DOM_PATTERNS: readonly ForbiddenRule[] = [
50
58
  {
51
59
  id: 'raw-style-tag',
@@ -57,6 +65,31 @@ const FORBIDDEN_DOM_PATTERNS: readonly ForbiddenRule[] = [
57
65
  pattern: /createElement\s*\(\s*['"`]style['"`]\s*\)/,
58
66
  message: '禁止调用 createElement("style") 动态注入样式表;请统一使用 Tailwind 候选类与 --soma-* 设计令牌',
59
67
  },
68
+ {
69
+ id: 'inline-style-html',
70
+ pattern: /<[a-zA-Z][^>]*\sstyle\s*=\s*['"]/i,
71
+ message: MSG_INLINE_STYLE_HTML,
72
+ },
73
+ {
74
+ id: 'inline-on-event-html',
75
+ pattern: /<[a-zA-Z][^>]*\son(?:click|change|input|keydown|keyup|submit|focus|blur|mousedown|mouseup|pointerdown|pointerup)\s*=\s*['"]/i,
76
+ message: MSG_INLINE_ON_EVENT,
77
+ },
78
+ {
79
+ id: 'dom-style-prop',
80
+ pattern: /\.\s*style\s*(?:\.\s*[a-zA-Z_$][\w$]*|\[\s*['"`][^'"`]+['"`]\s*\])/,
81
+ message: MSG_STYLE_PROP,
82
+ },
83
+ {
84
+ id: 'dom-set-attribute-style',
85
+ pattern: /\.\s*setAttribute(?:NS)?\s*\([^)]*['"`]style['"`]/,
86
+ message: MSG_SET_ATTR_STYLE,
87
+ },
88
+ {
89
+ id: 'dom-on-event-assign',
90
+ pattern: /\.\s*on(?:click|change|input|keydown|keyup|submit|focus|blur|mousedown|mouseup|pointerdown|pointerup)\s*=(?!=)/,
91
+ message: MSG_INLINE_ON_EVENT,
92
+ },
60
93
  {
61
94
  id: 'native-select-tag',
62
95
  pattern: /<\s*select(?=[\s>/])/i,
@@ -151,17 +184,243 @@ export function assertSinglePathComponent(name: string, def: SomaComponentDefini
151
184
  }
152
185
  }
153
186
 
187
+ const SKIP_SCAN_DIRS = new Set([
188
+ 'node_modules',
189
+ 'dist',
190
+ 'build',
191
+ 'coverage',
192
+ 'tests',
193
+ 'test',
194
+ 'scripts',
195
+ '.soma',
196
+ ]);
197
+
198
+ const DOM_INLINE_ON_EVENTS = new Set([
199
+ 'onclick',
200
+ 'onchange',
201
+ 'oninput',
202
+ 'onkeydown',
203
+ 'onkeyup',
204
+ 'onsubmit',
205
+ 'onfocus',
206
+ 'onblur',
207
+ 'onmousedown',
208
+ 'onmouseup',
209
+ 'onpointerdown',
210
+ 'onpointerup',
211
+ ]);
212
+
213
+ const HTML_TAG_FORBIDDEN_RULES: readonly ForbiddenRule[] = [
214
+ {
215
+ id: 'raw-style-tag',
216
+ pattern: /<\s*style(?=[\s>/])/i,
217
+ message: '禁止在模板或控制器中手写 <style> 标签注入全局样式;请统一使用 Tailwind 候选类与 --soma-* 设计令牌',
218
+ },
219
+ {
220
+ id: 'native-select-tag',
221
+ pattern: /<\s*select(?=[\s>/])/i,
222
+ message: '禁止手写原生 <select> 标签;请改用 soma-kit 标准组件 Select / Combobox(命令式嵌入用 mountKitSelectField)',
223
+ },
224
+ {
225
+ id: 'native-range-tag',
226
+ pattern: /<\s*input\b[^>]*\btype\s*=\s*['"]range['"]/i,
227
+ message: '禁止手写原生 <input type="range"> 滑块;请改用 soma-kit 标准组件 Range(自绘无障碍 SVG 滑块)',
228
+ },
229
+ {
230
+ id: 'native-date-tag',
231
+ pattern: /<\s*input\b[^>]*\btype\s*=\s*['"](?:date|datetime-local|time|month|week)['"]/i,
232
+ message: '禁止手写原生日期/时间 <input>;请改用 soma-kit 标准组件 Date / DateRange / TimePicker',
233
+ },
234
+ ];
235
+
236
+ const HTML_INLINE_ATTR_RULES: readonly ForbiddenRule[] = [
237
+ {
238
+ id: 'inline-style-html',
239
+ pattern: /<[a-zA-Z][^>]*\sstyle\s*=\s*['"]/i,
240
+ message: MSG_INLINE_STYLE_HTML,
241
+ },
242
+ {
243
+ id: 'inline-on-event-html',
244
+ pattern: /<[a-zA-Z][^>]*\son(?:click|change|input|keydown|keyup|submit|focus|blur|mousedown|mouseup|pointerdown|pointerup)\s*=\s*['"]/i,
245
+ message: MSG_INLINE_ON_EVENT,
246
+ },
247
+ ];
248
+
249
+ type TsModule = typeof import('typescript');
250
+
251
+ function scriptKindForFile(ts: TsModule, fileName: string): import('typescript').ScriptKind {
252
+ if (fileName.endsWith('.tsx')) return ts.ScriptKind.TSX;
253
+ if (fileName.endsWith('.jsx')) return ts.ScriptKind.JSX;
254
+ if (fileName.endsWith('.js') || fileName.endsWith('.mjs') || fileName.endsWith('.cjs')) return ts.ScriptKind.JS;
255
+ return ts.ScriptKind.TS;
256
+ }
257
+
258
+ function extractStaticHtmlText(ts: TsModule, node: import('typescript').Expression): string {
259
+ if (ts.isParenthesizedExpression(node) || ts.isAsExpression(node) || ts.isTypeAssertionExpression(node)) {
260
+ return extractStaticHtmlText(ts, node.expression);
261
+ }
262
+ if (ts.isStringLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node)) {
263
+ return node.text;
264
+ }
265
+ if (ts.isTemplateExpression(node)) {
266
+ return [node.head.text, ...node.templateSpans.map((span) => span.literal.text)].join(' ');
267
+ }
268
+ if (ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.PlusToken) {
269
+ return extractStaticHtmlText(ts, node.left) + extractStaticHtmlText(ts, node.right);
270
+ }
271
+ return '';
272
+ }
273
+
274
+ function propertyAccessName(ts: TsModule, node: import('typescript').Expression): string | undefined {
275
+ if (ts.isPropertyAccessExpression(node)) return node.name.text;
276
+ if (ts.isElementAccessExpression(node) && ts.isStringLiteralLike(node.argumentExpression)) {
277
+ return node.argumentExpression.text;
278
+ }
279
+ return undefined;
280
+ }
281
+
282
+ function scanSourceWithAst(
283
+ ts: TsModule,
284
+ fullPath: string,
285
+ code: string,
286
+ inComponentsDir: boolean,
287
+ ): Array<{ line: number; message: string }> {
288
+ const sourceFile = ts.createSourceFile(fullPath, code, ts.ScriptTarget.Latest, true, scriptKindForFile(ts, fullPath));
289
+ const hits: Array<{ line: number; message: string }> = [];
290
+ const seen = new Set<string>();
291
+
292
+ const pushHit = (node: import('typescript').Node, message: string): void => {
293
+ const line = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).line + 1;
294
+ const key = `${line}:${message}`;
295
+ if (seen.has(key)) return;
296
+ seen.add(key);
297
+ hits.push({ line, message });
298
+ };
299
+
300
+ const checkHtmlString = (node: import('typescript').Node, html: string, includeInlineAttrs: boolean): void => {
301
+ if (!html) return;
302
+ if (includeInlineAttrs) {
303
+ for (const rule of HTML_INLINE_ATTR_RULES) {
304
+ if (rule.pattern.test(html)) pushHit(node, rule.message);
305
+ }
306
+ }
307
+ for (const rule of HTML_TAG_FORBIDDEN_RULES) {
308
+ if (rule.pattern.test(html)) pushHit(node, rule.message);
309
+ }
310
+ };
311
+
312
+ const visit = (node: import('typescript').Node, insideFunction: boolean): void => {
313
+ if (ts.isTypeNode(node) || ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) {
314
+ return;
315
+ }
316
+
317
+ // 1. AST .style / ['style'] 访问(全应用禁止)
318
+ if (
319
+ (ts.isPropertyAccessExpression(node) && node.name.text === 'style')
320
+ || (ts.isElementAccessExpression(node) && ts.isStringLiteralLike(node.argumentExpression) && node.argumentExpression.text === 'style')
321
+ ) {
322
+ pushHit(node, MSG_STYLE_PROP);
323
+ }
324
+
325
+ // 2. AST 非组件目录禁止操作 .className / .classList
326
+ if (!inComponentsDir) {
327
+ const propName = ts.isPropertyAccessExpression(node)
328
+ ? node.name.text
329
+ : (ts.isElementAccessExpression(node) && ts.isStringLiteralLike(node.argumentExpression) ? node.argumentExpression.text : undefined);
330
+ if (propName === 'className' || propName === 'classList') {
331
+ pushHit(node, MSG_NON_COMP_CLASS);
332
+ }
333
+ }
334
+
335
+ // 3. AST 函数调用检查
336
+ if (ts.isCallExpression(node)) {
337
+ const calleeName = ts.isIdentifier(node.expression)
338
+ ? node.expression.text
339
+ : (ts.isPropertyAccessExpression(node.expression) ? node.expression.name.text : undefined);
340
+
341
+ if (calleeName === 'setAttribute' && node.arguments.length >= 1 && ts.isStringLiteralLike(node.arguments[0])) {
342
+ const attr = node.arguments[0].text.toLowerCase();
343
+ if (attr === 'style') pushHit(node, MSG_SET_ATTR_STYLE);
344
+ if (!inComponentsDir && attr === 'class') pushHit(node, MSG_NON_COMP_CLASS);
345
+ } else if (calleeName === 'setAttributeNS' && node.arguments.length >= 2 && ts.isStringLiteralLike(node.arguments[1])) {
346
+ const attr = node.arguments[1].text.toLowerCase();
347
+ if (attr === 'style') pushHit(node, MSG_SET_ATTR_STYLE);
348
+ if (!inComponentsDir && attr === 'class') pushHit(node, MSG_NON_COMP_CLASS);
349
+ } else if (calleeName === 'createElement' && node.arguments.length >= 1 && ts.isStringLiteralLike(node.arguments[0])) {
350
+ const tag = node.arguments[0].text.toLowerCase();
351
+ if (tag === 'style') {
352
+ pushHit(node, '禁止调用 createElement("style") 动态注入样式表;请统一使用 Tailwind 候选类与 --soma-* 设计令牌');
353
+ } else if (tag === 'select') {
354
+ pushHit(node, '禁止调用 createElement("select") 创建原生下拉框;请改用 mountKitSelectField 或 Select 组件');
355
+ }
356
+ } else if (calleeName === 'insertAdjacentHTML' && node.arguments.length >= 2) {
357
+ checkHtmlString(node.arguments[1]!, extractStaticHtmlText(ts, node.arguments[1]!), true);
358
+ } else if (!inComponentsDir && (calleeName === 'addEventListener' || calleeName === 'removeEventListener' || calleeName === 'dispatchEvent')) {
359
+ pushHit(node, MSG_NON_COMP_EVENT);
360
+ } else if (!inComponentsDir && calleeName === 'insertRule') {
361
+ pushHit(node, MSG_NON_COMP_CLASS);
362
+ }
363
+ }
364
+
365
+ // 4. AST new CSSStyleSheet()(非组件目录禁止)
366
+ if (!inComponentsDir && ts.isNewExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === 'CSSStyleSheet') {
367
+ pushHit(node, MSG_NON_COMP_CLASS);
368
+ }
369
+
370
+ // 5. AST 赋值表达式检查(innerHTML / outerHTML / .on* = / .type = 'range'|'date')
371
+ if (ts.isBinaryExpression(node) && (node.operatorToken.kind === ts.SyntaxKind.EqualsToken || node.operatorToken.kind === ts.SyntaxKind.PlusEqualsToken)) {
372
+ const leftName = propertyAccessName(ts, node.left);
373
+ if (leftName === 'innerHTML' || leftName === 'outerHTML') {
374
+ checkHtmlString(node.right, extractStaticHtmlText(ts, node.right), true);
375
+ } else if (node.operatorToken.kind === ts.SyntaxKind.EqualsToken && leftName !== undefined) {
376
+ if (DOM_INLINE_ON_EVENTS.has(leftName)) {
377
+ pushHit(node, MSG_INLINE_ON_EVENT);
378
+ } else if (leftName === 'type' && ts.isStringLiteralLike(node.right)) {
379
+ const val = node.right.text.toLowerCase();
380
+ if (val === 'range') {
381
+ pushHit(node, '禁止设置 input.type = "range" 创建原生滑块;请改用 soma-kit 标准组件 Range');
382
+ } else if (/^(?:date|datetime-local|time|month|week)$/.test(val)) {
383
+ pushHit(node, '禁止设置原生日期/时间 input.type;请改用 soma-kit 标准组件 Date / DateRange / TimePicker');
384
+ }
385
+ }
386
+ }
387
+ }
388
+
389
+ // 6. AST 对象字面量 templateHtml 属性检查
390
+ if (ts.isPropertyAssignment(node)) {
391
+ const propName = ts.isIdentifier(node.name) || ts.isStringLiteral(node.name) ? node.name.text : undefined;
392
+ if (propName === 'templateHtml') {
393
+ checkHtmlString(node.initializer, extractStaticHtmlText(ts, node.initializer), true);
394
+ }
395
+ }
396
+
397
+ // 7. 函数体内的字符串/模板字面量中的原生控件标签(如 renderSneaky 返回 `<select>...`),不误伤顶层纯数据字典
398
+ if (insideFunction && (ts.isStringLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node) || ts.isTemplateExpression(node))) {
399
+ checkHtmlString(node, extractStaticHtmlText(ts, node), false);
400
+ }
401
+
402
+ const nextInsideFunction = insideFunction || ts.isFunctionLike(node);
403
+ ts.forEachChild(node, (child) => visit(child, nextInsideFunction));
404
+ };
405
+
406
+ visit(sourceFile, false);
407
+ return hits;
408
+ }
409
+
154
410
  /**
155
- * 服务端编译与 `soma kit check` 全量源码门禁:
156
- * 递归扫描应用 `<root>/components` 目录下的全部实现文件(`.ts` / `.js` / `.mjs`),
157
- * 防止把非标原生控件拆分到辅助渲染子模块绕过单组件检查。
411
+ * 服务端编译与 `soma kit check` 全量源码 AST 门禁:
412
+ * 递归扫描应用根目录 `<root>` 下全部 `.ts` / `.tsx` / `.js` / `.mjs` 源码(跳过 `node_modules` / `dist` / `tests` / `.soma` 等),
413
+ * 1) 全应用禁止:非标原生控件、<style>、AST `.style` 访问、`setAttribute('style', ...)`、`innerHTML`/`outerHTML`/`templateHtml` 内联 `style="..."` 或 `on*`、`.onclick =` 等赋值;
414
+ * 2) 非 `components/` 目录(如 `views/**`、`actions/**`、`api/**`、`soma.app.ts`)额外禁止:操作 `.className` / `.classList` / `setAttribute('class', ...)` / `CSSStyleSheet` 与手绑 `addEventListener`。
158
415
  */
159
416
  export async function scanAppComponentSources(root: string): Promise<KitDiagnostic[]> {
160
417
  const fsSpec = 'node:fs/promises';
161
418
  const pathSpec = 'node:path';
419
+ const tsSpec = 'typescript';
162
420
  const fs = await import(fsSpec);
163
421
  const path = await import(pathSpec);
164
- const compDir = path.join(root, 'components');
422
+ const tsMod = await import(tsSpec);
423
+ const ts = (tsMod.default ?? tsMod) as TsModule;
165
424
  const diagnostics: KitDiagnostic[] = [];
166
425
 
167
426
  async function walk(dir: string): Promise<void> {
@@ -176,16 +435,15 @@ export async function scanAppComponentSources(root: string): Promise<KitDiagnost
176
435
  for (const entry of entries) {
177
436
  const full = path.join(dir, entry.name);
178
437
  if (entry.isDirectory()) {
179
- if (entry.name === 'node_modules' || entry.name.startsWith('.')) continue;
438
+ if (SKIP_SCAN_DIRS.has(entry.name) || entry.name.startsWith('.')) continue;
180
439
  await walk(full);
181
440
  continue;
182
441
  }
183
- if (!/\.(?:ts|js|mjs)$/.test(entry.name) || entry.name.endsWith('.d.ts')) continue;
442
+ if (!/\.(?:ts|tsx|js|mjs)$/.test(entry.name) || entry.name.endsWith('.d.ts')) continue;
184
443
  const code = await fs.readFile(full, 'utf8');
185
- // 仅对含可执行函数或模板字面量的组件/渲染模块扫描,跳过纯 JSON 常量数据字典
186
- if (!code.includes('`') && !/\bfunction\b|=>|createElement/.test(code)) continue;
187
444
  const rel = path.relative(root, full).split(path.sep).join('/');
188
- for (const hit of findForbiddenNativeControls(code)) {
445
+ const inComponentsDir = rel === 'components' || rel.startsWith('components/');
446
+ for (const hit of scanSourceWithAst(ts, full, code, inComponentsDir)) {
189
447
  diagnostics.push({
190
448
  code: 'KIT-APP-005',
191
449
  path: `${rel}:${hit.line}`,
@@ -195,6 +453,6 @@ export async function scanAppComponentSources(root: string): Promise<KitDiagnost
195
453
  }
196
454
  }
197
455
 
198
- await walk(compDir);
456
+ await walk(root);
199
457
  return diagnostics;
200
458
  }
@@ -12,7 +12,7 @@ import {
12
12
  SomaMiddlewareChain,
13
13
  type SomaRenderPorts,
14
14
  } from 'soma-core';
15
- import { createKitNotifyRenderer } from './notify-renderer';
15
+ import { createKitRenderPorts } from './render-ports';
16
16
  import type { SomaHostAssembly } from 'soma-core/server/host-assembly';
17
17
  import { createKitBaseComponents, KIT_BASE_COMPONENTS } from '../base/index';
18
18
  import { bizDataComponents, KIT_BIZ_DATA_COMPONENTS } from '../biz/data-components';
@@ -501,7 +501,7 @@ export function defineKitApp(options: DefineKitAppOptions = {}): KitApp {
501
501
  pageRoots: m.pageRoots,
502
502
  ...(options.auth !== undefined ? { auth: options.auth } : {}),
503
503
  eventMiddleware: eventMiddlewareChain,
504
- renderPorts: (renderPorts ??= options.renderPorts ?? { notify: createKitNotifyRenderer() }),
504
+ renderPorts: (renderPorts ??= createKitRenderPorts(options.renderPorts)),
505
505
  };
506
506
  },
507
507
  services: options.services ?? (() => ({ kind: 'table', routes: {} })),
@@ -39,12 +39,16 @@ export interface KitDraftPayload<V extends Record<string, unknown> = Record<stri
39
39
  readonly values: V;
40
40
  readonly dirty: boolean;
41
41
  readonly field?: string;
42
- readonly source?: 'input' | 'api' | 'load';
42
+ /** input = 用户输入;api = 展示对象写入;load = 草稿重建 / 详情到达;suggestion = 画布上一条 AI 建议被采纳 / 忽略(见 `suggestion`) */
43
+ readonly source?: 'input' | 'api' | 'load' | 'suggestion';
44
+ /** 画布(FlowEditor)AI 建议被处理:action = accept(建议已并入 values)/ reject(忽略);展示对象据此清掉自己持有的那条建议 */
45
+ readonly suggestion?: { readonly id: string; readonly action: 'accept' | 'reject' };
43
46
  }
44
47
 
45
48
  export interface KitViewDefinition<
46
49
  S extends Record<string, unknown>,
47
- P = KitDraftPayload & Record<string, any>,
50
+ // 方法载荷:草稿钩子(view.form.onDraft)是 KitDraftPayload,动作绑定(submit: view.<方法>)是 { row, … } 等事件载荷;各方法自己标注参数类型
51
+ P = any,
48
52
  > {
49
53
  /** 类名:以 View 结尾,页面 `page.view` 写同一个名字 */
50
54
  readonly name: string;
@@ -79,15 +83,15 @@ export function defineKitView<
79
83
  // 方法与生命周期钩子拿到的是 core ctx,这里统一扩成 kit ctx(多出 form / onRequestDone)
80
84
  const wrapped: Record<string, (view: SomaPageRootBase & SomaState<S>, payload: any, ctx: SomaViewContext) => unknown> = {};
81
85
  for (const [key, fn] of Object.entries(definition.methods ?? {})) {
82
- wrapped[key] = (view, payload, ctx) => fn(view, payload, extendKitViewContext(ctx));
86
+ wrapped[key] = (view, payload, ctx) => fn(view, payload, extendKitViewContext(ctx, definition.name));
83
87
  }
84
88
  const { onMount, onUnmount } = definition;
85
89
  return defineSomaView({
86
90
  name: definition.name,
87
91
  state: definition.state,
88
92
  methods: wrapped,
89
- ...(onMount !== undefined ? { onMount: (view: SomaPageRootBase & SomaState<S>, ctx: SomaViewContext) => onMount(view, extendKitViewContext(ctx)) } : {}),
90
- ...(onUnmount !== undefined ? { onUnmount: (view: SomaPageRootBase & SomaState<S>, ctx: SomaViewContext) => onUnmount(view, extendKitViewContext(ctx)) } : {}),
93
+ ...(onMount !== undefined ? { onMount: (view: SomaPageRootBase & SomaState<S>, ctx: SomaViewContext) => onMount(view, extendKitViewContext(ctx, definition.name)) } : {}),
94
+ ...(onUnmount !== undefined ? { onUnmount: (view: SomaPageRootBase & SomaState<S>, ctx: SomaViewContext) => onUnmount(view, extendKitViewContext(ctx, definition.name)) } : {}),
91
95
  }) as unknown as (new () => SomaPageRootBase & SomaState<S>) & { readonly viewName: string };
92
96
  } catch (error) {
93
97
  if (error instanceof SomaViewDefineError) {
@@ -0,0 +1,5 @@
1
+ // 开发态编译降级页的标记属性:编译失败时 dev 服务回一张诊断页(根元素带本属性),页面其余内容不挂载。
2
+ // 单一来源:kit 的 server.ts 写它;渲染观测的守卫(scripts/lib/aesthetic-kit-driver.mjs)经 Node 类型剥离直接读本文件,不抄字符串。
3
+ // 只放可被类型剥离的写法(常量与 as const),不要在本文件加 import 或枚举。
4
+ export const KIT_DEV_DIAGNOSTIC_ATTR = 'data-kit-dev-diagnostic' as const;
5
+ export const KIT_DEV_DIAGNOSTIC_VALUE = 'true' as const;