base-screen 0.3.0 → 0.4.0
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/dist/_internal/contracts/document/schema.d.ts +7 -0
- package/dist/_internal/contracts/document/schema.js +1 -1
- package/dist/_internal/contracts/document/validate-value-ref.js +6 -1
- package/dist/_internal/contracts/screen-document.schema.json +15 -3
- package/dist/_internal/contracts/types/diagnostics.d.ts +1 -1
- package/dist/_internal/contracts/types/document.d.ts +3 -1
- package/dist/_internal/core/blueprint/runtime-simulate.d.ts +57 -0
- package/dist/_internal/core/blueprint/runtime-simulate.js +177 -0
- package/dist/_internal/core/blueprint/runtime.d.ts +1 -0
- package/dist/_internal/core/blueprint/runtime.js +1 -0
- package/dist/_internal/core/commands/apply-collection-commands.d.ts +32 -0
- package/dist/_internal/core/commands/apply-collection-commands.js +174 -0
- package/dist/_internal/core/commands/apply.js +13 -0
- package/dist/_internal/core/commands/parse-command.js +12 -0
- package/dist/_internal/core/commands/types.d.ts +29 -1
- package/dist/_internal/core/data/data-candidates.d.ts +38 -0
- package/dist/_internal/core/data/data-candidates.js +186 -0
- package/dist/_internal/core/data/dataset-profile.d.ts +71 -0
- package/dist/_internal/core/data/dataset-profile.js +170 -0
- package/dist/_internal/core/data/sample-values.d.ts +25 -0
- package/dist/_internal/core/data/sample-values.js +45 -0
- package/dist/_internal/core/diff/screen-diff.js +6 -0
- package/dist/_internal/core/index.d.ts +7 -1
- package/dist/_internal/core/index.js +7 -1
- package/dist/_internal/core/state/state-preset.d.ts +32 -0
- package/dist/_internal/core/state/state-preset.js +37 -0
- package/dist/_internal/core/validation/layout-audit.d.ts +17 -0
- package/dist/_internal/core/validation/layout-audit.js +228 -0
- package/dist/_internal/core/validation/legibility.d.ts +9 -0
- package/dist/_internal/core/validation/legibility.js +33 -0
- package/dist/_internal/engine/browser/controllers/dataset/designer-dataset-draft-controller.d.ts +6 -1
- package/dist/_internal/engine/browser/controllers/designer-change-controller.d.ts +27 -0
- package/dist/_internal/engine/browser/dom/change/designer-change-dom.d.ts +21 -5
- package/dist/_internal/engine/browser/dom/dataset/designer-data-section-diff.d.ts +4 -6
- package/dist/_internal/engine/browser/dom/value-ref/designer-value-ref-types.d.ts +2 -0
- package/dist/_internal/engine/browser/viewport/designer-canvas-aids-types.d.ts +3 -3
- package/dist/_internal/engine/browser/viewport/designer-canvas-aids.d.ts +5 -3
- package/dist/_internal/engine/browser/viewport/designer-canvas-measurements.d.ts +2 -14
- package/dist/_internal/engine/browser/viewport/designer-guide-overlay-nodes.d.ts +2 -0
- package/dist/_internal/engine/browser/viewport/designer-snap-tuning.d.ts +14 -0
- package/dist/_internal/engine/common/operations/change/designer-change-events.d.ts +2 -0
- package/dist/_internal/engine/common/operations/change/designer-change-proposal.d.ts +35 -2
- package/dist/_internal/engine/common/operations/display/designer-target-display.d.ts +2 -2
- package/dist/_internal/engine/common/operations/style/designer-component-states.d.ts +7 -2
- package/dist/_internal/engine/common/ui-text/designer-ui-text.d.ts +42 -2
- package/dist/_internal/engine/{designer-blueprint-workbench-panel-CJ3iZo5v.js → designer-blueprint-workbench-panel-BWSglfAb.js} +210 -290
- package/dist/_internal/engine/{designer-dataset-controller-CrfOg2Ys.js → designer-dataset-controller-DdbY4ILC.js} +619 -561
- package/dist/_internal/engine/designer-element/api/designer-element-change.d.ts +24 -0
- package/dist/_internal/engine/designer-element/base-screen-designer-element.d.ts +12 -0
- package/dist/_internal/engine/designer-element/designer-element-public-api.d.ts +2 -1
- package/dist/_internal/engine/designer-element/runtime/designer-element-rendering.d.ts +1 -1
- package/dist/_internal/engine/designer-element/runtime/designer-element-runtime.d.ts +4 -1
- package/dist/_internal/engine/designer-element/runtime/designer-element-sample-data.d.ts +23 -0
- package/dist/_internal/engine/{designer-field-primitives-KBZuWN_D.js → designer-field-primitives-Crn464Qg.js} +44 -3
- package/dist/_internal/engine/{designer-left-panel-groups-dom-N2OHOWjl.js → designer-left-panel-groups-dom-DFdLWxxY.js} +2 -2
- package/dist/_internal/engine/{host-resource-selection-xo2mLCD4.js → host-resource-selection-CWrPLVOc.js} +2 -2
- package/dist/_internal/engine/index.js +4742 -4360
- package/dist/_internal/host-kit/index.d.ts +1 -0
- package/dist/_internal/host-kit/index.js +1 -0
- package/dist/_internal/host-kit/intent/index.d.ts +16 -0
- package/dist/_internal/host-kit/intent/index.js +13 -0
- package/dist/_internal/host-kit/intent/intent-behavior.d.ts +59 -0
- package/dist/_internal/host-kit/intent/intent-behavior.js +812 -0
- package/dist/_internal/host-kit/intent/intent-block.d.ts +59 -0
- package/dist/_internal/host-kit/intent/intent-block.js +359 -0
- package/dist/_internal/host-kit/intent/intent-catalog.d.ts +105 -0
- package/dist/_internal/host-kit/intent/intent-catalog.js +60 -0
- package/dist/_internal/host-kit/intent/intent-compile-types.d.ts +222 -0
- package/dist/_internal/host-kit/intent/intent-compile-types.js +10 -0
- package/dist/_internal/host-kit/intent/intent-compile.d.ts +35 -0
- package/dist/_internal/host-kit/intent/intent-compile.js +465 -0
- package/dist/_internal/host-kit/intent/intent-data-check.d.ts +50 -0
- package/dist/_internal/host-kit/intent/intent-data-check.js +163 -0
- package/dist/_internal/host-kit/intent/intent-data-context.d.ts +53 -0
- package/dist/_internal/host-kit/intent/intent-data-context.js +200 -0
- package/dist/_internal/host-kit/intent/intent-dataset.d.ts +52 -0
- package/dist/_internal/host-kit/intent/intent-dataset.js +125 -0
- package/dist/_internal/host-kit/intent/intent-format.d.ts +33 -0
- package/dist/_internal/host-kit/intent/intent-format.js +94 -0
- package/dist/_internal/host-kit/intent/intent-kpi-bind.d.ts +29 -0
- package/dist/_internal/host-kit/intent/intent-kpi-bind.js +59 -0
- package/dist/_internal/host-kit/intent/intent-layout.d.ts +102 -0
- package/dist/_internal/host-kit/intent/intent-layout.js +264 -0
- package/dist/_internal/host-kit/intent/intent-parse.d.ts +39 -0
- package/dist/_internal/host-kit/intent/intent-parse.js +930 -0
- package/dist/_internal/host-kit/intent/intent-prepare.d.ts +52 -0
- package/dist/_internal/host-kit/intent/intent-prepare.js +104 -0
- package/dist/_internal/host-kit/intent/intent-session.d.ts +202 -0
- package/dist/_internal/host-kit/intent/intent-session.js +1001 -0
- package/dist/_internal/host-kit/intent/intent-stream.d.ts +28 -0
- package/dist/_internal/host-kit/intent/intent-stream.js +183 -0
- package/dist/_internal/host-kit/intent/intent-style.d.ts +37 -0
- package/dist/_internal/host-kit/intent/intent-style.js +77 -0
- package/dist/_internal/host-kit/intent/intent-types.d.ts +234 -0
- package/dist/_internal/host-kit/intent/intent-types.js +10 -0
- package/dist/_internal/material/chart.js +34 -12
- package/dist/_internal/material/table.js +52 -21
- package/dist/_internal/plugin-sdk/index.d.ts +6 -0
- package/dist/_internal/plugin-sdk/index.js +6 -0
- package/dist/_internal/plugin-sdk/material-isolated-csp.d.ts +38 -0
- package/dist/_internal/plugin-sdk/material-isolated-csp.js +67 -0
- package/dist/_internal/plugin-sdk/material-isolated-runtime.d.ts +22 -0
- package/dist/_internal/plugin-sdk/material-isolated-runtime.js +262 -0
- package/dist/_internal/plugin-sdk/material-isolated.d.ts +94 -0
- package/dist/_internal/plugin-sdk/material-isolated.js +1024 -0
- package/dist/_internal/plugin-sdk/material-rendered-element.d.ts +10 -2
- package/dist/_internal/plugin-sdk/material-rendered-element.js +71 -7
- package/dist/_internal/plugin-sdk/material-spec-audit.d.ts +2 -0
- package/dist/_internal/plugin-sdk/material-spec-audit.js +26 -6
- package/dist/_internal/plugin-sdk/material-spec.d.ts +20 -0
- package/dist/_internal/plugin-sdk/material-spec.js +78 -3
- package/dist/_internal/plugin-sdk/material-template-audit.d.ts +12 -0
- package/dist/_internal/plugin-sdk/material-template-audit.js +302 -0
- package/dist/_internal/plugin-sdk/material-template-expression.d.ts +98 -0
- package/dist/_internal/plugin-sdk/material-template-expression.js +549 -0
- package/dist/_internal/plugin-sdk/material-template-render.d.ts +32 -0
- package/dist/_internal/plugin-sdk/material-template-render.js +579 -0
- package/dist/_internal/plugin-sdk/material-template.d.ts +185 -0
- package/dist/_internal/plugin-sdk/material-template.js +879 -0
- package/dist/auto-register.js +10 -10
- package/dist/contracts.js +5 -5
- package/dist/contrast-DRPezUIl.js +131 -0
- package/dist/contrast-DRPezUIl.js.map +1 -0
- package/dist/core.js +156 -136
- package/dist/core.js.map +1 -1
- package/dist/dataset-profile-Dk6xdtsM.js +261 -0
- package/dist/dataset-profile-Dk6xdtsM.js.map +1 -0
- package/dist/{designer-3Tb0EIDV.js → designer-CFOvOmLn.js} +2 -2
- package/dist/{designer-3Tb0EIDV.js.map → designer-CFOvOmLn.js.map} +1 -1
- package/dist/designer-auto-register.js +5 -5
- package/dist/{designer-blueprint-workbench-panel-CJ3iZo5v-BebifP4x.js → designer-blueprint-workbench-panel-BWSglfAb-ktaj6Ci9.js} +452 -531
- package/dist/designer-blueprint-workbench-panel-BWSglfAb-ktaj6Ci9.js.map +1 -0
- package/dist/{designer-dataset-controller-CrfOg2Ys-DhKUEJJe.js → designer-dataset-controller-DdbY4ILC-CMdGdGbr.js} +862 -804
- package/dist/designer-dataset-controller-DdbY4ILC-CMdGdGbr.js.map +1 -0
- package/dist/{designer-field-primitives-KBZuWN_D-B3h4jpYe.js → designer-field-primitives-Crn464Qg-Bi7q8s5J.js} +45 -4
- package/dist/designer-field-primitives-Crn464Qg-Bi7q8s5J.js.map +1 -0
- package/dist/{designer-left-panel-groups-dom-N2OHOWjl-D8CzGwbF.js → designer-left-panel-groups-dom-DFdLWxxY-BarlWMLY.js} +4 -4
- package/dist/{designer-left-panel-groups-dom-N2OHOWjl-D8CzGwbF.js.map → designer-left-panel-groups-dom-DFdLWxxY-BarlWMLY.js.map} +1 -1
- package/dist/designer.js +5 -5
- package/dist/{dist-6GRboBs-.js → dist-B2bW2Tru.js} +4 -4
- package/dist/{dist-6GRboBs-.js.map → dist-B2bW2Tru.js.map} +1 -1
- package/dist/{dist-BjLjFUy1.js → dist-CHK9BTXX.js} +3833 -3453
- package/dist/dist-CHK9BTXX.js.map +1 -0
- package/dist/engine.js +5 -5
- package/dist/{fragment-Y6YnW6wy.js → fragment-B-oP0Fru.js} +3 -3
- package/dist/{fragment-Y6YnW6wy.js.map → fragment-B-oP0Fru.js.map} +1 -1
- package/dist/host-kit.js +3963 -187
- package/dist/host-kit.js.map +1 -1
- package/dist/{host-resource-selection-xo2mLCD4-BR5XCcim.js → host-resource-selection-CWrPLVOc-DPDq3jau.js} +5 -5
- package/dist/{host-resource-selection-xo2mLCD4-BR5XCcim.js.map → host-resource-selection-CWrPLVOc-DPDq3jau.js.map} +1 -1
- package/dist/index.js +10 -10
- package/dist/legibility-CS28ivEz.js +12 -0
- package/dist/legibility-CS28ivEz.js.map +1 -0
- package/dist/{level-scale-BzUjE31V.js → level-scale-CwHqFEVd.js} +2 -2
- package/dist/{level-scale-BzUjE31V.js.map → level-scale-CwHqFEVd.js.map} +1 -1
- package/dist/{manager-Ch0RTu_i.js → manager-CeB4Jnr9.js} +3 -3
- package/dist/{manager-Ch0RTu_i.js.map → manager-CeB4Jnr9.js.map} +1 -1
- package/dist/{material-UbSfiuZq.js → material-DeVkzSoT.js} +2 -2
- package/dist/{material-UbSfiuZq.js.map → material-DeVkzSoT.js.map} +1 -1
- package/dist/material-auto-register.js +1 -1
- package/dist/material.js +2 -2
- package/dist/{migrate-document-D3HhCVlZ.js → migrate-document-BM888PtC.js} +2 -2
- package/dist/{migrate-document-D3HhCVlZ.js.map → migrate-document-BM888PtC.js.map} +1 -1
- package/dist/{parse-AOTE9WnD.js → parse-Ji7kE9ZT.js} +9 -4
- package/dist/parse-Ji7kE9ZT.js.map +1 -0
- package/dist/{parse-B1OD1teS.js → parse-aZat9tAS.js} +3 -3
- package/dist/{parse-B1OD1teS.js.map → parse-aZat9tAS.js.map} +1 -1
- package/dist/{parse-parts-BNrpdG5o.js → parse-parts-qzl4suzk.js} +2 -2
- package/dist/{parse-parts-BNrpdG5o.js.map → parse-parts-qzl4suzk.js.map} +1 -1
- package/dist/{plugin-DHgh9uHh.js → plugin-CstHQ5ws.js} +4 -4
- package/dist/{plugin-DHgh9uHh.js.map → plugin-CstHQ5ws.js.map} +1 -1
- package/dist/plugin-core.js +2 -2
- package/dist/plugin-manager.js +1 -1
- package/dist/plugin-package-DWifuHi1.js +4206 -0
- package/dist/plugin-package-DWifuHi1.js.map +1 -0
- package/dist/{plugin-registration-rsmb4GvS.js → plugin-registration-DTwBvnHX.js} +2 -2
- package/dist/{plugin-registration-rsmb4GvS.js.map → plugin-registration-DTwBvnHX.js.map} +1 -1
- package/dist/plugin-sdk.js +6 -6
- package/dist/{plugins-DGRHgREK.js → plugins-QDL0yIql.js} +2 -2
- package/dist/{plugins-DGRHgREK.js.map → plugins-QDL0yIql.js.map} +1 -1
- package/dist/plugins.js +8 -8
- package/dist/renderer.js +1 -1
- package/dist/{runtime-dispatch-BfnRDtMe.js → runtime-dispatch-C0gyIrTv.js} +2 -2
- package/dist/{runtime-dispatch-BfnRDtMe.js.map → runtime-dispatch-C0gyIrTv.js.map} +1 -1
- package/dist/runtime-simulate-aSYO9yDX.js +147 -0
- package/dist/runtime-simulate-aSYO9yDX.js.map +1 -0
- package/dist/{src-Bm7u11mN-_0u6cMEw.js → src-Bm7u11mN-Bi1hDVkh.js} +39 -39
- package/dist/{src-Bm7u11mN-_0u6cMEw.js.map → src-Bm7u11mN-Bi1hDVkh.js.map} +1 -1
- package/dist/state-preset-DtpygJOH.js +22 -0
- package/dist/state-preset-DtpygJOH.js.map +1 -0
- package/dist/{text-BNksUr5J.js → text-BSTz0pFQ.js} +87 -34
- package/dist/text-BSTz0pFQ.js.map +1 -0
- package/dist/{value-ref-BG_MV9C-.js → value-ref-XkLuckGV.js} +2 -2
- package/dist/{value-ref-BG_MV9C-.js.map → value-ref-XkLuckGV.js.map} +1 -1
- package/dist/{viewer-CrJupI8I-D9dVcNw4.js → viewer-CrJupI8I-BJiz1cvW.js} +4 -4
- package/dist/{viewer-CrJupI8I-D9dVcNw4.js.map → viewer-CrJupI8I-BJiz1cvW.js.map} +1 -1
- package/dist/viewer-auto-register.js +2 -2
- package/dist/viewer.js +2 -2
- package/dist/{viewport-CiCKeAQH.js → viewport-BNIRWjiT.js} +354 -155
- package/dist/viewport-BNIRWjiT.js.map +1 -0
- package/package.json +12 -12
- package/dist/designer-blueprint-workbench-panel-CJ3iZo5v-BebifP4x.js.map +0 -1
- package/dist/designer-dataset-controller-CrfOg2Ys-DhKUEJJe.js.map +0 -1
- package/dist/designer-field-primitives-KBZuWN_D-B3h4jpYe.js.map +0 -1
- package/dist/dist-BjLjFUy1.js.map +0 -1
- package/dist/parse-AOTE9WnD.js.map +0 -1
- package/dist/plugin-package-Dr5ro6h6.js +0 -1221
- package/dist/plugin-package-Dr5ro6h6.js.map +0 -1
- package/dist/text-BNksUr5J.js.map +0 -1
- package/dist/viewport-CiCKeAQH.js.map +0 -1
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { Box } from './intent-compile-types.js';
|
|
2
|
+
/**
|
|
3
|
+
* 布局求解器(ADR-0113 §2.3):区域序列 + 每格的内容量 → 像素矩形,或容量冲突。
|
|
4
|
+
*
|
|
5
|
+
* 一个纯函数,只读骨架里已有的量(指标个数、每块占几列、是不是数据型),不测字体、不依赖异步资源
|
|
6
|
+
* (AGENTS.md「无抖动」)。骨架不变,几何就不变——流式落稿靠这条把全部位置一次算定(ADR-0112 §2.5)。
|
|
7
|
+
*
|
|
8
|
+
* 装不下就报 `LAYOUT_CAPACITY_EXCEEDED`(带哪个区域、差多少像素),不硬塞:否则「5 块 + 指标带」在
|
|
9
|
+
* 1080 高里会被压成 20px 行高的表格,而不是请模型减块。
|
|
10
|
+
*/
|
|
11
|
+
export declare const WIDTH = 1920;
|
|
12
|
+
export declare const HEIGHT = 1080;
|
|
13
|
+
export declare const MARGIN = 64;
|
|
14
|
+
export declare const GAP = 24;
|
|
15
|
+
export declare const TITLE_Y = 44;
|
|
16
|
+
export declare const TITLE_HEIGHT = 62;
|
|
17
|
+
export declare const SUBTITLE_Y = 112;
|
|
18
|
+
export declare const SUBTITLE_HEIGHT = 30;
|
|
19
|
+
export declare const FOOTER_Y = 1026;
|
|
20
|
+
export declare const FOOTER_HEIGHT = 26;
|
|
21
|
+
/** 区域从标题区下方开始,到页脚上方结束。 */
|
|
22
|
+
export declare const REGION_TOP = 172;
|
|
23
|
+
export declare const REGION_BOTTOM = 1010;
|
|
24
|
+
/** 指标带:一排等宽小卡,固定高度。 */
|
|
25
|
+
export declare const BAND_HEIGHT = 148;
|
|
26
|
+
/** 指标卡的最小宽度:再窄,42px 的数值放不下。 */
|
|
27
|
+
export declare const BAND_MIN_CARD_WIDTH = 240;
|
|
28
|
+
/** 栅格 / 主侧栏里一行(一格)的最小高度:再矮,表格行高会被压到不可读。 */
|
|
29
|
+
export declare const MIN_ROW_HEIGHT = 120;
|
|
30
|
+
/** 四列栅格:块的 `span` 表示占几列。 */
|
|
31
|
+
export declare const COLUMNS = 4;
|
|
32
|
+
export interface LayoutSlot {
|
|
33
|
+
/** 四列栅格里占几列,1–4;只在 `grid` 区域里有意义。 */
|
|
34
|
+
readonly span: number;
|
|
35
|
+
/** 数据型块行高权重更大。 */
|
|
36
|
+
readonly data: boolean;
|
|
37
|
+
}
|
|
38
|
+
export type LayoutRegion = {
|
|
39
|
+
readonly kind: 'band';
|
|
40
|
+
readonly count: number;
|
|
41
|
+
} | {
|
|
42
|
+
readonly kind: 'grid';
|
|
43
|
+
readonly slots: readonly LayoutSlot[];
|
|
44
|
+
} | {
|
|
45
|
+
readonly kind: 'split';
|
|
46
|
+
readonly ratio: 'wide-narrow' | 'even';
|
|
47
|
+
readonly railSide: 'left' | 'right';
|
|
48
|
+
readonly main: readonly {
|
|
49
|
+
readonly data: boolean;
|
|
50
|
+
}[];
|
|
51
|
+
readonly rail: readonly {
|
|
52
|
+
readonly data: boolean;
|
|
53
|
+
}[];
|
|
54
|
+
};
|
|
55
|
+
/** 每个区域按其格子的顺序给出矩形(`grid` 按 `slots` 顺序,`split` 分主区与侧栏)。 */
|
|
56
|
+
export type SolvedRegion = {
|
|
57
|
+
readonly kind: 'band';
|
|
58
|
+
readonly boxes: readonly Box[];
|
|
59
|
+
} | {
|
|
60
|
+
readonly kind: 'grid';
|
|
61
|
+
readonly boxes: readonly Box[];
|
|
62
|
+
} | {
|
|
63
|
+
readonly kind: 'split';
|
|
64
|
+
readonly main: readonly Box[];
|
|
65
|
+
readonly rail: readonly Box[];
|
|
66
|
+
};
|
|
67
|
+
export interface LayoutCapacityIssue {
|
|
68
|
+
readonly regionIndex: number;
|
|
69
|
+
/** `height`:纵向装不下;`width`:指标带里的卡片太多、每张低于最小宽度。 */
|
|
70
|
+
readonly reason: 'height' | 'width';
|
|
71
|
+
readonly requiredPx: number;
|
|
72
|
+
readonly availablePx: number;
|
|
73
|
+
}
|
|
74
|
+
export type SolveOutcome = {
|
|
75
|
+
readonly ok: true;
|
|
76
|
+
readonly regions: readonly SolvedRegion[];
|
|
77
|
+
} | {
|
|
78
|
+
readonly ok: false;
|
|
79
|
+
readonly issues: readonly LayoutCapacityIssue[];
|
|
80
|
+
};
|
|
81
|
+
export declare function solveLayout(regions: readonly LayoutRegion[]): SolveOutcome;
|
|
82
|
+
/** `span` 之和超过四列就换行,保持模型给的顺序。 */
|
|
83
|
+
export declare function packRows<T extends {
|
|
84
|
+
readonly span: number;
|
|
85
|
+
}>(blocks: readonly T[]): T[][];
|
|
86
|
+
/**
|
|
87
|
+
* 行内 span 补齐到四列。
|
|
88
|
+
*
|
|
89
|
+
* 模型经常给「一块 span 2 独占一行」,按原样排就只占半屏、右侧留一大片空。
|
|
90
|
+
* 补齐按 span 从大到小逐列分配:单块直接铺满,两块 1+1 变成 2+2,不改相对宽度关系。
|
|
91
|
+
*/
|
|
92
|
+
export declare function stretchSpans(row: readonly {
|
|
93
|
+
readonly span: number;
|
|
94
|
+
}[]): number[];
|
|
95
|
+
/**
|
|
96
|
+
* 行高按内容权重分配:带 table / 数据集的块更吃纵向空间(表格要放下整表不滚动),
|
|
97
|
+
* 纯文本与素材块让位。分配后再做最小高度兜底,超出总高时从最高的行里回收。
|
|
98
|
+
*/
|
|
99
|
+
export declare function distributeRowHeights(rows: readonly (readonly {
|
|
100
|
+
readonly data: boolean;
|
|
101
|
+
}[])[], available: number): number[];
|
|
102
|
+
//# sourceMappingURL=intent-layout.d.ts.map
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 布局求解器(ADR-0113 §2.3):区域序列 + 每格的内容量 → 像素矩形,或容量冲突。
|
|
3
|
+
*
|
|
4
|
+
* 一个纯函数,只读骨架里已有的量(指标个数、每块占几列、是不是数据型),不测字体、不依赖异步资源
|
|
5
|
+
* (AGENTS.md「无抖动」)。骨架不变,几何就不变——流式落稿靠这条把全部位置一次算定(ADR-0112 §2.5)。
|
|
6
|
+
*
|
|
7
|
+
* 装不下就报 `LAYOUT_CAPACITY_EXCEEDED`(带哪个区域、差多少像素),不硬塞:否则「5 块 + 指标带」在
|
|
8
|
+
* 1080 高里会被压成 20px 行高的表格,而不是请模型减块。
|
|
9
|
+
*/
|
|
10
|
+
export const WIDTH = 1920;
|
|
11
|
+
export const HEIGHT = 1080;
|
|
12
|
+
export const MARGIN = 64;
|
|
13
|
+
export const GAP = 24;
|
|
14
|
+
export const TITLE_Y = 44;
|
|
15
|
+
export const TITLE_HEIGHT = 62;
|
|
16
|
+
export const SUBTITLE_Y = 112;
|
|
17
|
+
export const SUBTITLE_HEIGHT = 30;
|
|
18
|
+
export const FOOTER_Y = 1026;
|
|
19
|
+
export const FOOTER_HEIGHT = 26;
|
|
20
|
+
/** 区域从标题区下方开始,到页脚上方结束。 */
|
|
21
|
+
export const REGION_TOP = 172;
|
|
22
|
+
export const REGION_BOTTOM = 1010;
|
|
23
|
+
/** 指标带:一排等宽小卡,固定高度。 */
|
|
24
|
+
export const BAND_HEIGHT = 148;
|
|
25
|
+
/** 指标卡的最小宽度:再窄,42px 的数值放不下。 */
|
|
26
|
+
export const BAND_MIN_CARD_WIDTH = 240;
|
|
27
|
+
/** 栅格 / 主侧栏里一行(一格)的最小高度:再矮,表格行高会被压到不可读。 */
|
|
28
|
+
export const MIN_ROW_HEIGHT = 120;
|
|
29
|
+
/** 数据型块(表格 / 数据集)比文本块更吃纵向空间。 */
|
|
30
|
+
const DATA_WEIGHT = 1.35;
|
|
31
|
+
/** 四列栅格:块的 `span` 表示占几列。 */
|
|
32
|
+
export const COLUMNS = 4;
|
|
33
|
+
const CONTENT_WIDTH = WIDTH - MARGIN * 2;
|
|
34
|
+
const COLUMN_WIDTH = Math.floor((CONTENT_WIDTH - GAP * (COLUMNS - 1)) / COLUMNS);
|
|
35
|
+
export function solveLayout(regions) {
|
|
36
|
+
const issues = [];
|
|
37
|
+
const gaps = GAP * Math.max(0, regions.length - 1);
|
|
38
|
+
const plans = regions.map(planRegion);
|
|
39
|
+
for (const [index, plan] of plans.entries()) {
|
|
40
|
+
if (plan.kind === 'band') {
|
|
41
|
+
const width = bandCardWidth(plan.count);
|
|
42
|
+
if (plan.count > 0 && width < BAND_MIN_CARD_WIDTH) {
|
|
43
|
+
issues.push({
|
|
44
|
+
regionIndex: index,
|
|
45
|
+
reason: 'width',
|
|
46
|
+
requiredPx: BAND_MIN_CARD_WIDTH * plan.count + GAP * (plan.count - 1),
|
|
47
|
+
availablePx: CONTENT_WIDTH,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const fixed = plans.reduce((sum, plan) => sum + (plan.kind === 'band' ? plan.height : 0), 0);
|
|
53
|
+
const flexible = plans.flatMap((plan, index) => (plan.kind === 'band' ? [] : [{ plan, index }]));
|
|
54
|
+
const available = REGION_BOTTOM - REGION_TOP - gaps - fixed;
|
|
55
|
+
const minimum = flexible.reduce((sum, item) => sum + item.plan.minHeight, 0);
|
|
56
|
+
if (flexible.length > 0 && minimum > available) {
|
|
57
|
+
// 指出最吃空间的那个区域:请模型先从它那里减块。
|
|
58
|
+
const biggest = flexible.reduce((best, item) => item.plan.minHeight > best.plan.minHeight ? item : best);
|
|
59
|
+
issues.push({
|
|
60
|
+
regionIndex: biggest.index,
|
|
61
|
+
reason: 'height',
|
|
62
|
+
requiredPx: minimum,
|
|
63
|
+
availablePx: available,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
if (issues.length > 0)
|
|
67
|
+
return { ok: false, issues };
|
|
68
|
+
// 纵向:指标带固定高,其余区域按内容权重分剩余高度,不低于各自最小高度。
|
|
69
|
+
const heights = new Map();
|
|
70
|
+
if (flexible.length > 0) {
|
|
71
|
+
const totalWeight = flexible.reduce((sum, item) => sum + item.plan.weight, 0) || 1;
|
|
72
|
+
const shares = flexible.map((item) => Math.max(item.plan.minHeight, Math.floor((available * item.plan.weight) / totalWeight)));
|
|
73
|
+
let overflow = shares.reduce((sum, share) => sum + share, 0) - available;
|
|
74
|
+
while (overflow > 0) {
|
|
75
|
+
let tallest = 0;
|
|
76
|
+
shares.forEach((share, i) => {
|
|
77
|
+
if (share > (shares[tallest] ?? 0))
|
|
78
|
+
tallest = i;
|
|
79
|
+
});
|
|
80
|
+
const reducible = (shares[tallest] ?? 0) - (flexible[tallest]?.plan.minHeight ?? 0);
|
|
81
|
+
if (reducible <= 0)
|
|
82
|
+
break;
|
|
83
|
+
const cut = Math.min(reducible, overflow);
|
|
84
|
+
shares[tallest] = (shares[tallest] ?? 0) - cut;
|
|
85
|
+
overflow -= cut;
|
|
86
|
+
}
|
|
87
|
+
flexible.forEach((item, i) => heights.set(item.index, shares[i] ?? item.plan.minHeight));
|
|
88
|
+
}
|
|
89
|
+
const solved = [];
|
|
90
|
+
let y = REGION_TOP;
|
|
91
|
+
for (const [index, plan] of plans.entries()) {
|
|
92
|
+
const height = plan.kind === 'band' ? plan.height : (heights.get(index) ?? plan.minHeight);
|
|
93
|
+
solved.push(placeRegion(plan, y, height));
|
|
94
|
+
y += height + GAP;
|
|
95
|
+
}
|
|
96
|
+
return { ok: true, regions: solved };
|
|
97
|
+
}
|
|
98
|
+
function planRegion(region) {
|
|
99
|
+
if (region.kind === 'band')
|
|
100
|
+
return { kind: 'band', count: region.count, height: BAND_HEIGHT };
|
|
101
|
+
if (region.kind === 'grid') {
|
|
102
|
+
const rows = packRows(region.slots.map((slot, index) => ({ ...slot, index })));
|
|
103
|
+
return {
|
|
104
|
+
kind: 'grid',
|
|
105
|
+
rows,
|
|
106
|
+
weight: rows.reduce((sum, row) => sum + rowWeight(row), 0),
|
|
107
|
+
minHeight: stackMinimum(rows.length),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
const weight = (cells) => cells.reduce((sum, cell) => sum + (cell.data ? DATA_WEIGHT : 1), 0);
|
|
111
|
+
return {
|
|
112
|
+
kind: 'split',
|
|
113
|
+
region,
|
|
114
|
+
weight: Math.max(weight(region.main), weight(region.rail)),
|
|
115
|
+
minHeight: stackMinimum(Math.max(region.main.length, region.rail.length)),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function rowWeight(row) {
|
|
119
|
+
return row.some((cell) => cell.data) ? DATA_WEIGHT : 1;
|
|
120
|
+
}
|
|
121
|
+
function stackMinimum(rows) {
|
|
122
|
+
return rows === 0 ? 0 : MIN_ROW_HEIGHT * rows + GAP * (rows - 1);
|
|
123
|
+
}
|
|
124
|
+
// ---------------------------------------------------------------------------
|
|
125
|
+
// 落位
|
|
126
|
+
// ---------------------------------------------------------------------------
|
|
127
|
+
function placeRegion(plan, y, height) {
|
|
128
|
+
if (plan.kind === 'band') {
|
|
129
|
+
const width = bandCardWidth(plan.count);
|
|
130
|
+
const boxes = [];
|
|
131
|
+
for (let index = 0; index < plan.count; index += 1) {
|
|
132
|
+
boxes.push({ x: MARGIN + index * (width + GAP), y, width, height });
|
|
133
|
+
}
|
|
134
|
+
return { kind: 'band', boxes };
|
|
135
|
+
}
|
|
136
|
+
if (plan.kind === 'grid') {
|
|
137
|
+
// 行高按内容权重分配:数据块(表格 / 图表)比文本块更吃纵向空间,纯文本与素材块让位。
|
|
138
|
+
const heights = distributeRowHeights(plan.rows, height - GAP * (plan.rows.length - 1));
|
|
139
|
+
const boxes = new Array(plan.rows.reduce((sum, row) => sum + row.length, 0));
|
|
140
|
+
let rowY = y;
|
|
141
|
+
plan.rows.forEach((row, rowIndex) => {
|
|
142
|
+
// 行内 span 补齐到 4 列:单块独占一行时铺满整行,而不是只占半屏、右边留一片空。
|
|
143
|
+
const spans = stretchSpans(row);
|
|
144
|
+
const rowHeight = heights[rowIndex] ?? MIN_ROW_HEIGHT;
|
|
145
|
+
let offset = 0;
|
|
146
|
+
row.forEach((slot, slotIndex) => {
|
|
147
|
+
const span = spans[slotIndex] ?? 1;
|
|
148
|
+
boxes[slot.index] = {
|
|
149
|
+
x: MARGIN + offset * (COLUMN_WIDTH + GAP),
|
|
150
|
+
y: rowY,
|
|
151
|
+
width: COLUMN_WIDTH * span + GAP * (span - 1),
|
|
152
|
+
height: rowHeight,
|
|
153
|
+
};
|
|
154
|
+
offset += span;
|
|
155
|
+
});
|
|
156
|
+
rowY += rowHeight + GAP;
|
|
157
|
+
});
|
|
158
|
+
return { kind: 'grid', boxes };
|
|
159
|
+
}
|
|
160
|
+
const { region } = plan;
|
|
161
|
+
const railWidth = region.ratio === 'even' ? Math.floor((CONTENT_WIDTH - GAP) / 2) : COLUMN_WIDTH;
|
|
162
|
+
const mainWidth = region.ratio === 'even' ? railWidth : CONTENT_WIDTH - GAP - railWidth;
|
|
163
|
+
const mainX = region.railSide === 'left' ? MARGIN + railWidth + GAP : MARGIN;
|
|
164
|
+
const railX = region.railSide === 'left' ? MARGIN : MARGIN + mainWidth + GAP;
|
|
165
|
+
return {
|
|
166
|
+
kind: 'split',
|
|
167
|
+
main: stack(region.main, mainX, y, mainWidth, height),
|
|
168
|
+
rail: stack(region.rail, railX, y, railWidth, height),
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
/** 一列纵向堆叠:每格一行,行高按内容权重分。 */
|
|
172
|
+
function stack(cells, x, y, width, height) {
|
|
173
|
+
const rows = cells.map((cell, index) => [{ data: cell.data, index }]);
|
|
174
|
+
const heights = distributeRowHeights(rows, height - GAP * (rows.length - 1));
|
|
175
|
+
const boxes = [];
|
|
176
|
+
let cursor = y;
|
|
177
|
+
for (const [index, rowHeight] of heights.entries()) {
|
|
178
|
+
boxes[index] = { x, y: cursor, width, height: rowHeight };
|
|
179
|
+
cursor += rowHeight + GAP;
|
|
180
|
+
}
|
|
181
|
+
return boxes;
|
|
182
|
+
}
|
|
183
|
+
function bandCardWidth(count) {
|
|
184
|
+
return count <= 0 ? 0 : Math.floor((CONTENT_WIDTH - GAP * (count - 1)) / count);
|
|
185
|
+
}
|
|
186
|
+
// ---------------------------------------------------------------------------
|
|
187
|
+
// 栅格算术(自 `agent-compose.ts` 原样迁入)
|
|
188
|
+
// ---------------------------------------------------------------------------
|
|
189
|
+
function clampSpan(value) {
|
|
190
|
+
if (!Number.isFinite(value))
|
|
191
|
+
return 1;
|
|
192
|
+
return Math.min(COLUMNS, Math.max(1, Math.round(value)));
|
|
193
|
+
}
|
|
194
|
+
/** `span` 之和超过四列就换行,保持模型给的顺序。 */
|
|
195
|
+
export function packRows(blocks) {
|
|
196
|
+
const rows = [];
|
|
197
|
+
let current = [];
|
|
198
|
+
let used = 0;
|
|
199
|
+
for (const block of blocks) {
|
|
200
|
+
const span = clampSpan(block.span);
|
|
201
|
+
if (used + span > COLUMNS && current.length > 0) {
|
|
202
|
+
rows.push(current);
|
|
203
|
+
current = [];
|
|
204
|
+
used = 0;
|
|
205
|
+
}
|
|
206
|
+
current.push(block);
|
|
207
|
+
used += span;
|
|
208
|
+
}
|
|
209
|
+
if (current.length > 0)
|
|
210
|
+
rows.push(current);
|
|
211
|
+
return rows;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* 行内 span 补齐到四列。
|
|
215
|
+
*
|
|
216
|
+
* 模型经常给「一块 span 2 独占一行」,按原样排就只占半屏、右侧留一大片空。
|
|
217
|
+
* 补齐按 span 从大到小逐列分配:单块直接铺满,两块 1+1 变成 2+2,不改相对宽度关系。
|
|
218
|
+
*/
|
|
219
|
+
export function stretchSpans(row) {
|
|
220
|
+
const spans = row.map((block) => clampSpan(block.span));
|
|
221
|
+
let remaining = COLUMNS - spans.reduce((sum, span) => sum + span, 0);
|
|
222
|
+
if (remaining <= 0 || spans.length === 0)
|
|
223
|
+
return spans;
|
|
224
|
+
const order = spans
|
|
225
|
+
.map((span, index) => ({ span, index }))
|
|
226
|
+
.sort((left, right) => right.span - left.span || left.index - right.index)
|
|
227
|
+
.map((item) => item.index);
|
|
228
|
+
let cursor = 0;
|
|
229
|
+
while (remaining > 0) {
|
|
230
|
+
const index = order[cursor % order.length];
|
|
231
|
+
spans[index] = (spans[index] ?? 1) + 1;
|
|
232
|
+
remaining -= 1;
|
|
233
|
+
cursor += 1;
|
|
234
|
+
}
|
|
235
|
+
return spans;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* 行高按内容权重分配:带 table / 数据集的块更吃纵向空间(表格要放下整表不滚动),
|
|
239
|
+
* 纯文本与素材块让位。分配后再做最小高度兜底,超出总高时从最高的行里回收。
|
|
240
|
+
*/
|
|
241
|
+
export function distributeRowHeights(rows, available) {
|
|
242
|
+
if (rows.length === 0)
|
|
243
|
+
return [];
|
|
244
|
+
const minHeight = Math.max(MIN_ROW_HEIGHT, Math.min(200, Math.floor(available / rows.length)));
|
|
245
|
+
const weights = rows.map(rowWeight);
|
|
246
|
+
const totalWeight = weights.reduce((sum, weight) => sum + weight, 0) || 1;
|
|
247
|
+
const heights = weights.map((weight) => Math.max(minHeight, Math.floor((available * weight) / totalWeight)));
|
|
248
|
+
let overflow = heights.reduce((sum, height) => sum + height, 0) - available;
|
|
249
|
+
while (overflow > 0) {
|
|
250
|
+
let tallest = 0;
|
|
251
|
+
heights.forEach((height, index) => {
|
|
252
|
+
if (height > (heights[tallest] ?? 0))
|
|
253
|
+
tallest = index;
|
|
254
|
+
});
|
|
255
|
+
const reducible = (heights[tallest] ?? 0) - minHeight;
|
|
256
|
+
if (reducible <= 0)
|
|
257
|
+
break;
|
|
258
|
+
const cut = Math.min(reducible, overflow);
|
|
259
|
+
heights[tallest] = (heights[tallest] ?? 0) - cut;
|
|
260
|
+
overflow -= cut;
|
|
261
|
+
}
|
|
262
|
+
return heights;
|
|
263
|
+
}
|
|
264
|
+
//# sourceMappingURL=intent-layout.js.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { IntentCatalog } from './intent-catalog.js';
|
|
2
|
+
import type { IntentBlock, IntentInteraction, IntentItemResult, IntentKpi, IntentParseResult } from './intent-types.js';
|
|
3
|
+
/** 按字符宽度截断:含中日韩字符按 `max` 字,纯西文按 `max * 2` 字符。 */
|
|
4
|
+
export declare function clampText(text: string, max: number): string;
|
|
5
|
+
export interface ParseScreenIntentOptions {
|
|
6
|
+
readonly catalog: IntentCatalog;
|
|
7
|
+
/**
|
|
8
|
+
* 允许指标值为 `null`(没有数据的占位,编译器画「—」)。只给确定性兜底用:
|
|
9
|
+
* 模型给的 `null` 不是占位而是漏写,仍按不合格的指标进修复回环。
|
|
10
|
+
*/
|
|
11
|
+
readonly placeholders?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* 解析模型输出:接受原文字符串(容忍代码块围栏)或已解析的对象。
|
|
15
|
+
* 返回的 `diagnostics` 同时含 `error`(值得请模型修一次)与 `warning`(已收敛保留)。
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseScreenIntent(input: unknown, options: ParseScreenIntentOptions): IntentParseResult;
|
|
18
|
+
/**
|
|
19
|
+
* 一条指标:数值必须是有限数字,单位与格式化交给编译器。不合格的丢弃并记 `AGENT_KPI_INVALID`;
|
|
20
|
+
* 增减量写错只丢增减量、保留指标本身(`AGENT_KPI_DELTA_DROPPED`)。
|
|
21
|
+
*/
|
|
22
|
+
export declare function parseIntentKpi(raw: unknown, origin: string, options?: {
|
|
23
|
+
readonly placeholders?: boolean;
|
|
24
|
+
}): IntentItemResult<IntentKpi>;
|
|
25
|
+
/**
|
|
26
|
+
* 一个块:`type` 必须是目录里真实存在的物料,内容形态由物料声明的取值形态决定。
|
|
27
|
+
* 单块瑕疵只降级(裁行、丢参数、截断文案)或丢弃该块,不连累别的块。
|
|
28
|
+
*
|
|
29
|
+
* `grid` 为 false 时(侧栏 / 主区的纵向堆叠)`span` 固定为 1,模型给的值不报错。
|
|
30
|
+
*/
|
|
31
|
+
export declare function parseIntentBlock(raw: unknown, catalog: IntentCatalog, origin: string, where: {
|
|
32
|
+
readonly grid: boolean;
|
|
33
|
+
}): IntentItemResult<IntentBlock>;
|
|
34
|
+
/**
|
|
35
|
+
* 单独解析联动(编辑时的 `link` 操作用):编号从 `start` 起,与已有联动的 `interactions[i]` 接续。
|
|
36
|
+
* 不合格的项直接丢掉。
|
|
37
|
+
*/
|
|
38
|
+
export declare function parseScreenIntentInteractions(raw: readonly unknown[], start?: number): IntentInteraction[];
|
|
39
|
+
//# sourceMappingURL=intent-parse.d.ts.map
|