soma-kit 0.1.11 → 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 -1473
@@ -16,37 +16,23 @@ import type { SomaScopeMirrorDecl } from 'soma-core';
16
16
  import { KIT_VIEW_FORM_KEYS, KIT_VIEW_SLOTS } from '../../object-renderer/defaults';
17
17
  import { emitObject } from '../../object-renderer/emit-object';
18
18
  import { viewAnchor } from '../../object-renderer/emit-static';
19
- import type { KitAction, KitDiagnostic, KitFieldSchema, KitObject, KitViewForm } from '../../object-renderer/types';
19
+ import type { KitDiagnostic, KitFieldSchema, KitObject, KitViewForm } from '../../object-renderer/types';
20
20
  import type { KitFragment } from '../../compile/fragment';
21
21
  import type { KitBizContext, KitBizInput } from '../types';
22
22
  import { kitText } from '../../i18n/kit-text';
23
- import { gateOf, type KitGateDecl } from '../../object-renderer/adopt-gate';
24
- import { actionEvent, actionPipeline } from '../../object-renderer/emit-events';
23
+ import {
24
+ bizObjectName, checkRoleAllowedViews, finishBizCompile, validateBizAreaClass,
25
+ } from '../shared/compile-helpers';
25
26
  import { KIT_STEP_EVENTS, KIT_STEP_MIRRORS } from './hub';
27
+ import { StepForm } from './index';
26
28
  import {
27
- IDENT, addEmit, classesIn, dedupeDiagnostics, isRec, mirrorPath, newParts, patchProps, semanticPipe, sortMirrors,
28
- type Parts, type Rec,
29
+ IDENT, addEmit, classesIn, isRec, mirrorPath, newParts, patchProps, semanticPipe, sortMirrors,
30
+ type Rec,
29
31
  } from '../link/shared';
30
32
  import { STEP_FORM_AREAS, STEP_FORM_CLASS, stepFormHtml, stepFormIds } from './shell';
31
- import { rewriteStepRefs } from './steps-ref';
32
- import { runInKitStepScope } from '../../object-renderer/field-value';
33
-
34
- const RESERVED = new Set(['page', 'p', 'ctrl', 'frame', 'tabs']);
35
33
 
36
34
  export function stepFormObjectName(pageId: string, role: string): string {
37
- const name = `${pageId}_${role}`;
38
- return RESERVED.has(name) ? `${name}_obj` : name;
39
- }
40
-
41
- function finish(out: Parts, html: string): KitFragment {
42
- return {
43
- html,
44
- ui: { data: out.data, scopes: out.scopes as unknown as Record<string, unknown>, show: out.show },
45
- events: out.events,
46
- components: [...out.components].sort(),
47
- candidates: [...out.candidates].sort(),
48
- diagnostics: dedupeDiagnostics(out.diagnostics),
49
- };
35
+ return bizObjectName(pageId, role);
50
36
  }
51
37
 
52
38
  /** 一步规整:view 顶层的表单键归到 form 槽;只许 form 槽;不许读写 */
@@ -62,35 +48,20 @@ function normalizeStep(raw: Rec, path: string, diagnostics: KitDiagnostic[], per
62
48
  view.form = form;
63
49
  }
64
50
  }
65
- for (const slot of KIT_VIEW_SLOTS) {
66
- if (slot !== 'form' && view[slot] !== undefined) {
67
- fail(`StepForm 的每一步只有 form 视图,不允许 ${slot}`, `${path}.view.${slot}`);
68
- delete view[slot];
69
- }
70
- }
51
+ checkRoleAllowedViews('steps', { view }, StepForm.roles.steps, diagnostics, path);
71
52
  if (view.form === undefined) view.form = {};
72
53
  const behavior: Rec = isRec(raw.behavior) ? { ...raw.behavior } : {};
73
54
  if (behavior.from !== undefined) fail('StepForm 每一步不声明 behavior.from:分步表单只新建', `${path}.behavior.from`);
74
55
  if (behavior.write !== undefined && !perStep) {
75
56
  diagnostics.push({ code: 'KIT-STEP-001', message: 'saveMode 为 final 时步骤对象不写 behavior.write(读写由 target 承担;要每步保存请设 config.saveMode: perStep)', path: `${path}.behavior.write` });
76
57
  }
77
- // 步骤动作只许 request 动作且不写 on:上一步 / 下一步 / 提交由写死的按钮承担,request 动作只被 gate.run(「去验证」钮)引用
78
- const stepActions: unknown[] = [];
79
- if (Array.isArray(behavior.actions)) {
80
- behavior.actions.forEach((a, i) => {
81
- const ok = isRec(a) && isRec(a.request) && a.on === undefined && a.submit === undefined && a.builtin === undefined;
82
- if (ok) stepActions.push(a);
83
- else fail('StepForm 每一步的 behavior.actions 只许不写 on 的 request 动作(它只被 gate.run 引用;上一步 / 下一步 / 提交由写死的按钮承担)', `${path}.behavior.actions[${i}]`);
84
- });
85
- }
86
58
  // perStep 下步骤对象自带写口(首步 create + update,其余步 update);final 下没有读写
