soma-kit 0.1.12 → 0.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (261) 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 +158 -4
  6. package/spec/generated/kit-page.schema.json +139 -5
  7. package/spec/kit-grammar.json +438 -87
  8. package/spec/kit-grammar.schema.json +11 -3
  9. package/src/app/app-config.ts +83 -5
  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 +17 -5
  15. package/src/app/kit-view-context.ts +163 -14
  16. package/src/app/render-ports.ts +18 -0
  17. package/src/app/server-pages.ts +3 -1
  18. package/src/app/server.ts +40 -3
  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 +57 -12
  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 +49 -0
  34. package/src/base/fab.ts +1 -1
  35. package/src/base/gap-value.ts +148 -0
  36. package/src/base/hint-tips.ts +170 -0
  37. package/src/base/icons.ts +8 -0
  38. package/src/base/illustrations.ts +94 -0
  39. package/src/base/index.ts +27 -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 +23 -12
  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 +9 -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 +24 -22
  58. package/src/base/shared.ts +169 -23
  59. package/src/base/state-panel.ts +346 -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 +63 -33
  66. package/src/base/text.ts +42 -13
  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 -10
  71. package/src/base/view-transition.ts +77 -0
  72. package/src/biz/approval-desk/shell.ts +11 -8
  73. package/src/biz/auth-panel/shell.ts +5 -4
  74. package/src/biz/category-crud/compile.ts +2 -2
  75. package/src/biz/category-crud/shell.ts +2 -1
  76. package/src/biz/checkout-page/compile.ts +2 -1
  77. package/src/biz/checkout-page/shell.ts +4 -3
  78. package/src/biz/import-wizard/shell.ts +2 -1
  79. package/src/biz/link/hub.ts +23 -5
  80. package/src/biz/link/shared.ts +23 -12
  81. package/src/biz/master-sub/compile.ts +102 -10
  82. package/src/biz/master-sub/index.ts +5 -2
  83. package/src/biz/master-sub/shell.ts +95 -18
  84. package/src/biz/multi-board/compile.ts +4 -1
  85. package/src/biz/multi-board/shell.ts +8 -5
  86. package/src/biz/notification-center/shell.ts +6 -4
  87. package/src/biz/page-templates/result-page/shell.ts +2 -1
  88. package/src/biz/page-templates/sign-in-page/shell.ts +2 -2
  89. package/src/biz/record-detail/compile.ts +2 -2
  90. package/src/biz/record-detail/shell.ts +8 -6
  91. package/src/biz/settings-center/compile.ts +2 -1
  92. package/src/biz/settings-center/shell.ts +6 -4
  93. package/src/biz/shared/action-host.ts +6 -0
  94. package/src/biz/shared/compile-helpers.ts +18 -0
  95. package/src/biz/shared/coordinator.ts +7 -30
  96. package/src/biz/shared/index.ts +5 -0
  97. package/src/biz/shared/object-aliases.ts +154 -0
  98. package/src/biz/shared/overlay-compile.ts +239 -0
  99. package/src/biz/shared/overlay-shell.ts +139 -10
  100. package/src/biz/shared/pipes.ts +11 -5
  101. package/src/biz/shared/remove-wire.ts +4 -19
  102. package/src/biz/shared/runtime-hub.ts +10 -0
  103. package/src/biz/single-form/compile.ts +3 -2
  104. package/src/biz/single-form/shell.ts +4 -3
  105. package/src/biz/standard-crud/compile.ts +22 -160
  106. package/src/biz/standard-crud/shell.ts +16 -44
  107. package/src/biz/step-form/shell.ts +5 -5
  108. package/src/cli/kit-cli.ts +138 -13
  109. package/src/cli/kit-init.ts +6 -1
  110. package/src/cli/layout-cli.ts +167 -0
  111. package/src/cli/migrate/index.ts +10 -0
  112. package/src/cli/migrate/migrate.ts +248 -0
  113. package/src/cli/migrate/text-utils.ts +306 -0
  114. package/src/cli/migrate/theme-map.ts +104 -0
  115. package/src/cli/migrate/ts-rules.ts +235 -0
  116. package/src/cli/migrate/types.ts +95 -0
  117. package/src/cli/migrate/view-skeleton.ts +159 -0
  118. package/src/cli/migrate/yaml-report.ts +376 -0
  119. package/src/cli/migrate/yaml-rules.ts +465 -0
  120. package/src/cli/view-writes.ts +69 -60
  121. package/src/compile/closed-set.ts +65 -4
  122. package/src/compile/compile-page.ts +51 -7
  123. package/src/compile/component-candidates.ts +12 -1
  124. package/src/compile/layout-lint/engine.ts +82 -0
  125. package/src/compile/layout-lint/index.ts +55 -0
  126. package/src/compile/layout-lint/rules-composition.ts +218 -0
  127. package/src/compile/layout-lint/rules-form.ts +192 -0
  128. package/src/compile/layout-lint/rules-table.ts +194 -0
  129. package/src/compile/layout-lint/score.ts +52 -0
  130. package/src/compile/layout-lint/types.ts +51 -0
  131. package/src/compile/remove-guard.ts +10 -7
  132. package/src/compile/styles.ts +36 -8
  133. package/src/compile/types.ts +13 -1
  134. package/src/compile/view-check.ts +149 -16
  135. package/src/data/amount-breakdown.ts +6 -1
  136. package/src/data/approval-flow.ts +1 -1
  137. package/src/data/assignment-picker.ts +53 -27
  138. package/src/data/async-result-panel.ts +49 -3
  139. package/src/data/breadcrumbs.ts +3 -2
  140. package/src/data/calendar.ts +2 -2
  141. package/src/data/carousel.ts +8 -6
  142. package/src/data/chart.ts +141 -10
  143. package/src/data/checklist.ts +18 -5
  144. package/src/data/code-view.ts +8 -4
  145. package/src/data/comment-thread.ts +2 -2
  146. package/src/data/confirm-dialog.ts +71 -18
  147. package/src/data/context-menu.ts +3 -3
  148. package/src/data/dock.ts +1 -1
  149. package/src/data/embed.ts +231 -29
  150. package/src/data/field-mapper.ts +4 -4
  151. package/src/data/flow-editor-contract.ts +7 -0
  152. package/src/data/flow-editor.ts +25 -9
  153. package/src/data/flow-node-options.ts +33 -3
  154. package/src/data/gantt.ts +5 -2
  155. package/src/data/hero.ts +2 -1
  156. package/src/data/image-viewer.ts +7 -4
  157. package/src/data/index.ts +6 -1
  158. package/src/data/item-list.ts +18 -10
  159. package/src/data/kanban.ts +39 -10
  160. package/src/data/media-grid.ts +6 -1
  161. package/src/data/mega-menu.ts +6 -4
  162. package/src/data/menu-dom.ts +4 -2
  163. package/src/data/menu.ts +45 -13
  164. package/src/data/mockup.ts +8 -4
  165. package/src/data/modal-dialog.ts +29 -9
  166. package/src/data/navbar.ts +5 -5
  167. package/src/data/notice-list.ts +268 -0
  168. package/src/data/notify-renderer.ts +21 -6
  169. package/src/data/object-form.ts +354 -48
  170. package/src/data/outcome-watch.ts +61 -2
  171. package/src/data/pager.ts +17 -7
  172. package/src/data/permission-matrix.ts +33 -11
  173. package/src/data/permission-tree.ts +47 -22
  174. package/src/data/pricing-table.ts +21 -11
  175. package/src/data/prompt-dialog.ts +165 -0
  176. package/src/data/reaction-bar.ts +6 -4
  177. package/src/data/record-card.ts +23 -2
  178. package/src/data/record-picker.ts +13 -7
  179. package/src/data/result-panel.ts +4 -2
  180. package/src/data/rich-text.ts +17 -1
  181. package/src/data/row-editor.ts +79 -26
  182. package/src/data/rule-builder.ts +8 -8
  183. package/src/data/shape-util.ts +23 -9
  184. package/src/data/stat-group.ts +170 -29
  185. package/src/data/static-lazy.ts +1 -0
  186. package/src/data/static-registry.ts +2 -0
  187. package/src/data/steps.ts +8 -3
  188. package/src/data/survey.ts +3 -3
  189. package/src/data/system-switcher.ts +1 -1
  190. package/src/data/text-action-button.ts +17 -0
  191. package/src/data/timeline.ts +17 -6
  192. package/src/data/tour-guide.ts +1 -1
  193. package/src/data/transfer.ts +36 -16
  194. package/src/data/tree-table.ts +62 -36
  195. package/src/data/tree.ts +22 -2
  196. package/src/data/virtual-rows.ts +19 -10
  197. package/src/data/wrapped-candidates.ts +10 -0
  198. package/src/frames/page-bar.ts +14 -13
  199. package/src/frames/page-status.ts +7 -5
  200. package/src/frames/shared.ts +15 -10
  201. package/src/frames/split-frame/shell.ts +1 -1
  202. package/src/frames/tabs-frame/shell.ts +2 -1
  203. package/src/frames/tabs-frame/wiring.ts +1 -0
  204. package/src/frames/top-main-frame.ts +2 -2
  205. package/src/frames/workspace-frame/extras.ts +1 -1
  206. package/src/frames/workspace-frame/shell.ts +2 -2
  207. package/src/frames/workspace-frame/view.ts +141 -33
  208. package/src/generated/kit-grammar-runtime.ts +239 -55
  209. package/src/i18n/kit-text.ts +63 -4
  210. package/src/i18n/resolve-text-refs.ts +22 -6
  211. package/src/object-renderer/arrange.ts +42 -8
  212. package/src/object-renderer/collection-parts.ts +241 -60
  213. package/src/object-renderer/collection-table.ts +109 -5
  214. package/src/object-renderer/collection.ts +174 -36
  215. package/src/object-renderer/compile-data.ts +28 -3
  216. package/src/object-renderer/defaults.ts +30 -2
  217. package/src/object-renderer/display-checks.ts +1 -1
  218. package/src/object-renderer/emit-events.ts +43 -9
  219. package/src/object-renderer/emit-static.ts +370 -30
  220. package/src/object-renderer/form-detail.ts +1 -2
  221. package/src/object-renderer/form-notify.ts +45 -0
  222. package/src/object-renderer/layout-facts.ts +386 -0
  223. package/src/object-renderer/layout-plan.ts +132 -0
  224. package/src/object-renderer/layout-plan.types.ts +22 -0
  225. package/src/object-renderer/parts.ts +252 -1
  226. package/src/object-renderer/render-object.ts +54 -6
  227. package/src/object-renderer/request-actions.ts +4 -2
  228. package/src/object-renderer/skeleton.ts +58 -19
  229. package/src/object-renderer/table-actions.ts +135 -27
  230. package/src/object-renderer/table-tools.ts +12 -11
  231. package/src/object-renderer/types.ts +78 -7
  232. package/src/object-renderer/view-binding.ts +205 -8
  233. package/src/page-target/intent-schema.ts +11 -0
  234. package/src/page-target/target.ts +5 -1
  235. package/src/recipes/container.ts +46 -1
  236. package/src/recipes/control.ts +70 -12
  237. package/src/recipes/index.ts +49 -0
  238. package/src/recipes/nowrap.ts +16 -0
  239. package/src/recipes/overlay.ts +75 -17
  240. package/src/recipes/placeholder.ts +79 -0
  241. package/src/recipes/rail-grid.ts +45 -0
  242. package/src/recipes/slot-align.ts +56 -0
  243. package/src/recipes/state.ts +34 -5
  244. package/src/recipes/status.ts +139 -0
  245. package/src/recipes/surface.ts +40 -0
  246. package/src/recipes/table-row.ts +40 -3
  247. package/src/recipes/title-row.ts +37 -0
  248. package/src/recipes/typography.ts +13 -1
  249. package/src/shared/confirm-decl.ts +118 -0
  250. package/src/shared/envelope.ts +2 -2
  251. package/src/shared/paged-list-adapter.ts +15 -240
  252. package/src/shared/theme-runtime-shared.ts +6 -1
  253. package/src/theme/index.ts +1 -0
  254. package/src/theme/kit-theme-text.ts +1 -1
  255. package/src/theme/kit-theme.css +372 -12
  256. package/src/theme/kit-theme.tpl +372 -12
  257. package/src/theme/nine-dim-structure.ts +177 -7
  258. package/src/theme/surface-layers.ts +4 -0
  259. package/src/theme/theme-tokens.ts +53 -13
  260. package/src/theme/theme-types.ts +32 -0
  261. package/src/biz/shared/remove-key.ts +0 -6
