soma-kit 0.1.13 → 0.1.15
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/package.json +3 -3
- package/packs/finance/reconcile-desk/compile.ts +1 -1
- package/packs/finance/reconcile-desk/shell.ts +1 -1
- package/spec/generated/kit-app.schema.json +18 -2
- package/spec/generated/kit-page.schema.json +95 -0
- package/spec/kit-grammar.json +332 -75
- package/spec/kit-grammar.schema.json +1 -27
- package/src/app/app-config.ts +11 -5
- package/src/app/component-gate.ts +2 -2
- package/src/app/compose-apps.ts +5 -2
- package/src/app/define-kit-actions.ts +82 -10
- package/src/app/define-kit-app.ts +6 -5
- package/src/app/define-kit-view.ts +1 -1
- package/src/app/index.ts +20 -8
- package/src/app/kit-view-context.ts +30 -4
- package/src/app/server-pages.ts +5 -1
- package/src/app/server.ts +15 -5
- package/src/app/theme-endpoint.ts +1 -1
- package/src/app/theme-runtime.ts +7 -2
- package/src/base/alert.ts +23 -20
- package/src/base/anchored-layer.ts +1 -1
- package/src/base/button.ts +34 -17
- package/src/base/cascader.ts +8 -4
- package/src/base/check-core.ts +9 -6
- package/src/base/color-picker.ts +10 -6
- package/src/base/command-palette.ts +10 -4
- package/src/base/context-menu.ts +5 -2
- package/src/base/date-range.ts +9 -6
- package/src/base/date.ts +10 -6
- package/src/base/delta.ts +4 -2
- package/src/base/divider.ts +15 -66
- package/src/base/end-edge.ts +14 -2
- package/src/base/fab.ts +11 -6
- package/src/base/gap-value.ts +25 -5
- package/src/base/hint-tips.ts +1 -1
- package/src/base/illustrations.ts +2 -1
- package/src/base/index.ts +20 -4
- package/src/base/inline-error.ts +84 -0
- package/src/base/input.ts +54 -18
- package/src/base/kbd.ts +4 -3
- package/src/base/link.ts +1 -1
- package/src/base/listbox-core.ts +70 -22
- package/src/base/mentions.ts +6 -3
- package/src/base/menu-button.ts +73 -50
- package/src/base/menu-core.ts +9 -2
- package/src/base/motion/hover-3d.ts +4 -1
- package/src/base/motion/hover-gallery.ts +4 -1
- package/src/base/otp.ts +7 -3
- package/src/base/overlay-runtime.ts +3 -2
- package/src/base/overlay-shell.ts +141 -0
- package/src/base/popover.ts +7 -6
- package/src/base/popup.ts +47 -41
- package/src/base/qty-stepper.ts +14 -9
- package/src/base/reason-tip.ts +2 -2
- package/src/{frames → base}/resize-handle.ts +1 -1
- package/src/base/segmented.ts +44 -35
- package/src/base/select.ts +1 -0
- package/src/base/shared.ts +52 -18
- package/src/base/state-panel.ts +34 -13
- package/src/base/status-tone.ts +1 -1
- package/src/base/tag-input.ts +13 -8
- package/src/base/tag.ts +56 -57
- package/src/base/text.ts +38 -14
- package/src/base/textarea.ts +1 -1
- package/src/base/time-picker.ts +9 -5
- package/src/base/tree-select.ts +12 -9
- package/src/base/upload.ts +26 -17
- package/src/biz/approval-desk/compile.ts +28 -1
- package/src/biz/approval-desk/shell.ts +10 -9
- package/src/biz/auth-panel/compile.ts +1 -1
- package/src/biz/auth-panel/shell.ts +7 -6
- package/src/biz/category-crud/compile.ts +20 -6
- package/src/biz/category-crud/shell.ts +10 -7
- package/src/biz/checkout-page/compile.ts +1 -1
- package/src/biz/checkout-page/shell.ts +15 -13
- package/src/biz/compose.ts +5 -5
- package/src/biz/data-components.ts +4 -0
- package/src/biz/define.ts +1 -1
- package/src/biz/import-wizard/compile.ts +1 -1
- package/src/biz/import-wizard/shell.ts +17 -13
- package/src/biz/index.ts +4 -3
- package/src/biz/landing-page/compile.ts +1 -1
- package/src/biz/landing-page/shell.ts +6 -5
- package/src/biz/link/shared.ts +8 -1
- package/src/biz/master-sub/compile.ts +269 -27
- package/src/biz/master-sub/detail-head.ts +62 -0
- package/src/biz/master-sub/index.ts +5 -4
- package/src/biz/master-sub/shell.ts +138 -69
- package/src/biz/multi-board/compile.ts +166 -11
- package/src/biz/multi-board/composition.ts +58 -0
- package/src/biz/multi-board/index.ts +25 -10
- package/src/biz/multi-board/prose-fold.ts +143 -0
- package/src/biz/multi-board/shell.ts +96 -24
- package/src/biz/names.ts +1 -0
- package/src/biz/notification-center/compile.ts +9 -2
- package/src/biz/notification-center/shell.ts +15 -7
- package/src/biz/page-templates/domain-templates.ts +7 -3
- package/src/biz/page-templates/result-page/compile.ts +1 -1
- package/src/biz/page-templates/result-page/shell.ts +5 -4
- package/src/biz/page-templates/shared.ts +1 -1
- package/src/biz/page-templates/sign-in-page/compile.ts +1 -1
- package/src/biz/page-templates/sign-in-page/shell.ts +18 -18
- package/src/biz/record-detail/compile.ts +5 -2
- package/src/biz/record-detail/shell.ts +12 -11
- package/src/biz/settings-center/compile.ts +1 -1
- package/src/biz/settings-center/shell.ts +14 -10
- package/src/biz/shared/action-host.ts +12 -5
- package/src/biz/shared/compile-helpers.ts +83 -4
- package/src/biz/shared/coordinator.ts +104 -21
- package/src/biz/shared/overlay-compile.ts +76 -4
- package/src/biz/shared/overlay-shell.ts +65 -112
- package/src/biz/single-form/compile.ts +2 -2
- package/src/biz/single-form/shell.ts +13 -7
- package/src/biz/standard-crud/compile.ts +24 -4
- package/src/biz/standard-crud/shell.ts +38 -30
- package/src/biz/standard-crud/summary.ts +42 -0
- package/src/biz/step-form/compile.ts +1 -1
- package/src/biz/step-form/hub.ts +4 -0
- package/src/biz/step-form/shell.ts +16 -12
- package/src/biz/types.ts +15 -3
- package/src/cli/app-layer-check.ts +375 -0
- package/src/cli/kit-cli.ts +35 -8
- package/src/cli/kit-init.ts +149 -0
- package/src/cli/layout-cli.ts +7 -7
- package/src/compile/access-gate-attach.ts +27 -0
- package/src/compile/action-host-attach.ts +1 -1
- package/src/compile/compile-page.ts +36 -230
- package/src/compile/component-candidates.ts +4 -1
- package/src/compile/hints.ts +5 -58
- package/src/compile/index.ts +2 -2
- package/src/compile/layout-lint/index.ts +4 -1
- package/src/compile/layout-lint/rules-composition.ts +97 -18
- package/src/compile/layout-lint/rules-form.ts +6 -7
- package/src/compile/layout-lint/rules-table.ts +98 -14
- package/src/compile/page-composition.ts +191 -0
- package/src/compile/parse.ts +4 -0
- package/src/compile/producer-fingerprint.ts +56 -0
- package/src/compile/redirect.ts +1 -1
- package/src/compile/stages.ts +169 -0
- package/src/compile/styles.ts +80 -32
- package/src/compile/types.ts +5 -3
- package/src/data/access-gate.ts +112 -0
- package/src/data/amount-breakdown.ts +6 -2
- package/src/data/anchor-nav.ts +4 -1
- package/src/data/approval-flow.ts +13 -5
- package/src/data/assignment-picker.ts +35 -20
- package/src/data/async-result-panel.ts +7 -3
- package/src/data/breadcrumbs.ts +13 -9
- package/src/data/calendar.ts +10 -4
- package/src/data/carousel.ts +13 -5
- package/src/data/chart.ts +745 -48
- package/src/data/checklist.ts +9 -5
- package/src/data/code-view.ts +220 -26
- package/src/data/comment-thread.ts +9 -3
- package/src/data/confirm-dialog.ts +57 -20
- package/src/data/diff.ts +4 -1
- package/src/data/dock.ts +5 -1
- package/src/data/embed.ts +1 -1
- package/src/data/engine-ports.ts +126 -0
- package/src/data/field-mapper.ts +16 -7
- package/src/data/flow-editor.ts +106 -29
- package/src/data/footer.ts +8 -2
- package/src/data/gantt.ts +192 -27
- package/src/data/hero.ts +8 -2
- package/src/data/image-viewer.ts +7 -3
- package/src/data/index.ts +22 -8
- package/src/data/item-list.ts +11 -3
- package/src/data/json-view.ts +844 -0
- package/src/data/kanban.ts +13 -8
- package/src/data/markdown-view.ts +487 -0
- package/src/data/matrix.ts +400 -0
- package/src/data/media-grid.ts +5 -2
- package/src/data/mega-menu.ts +4 -3
- package/src/data/menu-dom.ts +9 -8
- package/src/data/menu.ts +35 -17
- package/src/data/mockup.ts +12 -8
- package/src/data/modal-dialog.ts +108 -57
- package/src/data/navbar.ts +13 -7
- package/src/data/notice-list.ts +53 -20
- package/src/data/notify-renderer.ts +21 -10
- package/src/data/object-form.ts +248 -151
- package/src/data/pager.ts +15 -10
- package/src/data/panel-head.ts +406 -0
- package/src/data/permission-matrix.ts +19 -9
- package/src/data/permission-tree.ts +30 -13
- package/src/data/pricing-table.ts +10 -4
- package/src/data/reaction-bar.ts +6 -3
- package/src/data/record-card.ts +30 -14
- package/src/data/record-picker.ts +8 -4
- package/src/data/redirect.ts +1 -1
- package/src/data/request-console.ts +20 -7
- package/src/data/resident.ts +6 -10
- package/src/data/result-panel.ts +2 -2
- package/src/data/rich-text.ts +58 -96
- package/src/data/row-editor.ts +12 -7
- package/src/data/rule-builder.ts +22 -11
- package/src/data/shape-util.ts +26 -14
- package/src/data/stat-group.ts +369 -84
- package/src/data/static-lazy.ts +7 -0
- package/src/data/static-registry.ts +14 -2
- package/src/data/steps.ts +6 -2
- package/src/data/survey.ts +13 -4
- package/src/data/system-switcher.ts +17 -7
- package/src/data/text-diff.ts +663 -0
- package/src/data/timeline.ts +1 -1
- package/src/data/tour-guide.ts +8 -4
- package/src/data/transfer.ts +24 -11
- package/src/data/tree-table.ts +84 -17
- package/src/data/tree.ts +6 -3
- package/src/data/virtual-rows.ts +22 -11
- package/src/data/wrap.ts +2 -2
- package/src/data/wrapped-candidates.ts +22 -1
- package/src/frames/index.ts +4 -2
- package/src/frames/inherited-shell.ts +178 -0
- package/src/frames/list-summary.ts +123 -0
- package/src/frames/page-bar.ts +10 -16
- package/src/frames/resident-components.ts +20 -0
- package/src/frames/shared.ts +37 -17
- package/src/frames/split-frame/shell.ts +17 -11
- package/src/frames/split-frame/wiring.ts +2 -2
- package/src/frames/tabs-frame/shell.ts +17 -9
- package/src/frames/top-main-frame.ts +1 -1
- package/src/frames/types.ts +6 -3
- package/src/frames/workspace-frame/extras.ts +19 -5
- package/src/frames/workspace-frame/shell.ts +4 -3
- package/src/frames/workspace-frame/state.ts +8 -2
- package/src/frames/workspace-frame/tab-scroll.ts +28 -0
- package/src/frames/workspace-frame/view.ts +156 -91
- package/src/generated/kit-grammar-runtime.ts +227 -58
- package/src/i18n/kit-text.ts +141 -2
- package/src/i18n/resolve-text-refs.ts +1 -1
- package/src/object-renderer/action-group.ts +169 -0
- package/src/object-renderer/action-more.ts +160 -0
- package/src/object-renderer/arrange.ts +86 -26
- package/src/object-renderer/candidates.ts +4 -0
- package/src/object-renderer/collection-parts.ts +72 -20
- package/src/object-renderer/collection-table.ts +178 -65
- package/src/object-renderer/collection.ts +129 -83
- package/src/object-renderer/compile-data.ts +1 -1
- package/src/object-renderer/defaults.ts +10 -5
- package/src/object-renderer/emit-events.ts +1 -1
- package/src/object-renderer/emit-object.ts +7 -0
- package/src/object-renderer/emit-static.ts +243 -87
- package/src/object-renderer/field-value.ts +12 -239
- package/src/object-renderer/filter-plan.ts +84 -0
- package/src/object-renderer/filter-toolbar.ts +103 -0
- package/src/{compile → object-renderer}/fragment.ts +13 -2
- package/src/object-renderer/index.ts +6 -1
- package/src/object-renderer/layout-facts.ts +46 -6
- package/src/object-renderer/layout-plan.ts +136 -43
- package/src/object-renderer/layout-plan.types.ts +42 -5
- package/src/object-renderer/overlay-decide.ts +82 -0
- package/src/object-renderer/parts.ts +7 -259
- package/src/object-renderer/render-object.ts +60 -47
- package/src/object-renderer/table-actions.ts +135 -56
- package/src/object-renderer/table-gap.ts +37 -0
- package/src/object-renderer/table-tools.ts +63 -25
- package/src/object-renderer/types.ts +16 -22
- package/src/recipes/app-blocks.ts +66 -0
- package/src/recipes/code-view.ts +56 -0
- package/src/recipes/compact-group.ts +31 -0
- package/src/recipes/container.ts +54 -13
- package/src/recipes/control.ts +77 -157
- package/src/recipes/desc-list.ts +14 -0
- package/src/recipes/divider.ts +53 -0
- package/src/recipes/emphasis.ts +60 -0
- package/src/recipes/frame-bleed.ts +33 -0
- package/src/recipes/index.ts +34 -1
- package/src/recipes/inherited-shell.ts +37 -0
- package/src/recipes/json-view.ts +49 -0
- package/src/recipes/markdown.ts +86 -0
- package/src/recipes/overlay.ts +149 -18
- package/src/recipes/page-width.ts +20 -0
- package/src/recipes/placeholder.ts +21 -5
- package/src/recipes/rail-grid.ts +3 -0
- package/src/recipes/stat-state.ts +65 -0
- package/src/recipes/state.ts +20 -28
- package/src/recipes/status.ts +17 -8
- package/src/recipes/strip.ts +72 -0
- package/src/recipes/surface-edge.ts +16 -0
- package/src/recipes/surface.ts +10 -6
- package/src/recipes/table-gap.ts +80 -0
- package/src/recipes/table-native-edit.ts +242 -0
- package/src/recipes/table-row.ts +120 -11
- package/src/recipes/tabs.ts +126 -0
- package/src/recipes/text-diff.ts +90 -0
- package/src/recipes/title-row.ts +7 -5
- package/src/recipes/typography.ts +24 -43
- package/src/shared/diagnostics.ts +16 -0
- package/src/shared/envelope.ts +1 -1
- package/src/shared/field-value-format.ts +246 -0
- package/src/shared/focus-ring.ts +8 -0
- package/src/shared/hints.ts +56 -0
- package/src/{base → shared}/icons.ts +12 -0
- package/src/shared/kit-error.ts +1 -1
- package/src/{object-renderer → shared}/merge-class.ts +3 -2
- package/src/shared/path-guard.ts +1 -1
- package/src/shared/primitives-types.ts +8 -0
- package/src/shared/theme-runtime-shared.ts +19 -0
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +49 -14
- package/src/theme/kit-theme.tpl +49 -14
- package/src/theme/nine-dim-structure.ts +129 -37
- package/src/theme/surface-layers.ts +17 -4
- package/src/theme/theme-tokens.ts +16 -5
- package/src/theme/typography.ts +21 -17
- package/src/app/envelope.ts +0 -1
- package/src/app/notify-renderer.ts +0 -1
- package/src/app/paged-list-adapter.ts +0 -1
- package/src/app/theme-runtime-shared.ts +0 -1
- package/src/compile/kit-error.ts +0 -1
- /package/src/{base → shared}/class-candidates.ts +0 -0
|
@@ -211,9 +211,7 @@
|
|
|
211
211
|
"groupsAs": {
|
|
212
212
|
"type": "object",
|
|
213
213
|
"required": [
|
|
214
|
-
"values"
|
|
215
|
-
"barClass",
|
|
216
|
-
"tabClass"
|
|
214
|
+
"values"
|
|
217
215
|
]
|
|
218
216
|
},
|
|
219
217
|
"fieldValue": {
|
|
@@ -1161,9 +1159,6 @@
|
|
|
1161
1159
|
"dropdown": {
|
|
1162
1160
|
"type": "object",
|
|
1163
1161
|
"required": [
|
|
1164
|
-
"rowClass",
|
|
1165
|
-
"panelMaxClass",
|
|
1166
|
-
"clamps",
|
|
1167
1162
|
"panelShadowClass",
|
|
1168
1163
|
"panelBorderClass",
|
|
1169
1164
|
"dialogShadowClass",
|
|
@@ -1176,27 +1171,6 @@
|
|
|
1176
1171
|
"note": {
|
|
1177
1172
|
"type": "string"
|
|
1178
1173
|
},
|
|
1179
|
-
"rowClass": {
|
|
1180
|
-
"type": "string"
|
|
1181
|
-
},
|
|
1182
|
-
"panelMaxClass": {
|
|
1183
|
-
"type": "string"
|
|
1184
|
-
},
|
|
1185
|
-
"clamps": {
|
|
1186
|
-
"type": "array",
|
|
1187
|
-
"items": {
|
|
1188
|
-
"type": "object",
|
|
1189
|
-
"required": [
|
|
1190
|
-
"cls"
|
|
1191
|
-
],
|
|
1192
|
-
"properties": {
|
|
1193
|
-
"cls": {
|
|
1194
|
-
"type": "string"
|
|
1195
|
-
}
|
|
1196
|
-
}
|
|
1197
|
-
},
|
|
1198
|
-
"minItems": 1
|
|
1199
|
-
},
|
|
1200
1174
|
"panelGapClass": {
|
|
1201
1175
|
"type": "string"
|
|
1202
1176
|
},
|
package/src/app/app-config.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import type { KitDiagnostic } from '../object-renderer/types';
|
|
4
4
|
import { checkNoRelativeOrSystemPath } from '../shared/path-guard';
|
|
5
|
-
import { parseKitEnvelope, type KitEnvelope } from '
|
|
5
|
+
import { parseKitEnvelope, type KitEnvelope } from '../shared/envelope';
|
|
6
6
|
import { KIT_LAYOUT_VERSIONS, normalizeLayoutPin } from '../object-renderer/layout-plan';
|
|
7
7
|
|
|
8
8
|
export type {
|
|
@@ -82,8 +82,10 @@ export interface KitAppLayoutNavItem {
|
|
|
82
82
|
|
|
83
83
|
export interface KitAppLayout {
|
|
84
84
|
frame?: string;
|
|
85
|
-
maxWidth?: 'narrow' | 'medium' | 'wide' | 'full';
|
|
85
|
+
maxWidth?: 'narrow' | 'medium' | 'wide' | 'xwide' | 'full';
|
|
86
86
|
stickyHeader?: boolean;
|
|
87
|
+
/** 默认内容区通栏(页面级 `frame.bleed` 覆盖);只继承给不自管整页布局的页面框 */
|
|
88
|
+
bleed?: boolean;
|
|
87
89
|
header?: {
|
|
88
90
|
brand?: { text: string; href?: string };
|
|
89
91
|
nav?: KitAppLayoutNavItem[];
|
|
@@ -212,8 +214,8 @@ export function checkRemovedThemeKeys(
|
|
|
212
214
|
return diagnostics;
|
|
213
215
|
}
|
|
214
216
|
const STATIC_KEYS = ['accept', 'desc'];
|
|
215
|
-
const LAYOUT_TOP_KEYS = ['frame', 'max_width', 'sticky_header', 'header', 'sidebar', 'footer', 'rules'];
|
|
216
|
-
const MAX_WIDTH_VALUES = ['narrow', 'medium', 'wide', 'full'] as const;
|
|
217
|
+
const LAYOUT_TOP_KEYS = ['frame', 'max_width', 'sticky_header', 'bleed', 'header', 'sidebar', 'footer', 'rules'];
|
|
218
|
+
const MAX_WIDTH_VALUES = ['narrow', 'medium', 'wide', 'xwide', 'full'] as const;
|
|
217
219
|
const LAYOUT_HEADER_KEYS = ['brand', 'nav', 'actions'];
|
|
218
220
|
const LAYOUT_SIDEBAR_KEYS = ['title', 'width', 'menu'];
|
|
219
221
|
const LAYOUT_FOOTER_KEYS = ['text', 'links'];
|
|
@@ -489,12 +491,16 @@ export function parseAppConfig(raw: unknown, diagnostics: KitDiagnostic[]): KitA
|
|
|
489
491
|
if (rawLayout.max_width !== undefined) {
|
|
490
492
|
const mw = typeof rawLayout.max_width === 'string' ? rawLayout.max_width.trim() : '';
|
|
491
493
|
if (!(MAX_WIDTH_VALUES as readonly string[]).includes(mw)) bad(layoutKeyPath('max_width'), `max_width「${String(rawLayout.max_width)}」只能是 ${MAX_WIDTH_VALUES.join(' / ')}`, diagnostics);
|
|
492
|
-
else layout.maxWidth = mw as '
|
|
494
|
+
else layout.maxWidth = mw as KitAppLayout['maxWidth'];
|
|
493
495
|
}
|
|
494
496
|
if (rawLayout.sticky_header !== undefined) {
|
|
495
497
|
if (typeof rawLayout.sticky_header === 'boolean') layout.stickyHeader = rawLayout.sticky_header;
|
|
496
498
|
else bad(layoutKeyPath('sticky_header'), 'sticky_header 必须是布尔值', diagnostics);
|
|
497
499
|
}
|
|
500
|
+
if (rawLayout.bleed !== undefined) {
|
|
501
|
+
if (typeof rawLayout.bleed === 'boolean') layout.bleed = rawLayout.bleed;
|
|
502
|
+
else bad(layoutKeyPath('bleed'), 'bleed 必须是布尔值', diagnostics);
|
|
503
|
+
}
|
|
498
504
|
if (rawLayout.header !== undefined) {
|
|
499
505
|
const hp = layoutKeyPath('header');
|
|
500
506
|
if (!isRecord(rawLayout.header)) {
|
|
@@ -15,9 +15,9 @@ import { KIT_BASE_COMPONENTS } from '../base/index';
|
|
|
15
15
|
import { KIT_EXTRA_COMPONENT_CANDIDATES } from '../compile/component-candidates';
|
|
16
16
|
import { KIT_STATIC_BUILTIN_LAZY_NAMES } from '../data/static-lazy';
|
|
17
17
|
import { KIT_RESIDENT_COMPONENT_NAMES, wrappedCandidateSource } from '../data/wrapped-candidates';
|
|
18
|
-
import { checkClasses } from '../
|
|
18
|
+
import { checkClasses } from '../shared/merge-class';
|
|
19
19
|
import type { KitDiagnostic } from '../object-renderer/types';
|
|
20
|
-
import { kitFail } from '../
|
|
20
|
+
import { kitFail } from '../shared/kit-error';
|
|
21
21
|
import { getKitControllerSource, isKitControllerFactory } from '../base/shared';
|
|
22
22
|
|
|
23
23
|
/** declareKitUses 允许引用的内置组件全集 */
|
package/src/app/compose-apps.ts
CHANGED
|
@@ -14,9 +14,10 @@ import type { SomaEventMiddlewareContext } from 'soma-core';
|
|
|
14
14
|
import { kitText } from '../i18n/kit-text';
|
|
15
15
|
import { kitActionExtras } from '../biz/shared/runtime-hub';
|
|
16
16
|
import { kitPermissionAllows } from '../base/permission-gate';
|
|
17
|
+
import { reportKitInlineError } from '../base/inline-error';
|
|
17
18
|
import type { DefineKitAppOptions } from './define-kit-app';
|
|
18
19
|
import type { KitViewClass } from './define-kit-view';
|
|
19
|
-
import { KitDiagnosticError, kitFail } from '../
|
|
20
|
+
import { KitDiagnosticError, kitFail } from '../shared/kit-error';
|
|
20
21
|
|
|
21
22
|
type Grant = ReturnType<NonNullable<DefineKitAppOptions['pageGrants']>>[number];
|
|
22
23
|
type ExclusiveKey = 'auth' | 'eventMiddleware' | 'login';
|
|
@@ -217,7 +218,9 @@ export function createKitPermissionMiddleware(): SomaMiddlewareChain<SomaEventMi
|
|
|
217
218
|
if (typeof code === 'string' && code !== '' && !kitPermissionAllows(code)) {
|
|
218
219
|
context.status = 'blocked';
|
|
219
220
|
context.message = kitText('soma.kit.perm_denied', { code });
|
|
220
|
-
|
|
221
|
+
// 无权限也是动作失败:就地提示条(窗口内进窗口槽,页面级进页头下),无槽回退轻提示(KT-K-feedback-3,§6.1 G-17)
|
|
222
|
+
const denied = context.message;
|
|
223
|
+
reportKitInlineError(context.element instanceof Element ? context.element : null, denied, `perm:${code}`, () => kitActionExtras(context.element).notify(denied, 'danger'));
|
|
221
224
|
return;
|
|
222
225
|
}
|
|
223
226
|
await next();
|
|
@@ -12,9 +12,12 @@
|
|
|
12
12
|
// - 每个动作进行中都登记到 base/action-busy(忙闲通道):带保存钮的组件声明 busy_action 即可禁用触发钮、防重复提交。
|
|
13
13
|
|
|
14
14
|
import { currentKitActionTarget, getKitHubByScope, hasKitHub, kitActionExtras, type KitActionExtras } from '../biz/shared/runtime-hub';
|
|
15
|
+
import { KIT_SUBMIT_ACTIONS_ATTR } from '../biz/shared/overlay-shell';
|
|
16
|
+
import { kitText } from '../i18n/kit-text';
|
|
15
17
|
import { beginKitAction } from '../base/action-busy';
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
+
import { clearKitInlineError, reportKitInlineError } from '../base/inline-error';
|
|
19
|
+
import { envelopeMessage, isEnvelopeFailure, kitHostEnvelopeAt, type KitEnvelope } from '../shared/envelope';
|
|
20
|
+
import { kitFail } from '../shared/kit-error';
|
|
18
21
|
import { SOMA_STD_KEY_LIMITS } from 'soma-core';
|
|
19
22
|
import { SOMA_PIPELINE_HOST_HTTP_REQUEST_TIMEOUT_MS } from 'soma-foundation/values';
|
|
20
23
|
|
|
@@ -36,6 +39,11 @@ export interface KitActionHttp {
|
|
|
36
39
|
}
|
|
37
40
|
|
|
38
41
|
export interface KitActionArgs extends KitActionExtras {
|
|
42
|
+
/**
|
|
43
|
+
* 浮层的提交动作成功后框架默认关窗并给成功反馈;调用它表示这次不关(例如保存后留在窗口里继续编辑)。
|
|
44
|
+
* 处理函数自己调过 close() / notify() 的,框架不重复。
|
|
45
|
+
*/
|
|
46
|
+
keepOpen(): void;
|
|
39
47
|
row: Record<string, unknown>;
|
|
40
48
|
value: unknown;
|
|
41
49
|
/** core 交来的完整载荷 */
|
|
@@ -44,6 +52,16 @@ export interface KitActionArgs extends KitActionExtras {
|
|
|
44
52
|
}
|
|
45
53
|
|
|
46
54
|
export type KitActionHandler = (args: KitActionArgs) => unknown;
|
|
55
|
+
|
|
56
|
+
/** 请求层失败(HTTP 非 2xx / 非 JSON):message 是给开发者的技术原话(方法、地址、状态码),给用户的提示另取产品文案 */
|
|
57
|
+
export class KitActionRequestError extends Error {
|
|
58
|
+
readonly detail: { method: string; url: string; status: number };
|
|
59
|
+
constructor(message: string, detail: { method: string; url: string; status: number }) {
|
|
60
|
+
super(message);
|
|
61
|
+
this.name = 'KitActionRequestError';
|
|
62
|
+
this.detail = detail;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
47
65
|
/** 带动作级缺省超时的登记条目:`{ handler, timeoutMs }`;timeoutMs 取 0(禁用)或 write.timeoutMs 区间内的整数毫秒 */
|
|
48
66
|
export interface KitActionEntry {
|
|
49
67
|
handler: KitActionHandler;
|
|
@@ -129,14 +147,14 @@ async function request(
|
|
|
129
147
|
|
|
130
148
|
try {
|
|
131
149
|
const res = await fetch(fullUrl, { ...init, signal: controller.signal });
|
|
132
|
-
if (!res.ok) throw new
|
|
150
|
+
if (!res.ok) throw new KitActionRequestError(`请求失败 ${method} ${fullUrl}:HTTP ${res.status}`, { method, url: fullUrl, status: res.status });
|
|
133
151
|
const text = await res.text();
|
|
134
152
|
let json: unknown = null;
|
|
135
153
|
if (text !== '') {
|
|
136
154
|
try {
|
|
137
155
|
json = JSON.parse(text);
|
|
138
156
|
} catch {
|
|
139
|
-
throw new
|
|
157
|
+
throw new KitActionRequestError(`请求失败 ${method} ${fullUrl}:接口返回了非 JSON 内容(可能登录态已失效或网关拦截)`, { method, url: fullUrl, status: res.status });
|
|
140
158
|
}
|
|
141
159
|
}
|
|
142
160
|
// 业务信封失败:判定与文案位置来自应用声明的信封约定(kit.app.yaml#envelope),这里不写任何后端字段
|
|
@@ -221,17 +239,43 @@ export function isKitDefinedAction(action: KitNamedAction): boolean {
|
|
|
221
239
|
return DEFINED_ACTION_FACTORIES.has(action);
|
|
222
240
|
}
|
|
223
241
|
|
|
242
|
+
/** 触发元素所在的浮层把这个动作登记为它的「提交」动作(biz/shared/overlay-shell 的 KIT_SUBMIT_ACTIONS_ATTR) */
|
|
243
|
+
function isOverlaySubmitAction(target: KitActionTarget, name: string): boolean {
|
|
244
|
+
if (!(typeof Element !== 'undefined' && target instanceof Element)) return false;
|
|
245
|
+
const host = target.closest(`[${KIT_SUBMIT_ACTIONS_ATTR}]`);
|
|
246
|
+
return host !== null && (host.getAttribute(KIT_SUBMIT_ACTIONS_ATTR) ?? '').split(/\s+/).includes(name);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* 动作失败给用户的文案:请求层的失败(HTTP 非 2xx、超时、取消、非 JSON)不露出方法与地址等引擎原话,换成产品文案;
|
|
251
|
+
* 业务信封的失败消息(后端写给人看的)与处理函数自己抛的错误文案原样给出。技术细节留在控制台。
|
|
252
|
+
*/
|
|
253
|
+
function kitActionFailureText(error: unknown, at: KitActionTarget): string {
|
|
254
|
+
const el = typeof Element !== 'undefined' && at instanceof Element ? at : null;
|
|
255
|
+
if (error instanceof KitActionRequestError) {
|
|
256
|
+
console.error('[soma-kit] 具名动作请求失败', error.detail);
|
|
257
|
+
return kitText('soma.kit.request_failed', undefined, el);
|
|
258
|
+
}
|
|
259
|
+
return error instanceof Error && error.message !== '' ? error.message : String(error);
|
|
260
|
+
}
|
|
261
|
+
|
|
224
262
|
function createNamedAction(name: string, handler: KitActionHandler, httpFor: KitActionHttpFor): KitNamedAction {
|
|
225
263
|
return async (payload) => {
|
|
226
264
|
const p = payload ?? {};
|
|
227
265
|
// 动作目标在调用同步段里取一次(此后 handler 可能 await,栈顶会换成别的动作的目标)
|
|
228
266
|
const ambientTarget = currentKitActionTarget();
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
267
|
+
// 绑定目标按「载荷 scope → 载荷 object → 触发元素 / 动作栈」取第一个真有协调组件登记的;
|
|
268
|
+
// 内置件(PermissionTree / AssignmentPicker 等)抛出的 object 是页面作者写的组件 prop(如 role_menu),不一定是协调组件的对象名,
|
|
269
|
+
// 命中不了协调组件时必须退到触发元素,否则 focusRow() / selected 全部读空(AF-8)。都命中不了才保留第一个候选(信封解析仍可用它)。
|
|
270
|
+
const candidates: Array<string | HTMLElement | undefined> = [
|
|
271
|
+
typeof p.scope === 'string' && p.scope !== '' ? p.scope : undefined,
|
|
272
|
+
typeof p.object === 'string' && p.object !== '' ? p.object : undefined,
|
|
273
|
+
ambientTarget,
|
|
274
|
+
];
|
|
275
|
+
const hubHit = candidates.find((c) => c !== undefined && hasKitHub(c));
|
|
276
|
+
const boundTarget = hubHit ?? ambientTarget;
|
|
233
277
|
// 本次调用的信封:按 boundTarget 所属页面宿主解析一次(定位不到元素时退回调用时的动作目标),固定进本次专用的 http
|
|
234
|
-
const http = httpFor(targetEnvelope(
|
|
278
|
+
const http = httpFor(targetEnvelope(hubHit ?? candidates.find((c) => c !== undefined), ambientTarget));
|
|
235
279
|
const extras = kitActionExtras(boundTarget);
|
|
236
280
|
const row = p.row !== null && typeof p.row === 'object' ? (p.row as Record<string, unknown>) : {};
|
|
237
281
|
const end = beginKitAction(name);
|
|
@@ -240,13 +284,41 @@ function createNamedAction(name: string, handler: KitActionHandler, httpFor: Kit
|
|
|
240
284
|
const endRow = typeof p.kit_row_busy === 'string' && p.kit_row_busy !== '' ? beginKitAction(p.kit_row_busy) : undefined;
|
|
241
285
|
try {
|
|
242
286
|
let result: unknown;
|
|
287
|
+
// 反馈唯一出口(AF-8):动作抛错时用户必须看到一条提示,不能只进控制台;处理函数自己已发过危险提示的不重复弹
|
|
288
|
+
let toasted = false;
|
|
289
|
+
let informed = false;
|
|
290
|
+
let closed = false;
|
|
291
|
+
let keep = false;
|
|
292
|
+
const notify: KitActionExtras['notify'] = (message, tone) => {
|
|
293
|
+
if (tone === 'danger') toasted = true;
|
|
294
|
+
else informed = true;
|
|
295
|
+
extras.notify(message, tone);
|
|
296
|
+
};
|
|
297
|
+
const close: KitActionExtras['close'] = (scope) => {
|
|
298
|
+
closed = true;
|
|
299
|
+
extras.close(scope);
|
|
300
|
+
};
|
|
243
301
|
try {
|
|
244
|
-
result = await handler({ ...extras, row, value: p.value, payload: p, http });
|
|
302
|
+
result = await handler({ ...extras, notify, close, keepOpen: () => { keep = true; }, row, value: p.value, payload: p, http });
|
|
303
|
+
} catch (error) {
|
|
304
|
+
// 错误不用轻提示(KT-K-feedback-3,§6.1 G-17):失败在发起处给就地提示条(窗口内进窗口槽,页面级进页头下),无槽才回退轻提示
|
|
305
|
+
if (!toasted) {
|
|
306
|
+
const failure = kitActionFailureText(error, ambientTarget);
|
|
307
|
+
reportKitInlineError(ambientTarget instanceof Element ? ambientTarget : null, failure, `action:${name}`, () => extras.notify(failure, 'danger'));
|
|
308
|
+
}
|
|
309
|
+
throw error;
|
|
245
310
|
} finally {
|
|
246
311
|
end();
|
|
247
312
|
}
|
|
248
313
|
// 返回 false = 动作主动中止:与抛错同一口径
|
|
249
314
|
if (result === false) throw new Error(`[soma-kit] 具名动作 ${name} 返回 false,终止后续步骤`);
|
|
315
|
+
// 同一动作下一次成功:撤掉它上一次失败留下的就地提示条(KT-K-feedback-3)
|
|
316
|
+
clearKitInlineError(ambientTarget instanceof Element ? ambientTarget : null, `action:${name}`);
|
|
317
|
+
// 浮层的提交动作(编译期在浮层外层登记)成功:框架默认关窗 + 成功反馈;处理函数自己关过 / 提示过的不重复,调了 keepOpen() 的不关
|
|
318
|
+
if (!keep && isOverlaySubmitAction(ambientTarget, name)) {
|
|
319
|
+
if (!closed) extras.close();
|
|
320
|
+
if (!informed) extras.notify(kitText('soma.kit.saved', undefined, ambientTarget instanceof Element ? ambientTarget : null), 'success');
|
|
321
|
+
}
|
|
250
322
|
// 业务组件的固定协作:有协调组件的页面里,动作成功后重取主对象与附带对象(重取失败只记日志,不让动作失败)
|
|
251
323
|
if (hasKitHub(boundTarget)) {
|
|
252
324
|
try { await extras.reload(); } catch (error) { console.error('[soma-kit] 具名动作后的重取失败', error); }
|
|
@@ -20,11 +20,12 @@ import { KIT_BIZ_COMPONENT_NAMES, KIT_FRAME_NAMES } from '../biz/names';
|
|
|
20
20
|
import type { KitBizDefinition } from '../biz/types';
|
|
21
21
|
import type { KitThemeConfig } from '../theme/theme-tokens';
|
|
22
22
|
import type { KitAppDicts, KitAppEntities, KitAppTheme } from './app-config';
|
|
23
|
-
import { parseKitAppEnvelopeFromYaml, registerKitAppDefaultEnvelope, type KitEnvelope } from '
|
|
23
|
+
import { parseKitAppEnvelopeFromYaml, registerKitAppDefaultEnvelope, type KitEnvelope } from '../shared/envelope';
|
|
24
24
|
import { KitPackError, type KitPack } from './define-kit-pack';
|
|
25
25
|
import { readKitViewInfo, type KitViewClass } from './define-kit-view';
|
|
26
26
|
import type { KitDiagnostic } from '../object-renderer/types';
|
|
27
27
|
import { createKitResidentDataComponents } from '../data/resident';
|
|
28
|
+
import { createKitFrameResidentComponents } from '../frames/resident-components';
|
|
28
29
|
import { addWrappedOwnCandidates } from '../data/wrapped-candidates';
|
|
29
30
|
import { assertSinglePathComponent } from './component-gate';
|
|
30
31
|
import { KIT_STATIC_BUILTIN_LAZY_NAMES as KIT_STATIC_BUILTIN_NAMES, KIT_STATIC_LAZY_LOADERS } from '../data/static-lazy';
|
|
@@ -32,10 +33,10 @@ import type { KitFrameDefinition } from '../frames/types';
|
|
|
32
33
|
import { bindKitActionRequestTimeout, isKitDefinedAction, validateKitAppRequestTimeout, type KitNamedAction } from './define-kit-actions';
|
|
33
34
|
import type { KitServerFace } from './server';
|
|
34
35
|
import { checkNoRelativeOrSystemPath } from '../shared/path-guard';
|
|
35
|
-
import { kitFail } from '../
|
|
36
|
+
import { kitFail } from '../shared/kit-error';
|
|
36
37
|
import { configureKitThemeAppId, installKitThemeRuntime, restoreKitThemeBeforeFirstPaint } from './theme-runtime';
|
|
37
38
|
import { withActiveKitActionTarget } from '../biz/shared/runtime-hub';
|
|
38
|
-
import { buildKitThemeBootDataElement, buildKitThemeFirstPaintScript, isKitThemePath, toKitRuntimeTheme } from '
|
|
39
|
+
import { buildKitThemeBootDataElement, buildKitThemeFirstPaintScript, isKitThemePath, toKitRuntimeTheme } from '../shared/theme-runtime-shared';
|
|
39
40
|
|
|
40
41
|
export { checkNoRelativeOrSystemPath };
|
|
41
42
|
|
|
@@ -406,8 +407,8 @@ function mergePacks(packs: readonly KitPack[], t: PackMergeTarget): void {
|
|
|
406
407
|
export function buildBrowserMount(registry: KitAppRegistry): KitBrowserMount {
|
|
407
408
|
const base: Record<string, SomaComponentDefinition> = { ...createKitBaseComponents(), ...registry.baseComponents };
|
|
408
409
|
const data = createKitResidentDataComponents(base);
|
|
409
|
-
//
|
|
410
|
-
const components: Record<string, SomaComponentDefinition> = { ...base, ...data, ...bizDataComponents() };
|
|
410
|
+
// 业务组件壳与页面框层依赖的协作常驻组件与内置数据组件同表;内置名不与应用名冲突(应用名须 App 开头)
|
|
411
|
+
const components: Record<string, SomaComponentDefinition> = { ...base, ...data, ...createKitFrameResidentComponents(), ...bizDataComponents() };
|
|
411
412
|
for (const [name, entry] of Object.entries(registry.staticComponents)) components[name] = entry.definition;
|
|
412
413
|
for (const [name, def] of Object.entries(registry.packDataComponents)) components[name] = def;
|
|
413
414
|
// 应用登记项同名覆盖内置时,常驻表优先(core 以 components 为准),不再按需加载内置版
|
|
@@ -31,7 +31,7 @@ export { readKitViewInfo };
|
|
|
31
31
|
import type { SomaPageRootBase, SomaState, SomaViewContext } from 'soma-core/base';
|
|
32
32
|
import { extendKitViewContext, type KitViewContext } from './kit-view-context';
|
|
33
33
|
import { findSharedStateReferences, type ViewStateShape } from 'soma-foundation/view-state';
|
|
34
|
-
import { kitFail } from '../
|
|
34
|
+
import { kitFail } from '../shared/kit-error';
|
|
35
35
|
import { isViewName } from '../object-renderer/view-binding';
|
|
36
36
|
|
|
37
37
|
/** 表单草稿钩子(`view.form.onDraft`)等展示对象方法的标准载荷类型 */
|
package/src/app/index.ts
CHANGED
|
@@ -16,8 +16,8 @@ export { defineKitActions, kitActionHttp, createKitActionHttp } from './define-k
|
|
|
16
16
|
export type { KitActionArgs, KitActionHandler, KitActionHttp, KitNamedAction } from './define-kit-actions';
|
|
17
17
|
// 业务信封读取(浏览器与服务端共用的约定读取点);分页整形助手(createPagedListAdapter / cursorPageWindow / withRowId)
|
|
18
18
|
// 实现在 soma-core/server/paged-list,kit 应用只经服务端入口 soma-kit/app/server 取用(J6;浏览器入口不导出)
|
|
19
|
-
export { unwrapEnvelope as unwrapBizEnvelope, isEnvelopeFailure as isBizFailure } from '
|
|
20
|
-
export type { UnwrappedEnvelope } from '
|
|
19
|
+
export { unwrapEnvelope as unwrapBizEnvelope, isEnvelopeFailure as isBizFailure } from '../shared/envelope';
|
|
20
|
+
export type { UnwrappedEnvelope } from '../shared/envelope';
|
|
21
21
|
export { KIT_PLACEHOLDER_URL, KitSubmitError } from './submit.types';
|
|
22
22
|
export type {
|
|
23
23
|
KitPageBindingView,
|
|
@@ -29,14 +29,14 @@ export type {
|
|
|
29
29
|
KitSubmitPersist,
|
|
30
30
|
KitSubmitResult,
|
|
31
31
|
} from './submit.types';
|
|
32
|
-
export { isEnvelopeFailure, envelopeMessage, unwrapEnvelope, parseKitEnvelope, getKitAppEnvelope } from '
|
|
33
|
-
export type { KitEnvelope } from '
|
|
32
|
+
export { isEnvelopeFailure, envelopeMessage, unwrapEnvelope, parseKitEnvelope, getKitAppEnvelope } from '../shared/envelope';
|
|
33
|
+
export type { KitEnvelope } from '../shared/envelope';
|
|
34
34
|
export { parseAppConfig } from './app-config';
|
|
35
35
|
// 运行期主题切换(浏览器面):服务端端点按九维声明求解令牌 CSS,浏览器替换 <style data-soma-kit-theme>
|
|
36
36
|
export { applyKitTheme, currentKitTheme, currentKitThemeOverrides, resetKitThemeOverrides, readAppBaseTheme, subscribeKitTheme, installKitThemeRuntime, restoreKitThemeBeforeFirstPaint, buildKitThemeFirstPaintScript, kitThemeStorageKey, kitThemeCssStorageKey, normalizeKitThemeAppId, configureKitThemeAppId, currentKitThemeAppId, normalizeKitRuntimeTheme, kitThemeQuery, KIT_THEME_ENDPOINT, KIT_THEME_STYLE_ATTR, KIT_THEME_STORAGE_KEY, KIT_THEME_CSS_STORAGE_KEY, KIT_THEME_CHANNEL, KIT_RUNTIME_THEME_KEYS } from './theme-runtime';
|
|
37
37
|
export type { ApplyKitThemeOptions, KitRuntimeTheme, KitRuntimeThemeKey, KitThemeApplyResult, KitThemeTables } from './theme-runtime';
|
|
38
38
|
export type { KitAppConfig, KitAppTheme } from './app-config';
|
|
39
|
-
export { createKitNotifyRenderer, KIT_NOTIFY_CLASS_CANDIDATES } from '
|
|
39
|
+
export { createKitNotifyRenderer, KIT_NOTIFY_CLASS_CANDIDATES } from '../data/notify-renderer';
|
|
40
40
|
/** 权限集异步加载完成后显式调用:已挂载的带权限码按钮按新权限重判显隐(core 权限服务无变更通知) */
|
|
41
41
|
export { addKitPermissionChecker, kitPermissionAllows, refreshKitPermissionGates, setKitPermissionChecker } from '../base/permission-gate';
|
|
42
42
|
// 应用叠加合并:把叠加应用并入基座应用的选项(登记表重名报错、基座独占面、requestHook 链、pageGrants 并集)与权限并集的点击拦截
|
|
@@ -54,7 +54,8 @@ export type { KitFieldA11yOptions, KitFieldState, KitComponentField, KitSelectFi
|
|
|
54
54
|
// 命令式 Date 字段(自绘日历,无原生 date 输入):与 mountKitSelectField 同族,支持 labelledby / required / invalid
|
|
55
55
|
export { mountKitDateField } from '../base/date';
|
|
56
56
|
export type { KitDateField, KitDateFieldOptions, KitDateFieldState } from '../base/date';
|
|
57
|
-
export { declareKitUses, declareKitStatePanel } from '../data/wrapped-candidates';
|
|
57
|
+
export { declareKitUses, declareKitStatePanel, declareKitComposition } from '../data/wrapped-candidates';
|
|
58
|
+
export type { KitCompositionRole } from '../data/wrapped-candidates';
|
|
58
59
|
// 应用组件的悬停提示(经浮层端口,不被 overflow 裁切)
|
|
59
60
|
export { kitTooltip, releaseReasonTipsIn, KIT_APP_TOOLTIP_CLASS_CANDIDATES } from '../base/reason-tip';
|
|
60
61
|
export type { KitTooltipOptions } from '../base/reason-tip';
|
|
@@ -65,10 +66,21 @@ export { createKitController, KIT_CONTROLLER, isKitControllerFactory, classCandi
|
|
|
65
66
|
export type { KitApi, KitView, KitViewSetup } from '../base/shared';
|
|
66
67
|
export { KIT_TYPOGRAPHY, KIT_TYPOGRAPHY_CLASS_CANDIDATES } from '../theme/typography';
|
|
67
68
|
export type { KitTypographyRole } from '../theme/typography';
|
|
69
|
+
// 控件几何配方与字阶配方(应用组件的按钮 / 输入 / 标题不要手写类串,直接取这两个出口;取值在 soma-design 真源 kit-control.json / kit-type.json)
|
|
70
|
+
export {
|
|
71
|
+
kitControlRecipe,
|
|
72
|
+
kitTextActionRecipe,
|
|
73
|
+
kitSegmentRecipe,
|
|
74
|
+
kitHelpTriggerRecipe,
|
|
75
|
+
KIT_CONTROL_RECIPE_CLASS_CANDIDATES,
|
|
76
|
+
kitTypographyRecipe,
|
|
77
|
+
KIT_TYPOGRAPHY_RECIPE_CLASS_CANDIDATES,
|
|
78
|
+
} from '../recipes';
|
|
79
|
+
export type { KitControlRecipeOptions, KitControlVariant, KitControlSize, KitTypographyRecipeRole } from '../recipes';
|
|
68
80
|
export type { KitBizContext, KitBizDefinition, KitBizInput, KitBizRole, KitOverlayDecl } from '../biz/types';
|
|
69
81
|
export type { KitFrameCapabilities, KitFrameDefinition, KitFrameInput, KitPageMeta } from '../frames/types';
|
|
70
|
-
export { emptyFragment, mergeFragments, fragmentFromEmit } from '../
|
|
71
|
-
export type { KitFragment } from '../
|
|
82
|
+
export { emptyFragment, mergeFragments, fragmentFromEmit } from '../object-renderer/fragment';
|
|
83
|
+
export type { KitFragment } from '../object-renderer/fragment';
|
|
72
84
|
export type { KitDiagnostic, KitObject } from '../object-renderer/types';
|
|
73
85
|
|
|
74
86
|
// core 的公开类型再导出:kit 应用写自定义组件 / 控制器 / 鉴权选项时统一从 soma-kit/app 或 soma-core 取用
|
|
@@ -13,11 +13,11 @@ import {
|
|
|
13
13
|
} from '../biz/shared/object-aliases';
|
|
14
14
|
import { OUTCOME_KEY_SEP, outcomeScopeOf } from '../base/action-gate';
|
|
15
15
|
import { failKitOutcome } from '../data/outcome-watch';
|
|
16
|
-
import { viewAnchor } from '../object-renderer/emit-static';
|
|
16
|
+
import { opsAnchor, selAnchor, viewAnchor } from '../object-renderer/emit-static';
|
|
17
17
|
import { KIT_ACT_SCOPE, requestSemanticName } from '../object-renderer/request-actions';
|
|
18
18
|
import type { KitRequestSpec } from '../object-renderer/request-actions';
|
|
19
19
|
import { KIT_GRAMMAR } from '../object-renderer/defaults';
|
|
20
|
-
import { getKitAppEnvelope, unwrapEnvelope, type KitEnvelope } from '
|
|
20
|
+
import { getKitAppEnvelope, unwrapEnvelope, type KitEnvelope } from '../shared/envelope';
|
|
21
21
|
import { kitActionExtras, openKitHubCreate, type KitNotifyTone } from '../biz/shared/runtime-hub';
|
|
22
22
|
import { runtimeNoticeText } from '../object-renderer/form-notify';
|
|
23
23
|
import { askKitConfirm, type KitConfirmOptions } from '../data/confirm-dialog';
|
|
@@ -328,7 +328,24 @@ export function extendKitViewContext(ctx: SomaViewContext, viewName?: string): K
|
|
|
328
328
|
askKitConfirm({ ...options, message, signal: dialogs.signal }) },
|
|
329
329
|
prompt: { value: (spec: KitViewPromptSpec): Promise<Record<string, string> | null> =>
|
|
330
330
|
askKitPrompt({ ...spec, signal: dialogs.signal }) },
|
|
331
|
-
view: { value: (object: string, slot: KitViewSlot): SomaViewComponentHandle =>
|
|
331
|
+
view: { value: (object: string, slot: KitViewSlot): SomaViewComponentHandle => {
|
|
332
|
+
const runtime = nameOf(object, 'view');
|
|
333
|
+
const base = ctx.component(viewAnchor(runtime, slot));
|
|
334
|
+
if (slot !== 'list') return base;
|
|
335
|
+
// 列表视图的行动作 / 行选择事件由行内组件发出(`<对象>__list__ops` / `__sel`),不是列表锚点本身:
|
|
336
|
+
// `ctx.view(对象,'list').on(...)` 同时订阅这几个发出者,按文档写法就收得到;`call` / `props` 仍指向列表锚点
|
|
337
|
+
const emitters = [base, ctx.component(opsAnchor(runtime)), ctx.component(selAnchor(runtime))];
|
|
338
|
+
return {
|
|
339
|
+
id: base.id,
|
|
340
|
+
mounted: () => base.mounted(),
|
|
341
|
+
props: () => base.props(),
|
|
342
|
+
call: (method, ...args) => base.call(method, ...args),
|
|
343
|
+
on: (emit, listener) => {
|
|
344
|
+
const offs = emitters.map((h) => h.on(emit, listener));
|
|
345
|
+
return () => { for (const off of offs) off(); };
|
|
346
|
+
},
|
|
347
|
+
} as SomaViewComponentHandle;
|
|
348
|
+
} },
|
|
332
349
|
form: { value: (object: string, slot: KitFormHandleSlot = 'form'): KitFormHandle => {
|
|
333
350
|
const runtime = nameOf(object, 'form');
|
|
334
351
|
const key = viewAnchor(runtime, slot);
|
|
@@ -352,12 +369,21 @@ export function extendKitViewContext(ctx: SomaViewContext, viewName?: string): K
|
|
|
352
369
|
if (view.status === 'pending' || view.status === 'idle') return;
|
|
353
370
|
const rowKey = scope === into ? undefined : scope.slice(into.length + OUTCOME_KEY_SEP.length);
|
|
354
371
|
const result = asRec(view.result);
|
|
372
|
+
const rawData = result.data;
|
|
373
|
+
let data: unknown = rawData;
|
|
374
|
+
if (view.status === 'saved' && rawData !== undefined) {
|
|
375
|
+
const env = getKitAppEnvelope();
|
|
376
|
+
if (env !== undefined) {
|
|
377
|
+
const unwrapped = unwrapEnvelope(rawData, env);
|
|
378
|
+
if (unwrapped.ok && unwrapped.data !== undefined) data = unwrapped.data;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
355
381
|
listener({
|
|
356
382
|
scope,
|
|
357
383
|
ok: view.status === 'saved',
|
|
358
384
|
status: view.status,
|
|
359
385
|
message: view.message,
|
|
360
|
-
data
|
|
386
|
+
data,
|
|
361
387
|
...(rowKey !== undefined ? { rowKey } : {}),
|
|
362
388
|
});
|
|
363
389
|
}) },
|
package/src/app/server-pages.ts
CHANGED
|
@@ -18,6 +18,7 @@ import type { PageProvenance } from 'soma-core/page-target';
|
|
|
18
18
|
import { SOMA_PIPELINE_LIMITS } from 'soma-core/pipeline/limits';
|
|
19
19
|
import { canonicalJson, fnv1a64Hex } from 'soma-foundation/fingerprint';
|
|
20
20
|
import { compileKitPage } from '../compile/compile-page';
|
|
21
|
+
import { KIT_VERSION_PREFIX } from '../compile/producer-fingerprint';
|
|
21
22
|
import { createYamlLocator } from '../compile/locate';
|
|
22
23
|
import type { KitAppContext, KitPageArtifact } from '../compile/types';
|
|
23
24
|
import { KIT_LAYOUT_LATEST_PIN } from '../object-renderer/layout-plan';
|
|
@@ -251,7 +252,7 @@ export function createKitServerPages(deps: KitServerPagesDeps): KitServerPages {
|
|
|
251
252
|
}));
|
|
252
253
|
|
|
253
254
|
const sourceDigest = kitSourceDigest(source.source);
|
|
254
|
-
const
|
|
255
|
+
const built = runtime.buildRegisterRequest({
|
|
255
256
|
address,
|
|
256
257
|
owner: KIT_PAGE_OWNER,
|
|
257
258
|
format: KIT_PAGE_FORMAT,
|
|
@@ -261,6 +262,9 @@ export function createKitServerPages(deps: KitServerPagesDeps): KitServerPages {
|
|
|
261
262
|
caller,
|
|
262
263
|
now,
|
|
263
264
|
});
|
|
265
|
+
// 版本带产出方指纹(kit 包版本 + 默认值指纹):落盘的持久页升级后由 kit 的版本守卫判过期并丢弃(与装配期注册的表内页同一套),
|
|
266
|
+
// 载荷摘要仍是判重依据(同载荷同指纹才判未变)
|
|
267
|
+
const request = { ...built, version: `${KIT_VERSION_PREFIX}${built.version}`, options: { ...built.options, version: `${KIT_VERSION_PREFIX}${built.options.version}` } } as typeof built;
|
|
264
268
|
if (options.dryRun !== true) guard(() => runtime.checkExpectedGeneration(runtime, address, options.expectGeneration));
|
|
265
269
|
return {
|
|
266
270
|
address,
|
package/src/app/server.ts
CHANGED
|
@@ -6,8 +6,10 @@ import { KIT_DEV_DIAGNOSTIC_ATTR, KIT_DEV_DIAGNOSTIC_VALUE } from './dev-diagnos
|
|
|
6
6
|
|
|
7
7
|
import { createHash } from 'node:crypto';
|
|
8
8
|
import { canonicalJson } from 'soma-foundation/fingerprint';
|
|
9
|
+
import { KIT_DEFAULTS_DIGEST, KIT_VERSION_PREFIX, kitDefaultsDigestOf, kitVersionGuard } from '../compile/producer-fingerprint';
|
|
9
10
|
import { KIT_BASE_COMPONENTS } from '../base/index';
|
|
10
11
|
import { KIT_STATIC_BUILTIN_SPECS, staticPropTypesOf } from '../data/static-registry';
|
|
12
|
+
import { kitCompositionOf, type KitCompositionRole } from '../data/wrapped-candidates';
|
|
11
13
|
import { compileKitPage, KIT_ROOT_HOST } from '../compile/compile-page';
|
|
12
14
|
import grammarJson from '../../spec/kit-grammar.json';
|
|
13
15
|
import { inferPageUrlFromPath } from '../compile/parse';
|
|
@@ -39,6 +41,9 @@ export const KIT_GRAMMAR_DIGEST = createHash('sha256')
|
|
|
39
41
|
export const KIT_GRAMMAR_VERSION = KIT_GRAMMAR_DIGEST;
|
|
40
42
|
export const MAX_KIT_PAGE_CACHE = 256;
|
|
41
43
|
|
|
44
|
+
// 默认值指纹与产出方指纹的定义在 compile/producer-fingerprint(页面 version 与进程内缓存键共用)
|
|
45
|
+
export { KIT_DEFAULTS_DIGEST, kitDefaultsDigestOf };
|
|
46
|
+
|
|
42
47
|
const kitPageCompileCache = new Map<string, KitPageArtifact>();
|
|
43
48
|
const kitRegistryCacheScopeIds = new WeakMap<KitAppRegistry, number>();
|
|
44
49
|
let nextKitRegistryCacheScopeId = 1;
|
|
@@ -261,6 +266,8 @@ function computeKitPageCacheKeyInternal(
|
|
|
261
266
|
return createHash('sha256')
|
|
262
267
|
.update(KIT_GRAMMAR_DIGEST)
|
|
263
268
|
.update('\0')
|
|
269
|
+
.update(KIT_DEFAULTS_DIGEST)
|
|
270
|
+
.update('\0')
|
|
264
271
|
.update(canonicalJson(normalized))
|
|
265
272
|
.digest('hex');
|
|
266
273
|
} catch {
|
|
@@ -378,13 +385,13 @@ function buildDevDiagnosticFallbackArtifact(
|
|
|
378
385
|
.join('\n');
|
|
379
386
|
const html = `<div data-soma-host="${KIT_ROOT_HOST}" ${KIT_DEV_DIAGNOSTIC_ATTR}="${KIT_DEV_DIAGNOSTIC_VALUE}" class="p-6 space-y-4"><div class="rounded border border-subtle bg-surface-sunken p-4"><h1 class="text-base font-semibold text-danger-on-soft">页面编译失败(开发态诊断降级页):${escapeHtml(file)}</h1><p class="mt-1 text-xs text-fg-muted">路由:${escapeHtml(url)} — 修复以下 ${diags.length} 条诊断后保存即可恢复正常渲染</p><ul class="mt-3 space-y-2">\n${itemsHtml}\n</ul></div></div>`;
|
|
380
387
|
const css = [appContext.themeTokensCss ?? '', appContext.themeCss].filter((s) => s !== '').join('\n');
|
|
381
|
-
const version = createHash('sha256')
|
|
388
|
+
const version = `${KIT_VERSION_PREFIX}dev-${createHash('sha256')
|
|
382
389
|
.update('dev-fallback:')
|
|
383
390
|
.update(url)
|
|
384
391
|
.update('\0')
|
|
385
392
|
.update(JSON.stringify(diags))
|
|
386
393
|
.digest('hex')
|
|
387
|
-
.slice(0, 16)
|
|
394
|
+
.slice(0, 16)}`;
|
|
388
395
|
return {
|
|
389
396
|
url,
|
|
390
397
|
html,
|
|
@@ -485,7 +492,7 @@ export async function assembleKitServer(options: DefineKitAppOptions, registry:
|
|
|
485
492
|
if (!(name in registry.baseComponents)) diagnostics.push({ code: 'KIT-APP-001', path: `baseComponents.${name}`, message: `kit.app.yaml 登记了基础组件 ${name},soma.app.ts 没有提供实现` });
|
|
486
493
|
}
|
|
487
494
|
// 只在代码里登记(kit.app.yaml#baseComponents 没有条目):不报错,按代码登记即可(不往配置对象里写东西)
|
|
488
|
-
const staticContracts: Record<string, { accept: 'single' | 'list'; emits: readonly string[]; props: readonly string[]; propTypes: Readonly<Record<string, string
|
|
495
|
+
const staticContracts: Record<string, { accept: 'single' | 'list'; emits: readonly string[]; props: readonly string[]; propTypes: Readonly<Record<string, string>>; composition?: KitCompositionRole }> = {};
|
|
489
496
|
for (const spec of KIT_STATIC_BUILTIN_SPECS) {
|
|
490
497
|
const def = spec.define();
|
|
491
498
|
staticContracts[spec.name] = { accept: spec.accept, emits: Object.keys(def.contract.emits ?? {}), props: Object.keys(def.contract.props ?? {}), propTypes: staticPropTypesOf(def) };
|
|
@@ -502,7 +509,8 @@ export async function assembleKitServer(options: DefineKitAppOptions, registry:
|
|
|
502
509
|
if (accept === undefined) {
|
|
503
510
|
diagnostics.push({ code: 'KIT-APP-001', path: `staticObjectComponents.${name}`, message: `数据组件 ${name} 没有 accept:请在 kit.app.yaml 的 staticObjectComponents 登记` });
|
|
504
511
|
} else {
|
|
505
|
-
|
|
512
|
+
const role = kitCompositionOf(entry.definition);
|
|
513
|
+
staticContracts[name] = { accept, emits: Object.keys(entry.definition.contract.emits ?? {}), props: Object.keys(entry.definition.contract.props ?? {}), propTypes: staticPropTypesOf(entry.definition), ...(role !== undefined ? { composition: role } : {}) };
|
|
506
514
|
}
|
|
507
515
|
}
|
|
508
516
|
const sourceGateDiagnostics = await scanAppComponentSources(root);
|
|
@@ -713,7 +721,9 @@ export async function assembleKitServer(options: DefineKitAppOptions, registry:
|
|
|
713
721
|
|
|
714
722
|
// 5 注册(若同一 URL 已由 soma-kit 预热落盘,再次装配时保持 persist: true,避免抹除持久绑定文件)
|
|
715
723
|
const register = async (persist: boolean): Promise<void> => {
|
|
716
|
-
const { listBindings, registerSomaPages, withdrawPage } = await import('soma-core/server/runtime');
|
|
724
|
+
const { listBindings, registerSomaPages, withdrawPage, registerOwnerVersionGuard } = await import('soma-core/server/runtime');
|
|
725
|
+
// 升级隐患闸:落盘的 kit 页面产物其 version 不以本版产出方指纹开头(旧版 kit 编的)一律丢弃,由下面重新注册 / 由提交方重提
|
|
726
|
+
registerOwnerVersionGuard(KIT_OWNER, kitVersionGuard);
|
|
717
727
|
const existing = listBindings();
|
|
718
728
|
for (const b of existing) {
|
|
719
729
|
if (b.owner === KIT_OWNER && b.caller === null && !artifacts.has(b.address)) {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// 本文件只在服务端可达(经 server.ts 惰性载入),浏览器侧见 ./theme-runtime.ts。
|
|
6
6
|
|
|
7
7
|
import type { KitAppTheme } from './app-config';
|
|
8
|
-
import { KIT_THEME_ENDPOINT, KIT_RUNTIME_THEME_KEYS, isKitThemePath, toKitRuntimeTheme, type KitRuntimeTheme } from '
|
|
8
|
+
import { KIT_THEME_ENDPOINT, KIT_RUNTIME_THEME_KEYS, isKitThemePath, toKitRuntimeTheme, type KitRuntimeTheme } from '../shared/theme-runtime-shared';
|
|
9
9
|
import { NINE_DIM_STRUCTURE_CSS } from '../theme/nine-dim-structure';
|
|
10
10
|
import { serializeTokenTables, solveKitTheme, type KitThemeConfig } from '../theme/theme-tokens';
|
|
11
11
|
|
package/src/app/theme-runtime.ts
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
// 本文件不 import 任何 foundation / 服务端模块(浏览器包安全)。
|
|
11
11
|
|
|
12
12
|
import {
|
|
13
|
+
KIT_EMBED_ATTR,
|
|
13
14
|
KIT_RUNTIME_THEME_KEYS,
|
|
14
15
|
KIT_THEME_BOOT_ID,
|
|
15
16
|
KIT_THEME_CSS_STORAGE_PREFIX,
|
|
@@ -19,13 +20,14 @@ import {
|
|
|
19
20
|
KIT_THEME_STYLE_ATTR,
|
|
20
21
|
buildKitThemeBootDataElement,
|
|
21
22
|
buildKitThemeFirstPaintScript,
|
|
23
|
+
isEmbedQuery,
|
|
22
24
|
kitThemeCssStorageKey,
|
|
23
25
|
kitThemeStorageKey,
|
|
24
26
|
normalizeKitRuntimeTheme,
|
|
25
27
|
normalizeKitThemeAppId,
|
|
26
28
|
toKitRuntimeTheme,
|
|
27
|
-
} from '
|
|
28
|
-
import type { KitRuntimeTheme, KitRuntimeThemeKey } from '
|
|
29
|
+
} from '../shared/theme-runtime-shared';
|
|
30
|
+
import type { KitRuntimeTheme, KitRuntimeThemeKey } from '../shared/theme-runtime-shared';
|
|
29
31
|
|
|
30
32
|
export {
|
|
31
33
|
KIT_RUNTIME_THEME_KEYS,
|
|
@@ -485,6 +487,9 @@ function broadcastOverrides(overrides: KitRuntimeTheme, appId?: string): void {
|
|
|
485
487
|
*/
|
|
486
488
|
export function restoreKitThemeBeforeFirstPaint(doc?: Document, appId?: string): KitRuntimeTheme | undefined {
|
|
487
489
|
const targetDoc = doc ?? (typeof document === 'undefined' ? undefined : document);
|
|
490
|
+
if (targetDoc !== undefined && isEmbedQuery()) {
|
|
491
|
+
targetDoc.documentElement?.setAttribute?.(KIT_EMBED_ATTR, '1');
|
|
492
|
+
}
|
|
488
493
|
if (targetDoc === undefined || typeof localStorage === 'undefined') return undefined;
|
|
489
494
|
const effAppId = resolveEffectiveAppId(appId, targetDoc);
|
|
490
495
|
try {
|