87
- const { gate: _gate, ...rest } = raw;
88
59
  return {
89
- ...rest,
60
+ ...raw,
90
61
  schema: isRec(raw.schema) ? raw.schema : {},
91
62
  behavior: {
92
63
  ...(perStep && behavior.write !== undefined ? { write: behavior.write } : {}),
93
- ...(stepActions.length > 0 ? { actions: stepActions } : {}),
64
+ ...(Array.isArray(behavior.actions) ? { actions: behavior.actions } : {}),
94
65
  },
95
66
  view,
96
67
  } as unknown as KitObject;
@@ -175,7 +146,7 @@ export function compileStepForm(input: KitBizInput, ctx: KitBizContext): KitFrag
175
146
  const rawTarget = input.objects.target;
176
147
  if (!isRec(rawSteps) || Object.keys(rawSteps).length === 0) {
177
148
  fail('KIT-BIZ-001', 'StepForm 缺少必填对象角色槽 steps(至少 1 步)', 'product.objects.steps');
178
- return finish(out, '');
149
+ return finishBizCompile(out, '');
179
150
  }
180
151
  const cfg = readStepConfig(isRec(input.config) ? input.config : undefined, out.diagnostics);
181
152
  const perStep = cfg.perStep;
@@ -189,22 +160,16 @@ export function compileStepForm(input: KitBizInput, ctx: KitBizContext): KitFrag
189
160
  } else {
190
161
  if (!isRec(rawTarget) || !isRec(rawTarget.behavior) || (rawTarget.behavior as Rec).write === undefined) {
191
162
  fail('KIT-BIZ-001', 'StepForm 缺少必填对象角色槽 target(需含 behavior.write:最终提交的写接口)', 'product.objects.target');
192
- return finish(out, '');
163
+ return finishBizCompile(out, '');
193
164
  }
194
165
  if (rawTarget.schema !== undefined) fail('KIT-BIZ-003', 'StepForm 的 target 不写 schema:字段字典由各步 schema 合并而来', 'product.objects.target.schema');
195
166
  if (rawTarget.view !== undefined) fail('KIT-BIZ-003', 'StepForm 的 target 不写 view', 'product.objects.target.view');
196
167
  if ((rawTarget.behavior as Rec).from !== undefined) fail('KIT-BIZ-003', 'StepForm 的 target 不支持 behavior.from(分步表单只新建)', 'product.objects.target.behavior.from');
197
168
  }
198
- for (const key of Object.keys(input.areaClass ?? {})) {
199
- if (!(STEP_FORM_AREAS as readonly string[]).includes(key)) {
200
- fail('KIT-PAGE-001', `areaClass 里的区域名 "${key}" 不在 StepForm 的区域闭集 ${STEP_FORM_AREAS.join(' / ')} 内`, `product.areaClass.${key}`);
201
- }
202
- }
169
+ validateBizAreaClass(input, 'StepForm', STEP_FORM_AREAS, out.diagnostics);
203
170
  const stepNames = Object.keys(rawSteps);
204
- const steps: Array<{ name: string; object: string; obj: KitObject; title: string; fields: string[]; usesSteps: boolean; gate?: KitGateDecl }> = [];
171
+ const steps: Array<{ name: string; object: string; obj: KitObject; title: string; fields: string[] }> = [];
205
172
  const union: Record<string, KitFieldSchema> = {};
206
- /** 已处理的更早步骤:闸门的 steps.<名>.<字段> 只能指向它们 */
207
- const earlier = new Map<string, { index: number; fields: ReadonlySet<string> }>();
208
173
  for (const n of stepNames) {
209
174
  const at = `product.objects.steps.${n}`;
210
175
  const raw = rawSteps[n];
@@ -213,9 +178,7 @@ export function compileStepForm(input: KitBizInput, ctx: KitBizContext): KitFrag
213
178
  fail('KIT-BIZ-001', `steps.${n} 必须是对象声明且含非空 schema`, at);
214
179
  continue;
215
180
  }