@@ -534,9 +534,6 @@
534
534
  "batchActionKeys": {
535
535
  "$ref": "#/$defs/strings"
536
536
  },
537
- "batchConfirmCount": {
538
- "type": "string"
539
- },
540
537
  "selectScopes": {
541
538
  "$ref": "#/$defs/strings"
542
539
  },
@@ -1416,6 +1413,17 @@
1416
1413
  "actionKeys": {
1417
1414
  "$ref": "#/$defs/strings"
1418
1415
  },
1416
+ "actionConfirm": {
1417
+ "type": "object",
1418
+ "properties": {
1419
+ "note": {
1420
+ "type": "string"
1421
+ },
1422
+ "keys": {
1423
+ "$ref": "#/$defs/strings"
1424
+ }
1425
+ }
1426
+ },
1419
1427
  "actionBuiltins": {
1420
1428
  "type": "object",
1421
1429
  "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,
@@ -93,6 +114,8 @@ export interface KitAppConfig {
93
114
  theme?: KitAppTheme;
94
115
  /** 默认页面布局配置:继承给子页面 */
95
116
  layout?: KitAppLayout;
117
+ /** 布局规则版本钉(`layout.rules`,RV-1117):缺省 0 = 现状 12 份均分,输出逐字节不变;只写 rules 不算启用外框继承 */
118
+ layoutRules?: number;
96
119
  /** 主题头文件路径(相对应用根);缺省用内置 kit-theme.css */
97
120
  style?: string;
98
121
  /** 应用扩展的基础组件:名字 -> 说明 */
@@ -127,6 +150,13 @@ const THEME_KEYS = [
127
150
  'surface_texture',
128
151
  'surfaceTexture',
129
152
  'density',
153
+ 'motion',
154
+ 'table_style',
155
+ 'tableStyle',
156
+ 'contrast',
157
+ 'accent_usage',
158
+ 'accentUsage',
159
+ 'preset',
130
160
  'mode',
131
161
  ];
132
162
  /**
@@ -141,7 +171,6 @@ export const REMOVED_THEME_KEYS: Readonly<Record<string, string>> = {
141
171
  color: '品牌色号不再支持:改用九维 palette 选一套人工精调配色,配合 color_depth / color_saturation 调深浅与饱和度',
142
172
  polarity: '改用 mode(light / dark / soft / system)',
143
173
  radius: '改用九维 shape',
144
- preset: '改用九维 palette 配合 color_depth / color_saturation',
145
174
  color_scheme: '改用九维 palette 配合 color_depth / color_saturation',
146
175
  colorScheme: '改用九维 palette 配合 color_depth / color_saturation',
147
176
  tone: '改用九维 palette 配合 color_depth / color_saturation',
@@ -151,6 +180,13 @@ export const REMOVED_THEME_KEYS: Readonly<Record<string, string>> = {
151
180
  componentStyle: '改用九维 boundary 与 surface_texture',
152
181
  };
153
182
 
183
+ /**
184
+ * 已删除的主题取值(维度 -> 旧值 -> 迁移指引):取值域校验命中时给出清晰的迁移诊断,不留兼容别名。
185
+ */
186
+ export const REMOVED_THEME_VALUES: Readonly<Record<string, Readonly<Record<string, string>>>> = {
187
+ surface_texture: { FROSTED_CHROME: '已合并为 GLASS_CHROME(顶栏与悬浮层毛玻璃,带不透明回退),请改写 GLASS_CHROME' },
188
+ };
189
+
154
190
  /**
155
191
  * 校验主题对象中的已删除旧键(palette_scheme/paletteScheme/font_scheme/fontScheme/color 等),
156
192
  * 命中即推入 KIT-APP-002 迁移诊断。
@@ -169,14 +205,14 @@ export function checkRemovedThemeKeys(
169
205
  diagnostics.push({
170
206
  code: 'KIT-APP-002',
171
207
  path: kp,
172
- message: `theme.${k} 已删除(kit 主题只支持九维 palette / color_depth / color_saturation / font_family / font_scale / boundary / shape / surface_texture / density + mode):${removedHint}`,
208
+ message: `theme.${k} 已删除(kit 主题只支持九维 palette / color_depth / color_saturation / font_family / font_scale / boundary / shape / surface_texture / density + 扩展维度 motion / table_style / contrast / accent_usage + 预设 preset + mode):${removedHint}`,
173
209
  });
174
210
  }
175
211
  }
176
212
  return diagnostics;
177
213
  }
178
214
  const STATIC_KEYS = ['accept', 'desc'];
179
- const LAYOUT_TOP_KEYS = ['frame', 'max_width', 'sticky_header', 'header', 'sidebar', 'footer'];
215
+ const LAYOUT_TOP_KEYS = ['frame', 'max_width', 'sticky_header', 'header', 'sidebar', 'footer', 'rules'];
180
216
  const MAX_WIDTH_VALUES = ['narrow', 'medium', 'wide', 'full'] as const;
181
217
  const LAYOUT_HEADER_KEYS = ['brand', 'nav', 'actions'];
182
218
  const LAYOUT_SIDEBAR_KEYS = ['title', 'width', 'menu'];
@@ -373,7 +409,8 @@ export function parseAppConfig(raw: unknown, diagnostics: KitDiagnostic[]): KitA
373
409
  }
374
410
  } else if (k === 'surface_texture' || k === 'surfaceTexture') {
375
411
  if (!(KIT_THEME_SURFACE_TEXTURES as readonly string[]).includes(val)) {
376
- bad(kp, `${k}「${val}」只能是 ${KIT_THEME_SURFACE_TEXTURES.join(' / ')}`, diagnostics);
412
+ const removed = Object.hasOwn(REMOVED_THEME_VALUES.surface_texture, val) ? REMOVED_THEME_VALUES.surface_texture[val] : undefined;
413
+ bad(kp, `${k}「${val}」${removed !== undefined ? `已删除:${removed};` : ''}只能是 ${KIT_THEME_SURFACE_TEXTURES.join(' / ')}`, diagnostics);
377
414
  } else {
378
415
  theme.surface_texture = val as KitThemeSurfaceTexture;
379
416
  theme.surfaceTexture = val as KitThemeSurfaceTexture;
@@ -384,6 +421,39 @@ export function parseAppConfig(raw: unknown, diagnostics: KitDiagnostic[]): KitA
384
421
  } else {
385
422
  theme.density = val as KitThemeDensity;
386
423
  }
424
+ } else if (k === 'motion') {
425
+ if (!(KIT_THEME_MOTIONS as readonly string[]).includes(val)) {
426
+ bad(kp, `motion「${val}」只能是 ${KIT_THEME_MOTIONS.join(' / ')}`, diagnostics);
427
+ } else {
428
+ theme.motion = val as KitThemeMotion;
429
+ }
430
+ } else if (k === 'table_style' || k === 'tableStyle') {
431
+ if (!(KIT_THEME_TABLE_STYLES as readonly string[]).includes(val)) {
432
+ bad(kp, `${k}「${val}」只能是 ${KIT_THEME_TABLE_STYLES.join(' / ')}`, diagnostics);
433
+ } else {
434
+ theme.table_style = val as KitThemeTableStyle;
435
+ theme.tableStyle = val as KitThemeTableStyle;
436
+ }
437
+ } else if (k === 'contrast') {
438
+ if (!(KIT_THEME_CONTRASTS as readonly string[]).includes(val)) {
439
+ bad(kp, `contrast「${val}」只能是 ${KIT_THEME_CONTRASTS.join(' / ')}`, diagnostics);
440
+ } else {
441
+ theme.contrast = val as KitThemeContrast;
442
+ }
443
+ } else if (k === 'accent_usage' || k === 'accentUsage') {
444
+ if (!(KIT_THEME_ACCENT_USAGES as readonly string[]).includes(val)) {
445
+ bad(kp, `${k}「${val}」只能是 ${KIT_THEME_ACCENT_USAGES.join(' / ')}`, diagnostics);
446
+ } else {
447
+ theme.accent_usage = val as KitThemeAccentUsage;
448
+ theme.accentUsage = val as KitThemeAccentUsage;
449
+ }
450
+ } else if (k === 'preset') {
451
+ // 未知预设名按主题取值域错误报 KIT-APP-002(与求解端 solveKitTheme 同码同路径),不写入 cfg.theme
452
+ if (!(KIT_THEME_PRESETS as readonly string[]).includes(val)) {
453
+ diagnostics.push({ code: 'KIT-APP-002', path: kp, message: `preset「${val}」不是已知主题预设,只能是 ${KIT_THEME_PRESETS.join(' / ')}` });
454
+ } else {
455
+ theme.preset = val as KitThemePreset;
456
+ }
387
457
  } else if (k === 'mode') {
388
458
  if (!(KIT_THEME_MODES as readonly string[]).includes(val)) {
389
459
  bad(kp, `mode「${val}」只能是 ${KIT_THEME_MODES.join(' / ')}`, diagnostics);
@@ -405,6 +475,13 @@ export function parseAppConfig(raw: unknown, diagnostics: KitDiagnostic[]): KitA
405
475
  if (!LAYOUT_TOP_KEYS.includes(k)) bad(layoutKeyPath(k), `未知键 ${k}(允许:${LAYOUT_TOP_KEYS.join(' / ')})`, diagnostics);
406
476
  }
407
477
  const layout: KitAppLayout = {};
478
+ // 布局规则版本钉(RV-1117 T09):缺省 0 = 现状,输出逐字节不变;新应用 / AI 页钉最新版。
479
+ // 它不是「外框继承」配置,不进 cfg.layout(否则只写 rules 的应用会被当成启用了继承外框而多包一层)
480
+ if (rawLayout.rules !== undefined) {
481
+ const pin = typeof rawLayout.rules === 'number' ? normalizeLayoutPin(rawLayout.rules) : undefined;
482
+ if (pin === undefined) bad(layoutKeyPath('rules'), `rules 必须是已存在的布局规则版本号(整数,${KIT_LAYOUT_VERSIONS.join(' / ')};缺省 0 = 现状)`, diagnostics);
483
+ else cfg.layoutRules = pin;
484
+ }
408
485
  if (rawLayout.frame !== undefined) {
409
486
  if (typeof rawLayout.frame === 'string' && rawLayout.frame.trim() !== '') layout.frame = rawLayout.frame.trim();
410
487
  else bad(layoutKeyPath('frame'), 'frame 必须是非空字符串', diagnostics);
@@ -554,7 +631,8 @@ export function parseAppConfig(raw: unknown, diagnostics: KitDiagnostic[]): KitA
554
631
  layout.footer = footer;
555
632
  }
556
633
  }
557
- cfg.layout = layout;
634
+ // 只写了 rules 的 layout 块不是外框继承配置(见上),不进 cfg.layout,存量应用输出不变
635
+ if (!(Object.keys(rawLayout).length === 1 && rawLayout.rules !== undefined)) cfg.layout = layout;
558
636
  }
559
637
  }
560
638
  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;
package/src/app/index.ts CHANGED
@@ -10,12 +10,14 @@ export type {
10
10
  export { defineKitPack, KitPackError, packPrefix } from './define-kit-pack';
11
11
  export { defineKitView } from './define-kit-view';
12
12
  export type { KitViewClass, KitViewDefinition } from './define-kit-view';
13
- export type { KitViewContext, KitFormHandle, KitFormChange, KitRequestDone } from './kit-view-context';
13
+ export type { KitViewHttp, KitViewContext, KitFormHandle, KitFormHandleSlot, KitFormChange, KitRequestDone, KitViewConfirmOptions, KitViewPromptSpec } from './kit-view-context';
14
14
  export type { KitPack, KitPackInput, KitPackStaticComponent } from './define-kit-pack';
15
15
  export { defineKitActions, kitActionHttp, createKitActionHttp } from './define-kit-actions';
16
16
  export type { KitActionArgs, KitActionHandler, KitActionHttp, KitNamedAction } from './define-kit-actions';
17
- export { createPagedListAdapter, unwrapBizEnvelope, isBizFailure, withRowId, cursorPageWindow } from './paged-list-adapter';
18
- export type { PagedListAdapter, PagedListAdapterOptions, PagedQuery, PagedList, UnwrappedEnvelope, CursorLoader, CursorPageOptions, CursorPageResult } from './paged-list-adapter';
17
+ // 业务信封读取(浏览器与服务端共用的约定读取点);分页整形助手(createPagedListAdapter / cursorPageWindow / withRowId)
18
+ // 实现在 soma-core/server/paged-list,kit 应用只经服务端入口 soma-kit/app/server 取用(J6;浏览器入口不导出)
19
+ export { unwrapEnvelope as unwrapBizEnvelope, isEnvelopeFailure as isBizFailure } from './envelope';
20
+ export type { UnwrappedEnvelope } from './envelope';
19
21
  export { KIT_PLACEHOLDER_URL, KitSubmitError } from './submit.types';
20
22
  export type {
21
23
  KitPageBindingView,
@@ -47,8 +49,18 @@ export { wrapKitBizComponent, composeKitBizComponents } from '../biz/compose';
47
49
  export type { WrapBizOptions, WrapBizShellContext, ComposeBizPart, ComposeBizOptions, ComposeBizShellContext } from '../biz/compose';
48
50
  export { wrapKitDataComponent, composeKitDataComponents, mapKeys } from '../data/wrap';
49
51
  export type { PackProps, WrapDataOptions, WrapOptions, ComposeDataPart, ComposeDataOptions, ComposeEventForward } from '../data/wrap';
50
- export { mountKitComponent, mountKitSelectField, createKitEmbedBag } from '../data/embed';
51
- export { declareKitUses } from '../data/wrapped-candidates';
52
+ export { mountKitComponent, mountKitSelectField, mountKitInputField, mountKitTextareaField, mountKitCheckboxField, createKitEmbedBag } from '../data/embed';
53
+ export type { KitFieldA11yOptions, KitFieldState, KitComponentField, KitSelectFieldOptions, KitSelectField, KitInputFieldOptions, KitTextareaFieldOptions, KitCheckboxFieldOptions } from '../data/embed';
54
+ // 命令式 Date 字段(自绘日历,无原生 date 输入):与 mountKitSelectField 同族,支持 labelledby / required / invalid
55
+ export { mountKitDateField } from '../base/date';
56
+ export type { KitDateField, KitDateFieldOptions, KitDateFieldState } from '../base/date';
57
+ export { declareKitUses, declareKitStatePanel } from '../data/wrapped-candidates';
58
+ // 应用组件的悬停提示(经浮层端口,不被 overflow 裁切)
59
+ export { kitTooltip, releaseReasonTipsIn, KIT_APP_TOOLTIP_CLASS_CANDIDATES } from '../base/reason-tip';
60
+ export type { KitTooltipOptions } from '../base/reason-tip';
61
+ // 应用组件的三态面板(loading / empty / error / not_ready / upstream_broken / denied):与集合、数据组件同一份画法
62
+ export { kitStatePanel, paintKitStatePanel, KIT_STATE_PANEL_CLASS_CANDIDATES } from '../base/state-panel';
63
+ export type { KitStateKind, KitStatePanelOptions } from '../base/state-panel';
52
64
  export { createKitController, KIT_CONTROLLER, isKitControllerFactory, classCandidates } from '../base/shared';
53
65
  export type { KitApi, KitView, KitViewSetup } from '../base/shared';
54
66
  export { KIT_TYPOGRAPHY, KIT_TYPOGRAPHY_CLASS_CANDIDATES } from '../theme/typography';