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