216
- // GB1:把声明里的 $steps.<步骤名>.<字段> 校验后改写成序号形态(只许指向更早的步骤)
217
- const refd = rewriteStepRefs(raw as Rec, at, earlier, out.diagnostics);
218
- const obj = normalizeStep(refd.step, at, out.diagnostics, perStep);
181
+ const obj = normalizeStep(raw as Rec, at, out.diagnostics, perStep);
219
182
  if (perStep) {
220
183
  checkPerStepWrite(isRec(raw.behavior) ? (raw.behavior as Rec).write : undefined, stepNames[0] === n, stepKey, abandonDelete, at, out.diagnostics);
221
184
  if (stepKey in obj.schema) fail('KIT-STEP-001', `stepKey "${stepKey}" 是主键位,不能同时是步骤字段`, `${at}.schema.${stepKey}`);
@@ -224,27 +187,20 @@ export function compileStepForm(input: KitBizInput, ctx: KitBizContext): KitFrag
224
187
  for (const f of fields) {
225
188
  if (f in union) fail('KIT-BIZ-003', `字段 ${f} 在多个步骤里重复声明(字段名在各步之间不得重名)`, `${at}.schema.${f}`);
226
189
  else {
227
- // 提交目标只取字典(rules / 类型):初值 / 隐藏 / 派生是各步表单自己的事,不带进目标(目标不发射界面)
228
- const { default: _default, hidden: _hidden, derive: _derive, ...plain } = obj.schema[f]!;
190
+ // 提交目标只取字典(rules / 类型):初值 / 隐藏是各步表单自己的事,不带进目标(目标不发射界面)
191
+ const { default: _default, hidden: _hidden, ...plain } = obj.schema[f]!;
229
192
  union[f] = plain;
230
193
  }
231
194
  }
232
- // 阶段闸门:{ when, message },不满足时本步「下一步」禁用并显示 message
233
- const gate = raw.gate === undefined
234
- ? null
235
- : gateOf(raw.gate, `${at}.gate`, new Set(fields), new Map(earlier), out.diagnostics);
236
195
  steps.push({
237
196
  name: n,
238
197
  object: stepFormObjectName(ctx.pageId, `step_${n}`),
239
198
  obj,
240
199
  title: typeof raw.title === 'string' && raw.title !== '' ? raw.title : n,
241
200
  fields,
242
- usesSteps: refd.used,
243
- ...(gate !== null ? { gate } : {}),
244
201
  });
245
- earlier.set(n, { index: steps.length - 1, fields: new Set(fields) });
246
202
  }
247
- if (out.diagnostics.length > 0) return finish(out, '');
203
+ if (out.diagnostics.length > 0) return finishBizCompile(out, '');
248
204
 
249
205
  const ids = stepFormIds(ctx.pageId);
250
206
  const link = ids.link;
@@ -256,8 +212,7 @@ export function compileStepForm(input: KitBizInput, ctx: KitBizContext): KitFrag
256
212
  // ---- 每步一个表单(只含本步字段的数据对象 + KitObjectForm)
257
213
  const formHtml: Record<string, string> = {};
258
214
  steps.forEach((s, i) => {
259
- // runInKitStepScope:规范序号形态的 $steps 引用只在步骤编译期间被下游校验认作合法
260
- const r = runInKitStepScope(() => emitObject(
215
+ const r = emitObject(
261
216
  s.obj,
262
217
  { object: s.object, scope: `${s.object}_scope`, registered: ctx.registeredComponents, staticComponents: ctx.staticComponents },
263
218
  {
@@ -265,7 +220,7 @@ export function compileStepForm(input: KitBizInput, ctx: KitBizContext): KitFrag
265
220
  formMode: 'create',
266
221
  formInitialPath: mirrorPath(link, KIT_STEP_MIRRORS.values(i).key),
267
222
  },
268
- ));
223
+ );
269
224
  r.diagnostics = r.diagnostics.map((d) => ({ ...d, path: `${s.object}:${d.path}` }));
270
225
  addEmit(out, r);
271
226
  // abandon: delete:首步 write.delete 的 {stepKey} 占位取自目标记录,core 要求它是本对象字典里的字段;
@@ -290,28 +245,6 @@ export function compileStepForm(input: KitBizInput, ctx: KitBizContext): KitFrag
290
245
  resetLabel: '',
291
246
  ...(i > 0 ? { cancelLabel: kitText('soma.kit.prev_step', undefined, ctx.locale) } : {}),
292
247
  });
293
- // 阶段闸门:声明与各步已确认值(镜像)一并交给表单,由表单实时求值、禁用提交并显示原因
294
- if (s.gate !== undefined) {
295
- let gate: KitGateDecl = s.gate;
296
- const gateAt = `product.objects.steps.${s.name}.gate`;
297
- if (gate.run !== undefined) {
298
- // 「去验证」钮:指向本步一个不写 on 的 request 动作,其 into 必须写明(闸门用 outcome.<into>.status 读它)
299
- const acts = (s.obj.behavior.actions ?? []) as KitAction[];
300
- const hit = acts.find((a) => a.id === gate.run);
301
- const into = hit?.request?.into;
302
- if (hit === undefined || hit.request === undefined) fail('KIT-STEP-004', `gate.run "${gate.run}" 不是本步 behavior.actions 里的 request 动作`, `${gateAt}.run`);
303
- else if (typeof into !== 'string' || into === '') fail('KIT-STEP-004', `gate.run 指向的动作 ${hit.id} 必须写 request.into(闸门读它的结果)`, `${gateAt}.run`);
304
- else {
305
- const pipe = runInKitStepScope(() => actionPipeline(hit, `${gateAt}.run`, { actions: acts, hasWrite: false, object: s.object, ...(ctx.registeredActions !== undefined ? { registeredActions: ctx.registeredActions } : {}) }, out.diagnostics));
306
- if (pipe !== null) out.events[`${formId}.gate_run`] = actionEvent(pipe, hit, `${s.object}_scope`);
307
- gate = { ...gate, runOutcome: into };
308
- }
309
- }
310
- patchProps(out.show, formId, { gate, gateSteps: mirrorPath(link, KIT_STEP_MIRRORS.allValues.key) });
311
- } else if (s.usesSteps) {
312
- // GB1:没有闸门但字段 default / options.params / derive 用到 $steps:只交各步已确认值的镜像
313
- patchProps(out.show, formId, { gateSteps: mirrorPath(link, KIT_STEP_MIRRORS.allValues.key) });
314
- }
315
248
  out.events[`${formId}.submit`] = semanticPipe(link, KIT_STEP_EVENTS.next);
