soma-kit 0.1.11 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +106 -112
- package/bin/soma-kit.mjs +32 -2
- package/bin/soma.mjs +22 -0
- package/package.json +14 -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 +929 -37
- package/spec/generated/kit-page.schema.json +1684 -161
- package/spec/kit-grammar.json +1176 -584
- package/spec/kit-grammar.schema.json +1971 -393
- package/src/app/app-config.ts +449 -347
- package/src/app/component-gate.ts +283 -28
- package/src/app/compose-apps.ts +79 -8
- package/src/app/define-kit-actions.ts +245 -41
- package/src/app/define-kit-app.ts +176 -33
- package/src/app/define-kit-view.ts +104 -0
- package/src/app/dev-diagnostic.ts +5 -0
- package/src/app/envelope.ts +1 -161
- package/src/app/index.ts +29 -6
- package/src/app/kit-view-context.ts +439 -0
- package/src/app/notify-renderer.ts +1 -115
- package/src/app/paged-list-adapter.ts +1 -240
- package/src/app/render-ports.ts +18 -0
- package/src/app/server-pages.ts +11 -3
- package/src/app/server.ts +530 -103
- 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 +667 -0
- package/src/base/action-busy.ts +103 -6
- package/src/base/action-gate.ts +4 -255
- package/src/base/action-slots.ts +58 -0
- package/src/base/alert.ts +5 -3
- package/src/base/anchored-layer.ts +50 -0
- package/src/base/avatar.ts +2 -2
- package/src/base/button.ts +99 -37
- package/src/base/cascader.ts +11 -12
- package/src/base/check-core.ts +9 -1
- package/src/base/checkbox.ts +2 -1
- package/src/base/choice.ts +49 -28
- package/src/base/class-candidates.ts +17 -0
- package/src/base/color-picker.ts +16 -11
- package/src/base/combobox.ts +5 -3
- package/src/base/command-palette.ts +10 -6
- package/src/base/context-menu.ts +10 -7
- package/src/base/countdown.ts +1 -1
- package/src/base/date-range.ts +32 -18
- package/src/base/date.ts +135 -28
- package/src/base/delta.ts +72 -0
- package/src/base/divider.ts +2 -2
- package/src/base/end-edge.ts +49 -0
- package/src/base/fab.ts +12 -5
- package/src/base/gap-value.ts +148 -0
- package/src/base/hint-tips.ts +170 -0
- package/src/base/icons.ts +8 -0
- package/src/base/illustrations.ts +94 -0
- package/src/base/image.ts +1 -1
- package/src/base/index.ts +35 -11
- 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 +56 -35
- package/src/base/loading-gate.ts +186 -0
- package/src/base/mentions.ts +7 -6
- package/src/base/menu-button.ts +28 -12
- package/src/base/menu-core.ts +41 -8
- package/src/base/motion/aura.ts +2 -2
- package/src/base/motion/hover-3d.ts +3 -3
- package/src/base/motion/hover-gallery.ts +2 -2
- package/src/base/motion/marquee.ts +3 -3
- package/src/base/motion/text-rotate.ts +2 -2
- package/src/base/number.ts +93 -80
- package/src/base/otp.ts +9 -5
- package/src/base/overlay-runtime.ts +235 -0
- package/src/base/permission-gate.ts +6 -0
- package/src/base/popover.ts +48 -16
- package/src/base/popup.ts +143 -19
- package/src/base/portal-core.ts +4 -0
- 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 +14 -8
- package/src/base/radio.ts +2 -1
- package/src/base/range.ts +21 -4
- package/src/base/rating.ts +12 -7
- package/src/base/reason-tip.ts +150 -0
- package/src/base/segmented.ts +27 -21
- package/src/base/select.ts +4 -3
- package/src/base/shared.ts +387 -49
- package/src/base/state-panel.ts +346 -0
- package/src/base/status-tone.ts +27 -0
- package/src/base/sticky-edge.ts +116 -0
- package/src/base/swap.ts +10 -7
- package/src/base/switch.ts +11 -6
- package/src/base/tag-input.ts +20 -16
- package/src/base/tag.ts +68 -34
- package/src/base/text.ts +80 -18
- package/src/base/textarea.ts +37 -11
- package/src/base/time-picker.ts +18 -13
- package/src/base/tree-select.ts +21 -12
- package/src/base/trend-tone.ts +9 -0
- package/src/base/upload.ts +48 -14
- package/src/base/view-transition.ts +77 -0
- package/src/base/virtual-list.ts +107 -1
- package/src/biz/approval-desk/compile.ts +23 -41
- package/src/biz/approval-desk/shell.ts +11 -8
- package/src/biz/auth-panel/compile.ts +37 -52
- package/src/biz/auth-panel/index.ts +1 -1
- package/src/biz/auth-panel/shell.ts +5 -4
- package/src/biz/category-crud/compile.ts +23 -37
- package/src/biz/category-crud/shell.ts +2 -1
- package/src/biz/checkout-page/compile.ts +22 -5
- package/src/biz/checkout-page/shell.ts +4 -3
- 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 +5 -4
- package/src/biz/index.ts +3 -3
- package/src/biz/landing-page/compile.ts +19 -3
- package/src/biz/link/hub.ts +69 -22
- package/src/biz/link/shared.ts +127 -119
- package/src/biz/master-sub/compile.ts +127 -48
- package/src/biz/master-sub/index.ts +5 -2
- package/src/biz/master-sub/shell.ts +95 -18
- package/src/biz/multi-board/compile.ts +38 -50
- package/src/biz/multi-board/index.ts +18 -1
- package/src/biz/multi-board/shell.ts +32 -20
- package/src/biz/notification-center/compile.ts +21 -33
- package/src/biz/notification-center/shell.ts +6 -4
- 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/result-page/shell.ts +2 -1
- package/src/biz/page-templates/shared.ts +34 -36
- package/src/biz/page-templates/sign-in-page/shell.ts +2 -2
- package/src/biz/record-detail/compile.ts +48 -43
- package/src/biz/record-detail/index.ts +11 -1
- package/src/biz/record-detail/shell.ts +8 -6
- package/src/biz/settings-center/compile.ts +7 -5
- package/src/biz/settings-center/shell.ts +6 -4
- package/src/biz/shared/action-host.ts +97 -211
- package/src/biz/shared/compile-helpers.ts +98 -0
- package/src/biz/shared/coordinator.ts +472 -92
- package/src/biz/shared/index.ts +13 -2
- package/src/biz/shared/object-aliases.ts +154 -0
- package/src/biz/shared/overlay-compile.ts +239 -0
- package/src/biz/shared/overlay-shell.ts +209 -0
- package/src/biz/shared/pipes.ts +50 -31
- package/src/biz/shared/remove-wire.ts +14 -0
- package/src/biz/shared/runtime-hub.ts +226 -24
- package/src/biz/single-form/compile.ts +16 -37
- package/src/biz/single-form/shell.ts +4 -3
- package/src/biz/standard-crud/compile.ts +72 -255
- package/src/biz/standard-crud/shell.ts +21 -99
- package/src/biz/step-form/compile.ts +26 -97
- package/src/biz/step-form/hub.ts +34 -41
- package/src/biz/step-form/shell.ts +5 -5
- package/src/biz/types.ts +4 -3
- package/src/cli/core-imports.ts +54 -0
- package/src/cli/kit-cli.ts +254 -25
- package/src/cli/kit-init.ts +227 -0
- package/src/cli/layout-cli.ts +167 -0
- package/src/cli/migrate/index.ts +10 -0
- package/src/cli/migrate/migrate.ts +248 -0
- package/src/cli/migrate/text-utils.ts +306 -0
- package/src/cli/migrate/theme-map.ts +104 -0
- package/src/cli/migrate/ts-rules.ts +235 -0
- package/src/cli/migrate/types.ts +95 -0
- package/src/cli/migrate/view-skeleton.ts +159 -0
- package/src/cli/migrate/yaml-report.ts +376 -0
- package/src/cli/migrate/yaml-rules.ts +465 -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 +761 -0
- package/src/compile/action-host-attach.ts +21 -29
- package/src/compile/closed-set.ts +570 -0
- package/src/compile/compile-page.ts +267 -76
- package/src/compile/component-candidates.ts +13 -2
- 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/layout-lint/engine.ts +82 -0
- package/src/compile/layout-lint/index.ts +55 -0
- package/src/compile/layout-lint/rules-composition.ts +218 -0
- package/src/compile/layout-lint/rules-form.ts +192 -0
- package/src/compile/layout-lint/rules-table.ts +194 -0
- package/src/compile/layout-lint/score.ts +52 -0
- package/src/compile/layout-lint/types.ts +51 -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/remove-guard.ts +10 -7
- package/src/compile/styles.ts +63 -2
- package/src/compile/types.ts +31 -3
- package/src/compile/view-check.ts +284 -0
- package/src/data/amount-breakdown.ts +8 -3
- package/src/data/anchor-nav.ts +2 -2
- package/src/data/approval-flow.ts +3 -3
- package/src/data/assignment-picker.ts +92 -55
- package/src/data/async-result-panel.ts +111 -9
- package/src/data/breadcrumbs.ts +5 -4
- package/src/data/calendar.ts +24 -27
- package/src/data/carousel.ts +13 -8
- package/src/data/chart.ts +183 -44
- package/src/data/checklist.ts +20 -7
- package/src/data/code-view.ts +12 -6
- package/src/data/comment-thread.ts +7 -4
- package/src/data/confirm-dialog.ts +81 -18
- 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 +3 -3
- package/src/data/embed.ts +233 -30
- package/src/data/field-mapper.ts +35 -30
- package/src/data/flow-editor-contract.ts +8 -1
- package/src/data/flow-editor.ts +113 -108
- package/src/data/flow-node-options.ts +120 -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 +19 -19
- package/src/data/hero.ts +4 -3
- package/src/data/image-viewer.ts +27 -30
- package/src/data/index.ts +5 -2
- package/src/data/item-list.ts +48 -31
- package/src/data/kanban.ts +82 -52
- package/src/data/media-grid.ts +20 -20
- package/src/data/mega-menu.ts +6 -4
- package/src/data/menu-dom.ts +4 -2
- package/src/data/menu.ts +47 -15
- package/src/data/mockup.ts +10 -6
- package/src/data/modal-dialog.ts +49 -25
- package/src/data/navbar.ts +12 -7
- package/src/data/notice-list.ts +268 -0
- package/src/data/notify-renderer.ts +250 -0
- package/src/data/object-form.ts +1360 -666
- package/src/data/outcome-watch.ts +61 -2
- package/src/data/pager.ts +80 -34
- package/src/data/permission-matrix.ts +52 -31
- package/src/data/permission-tree.ts +71 -44
- package/src/data/pricing-table.ts +30 -14
- package/src/data/prompt-dialog.ts +124 -194
- package/src/data/reaction-bar.ts +83 -92
- package/src/data/read-rollback.ts +73 -0
- package/src/data/record-card.ts +26 -5
- package/src/data/record-picker.ts +104 -55
- 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 +8 -4
- package/src/data/rich-text.ts +61 -55
- package/src/data/row-editor.ts +362 -76
- package/src/data/rule-builder.ts +26 -20
- package/src/data/shape-util.ts +27 -9
- package/src/data/stat-group.ts +392 -109
- package/src/data/static-lazy.ts +1 -0
- package/src/data/static-registry.ts +24 -11
- package/src/data/steps.ts +10 -5
- package/src/data/survey.ts +27 -32
- package/src/data/system-switcher.ts +3 -3
- package/src/data/text-action-button.ts +17 -0
- package/src/data/timeline.ts +19 -8
- package/src/data/tour-guide.ts +23 -30
- package/src/data/transfer.ts +62 -38
- package/src/data/tree-table.ts +152 -78
- package/src/data/tree.ts +49 -36
- package/src/data/trend-line.ts +6 -24
- package/src/data/virtual-rows.ts +133 -82
- package/src/data/watermark.ts +2 -2
- package/src/data/wrap.ts +63 -38
- package/src/data/wrapped-candidates.ts +10 -0
- package/src/frames/blank-frame.ts +1 -0
- package/src/frames/index.ts +2 -2
- package/src/frames/page-bar.ts +26 -24
- package/src/frames/page-header.ts +14 -5
- package/src/frames/page-status.ts +9 -7
- package/src/frames/shared.ts +36 -25
- package/src/frames/single-frame.ts +1 -0
- package/src/frames/split-frame/shell.ts +6 -6
- package/src/frames/split-frame/wiring.ts +2 -2
- package/src/frames/tabs-frame/shell.ts +4 -14
- package/src/frames/tabs-frame/wiring.ts +5 -8
- package/src/frames/top-main-frame.ts +3 -2
- package/src/frames/types.ts +13 -2
- package/src/frames/workspace-frame/extras.ts +21 -5
- package/src/frames/workspace-frame/index.ts +1 -1
- package/src/frames/workspace-frame/shell.ts +3 -2
- package/src/frames/workspace-frame/state.ts +13 -6
- package/src/frames/workspace-frame/view.ts +250 -48
- package/src/generated/kit-grammar-runtime.ts +645 -397
- package/src/generated/page-origin.ts +0 -11
- package/src/i18n/kit-text.ts +84 -29
- package/src/i18n/resolve-text-refs.ts +22 -6
- package/src/index.ts +2 -1
- package/src/object-renderer/action-gate.ts +11 -147
- package/src/object-renderer/arrange.ts +112 -84
- 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 +401 -104
- package/src/object-renderer/collection-table.ts +287 -45
- package/src/object-renderer/collection.ts +258 -104
- package/src/object-renderer/compile-data.ts +112 -102
- package/src/object-renderer/crud-bridge.ts +32 -0
- package/src/object-renderer/defaults.ts +38 -16
- package/src/object-renderer/display-checks.ts +4 -25
- package/src/object-renderer/emit-events.ts +224 -176
- package/src/object-renderer/emit-object.ts +15 -2
- package/src/object-renderer/emit-static.ts +533 -151
- 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 +111 -2
- package/src/object-renderer/form-notify.ts +45 -0
- package/src/object-renderer/index.ts +26 -0
- package/src/object-renderer/key-field.ts +12 -0
- package/src/object-renderer/layout-facts.ts +386 -0
- package/src/object-renderer/layout-plan.ts +132 -0
- package/src/object-renderer/layout-plan.types.ts +22 -0
- package/src/object-renderer/linkage.ts +7 -270
- package/src/object-renderer/merge-class.ts +18 -1
- package/src/object-renderer/parts.ts +252 -1
- package/src/object-renderer/path-pick.ts +27 -0
- package/src/object-renderer/render-object.ts +456 -89
- package/src/object-renderer/request-actions.ts +232 -249
- package/src/object-renderer/skeleton.ts +58 -19
- package/src/object-renderer/table-actions.ts +319 -111
- package/src/object-renderer/table-summary.ts +2 -2
- package/src/object-renderer/table-tools.ts +429 -94
- package/src/object-renderer/types.ts +204 -127
- package/src/object-renderer/view-binding.ts +393 -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 +165 -28
- package/src/page-target/target.ts +262 -51
- package/src/page-target/writer-policy.ts +14 -3
- package/src/recipes/container.ts +210 -0
- package/src/recipes/control.ts +277 -0
- package/src/recipes/index.ts +312 -0
- package/src/recipes/nowrap.ts +16 -0
- package/src/recipes/overlay.ts +240 -0
- package/src/recipes/placeholder.ts +79 -0
- package/src/recipes/rail-grid.ts +45 -0
- package/src/recipes/slot-align.ts +56 -0
- package/src/recipes/state.ts +99 -0
- package/src/recipes/status.ts +139 -0
- package/src/recipes/surface.ts +40 -0
- package/src/recipes/table-row.ts +88 -0
- package/src/recipes/title-row.ts +37 -0
- package/src/recipes/typography.ts +99 -0
- package/src/shared/action-field-guard.ts +41 -0
- package/src/shared/confirm-decl.ts +118 -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 +15 -0
- package/src/shared/path-guard.ts +127 -0
- package/src/shared/theme-runtime-shared.ts +180 -0
- package/src/shared/view-info.ts +10 -0
- package/src/theme/index.ts +13 -0
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +407 -10
- package/src/theme/kit-theme.tpl +407 -10
- package/src/theme/nine-dim-structure.ts +247 -0
- package/src/theme/surface-layers.ts +101 -0
- package/src/theme/theme-tokens.ts +130 -84
- package/src/theme/theme-types.ts +103 -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/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 -1473
package/src/app/app-config.ts
CHANGED
|
@@ -1,226 +1,76 @@
|
|
|
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';
|
|
6
|
+
import { KIT_LAYOUT_VERSIONS, normalizeLayoutPin } from '../object-renderer/layout-plan';
|
|
5
7
|
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
export
|
|
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
|
-
}
|
|
8
|
+
export type {
|
|
9
|
+
KitThemePalette,
|
|
10
|
+
KitThemeColorDepth,
|
|
11
|
+
KitThemeColorSaturation,
|
|
12
|
+
KitThemeFontFamily,
|
|
13
|
+
KitThemeFontScale,
|
|
14
|
+
KitThemeBoundary,
|
|
15
|
+
KitThemeShape,
|
|
16
|
+
KitThemeSurfaceTexture,
|
|
17
|
+
KitThemeDensity,
|
|
18
|
+
KitThemeMotion,
|
|
19
|
+
KitThemeTableStyle,
|
|
20
|
+
KitThemeContrast,
|
|
21
|
+
KitThemeAccentUsage,
|
|
22
|
+
KitThemePreset,
|
|
23
|
+
KitAppTheme,
|
|
24
|
+
} from '../theme/theme-types';
|
|
25
|
+
export {
|
|
26
|
+
KIT_THEME_PALETTES,
|
|
27
|
+
KIT_THEME_COLOR_DEPTHS,
|
|
28
|
+
KIT_THEME_COLOR_SATURATIONS,
|
|
29
|
+
KIT_THEME_FONT_FAMILIES,
|
|
30
|
+
KIT_THEME_FONT_SCALES,
|
|
31
|
+
KIT_THEME_BOUNDARIES,
|
|
32
|
+
KIT_THEME_SHAPES,
|
|
33
|
+
KIT_THEME_SURFACE_TEXTURES,
|
|
34
|
+
KIT_THEME_DENSITIES,
|
|
35
|
+
KIT_THEME_MOTIONS,
|
|
36
|
+
KIT_THEME_TABLE_STYLES,
|
|
37
|
+
KIT_THEME_CONTRASTS,
|
|
38
|
+
KIT_THEME_ACCENT_USAGES,
|
|
39
|
+
KIT_THEME_PRESETS,
|
|
40
|
+
} from '../theme/theme-types';
|
|
41
|
+
import {
|
|
42
|
+
KIT_THEME_PALETTES,
|
|
43
|
+
KIT_THEME_COLOR_DEPTHS,
|
|
44
|
+
KIT_THEME_COLOR_SATURATIONS,
|
|
45
|
+
KIT_THEME_FONT_FAMILIES,
|
|
46
|
+
KIT_THEME_FONT_SCALES,
|
|
47
|
+
KIT_THEME_BOUNDARIES,
|
|
48
|
+
KIT_THEME_SHAPES,
|
|
49
|
+
KIT_THEME_SURFACE_TEXTURES,
|
|
50
|
+
KIT_THEME_DENSITIES,
|
|
51
|
+
KIT_THEME_MOTIONS,
|
|
52
|
+
KIT_THEME_TABLE_STYLES,
|
|
53
|
+
KIT_THEME_CONTRASTS,
|
|
54
|
+
KIT_THEME_ACCENT_USAGES,
|
|
55
|
+
KIT_THEME_PRESETS,
|
|
56
|
+
type KitThemeAccentUsage,
|
|
57
|
+
type KitThemePreset,
|
|
58
|
+
type KitThemeMotion,
|
|
59
|
+
type KitThemeTableStyle,
|
|
60
|
+
type KitThemeContrast,
|
|
61
|
+
type KitThemePalette,
|
|
62
|
+
type KitThemeColorDepth,
|
|
63
|
+
type KitThemeColorSaturation,
|
|
64
|
+
type KitThemeFontFamily,
|
|
65
|
+
type KitThemeFontScale,
|
|
66
|
+
type KitThemeBoundary,
|
|
67
|
+
type KitThemeShape,
|
|
68
|
+
type KitThemeSurfaceTexture,
|
|
69
|
+
type KitThemeDensity,
|
|
70
|
+
type KitAppTheme,
|
|
71
|
+
} from '../theme/theme-types';
|
|
72
|
+
import { KIT_THEME_MODES } from '../theme/theme-tokens';
|
|
73
|
+
export { KIT_THEME_MODES };
|
|
224
74
|
|
|
225
75
|
export interface KitAppLayoutNavItem {
|
|
226
76
|
id: string;
|
|
@@ -250,11 +100,22 @@ export interface KitAppLayout {
|
|
|
250
100
|
};
|
|
251
101
|
}
|
|
252
102
|
|
|
103
|
+
export interface KitDictOption {
|
|
104
|
+
value: string | number | boolean;
|
|
105
|
+
label: string;
|
|
106
|
+
tone?: string;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export type KitAppDicts = Record<string, KitDictOption[]>;
|
|
110
|
+
export type KitAppEntities = Record<string, Record<string, unknown>>;
|
|
111
|
+
|
|
253
112
|
export interface KitAppConfig {
|
|
254
113
|
/** 主题:9 维正交页面主题 DSL 规格或基础方案 */
|
|
255
114
|
theme?: KitAppTheme;
|
|
256
115
|
/** 默认页面布局配置:继承给子页面 */
|
|
257
116
|
layout?: KitAppLayout;
|
|
117
|
+
/** 布局规则版本钉(`layout.rules`,RV-1117):缺省 0 = 现状 12 份均分,输出逐字节不变;只写 rules 不算启用外框继承 */
|
|
118
|
+
layoutRules?: number;
|
|
258
119
|
/** 主题头文件路径(相对应用根);缺省用内置 kit-theme.css */
|
|
259
120
|
style?: string;
|
|
260
121
|
/** 应用扩展的基础组件:名字 -> 说明 */
|
|
@@ -263,10 +124,17 @@ export interface KitAppConfig {
|
|
|
263
124
|
staticObjectComponents: Record<string, { accept: 'single' | 'list'; desc: string }>;
|
|
264
125
|
/** 业务信封约定(失败判定 / 业务文案位置 / 数据位置):声明一次,编译与运行时共读;页面 page.envelope 可覆写 */
|
|
265
126
|
envelope?: KitEnvelope;
|
|
127
|
+
/** 应用级共享枚举字典(供页面 schema 字段 options: '$dict.<name>' 编译期静态展开) */
|
|
128
|
+
dicts?: KitAppDicts;
|
|
129
|
+
/** 应用级共享实体字段定义(供页面对象 schema: '$entity.<name>' 或 { $ref: '$entity.<name>', pick?, omit?, override? } 编译期静态展开) */
|
|
130
|
+
entities?: KitAppEntities;
|
|
266
131
|
}
|
|
267
132
|
|
|
268
133
|
const APP_NAME = /^App[A-Z][A-Za-z0-9]*$/;
|
|
269
|
-
const TOP_KEYS = ['style', 'theme', 'layout', 'baseComponents', 'staticObjectComponents', 'envelope'];
|
|
134
|
+
const TOP_KEYS = ['style', 'theme', 'layout', 'baseComponents', 'staticObjectComponents', 'envelope', 'dicts', 'entities', 'app'];
|
|
135
|
+
const APP_SUB_KEYS = ['style', 'theme', 'layout', 'envelope', 'dicts', 'entities'];
|
|
136
|
+
const DICT_OPTION_KEYS = ['value', 'label', 'tone'];
|
|
137
|
+
const ENTITY_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
270
138
|
const THEME_KEYS = [
|
|
271
139
|
'palette',
|
|
272
140
|
'color_depth',
|
|
@@ -282,25 +150,69 @@ const THEME_KEYS = [
|
|
|
282
150
|
'surface_texture',
|
|
283
151
|
'surfaceTexture',
|
|
284
152
|
'density',
|
|
153
|
+
'motion',
|
|
154
|
+
'table_style',
|
|
155
|
+
'tableStyle',
|
|
156
|
+
'contrast',
|
|
157
|
+
'accent_usage',
|
|
158
|
+
'accentUsage',
|
|
285
159
|
'preset',
|
|
286
|
-
'polarity',
|
|
287
|
-
'radius',
|
|
288
160
|
'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
161
|
];
|
|
162
|
+
/**
|
|
163
|
+
* 已删除的旧主题链键(库配色方案、库字体方案、品牌色号与旧布局/样式键):只用于报 KIT-APP-002 迁移诊断,不再解析、不留兼容。
|
|
164
|
+
* 键 -> 迁移指引(改用九维对应维度)。
|
|
165
|
+
*/
|
|
166
|
+
export const REMOVED_THEME_KEYS: Readonly<Record<string, string>> = {
|
|
167
|
+
palette_scheme: `改用九维 palette(行业配色枚举,如 ${KIT_THEME_PALETTES[0]}),配色深浅与饱和度用 color_depth / color_saturation`,
|
|
168
|
+
paletteScheme: `改用九维 palette(行业配色枚举,如 ${KIT_THEME_PALETTES[0]}),配色深浅与饱和度用 color_depth / color_saturation`,
|
|
169
|
+
font_scheme: `改用九维 font_family(字体枚举,如 ${KIT_THEME_FONT_FAMILIES[0]})与 font_scale(字号行距档)`,
|
|
170
|
+
fontScheme: `改用九维 font_family(字体枚举,如 ${KIT_THEME_FONT_FAMILIES[0]})与 font_scale(字号行距档)`,
|
|
171
|
+
color: '品牌色号不再支持:改用九维 palette 选一套人工精调配色,配合 color_depth / color_saturation 调深浅与饱和度',
|
|
172
|
+
polarity: '改用 mode(light / dark / soft / system)',
|
|
173
|
+
radius: '改用九维 shape',
|
|
174
|
+
color_scheme: '改用九维 palette 配合 color_depth / color_saturation',
|
|
175
|
+
colorScheme: '改用九维 palette 配合 color_depth / color_saturation',
|
|
176
|
+
tone: '改用九维 palette 配合 color_depth / color_saturation',
|
|
177
|
+
typography_scheme: '改用九维 font_family 与 font_scale',
|
|
178
|
+
typographyScheme: '改用九维 font_family 与 font_scale',
|
|
179
|
+
component_style: '改用九维 boundary 与 surface_texture',
|
|
180
|
+
componentStyle: '改用九维 boundary 与 surface_texture',
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* 已删除的主题取值(维度 -> 旧值 -> 迁移指引):取值域校验命中时给出清晰的迁移诊断,不留兼容别名。
|
|
185
|
+
*/
|
|
186
|
+
export const REMOVED_THEME_VALUES: Readonly<Record<string, Readonly<Record<string, string>>>> = {
|
|
187
|
+
surface_texture: { FROSTED_CHROME: '已合并为 GLASS_CHROME(顶栏与悬浮层毛玻璃,带不透明回退),请改写 GLASS_CHROME' },
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* 校验主题对象中的已删除旧键(palette_scheme/paletteScheme/font_scheme/fontScheme/color 等),
|
|
192
|
+
* 命中即推入 KIT-APP-002 迁移诊断。
|
|
193
|
+
*/
|
|
194
|
+
export function checkRemovedThemeKeys(
|
|
195
|
+
rawTheme: unknown,
|
|
196
|
+
pathPrefix: string = 'theme',
|
|
197
|
+
diagnostics: KitDiagnostic[] = [],
|
|
198
|
+
keyPathResolver?: (key: string) => string,
|
|
199
|
+
): KitDiagnostic[] {
|
|
200
|
+
if (rawTheme === null || typeof rawTheme !== 'object' || Array.isArray(rawTheme)) return diagnostics;
|
|
201
|
+
for (const k of Object.keys(rawTheme)) {
|
|
202
|
+
const removedHint = Object.prototype.hasOwnProperty.call(REMOVED_THEME_KEYS, k) ? REMOVED_THEME_KEYS[k] : undefined;
|
|
203
|
+
if (removedHint !== undefined) {
|
|
204
|
+
const kp = keyPathResolver !== undefined ? keyPathResolver(k) : (pathPrefix !== '' ? `${pathPrefix}.${k}` : k);
|
|
205
|
+
diagnostics.push({
|
|
206
|
+
code: 'KIT-APP-002',
|
|
207
|
+
path: kp,
|
|
208
|
+
message: `theme.${k} 已删除(kit 主题只支持九维 palette / color_depth / color_saturation / font_family / font_scale / boundary / shape / surface_texture / density + 扩展维度 motion / table_style / contrast / accent_usage + 预设 preset + mode):${removedHint}`,
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return diagnostics;
|
|
213
|
+
}
|
|
302
214
|
const STATIC_KEYS = ['accept', 'desc'];
|
|
303
|
-
const LAYOUT_TOP_KEYS = ['frame', 'max_width', 'sticky_header', 'header', 'sidebar', 'footer'];
|
|
215
|
+
const LAYOUT_TOP_KEYS = ['frame', 'max_width', 'sticky_header', 'header', 'sidebar', 'footer', 'rules'];
|
|
304
216
|
const MAX_WIDTH_VALUES = ['narrow', 'medium', 'wide', 'full'] as const;
|
|
305
217
|
const LAYOUT_HEADER_KEYS = ['brand', 'nav', 'actions'];
|
|
306
218
|
const LAYOUT_SIDEBAR_KEYS = ['title', 'width', 'menu'];
|
|
@@ -317,6 +229,45 @@ function bad(path: string, message: string, out: KitDiagnostic[]): void {
|
|
|
317
229
|
out.push({ code: 'KIT-APP-001', path, message });
|
|
318
230
|
}
|
|
319
231
|
|
|
232
|
+
function resolveAppSection(
|
|
233
|
+
raw: Record<string, unknown>,
|
|
234
|
+
appBlock: Record<string, unknown> | undefined,
|
|
235
|
+
key: (typeof APP_SUB_KEYS)[number],
|
|
236
|
+
): { value: unknown; pathPrefix: string; keyPathOf: (subKey: string) => string } {
|
|
237
|
+
const topVal = raw[key];
|
|
238
|
+
const appVal = appBlock?.[key];
|
|
239
|
+
if (isRecord(topVal) && isRecord(appVal)) {
|
|
240
|
+
return {
|
|
241
|
+
value: { ...topVal, ...appVal },
|
|
242
|
+
pathPrefix: `kit.app.yaml.app.${key}`,
|
|
243
|
+
keyPathOf: (subKey: string) =>
|
|
244
|
+
Object.prototype.hasOwnProperty.call(appVal, subKey)
|
|
245
|
+
? `kit.app.yaml.app.${key}.${subKey}`
|
|
246
|
+
: `kit.app.yaml.${key}.${subKey}`,
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
if (topVal === undefined && appVal !== undefined) {
|
|
250
|
+
return {
|
|
251
|
+
value: appVal,
|
|
252
|
+
pathPrefix: `kit.app.yaml.app.${key}`,
|
|
253
|
+
keyPathOf: (subKey: string) => `kit.app.yaml.app.${key}.${subKey}`,
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
if (appVal !== undefined && !isRecord(appVal) && isRecord(topVal)) {
|
|
257
|
+
return {
|
|
258
|
+
value: appVal,
|
|
259
|
+
pathPrefix: `kit.app.yaml.app.${key}`,
|
|
260
|
+
keyPathOf: (subKey: string) => `kit.app.yaml.app.${key}.${subKey}`,
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
return {
|
|
264
|
+
value: topVal !== undefined ? topVal : appVal,
|
|
265
|
+
pathPrefix: topVal !== undefined ? `kit.app.yaml.${key}` : `kit.app.yaml.app.${key}`,
|
|
266
|
+
keyPathOf: (subKey: string) =>
|
|
267
|
+
topVal !== undefined ? `kit.app.yaml.${key}.${subKey}` : `kit.app.yaml.app.${key}.${subKey}`,
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
|
|
320
271
|
function parseNavItem(raw: unknown, path: string, diagnostics: KitDiagnostic[]): KitAppLayoutNavItem | undefined {
|
|
321
272
|
if (!isRecord(raw)) {
|
|
322
273
|
bad(path, `${path} 必须是对象 { id, label, href?, url?, icon? }`, diagnostics);
|
|
@@ -334,13 +285,23 @@ function parseNavItem(raw: unknown, path: string, diagnostics: KitDiagnostic[]):
|
|
|
334
285
|
return undefined;
|
|
335
286
|
}
|
|
336
287
|
const item: KitAppLayoutNavItem = { id: raw.id.trim(), label: raw.label.trim() };
|
|
288
|
+
if (raw.path !== undefined) {
|
|
289
|
+
if (typeof raw.path === 'string') checkNoRelativeOrSystemPath(raw.path, `${path}.path`, diagnostics, 'KIT-APP-001');
|
|
290
|
+
else bad(`${path}.path`, 'path 必须是字符串', diagnostics);
|
|
291
|
+
}
|
|
337
292
|
if (raw.href !== undefined) {
|
|
338
|
-
if (typeof raw.href === 'string')
|
|
339
|
-
|
|
293
|
+
if (typeof raw.href === 'string') {
|
|
294
|
+
if (checkNoRelativeOrSystemPath(raw.href, `${path}.href`, diagnostics, 'KIT-APP-001', { allowExternalHref: true })) {
|
|
295
|
+
item.href = raw.href;
|
|
296
|
+
}
|
|
297
|
+
} else bad(`${path}.href`, 'href 必须是字符串', diagnostics);
|
|
340
298
|
}
|
|
341
299
|
if (raw.url !== undefined) {
|
|
342
|
-
if (typeof raw.url === 'string')
|
|
343
|
-
|
|
300
|
+
if (typeof raw.url === 'string') {
|
|
301
|
+
if (checkNoRelativeOrSystemPath(raw.url, `${path}.url`, diagnostics, 'KIT-APP-001')) {
|
|
302
|
+
item.url = raw.url;
|
|
303
|
+
}
|
|
304
|
+
} else bad(`${path}.url`, 'url 必须是字符串', diagnostics);
|
|
344
305
|
}
|
|
345
306
|
if (raw.icon !== undefined) {
|
|
346
307
|
if (typeof raw.icon === 'string') item.icon = raw.icon;
|
|
@@ -360,178 +321,230 @@ export function parseAppConfig(raw: unknown, diagnostics: KitDiagnostic[]): KitA
|
|
|
360
321
|
for (const k of Object.keys(raw)) {
|
|
361
322
|
if (!TOP_KEYS.includes(k)) bad(`kit.app.yaml.${k}`, `未知键 ${k}(允许:${TOP_KEYS.join(' / ')})`, diagnostics);
|
|
362
323
|
}
|
|
363
|
-
if (raw.
|
|
364
|
-
if (
|
|
365
|
-
|
|
324
|
+
if (raw.app !== undefined) {
|
|
325
|
+
if (!isRecord(raw.app)) {
|
|
326
|
+
bad('kit.app.yaml.app', 'app 必须是对象', diagnostics);
|
|
327
|
+
} else {
|
|
328
|
+
for (const k of Object.keys(raw.app)) {
|
|
329
|
+
if (!APP_SUB_KEYS.includes(k)) bad(`kit.app.yaml.app.${k}`, `未知键 ${k}(允许:${APP_SUB_KEYS.join(' / ')})`, diagnostics);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
const appBlock = isRecord(raw.app) ? raw.app : undefined;
|
|
334
|
+
const { value: rawStyle, pathPrefix: stylePath } = resolveAppSection(raw, appBlock, 'style');
|
|
335
|
+
if (rawStyle !== undefined) {
|
|
336
|
+
if (typeof rawStyle === 'string' && rawStyle !== '') {
|
|
337
|
+
if (checkNoRelativeOrSystemPath(rawStyle, stylePath, diagnostics, 'KIT-APP-001', { allowConfigSubpath: true })) {
|
|
338
|
+
cfg.style = rawStyle;
|
|
339
|
+
}
|
|
340
|
+
} else bad(stylePath, 'style 必须是主题头文件路径', diagnostics);
|
|
366
341
|
}
|
|
367
|
-
|
|
368
|
-
|
|
342
|
+
const { value: rawEnvelope, pathPrefix: envelopePath } = resolveAppSection(raw, appBlock, 'envelope');
|
|
343
|
+
if (rawEnvelope !== undefined) {
|
|
344
|
+
const envelope = parseKitEnvelope(rawEnvelope, envelopePath, 'KIT-APP-001', diagnostics);
|
|
369
345
|
if (envelope !== undefined) cfg.envelope = envelope;
|
|
370
346
|
}
|
|
371
|
-
|
|
372
|
-
|
|
347
|
+
const { value: rawTheme, pathPrefix: themePath, keyPathOf: themeKeyPath } = resolveAppSection(raw, appBlock, 'theme');
|
|
348
|
+
if (rawTheme !== undefined) {
|
|
349
|
+
if (!isRecord(rawTheme)) bad(themePath, 'theme 必须是对象', diagnostics);
|
|
373
350
|
else {
|
|
351
|
+
checkRemovedThemeKeys(rawTheme, themePath, diagnostics, themeKeyPath);
|
|
374
352
|
const theme: KitAppTheme = {};
|
|
375
|
-
for (const [k, v] of Object.entries(
|
|
353
|
+
for (const [k, v] of Object.entries(rawTheme)) {
|
|
354
|
+
if (Object.prototype.hasOwnProperty.call(REMOVED_THEME_KEYS, k)) {
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
const kp = themeKeyPath(k);
|
|
376
358
|
if (!THEME_KEYS.includes(k)) {
|
|
377
|
-
bad(
|
|
359
|
+
bad(kp, `未知键 ${k}(允许:${THEME_KEYS.join(' / ')})`, diagnostics);
|
|
378
360
|
} else if (typeof v !== 'string' || v.trim() === '') {
|
|
379
|
-
bad(
|
|
361
|
+
bad(kp, `${k} 必须是非空字符串`, diagnostics);
|
|
380
362
|
} else {
|
|
381
363
|
const val = v.trim();
|
|
382
364
|
if (k === 'palette') {
|
|
383
365
|
if (!(KIT_THEME_PALETTES as readonly string[]).includes(val)) {
|
|
384
|
-
bad(
|
|
366
|
+
bad(kp, `palette「${val}」只能是 ${KIT_THEME_PALETTES.join(' / ')}`, diagnostics);
|
|
385
367
|
} else {
|
|
386
368
|
theme.palette = val as KitThemePalette;
|
|
387
369
|
}
|
|
388
370
|
} else if (k === 'color_depth' || k === 'colorDepth') {
|
|
389
371
|
if (!(KIT_THEME_COLOR_DEPTHS as readonly string[]).includes(val)) {
|
|
390
|
-
bad(
|
|
372
|
+
bad(kp, `${k}「${val}」只能是 ${KIT_THEME_COLOR_DEPTHS.join(' / ')}`, diagnostics);
|
|
391
373
|
} else {
|
|
392
374
|
theme.color_depth = val as KitThemeColorDepth;
|
|
393
375
|
theme.colorDepth = val as KitThemeColorDepth;
|
|
394
376
|
}
|
|
395
377
|
} else if (k === 'color_saturation' || k === 'colorSaturation') {
|
|
396
378
|
if (!(KIT_THEME_COLOR_SATURATIONS as readonly string[]).includes(val)) {
|
|
397
|
-
bad(
|
|
379
|
+
bad(kp, `${k}「${val}」只能是 ${KIT_THEME_COLOR_SATURATIONS.join(' / ')}`, diagnostics);
|
|
398
380
|
} else {
|
|
399
381
|
theme.color_saturation = val as KitThemeColorSaturation;
|
|
400
382
|
theme.colorSaturation = val as KitThemeColorSaturation;
|
|
401
383
|
}
|
|
402
384
|
} else if (k === 'font_family' || k === 'fontFamily') {
|
|
403
385
|
if (!(KIT_THEME_FONT_FAMILIES as readonly string[]).includes(val)) {
|
|
404
|
-
bad(
|
|
386
|
+
bad(kp, `${k}「${val}」只能是 ${KIT_THEME_FONT_FAMILIES.join(' / ')}`, diagnostics);
|
|
405
387
|
} else {
|
|
406
388
|
theme.font_family = val as KitThemeFontFamily;
|
|
407
389
|
theme.fontFamily = val as KitThemeFontFamily;
|
|
408
390
|
}
|
|
409
391
|
} else if (k === 'font_scale' || k === 'fontScale') {
|
|
410
392
|
if (!(KIT_THEME_FONT_SCALES as readonly string[]).includes(val)) {
|
|
411
|
-
bad(
|
|
393
|
+
bad(kp, `${k}「${val}」只能是 ${KIT_THEME_FONT_SCALES.join(' / ')}`, diagnostics);
|
|
412
394
|
} else {
|
|
413
395
|
theme.font_scale = val as KitThemeFontScale;
|
|
414
396
|
theme.fontScale = val as KitThemeFontScale;
|
|
415
397
|
}
|
|
416
398
|
} else if (k === 'boundary') {
|
|
417
399
|
if (!(KIT_THEME_BOUNDARIES as readonly string[]).includes(val)) {
|
|
418
|
-
bad(
|
|
400
|
+
bad(kp, `boundary「${val}」只能是 ${KIT_THEME_BOUNDARIES.join(' / ')}`, diagnostics);
|
|
419
401
|
} else {
|
|
420
402
|
theme.boundary = val as KitThemeBoundary;
|
|
421
403
|
}
|
|
422
404
|
} else if (k === 'shape') {
|
|
423
405
|
if (!(KIT_THEME_SHAPES as readonly string[]).includes(val)) {
|
|
424
|
-
bad(
|
|
406
|
+
bad(kp, `shape「${val}」只能是 ${KIT_THEME_SHAPES.join(' / ')}`, diagnostics);
|
|
425
407
|
} else {
|
|
426
408
|
theme.shape = val as KitThemeShape;
|
|
427
409
|
}
|
|
428
410
|
} else if (k === 'surface_texture' || k === 'surfaceTexture') {
|
|
429
411
|
if (!(KIT_THEME_SURFACE_TEXTURES as readonly string[]).includes(val)) {
|
|
430
|
-
|
|
412
|
+
const removed = Object.hasOwn(REMOVED_THEME_VALUES.surface_texture, val) ? REMOVED_THEME_VALUES.surface_texture[val] : undefined;
|
|
413
|
+
bad(kp, `${k}「${val}」${removed !== undefined ? `已删除:${removed};` : ''}只能是 ${KIT_THEME_SURFACE_TEXTURES.join(' / ')}`, diagnostics);
|
|
431
414
|
} else {
|
|
432
415
|
theme.surface_texture = val as KitThemeSurfaceTexture;
|
|
433
416
|
theme.surfaceTexture = val as KitThemeSurfaceTexture;
|
|
434
417
|
}
|
|
435
418
|
} else if (k === 'density') {
|
|
436
419
|
if (!(KIT_THEME_DENSITIES as readonly string[]).includes(val)) {
|
|
437
|
-
bad(
|
|
420
|
+
bad(kp, `density「${val}」只能是 ${KIT_THEME_DENSITIES.join(' / ')}`, diagnostics);
|
|
438
421
|
} else {
|
|
439
422
|
theme.density = val as KitThemeDensity;
|
|
440
423
|
}
|
|
424
|
+
} else if (k === 'motion') {
|
|
425
|
+
if (!(KIT_THEME_MOTIONS as readonly string[]).includes(val)) {
|
|
426
|
+
bad(kp, `motion「${val}」只能是 ${KIT_THEME_MOTIONS.join(' / ')}`, diagnostics);
|
|
427
|
+
} else {
|
|
428
|
+
theme.motion = val as KitThemeMotion;
|
|
429
|
+
}
|
|
430
|
+
} else if (k === 'table_style' || k === 'tableStyle') {
|
|
431
|
+
if (!(KIT_THEME_TABLE_STYLES as readonly string[]).includes(val)) {
|
|
432
|
+
bad(kp, `${k}「${val}」只能是 ${KIT_THEME_TABLE_STYLES.join(' / ')}`, diagnostics);
|
|
433
|
+
} else {
|
|
434
|
+
theme.table_style = val as KitThemeTableStyle;
|
|
435
|
+
theme.tableStyle = val as KitThemeTableStyle;
|
|
436
|
+
}
|
|
437
|
+
} else if (k === 'contrast') {
|
|
438
|
+
if (!(KIT_THEME_CONTRASTS as readonly string[]).includes(val)) {
|
|
439
|
+
bad(kp, `contrast「${val}」只能是 ${KIT_THEME_CONTRASTS.join(' / ')}`, diagnostics);
|
|
440
|
+
} else {
|
|
441
|
+
theme.contrast = val as KitThemeContrast;
|
|
442
|
+
}
|
|
443
|
+
} else if (k === 'accent_usage' || k === 'accentUsage') {
|
|
444
|
+
if (!(KIT_THEME_ACCENT_USAGES as readonly string[]).includes(val)) {
|
|
445
|
+
bad(kp, `${k}「${val}」只能是 ${KIT_THEME_ACCENT_USAGES.join(' / ')}`, diagnostics);
|
|
446
|
+
} else {
|
|
447
|
+
theme.accent_usage = val as KitThemeAccentUsage;
|
|
448
|
+
theme.accentUsage = val as KitThemeAccentUsage;
|
|
449
|
+
}
|
|
441
450
|
} else if (k === 'preset') {
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
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;
|
|
451
|
+
// 未知预设名按主题取值域错误报 KIT-APP-002(与求解端 solveKitTheme 同码同路径),不写入 cfg.theme
|
|
452
|
+
if (!(KIT_THEME_PRESETS as readonly string[]).includes(val)) {
|
|
453
|
+
diagnostics.push({ code: 'KIT-APP-002', path: kp, message: `preset「${val}」不是已知主题预设,只能是 ${KIT_THEME_PRESETS.join(' / ')}` });
|
|
454
|
+
} else {
|
|
455
|
+
theme.preset = val as KitThemePreset;
|
|
456
|
+
}
|
|
461
457
|
} else if (k === 'mode') {
|
|
462
|
-
|
|
458
|
+
if (!(KIT_THEME_MODES as readonly string[]).includes(val)) {
|
|
459
|
+
bad(kp, `mode「${val}」只能是 ${KIT_THEME_MODES.join(' / ')}`, diagnostics);
|
|
460
|
+
} else {
|
|
461
|
+
theme.mode = val;
|
|
462
|
+
}
|
|
463
463
|
}
|
|
464
464
|
}
|
|
465
465
|
}
|
|
466
466
|
cfg.theme = theme;
|
|
467
467
|
}
|
|
468
468
|
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
469
|
+
const { value: rawLayout, pathPrefix: layoutPath, keyPathOf: layoutKeyPath } = resolveAppSection(raw, appBlock, 'layout');
|
|
470
|
+
if (rawLayout !== undefined) {
|
|
471
|
+
if (!isRecord(rawLayout)) {
|
|
472
|
+
bad(layoutPath, 'layout 必须是对象', diagnostics);
|
|
472
473
|
} else {
|
|
473
|
-
for (const k of Object.keys(
|
|
474
|
-
if (!LAYOUT_TOP_KEYS.includes(k)) bad(
|
|
474
|
+
for (const k of Object.keys(rawLayout)) {
|
|
475
|
+
if (!LAYOUT_TOP_KEYS.includes(k)) bad(layoutKeyPath(k), `未知键 ${k}(允许:${LAYOUT_TOP_KEYS.join(' / ')})`, diagnostics);
|
|
475
476
|
}
|
|
476
477
|
const layout: KitAppLayout = {};
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
478
|
+
// 布局规则版本钉(RV-1117 T09):缺省 0 = 现状,输出逐字节不变;新应用 / AI 页钉最新版。
|
|
479
|
+
// 它不是「外框继承」配置,不进 cfg.layout(否则只写 rules 的应用会被当成启用了继承外框而多包一层)
|
|
480
|
+
if (rawLayout.rules !== undefined) {
|
|
481
|
+
const pin = typeof rawLayout.rules === 'number' ? normalizeLayoutPin(rawLayout.rules) : undefined;
|
|
482
|
+
if (pin === undefined) bad(layoutKeyPath('rules'), `rules 必须是已存在的布局规则版本号(整数,${KIT_LAYOUT_VERSIONS.join(' / ')};缺省 0 = 现状)`, diagnostics);
|
|
483
|
+
else cfg.layoutRules = pin;
|
|
484
|
+
}
|
|
485
|
+
if (rawLayout.frame !== undefined) {
|
|
486
|
+
if (typeof rawLayout.frame === 'string' && rawLayout.frame.trim() !== '') layout.frame = rawLayout.frame.trim();
|
|
487
|
+
else bad(layoutKeyPath('frame'), 'frame 必须是非空字符串', diagnostics);
|
|
480
488
|
}
|
|
481
|
-
if (
|
|
482
|
-
const mw = typeof
|
|
483
|
-
if (!(MAX_WIDTH_VALUES as readonly string[]).includes(mw)) bad('
|
|
489
|
+
if (rawLayout.max_width !== undefined) {
|
|
490
|
+
const mw = typeof rawLayout.max_width === 'string' ? rawLayout.max_width.trim() : '';
|
|
491
|
+
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
492
|
else layout.maxWidth = mw as 'narrow' | 'medium' | 'wide' | 'full';
|
|
485
493
|
}
|
|
486
|
-
if (
|
|
487
|
-
if (typeof
|
|
488
|
-
else bad('
|
|
494
|
+
if (rawLayout.sticky_header !== undefined) {
|
|
495
|
+
if (typeof rawLayout.sticky_header === 'boolean') layout.stickyHeader = rawLayout.sticky_header;
|
|
496
|
+
else bad(layoutKeyPath('sticky_header'), 'sticky_header 必须是布尔值', diagnostics);
|
|
489
497
|
}
|
|
490
|
-
if (
|
|
491
|
-
|
|
492
|
-
|
|
498
|
+
if (rawLayout.header !== undefined) {
|
|
499
|
+
const hp = layoutKeyPath('header');
|
|
500
|
+
if (!isRecord(rawLayout.header)) {
|
|
501
|
+
bad(hp, 'header 必须是对象', diagnostics);
|
|
493
502
|
} else {
|
|
494
|
-
for (const k of Object.keys(
|
|
495
|
-
if (!LAYOUT_HEADER_KEYS.includes(k)) bad(
|
|
503
|
+
for (const k of Object.keys(rawLayout.header)) {
|
|
504
|
+
if (!LAYOUT_HEADER_KEYS.includes(k)) bad(`${hp}.${k}`, `未知键 ${k}(允许:${LAYOUT_HEADER_KEYS.join(' / ')})`, diagnostics);
|
|
496
505
|
}
|
|
497
506
|
const header: NonNullable<KitAppLayout['header']> = {};
|
|
498
|
-
if (
|
|
499
|
-
|
|
500
|
-
|
|
507
|
+
if (rawLayout.header.brand !== undefined) {
|
|
508
|
+
const bp = `${hp}.brand`;
|
|
509
|
+
if (!isRecord(rawLayout.header.brand)) {
|
|
510
|
+
bad(bp, 'brand 必须是对象', diagnostics);
|
|
501
511
|
} else {
|
|
502
|
-
for (const k of Object.keys(
|
|
503
|
-
if (!BRAND_KEYS.includes(k)) bad(
|
|
512
|
+
for (const k of Object.keys(rawLayout.header.brand)) {
|
|
513
|
+
if (!BRAND_KEYS.includes(k)) bad(`${bp}.${k}`, `未知键 ${k}(允许:${BRAND_KEYS.join(' / ')})`, diagnostics);
|
|
504
514
|
}
|
|
505
|
-
if (typeof
|
|
506
|
-
bad(
|
|
515
|
+
if (typeof rawLayout.header.brand.text !== 'string' || rawLayout.header.brand.text.trim() === '') {
|
|
516
|
+
bad(`${bp}.text`, 'brand.text 必须是非空字符串', diagnostics);
|
|
507
517
|
} else {
|
|
508
|
-
header.brand = { text:
|
|
509
|
-
if (
|
|
510
|
-
if (typeof
|
|
511
|
-
|
|
518
|
+
header.brand = { text: rawLayout.header.brand.text.trim() };
|
|
519
|
+
if (rawLayout.header.brand.href !== undefined) {
|
|
520
|
+
if (typeof rawLayout.header.brand.href === 'string') {
|
|
521
|
+
if (checkNoRelativeOrSystemPath(rawLayout.header.brand.href, `${bp}.href`, diagnostics, 'KIT-APP-001', { allowExternalHref: true })) {
|
|
522
|
+
header.brand.href = rawLayout.header.brand.href;
|
|
523
|
+
}
|
|
524
|
+
} else bad(`${bp}.href`, 'brand.href 必须是字符串', diagnostics);
|
|
512
525
|
}
|
|
513
526
|
}
|
|
514
527
|
}
|
|
515
528
|
}
|
|
516
|
-
if (
|
|
517
|
-
if (!Array.isArray(
|
|
518
|
-
bad(
|
|
529
|
+
if (rawLayout.header.nav !== undefined) {
|
|
530
|
+
if (!Array.isArray(rawLayout.header.nav)) {
|
|
531
|
+
bad(`${hp}.nav`, 'nav 必须是数组', diagnostics);
|
|
519
532
|
} else {
|
|
520
533
|
const nav: KitAppLayoutNavItem[] = [];
|
|
521
|
-
|
|
522
|
-
const parsed = parseNavItem(it,
|
|
534
|
+
rawLayout.header.nav.forEach((it, i) => {
|
|
535
|
+
const parsed = parseNavItem(it, `${hp}.nav[${i}]`, diagnostics);
|
|
523
536
|
if (parsed) nav.push(parsed);
|
|
524
537
|
});
|
|
525
538
|
header.nav = nav;
|
|
526
539
|
}
|
|
527
540
|
}
|
|
528
|
-
if (
|
|
529
|
-
if (!Array.isArray(
|
|
530
|
-
bad(
|
|
541
|
+
if (rawLayout.header.actions !== undefined) {
|
|
542
|
+
if (!Array.isArray(rawLayout.header.actions)) {
|
|
543
|
+
bad(`${hp}.actions`, 'actions 必须是数组', diagnostics);
|
|
531
544
|
} else {
|
|
532
545
|
const actions: KitAppLayoutNavItem[] = [];
|
|
533
|
-
|
|
534
|
-
const parsed = parseNavItem(it,
|
|
546
|
+
rawLayout.header.actions.forEach((it, i) => {
|
|
547
|
+
const parsed = parseNavItem(it, `${hp}.actions[${i}]`, diagnostics);
|
|
535
548
|
if (parsed) actions.push(parsed);
|
|
536
549
|
});
|
|
537
550
|
header.actions = actions;
|
|
@@ -540,29 +553,30 @@ export function parseAppConfig(raw: unknown, diagnostics: KitDiagnostic[]): KitA
|
|
|
540
553
|
layout.header = header;
|
|
541
554
|
}
|
|
542
555
|
}
|
|
543
|
-
if (
|
|
544
|
-
|
|
545
|
-
|
|
556
|
+
if (rawLayout.sidebar !== undefined) {
|
|
557
|
+
const sp = layoutKeyPath('sidebar');
|
|
558
|
+
if (!isRecord(rawLayout.sidebar)) {
|
|
559
|
+
bad(sp, 'sidebar 必须是对象', diagnostics);
|
|
546
560
|
} else {
|
|
547
|
-
for (const k of Object.keys(
|
|
548
|
-
if (!LAYOUT_SIDEBAR_KEYS.includes(k)) bad(
|
|
561
|
+
for (const k of Object.keys(rawLayout.sidebar)) {
|
|
562
|
+
if (!LAYOUT_SIDEBAR_KEYS.includes(k)) bad(`${sp}.${k}`, `未知键 ${k}(允许:${LAYOUT_SIDEBAR_KEYS.join(' / ')})`, diagnostics);
|
|
549
563
|
}
|
|
550
564
|
const sidebar: NonNullable<KitAppLayout['sidebar']> = {};
|
|
551
|
-
if (
|
|
552
|
-
if (typeof
|
|
553
|
-
else bad(
|
|
565
|
+
if (rawLayout.sidebar.title !== undefined) {
|
|
566
|
+
if (typeof rawLayout.sidebar.title === 'string') sidebar.title = rawLayout.sidebar.title;
|
|
567
|
+
else bad(`${sp}.title`, 'sidebar.title 必须是字符串', diagnostics);
|
|
554
568
|
}
|
|
555
|
-
if (
|
|
556
|
-
if (typeof
|
|
557
|
-
else bad(
|
|
569
|
+
if (rawLayout.sidebar.width !== undefined) {
|
|
570
|
+
if (typeof rawLayout.sidebar.width === 'number' && !Number.isNaN(rawLayout.sidebar.width)) sidebar.width = rawLayout.sidebar.width;
|
|
571
|
+
else bad(`${sp}.width`, 'sidebar.width 必须是数字', diagnostics);
|
|
558
572
|
}
|
|
559
|
-
if (
|
|
560
|
-
if (!Array.isArray(
|
|
561
|
-
bad(
|
|
573
|
+
if (rawLayout.sidebar.menu !== undefined) {
|
|
574
|
+
if (!Array.isArray(rawLayout.sidebar.menu)) {
|
|
575
|
+
bad(`${sp}.menu`, 'sidebar.menu 必须是数组', diagnostics);
|
|
562
576
|
} else {
|
|
563
577
|
const menu: KitAppLayoutNavItem[] = [];
|
|
564
|
-
|
|
565
|
-
const parsed = parseNavItem(it,
|
|
578
|
+
rawLayout.sidebar.menu.forEach((it, i) => {
|
|
579
|
+
const parsed = parseNavItem(it, `${sp}.menu[${i}]`, diagnostics);
|
|
566
580
|
if (parsed) menu.push(parsed);
|
|
567
581
|
});
|
|
568
582
|
sidebar.menu = menu;
|
|
@@ -571,25 +585,26 @@ export function parseAppConfig(raw: unknown, diagnostics: KitDiagnostic[]): KitA
|
|
|
571
585
|
layout.sidebar = sidebar;
|
|
572
586
|
}
|
|
573
587
|
}
|
|
574
|
-
if (
|
|
575
|
-
|
|
576
|
-
|
|
588
|
+
if (rawLayout.footer !== undefined) {
|
|
589
|
+
const fp = layoutKeyPath('footer');
|
|
590
|
+
if (!isRecord(rawLayout.footer)) {
|
|
591
|
+
bad(fp, 'footer 必须是对象', diagnostics);
|
|
577
592
|
} else {
|
|
578
|
-
for (const k of Object.keys(
|
|
579
|
-
if (!LAYOUT_FOOTER_KEYS.includes(k)) bad(
|
|
593
|
+
for (const k of Object.keys(rawLayout.footer)) {
|
|
594
|
+
if (!LAYOUT_FOOTER_KEYS.includes(k)) bad(`${fp}.${k}`, `未知键 ${k}(允许:${LAYOUT_FOOTER_KEYS.join(' / ')})`, diagnostics);
|
|
580
595
|
}
|
|
581
596
|
const footer: NonNullable<KitAppLayout['footer']> = {};
|
|
582
|
-
if (
|
|
583
|
-
if (typeof
|
|
584
|
-
else bad(
|
|
597
|
+
if (rawLayout.footer.text !== undefined) {
|
|
598
|
+
if (typeof rawLayout.footer.text === 'string') footer.text = rawLayout.footer.text;
|
|
599
|
+
else bad(`${fp}.text`, 'footer.text 必须是字符串', diagnostics);
|
|
585
600
|
}
|
|
586
|
-
if (
|
|
587
|
-
if (!Array.isArray(
|
|
588
|
-
bad(
|
|
601
|
+
if (rawLayout.footer.links !== undefined) {
|
|
602
|
+
if (!Array.isArray(rawLayout.footer.links)) {
|
|
603
|
+
bad(`${fp}.links`, 'footer.links 必须是数组', diagnostics);
|
|
589
604
|
} else {
|
|
590
605
|
const links: Array<{ label: string; href: string }> = [];
|
|
591
|
-
|
|
592
|
-
const lp =
|
|
606
|
+
rawLayout.footer.links.forEach((link, i) => {
|
|
607
|
+
const lp = `${fp}.links[${i}]`;
|
|
593
608
|
if (!isRecord(link)) {
|
|
594
609
|
bad(lp, `${lp} 必须是对象 { label, href }`, diagnostics);
|
|
595
610
|
return;
|
|
@@ -605,6 +620,9 @@ export function parseAppConfig(raw: unknown, diagnostics: KitDiagnostic[]): KitA
|
|
|
605
620
|
bad(`${lp}.href`, 'href 必须是非空字符串', diagnostics);
|
|
606
621
|
return;
|
|
607
622
|
}
|
|
623
|
+
if (!checkNoRelativeOrSystemPath(link.href, `${lp}.href`, diagnostics, 'KIT-APP-001', { allowExternalHref: true })) {
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
608
626
|
links.push({ label: link.label.trim(), href: link.href.trim() });
|
|
609
627
|
});
|
|
610
628
|
footer.links = links;
|
|
@@ -613,7 +631,8 @@ export function parseAppConfig(raw: unknown, diagnostics: KitDiagnostic[]): KitA
|
|
|
613
631
|
layout.footer = footer;
|
|
614
632
|
}
|
|
615
633
|
}
|
|
616
|
-
|
|
634
|
+
// 只写了 rules 的 layout 块不是外框继承配置(见上),不进 cfg.layout,存量应用输出不变
|
|
635
|
+
if (!(Object.keys(rawLayout).length === 1 && rawLayout.rules !== undefined)) cfg.layout = layout;
|
|
617
636
|
}
|
|
618
637
|
}
|
|
619
638
|
if (raw.baseComponents !== undefined) {
|
|
@@ -649,5 +668,88 @@ export function parseAppConfig(raw: unknown, diagnostics: KitDiagnostic[]): KitA
|
|
|
649
668
|
}
|
|
650
669
|
}
|
|
651
670
|
}
|
|
671
|
+
const { value: rawDicts, pathPrefix: dictsPathPrefix, keyPathOf: dictsKeyPath } = resolveAppSection(raw, appBlock, 'dicts');
|
|
672
|
+
if (rawDicts !== undefined) {
|
|
673
|
+
if (!isRecord(rawDicts)) {
|
|
674
|
+
bad(dictsPathPrefix, "dicts 必须是 { 字典名: [{ value, label, tone? }] }", diagnostics);
|
|
675
|
+
} else {
|
|
676
|
+
const dicts: KitAppDicts = {};
|
|
677
|
+
for (const [dictName, items] of Object.entries(rawDicts)) {
|
|
678
|
+
const dp = dictsKeyPath(dictName);
|
|
679
|
+
if (!ENTITY_NAME_RE.test(dictName)) {
|
|
680
|
+
bad(dp, `字典名 ${dictName} 必须是合法标识符`, diagnostics);
|
|
681
|
+
continue;
|
|
682
|
+
}
|
|
683
|
+
if (!Array.isArray(items) || items.length === 0) {
|
|
684
|
+
bad(dp, "字典项必须是非空选项数组 [{ value, label, tone? }]", diagnostics);
|
|
685
|
+
continue;
|
|
686
|
+
}
|
|
687
|
+
const parsedItems: KitDictOption[] = [];
|
|
688
|
+
items.forEach((it, idx) => {
|
|
689
|
+
const ip = `${dp}[${idx}]`;
|
|
690
|
+
if (!isRecord(it)) {
|
|
691
|
+
bad(ip, "字典选项必须是 { value, label, tone? } 对象", diagnostics);
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
for (const k of Object.keys(it)) {
|
|
695
|
+
if (!DICT_OPTION_KEYS.includes(k)) bad(`${ip}.${k}`, `未知键 ${k}(允许:${DICT_OPTION_KEYS.join(" / ")})`, diagnostics);
|
|
696
|
+
}
|
|
697
|
+
if (typeof it.value !== "string" && typeof it.value !== "number" && typeof it.value !== "boolean") {
|
|
698
|
+
bad(`${ip}.value`, "value 必须是字符串、数字或布尔值", diagnostics);
|
|
699
|
+
return;
|
|
700
|
+
}
|
|
701
|
+
if (typeof it.label !== "string" || it.label.trim() === "") {
|
|
702
|
+
bad(`${ip}.label`, "label 必须是非空字符串", diagnostics);
|
|
703
|
+
return;
|
|
704
|
+
}
|
|
705
|
+
const opt: KitDictOption = { value: it.value, label: it.label };
|
|
706
|
+
if (it.tone !== undefined) {
|
|
707
|
+
if (typeof it.tone !== "string" || it.tone.trim() === "") {
|
|
708
|
+
bad(`${ip}.tone`, "tone 必须是非空字符串", diagnostics);
|
|
709
|
+
} else {
|
|
710
|
+
opt.tone = it.tone;
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
parsedItems.push(opt);
|
|
714
|
+
});
|
|
715
|
+
dicts[dictName] = parsedItems;
|
|
716
|
+
}
|
|
717
|
+
cfg.dicts = dicts;
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
const { value: rawEntities, pathPrefix: entitiesPathPrefix, keyPathOf: entitiesKeyPath } = resolveAppSection(raw, appBlock, 'entities');
|
|
721
|
+
if (rawEntities !== undefined) {
|
|
722
|
+
if (!isRecord(rawEntities)) {
|
|
723
|
+
bad(entitiesPathPrefix, "entities 必须是 { 实体名: { 字段名: 字段声明 } }", diagnostics);
|
|
724
|
+
} else {
|
|
725
|
+
const entities: KitAppEntities = {};
|
|
726
|
+
for (const [entityName, entityVal] of Object.entries(rawEntities)) {
|
|
727
|
+
const ep = entitiesKeyPath(entityName);
|
|
728
|
+
if (!ENTITY_NAME_RE.test(entityName)) {
|
|
729
|
+
bad(ep, `实体名 ${entityName} 必须是合法标识符`, diagnostics);
|
|
730
|
+
continue;
|
|
731
|
+
}
|
|
732
|
+
if (!isRecord(entityVal)) {
|
|
733
|
+
bad(ep, "实体定义必须是字段声明映射对象", diagnostics);
|
|
734
|
+
continue;
|
|
735
|
+
}
|
|
736
|
+
const fieldMap = isRecord(entityVal.fields) && typeof entityVal.fields.type !== "string"
|
|
737
|
+
? entityVal.fields
|
|
738
|
+
: isRecord(entityVal.schema) && typeof entityVal.schema.type !== "string"
|
|
739
|
+
? entityVal.schema
|
|
740
|
+
: entityVal;
|
|
741
|
+
const resolvedFields: Record<string, unknown> = {};
|
|
742
|
+
for (const [fName, fDef] of Object.entries(fieldMap)) {
|
|
743
|
+
if (!isRecord(fDef)) {
|
|
744
|
+
bad(`${ep}.${fName}`, `实体 ${entityName} 的字段 ${fName} 必须是对象`, diagnostics);
|
|
745
|
+
continue;
|
|
746
|
+
}
|
|
747
|
+
resolvedFields[fName] = { ...fDef };
|
|
748
|
+
}
|
|
749
|
+
entities[entityName] = resolvedFields;
|
|
750
|
+
}
|
|
751
|
+
cfg.entities = entities;
|
|
752
|
+
}
|
|
753
|
+
}
|
|
652
754
|
return cfg;
|
|
653
755
|
}
|