316
249
  if (i > 0) out.events[`${formId}.cancel`] = semanticPipe(link, KIT_STEP_EVENTS.prev);
317
250
  // abandon: delete:每步多一个「取消」,放弃并(已保存过时)二次确认后删掉半成品
@@ -320,7 +253,7 @@ export function compileStepForm(input: KitBizInput, ctx: KitBizContext): KitFrag
320
253
  out.events[`${ids.abort(i)}.click`] = semanticPipe(link, KIT_STEP_EVENTS.abort);
321
254
  }
322
255
  });
323
- if (out.diagnostics.length > 0) return finish(out, '');
256
+ if (out.diagnostics.length > 0) return finishBizCompile(out, '');
324
257
 
325
258
  // ---- 提交目标的数据对象:字段字典 = 并集,带 write;只取它的 data 声明,不发射界面
326
259
  // perStep 不要提交目标:写口在各步对象上
@@ -330,21 +263,17 @@ export function compileStepForm(input: KitBizInput, ctx: KitBizContext): KitFrag
330
263
  behavior: { write: (targetRec.behavior as Rec).write },
331
264
  view: { form: { fields: Object.keys(union) } },
332
265
  } as unknown as KitObject;
333
- // 并集字典里带着各步已改写成规范序号形态的 $steps 引用,同样在步骤作用域里校验
334
- const tr = runInKitStepScope(() => emitObject(
266
+ const tr = emitObject(
335
267
  targetObj,
336
268
  { object: targetName, scope: `${targetName}_scope`, registered: ctx.registeredComponents, staticComponents: ctx.staticComponents },
337
269
  { registeredActions: ctx.registeredActions, formMode: 'create' },
338
- ));
270
+ );
339
271
  out.diagnostics.push(...tr.diagnostics.map((d) => ({ ...d, path: `${targetName}:${d.path}` })));
340
272
  Object.assign(out.data, tr.ui.data);
341
273
  }
342
274
 
343
275
  // ---- 链接作用域:focus 归 KitStepHub
344
276
  const mirrors: SomaScopeMirrorDecl[] = [{ key: KIT_STEP_MIRRORS.done.key, slice: 'focus', path: KIT_STEP_MIRRORS.done.path, as: 'truthy' }];
345
- if (steps.some((s) => s.gate !== undefined || s.usesSteps)) {
346
- mirrors.push({ key: KIT_STEP_MIRRORS.allValues.key, slice: 'focus', path: KIT_STEP_MIRRORS.allValues.path, as: KIT_STEP_MIRRORS.allValues.as });
347
- }
348
277
  for (let i = 0; i < total; i += 1) {
349
278
  for (const x of [KIT_STEP_MIRRORS.at(i), KIT_STEP_MIRRORS.past(i), KIT_STEP_MIRRORS.fut(i)]) {
350
279
  mirrors.push({ key: x.key, slice: 'focus', path: x.path, as: x.as });
@@ -379,7 +308,7 @@ export function compileStepForm(input: KitBizInput, ctx: KitBizContext): KitFrag
379
308
  ...(abandonDelete ? { abandon: 'delete' } : {}),
380
309
  },
381
310
  };
382
- out.events[`${ids.hub}.saved`] = { steps: [{ do: `NOTIFY | success | ${kitText('soma.kit.sf_done', undefined, ctx.locale)}` }] };
311
+ out.events[`${ids.hub}.saved`] = `NOTIFY | success | ${kitText('soma.kit.sf_done', undefined, ctx.locale)}`;
383
312
 
384
313
  const doneTitle = typeof targetRec.title === 'string' && targetRec.title !== '' ? targetRec.title : kitText('soma.kit.sf_done', undefined, ctx.locale);
385
314
  const html = stepFormHtml(
@@ -396,5 +325,5 @@ export function compileStepForm(input: KitBizInput, ctx: KitBizContext): KitFrag
396
325
  );
397
326
  for (const c of classesIn(html)) out.candidates.add(c);
398
327
  for (const c of Object.values(STEP_FORM_CLASS)) for (const t of c.split(/\s+/)) if (t !== '') out.candidates.add(t);
399
- return finish(out, html);
328
+ return finishBizCompile(out, html);
400
329
  }
@@ -25,10 +25,10 @@
25
25
  //
26
26
  // focus 切片值:{ step, total, done, busy, at: {s<i>}, past: {s<i>}, fut: {s<i>}, values: {s<i>: model}, seq, rid? }
27
27
 
28
- import type { SomaComponentControllerContext, SomaComponentDefinition, SomaDataPort, SomaRegionPort } from 'soma-core';
28
+ import type { SomaComponentDefinition, SomaDataPort, SomaRegionPort } from 'soma-core';
29
+ import { createKitController } from '../../base/shared';
29
30
  import { kitText } from '../../i18n/kit-text';
30
31
  import { askKitConfirm } from '../../data/confirm-dialog';
31
- import { registerKitStepValues } from '../shared/step-values';
32
32
 
33
33
  /** 语义事件名(SCOPE | semantic 要求小写 snake_case) */
34
34
  export const KIT_STEP_EVENTS = {
@@ -60,8 +60,6 @@ export const KIT_STEP_MIRRORS = {
60
60
  fut: (i: number): { key: string; path: string; as: 'truthy' } => ({ key: `step_fut_${i}`, path: `fut.s${i}`, as: 'truthy' }),
61
61
  values: (i: number): { key: string; path: string; as: 'value' } => ({ key: `step_vals_${i}`, path: `values.s${i}`, as: 'value' }),
62
62
  done: { key: 'step_done', path: 'done', as: 'truthy' } as const,
63
- /** 全部步骤已确认的 model(阶段闸门 steps.s<i>.字段 的取值来源;只有声明了 gate 才编入) */
64
- allValues: { key: 'step_vals_all', path: 'values', as: 'value' } as const,
65
63
  } as const;
66
64
 
67
65
  type Rec = Record<string, unknown>;
@@ -208,17 +206,17 @@ export function createKitStepHub(): SomaComponentDefinition {
208
206
  },
209
207
  services: ['region', 'data', 'notify'],
210
208
  templateHtml: '<div data-soma-id="root" class="hidden"></div>',
211
- controllerFactory: (ctx: SomaComponentControllerContext) => {
209
+ controllerFactory: createKitController((api) => {
212
210
  let off: (() => void) | undefined;
213
211
  let alive = false;
214
- const props = (): Rec => (ctx.readProps ? ctx.readProps() : ctx.props);
212
+ const props = (): Rec => api.props() as Rec;
215
213
  const steps = (): string[] => strings(props().steps);
216
214
  const dataPort = (): SomaDataPort | undefined => {
217
- const port = (ctx.services as { data?: SomaDataPort } | undefined)?.data;
215
+ const port = (api.services as { data?: SomaDataPort } | undefined)?.data;
218
216
  return port && typeof port === 'object' ? port : undefined;
219
217
  };
220
218
  const toast = (level: string, message: string): void => {
221
- const svc = (ctx.services as { notify?: { toast?: (o: { level: string; message: string }) => void } } | undefined)?.notify;
219
+ const svc = (api.services as { notify?: { toast?: (o: { level: string; message: string }) => void } } | undefined)?.notify;
222
220
  if (svc && typeof svc.toast === 'function') svc.toast({ level, message });
223
221
  };
224
222
 
@@ -235,7 +233,7 @@ export function createKitStepHub(): SomaComponentDefinition {
235
233
  if (cur.seq !== focus.seq) return;
236
234
  if (result.ok) {
237
235
  slice.set({ ...stepFocus(cur.step, cur.total, true, cur.values, cur.seq + 1) });
238
- ctx.emit('saved', { result: result.data ?? {} });
236
+ api.emit('saved', { result: result.data ?? {} });
239
237
  return;
240
238
  }
241
239
  const errors = result.fieldErrors ?? {};
@@ -243,11 +241,11 @@ export function createKitStepHub(): SomaComponentDefinition {
243
241
  const fields = rawFields.map((f) => strings(f));
244
242
  const at = stepOfFirstError(errors, fields);
245
243
  const first = Object.values(errors).find((m) => typeof m === 'string' && m !== '');
246
- const message = first ?? (result.message !== '' ? result.message : kitText('soma.kit.step_failed', undefined, ctx.host));
244
+ const message = first ?? (result.message !== '' ? result.message : kitText('soma.kit.step_failed', undefined, api.host));
247
245
  const back = at >= 0 ? at : cur.step;
248
246
  slice.set(stepFocus(back, cur.total, false, cur.values, cur.seq + 1));
249
- toast('danger', at >= 0 ? kitText('soma.kit.step_n_message', { n: at + 1, message }, ctx.host) : message);
250
- if (back !== cur.step) ctx.emit('step_change', { step: back, total: cur.total });
247
+ toast('danger', at >= 0 ? kitText('soma.kit.step_n_message', { n: at + 1, message }, api.host) : message);
248
+ if (back !== cur.step) api.emit('step_change', { step: back, total: cur.total });
251
249
  };
252
250
 
253
251
  /** perStep:保存一步;成功才前进(末步即完成态),失败停在本步(fieldErrors 指向更早的步则退回那一步),rid 不清 */
@@ -268,15 +266,15 @@ export function createKitStepHub(): SomaComponentDefinition {
268
266
  const rawFields = Array.isArray(props().fields) ? (props().fields as unknown[]) : [];
269
267
  const at = stepOfFirstError(fieldErrors, rawFields.map((f) => strings(f)));
270
268
  const first = Object.values(fieldErrors).find((m) => typeof m === 'string' && m !== '');
271
- const text = first ?? (message !== '' ? message : kitText('soma.kit.step_failed', undefined, ctx.host));
269
+ const text = first ?? (message !== '' ? message : kitText('soma.kit.step_failed', undefined, api.host));
272
270
  const back = at >= 0 ? at : cur.step;
273
271
  slice.set(stepFocus(back, cur.total, false, cur.values, cur.seq + 1, false, cur.rid));
274
- toast('danger', at >= 0 ? kitText('soma.kit.step_n_message', { n: at + 1, message: text }, ctx.host) : text);
275
- if (back !== cur.step) ctx.emit('step_change', { step: back, total: cur.total });
272
+ toast('danger', at >= 0 ? kitText('soma.kit.step_n_message', { n: at + 1, message: text }, api.host) : text);
273
+ if (back !== cur.step) api.emit('step_change', { step: back, total: cur.total });
276
274
  };
277
275
  // 首步没有 rid 用 create,其余(含回到首步改后再下一步)用 update;update 必须带 rid
278
276
  const creating = rid === undefined;
279
- if (creating && job.idx !== 0) { fail(kitText('soma.kit.step_no_id', undefined, ctx.host)); return; }
277
+ if (creating && job.idx !== 0) { fail(kitText('soma.kit.step_no_id', undefined, api.host)); return; }
280
278
  const result = creating
281
279
  ? await data.submit(object, job.model, 'create')
282
280
  : await data.submit(object, { ...job.model, [stepKey]: rid }, 'update', { identityField: stepKey });
@@ -285,14 +283,14 @@ export function createKitStepHub(): SomaComponentDefinition {
285
283
  if (cur.seq !== focus.seq) return; // 保存期间点了「重新开始」:过期回执不写回
286
284
  if (!result.ok) { fail(result.message, result.fieldErrors ?? {}); return; }
287
285
  const got = creating ? pickStepRid(result.data, stepKey) : rid;
288
- if (got === undefined) { fail(kitText('soma.kit.step_no_id', undefined, ctx.host)); return; }
286
+ if (got === undefined) { fail(kitText('soma.kit.step_no_id', undefined, api.host)); return; }
289
287
  if (job.last) {
290
288
  slice.set(stepFocus(cur.step, cur.total, true, cur.values, cur.seq + 1, false, got));
291
- ctx.emit('saved', { result: result.data ?? {}, id: String(got) });
289
+ api.emit('saved', { result: result.data ?? {}, id: String(got) });
292
290
  return;
293
291
  }
294
292
  slice.set(stepFocus(job.idx + 1, cur.total, false, cur.values, cur.seq + 1, false, got));
295
- ctx.emit('step_change', { step: job.idx + 1, total: cur.total });
293
+ api.emit('step_change', { step: job.idx + 1, total: cur.total });
296
294
  };
297
295
 
298
296
  /** abandon: delete:调首步对象已声明的 write.delete,主键取 focus.rid;失败照实 toast,返回是否删成 */
@@ -301,18 +299,18 @@ export function createKitStepHub(): SomaComponentDefinition {
301
299
  const stepKey = typeof props().stepKey === 'string' ? (props().stepKey as string) : '';
302
300
  const first = steps()[0] ?? '';
303
301
  if (!data || focus.rid === undefined || first === '' || stepKey === '') {
304
- toast('danger', kitText('soma.kit.step_abandon_failed', { message: kitText('soma.kit.step_failed', undefined, ctx.host) }, ctx.host));
302
+ toast('danger', kitText('soma.kit.step_abandon_failed', { message: kitText('soma.kit.step_failed', undefined, api.host) }, api.host));
305
303
  return false;
306
304
  }
307
305
  slice.set({ ...focus, busy: true });
308
306
  const result = await data.remove(first, { [stepKey]: focus.rid });
309
307
  if (result.ok) return true;
310
- toast('danger', kitText('soma.kit.step_abandon_failed', { message: result.message !== '' ? result.message : kitText('soma.kit.step_failed', undefined, ctx.host) }, ctx.host));
308
+ toast('danger', kitText('soma.kit.step_abandon_failed', { message: result.message !== '' ? result.message : kitText('soma.kit.step_failed', undefined, api.host) }, api.host));
311
309
  return false;
312
310
  };
313
311
  // 放弃半成品的确认:自绘对话框(异步,danger 色调);无 DOM 时视为同意
314
312
  const askAbandon = (): Promise<boolean> => askKitConfirm({
315
- message: kitText('soma.kit.step_abandon_confirm', undefined, ctx.host), tone: 'danger', at: ctx.host ?? null, whenNoDom: true,
313
+ message: kitText('soma.kit.step_abandon_confirm', undefined, api.host), tone: 'danger', at: api.host ?? null, whenNoDom: true,
316
314
  });
317
315
 
318
316
  /** 中途点「取消」且已保存过:二次确认 -> 删半成品 -> 成功回到初始;失败停在原地(保留状态,可重试或继续填) */
@@ -325,13 +323,12 @@ export function createKitStepHub(): SomaComponentDefinition {
325
323
  if (cur.seq !== focus.seq) return; // 期间点了「重新开始」:过期回执不写回
326
324
  if (!ok) { slice.set({ ...cur, busy: false }); return; }
327
325
  slice.set(initialStepFocus(cur.total, cur.seq + 1));
328
- toast('success', kitText('soma.kit.step_abandoned', undefined, ctx.host));
329
- if (cur.step !== 0) ctx.emit('step_change', { step: 0, total: cur.total });
326
+ toast('success', kitText('soma.kit.step_abandoned', undefined, api.host));
327
+ if (cur.step !== 0) api.emit('step_change', { step: 0, total: cur.total });
330
328
  };
331
329
 
332
330
  /** 离开页面守卫(abandon: delete 且已有半成品、未完成时生效):站内链接二次确认后删半成品再走(删除失败照实报错,不拦离开);刷新 / 关闭只能走浏览器自带提示,来不及异步删除 */
333
331
  let offGuard: (() => void) | undefined;
334
- let offStepValues: (() => void) | undefined;
335
332
  const installLeaveGuard = (slice: NonNullable<ReturnType<SomaRegionPort['slice']>>): void => {
336
333
  if (typeof window === 'undefined' || typeof document === 'undefined') return;
337
334
  const active = (): KitStepFocus | undefined => {
@@ -367,17 +364,14 @@ export function createKitStepHub(): SomaComponentDefinition {
367
364
  };
368
365
 
369
366
  return {
370
- onMount(): void {
367
+ attach() {
371
368
  alive = true;
372
369
  const scope = typeof props().scope === 'string' ? (props().scope as string) : '';
373
- const svc = (ctx.services as { region?: (id: string) => SomaRegionPort | null } | undefined)?.region;
370
+ const svc = (api.services as { region?: (id: string) => SomaRegionPort | null } | undefined)?.region;
374
371
  const port = scope !== '' && typeof svc === 'function' ? svc(scope) : null;
375
372
  const focus = port?.slice('focus');
376
373
  if (!port || !focus) return;
377
374
  focus.set(initialStepFocus(steps().length));
378
- // GB1:登记各步已确认值的读口,request 动作的 $steps.s<i>.<字段> 经它取值
379
- offStepValues?.();
380
- offStepValues = registerKitStepValues(() => focusOf(focus.get(), steps().length).values);
381
375
  offGuard?.();
382
376
  offGuard = undefined;
383
377
  if (props().saveMode === 'perStep' && props().abandon === 'delete') installLeaveGuard(focus);
@@ -387,24 +381,23 @@ export function createKitStepHub(): SomaComponentDefinition {
387
381
  const r = reduceStepHub(now, name, payload, steps(), perStep);
388
382
  if (r.focus !== now) {
389
383
  focus.set(r.focus);
390
- if (r.focus.step !== now.step) ctx.emit('step_change', { step: r.focus.step, total: r.focus.total });
384
+ if (r.focus.step !== now.step) api.emit('step_change', { step: r.focus.step, total: r.focus.total });
391
385
  }
392
386
  if (r.submit !== null) void submit(r.focus, port, r.submit);
393
387
  if (r.save !== null) void saveStep(r.focus, port, r.save);
394
388
  if (r.abort === 'delete' && props().abandon === 'delete') void abandon(focus, r.focus);
395
389
  });
390
+ return () => {
391
+ alive = false;
392
+ offGuard?.();
393
+ offGuard = undefined;
394
+ if (off) off();
395
+ off = undefined;
396
+ };
396
397
  },
397
- onUnmount(): void {
398
- alive = false;
399
- offGuard?.();
400
- offGuard = undefined;
401
- offStepValues?.();
402
- offStepValues = undefined;
403
- if (off) off();
404
- off = undefined;
405
- },
398
+ render() {},
406
399
  };
407
- },
400
+ }),
408
401
  };
409
402
  }
410
403
 
package/src/biz/types.ts CHANGED
@@ -37,10 +37,9 @@ export interface KitOverlayDecl {
37
37
  schema?: KitObject['schema'];
38
38
  }
39
39
 
40
- /** 浮层事件先执行具名动作、成功后再走 then(M1-5):`{ action: 具名动作, then: saved | close | reload }` */
40
+ /** 浮层事件绑具名动作:`{ action: 具名动作 }`(单管道;动作之后的提示 / 重取 / 关窗写在具名动作处理函数里) */
41
41
  export interface KitOverlayEventAction {
42
42
  action: string;
43
- then?: 'saved' | 'close' | 'reload';
44
43
  }
45
44
 
46
45
  export interface KitBizInput {
@@ -66,7 +65,7 @@ export interface KitBizContext {
66
65
  /** 已登记的基础组件名(内置 13 个 + App*) */
67
66
  registeredComponents: ReadonlySet<string>;
68
67
  /** 已登记的写死形状数据组件 */
69
- staticComponents: Record<string, { accept: 'single' | 'list'; emits?: readonly string[]; props?: readonly string[] }>;
68
+ staticComponents: Record<string, { accept: 'single' | 'list'; emits?: readonly string[]; props?: readonly string[]; propTypes?: Readonly<Record<string, string>> }>;
70
69
  /** 页面语言(`page.locale`,缺省应用 defaultLocale;未声明为空串):业务组件写进产物的内置文案按它取(`kitText(key, params, ctx.locale)`) */
71
70
  locale?: string;
72
71
  }
@@ -77,6 +76,8 @@ export interface KitBizRole {
77
76
  views: Array<'list' | 'summary' | 'filter' | 'form'>;
78
77
  /** 对象表(如 `subs.*`):值是「名字 -> 对象」 */
79
78
  many?: boolean;
79
+ /** 该角色下对象声明允许的额外顶层键(如看板面板的 title / span / class、详情主记录的 subsLayout) */
80
+ extraKeys?: readonly string[];
80
81
  }
81
82
 
82
83
  export interface KitBizDefinition {
@@ -0,0 +1,54 @@
1
+ // AP-1(应用代码不直接 import soma-core*)在 kit 线的检查:`soma kit check` 递归扫描应用根下的 js/ts 源码,
2
+ // 命中即报 KIT-APP-013(诊断带文件、行号与改用 soma-kit/app 的建议)。规则册闸门 G84。
3
+ // 跳过:node_modules、.soma、tests/、test/(测试允许 import core 内部名校验产物)与其他点目录、构建产物目录。
4
+ import type { KitDiagnostic } from '../object-renderer/types';
5
+
6
+ const SKIP_DIRS = new Set(['node_modules', 'tests', 'test', 'dist', 'build', 'coverage']);
7
+ /** import / import type / export … from / 动态 import() / require() 里的 soma-core 或 soma-core/* 说明符 */
8
+ const IMPORT_CORE = /(?:\bfrom\s*|\bimport\s*\(?\s*|\brequire\s*\(\s*)['"](soma-core(?:\/[^'"]*)?)['"]/g;
9
+
10
+ /** 扫描应用根目录;返回 KIT-APP-013 诊断(按文件名、行号有序);目录读不到当作空 */
11
+ export async function scanKitCoreImports(appDir: string): Promise<KitDiagnostic[]> {
12
+ const path = await import(/* webpackIgnore: true */ 'node:path');
13
+ const fs = await import(/* webpackIgnore: true */ 'node:fs');
14
+ const root = path.resolve(appDir);
15
+ const out: KitDiagnostic[] = [];
16
+ const walk = (dir: string): void => {
17
+ let entries: import('node:fs').Dirent[];
18
+ try {
19
+ entries = fs.readdirSync(dir, { withFileTypes: true });
20
+ } catch {
21
+ return;
22
+ }
23
+ for (const e of entries.sort((a, b) => a.name.localeCompare(b.name))) {
24
+ const full = path.join(dir, e.name);
25
+ if (e.isDirectory()) {
26
+ if (!SKIP_DIRS.has(e.name) && !e.name.startsWith('.')) walk(full);
27
+ continue;
28
+ }
29
+ if (!/\.[cm]?[jt]sx?$/.test(e.name) || /\.d\.[cm]?ts$/.test(e.name)) continue;
30
+ let text: string;
31
+ try {
32
+ text = fs.readFileSync(full, 'utf8');
33
+ } catch {
34
+ continue;
35
+ }
36
+ const file = path.relative(root, full).split(path.sep).join('/');
37
+ text.split('\n').forEach((lineText, i) => {
38
+ for (const m of lineText.matchAll(IMPORT_CORE)) {
39
+ out.push({
40
+ code: 'KIT-APP-013',
41
+ path: `${file}:${i + 1}`,
42
+ file,
43
+ line: i + 1,
44
+ column: (m.index ?? 0) + 1,
45
+ message: `应用代码直接 import '${m[1]}'(AP-1:应用不直接依赖 soma-core*)`,
46
+ hint: `改为从 'soma-kit/app' 取用(装配名字在 soma-kit/app,服务端名字在 soma-kit/app/server)`,
47
+ });
48
+ }
49
+ });
50
+ }
51
+ };
52
+ walk(root);
53
+ return out;
54
+ }