@k-table/sheet-core 0.0.1 → 1.0.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/chunk-2Z7KMZEW.js +1 -0
- package/dist/chunk-FRYFH3X6.js +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +2076 -0
- package/dist/index.d.ts +2076 -0
- package/dist/index.js +1 -0
- package/dist/migrate/index.cjs +1 -0
- package/dist/migrate/index.d.cts +9 -0
- package/dist/migrate/index.d.ts +9 -0
- package/dist/migrate/index.js +1 -0
- package/dist/sheet-template-model.cjs +1 -0
- package/dist/sheet-template-model.d.cts +132 -0
- package/dist/sheet-template-model.d.ts +132 -0
- package/dist/sheet-template-model.js +1 -0
- package/dist/types-9rRrxBdg.d.cts +435 -0
- package/dist/types-9rRrxBdg.d.ts +435 -0
- package/package.json +47 -9
- package/README.md +0 -5
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,2076 @@
|
|
|
1
|
+
import { SheetTemplateState, TextRun, CellData as CellData$1, BaseTemplateCellBinding, PageSettings as PageSettings$1, PageMarginsCm, SheetPaperKind, SheetOrientation, MergeRange } from './sheet-template-model.js';
|
|
2
|
+
import { T as TemplateFieldRegistry, A as AggregateEmptyAs, W as WorkbookScripts, a as WorkbookMeta, b as WorkbookNamedRange, K as KtTemplateRoot, M as MergeRect, B as BorderWidth, c as BorderPattern, S as Sheet, C as CellData, P as PageSettings, d as SheetItem, e as Workbook, F as FormulaCatalogTarget, f as FormulaCatalogEntry, g as TemplateFieldDef, h as TemplateSubFieldDef } from './types-9rRrxBdg.js';
|
|
3
|
+
export { i as BusinessSheetProfile, j as BusinessSheetProfiles, k as CREATION_MODE, l as CellBorderSide, m as CellBorders, n as CellStyle, o as CreationMode, D as DEFAULT_COMPUTE_POLICY, p as DRAFT_KIND, q as DerivedFieldRule, r as DraftDbSpliceMeta, s as DraftKind, t as FormulaCatalog, H as HorizontalAlign, u as KtTemplateBinding, v as KtTemplateFlexibleRowSegment, w as KtTemplateMainField, x as KtTemplateSlotRect, y as KtTemplateSpliceSpec, z as KtTemplateSubTable, E as KtTemplateSubTableColumn, G as PaperSizeName, R as RichRun, I as SNAPSHOT_KIND, J as SPLICE_COLUMN_MODE, L as SnapshotKind, N as SpliceComposeCacheV1, O as SubTableSlotConfig, Q as SubTableSlotConfigEntry, U as TEMPLATE_FIELD_REGISTRY_VERSION, V as VerticalAlign, X as WORKBOOK_META_BUSINESS_SHEET_PROFILES, Y as WORKBOOK_META_INHERIT_SOURCE_BASE_SNAPSHOT_ROW_ID, Z as WorkbookComputePolicy, _ as WorkbookReportBandDef, $ as WorkbookReportMeta, a0 as WorkbookScriptBlock, a1 as WorkbookScriptHook, a2 as emptyFormulaCatalog, a3 as getAggregateEmptyAs, a4 as getFormulaCatalogFromMeta, a5 as getWorkbookComputePolicy, a6 as getWorkbookDerivedRules, a7 as newDerivedRuleId, a8 as normalizeComputePolicy, a9 as normalizeDerivedRules, aa as normalizeFormulaCatalog } from './types-9rRrxBdg.js';
|
|
4
|
+
import { SignatureKind, SignatureResult, SignatureSpec } from '@k-table/sheet-host';
|
|
5
|
+
export { SignatureKind, SignaturePort, SignatureResult, SignatureSpec } from '@k-table/sheet-host';
|
|
6
|
+
|
|
7
|
+
/** 画布缩放限制(与旧 sheetEngineStore 行为一致)。 */
|
|
8
|
+
declare function clampZoom(z: number): number;
|
|
9
|
+
|
|
10
|
+
/** 引擎可调参数(与实现计划 A0-2 对齐)。 */
|
|
11
|
+
declare const SHEET_ENGINE_CONFIG: {
|
|
12
|
+
readonly DEFAULT_ROW_COUNT: 200;
|
|
13
|
+
readonly DEFAULT_COL_COUNT: 50;
|
|
14
|
+
readonly MAX_ROWS: 1048576;
|
|
15
|
+
readonly MAX_COLS: 16384;
|
|
16
|
+
readonly DEFAULT_ROW_HEIGHT: 24;
|
|
17
|
+
readonly DEFAULT_COL_WIDTH: 80;
|
|
18
|
+
readonly HEADER_ROW_HEIGHT: 24;
|
|
19
|
+
readonly HEADER_COL_WIDTH: 48;
|
|
20
|
+
readonly MIN_FONT_SIZE_PT: 6;
|
|
21
|
+
readonly DEFAULT_FONT_SIZE_PT: 11;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 用户可见坐标(1-based 行、A.. 列)与内部 0-based `r,c` 的**唯一**转换层。
|
|
26
|
+
* 见实现计划核心引擎A §3.0 / A6-4。
|
|
27
|
+
*/
|
|
28
|
+
declare function colIndexToLetters(c: number): string;
|
|
29
|
+
declare function lettersToColIndex(letters: string): number;
|
|
30
|
+
/** 内部 `r,c` → `A1`(行 1-based 展示)。 */
|
|
31
|
+
declare function toA1(r: number, c: number): string;
|
|
32
|
+
/** `A1` / `b2` → 内部 0-based。 */
|
|
33
|
+
declare function parseA1(a1: string): {
|
|
34
|
+
r: number;
|
|
35
|
+
c: number;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
interface Rect {
|
|
39
|
+
r1: number;
|
|
40
|
+
c1: number;
|
|
41
|
+
r2: number;
|
|
42
|
+
c2: number;
|
|
43
|
+
}
|
|
44
|
+
declare function normalizeRect(r1: number, c1: number, r2: number, c2: number): Rect;
|
|
45
|
+
declare function rectContains(rect: Rect, r: number, c: number): boolean;
|
|
46
|
+
/** 两轴对齐矩形是否相交(角点可不预先规范化)。 */
|
|
47
|
+
declare function rectsOverlap(a: Rect, b: Rect): boolean;
|
|
48
|
+
|
|
49
|
+
/** 选区矩形(规范化后的行列范围)。 */
|
|
50
|
+
interface SelectionRect {
|
|
51
|
+
r1: number;
|
|
52
|
+
c1: number;
|
|
53
|
+
r2: number;
|
|
54
|
+
c2: number;
|
|
55
|
+
}
|
|
56
|
+
/** 行高:显式 0 表示隐藏;>0 生效;否则回退默认。 */
|
|
57
|
+
declare function getRowHeight(sheet: SheetTemplateState, r: number): number;
|
|
58
|
+
/** 列宽:第 0 列允许为 0(隐藏行号列);其余 >0 生效,否则回退默认。 */
|
|
59
|
+
declare function getColWidth(sheet: SheetTemplateState, c: number): number;
|
|
60
|
+
|
|
61
|
+
type FillExtension = {
|
|
62
|
+
dir: "down";
|
|
63
|
+
n: number;
|
|
64
|
+
} | {
|
|
65
|
+
dir: "up";
|
|
66
|
+
n: number;
|
|
67
|
+
} | {
|
|
68
|
+
dir: "right";
|
|
69
|
+
n: number;
|
|
70
|
+
} | {
|
|
71
|
+
dir: "left";
|
|
72
|
+
n: number;
|
|
73
|
+
};
|
|
74
|
+
/** 选区规范化(与 geometry.normalizeRect 一致,保留 SelectionRect 命名) */
|
|
75
|
+
declare function normSelectionRect(sel: SelectionRect): Rect;
|
|
76
|
+
/** 由源选区与目标外接矩形推断单向延伸(与画布轴锁定一致) */
|
|
77
|
+
declare function detectFillExtension(source: SelectionRect, target: SelectionRect): FillExtension | null;
|
|
78
|
+
declare function extensionStripRect(s: Rect, ext: FillExtension): SelectionRect;
|
|
79
|
+
declare function targetRectFromExtension(s: Rect, ext: FillExtension): SelectionRect;
|
|
80
|
+
/** 根据拖拽命中格与锁定轴向计算预览选区(未延伸则返回源选区) */
|
|
81
|
+
declare function computeFillPreviewSelection(sourceSel: SelectionRect, axis: "row" | "col", hitR: number, hitC: number): SelectionRect;
|
|
82
|
+
/** 从首次移动偏差锁定轴向(仿 Excel:以较大位移为准) */
|
|
83
|
+
declare function lockFillAxis(dRow: number, dCol: number): "row" | "col";
|
|
84
|
+
|
|
85
|
+
declare function cellKey(r: number, c: number): string;
|
|
86
|
+
declare function parseCellKey(key: string): {
|
|
87
|
+
r: number;
|
|
88
|
+
c: number;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* 工作簿嵌入层 SSOT 类型(逻辑 normalizeWorkbookEmbeds 等保留在 kt-web embed/embedTypes.ts)。
|
|
93
|
+
*/
|
|
94
|
+
type EmbedAnchorRect = {
|
|
95
|
+
sheetId: string;
|
|
96
|
+
r1: number;
|
|
97
|
+
c1: number;
|
|
98
|
+
r2: number;
|
|
99
|
+
c2: number;
|
|
100
|
+
};
|
|
101
|
+
type EmbedAnchorCell = {
|
|
102
|
+
sheetId: string;
|
|
103
|
+
r: number;
|
|
104
|
+
c: number;
|
|
105
|
+
};
|
|
106
|
+
/** 相对锚点格左上,单位 pt */
|
|
107
|
+
type EmbedBoxPt = {
|
|
108
|
+
x: number;
|
|
109
|
+
y: number;
|
|
110
|
+
width: number;
|
|
111
|
+
height: number;
|
|
112
|
+
};
|
|
113
|
+
type EmbedBase = {
|
|
114
|
+
embedId: string;
|
|
115
|
+
kind: "chart" | "asset";
|
|
116
|
+
name?: string;
|
|
117
|
+
zIndex?: number;
|
|
118
|
+
visibleWhen?: "always" | "hasData" | "expression";
|
|
119
|
+
};
|
|
120
|
+
type ChartDataSource = {
|
|
121
|
+
mode: "mainFields";
|
|
122
|
+
fields: string[];
|
|
123
|
+
} | {
|
|
124
|
+
mode: "subTable";
|
|
125
|
+
subSchemaId: number;
|
|
126
|
+
rowScope: "all" | "currentPage" | "slotRange";
|
|
127
|
+
slotRange?: {
|
|
128
|
+
from: number;
|
|
129
|
+
to: number;
|
|
130
|
+
};
|
|
131
|
+
columns: string[];
|
|
132
|
+
} | {
|
|
133
|
+
mode: "namedRange";
|
|
134
|
+
name: string;
|
|
135
|
+
} | {
|
|
136
|
+
mode: "gridRange";
|
|
137
|
+
sheetId: string;
|
|
138
|
+
a1: string;
|
|
139
|
+
} | {
|
|
140
|
+
mode: "script";
|
|
141
|
+
scriptBlockKey: string;
|
|
142
|
+
};
|
|
143
|
+
type ChartEmbedDef = EmbedBase & {
|
|
144
|
+
kind: "chart";
|
|
145
|
+
anchorRect: EmbedAnchorRect;
|
|
146
|
+
chart: {
|
|
147
|
+
type: "line" | "bar" | "column" | "pie" | "scatter" | "combo";
|
|
148
|
+
title?: string;
|
|
149
|
+
legend?: "none" | "bottom" | "right";
|
|
150
|
+
dataSource: ChartDataSource;
|
|
151
|
+
palette?: string[];
|
|
152
|
+
comboSeriesTypes?: Array<"line" | "bar">;
|
|
153
|
+
/** JS 模板:return ECharts option;占位符见 chartOptionTemplate.ts */
|
|
154
|
+
optionTemplate?: string;
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
type AssetKind = "image" | "signature" | "qrcode" | "stamp" | "barcode";
|
|
158
|
+
type AssetEmbedDef = EmbedBase & {
|
|
159
|
+
kind: "asset";
|
|
160
|
+
assetKind: AssetKind;
|
|
161
|
+
anchorCell: EmbedAnchorCell;
|
|
162
|
+
box: EmbedBoxPt;
|
|
163
|
+
slotId: string;
|
|
164
|
+
defaultFileId?: string;
|
|
165
|
+
signature?: {
|
|
166
|
+
required?: boolean;
|
|
167
|
+
allowedRoles?: string[];
|
|
168
|
+
};
|
|
169
|
+
qrcode?: {
|
|
170
|
+
payloadTemplate: string;
|
|
171
|
+
errorCorrection?: "L" | "M" | "Q" | "H";
|
|
172
|
+
fgColor?: string;
|
|
173
|
+
};
|
|
174
|
+
barcode?: {
|
|
175
|
+
payloadTemplate: string;
|
|
176
|
+
/** 缺省 Code128 */
|
|
177
|
+
symbology?: "code128";
|
|
178
|
+
};
|
|
179
|
+
runtimeMovable?: boolean;
|
|
180
|
+
};
|
|
181
|
+
type WorkbookEmbedDef = ChartEmbedDef | AssetEmbedDef;
|
|
182
|
+
/** 实例动态态(field pack v2 embedStates) */
|
|
183
|
+
type EmbedInstanceState = {
|
|
184
|
+
fileId?: string;
|
|
185
|
+
qrPayload?: string;
|
|
186
|
+
signedBy?: string;
|
|
187
|
+
signedAt?: string;
|
|
188
|
+
frozenImageFileId?: string;
|
|
189
|
+
frozenAt?: string;
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
/** pt 与屏显 px 换算(96dpi 默认) */
|
|
193
|
+
declare function ptToCssPx(pt: number, dpi?: number): number;
|
|
194
|
+
declare function cssPxToPt(px: number, dpi?: number): number;
|
|
195
|
+
|
|
196
|
+
/** 受限 JS 表达式运行时:表达式求值 + 语句解释 + 白名单沙箱 */
|
|
197
|
+
type SjsValue = number | string | boolean | null | undefined | SjsValue[] | SjsObject;
|
|
198
|
+
interface SjsObject {
|
|
199
|
+
[k: string]: SjsValue | SjsFn;
|
|
200
|
+
}
|
|
201
|
+
type SjsFn = (...args: SjsValue[]) => SjsValue;
|
|
202
|
+
declare class SjsError extends Error {
|
|
203
|
+
constructor(msg: string);
|
|
204
|
+
}
|
|
205
|
+
declare class SjsCycleError extends SjsError {
|
|
206
|
+
constructor();
|
|
207
|
+
}
|
|
208
|
+
/** 用给定上下文执行 source,返回 return 值或最后表达式值 */
|
|
209
|
+
declare function runSjs(source: string, context: Record<string, SjsValue | SjsFn>): SjsValue;
|
|
210
|
+
/** 执行单一表达式(field 公式 :=expr 专用) */
|
|
211
|
+
declare function runSjsExpr(source: string, context: Record<string, SjsValue | SjsFn>): SjsValue;
|
|
212
|
+
/** 静态扫描表达式引用到的标识符(顶层 Ident 与 Member 的根) */
|
|
213
|
+
declare function collectReferencedRoots(source: string, isExpr: boolean): Set<string>;
|
|
214
|
+
|
|
215
|
+
/** Inspector / tableSystem.cellMeta 侧约定(与 workbook JSON 共存)。纯类型 + 复合键工具。 */
|
|
216
|
+
type CellBindingKind = "none" | "text" | "basicField" | "dict" | "mainField" | "subField" | "systemParam";
|
|
217
|
+
type SystemParamId = "templateName" | "sheetCount" | "sheetIndex" | "sheetName" | "pageNumber" | "totalPageNumber" | "currentDate" | "currentDateTime" | "tenantName" | "userDisplayName" | "userLoginName" | "subSchemaCount" | (string & {});
|
|
218
|
+
type CellBindingMeta = {
|
|
219
|
+
bindingKind?: CellBindingKind;
|
|
220
|
+
paramId?: SystemParamId;
|
|
221
|
+
instanceFillable?: boolean;
|
|
222
|
+
fieldCode?: string;
|
|
223
|
+
subSchemaId?: number;
|
|
224
|
+
subRowIndex?: number;
|
|
225
|
+
subRowSlot?: number;
|
|
226
|
+
dictCode?: string;
|
|
227
|
+
remark?: string;
|
|
228
|
+
dictAllowCustom?: boolean;
|
|
229
|
+
dataType?: string;
|
|
230
|
+
imageStorage?: "base64" | "fileId" | "url";
|
|
231
|
+
};
|
|
232
|
+
type CellLayoutHint = {
|
|
233
|
+
layoutElement?: "none" | "signature" | "qrcode" | "chart" | "image";
|
|
234
|
+
};
|
|
235
|
+
type CellRoundingMeta = {
|
|
236
|
+
roundMode?: "half_up" | "half_even" | "truncate" | "ceiling" | "floor" | "to_interval" | "significant";
|
|
237
|
+
interval?: number;
|
|
238
|
+
scale?: number;
|
|
239
|
+
sigDigits?: number;
|
|
240
|
+
triggers?: Array<"onCommit" | "onCompute">;
|
|
241
|
+
};
|
|
242
|
+
type CellFormulaBindingMeta = {
|
|
243
|
+
formulaKind?: "grid" | "field" | "script";
|
|
244
|
+
source?: string;
|
|
245
|
+
scriptBlockKey?: string;
|
|
246
|
+
writeBack?: "value" | "display";
|
|
247
|
+
roundAfter?: boolean;
|
|
248
|
+
errorText?: string;
|
|
249
|
+
fieldScope?: "main" | "subRow";
|
|
250
|
+
subSchemaId?: number;
|
|
251
|
+
writeToFieldCode?: string;
|
|
252
|
+
inputWhen?: "always" | "anyPresent" | "allPresent";
|
|
253
|
+
inputFields?: string[];
|
|
254
|
+
runWhen?: "auto" | "manualOnly";
|
|
255
|
+
};
|
|
256
|
+
type SubTableRegionConfig = {
|
|
257
|
+
id: string;
|
|
258
|
+
subSchemaId?: number;
|
|
259
|
+
anchor: string;
|
|
260
|
+
direction: "vertical" | "horizontal";
|
|
261
|
+
rowsPerPage: number;
|
|
262
|
+
};
|
|
263
|
+
declare function cellMetaCompoundKey(sheetId: string, cellKey: string): string;
|
|
264
|
+
declare function parseCellMetaCompoundKey(key: string): {
|
|
265
|
+
sheetId: string;
|
|
266
|
+
cellKey: string;
|
|
267
|
+
} | null;
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* 实例 data JSON 的 `logicalState`:用于"逻辑页"扩容子表行数。
|
|
271
|
+
*
|
|
272
|
+
* - `data.subTables[N].rows` 始终是全量数组;`logicalPageIndex` 只是显示窗口
|
|
273
|
+
* - 一页行容量 = `region.rows`;总可填行数 = `region.rows * logicalPageCount`
|
|
274
|
+
* - 切页只更新 `logicalPageIndex`,不改 rows,不卸载编辑器
|
|
275
|
+
*/
|
|
276
|
+
interface LogicalState {
|
|
277
|
+
/** 全局当前逻辑页(默认 0) */
|
|
278
|
+
logicalPageIndex?: number;
|
|
279
|
+
/** 全局逻辑页总数(最少 1) */
|
|
280
|
+
logicalPageCount?: number;
|
|
281
|
+
/**
|
|
282
|
+
* 多 sheet 模板时每个 sheet 独立逻辑页(缺省回退到全局)
|
|
283
|
+
* key = sheetId
|
|
284
|
+
*/
|
|
285
|
+
perSheet?: Record<string, {
|
|
286
|
+
logicalPageIndex: number;
|
|
287
|
+
logicalPageCount: number;
|
|
288
|
+
}>;
|
|
289
|
+
/**
|
|
290
|
+
* 不参与打印预览的逻辑页 slot(`${sheetId}::${logicalPageIndex}`)。
|
|
291
|
+
* 隐藏页仍可编辑;页脚 pageNumber/totalPageNumber 留空。
|
|
292
|
+
*/
|
|
293
|
+
hiddenPageSlots?: string[];
|
|
294
|
+
}
|
|
295
|
+
/** 从实例 data JSON 字符串读 logicalState;缺失/非法返回空对象 */
|
|
296
|
+
declare function parseLogicalState(dataJson: string | null | undefined): LogicalState;
|
|
297
|
+
/** 从已解析的 root 对象读 logicalState(无副作用) */
|
|
298
|
+
declare function pickLogicalStateFromRoot(root: unknown): LogicalState;
|
|
299
|
+
/** 取某个 sheet 当前应当用的 (logicalPageIndex, logicalPageCount):优先 perSheet[sheetId],回退全局,再回退 (0,1) */
|
|
300
|
+
declare function resolveSheetLogicalPage(ls: LogicalState | null | undefined, sheetId: string): {
|
|
301
|
+
logicalPageIndex: number;
|
|
302
|
+
logicalPageCount: number;
|
|
303
|
+
};
|
|
304
|
+
/** 把 logicalState 合并写回实例 data JSON(不动 cells/cellsBySheet 等其它字段) */
|
|
305
|
+
declare function mergeInstanceDataJsonWithLogicalState(priorDataJson: string, patch: Partial<LogicalState> | LogicalState | null | undefined): string;
|
|
306
|
+
/**
|
|
307
|
+
* 子表全量数据(acc)持久化在 instance data JSON 的 `subTables` 字段:
|
|
308
|
+
* data.subTables[N] = { rows: Array<Record<col,val>> }
|
|
309
|
+
* 与 docs/sheet-system/03 §2 的"伪结构示例"一致;缺失视为空 acc。
|
|
310
|
+
*/
|
|
311
|
+
type InstanceSubTablesData = Record<string, {
|
|
312
|
+
rows: Array<Record<string, unknown>>;
|
|
313
|
+
}>;
|
|
314
|
+
/** 从 instance data JSON 读 subTables.rows → 转成 acc 格式(以 number 子表序号为键) */
|
|
315
|
+
declare function parseInstanceSubTables(dataJson: string | null | undefined): Record<number, Array<Record<string, unknown>>>;
|
|
316
|
+
/** 把 acc(按 number sid 索引)合并写回 data.subTables(用 "1"/"2" 作为 key 与文档一致) */
|
|
317
|
+
declare function mergeInstanceDataJsonWithSubTables(priorDataJson: string, acc: Record<number, Array<Record<string, unknown>>> | null | undefined): string;
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* 模板包内嵌字典目录(设计态 workbook.meta.dictCatalog)纯类型与常量。
|
|
321
|
+
* 逻辑(规范化 / 快照 / overlay 合并)保留在 kt-web templateDictCatalog.ts。
|
|
322
|
+
*/
|
|
323
|
+
declare const TEMPLATE_DICT_CATALOG_VERSION: 1;
|
|
324
|
+
declare const DICT_CATALOG_META_KEY = "dictCatalog";
|
|
325
|
+
declare const DICT_OVERLAYS_BY_USER_KEY = "dictOverlaysByUser";
|
|
326
|
+
type TemplateDictKind = "fixed" | "editable";
|
|
327
|
+
/** 设计器/表格展示用 dictKind 中文标签 */
|
|
328
|
+
declare function describeDictKind(kind: TemplateDictKind): string;
|
|
329
|
+
type TemplateDictItem = {
|
|
330
|
+
value: string;
|
|
331
|
+
label: string;
|
|
332
|
+
sortOrder?: number;
|
|
333
|
+
enabled?: boolean;
|
|
334
|
+
};
|
|
335
|
+
type TemplateDictDef = {
|
|
336
|
+
code: string;
|
|
337
|
+
name: string;
|
|
338
|
+
dictKind: TemplateDictKind;
|
|
339
|
+
items: TemplateDictItem[];
|
|
340
|
+
enabled?: boolean;
|
|
341
|
+
};
|
|
342
|
+
type TemplateDictCatalog = {
|
|
343
|
+
v: typeof TEMPLATE_DICT_CATALOG_VERSION;
|
|
344
|
+
updatedAt?: string;
|
|
345
|
+
dicts: TemplateDictDef[];
|
|
346
|
+
};
|
|
347
|
+
type DictSnapshotEntry = {
|
|
348
|
+
dictKind: TemplateDictKind;
|
|
349
|
+
name?: string;
|
|
350
|
+
items: TemplateDictItem[];
|
|
351
|
+
};
|
|
352
|
+
type DictSnapshotsMap = Record<string, DictSnapshotEntry>;
|
|
353
|
+
/** userId → dictCode → overlay items */
|
|
354
|
+
type InstanceDictOverlaysByUser = Record<string, Record<string, TemplateDictItem[]>>;
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* 实例 data JSON schema v2(字段包 SSOT)
|
|
358
|
+
*/
|
|
359
|
+
|
|
360
|
+
declare const INSTANCE_DATA_SCHEMA_V2: 2;
|
|
361
|
+
declare const INSTANCE_DATA_SCHEMA_V3: 3;
|
|
362
|
+
type RefreshPolicy = "manual" | "onOpen" | "onSourceSave";
|
|
363
|
+
type PullContextSource = {
|
|
364
|
+
alias: string;
|
|
365
|
+
sourceInstanceId?: string;
|
|
366
|
+
sourceProductCode?: string;
|
|
367
|
+
fromPolicy?: boolean;
|
|
368
|
+
adhocRules?: FieldPullRuleDef[];
|
|
369
|
+
};
|
|
370
|
+
type PullContext = {
|
|
371
|
+
sources: PullContextSource[];
|
|
372
|
+
refreshPolicy?: RefreshPolicy;
|
|
373
|
+
lastPulledAt?: string;
|
|
374
|
+
lastPullSignature?: string;
|
|
375
|
+
};
|
|
376
|
+
type FieldPullRuleDef = {
|
|
377
|
+
targetPath: string;
|
|
378
|
+
mode: "direct" | "aggregate" | "filter" | "expr";
|
|
379
|
+
sourceAlias?: string;
|
|
380
|
+
sourcePath?: string;
|
|
381
|
+
aggregateFn?: "sum" | "avg" | "min" | "max" | "count";
|
|
382
|
+
filterJson?: Record<string, unknown>;
|
|
383
|
+
exprSource?: string;
|
|
384
|
+
enabled?: boolean;
|
|
385
|
+
};
|
|
386
|
+
type RoundingOverrideEntry = {
|
|
387
|
+
roundMode?: "decimal" | "interval" | "sigDigits";
|
|
388
|
+
scale?: number;
|
|
389
|
+
interval?: number;
|
|
390
|
+
sigDigits?: number;
|
|
391
|
+
triggers?: Array<"onCommit" | "onCompute">;
|
|
392
|
+
};
|
|
393
|
+
type ComboSharedContext = {
|
|
394
|
+
sharedSeed?: Record<string, unknown>;
|
|
395
|
+
uiLayout?: {
|
|
396
|
+
slotOrder?: string[];
|
|
397
|
+
hiddenSlotKeys?: string[];
|
|
398
|
+
};
|
|
399
|
+
refreshPolicyDefault?: RefreshPolicy;
|
|
400
|
+
};
|
|
401
|
+
type ComboInstanceDataV3 = {
|
|
402
|
+
schemaVersion: typeof INSTANCE_DATA_SCHEMA_V3;
|
|
403
|
+
kind: "combo";
|
|
404
|
+
comboSnapshotId: string;
|
|
405
|
+
sharedContext: ComboSharedContext;
|
|
406
|
+
slots: Record<string, InstanceFieldPackV2Ext>;
|
|
407
|
+
};
|
|
408
|
+
type InstanceSubTablePack = {
|
|
409
|
+
rows: Array<Record<string, unknown>>;
|
|
410
|
+
logicalState?: {
|
|
411
|
+
logicalPageIndex?: number;
|
|
412
|
+
logicalPageCount?: number;
|
|
413
|
+
};
|
|
414
|
+
};
|
|
415
|
+
type InstanceFieldPackV2 = {
|
|
416
|
+
schemaVersion: typeof INSTANCE_DATA_SCHEMA_V2;
|
|
417
|
+
base: Record<string, unknown>;
|
|
418
|
+
/** 分页专用基本项:scopeId → 字段键值(含 table_name) */
|
|
419
|
+
baseScoped?: Record<string, Record<string, unknown>>;
|
|
420
|
+
main: Record<string, unknown>;
|
|
421
|
+
subTables: Record<string, InstanceSubTablePack>;
|
|
422
|
+
params: Record<string, unknown>;
|
|
423
|
+
logicalState: LogicalState;
|
|
424
|
+
orphanCellsBySheet: Record<string, Record<string, unknown>>;
|
|
425
|
+
/** 嵌入资产实例态:签章 fileId、QR 覆盖等,key = slotId */
|
|
426
|
+
embedStates?: Record<string, EmbedInstanceState>;
|
|
427
|
+
upgradeLog?: Array<Record<string, unknown>>;
|
|
428
|
+
/** 一次性 legacy 备份(运维可清理) */
|
|
429
|
+
_legacyBackup?: unknown;
|
|
430
|
+
/** editable 模板字典增量(按用户,不回写模板) */
|
|
431
|
+
dictOverlaysByUser?: InstanceDictOverlaysByUser;
|
|
432
|
+
};
|
|
433
|
+
/** v2 字段包扩展:报告拉取上下文与修约覆盖 */
|
|
434
|
+
type InstanceFieldPackV2Ext = InstanceFieldPackV2 & {
|
|
435
|
+
pullContext?: PullContext;
|
|
436
|
+
roundingOverrides?: Record<string, RoundingOverrideEntry>;
|
|
437
|
+
};
|
|
438
|
+
type InstanceDataRoot = Record<string, unknown>;
|
|
439
|
+
/** 判别是否为 v3 组合实例 */
|
|
440
|
+
declare function isComboInstanceDataV3(data: unknown): data is ComboInstanceDataV3;
|
|
441
|
+
/** 从 root 提取 v3 组合包 */
|
|
442
|
+
declare function comboDataFromRoot(root: InstanceDataRoot): ComboInstanceDataV3 | null;
|
|
443
|
+
/** 判别是否为 v2 字段包 */
|
|
444
|
+
declare function isInstanceFieldPackV2(data: unknown): data is InstanceFieldPackV2;
|
|
445
|
+
/** 从 JSON 字符串解析 root */
|
|
446
|
+
declare function parseInstanceDataRoot(dataJson: string | null | undefined): InstanceDataRoot;
|
|
447
|
+
/** 是否 legacy v1(cells/cellsBySheet 为主,无 schemaVersion=2) */
|
|
448
|
+
declare function isLegacyInstanceDataV1(root: InstanceDataRoot): boolean;
|
|
449
|
+
/** 创建空 v2 字段包 */
|
|
450
|
+
declare function emptyFieldPackV2(): InstanceFieldPackV2;
|
|
451
|
+
/** 序列化 v2 字段包为 JSON 字符串 */
|
|
452
|
+
declare function serializeFieldPackV2(pack: InstanceFieldPackV2): string;
|
|
453
|
+
/** 从 root 提取 v2 字段包(已是 v2 时);否则 null */
|
|
454
|
+
declare function fieldPackFromRoot(root: InstanceDataRoot): InstanceFieldPackV2 | null;
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* 字段修约规则解析与运行时应用(field 公式写回 / roundByField)
|
|
458
|
+
*/
|
|
459
|
+
|
|
460
|
+
/** 从 rounding_json 字符串解析修约元数据 */
|
|
461
|
+
declare function parseRoundingJson(raw: string | null | undefined): CellRoundingMeta | undefined;
|
|
462
|
+
/** 计算阶段是否应用修约(与 compute.ts getRoundingForCompute 一致) */
|
|
463
|
+
declare function roundingForCompute(meta: CellRoundingMeta | undefined): CellRoundingMeta | undefined;
|
|
464
|
+
type FieldRoundingTarget = {
|
|
465
|
+
scope: "main" | "base" | "sub";
|
|
466
|
+
key: string;
|
|
467
|
+
subSchemaId?: number;
|
|
468
|
+
};
|
|
469
|
+
/** 按目标字段从 fieldRegistry 查 rounding_json;实例 override 优先于 registry */
|
|
470
|
+
declare function resolveRoundingForTarget(registry: TemplateFieldRegistry | null | undefined, target: FieldRoundingTarget, overrides?: Record<string, RoundingOverrideEntry> | null): CellRoundingMeta | undefined;
|
|
471
|
+
/** 与修约 override 键一致:main.kyqd / base.xxx / sub:1.strength */
|
|
472
|
+
declare function targetToOverrideKey(target: FieldRoundingTarget): string;
|
|
473
|
+
type ParsedFieldPath = {
|
|
474
|
+
scope: "main";
|
|
475
|
+
key: string;
|
|
476
|
+
} | {
|
|
477
|
+
scope: "base";
|
|
478
|
+
key: string;
|
|
479
|
+
} | {
|
|
480
|
+
scope: "sub";
|
|
481
|
+
subSchemaId: number;
|
|
482
|
+
key: string;
|
|
483
|
+
} | {
|
|
484
|
+
scope: "row";
|
|
485
|
+
key: string;
|
|
486
|
+
};
|
|
487
|
+
/**
|
|
488
|
+
* 解析字段路径字符串,如 m2 / m.m2 / s1.qdqz / row.qd1 / b.xxx
|
|
489
|
+
*/
|
|
490
|
+
declare function parseFieldPath(raw: string): ParsedFieldPath | null;
|
|
491
|
+
declare function resolveRoundingFromFieldPath(registry: TemplateFieldRegistry | null | undefined, path: string, ctx: {
|
|
492
|
+
currentTarget?: FieldRoundingTarget;
|
|
493
|
+
subSchemaId?: number;
|
|
494
|
+
}): CellRoundingMeta | undefined;
|
|
495
|
+
/** 将数值按修约元数据修约;null/''/非数值原样返回 */
|
|
496
|
+
declare function applyNumericRounding(value: SjsValue, meta: CellRoundingMeta | undefined): SjsValue;
|
|
497
|
+
type ComputeFieldLhs = {
|
|
498
|
+
kind: "main";
|
|
499
|
+
key: string;
|
|
500
|
+
} | {
|
|
501
|
+
kind: "base";
|
|
502
|
+
key: string;
|
|
503
|
+
} | {
|
|
504
|
+
kind: "subRow";
|
|
505
|
+
subSchemaId: number;
|
|
506
|
+
col: string;
|
|
507
|
+
rowIndex: number;
|
|
508
|
+
};
|
|
509
|
+
declare function lhsToRoundingTarget(lhs: ComputeFieldLhs): FieldRoundingTarget;
|
|
510
|
+
/** field 公式写回 fieldData 前:按目标字段 onCompute 修约 */
|
|
511
|
+
declare function applyFieldRoundingForStore(value: SjsValue, registry: TemplateFieldRegistry | null | undefined, lhs: ComputeFieldLhs, opts?: {
|
|
512
|
+
roundAfter?: boolean;
|
|
513
|
+
}): SjsValue;
|
|
514
|
+
|
|
515
|
+
/** field 公式:`:= <expr>` 解析 + 字段上下文构造 + 聚合函数注入 */
|
|
516
|
+
|
|
517
|
+
/** 若源码以 ':=' 起头则返回去前缀后的表达式;否则返回 null */
|
|
518
|
+
declare function stripFieldPrefix(src: string): string | null;
|
|
519
|
+
/** LHS 推导:从绑定与作用域决定字段公式作用于 main/subRow */
|
|
520
|
+
type FieldLhs = {
|
|
521
|
+
kind: "main";
|
|
522
|
+
key: string;
|
|
523
|
+
} | {
|
|
524
|
+
kind: "sub";
|
|
525
|
+
subSchemaId: number;
|
|
526
|
+
col: string;
|
|
527
|
+
};
|
|
528
|
+
interface FieldDataCtx {
|
|
529
|
+
base: Record<string, unknown>;
|
|
530
|
+
main: Record<string, unknown>;
|
|
531
|
+
sub: Record<number, Array<Record<string, unknown>>>;
|
|
532
|
+
params: Record<string, unknown>;
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* 构造表达式运行时上下文:包含 b/m/sN/p + row(subRow 作用域)+ 聚合/数学函数。
|
|
536
|
+
*
|
|
537
|
+
* `mutable=true`(脚本块场景)时额外注入 `assign / setMain / setBase / setSub` 一组 setter,
|
|
538
|
+
* 让脚本能主动写回字段数据(典型用例:`fxStat` 一个脚本算多个统计指标分别赋给 m11/m12/m13)。
|
|
539
|
+
* field 公式只能返回单值不应使用,故默认 false。
|
|
540
|
+
*/
|
|
541
|
+
type FieldRunContextOptions = {
|
|
542
|
+
mutable?: boolean;
|
|
543
|
+
fieldRegistry?: TemplateFieldRegistry | null;
|
|
544
|
+
/** 当前公式目标,roundByField 默认规则来源 */
|
|
545
|
+
currentTarget?: FieldRoundingTarget;
|
|
546
|
+
aggregateEmptyAs?: AggregateEmptyAs;
|
|
547
|
+
};
|
|
548
|
+
declare function buildFieldRunContext(data: FieldDataCtx, scope: {
|
|
549
|
+
kind: "main";
|
|
550
|
+
} | {
|
|
551
|
+
kind: "sub";
|
|
552
|
+
subSchemaId: number;
|
|
553
|
+
rowIndex: number;
|
|
554
|
+
}, options?: FieldRunContextOptions): Record<string, SjsValue | SjsFn>;
|
|
555
|
+
type FormulaStdLibOptions = {
|
|
556
|
+
fieldRegistry?: TemplateFieldRegistry | null;
|
|
557
|
+
currentTarget?: FieldRoundingTarget;
|
|
558
|
+
subSchemaId?: number;
|
|
559
|
+
aggregateEmptyAs?: AggregateEmptyAs;
|
|
560
|
+
};
|
|
561
|
+
/** 纯函数标准库:sum/avg/min/max/count/first/last + round/roundToInterval/roundSig + abs/ceil/floor + ifEmpty/formatDate */
|
|
562
|
+
declare function buildFormulaStdLib(opts?: FormulaStdLibOptions): Record<string, SjsFn>;
|
|
563
|
+
|
|
564
|
+
/** 打印/预览叠图 embed 上下文 */
|
|
565
|
+
type EmbedPrintContext = {
|
|
566
|
+
embeds: WorkbookEmbedDef[];
|
|
567
|
+
embedStates?: Record<string, EmbedInstanceState>;
|
|
568
|
+
qrPayloadBySlot?: Record<string, string>;
|
|
569
|
+
/** 图表 live 栅格数据源 */
|
|
570
|
+
fieldData?: FieldDataCtx;
|
|
571
|
+
/** 图表 script 数据源 */
|
|
572
|
+
scripts?: WorkbookScripts | null;
|
|
573
|
+
};
|
|
574
|
+
declare function hasEmbedsToPaint(ctx: EmbedPrintContext | null | undefined): boolean;
|
|
575
|
+
|
|
576
|
+
/** 与 `SheetTemplateState` 对齐的工作簿页(SSOT)。 */
|
|
577
|
+
type TemplateSheetItem = {
|
|
578
|
+
id: string;
|
|
579
|
+
name: string;
|
|
580
|
+
sheet: SheetTemplateState;
|
|
581
|
+
};
|
|
582
|
+
/** 持久化/工具链使用的模板工作簿根对象(取代旧 `Workbook` + 桥接)。 */
|
|
583
|
+
type TemplateWorkbookState = {
|
|
584
|
+
workbookVersion: number;
|
|
585
|
+
activeSheetId: string;
|
|
586
|
+
sheets: TemplateSheetItem[];
|
|
587
|
+
meta?: WorkbookMeta;
|
|
588
|
+
/** M3:工作簿级 CALC_* 脚本块(与旧 Workbook.scripts 对齐) */
|
|
589
|
+
scripts?: WorkbookScripts | null;
|
|
590
|
+
/** M3+:命名区域 */
|
|
591
|
+
namedRanges?: WorkbookNamedRange[] | null;
|
|
592
|
+
/** 嵌入层:图表区 + 签章/图片/QR 槽(设计态 SSOT) */
|
|
593
|
+
embeds?: WorkbookEmbedDef[] | null;
|
|
594
|
+
/** 域 02:拼接/可变行等元数据;持久化于内层工作簿根 */
|
|
595
|
+
ktTemplate?: KtTemplateRoot;
|
|
596
|
+
};
|
|
597
|
+
declare const TEMPLATE_WORKBOOK_JSON_VERSION: 1;
|
|
598
|
+
|
|
599
|
+
interface MasterCell {
|
|
600
|
+
masterR: number;
|
|
601
|
+
masterC: number;
|
|
602
|
+
rect: MergeRect;
|
|
603
|
+
}
|
|
604
|
+
/** 合并区快速查询:O(1) 命中主格(初始化 O(格数))。 */
|
|
605
|
+
declare class MergeIndex {
|
|
606
|
+
private readonly map;
|
|
607
|
+
constructor(merges: MergeRect[]);
|
|
608
|
+
getMaster(r: number, c: number): MasterCell | undefined;
|
|
609
|
+
/** 若 (r,c) 为合并块左上角则为主格。 */
|
|
610
|
+
isMaster(r: number, c: number): boolean;
|
|
611
|
+
static overlaps(a: MergeRect, b: MergeRect): boolean;
|
|
612
|
+
static normalize(rect: MergeRect): MergeRect;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
type BorderPreset = "none" | "all" | "outer" | "top" | "bottom" | "left" | "right" | "innerHorizontal" | "innerVertical";
|
|
616
|
+
interface BorderApplySpec {
|
|
617
|
+
width: Exclude<BorderWidth, "none">;
|
|
618
|
+
color: string;
|
|
619
|
+
pattern: BorderPattern;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
/** 选区内每个主格是否都是独立单格(无合并)。 */
|
|
623
|
+
declare function selectionIsUnmergedRectangle(idx: MergeIndex, rect: {
|
|
624
|
+
r1: number;
|
|
625
|
+
c1: number;
|
|
626
|
+
r2: number;
|
|
627
|
+
c2: number;
|
|
628
|
+
}): boolean;
|
|
629
|
+
declare function applyBorderPresetToSheet(sheet: Sheet, mergeIdx: MergeIndex, rect: {
|
|
630
|
+
r1: number;
|
|
631
|
+
c1: number;
|
|
632
|
+
r2: number;
|
|
633
|
+
c2: number;
|
|
634
|
+
}, preset: BorderPreset, spec: BorderApplySpec): Record<string, CellData>;
|
|
635
|
+
|
|
636
|
+
declare function matrixToTsv(rows: string[][]): string;
|
|
637
|
+
declare function tsvToMatrix(tsv: string): string[][];
|
|
638
|
+
declare function readSelectionAsTsv(sheet: Sheet, r1: number, c1: number, r2: number, c2: number): string;
|
|
639
|
+
interface PasteCellPatch {
|
|
640
|
+
key: string;
|
|
641
|
+
before: CellData | undefined;
|
|
642
|
+
after: CellData | undefined;
|
|
643
|
+
}
|
|
644
|
+
/** 自 (startR,startC) 粘贴矩阵;返回 cell 级 patch(用于撤销)。 */
|
|
645
|
+
declare function buildPastePatches(sheet: Sheet, startR: number, startC: number, matrix: string[][]): PasteCellPatch[];
|
|
646
|
+
|
|
647
|
+
declare function createDefaultPage(): PageSettings;
|
|
648
|
+
declare function createEmptySheet(name: string, rowCount?: 200, colCount?: 50): SheetItem;
|
|
649
|
+
declare function createEmptyWorkbook(): Workbook;
|
|
650
|
+
/** 稀疏填充用于压力 / dev 基线(showcase)。 */
|
|
651
|
+
declare function fillSparseDemoCells(sheet: Sheet, rows: number, cols: number): void;
|
|
652
|
+
|
|
653
|
+
declare function serializeWorkbook(workbook: Workbook): string;
|
|
654
|
+
declare function parseWorkbookJson(text: string): Workbook;
|
|
655
|
+
|
|
656
|
+
/** 公式引擎统一类型:AST 节点、值域、错误、计算上下文 */
|
|
657
|
+
type FormulaValueKind = "num" | "str" | "bool" | "null" | "err";
|
|
658
|
+
type FormulaError = {
|
|
659
|
+
code: "#ERR" | "#DIV0" | "#REF" | "#NAME" | "#VALUE" | "#CYCLE" | "#NUM";
|
|
660
|
+
message?: string;
|
|
661
|
+
};
|
|
662
|
+
type FormulaValue = {
|
|
663
|
+
k: "num";
|
|
664
|
+
v: number;
|
|
665
|
+
} | {
|
|
666
|
+
k: "str";
|
|
667
|
+
v: string;
|
|
668
|
+
} | {
|
|
669
|
+
k: "bool";
|
|
670
|
+
v: boolean;
|
|
671
|
+
} | {
|
|
672
|
+
k: "null";
|
|
673
|
+
} | {
|
|
674
|
+
k: "err";
|
|
675
|
+
v: FormulaError;
|
|
676
|
+
};
|
|
677
|
+
/** 数组(区域)值:二维矩阵;行主序 */
|
|
678
|
+
type FormulaArray = {
|
|
679
|
+
k: "arr";
|
|
680
|
+
rows: FormulaValue[][];
|
|
681
|
+
};
|
|
682
|
+
type FormulaAny = FormulaValue | FormulaArray;
|
|
683
|
+
declare function vNum(v: number): FormulaValue;
|
|
684
|
+
declare function vStr(v: string): FormulaValue;
|
|
685
|
+
declare function vBool(v: boolean): FormulaValue;
|
|
686
|
+
declare const V_NULL: FormulaValue;
|
|
687
|
+
declare function vErr(code: FormulaError["code"], message?: string): FormulaValue;
|
|
688
|
+
declare function isErr(v: FormulaAny): v is {
|
|
689
|
+
k: "err";
|
|
690
|
+
v: FormulaError;
|
|
691
|
+
};
|
|
692
|
+
declare function coerceNum(v: FormulaValue): number | null;
|
|
693
|
+
declare function coerceStr(v: FormulaValue): string;
|
|
694
|
+
declare function coerceBool(v: FormulaValue): boolean | null;
|
|
695
|
+
/** 迭代区域内每个值(按行主序) */
|
|
696
|
+
declare function forEachArrayValue(arr: FormulaArray, fn: (v: FormulaValue) => void): void;
|
|
697
|
+
/** AST */
|
|
698
|
+
type AstNode = {
|
|
699
|
+
type: "num";
|
|
700
|
+
value: number;
|
|
701
|
+
} | {
|
|
702
|
+
type: "str";
|
|
703
|
+
value: string;
|
|
704
|
+
} | {
|
|
705
|
+
type: "bool";
|
|
706
|
+
value: boolean;
|
|
707
|
+
} | {
|
|
708
|
+
type: "ref";
|
|
709
|
+
sheet?: string;
|
|
710
|
+
r: number;
|
|
711
|
+
c: number;
|
|
712
|
+
absR?: boolean;
|
|
713
|
+
absC?: boolean;
|
|
714
|
+
} | {
|
|
715
|
+
type: "range";
|
|
716
|
+
sheet?: string;
|
|
717
|
+
r1: number;
|
|
718
|
+
c1: number;
|
|
719
|
+
r2: number;
|
|
720
|
+
c2: number;
|
|
721
|
+
} | {
|
|
722
|
+
type: "name";
|
|
723
|
+
name: string;
|
|
724
|
+
} | {
|
|
725
|
+
type: "unary";
|
|
726
|
+
op: "+" | "-";
|
|
727
|
+
expr: AstNode;
|
|
728
|
+
} | {
|
|
729
|
+
type: "binary";
|
|
730
|
+
op: BinOp;
|
|
731
|
+
left: AstNode;
|
|
732
|
+
right: AstNode;
|
|
733
|
+
} | {
|
|
734
|
+
type: "call";
|
|
735
|
+
name: string;
|
|
736
|
+
args: AstNode[];
|
|
737
|
+
} | {
|
|
738
|
+
type: "percent";
|
|
739
|
+
expr: AstNode;
|
|
740
|
+
};
|
|
741
|
+
type BinOp = "+" | "-" | "*" | "/" | "^" | "&" | "=" | "<>" | "<" | "<=" | ">" | ">=";
|
|
742
|
+
/** 计算上下文:由 compute.ts 构造后传给 evaluator */
|
|
743
|
+
interface EvalContext {
|
|
744
|
+
activeSheetId: string;
|
|
745
|
+
getCell: (sheetId: string, r: number, c: number) => FormulaValue;
|
|
746
|
+
getNamed?: (name: string) => {
|
|
747
|
+
sheet: string;
|
|
748
|
+
r1: number;
|
|
749
|
+
c1: number;
|
|
750
|
+
r2: number;
|
|
751
|
+
c2: number;
|
|
752
|
+
} | null;
|
|
753
|
+
here?: {
|
|
754
|
+
sheetId: string;
|
|
755
|
+
r: number;
|
|
756
|
+
c: number;
|
|
757
|
+
};
|
|
758
|
+
fieldCtx?: FieldEvalContext;
|
|
759
|
+
}
|
|
760
|
+
/** 字段公式 / 脚本专用:主/子表数据读取 */
|
|
761
|
+
interface FieldEvalContext {
|
|
762
|
+
base: Record<string, unknown>;
|
|
763
|
+
main: Record<string, unknown>;
|
|
764
|
+
sub: Record<number, Array<Record<string, unknown>>>;
|
|
765
|
+
params: Record<string, unknown>;
|
|
766
|
+
rowIndex?: number;
|
|
767
|
+
currentSubSchemaId?: number;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
/**
|
|
771
|
+
* A1 寻址工具:列字母与 0-based 下标互转;解析 A1 / A1:B10 / Sheet2!A1 引用。
|
|
772
|
+
* 内部下标全部 0-based(与引擎一致);对外展示(公式栏)使用 1-based A1。
|
|
773
|
+
*/
|
|
774
|
+
declare function columnLettersToIndex(letters: string): number;
|
|
775
|
+
declare function columnIndexToLetters(index0: number): string;
|
|
776
|
+
type A1SingleRef = {
|
|
777
|
+
kind: "single";
|
|
778
|
+
sheet?: string;
|
|
779
|
+
/** 0-based 行 */
|
|
780
|
+
r: number;
|
|
781
|
+
/** 0-based 列 */
|
|
782
|
+
c: number;
|
|
783
|
+
/** 绝对行 $1 */
|
|
784
|
+
absR?: boolean;
|
|
785
|
+
/** 绝对列 $A */
|
|
786
|
+
absC?: boolean;
|
|
787
|
+
};
|
|
788
|
+
type A1RangeRef = {
|
|
789
|
+
kind: "range";
|
|
790
|
+
sheet?: string;
|
|
791
|
+
r1: number;
|
|
792
|
+
c1: number;
|
|
793
|
+
r2: number;
|
|
794
|
+
c2: number;
|
|
795
|
+
};
|
|
796
|
+
type A1Ref = A1SingleRef | A1RangeRef;
|
|
797
|
+
/** 解析 sheetId.r11c1:1-based 行列(与画布 cell 坐标一致),sheet 为工作表 id / 快照 id。 */
|
|
798
|
+
declare function parseInternalR1C1Ref(input: string): A1SingleRef | null;
|
|
799
|
+
/** 解析单点 A1,不含 sheet 时返回 sheet=undefined */
|
|
800
|
+
declare function parseA1Single(input: string): A1SingleRef | null;
|
|
801
|
+
/** 解析 A1 或 A1:B10(含可选 sheet!) */
|
|
802
|
+
declare function parseA1Ref(input: string): A1Ref | null;
|
|
803
|
+
declare function formatA1Single(r0: number, c0: number, sheet?: string): string;
|
|
804
|
+
declare function formatA1Range(r1: number, c1: number, r2: number, c2: number, sheet?: string): string;
|
|
805
|
+
|
|
806
|
+
/** 网格公式词法:把 =SUM(A1:B2, 3*4) 切成 token 流 */
|
|
807
|
+
type TokenType = "num" | "str" | "ident" | "ref" | "range" | "op" | "lparen" | "rparen" | "comma" | "semi" | "eof";
|
|
808
|
+
interface Token {
|
|
809
|
+
type: TokenType;
|
|
810
|
+
text: string;
|
|
811
|
+
/** 起始偏移 */
|
|
812
|
+
pos: number;
|
|
813
|
+
}
|
|
814
|
+
declare function tokenize(src: string): Token[];
|
|
815
|
+
|
|
816
|
+
/** 网格公式语法分析:Pratt 优先级 */
|
|
817
|
+
|
|
818
|
+
declare class Parser {
|
|
819
|
+
private toks;
|
|
820
|
+
private i;
|
|
821
|
+
constructor(src: string);
|
|
822
|
+
parse(): AstNode;
|
|
823
|
+
private peek;
|
|
824
|
+
private eat;
|
|
825
|
+
private parseExpr;
|
|
826
|
+
private parseUnary;
|
|
827
|
+
private parsePostfix;
|
|
828
|
+
private parsePrimary;
|
|
829
|
+
}
|
|
830
|
+
declare function parseFormula(src: string): AstNode;
|
|
831
|
+
|
|
832
|
+
/** 依赖图:节点 id 规则
|
|
833
|
+
* - 网格格:grid:<sheetId>!r,c
|
|
834
|
+
* - 字段:field:m.<key>、field:s<N>.<col>#<rowIdx>
|
|
835
|
+
* - 脚本:script:<key>(scope=main)或 script:<key>#<rowIdx>(subRow)
|
|
836
|
+
*/
|
|
837
|
+
type NodeId = string;
|
|
838
|
+
declare function gridNodeId(sheetId: string, r: number, c: number): NodeId;
|
|
839
|
+
declare function mainFieldNodeId(key: string): NodeId;
|
|
840
|
+
declare function subFieldNodeId(subSchemaId: number, key: string, rowIdx: number): NodeId;
|
|
841
|
+
declare function scriptNodeId(key: string, rowIdx?: number, subSchemaId?: number): NodeId;
|
|
842
|
+
declare class DepGraph {
|
|
843
|
+
/** 出边:a → {b} 表示 b 依赖 a(a 变 b 需要重算) */
|
|
844
|
+
private outEdges;
|
|
845
|
+
/** 入边:a → {b} 表示 a 依赖 b */
|
|
846
|
+
private inEdges;
|
|
847
|
+
private allNodes;
|
|
848
|
+
addNode(id: NodeId): void;
|
|
849
|
+
/** self 依赖 dep:dep 变则 self 重算 */
|
|
850
|
+
addEdge(self: NodeId, dep: NodeId): void;
|
|
851
|
+
hasNode(id: NodeId): boolean;
|
|
852
|
+
dependenciesOf(id: NodeId): NodeId[];
|
|
853
|
+
dependentsOf(id: NodeId): NodeId[];
|
|
854
|
+
allIds(): NodeId[];
|
|
855
|
+
/**
|
|
856
|
+
* 拓扑排序;若存在环路,将环上所有节点标记为 cyclic(以数组二元组返回)。
|
|
857
|
+
* 返回 { order, cyclic }:order 为无环部分的求值顺序(先 dep 后 self)。
|
|
858
|
+
*/
|
|
859
|
+
topoSort(): {
|
|
860
|
+
order: NodeId[];
|
|
861
|
+
cyclic: Set<NodeId>;
|
|
862
|
+
};
|
|
863
|
+
/** 增量:找出所有需要重算的节点(dirty 的所有下游) */
|
|
864
|
+
dirtyClosure(roots: Iterable<NodeId>): Set<NodeId>;
|
|
865
|
+
clear(): void;
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
/** 网格公式内置函数(M3 最小集 + 少量常用):求值器调用 */
|
|
869
|
+
|
|
870
|
+
type FnImpl = (args: FormulaAny[]) => FormulaValue;
|
|
871
|
+
declare const FUNCTIONS: Record<string, FnImpl>;
|
|
872
|
+
|
|
873
|
+
/** 受限 JS 表达式引擎(field 公式 `:= expr` 与 script 共享)
|
|
874
|
+
*
|
|
875
|
+
* 支持:字面量(数字/字符串/布尔/null/数组/对象)、变量、成员访问(可选链)、
|
|
876
|
+
* 索引、一元 +/-/!、二元算术与比较、&&/||、三元、函数调用;let/const 声明、
|
|
877
|
+
* if/else、for…of、return;模板字符串(无嵌入式表达式)。
|
|
878
|
+
*
|
|
879
|
+
* 禁止:function 声明、class、new、this、import/require、regex 字面量、try/catch、
|
|
880
|
+
* 赋值给非本地变量、访问全局对象(window/document/globalThis/eval/Function 等)。
|
|
881
|
+
*/
|
|
882
|
+
type SjsNode = {
|
|
883
|
+
t: "Num";
|
|
884
|
+
v: number;
|
|
885
|
+
} | {
|
|
886
|
+
t: "Str";
|
|
887
|
+
v: string;
|
|
888
|
+
} | {
|
|
889
|
+
t: "Bool";
|
|
890
|
+
v: boolean;
|
|
891
|
+
} | {
|
|
892
|
+
t: "Null";
|
|
893
|
+
} | {
|
|
894
|
+
t: "Ident";
|
|
895
|
+
name: string;
|
|
896
|
+
} | {
|
|
897
|
+
t: "Arr";
|
|
898
|
+
items: SjsNode[];
|
|
899
|
+
} | {
|
|
900
|
+
t: "Obj";
|
|
901
|
+
props: Array<{
|
|
902
|
+
key: string;
|
|
903
|
+
value: SjsNode;
|
|
904
|
+
}>;
|
|
905
|
+
} | {
|
|
906
|
+
t: "Member";
|
|
907
|
+
obj: SjsNode;
|
|
908
|
+
prop: string;
|
|
909
|
+
optional?: boolean;
|
|
910
|
+
} | {
|
|
911
|
+
t: "Index";
|
|
912
|
+
obj: SjsNode;
|
|
913
|
+
idx: SjsNode;
|
|
914
|
+
optional?: boolean;
|
|
915
|
+
} | {
|
|
916
|
+
t: "Call";
|
|
917
|
+
callee: SjsNode;
|
|
918
|
+
args: SjsNode[];
|
|
919
|
+
optional?: boolean;
|
|
920
|
+
} | {
|
|
921
|
+
t: "Unary";
|
|
922
|
+
op: "+" | "-" | "!";
|
|
923
|
+
expr: SjsNode;
|
|
924
|
+
} | {
|
|
925
|
+
t: "Bin";
|
|
926
|
+
op: SjsBinOp;
|
|
927
|
+
l: SjsNode;
|
|
928
|
+
r: SjsNode;
|
|
929
|
+
} | {
|
|
930
|
+
t: "Tern";
|
|
931
|
+
c: SjsNode;
|
|
932
|
+
a: SjsNode;
|
|
933
|
+
b: SjsNode;
|
|
934
|
+
} | {
|
|
935
|
+
t: "Assign";
|
|
936
|
+
op: "=" | "+=" | "-=" | "*=" | "/=" | "**=";
|
|
937
|
+
name: string;
|
|
938
|
+
value: SjsNode;
|
|
939
|
+
};
|
|
940
|
+
type SjsBinOp = "+" | "-" | "*" | "/" | "%" | "**" | "==" | "!=" | "===" | "!==" | "<" | "<=" | ">" | ">=" | "&&" | "||" | "??";
|
|
941
|
+
type SjsStmt = {
|
|
942
|
+
t: "ExprStmt";
|
|
943
|
+
expr: SjsNode;
|
|
944
|
+
} | {
|
|
945
|
+
t: "VarDecl";
|
|
946
|
+
kind: "let" | "const";
|
|
947
|
+
name: string;
|
|
948
|
+
init?: SjsNode;
|
|
949
|
+
} | {
|
|
950
|
+
t: "If";
|
|
951
|
+
cond: SjsNode;
|
|
952
|
+
then: SjsStmt[];
|
|
953
|
+
else?: SjsStmt[];
|
|
954
|
+
} | {
|
|
955
|
+
t: "ForOf";
|
|
956
|
+
name: string;
|
|
957
|
+
iter: SjsNode;
|
|
958
|
+
body: SjsStmt[];
|
|
959
|
+
} | {
|
|
960
|
+
t: "Return";
|
|
961
|
+
arg?: SjsNode;
|
|
962
|
+
} | {
|
|
963
|
+
t: "Block";
|
|
964
|
+
body: SjsStmt[];
|
|
965
|
+
};
|
|
966
|
+
interface SjsProgram {
|
|
967
|
+
body: SjsStmt[];
|
|
968
|
+
}
|
|
969
|
+
type TT = "num" | "str" | "tpl" | "ident" | "punct" | "kw" | "eof";
|
|
970
|
+
interface Tok {
|
|
971
|
+
t: TT;
|
|
972
|
+
v: string;
|
|
973
|
+
pos: number;
|
|
974
|
+
}
|
|
975
|
+
declare function sjsTokenize(src: string): Tok[];
|
|
976
|
+
declare function parseSjsProgram(src: string): SjsProgram;
|
|
977
|
+
declare function parseSjsExpr(src: string): SjsNode;
|
|
978
|
+
|
|
979
|
+
/**
|
|
980
|
+
* 内置参数编码 SSOT(与后端 BuiltinParamCatalog 对齐)。
|
|
981
|
+
*/
|
|
982
|
+
/** 后端目录预置、租户可开关 */
|
|
983
|
+
declare const BUILTIN_PARAM_CATALOG_CODES: readonly ["pageNumber", "totalPageNumber", "currentDate", "currentDateTime", "tenantName", "userDisplayName", "userLoginName"];
|
|
984
|
+
/** 不进目录表、由运行态按工作簿/渲染上下文求值 */
|
|
985
|
+
declare const RUNTIME_ONLY_SYSTEM_PARAM_CODES: readonly ["sheetIndex", "sheetName", "sheetCount", "templateName", "subSchemaCount"];
|
|
986
|
+
type BuiltinParamCatalogCode = (typeof BUILTIN_PARAM_CATALOG_CODES)[number];
|
|
987
|
+
type RuntimeOnlySystemParamCode = (typeof RUNTIME_ONLY_SYSTEM_PARAM_CODES)[number];
|
|
988
|
+
declare const LEGACY_SYSTEM_PARAM_TEMPLATE_TOKENS: Record<string, string>;
|
|
989
|
+
declare function normalizeSystemParamId(id: string): string;
|
|
990
|
+
declare function isKnownSystemParamId(id: string): boolean;
|
|
991
|
+
declare const RUNTIME_COMPUTED_SYSTEM_PARAM_CODES: readonly ["pageNumber", "totalPageNumber", "currentDate", "currentDateTime", "tenantName", "userDisplayName", "userLoginName", "sheetIndex", "sheetName", "sheetCount", "templateName", "subSchemaCount"];
|
|
992
|
+
declare function isRuntimeComputedSystemParam(id: string): boolean;
|
|
993
|
+
declare function listKnownSystemParamIdsForTemplate(): string[];
|
|
994
|
+
declare function listTemplateSystemParamTokenEntries(): Array<{
|
|
995
|
+
token: string;
|
|
996
|
+
canonical: string;
|
|
997
|
+
}>;
|
|
998
|
+
|
|
999
|
+
/** 字段修约 triggers 预设:UI 单选 ↔ rounding_json.triggers */
|
|
1000
|
+
|
|
1001
|
+
type RoundingWhenPreset = "both" | "commitOnly" | "computeOnly" | "none";
|
|
1002
|
+
type RoundingTriggerFlags = {
|
|
1003
|
+
onCommit: boolean;
|
|
1004
|
+
onCompute: boolean;
|
|
1005
|
+
};
|
|
1006
|
+
/** 解析 triggers;缺省视为录入+计算都修约 */
|
|
1007
|
+
declare function normalizeRoundingTriggers(raw?: Array<"onCommit" | "onCompute"> | null): RoundingTriggerFlags;
|
|
1008
|
+
declare function presetToTriggers(preset: RoundingWhenPreset): Array<"onCommit" | "onCompute">;
|
|
1009
|
+
declare function triggersToPreset(raw?: Array<"onCommit" | "onCompute"> | null): RoundingWhenPreset;
|
|
1010
|
+
declare const ROUNDING_WHEN_LABELS: Record<RoundingWhenPreset, string>;
|
|
1011
|
+
declare function describeRoundingWhenPreset(preset: RoundingWhenPreset): string;
|
|
1012
|
+
/** 录入提交路径:是否应用修约 */
|
|
1013
|
+
declare function getRoundingForCommit(meta: CellRoundingMeta | undefined): CellRoundingMeta | undefined;
|
|
1014
|
+
/** 计算/绑定刷新路径:是否应用修约 */
|
|
1015
|
+
declare function getRoundingForComputeMeta(meta: CellRoundingMeta | undefined): CellRoundingMeta | undefined;
|
|
1016
|
+
|
|
1017
|
+
/**
|
|
1018
|
+
* 从发布态单元格 meta 条目解析修约配置:支持顶层 roundMode/scale 等,或嵌套 rounding 对象。
|
|
1019
|
+
*/
|
|
1020
|
+
declare function getRoundingMetaFromCellMetaEntry(entry: unknown): CellRoundingMeta | undefined;
|
|
1021
|
+
declare function tryParseNumericString(raw: string): number | null;
|
|
1022
|
+
/** 将数字按 CellRoundingMeta 修约并格式化为字符串;raw 不是合法数字时原样返回 */
|
|
1023
|
+
declare function formatNumericByMeta(raw: string, meta: CellRoundingMeta | undefined): string;
|
|
1024
|
+
declare function applyRoundingForInstancePlain(plain: string, cellMeta: Record<string, unknown> | null | undefined, sheetId: string, mr: number, mc: number): string;
|
|
1025
|
+
/** 对数字 n 按 meta 执行修约(不格式化,仅返回 number) */
|
|
1026
|
+
declare function applyRounding(n: number, meta: CellRoundingMeta | undefined): number;
|
|
1027
|
+
/** 支持负 scale:-1 保留到十位,-2 到百位,0 到个位,1 到 1 位小数 */
|
|
1028
|
+
declare function roundFinite(n: number, scale: number, mode: NonNullable<Exclude<CellRoundingMeta["roundMode"], "to_interval" | "significant">>): number;
|
|
1029
|
+
/** 修约到 N 的倍数(默认 half_up,符合工程修约直觉:17 → 18;13 → 15) */
|
|
1030
|
+
declare function roundToInterval(n: number, interval: number, mode?: "half_even" | "half_up"): number;
|
|
1031
|
+
/** 保留 k 位有效数字(正整数 k) */
|
|
1032
|
+
declare function roundToSignificant(n: number, k: number): number;
|
|
1033
|
+
|
|
1034
|
+
/**
|
|
1035
|
+
* 子表有效行数:统计键非空的 globalIndex 个数(any_filled,不要求连续)。
|
|
1036
|
+
*/
|
|
1037
|
+
|
|
1038
|
+
/** 解析 subSchema 的统计键字段 code;标记优先,否则 sortOrder 最小 */
|
|
1039
|
+
declare function resolveSubRowStatKey(registry: TemplateFieldRegistry | null | undefined, subSchemaId: number): string;
|
|
1040
|
+
/** 统计键非空行数 */
|
|
1041
|
+
declare function countActiveSubRows(rows: Array<Record<string, unknown>>, statKey: string): number;
|
|
1042
|
+
/** 返回统计键非空的 rowIndex 列表(供 subRow 脚本迭代) */
|
|
1043
|
+
declare function activeSubRowIndices(rows: Array<Record<string, unknown>>, statKey: string): number[];
|
|
1044
|
+
/** 各 subSchemaId → 有效行数 */
|
|
1045
|
+
declare function buildActiveSubRowCounts(fieldDataSub: Record<number, Array<Record<string, unknown>>>, registry: TemplateFieldRegistry | null | undefined): Record<number, number>;
|
|
1046
|
+
|
|
1047
|
+
/**
|
|
1048
|
+
* 子表 fieldData / acc 槽位:公式与序列化用标量;用户富文本用 `{ value, runs }`。
|
|
1049
|
+
* 供公式/runtime 读取时先规范化。
|
|
1050
|
+
*/
|
|
1051
|
+
declare function normalizeSubFieldSlotForFormula(v: unknown): unknown;
|
|
1052
|
+
/** 从画布 CellData 写入 fieldData.sub / acc:无 runs 时与原先一致(数字会 tryParse)。 */
|
|
1053
|
+
declare function subFieldPersistValueFromCell(cd: CellData$1 | undefined): unknown;
|
|
1054
|
+
declare function isSubFieldRichPersist(v: unknown): v is {
|
|
1055
|
+
value: string;
|
|
1056
|
+
runs: TextRun[];
|
|
1057
|
+
};
|
|
1058
|
+
/** 切页 / 打印 swap:用 acc 槽位还原格(支持富文本)。 */
|
|
1059
|
+
declare function mergeSubFieldCellFromAccValue(prev: CellData$1 | undefined, accVal: unknown): {
|
|
1060
|
+
cell: CellData$1;
|
|
1061
|
+
changed: boolean;
|
|
1062
|
+
};
|
|
1063
|
+
|
|
1064
|
+
/**
|
|
1065
|
+
* 多层修约覆盖合并(UI-06 终端用户修约中心的 core 支撑,P0)。
|
|
1066
|
+
*
|
|
1067
|
+
* 优先级(低→高,就近覆盖优先,见 UI-06 §6):
|
|
1068
|
+
* 模版默认(设计态, 由 fieldRegistry.rounding_json 提供,不在本层)
|
|
1069
|
+
* < 组合策略覆盖(comboProfile) < 我的默认(userDefault) < 该模版覆盖(templateScoped) < 本实例(instance)
|
|
1070
|
+
*
|
|
1071
|
+
* 合并产出一个 `RoundingOverrideMap`(键 = targetToOverrideKey:main.xxx / base.xxx / sub:1.xxx),
|
|
1072
|
+
* 再交给 `resolveRoundingForTarget(registry, target, mergedOverrides)` 与模版默认叠加得到最终生效修约。
|
|
1073
|
+
*
|
|
1074
|
+
* 锁定字段(模版标「禁止用户改」):忽略所有用户层覆盖,仅保留设计态(comboProfile)。
|
|
1075
|
+
*/
|
|
1076
|
+
|
|
1077
|
+
type RoundingOverrideMap = Record<string, RoundingOverrideEntry>;
|
|
1078
|
+
/** 覆盖层作用域(按优先级低→高)。comboProfile 属设计态;其余为用户层。 */
|
|
1079
|
+
type RoundingLayerScope = "comboProfile" | "userDefault" | "templateScoped" | "instance";
|
|
1080
|
+
declare const ROUNDING_LAYER_ORDER: readonly RoundingLayerScope[];
|
|
1081
|
+
interface RoundingLayer {
|
|
1082
|
+
scope: RoundingLayerScope;
|
|
1083
|
+
/** 键 = targetToOverrideKey(main.xxx / base.xxx / sub:{id}.xxx) */
|
|
1084
|
+
overrides: RoundingOverrideMap;
|
|
1085
|
+
}
|
|
1086
|
+
/**
|
|
1087
|
+
* 按优先级低→高合并多层覆盖为单一 map。
|
|
1088
|
+
* @param layers 任意顺序均可;内部按 ROUNDING_LAYER_ORDER 归一排序后合并。
|
|
1089
|
+
* @param lockedKeys 锁定字段(overrideKey),用户层对其覆盖被忽略。
|
|
1090
|
+
*/
|
|
1091
|
+
declare function mergeRoundingOverrideLayers(layers: readonly RoundingLayer[], lockedKeys?: ReadonlySet<string>): RoundingOverrideMap;
|
|
1092
|
+
/** 便捷:从「作用域→覆盖 map」记录构建 layers(缺省作用域跳过)。 */
|
|
1093
|
+
declare function buildRoundingLayers(byScope: Partial<Record<RoundingLayerScope, RoundingOverrideMap | null | undefined>>): RoundingLayer[];
|
|
1094
|
+
|
|
1095
|
+
/**
|
|
1096
|
+
* 拼接诊断聚合(UI-04 §5「拼接冲突/错位诊断面板」的 core 规则,P1)。
|
|
1097
|
+
*
|
|
1098
|
+
* 「发布前质量门」大脑:把编辑器算出的各类信号(对齐错位 / 可打印宽超出 / 槽位未绑定)
|
|
1099
|
+
* 聚合为统一诊断列表 + 定级,并给出 canPublish(有 error 即禁止发布)。
|
|
1100
|
+
*
|
|
1101
|
+
* 纯函数:入参为原语信号(由 host 用 compose/* 算法算出),不直依赖 Sheet/DOM,便于 core 单测与消费系统复用。
|
|
1102
|
+
*/
|
|
1103
|
+
type SpliceDiagnosticLevel = "error" | "warning";
|
|
1104
|
+
/** 可执行修复动作(UI 侧「一键吸附/去绑定/调整」)。 */
|
|
1105
|
+
type SpliceDiagnosticFix = "snap" | "unbind" | "adjust";
|
|
1106
|
+
interface SpliceDiagnostic {
|
|
1107
|
+
level: SpliceDiagnosticLevel;
|
|
1108
|
+
/** 稳定 code,便于 UI 定位与 i18n */
|
|
1109
|
+
code: string;
|
|
1110
|
+
/** 人读位置,如「中区 C 列」「表尾」「中区 R8」 */
|
|
1111
|
+
location: string;
|
|
1112
|
+
message: string;
|
|
1113
|
+
fix?: SpliceDiagnosticFix;
|
|
1114
|
+
/** 关联槽位(未绑定类) */
|
|
1115
|
+
slotKey?: string;
|
|
1116
|
+
}
|
|
1117
|
+
interface SpliceMisalignSignal {
|
|
1118
|
+
location: string;
|
|
1119
|
+
/** 列宽超出母版像素(>0 视为 error;未知可省略仅标错位 warning) */
|
|
1120
|
+
colOverflowPx?: number;
|
|
1121
|
+
/** 行高不足等(true → warning) */
|
|
1122
|
+
rowUnderfilled?: boolean;
|
|
1123
|
+
}
|
|
1124
|
+
interface SpliceUnboundSlotSignal {
|
|
1125
|
+
slotKey: string;
|
|
1126
|
+
location: string;
|
|
1127
|
+
}
|
|
1128
|
+
interface SpliceDiagnosticsSignals {
|
|
1129
|
+
/** 中区各段对齐错位信号 */
|
|
1130
|
+
misaligned?: SpliceMisalignSignal[];
|
|
1131
|
+
/** 合成后可打印宽超出(px);>0 → error(发布拦截) */
|
|
1132
|
+
printableOverflowPx?: number;
|
|
1133
|
+
/** @槽位存在但未绑定字段 → warning */
|
|
1134
|
+
unboundSlots?: SpliceUnboundSlotSignal[];
|
|
1135
|
+
/** 额外自定义诊断(宿主注入) */
|
|
1136
|
+
extra?: SpliceDiagnostic[];
|
|
1137
|
+
}
|
|
1138
|
+
interface SpliceDiagnosticsReport {
|
|
1139
|
+
diagnostics: SpliceDiagnostic[];
|
|
1140
|
+
errorCount: number;
|
|
1141
|
+
warningCount: number;
|
|
1142
|
+
/** 无 error 才允许发布 */
|
|
1143
|
+
canPublish: boolean;
|
|
1144
|
+
}
|
|
1145
|
+
declare function buildSpliceDiagnostics(signals: SpliceDiagnosticsSignals): SpliceDiagnosticsReport;
|
|
1146
|
+
|
|
1147
|
+
/**
|
|
1148
|
+
* 签名/签章工作流聚合(UI-05,SignaturePort 的 core 支撑)。
|
|
1149
|
+
*
|
|
1150
|
+
* 给定设计态签名位 SignatureSpec[] 与已采集 SignatureResult[],聚合每位状态 + 完成门
|
|
1151
|
+
* (所有 required 已签才 canComplete)。纯函数,采集/证书/时间戳由宿主 SignaturePort 实现。
|
|
1152
|
+
*/
|
|
1153
|
+
|
|
1154
|
+
type SignatureSlotStatus = "signed" | "pending" | "missingRequired";
|
|
1155
|
+
interface SignatureSlotState {
|
|
1156
|
+
slotId: string;
|
|
1157
|
+
name: string;
|
|
1158
|
+
kind: SignatureKind;
|
|
1159
|
+
role?: string;
|
|
1160
|
+
required: boolean;
|
|
1161
|
+
status: SignatureSlotStatus;
|
|
1162
|
+
result?: SignatureResult;
|
|
1163
|
+
}
|
|
1164
|
+
interface SignatureWorkflowReport {
|
|
1165
|
+
slots: SignatureSlotState[];
|
|
1166
|
+
signedCount: number;
|
|
1167
|
+
requiredCount: number;
|
|
1168
|
+
missingRequiredCount: number;
|
|
1169
|
+
/** 所有 required 均已签 → 可完成/发布 */
|
|
1170
|
+
canComplete: boolean;
|
|
1171
|
+
}
|
|
1172
|
+
declare function buildSignatureWorkflow(specs: readonly SignatureSpec[], results: readonly SignatureResult[]): SignatureWorkflowReport;
|
|
1173
|
+
/** 下一个待签(required 优先);无则 null。供「去签名」引导。 */
|
|
1174
|
+
declare function nextPendingSignature(report: SignatureWorkflowReport): SignatureSlotState | null;
|
|
1175
|
+
|
|
1176
|
+
/**
|
|
1177
|
+
* 签名工作流 ↔ embed 资产模型桥接(UI-05)。
|
|
1178
|
+
*
|
|
1179
|
+
* 设计态签名位 = `assetKind: "signature" | "stamp"` 的 AssetEmbedDef;
|
|
1180
|
+
* 运行态结果 = `EmbedInstanceState`(fileId + signedBy + signedAt)。
|
|
1181
|
+
* 本桥把两者映射为 SignatureSpec / SignatureResult,供 buildSignatureWorkflow 与签署工作台使用。纯函数。
|
|
1182
|
+
*/
|
|
1183
|
+
|
|
1184
|
+
/** 从 workbook.embeds 提取签名位 → SignatureSpec[](signature→手写、stamp→图片印章)。 */
|
|
1185
|
+
declare function signatureSpecsFromEmbeds(embeds: readonly WorkbookEmbedDef[] | null | undefined): SignatureSpec[];
|
|
1186
|
+
/** 从实例 embedStates 还原已落章的 SignatureResult[](有 fileId 视为已签)。 */
|
|
1187
|
+
declare function signatureResultsFromEmbedStates(embedStates: Record<string, EmbedInstanceState> | null | undefined): SignatureResult[];
|
|
1188
|
+
/** 把签署/作废后的结果并回 embedStates(供持久化到实例 data)。 */
|
|
1189
|
+
declare function applySignatureResultsToEmbedStates(prev: Record<string, EmbedInstanceState> | null | undefined, results: readonly SignatureResult[], removedSlotIds?: readonly string[]): Record<string, EmbedInstanceState>;
|
|
1190
|
+
|
|
1191
|
+
/**
|
|
1192
|
+
* 内置参数(systemParam)运行态——纯函数子集(无 store / window 依赖)。
|
|
1193
|
+
*
|
|
1194
|
+
* host 相关的 buildSystemParams* / readClientBrandingParams / applyCatalogSessionParams
|
|
1195
|
+
* 因依赖 ShellBranding store、workbookPrintPlan、businessSheetProfile 仍留在 kt-web。
|
|
1196
|
+
*/
|
|
1197
|
+
type SystemParamMap = Record<string, unknown>;
|
|
1198
|
+
type SystemParamBranding = {
|
|
1199
|
+
tenantName?: string;
|
|
1200
|
+
userDisplayName?: string;
|
|
1201
|
+
userLoginName?: string;
|
|
1202
|
+
};
|
|
1203
|
+
/** 按 sheet 渲染内置参数时:剔除运行态求值项,避免 activeSheet 注入的页码污染其它 Tab */
|
|
1204
|
+
declare function stripRuntimeComputedUserParams(params: Record<string, unknown> | null | undefined): Record<string, unknown>;
|
|
1205
|
+
/** displayText / remark 中是否含已知内置参数 token(含废弃别名 pageCurrent 等) */
|
|
1206
|
+
declare function templateContainsSystemParamTokens(template: string): boolean;
|
|
1207
|
+
/**
|
|
1208
|
+
* field 公式 p.xxx 成员访问:在规范 params 上镜像废弃别名键,便于 `p.pageCurrent` 等旧写法。
|
|
1209
|
+
*/
|
|
1210
|
+
declare function enrichParamsForFieldRuntime(params: Record<string, unknown> | null | undefined): Record<string, unknown>;
|
|
1211
|
+
declare function expandSystemParamTemplate(template: string, params: Record<string, unknown> | null | undefined): string;
|
|
1212
|
+
/**
|
|
1213
|
+
* 把系统参数与现有实例参数合并:
|
|
1214
|
+
* - 系统参数为兜底,被用户/实例数据中的同名非空值覆盖(systemParam 格也可能手填校稿)。
|
|
1215
|
+
* - 运行态专有项(pageNumber/totalPageNumber 等)不接受非数值占位覆盖。
|
|
1216
|
+
* - 实例 params 键名归一为规范编码(兼容历史别名如 pageCurrent)。
|
|
1217
|
+
*/
|
|
1218
|
+
declare function mergeSystemAndUserParams(system: SystemParamMap, existingParams: Record<string, unknown> | null | undefined): SystemParamMap;
|
|
1219
|
+
|
|
1220
|
+
type CompileResult = {
|
|
1221
|
+
ok: true;
|
|
1222
|
+
target: FormulaCatalogTarget;
|
|
1223
|
+
source: string;
|
|
1224
|
+
assignment: string;
|
|
1225
|
+
} | {
|
|
1226
|
+
ok: false;
|
|
1227
|
+
error: string;
|
|
1228
|
+
};
|
|
1229
|
+
/** 用户赋值式 → 编译为 field formula `:= rhs` */
|
|
1230
|
+
declare function compileFormulaAssignment(input: string): CompileResult;
|
|
1231
|
+
/** 从编译 source 提取依赖字段 id(简化:m.xxx / sN.xxx / b.xxx) */
|
|
1232
|
+
declare function extractFormulaDeps(source: string): string[];
|
|
1233
|
+
declare function catalogEntryNodeId(entry: {
|
|
1234
|
+
id: string;
|
|
1235
|
+
target?: FormulaCatalogTarget;
|
|
1236
|
+
}): string;
|
|
1237
|
+
|
|
1238
|
+
/** 网格公式求值器:AST → FormulaValue */
|
|
1239
|
+
|
|
1240
|
+
declare function evaluate(ast: AstNode, ctx: EvalContext): FormulaAny;
|
|
1241
|
+
|
|
1242
|
+
/**
|
|
1243
|
+
* 公式何时执行:UI runWhen ↔ formulaJson / catalog
|
|
1244
|
+
*/
|
|
1245
|
+
|
|
1246
|
+
type FormulaRunWhen = "auto" | "manualOnly";
|
|
1247
|
+
type ComputePass = "incremental" | "full";
|
|
1248
|
+
declare const FORMULA_RUN_WHEN_LABELS: Record<FormulaRunWhen, string>;
|
|
1249
|
+
type RunWhenSource = {
|
|
1250
|
+
runWhen?: FormulaRunWhen;
|
|
1251
|
+
triggers?: Array<"onCommit" | "onCompute">;
|
|
1252
|
+
};
|
|
1253
|
+
/** 从 runWhen 或旧 triggers 推导执行模式;默认 auto */
|
|
1254
|
+
declare function normalizeFormulaRunWhen(src?: RunWhenSource | null): FormulaRunWhen;
|
|
1255
|
+
declare function runWhenToStorage(runWhen: FormulaRunWhen): {
|
|
1256
|
+
runWhen: FormulaRunWhen;
|
|
1257
|
+
triggers: Array<"onCompute">;
|
|
1258
|
+
};
|
|
1259
|
+
declare function shouldRunFieldFormula(meta: CellFormulaBindingMeta | null | undefined, pass: ComputePass): boolean;
|
|
1260
|
+
declare function shouldRunScriptBlock(meta: CellFormulaBindingMeta | null | undefined, pass: ComputePass): boolean;
|
|
1261
|
+
declare function catalogEntryRunWhen(entry: Pick<FormulaCatalogEntry, "runWhen" | "triggers">): FormulaRunWhen;
|
|
1262
|
+
|
|
1263
|
+
/**
|
|
1264
|
+
* field 公式 inputWhen 门禁:输入满足条件时才计算
|
|
1265
|
+
*/
|
|
1266
|
+
|
|
1267
|
+
type FieldInputWhen = "always" | "anyPresent" | "allPresent";
|
|
1268
|
+
type FormulaInputTarget = {
|
|
1269
|
+
kind: "main";
|
|
1270
|
+
key: string;
|
|
1271
|
+
} | {
|
|
1272
|
+
kind: "base";
|
|
1273
|
+
key: string;
|
|
1274
|
+
} | {
|
|
1275
|
+
kind: "subRow";
|
|
1276
|
+
subSchemaId: number;
|
|
1277
|
+
col: string;
|
|
1278
|
+
};
|
|
1279
|
+
type InputDep = {
|
|
1280
|
+
kind: "main";
|
|
1281
|
+
key: string;
|
|
1282
|
+
} | {
|
|
1283
|
+
kind: "base";
|
|
1284
|
+
key: string;
|
|
1285
|
+
} | {
|
|
1286
|
+
kind: "row";
|
|
1287
|
+
key: string;
|
|
1288
|
+
} | {
|
|
1289
|
+
kind: "subCol";
|
|
1290
|
+
subSchemaId: number;
|
|
1291
|
+
key: string;
|
|
1292
|
+
};
|
|
1293
|
+
/** 从公式体自动提取 row.xxx 字段名 */
|
|
1294
|
+
declare function extractRowInputFields(source: string): string[];
|
|
1295
|
+
/** 合并 m/b/sN + row.* 依赖,排除公式目标自身 */
|
|
1296
|
+
declare function resolveInputDeps(source: string, target?: FormulaInputTarget | null): InputDep[];
|
|
1297
|
+
declare function isSubColumnPresent(data: FieldDataCtx, subSchemaId: number, colKey: string): boolean;
|
|
1298
|
+
/**
|
|
1299
|
+
* 判断是否应执行 field 公式。
|
|
1300
|
+
* 不满足 inputWhen 时返回 false(调用方应写 null,不记错误)。
|
|
1301
|
+
*/
|
|
1302
|
+
declare function shouldComputeFieldByInput(meta: CellFormulaBindingMeta, source: string, data: FieldDataCtx, scope: {
|
|
1303
|
+
kind: "main";
|
|
1304
|
+
} | {
|
|
1305
|
+
kind: "sub";
|
|
1306
|
+
subSchemaId: number;
|
|
1307
|
+
rowIndex: number;
|
|
1308
|
+
}, target?: FormulaInputTarget | null): boolean;
|
|
1309
|
+
|
|
1310
|
+
/**
|
|
1311
|
+
* 模板包内嵌字段注册表——纯逻辑(规范化 / 深拷贝 / 索引 / meta 读写 / 校验 / 信封解析)。
|
|
1312
|
+
*
|
|
1313
|
+
* host 相关(upsert/remove/replace 依赖 agent subSchemaId 归一、knownFieldKeysStore 同步)
|
|
1314
|
+
* 仍留在 kt-web templateFieldRegistry.ts。
|
|
1315
|
+
*/
|
|
1316
|
+
|
|
1317
|
+
type FieldRegistryIndex = {
|
|
1318
|
+
baseByKey: Map<string, TemplateFieldDef>;
|
|
1319
|
+
mainByKey: Map<string, TemplateFieldDef>;
|
|
1320
|
+
subBySchema: Map<number, Map<string, TemplateSubFieldDef>>;
|
|
1321
|
+
};
|
|
1322
|
+
type UpsertFieldDefInput = {
|
|
1323
|
+
bindingKey: string;
|
|
1324
|
+
displayName?: string;
|
|
1325
|
+
dataType?: string;
|
|
1326
|
+
roundingJson?: string | null;
|
|
1327
|
+
formulaJson?: string | null;
|
|
1328
|
+
dictCode?: string | null;
|
|
1329
|
+
requiredDefault?: boolean;
|
|
1330
|
+
defaultValue?: string | null;
|
|
1331
|
+
runtimeEditable?: boolean;
|
|
1332
|
+
writebackTarget?: string | null;
|
|
1333
|
+
description?: string | null;
|
|
1334
|
+
sortOrder?: number;
|
|
1335
|
+
enabled?: boolean;
|
|
1336
|
+
};
|
|
1337
|
+
declare function isFieldRegistryRecord(x: unknown): x is Record<string, unknown>;
|
|
1338
|
+
declare function normalizeFieldKey(k: string | null | undefined): string;
|
|
1339
|
+
declare function normalizeFieldDef(raw: unknown): TemplateFieldDef | null;
|
|
1340
|
+
declare function normalizeSubFieldDef(raw: unknown): TemplateSubFieldDef | null;
|
|
1341
|
+
/** 空注册表 */
|
|
1342
|
+
declare function emptyFieldRegistry(): TemplateFieldRegistry;
|
|
1343
|
+
/** 解析/规范化 meta 或 capabilities 中的 fieldRegistry */
|
|
1344
|
+
declare function normalizeFieldRegistry(raw: unknown): TemplateFieldRegistry;
|
|
1345
|
+
/** 深拷贝 */
|
|
1346
|
+
declare function cloneFieldRegistry(reg: TemplateFieldRegistry): TemplateFieldRegistry;
|
|
1347
|
+
/** 从 workbook.meta 取 registry,缺省返回空 */
|
|
1348
|
+
declare function getFieldRegistryFromMeta(meta: {
|
|
1349
|
+
fieldRegistry?: unknown;
|
|
1350
|
+
} | null | undefined): TemplateFieldRegistry;
|
|
1351
|
+
/** 写入 meta(返回新 meta 对象) */
|
|
1352
|
+
declare function setFieldRegistryOnMeta(meta: Record<string, unknown> | undefined, reg: TemplateFieldRegistry): Record<string, unknown>;
|
|
1353
|
+
/** 建索引(仅 enabled 字段) */
|
|
1354
|
+
declare function indexFieldRegistry(reg: TemplateFieldRegistry | null | undefined): FieldRegistryIndex;
|
|
1355
|
+
type FieldDefRegisterMode = "upsert" | "bindingOnly" | "reject";
|
|
1356
|
+
/** 业务模板 b.* 仅写 binding;基础模板 main/sub 拒绝 */
|
|
1357
|
+
declare function resolveFieldDefRegisterMode(isBaseDraft: boolean, kind: BaseTemplateCellBinding["kind"]): FieldDefRegisterMode;
|
|
1358
|
+
declare function fieldPartitionKey(kind: BaseTemplateCellBinding["kind"]): "base" | "main" | "sub" | null;
|
|
1359
|
+
/** 合并 base 段(继承初始化:以母版为准整段替换) */
|
|
1360
|
+
declare function mergeBaseFieldPartition(reg: TemplateFieldRegistry, baseFromSource: TemplateFieldDef[]): TemplateFieldRegistry;
|
|
1361
|
+
/** 合并 base(来自基础快照)+ main/sub(来自业务草案)供 bake */
|
|
1362
|
+
declare function mergeBakedFieldRegistry(baseFromSnapshot: TemplateFieldDef[], draftReg: TemplateFieldRegistry, usedBaseKeys: Set<string>, usedMainKeys: Set<string>, usedSubKeys: Map<number, Set<string>>): TemplateFieldRegistry;
|
|
1363
|
+
/** 从 capabilities JSON 解析 fieldRegistry */
|
|
1364
|
+
declare function parseFieldRegistryFromCapabilities(capabilities: string | Record<string, unknown> | null | undefined): TemplateFieldRegistry | null;
|
|
1365
|
+
/** 从 workbook 信封 JSON 读取 meta.fieldRegistry.base(继承初始化 fallback) */
|
|
1366
|
+
declare function extractBaseFieldDefsFromWorkbookEnvelope(workbookJson: string): TemplateFieldDef[];
|
|
1367
|
+
/** 将 base 段写入 workbook 信封 JSON 的 meta.fieldRegistry */
|
|
1368
|
+
declare function injectBaseFieldRegistryIntoWorkbookEnvelope(workbookJson: string, baseDefs: TemplateFieldDef[]): string;
|
|
1369
|
+
/** 从基础快照 capabilities 或 workbook 解析 base 段(capabilities 优先) */
|
|
1370
|
+
declare function resolveBaseFieldDefsFromBaseSource(input: {
|
|
1371
|
+
capabilities?: string | null;
|
|
1372
|
+
workbookJson: string;
|
|
1373
|
+
}): TemplateFieldDef[];
|
|
1374
|
+
|
|
1375
|
+
/**
|
|
1376
|
+
* 设计态字段行 `#类型[:小数位[:修约简码]]` 简写解析(方案 B)。
|
|
1377
|
+
* 格内绑定仅存前缀+键名;类型与修约写入字段注册表。
|
|
1378
|
+
*/
|
|
1379
|
+
|
|
1380
|
+
type DesignFieldMetaFromShorthand = {
|
|
1381
|
+
dataType: string;
|
|
1382
|
+
roundingJson?: string;
|
|
1383
|
+
/** image 字段存储方式 */
|
|
1384
|
+
imageStorage?: "base64" | "fileId" | "url";
|
|
1385
|
+
};
|
|
1386
|
+
/** 修约简码 → roundMode(与 cellMeta / FieldRoundingForm 一致) */
|
|
1387
|
+
declare const ROUND_MODE_LETTER_MAP: Record<string, CellRoundingMeta['roundMode']>;
|
|
1388
|
+
/** 将第一个 `#` 拆为绑定段与类型简写段 */
|
|
1389
|
+
declare function splitBindingAndTypeSuffix(raw: string): {
|
|
1390
|
+
bindingPart: string;
|
|
1391
|
+
typeSpec?: string;
|
|
1392
|
+
};
|
|
1393
|
+
/**
|
|
1394
|
+
* 解析 `#` 后的类型简写段。
|
|
1395
|
+
* 格式:`{类型}[:{小数位}[:{修约简码}]]`
|
|
1396
|
+
*/
|
|
1397
|
+
declare function parseFieldTypeSpec(spec: string): DesignFieldMetaFromShorthand | null;
|
|
1398
|
+
/** 由字段 meta 反显简写段(不含 `#` 与前缀) */
|
|
1399
|
+
declare function formatFieldTypeShorthand(meta: DesignFieldMetaFromShorthand): string;
|
|
1400
|
+
/** Agent / 技能注入用:字段行类型修约简写说明 */
|
|
1401
|
+
declare const DESIGN_FIELD_SHORTHAND_SKILLS = "### \u5B57\u6BB5\u884C\u7C7B\u578B/\u4FEE\u7EA6\u7B80\u5199\uFF08registerSelectionToFields \u81EA\u52A8\u843D\u5E93\uFF09\n\u683C\u5F0F\uFF1A`{\u524D\u7F00}{\u5B57\u6BB5\u952E}#{\u7C7B\u578B}[:{\u5C0F\u6570\u4F4D}[:{\u4FEE\u7EA6\u7B80\u7801}]]`\n- \u524D\u7F00\uFF1A`b.` / `m.` / `sN.` / `d.` / `p.`\uFF08\u6CE8\u518C\u987B\u663E\u5F0F\u524D\u7F00\uFF09\n- \u7C7B\u578B\uFF1A`n` number\u3001`i` integer\u3001`s` string\u3001`d` date\u3001`dt` datetime\u3001`b` boolean\n- \u6570\u503C\uFF1A`#n` \u6216 `#n:1` \u9ED8\u8BA4 scale=1\u3001\u4FEE\u7EA6 half_even\uFF08\u6B63\u5E38\u4FDD\u7559\uFF09\uFF1B\u7B2C\u4E09\u6BB5\u4FEE\u7EA6\u7B80\u7801\u53EF\u9009\n- \u4FEE\u7EA6\u7B80\u7801\uFF1A\u7701\u7565\u6216 `a`/`e`=half_even\uFF08\u6B63\u5E38\u4FDD\u7559\uFF09\u3001`u`=\u56DB\u820D\u4E94\u5165\u3001`t`=\u622A\u65AD\u3001`c`=\u5411\u4E0A\u3001`f`=\u5411\u4E0B\n- \u793A\u4F8B\uFF1A`s1.lq#n:1`\u3001`m.wt#n:2:u`\u3001`m.remark#s`\u3001`m.test_date#d`\u3001`s1.cnt#i`\n- \u6CE8\u518C\u540E\u683C\u5185 value \u89C4\u8303\u4E3A `s1.lq`\uFF08\u65E0 # \u6BB5\uFF09\uFF1B\u7C7B\u578B/\u4FEE\u7EA6\u4EC5\u5B58\u5B57\u6BB5\u8868\n- \u65E0 `#` \u65F6\u4ECD\u9ED8\u8BA4 string\uFF08\u5411\u540E\u517C\u5BB9\uFF09\uFF1B\u5DF2\u5B58\u5728\u5B57\u6BB5\u4EC5\u5728\u5E26 `#` \u7B80\u5199\u65F6\u66F4\u65B0 dataType/\u4FEE\u7EA6";
|
|
1402
|
+
/** 子表 @槽位绑定(替代 subTableRegions) */
|
|
1403
|
+
declare const SUBTABLE_SLOT_BINDING_SKILLS = "### \u5B50\u8868 @\u69FD\u4F4D\u7ED1\u5B9A\uFF08\u5FC5\u5B88\uFF0C\u5DF2\u66FF\u4EE3 subTableRegions\uFF09\n- \u8BED\u6CD5\uFF1A`s{N}.{fieldKey}[#{typeSpec}]@{slot}` \u2014 **@ \u5FC5\u987B\u5728\u6700\u540E**\uFF0C\u4F8B `s1.sq#n:2@1`\n- **subField \u5FC5\u987B\u5E26 @slot**\uFF1B\u540C\u7EC4\u591A\u683C\uFF08sjcc1@1 / sjcc2@1\uFF09\u5171\u4EAB `subTables[\"N\"].rows[globalIndex]`\n- globalIndex = logicalPageIndex \u00D7 slotsPerPage + (slot - 1)\uFF1B\u6301\u4E45\u5316 `subTables[\"1\"].rows[7]` \u800C\u975E\u5750\u6807\u586B\u683C\n- \u6BCF sheet\u00D7subSchema \u914D\u7F6E `meta.subTableSlotConfig` \u6BCF\u9875\u7EC4\u6570\uFF1B\u7F3A\u7701 = \u8BE5 sheet \u6700\u5927 @ \u69FD\u4F4D\n- \u7981\u6B62\u521B\u5EFA subTableRegions\uFF1BlistValidationErrors \u7F3A @ \u4E3A error\n- Agent \u586B\u6570\uFF1AfillInstanceFields \u2192 `subTables[\"1\"].rows[i].fieldKey`\uFF0C\u52FF\u7528 fillInstanceBatch \u586B\u5DF2\u7ED1\u5B9A\u5B50\u8868\u5B57\u6BB5";
|
|
1404
|
+
|
|
1405
|
+
/**
|
|
1406
|
+
* 工作簿打印计划纯类型(RenderContext 等),驱动 systemParam 页码/表序求值。
|
|
1407
|
+
* 逻辑(buildWorkbookPrintPlan / buildRenderContext* 依赖 businessSheetProfile、instancePageTabs)留 kt-web。
|
|
1408
|
+
*/
|
|
1409
|
+
interface PrintPageSlot {
|
|
1410
|
+
sheetId: string;
|
|
1411
|
+
/** 该 sheet 内第几逻辑页(0-based) */
|
|
1412
|
+
sheetLogicalPageIndex: number;
|
|
1413
|
+
/** 工作簿全局第几页(0-based) */
|
|
1414
|
+
globalPageIndex: number;
|
|
1415
|
+
}
|
|
1416
|
+
interface WorkbookPrintPlan {
|
|
1417
|
+
slots: PrintPageSlot[];
|
|
1418
|
+
globalPageCount: number;
|
|
1419
|
+
}
|
|
1420
|
+
/** 单次渲染/预览/打印页的上下文,驱动系统参数求值 */
|
|
1421
|
+
interface RenderContext {
|
|
1422
|
+
sheetId: string;
|
|
1423
|
+
sheetLogicalPageIndex: number;
|
|
1424
|
+
globalPageIndex: number;
|
|
1425
|
+
globalPageCount: number;
|
|
1426
|
+
/** sheets[] 中位置(1-based) */
|
|
1427
|
+
sheetIndex: number;
|
|
1428
|
+
/** profile.displayName ?? sheet.name */
|
|
1429
|
+
sheetName: string;
|
|
1430
|
+
/** false:隐藏页,pageNumber/totalPageNumber 留空(缺省 true) */
|
|
1431
|
+
includeInPageNumber?: boolean;
|
|
1432
|
+
}
|
|
1433
|
+
|
|
1434
|
+
interface LayoutLinesResult {
|
|
1435
|
+
lines: string[];
|
|
1436
|
+
fontSizePt: number;
|
|
1437
|
+
}
|
|
1438
|
+
/** shrinkToFit 字号下限(pt)。1pt 几乎能缩尽,避免触底后折行把行撑开。 */
|
|
1439
|
+
declare const MIN_SHRINK_FONT_PT = 1;
|
|
1440
|
+
/**
|
|
1441
|
+
* 换行 / shrink 测量用字重斜体。须与渲染侧一致,否则加粗会低估宽度。
|
|
1442
|
+
* 字重用 CSS `bold`(与 sheet-report `fontWeight: "bold"` 对齐)。
|
|
1443
|
+
*/
|
|
1444
|
+
type LayoutFontStyleOpts = {
|
|
1445
|
+
bold?: boolean;
|
|
1446
|
+
italic?: boolean;
|
|
1447
|
+
};
|
|
1448
|
+
/** 拼 canvas/CSS 可用的 font 串:`[style] [weight] [size]px [family]`。 */
|
|
1449
|
+
declare function layoutFontCss(fontPx: number, fontFamily: string, style?: LayoutFontStyleOpts): string;
|
|
1450
|
+
/**
|
|
1451
|
+
* 文本测量抽象(去 UI 化 M1.1)。
|
|
1452
|
+
* core 不得直依赖 `CanvasRenderingContext2D`;换行/shrink 算法只依赖本接口。
|
|
1453
|
+
* 与 `@k-table/sheet-host` 的 `TextMeasurePort` 对齐;由宿主注入具体实现(如 canvas adapter)。
|
|
1454
|
+
*/
|
|
1455
|
+
interface TextMeasurer {
|
|
1456
|
+
/** 测量给定 css font(如 "normal bold 10.5px sans-serif")下文本宽度(px)。 */
|
|
1457
|
+
measure(text: string, font: string): number;
|
|
1458
|
+
}
|
|
1459
|
+
/** 软换行(measurer 版,纯逻辑,无 DOM 依赖)。 */
|
|
1460
|
+
declare function wrapTextToWidthM(measurer: TextMeasurer, font: string, text: string, maxWidth: number): string[];
|
|
1461
|
+
/** shrinkToFit(measurer 版):先按 wrapText 折行,仍超格再缩字;仅 shrink 只压宽不自动折。 */
|
|
1462
|
+
declare function layoutLinesForCellM(measurer: TextMeasurer, text: string, cellInnerWidth: number, cellInnerHeight: number, baseFontSizePt: number, wrapText: boolean, shrinkToFit: boolean, fontFamily?: string, fontStyle?: LayoutFontStyleOpts): LayoutLinesResult;
|
|
1463
|
+
|
|
1464
|
+
/** CSS px/inch,与画布及 Excel 导出换算一致 */
|
|
1465
|
+
declare const CSS_PX_PER_INCH = 96;
|
|
1466
|
+
declare const MM_PER_INCH = 25.4;
|
|
1467
|
+
declare function mmToCssPx(mm: number): number;
|
|
1468
|
+
/** 与打印假定的逻辑 CSS 像素下物理长度(用于状态栏等) */
|
|
1469
|
+
declare function cssPxToCm(px: number): number;
|
|
1470
|
+
/**
|
|
1471
|
+
* 在 96 CSS px/英寸 假定下,1 cm 对应多少 CSS px(`cssPxToCm` 的标度:约 37.8 px/cm)。
|
|
1472
|
+
*/
|
|
1473
|
+
declare function cssOneCmToCssPx(): number;
|
|
1474
|
+
/** 页边距 cm → mm(与存库/打印数学一致) */
|
|
1475
|
+
declare function marginsCmToMm(m: PageMarginsCm): {
|
|
1476
|
+
top: number;
|
|
1477
|
+
right: number;
|
|
1478
|
+
bottom: number;
|
|
1479
|
+
left: number;
|
|
1480
|
+
};
|
|
1481
|
+
/** 纸张外廓(mm),不含方向 */
|
|
1482
|
+
declare function paperSizeMmRaw(paper: SheetPaperKind): {
|
|
1483
|
+
widthMm: number;
|
|
1484
|
+
heightMm: number;
|
|
1485
|
+
};
|
|
1486
|
+
/** 应用横纵向后的纸张宽高(mm) */
|
|
1487
|
+
declare function paperSizeMm(paper: SheetPaperKind, orientation: SheetOrientation): {
|
|
1488
|
+
widthMm: number;
|
|
1489
|
+
heightMm: number;
|
|
1490
|
+
};
|
|
1491
|
+
/**
|
|
1492
|
+
* 按整份 PageSettings 求纸张宽高(mm)。
|
|
1493
|
+
* `paper === "Custom"` 时取 `widthMm/heightMm` 原值(orientation 不参与换算;缺失回落 A4)。
|
|
1494
|
+
*/
|
|
1495
|
+
declare function paperSizeMmFromPage(page: PageSettings$1): {
|
|
1496
|
+
widthMm: number;
|
|
1497
|
+
heightMm: number;
|
|
1498
|
+
};
|
|
1499
|
+
/**
|
|
1500
|
+
* 输出物理纸张宽高(mm):`outputRotation` 90/270 时交换设计宽高。
|
|
1501
|
+
* 版式/可印区域仍按设计坐标系(`paperSizeMmFromPage`)计算,仅输出(@page、PDF 页)用物理尺寸。
|
|
1502
|
+
*/
|
|
1503
|
+
declare function physicalPaperSizeMmFromPage(page: PageSettings$1): {
|
|
1504
|
+
widthMm: number;
|
|
1505
|
+
heightMm: number;
|
|
1506
|
+
};
|
|
1507
|
+
/** 可印区域 = 纸张 − 边距(边距为 cm,内部换算为 mm) */
|
|
1508
|
+
declare function printableSizeMm(page: PageSettings$1): {
|
|
1509
|
+
widthMm: number;
|
|
1510
|
+
heightMm: number;
|
|
1511
|
+
};
|
|
1512
|
+
declare function printableSizeCssPx(page: PageSettings$1): {
|
|
1513
|
+
widthPx: number;
|
|
1514
|
+
heightPx: number;
|
|
1515
|
+
};
|
|
1516
|
+
/** `@page` 用:具名纸张 + 四边距(cm 存库,写 CSS 为 mm) */
|
|
1517
|
+
declare function pageAtRuleCss(page: PageSettings$1): string;
|
|
1518
|
+
/** jsPDF format 名(与纸张对应) */
|
|
1519
|
+
declare function jsPdfFormat(page: PageSettings$1): "a4" | "a3" | "letter";
|
|
1520
|
+
declare function jsPdfOrientation(page: PageSettings$1): "p" | "l";
|
|
1521
|
+
/** 内容区切片(逻辑像素,与导出画布同一坐标系) */
|
|
1522
|
+
declare function sliceRectangles(contentWidth: number, contentHeight: number, sliceWidth: number, sliceHeight: number): {
|
|
1523
|
+
x: number;
|
|
1524
|
+
y: number;
|
|
1525
|
+
w: number;
|
|
1526
|
+
h: number;
|
|
1527
|
+
}[];
|
|
1528
|
+
/** 将 cm 边距转为 jsPDF 用的 pt(72pt/inch,经 mm) */
|
|
1529
|
+
declare function marginsCmToPt(m: PageMarginsCm): {
|
|
1530
|
+
top: number;
|
|
1531
|
+
right: number;
|
|
1532
|
+
bottom: number;
|
|
1533
|
+
left: number;
|
|
1534
|
+
};
|
|
1535
|
+
|
|
1536
|
+
/**
|
|
1537
|
+
* 报表按行分页 — 页眉/页脚行区间每物理页重复,正文行按可用高度切页。
|
|
1538
|
+
*
|
|
1539
|
+
* 与 `print/pageGeometry.sliceRectangles`(像素矩形切片)不同:报表分页以「行」为
|
|
1540
|
+
* 最小单位,保证行不被腰斩,且 `PageSettings.pageHeaderRows/pageFooterRows`
|
|
1541
|
+
* 指定的行区间在每一物理页重复渲染。
|
|
1542
|
+
*/
|
|
1543
|
+
|
|
1544
|
+
/** 1-based 含端点的连续行区间 */
|
|
1545
|
+
type ReportRowSegment = {
|
|
1546
|
+
startRow: number;
|
|
1547
|
+
endRow: number;
|
|
1548
|
+
};
|
|
1549
|
+
type ReportPhysicalPage = {
|
|
1550
|
+
/** 0-based 物理页序号 */
|
|
1551
|
+
pageIndex: number;
|
|
1552
|
+
/** 每页重复的页眉行区间(无则 null) */
|
|
1553
|
+
headerRows: ReportRowSegment | null;
|
|
1554
|
+
/** 本页正文行(连续段列表;正文行剔除页眉页脚行后可能不连续) */
|
|
1555
|
+
bodySegments: ReportRowSegment[];
|
|
1556
|
+
/** 每页重复的页脚行区间(无则 null) */
|
|
1557
|
+
footerRows: ReportRowSegment | null;
|
|
1558
|
+
};
|
|
1559
|
+
type PaginateReportRowsArgs = {
|
|
1560
|
+
rowCount: number;
|
|
1561
|
+
/** index 0 = 第 1 行;缺省行用 defaultRowHeight */
|
|
1562
|
+
rowHeights?: number[] | null;
|
|
1563
|
+
defaultRowHeight: number;
|
|
1564
|
+
page: PageSettings$1;
|
|
1565
|
+
};
|
|
1566
|
+
type ReportPaginationResult = {
|
|
1567
|
+
pages: ReportPhysicalPage[];
|
|
1568
|
+
/** 可印区域高度(CSS px,96dpi) */
|
|
1569
|
+
printableHeightPx: number;
|
|
1570
|
+
headerHeightPx: number;
|
|
1571
|
+
footerHeightPx: number;
|
|
1572
|
+
/** 每页正文可用高度 = printable − header − footer */
|
|
1573
|
+
bodyAvailPx: number;
|
|
1574
|
+
};
|
|
1575
|
+
/**
|
|
1576
|
+
* 报表按行分页。页眉/页脚行高从正文可用高度中扣除;
|
|
1577
|
+
* 单行高度超过可用高度时独占一页(内容溢出交由渲染端裁剪/缩放)。
|
|
1578
|
+
*/
|
|
1579
|
+
declare function paginateReportRows(args: PaginateReportRowsArgs): ReportPaginationResult;
|
|
1580
|
+
|
|
1581
|
+
/**
|
|
1582
|
+
* 报表无状态灌数 — 快照 workbook + 字段数据 → 已填值 workbook。
|
|
1583
|
+
*
|
|
1584
|
+
* 面向报表渲染(@k-table/sheet-report)与服务端 PDF 的最小灌数管线:
|
|
1585
|
+
* - `baseTemplateBinding` 绑定格:basicField / mainField / subField / systemParam
|
|
1586
|
+
* - 纯文本格:`{b.x}` `{m.x}` `{p.x}` `{sN.x}` 占位符展开
|
|
1587
|
+
* - 未命中数据的绑定格默认清空(避免打印出设计占位文本)
|
|
1588
|
+
*
|
|
1589
|
+
* 遗留(LIMS `[#M2].value` 等)绑定不在本模块处理,宿主应先行转换。
|
|
1590
|
+
*/
|
|
1591
|
+
|
|
1592
|
+
/** 报表字段数据包(键大小写不敏感;子表 s 按 subSchemaId 分组、数组序 = 行序) */
|
|
1593
|
+
type ReportFieldData = {
|
|
1594
|
+
/** 基础字段 b.* */
|
|
1595
|
+
b?: Record<string, unknown>;
|
|
1596
|
+
/** 主表字段 m.* */
|
|
1597
|
+
m?: Record<string, unknown>;
|
|
1598
|
+
/** 子表:subSchemaId → 行数组(每行为 key→value) */
|
|
1599
|
+
s?: Record<string | number, Array<Record<string, unknown>>>;
|
|
1600
|
+
/** 用户/系统参数 p.*(与 systemParams 合并,systemParams 优先) */
|
|
1601
|
+
params?: Record<string, unknown>;
|
|
1602
|
+
};
|
|
1603
|
+
type HydrateFieldDataOptions = {
|
|
1604
|
+
/** 页码等系统参数(通常由打印编排注入) */
|
|
1605
|
+
systemParams?: Record<string, unknown>;
|
|
1606
|
+
/** 绑定格无数据时清空显示(默认 true) */
|
|
1607
|
+
clearUnresolvedBindings?: boolean;
|
|
1608
|
+
};
|
|
1609
|
+
/** 展开纯文本中的 `{b.x}` `{m.x}` `{p.x}` `{sN.x}` 占位符;未命中保持原样 */
|
|
1610
|
+
declare function expandFieldTokens(text: string, data: ReportFieldData, systemParams?: Record<string, unknown>): string;
|
|
1611
|
+
/** 对单个 sheet 灌数(纯函数,返回新对象) */
|
|
1612
|
+
declare function hydrateSheetFieldData(sheet: SheetTemplateState, data: ReportFieldData, options?: HydrateFieldDataOptions): SheetTemplateState;
|
|
1613
|
+
/** 对整个 workbook 灌数(纯函数,返回新对象) */
|
|
1614
|
+
declare function hydrateWorkbookFieldData(workbook: TemplateWorkbookState, data: ReportFieldData, options?: HydrateFieldDataOptions): TemplateWorkbookState;
|
|
1615
|
+
|
|
1616
|
+
/**
|
|
1617
|
+
* 报表共用表头表尾 — 模板条带提取与设计时合成(纯函数)。
|
|
1618
|
+
*
|
|
1619
|
+
* 「表头表尾模板」是一个普通报表 workbook:单 sheet,用
|
|
1620
|
+
* `page.pageHeaderRows` / `page.pageFooterRows` 标出表头/表尾行区间。
|
|
1621
|
+
* 应用时把模板条带合成进目标报表(顶部插入表头、底部追加表尾;
|
|
1622
|
+
* 目标已有区间则整段替换),合成结果自包含、无运行时依赖。
|
|
1623
|
+
*/
|
|
1624
|
+
|
|
1625
|
+
/** 单条带:行号以条带内 1-based 相对坐标表示 */
|
|
1626
|
+
type HeaderFooterStrip = {
|
|
1627
|
+
rowCount: number;
|
|
1628
|
+
/** index 0 = 条带第 1 行 */
|
|
1629
|
+
rowHeights: number[];
|
|
1630
|
+
cells: Record<string, CellData$1>;
|
|
1631
|
+
merges: MergeRange[];
|
|
1632
|
+
};
|
|
1633
|
+
type ReportHeaderFooterStrips = {
|
|
1634
|
+
header: HeaderFooterStrip | null;
|
|
1635
|
+
footer: HeaderFooterStrip | null;
|
|
1636
|
+
colCount: number;
|
|
1637
|
+
colWidths?: number[];
|
|
1638
|
+
defaultRowHeight: number;
|
|
1639
|
+
};
|
|
1640
|
+
/**
|
|
1641
|
+
* 从模板 workbook 提取表头/表尾条带。
|
|
1642
|
+
* 取 sheetId 指定的 sheet(缺省首个);两个区间均缺失时返回 null。
|
|
1643
|
+
*/
|
|
1644
|
+
declare function extractHeaderFooterStrips(tpl: TemplateWorkbookState, sheetId?: string): ReportHeaderFooterStrips | null;
|
|
1645
|
+
type ApplyHeaderFooterOptions = {
|
|
1646
|
+
/** 仅应用到指定 sheet;缺省全部 sheet */
|
|
1647
|
+
sheetIds?: string[];
|
|
1648
|
+
};
|
|
1649
|
+
/**
|
|
1650
|
+
* 把模板条带合成进目标报表(返回新 workbook,不修改入参)。
|
|
1651
|
+
* - 模板含表头:移除目标旧 pageHeaderRows 区间行,条带插到顶部并重标区间;
|
|
1652
|
+
* - 模板含表尾:移除目标旧 pageFooterRows 区间行,条带接到底部并重标区间;
|
|
1653
|
+
* - 模板缺某一部分时,目标对应部分保持不变;
|
|
1654
|
+
* - 正文 cells / merges / meta.report.bands 行坐标随位移平移。
|
|
1655
|
+
*/
|
|
1656
|
+
declare function applyReportHeaderFooterTemplate(target: TemplateWorkbookState, strips: ReportHeaderFooterStrips, options?: ApplyHeaderFooterOptions): TemplateWorkbookState;
|
|
1657
|
+
/**
|
|
1658
|
+
* 从当前报表切出表头表尾,落成独立的模板 workbook(用于导出 .ktl 模板文件)。
|
|
1659
|
+
* 结构:表头条带 + 1 行空正文 + 表尾条带,并标好 pageHeaderRows/pageFooterRows。
|
|
1660
|
+
*/
|
|
1661
|
+
declare function buildHeaderFooterTemplateWorkbook(source: TemplateWorkbookState, sheetId?: string): TemplateWorkbookState | null;
|
|
1662
|
+
|
|
1663
|
+
/**
|
|
1664
|
+
* 报表槽位翻页展开 — 与业务模版「每页子表槽位」同思路的固定版式自动翻页。
|
|
1665
|
+
*
|
|
1666
|
+
* 模板 sheet 用 `subField + subRowSlot`(0-based 页内槽位)绑定子表字段,
|
|
1667
|
+
* 每页槽位数取 `meta.subTableSlotConfig` 配置,缺省按最大槽位号 + 1 推断。
|
|
1668
|
+
* 展开时按数据行数把 sheet 复制为多个逻辑页副本,副本内重写
|
|
1669
|
+
* `subRowSlot = 页序 × slotsPerPage + 槽位`,交由 hydrate 直接按行号取数。
|
|
1670
|
+
*
|
|
1671
|
+
* 典型场景:针式样品标签小卡(每页 1 张卡 = 1 个样品,N 个样品 N 页)。
|
|
1672
|
+
*/
|
|
1673
|
+
|
|
1674
|
+
/**
|
|
1675
|
+
* 按子表数据行数展开槽位逻辑页(纯函数,返回新 workbook)。
|
|
1676
|
+
* - 无槽位绑定的 sheet 原样保留;
|
|
1677
|
+
* - 数据为空时保留 1 页(绑定格由 hydrate 清空);
|
|
1678
|
+
* - 多个子表并存时页数取各子表所需页数的最大值,各自按窗口推进。
|
|
1679
|
+
*/
|
|
1680
|
+
declare function expandReportSlotPages(workbook: TemplateWorkbookState, fieldData: ReportFieldData | undefined): TemplateWorkbookState;
|
|
1681
|
+
|
|
1682
|
+
/**
|
|
1683
|
+
* 报表/标签智能缩放 — 把版式从原纸张适配到新纸张尺寸。
|
|
1684
|
+
*
|
|
1685
|
+
* 不是无脑等比:按新旧「可打印区域」分别缩放列宽(横向)与行高(纵向),
|
|
1686
|
+
* 并施加最小尺寸约束(标签行高/列宽/字号有可读下限);因下限被挡住导致
|
|
1687
|
+
* 内容放不下时返回警告,交由界面提示用户手动微调。
|
|
1688
|
+
*/
|
|
1689
|
+
|
|
1690
|
+
type RescaleTargetSize = {
|
|
1691
|
+
widthMm: number;
|
|
1692
|
+
heightMm: number;
|
|
1693
|
+
};
|
|
1694
|
+
type RescaleOptions = {
|
|
1695
|
+
/** 行高下限(CSS px),默认 14 */
|
|
1696
|
+
minRowHeightPx?: number;
|
|
1697
|
+
/** 列宽下限(CSS px),默认 24 */
|
|
1698
|
+
minColWidthPx?: number;
|
|
1699
|
+
/** 字号下限(pt),默认 6 */
|
|
1700
|
+
minFontSizePt?: number;
|
|
1701
|
+
/** 是否缩放字号(默认 true;仅缩小、不放大) */
|
|
1702
|
+
scaleFontSize?: boolean;
|
|
1703
|
+
};
|
|
1704
|
+
type RescaleSheetResult = {
|
|
1705
|
+
sheet: SheetTemplateState;
|
|
1706
|
+
warnings: string[];
|
|
1707
|
+
};
|
|
1708
|
+
/**
|
|
1709
|
+
* 把 sheet 版式从当前纸张缩放到 `target`(mm)。纯函数:
|
|
1710
|
+
* - 列宽按可打印宽度比缩放、行高按可打印高度比缩放(各自 clamp 下限);
|
|
1711
|
+
* - 字号按 min(sx, sy) 只缩不放(clamp 下限);
|
|
1712
|
+
* - page 置为 Custom + 新宽高;
|
|
1713
|
+
* - 因 clamp 导致内容超出新可打印区域时输出警告。
|
|
1714
|
+
*/
|
|
1715
|
+
declare function rescaleReportSheet(sheet: SheetTemplateState, target: RescaleTargetSize, options?: RescaleOptions): RescaleSheetResult;
|
|
1716
|
+
/** workbook 级便捷封装:所有 sheet 应用同一目标尺寸 */
|
|
1717
|
+
declare function rescaleReportWorkbook(workbook: TemplateWorkbookState, target: RescaleTargetSize, options?: RescaleOptions): {
|
|
1718
|
+
workbook: TemplateWorkbookState;
|
|
1719
|
+
warnings: string[];
|
|
1720
|
+
};
|
|
1721
|
+
|
|
1722
|
+
/**
|
|
1723
|
+
* 网格 ↔ 纸张 ↔ Excel 尺寸的统一换算(CSS px @ 96dpi)。
|
|
1724
|
+
* 显示、导入、导出、打印预览共用本模块,保证列宽/行高比例一致。
|
|
1725
|
+
*/
|
|
1726
|
+
|
|
1727
|
+
/** Excel 默认行高(pt)与列宽(字符数) */
|
|
1728
|
+
declare const EXCEL_DEFAULT_ROW_HEIGHT_PT = 15;
|
|
1729
|
+
declare const EXCEL_DEFAULT_COL_WIDTH_CHAR = 8.43;
|
|
1730
|
+
/** OOXML 近似:pixel = round(charWidth × 7 + 5)(Calibri 11pt) */
|
|
1731
|
+
declare const EXCEL_COL_DIGIT_WIDTH_PX = 7;
|
|
1732
|
+
declare const EXCEL_COL_PADDING_PX = 5;
|
|
1733
|
+
/** Canvas 导入表 row=0/col=0 索引 gutter 的典型尺寸(px) */
|
|
1734
|
+
declare const CHROME_GUTTER_COL_WIDTH_PX = 40;
|
|
1735
|
+
declare const CHROME_GUTTER_ROW_HEIGHT_PX = 24;
|
|
1736
|
+
type GridLayoutMode = "compact" | "chrome";
|
|
1737
|
+
type SheetDataRegion = {
|
|
1738
|
+
r1: number;
|
|
1739
|
+
r2: number;
|
|
1740
|
+
c1: number;
|
|
1741
|
+
c2: number;
|
|
1742
|
+
};
|
|
1743
|
+
/** Excel 列宽(字符)→ CSS px */
|
|
1744
|
+
declare function excelColWidthToPx(charW: number): number;
|
|
1745
|
+
/** CSS px → Excel 列宽(字符),与 excelColWidthToPx 互逆 */
|
|
1746
|
+
declare function pxToExcelColWidth(px: number): number;
|
|
1747
|
+
/** Excel 行高(pt)→ CSS px */
|
|
1748
|
+
declare function excelRowHeightPtToPx(pt: number): number;
|
|
1749
|
+
/** CSS px → Excel 行高(pt) */
|
|
1750
|
+
declare function pxToExcelRowHeightPt(px: number): number;
|
|
1751
|
+
/**
|
|
1752
|
+
* compact:KTL/报表模板,rowCount/colCount 即数据区,colWidths[i] = 第 i+1 列(px)
|
|
1753
|
+
* chrome:Canvas/Excel 导入,含 row0/col0 索引 gutter
|
|
1754
|
+
*/
|
|
1755
|
+
declare function detectGridLayoutMode(sheet: SheetTemplateState): GridLayoutMode;
|
|
1756
|
+
/** 数据区 1-based 行列边界(不含 gutter) */
|
|
1757
|
+
declare function sheetDataRegion(sheet: SheetTemplateState): SheetDataRegion;
|
|
1758
|
+
/** 第 col 列(1-based)宽 px */
|
|
1759
|
+
declare function sheetDataColWidthPx(sheet: SheetTemplateState, col1Based: number): number;
|
|
1760
|
+
/** 第 row 行(1-based)高 px */
|
|
1761
|
+
declare function sheetDataRowHeightPx(sheet: SheetTemplateState, row1Based: number): number;
|
|
1762
|
+
/** 数据区总宽/总高(px) */
|
|
1763
|
+
declare function sheetDataGridWidthPx(sheet: SheetTemplateState): number;
|
|
1764
|
+
declare function sheetDataGridHeightPx(sheet: SheetTemplateState): number;
|
|
1765
|
+
/** 内容宽超出可印宽时的等比缩放系数(只缩不放) */
|
|
1766
|
+
declare function computeFitScale(contentWidthPx: number, printableWidthPx: number): number;
|
|
1767
|
+
/** 按目标总宽等比缩放列宽数组,保持比例;可选单列下限 */
|
|
1768
|
+
declare function scaleWidthsProportional(widths: number[], targetTotalPx: number, minColPx?: number): number[];
|
|
1769
|
+
type FitGridToPageOptions = {
|
|
1770
|
+
/** 是否同步缩放行高(默认 false,列宽为主) */
|
|
1771
|
+
scaleRows?: boolean;
|
|
1772
|
+
minColWidthPx?: number;
|
|
1773
|
+
minRowHeightPx?: number;
|
|
1774
|
+
};
|
|
1775
|
+
/**
|
|
1776
|
+
* 将 sheet 数据区列宽(及可选行高)等比缩放到 page 可印区域内;仅缩小、不放大。
|
|
1777
|
+
* 返回新 sheet(compact 模式数组索引)。
|
|
1778
|
+
*/
|
|
1779
|
+
declare function fitSheetDataGridToPage(sheet: SheetTemplateState, page: PageSettings$1, options?: FitGridToPageOptions): SheetTemplateState;
|
|
1780
|
+
/** chrome → compact:去掉 gutter 行/列,保留 1-based 单元格坐标 */
|
|
1781
|
+
declare function normalizeSheetToCompactGrid(sheet: SheetTemplateState): SheetTemplateState;
|
|
1782
|
+
/** 预览/打印:表格数据区宽 vs 可印宽 → fitScale */
|
|
1783
|
+
declare function sheetPrintFitScale(sheet: SheetTemplateState): number;
|
|
1784
|
+
|
|
1785
|
+
/**
|
|
1786
|
+
* 单元格 `fontSize` 与 Excel 一致,单位为**磅(pt)**;画布/CSS 用 96dpi 逻辑像素时需换算。
|
|
1787
|
+
* 默认 10 磅(常见正文)。
|
|
1788
|
+
*/
|
|
1789
|
+
declare const DEFAULT_FONT_SIZE_PT = 10;
|
|
1790
|
+
declare const MIN_FONT_SIZE_PT = 1;
|
|
1791
|
+
/** 与 Excel 字体大小上限一致 */
|
|
1792
|
+
declare const MAX_FONT_SIZE_PT = 409;
|
|
1793
|
+
/** pt → CSS/Canvas 像素(96dpi:1in = 96px = 72pt) */
|
|
1794
|
+
declare function fontSizePtToCssPx(pt: number): number;
|
|
1795
|
+
/** 旧版按 px 存的字号 → 磅(用于模板 v1 迁移) */
|
|
1796
|
+
declare function cssPxToFontSizePt(px: number): number;
|
|
1797
|
+
declare function clampFontSizePt(pt: number): number;
|
|
1798
|
+
|
|
1799
|
+
/**
|
|
1800
|
+
* 内置字体:存短 id(JSON),绘制时展开为跨平台 font-family 栈,Excel 导出用中文名。
|
|
1801
|
+
*/
|
|
1802
|
+
declare const SHEET_FONT_OPTIONS: {
|
|
1803
|
+
value: string;
|
|
1804
|
+
label: string;
|
|
1805
|
+
}[];
|
|
1806
|
+
/** Canvas / contenteditable 用 CSS font-family 串 */
|
|
1807
|
+
declare function sheetFontFamilyCss(id: string | undefined): string;
|
|
1808
|
+
/** exceljs font.name */
|
|
1809
|
+
declare function sheetFontFamilyExcelName(id: string | undefined): string | undefined;
|
|
1810
|
+
/** 从粘贴 CSS font-family 猜内置 id(无法匹配则 undefined,由调用方忽略或保留扩展) */
|
|
1811
|
+
declare function guessSheetFontIdFromCssFontFamily(raw: string): string | undefined;
|
|
1812
|
+
|
|
1813
|
+
/**
|
|
1814
|
+
* 网格列标(1-based,含行号列偏移):0 -> '', 1 -> 'A'。
|
|
1815
|
+
* 注意与 formula/a1 的 columnIndexToLetters(0-based,0 -> 'A')语义不同,故独立命名。
|
|
1816
|
+
*/
|
|
1817
|
+
declare function gridColumnIndexToLetters(c0: number): string;
|
|
1818
|
+
|
|
1819
|
+
/**
|
|
1820
|
+
* 工具栏取色:两排对齐——
|
|
1821
|
+
* - 第一排:常见「纯色」标准(红/黄/蓝等为 sRGB 纯色),首格为白;
|
|
1822
|
+
* - 第二排:与 Excel 主题接近的常用色,首格为黑(与第一排白同一列对应)。
|
|
1823
|
+
*/
|
|
1824
|
+
declare const SHEET_COLOR_ROW_STANDARD: readonly {
|
|
1825
|
+
hex: string;
|
|
1826
|
+
label: string;
|
|
1827
|
+
}[];
|
|
1828
|
+
/** 与 Excel 主题色接近的一组(原「标准色」近似) */
|
|
1829
|
+
declare const SHEET_COLOR_ROW_THEME: readonly {
|
|
1830
|
+
hex: string;
|
|
1831
|
+
label: string;
|
|
1832
|
+
}[];
|
|
1833
|
+
|
|
1834
|
+
declare function defaultPageSettings(): PageSettings$1;
|
|
1835
|
+
/**
|
|
1836
|
+
* 统一页边距为 cm;兼容旧 `marginsMm`(读入时 /10 转为 cm)。
|
|
1837
|
+
*/
|
|
1838
|
+
declare function normalizePageSettings(input: unknown): PageSettings$1;
|
|
1839
|
+
|
|
1840
|
+
/**
|
|
1841
|
+
* Excel 导入中间格式 — v1
|
|
1842
|
+
* 设计目标:完整保留 .xlsx 解析信息 + LLM 可理解 + 可还原到 SheetTemplateState
|
|
1843
|
+
*/
|
|
1844
|
+
interface ExcelImportIntermediateV1 {
|
|
1845
|
+
kind: "kt.excelImport";
|
|
1846
|
+
version: 1;
|
|
1847
|
+
source: {
|
|
1848
|
+
fileName: string;
|
|
1849
|
+
fileSize: number;
|
|
1850
|
+
sheetName: string;
|
|
1851
|
+
sheetIndex: number;
|
|
1852
|
+
parsedAt: string;
|
|
1853
|
+
};
|
|
1854
|
+
dimensions: {
|
|
1855
|
+
rowCount: number;
|
|
1856
|
+
colCount: number;
|
|
1857
|
+
usedRange: {
|
|
1858
|
+
r1: number;
|
|
1859
|
+
c1: number;
|
|
1860
|
+
r2: number;
|
|
1861
|
+
c2: number;
|
|
1862
|
+
};
|
|
1863
|
+
};
|
|
1864
|
+
defaults: {
|
|
1865
|
+
rowHeightPx: number;
|
|
1866
|
+
colWidthPx: number;
|
|
1867
|
+
fontFamily: string;
|
|
1868
|
+
fontSizePt: number;
|
|
1869
|
+
};
|
|
1870
|
+
rowHeights: Record<string, number>;
|
|
1871
|
+
colWidths: Record<string, number>;
|
|
1872
|
+
merges: ExcelImportMerge[];
|
|
1873
|
+
cells: Record<string, ExcelImportCell>;
|
|
1874
|
+
stats: ExcelImportStats;
|
|
1875
|
+
availableSheets: {
|
|
1876
|
+
index: number;
|
|
1877
|
+
name: string;
|
|
1878
|
+
}[];
|
|
1879
|
+
extension?: Record<string, unknown>;
|
|
1880
|
+
}
|
|
1881
|
+
interface ExcelImportMerge {
|
|
1882
|
+
r1: number;
|
|
1883
|
+
c1: number;
|
|
1884
|
+
r2: number;
|
|
1885
|
+
c2: number;
|
|
1886
|
+
ref?: string;
|
|
1887
|
+
}
|
|
1888
|
+
interface ExcelImportCell {
|
|
1889
|
+
value: string;
|
|
1890
|
+
formula?: string;
|
|
1891
|
+
style?: ExcelImportCellStyle;
|
|
1892
|
+
richText?: ExcelImportRichRun[];
|
|
1893
|
+
}
|
|
1894
|
+
interface ExcelImportCellStyle {
|
|
1895
|
+
fontFamily?: string;
|
|
1896
|
+
fontSizePt?: number;
|
|
1897
|
+
bold?: boolean;
|
|
1898
|
+
italic?: boolean;
|
|
1899
|
+
underline?: boolean;
|
|
1900
|
+
strikethrough?: boolean;
|
|
1901
|
+
textColor?: string;
|
|
1902
|
+
superscript?: boolean;
|
|
1903
|
+
subscript?: boolean;
|
|
1904
|
+
horizontalAlign?: "left" | "center" | "right";
|
|
1905
|
+
verticalAlign?: "top" | "middle" | "bottom";
|
|
1906
|
+
wrapText?: boolean;
|
|
1907
|
+
shrinkToFit?: boolean;
|
|
1908
|
+
bgColor?: string;
|
|
1909
|
+
border?: {
|
|
1910
|
+
top?: ExcelImportBorderSide;
|
|
1911
|
+
right?: ExcelImportBorderSide;
|
|
1912
|
+
bottom?: ExcelImportBorderSide;
|
|
1913
|
+
left?: ExcelImportBorderSide;
|
|
1914
|
+
};
|
|
1915
|
+
}
|
|
1916
|
+
interface ExcelImportBorderSide {
|
|
1917
|
+
width: "thin" | "medium" | "thick";
|
|
1918
|
+
pattern: "solid" | "dashed" | "dotted";
|
|
1919
|
+
color: string;
|
|
1920
|
+
}
|
|
1921
|
+
interface ExcelImportRichRun {
|
|
1922
|
+
text: string;
|
|
1923
|
+
style?: {
|
|
1924
|
+
bold?: boolean;
|
|
1925
|
+
italic?: boolean;
|
|
1926
|
+
underline?: boolean;
|
|
1927
|
+
strikethrough?: boolean;
|
|
1928
|
+
superscript?: boolean;
|
|
1929
|
+
subscript?: boolean;
|
|
1930
|
+
fontSizePt?: number;
|
|
1931
|
+
fontFamily?: string;
|
|
1932
|
+
textColor?: string;
|
|
1933
|
+
};
|
|
1934
|
+
}
|
|
1935
|
+
interface ExcelImportStats {
|
|
1936
|
+
totalCells: number;
|
|
1937
|
+
styledCells: number;
|
|
1938
|
+
mergedRegions: number;
|
|
1939
|
+
formulaCells: number;
|
|
1940
|
+
richTextCells: number;
|
|
1941
|
+
}
|
|
1942
|
+
interface ExcelImportOptions {
|
|
1943
|
+
sheetIndex: number;
|
|
1944
|
+
keepBorders: boolean;
|
|
1945
|
+
keepFonts: boolean;
|
|
1946
|
+
keepMerges: boolean;
|
|
1947
|
+
keepBackground: boolean;
|
|
1948
|
+
keepFormula: boolean;
|
|
1949
|
+
keepDimensions: boolean;
|
|
1950
|
+
}
|
|
1951
|
+
declare const DEFAULT_IMPORT_OPTIONS: Omit<ExcelImportOptions, "sheetIndex">;
|
|
1952
|
+
|
|
1953
|
+
/** 数据区单元格地址,如 A1、B2(r,c 为 0-based 网格坐标,且 r>=1,c>=1) */
|
|
1954
|
+
declare function formatA1(r: number, c: number): string;
|
|
1955
|
+
/** 名称框展示:单格 A1;多格 A1:B2(与 Excel 一致) */
|
|
1956
|
+
declare function formatSelectionA1(sel: SelectionRect): string;
|
|
1957
|
+
/** 1-based 数据格 A1 解析(与 coords.parseA1 的 0-based 语义不同,故独立命名)。 */
|
|
1958
|
+
declare function parseA1Cell(s: string): {
|
|
1959
|
+
r: number;
|
|
1960
|
+
c: number;
|
|
1961
|
+
} | null;
|
|
1962
|
+
/** 名称框跳转:支持 A1 或 A1:B2 / A1:A8 等矩形选区 */
|
|
1963
|
+
declare function parseA1OrRangeToSelection(s: string): SelectionRect | null;
|
|
1964
|
+
declare function parseGridRcAddress(s: string): {
|
|
1965
|
+
r: number;
|
|
1966
|
+
c: number;
|
|
1967
|
+
} | null;
|
|
1968
|
+
|
|
1969
|
+
/**
|
|
1970
|
+
* 工作簿计算运行器(M3.0 + M3.1 + M3.2 + M3+):
|
|
1971
|
+
* 给定工作簿 + 元数据 + 字段数据 + 脚本块,按 3 类公式(grid/field/script)
|
|
1972
|
+
* 统一求值并把结果写回 `wb.sheets[*].sheet.cells[key].value`;
|
|
1973
|
+
* 可选应用单元格修约(`CellRoundingMeta`)。
|
|
1974
|
+
*
|
|
1975
|
+
* 评估策略(简化但正确):
|
|
1976
|
+
* 1. 先以当前字段数据渲染所有"绑定格"的 `value`;
|
|
1977
|
+
* 2. 计算 field 公式(主/子行级),更新字段数据;
|
|
1978
|
+
* 3. 计算 script 块(CALC_*),写入字段数据或单元格;
|
|
1979
|
+
* 4. 渲染一次绑定格;
|
|
1980
|
+
* 5. 计算 grid 公式(A1 依赖图 + 拓扑顺序);
|
|
1981
|
+
* 6. 对 onCompute 修约的单元格执行修约;
|
|
1982
|
+
* 7. 如仍有依赖跨类(grid → field),迭代第 2~5 步最多 N 次直到稳定。
|
|
1983
|
+
*
|
|
1984
|
+
* M3+ 支持:
|
|
1985
|
+
* - 跨表引用 Sheet2!A1 / 'Sheet Name'!A1
|
|
1986
|
+
* - 工作簿命名区域(namedRanges)
|
|
1987
|
+
*/
|
|
1988
|
+
|
|
1989
|
+
/**
|
|
1990
|
+
* 系统参数构建器(host 注入)。core 引擎不读任何 UI store;
|
|
1991
|
+
* kt-web 提供读 ShellBranding store 的实现,LIMS/TAM 可提供各自实现或省略(无内置参数)。
|
|
1992
|
+
*/
|
|
1993
|
+
interface ComputeSystemParamsProvider {
|
|
1994
|
+
buildSystemParams: (wb: TemplateWorkbookState, ctx?: {
|
|
1995
|
+
render?: RenderContext;
|
|
1996
|
+
branding?: SystemParamBranding | null;
|
|
1997
|
+
}) => SystemParamMap;
|
|
1998
|
+
buildSystemParamsForSheet: (wb: TemplateWorkbookState, sheetId: string, logicalState: LogicalState | null | undefined, userParams: Record<string, unknown> | null | undefined, branding: SystemParamBranding | null | undefined) => SystemParamMap;
|
|
1999
|
+
}
|
|
2000
|
+
interface ComputeInput {
|
|
2001
|
+
wb: TemplateWorkbookState;
|
|
2002
|
+
/** 扁平复合键:`${sheetId}::${r},${c}`,值为合并对象 */
|
|
2003
|
+
cellMeta: Record<string, unknown> | null | undefined;
|
|
2004
|
+
fieldData: FieldDataCtx;
|
|
2005
|
+
/** 多 Tab 各 sheet 独立 pageNumber / totalPageNumber 等 */
|
|
2006
|
+
logicalState?: LogicalState | null;
|
|
2007
|
+
/**
|
|
2008
|
+
* 打印/预览逐页重算时按 sheet 注入 RenderContext(优先于 logicalState 推导)。
|
|
2009
|
+
* 键 = sheetId。
|
|
2010
|
+
*/
|
|
2011
|
+
renderContextBySheet?: Record<string, RenderContext> | null;
|
|
2012
|
+
/** 系统参数 branding(实例/测试页由 Shell 传入,避免重复读 localStorage) */
|
|
2013
|
+
systemParamBranding?: SystemParamBranding | null;
|
|
2014
|
+
scripts?: WorkbookScripts | null;
|
|
2015
|
+
namedRanges?: WorkbookNamedRange[] | null;
|
|
2016
|
+
/** 子表统计键 / activeCount;缺省读 wb.meta.fieldRegistry */
|
|
2017
|
+
fieldRegistry?: TemplateFieldRegistry | null;
|
|
2018
|
+
/** 最大迭代轮次;默认 3 */
|
|
2019
|
+
maxIterations?: number;
|
|
2020
|
+
/** incremental=录入后增量计算;full=全量重算/设计态试算(默认) */
|
|
2021
|
+
computePass?: 'incremental' | 'full';
|
|
2022
|
+
/** 系统参数构建器(host 注入);缺省时 systemParam 绑定格按空参数展开。 */
|
|
2023
|
+
systemParamsProvider?: ComputeSystemParamsProvider;
|
|
2024
|
+
/** 调试钩子(host 注入,kt-web 用 window+flag 守卫);缺省无操作。 */
|
|
2025
|
+
debug?: (event: string, payload: unknown) => void;
|
|
2026
|
+
}
|
|
2027
|
+
interface ComputeIssue {
|
|
2028
|
+
kind: 'grid' | 'field' | 'script';
|
|
2029
|
+
sheetId?: string;
|
|
2030
|
+
cellKey?: string;
|
|
2031
|
+
blockKey?: string;
|
|
2032
|
+
message: string;
|
|
2033
|
+
}
|
|
2034
|
+
interface ComputeResult {
|
|
2035
|
+
wb: TemplateWorkbookState;
|
|
2036
|
+
fieldData: FieldDataCtx;
|
|
2037
|
+
issues: ComputeIssue[];
|
|
2038
|
+
/** 迭代停止时的轮次 */
|
|
2039
|
+
iterations: number;
|
|
2040
|
+
}
|
|
2041
|
+
declare function computeWorkbook(input: ComputeInput): ComputeResult;
|
|
2042
|
+
/**
|
|
2043
|
+
* 增量计算包装(M3.4 实例运行时主入口)。
|
|
2044
|
+
* 实际策略:基于 dirtySeeds 判定是否需要计算。
|
|
2045
|
+
* - 若 cellMeta 中没有任何 formulaKind 条目,直接返回原工作簿(零开销)。
|
|
2046
|
+
* - 其余情况执行 `computeWorkbook` 完整求值;因为依赖图在内部构造,
|
|
2047
|
+
* 拓扑遍历仅扫当前公式集合,开销可接受。
|
|
2048
|
+
* 未来可在此基础上做真正的「闭包节点仅重算」优化。
|
|
2049
|
+
*/
|
|
2050
|
+
interface IncrementalInput extends ComputeInput {
|
|
2051
|
+
/** 刚刚变更的种子格位置(配合依赖闭包用;当前版本内部仅做快检) */
|
|
2052
|
+
dirtySeeds?: Array<{
|
|
2053
|
+
sheetId: string;
|
|
2054
|
+
r: number;
|
|
2055
|
+
c: number;
|
|
2056
|
+
}>;
|
|
2057
|
+
}
|
|
2058
|
+
declare function computeWorkbookIncremental(input: IncrementalInput): ComputeResult;
|
|
2059
|
+
|
|
2060
|
+
/**
|
|
2061
|
+
* @k-table/sheet-core — kt 表格无头引擎(增量迁移中,见蓝图 M2)。
|
|
2062
|
+
*
|
|
2063
|
+
* 迁移序(依赖拓扑):
|
|
2064
|
+
* 0. 【前置】下沉 sheet 模型类型(SheetTemplateState 等)至共享位置,
|
|
2065
|
+
* 否则 core 的 TemplateWorkbookState 反依赖 components/sheet-template(canvas)。
|
|
2066
|
+
* 1. model / 坐标 coords / 几何 geometry / 布局 layout。
|
|
2067
|
+
* 2. serialize / formula / runtime / compose / instance-data。
|
|
2068
|
+
* 3. migrate(复用现有 migrateWorkbook / legacyWorkbookToTemplateWorkbook)。
|
|
2069
|
+
* 4. 补新能力:多层修约覆盖合并、明细列表行重复渲染。
|
|
2070
|
+
*
|
|
2071
|
+
* 纯度由 eslint-boundaries(M0.4)在迁入时机械强制:禁 react/next/window/document/zustand/echarts/fetch。
|
|
2072
|
+
* 当前阶段:包骨架就位,等待 workspace 装配后逐模块搬迁。
|
|
2073
|
+
*/
|
|
2074
|
+
declare const SHEET_CORE_PACKAGE: "@k-table/sheet-core";
|
|
2075
|
+
|
|
2076
|
+
export { type A1RangeRef, type A1Ref, type A1SingleRef, AggregateEmptyAs, type ApplyHeaderFooterOptions, type AssetEmbedDef, type AssetKind, type AstNode, BUILTIN_PARAM_CATALOG_CODES, type BinOp, type BorderApplySpec, BorderPattern, type BorderPreset, BorderWidth, type BuiltinParamCatalogCode, CHROME_GUTTER_COL_WIDTH_PX, CHROME_GUTTER_ROW_HEIGHT_PX, CSS_PX_PER_INCH, type CellBindingKind, type CellBindingMeta, CellData, type CellFormulaBindingMeta, type CellLayoutHint, type CellRoundingMeta, type ChartDataSource, type ChartEmbedDef, type ComboInstanceDataV3, type ComboSharedContext, type CompileResult, type ComputeFieldLhs, type ComputeInput, type ComputeIssue, type ComputePass, type ComputeResult, type ComputeSystemParamsProvider, DEFAULT_FONT_SIZE_PT, DEFAULT_IMPORT_OPTIONS, DESIGN_FIELD_SHORTHAND_SKILLS, DICT_CATALOG_META_KEY, DICT_OVERLAYS_BY_USER_KEY, DepGraph, type DesignFieldMetaFromShorthand, type DictSnapshotEntry, type DictSnapshotsMap, EXCEL_COL_DIGIT_WIDTH_PX, EXCEL_COL_PADDING_PX, EXCEL_DEFAULT_COL_WIDTH_CHAR, EXCEL_DEFAULT_ROW_HEIGHT_PT, type EmbedAnchorCell, type EmbedAnchorRect, type EmbedBase, type EmbedBoxPt, type EmbedInstanceState, type EmbedPrintContext, type EvalContext, type ExcelImportBorderSide, type ExcelImportCell, type ExcelImportCellStyle, type ExcelImportIntermediateV1, type ExcelImportMerge, type ExcelImportOptions, type ExcelImportRichRun, type ExcelImportStats, FORMULA_RUN_WHEN_LABELS, FUNCTIONS, type FieldDataCtx, type FieldDefRegisterMode, type FieldEvalContext, type FieldInputWhen, type FieldLhs, type FieldPullRuleDef, type FieldRegistryIndex, type FieldRoundingTarget, type FieldRunContextOptions, type FillExtension, type FitGridToPageOptions, type FnImpl, type FormulaAny, type FormulaArray, FormulaCatalogEntry, FormulaCatalogTarget, type FormulaError, type FormulaInputTarget, type FormulaRunWhen, type FormulaStdLibOptions, type FormulaValue, type FormulaValueKind, type GridLayoutMode, type HeaderFooterStrip, type HydrateFieldDataOptions, INSTANCE_DATA_SCHEMA_V2, INSTANCE_DATA_SCHEMA_V3, type IncrementalInput, type InstanceDataRoot, type InstanceDictOverlaysByUser, type InstanceFieldPackV2, type InstanceFieldPackV2Ext, type InstanceSubTablePack, type InstanceSubTablesData, KtTemplateRoot, LEGACY_SYSTEM_PARAM_TEMPLATE_TOKENS, type LayoutFontStyleOpts, type LayoutLinesResult, type LogicalState, MAX_FONT_SIZE_PT, MIN_FONT_SIZE_PT, MIN_SHRINK_FONT_PT, MM_PER_INCH, type MasterCell, MergeIndex, MergeRect, type NodeId, PageSettings, type PaginateReportRowsArgs, type ParsedFieldPath, Parser, type PasteCellPatch, type PrintPageSlot, type PullContext, type PullContextSource, ROUNDING_LAYER_ORDER, ROUNDING_WHEN_LABELS, ROUND_MODE_LETTER_MAP, RUNTIME_COMPUTED_SYSTEM_PARAM_CODES, RUNTIME_ONLY_SYSTEM_PARAM_CODES, type Rect, type RefreshPolicy, type RenderContext, type ReportFieldData, type ReportHeaderFooterStrips, type ReportPaginationResult, type ReportPhysicalPage, type ReportRowSegment, type RescaleOptions, type RescaleSheetResult, type RescaleTargetSize, type RoundingLayer, type RoundingLayerScope, type RoundingOverrideEntry, type RoundingOverrideMap, type RoundingTriggerFlags, type RoundingWhenPreset, type RuntimeOnlySystemParamCode, SHEET_COLOR_ROW_STANDARD, SHEET_COLOR_ROW_THEME, SHEET_CORE_PACKAGE, SHEET_ENGINE_CONFIG, SHEET_FONT_OPTIONS, SUBTABLE_SLOT_BINDING_SKILLS, type SelectionRect, Sheet, type SheetDataRegion, SheetItem, type SignatureSlotState, type SignatureSlotStatus, type SignatureWorkflowReport, type SjsBinOp, SjsCycleError, SjsError, type SjsFn, type SjsNode, type SjsObject, type SjsProgram, type SjsStmt, type SjsValue, type SpliceDiagnostic, type SpliceDiagnosticFix, type SpliceDiagnosticLevel, type SpliceDiagnosticsReport, type SpliceDiagnosticsSignals, type SpliceMisalignSignal, type SpliceUnboundSlotSignal, type SubTableRegionConfig, type SystemParamBranding, type SystemParamId, type SystemParamMap, TEMPLATE_DICT_CATALOG_VERSION, TEMPLATE_WORKBOOK_JSON_VERSION, type TemplateDictCatalog, type TemplateDictDef, type TemplateDictItem, type TemplateDictKind, TemplateFieldDef, TemplateFieldRegistry, type TemplateSheetItem, TemplateSubFieldDef, type TemplateWorkbookState, type TextMeasurer, type Token, type TokenType, type UpsertFieldDefInput, V_NULL, Workbook, type WorkbookEmbedDef, WorkbookMeta, WorkbookNamedRange, type WorkbookPrintPlan, WorkbookScripts, activeSubRowIndices, applyBorderPresetToSheet, applyFieldRoundingForStore, applyNumericRounding, applyReportHeaderFooterTemplate, applyRounding, applyRoundingForInstancePlain, applySignatureResultsToEmbedStates, buildActiveSubRowCounts, buildFieldRunContext, buildFormulaStdLib, buildHeaderFooterTemplateWorkbook, buildPastePatches, buildRoundingLayers, buildSignatureWorkflow, buildSpliceDiagnostics, catalogEntryNodeId, catalogEntryRunWhen, cellKey, cellMetaCompoundKey, clampFontSizePt, clampZoom, cloneFieldRegistry, coerceBool, coerceNum, coerceStr, colIndexToLetters, collectReferencedRoots, columnIndexToLetters, columnLettersToIndex, comboDataFromRoot, compileFormulaAssignment, computeFillPreviewSelection, computeFitScale, computeWorkbook, computeWorkbookIncremental, countActiveSubRows, createDefaultPage, createEmptySheet, createEmptyWorkbook, cssOneCmToCssPx, cssPxToCm, cssPxToFontSizePt, cssPxToPt, defaultPageSettings, describeDictKind, describeRoundingWhenPreset, detectFillExtension, detectGridLayoutMode, emptyFieldPackV2, emptyFieldRegistry, enrichParamsForFieldRuntime, evaluate, excelColWidthToPx, excelRowHeightPtToPx, expandFieldTokens, expandReportSlotPages, expandSystemParamTemplate, extensionStripRect, extractBaseFieldDefsFromWorkbookEnvelope, extractFormulaDeps, extractHeaderFooterStrips, extractRowInputFields, fieldPackFromRoot, fieldPartitionKey, fillSparseDemoCells, fitSheetDataGridToPage, fontSizePtToCssPx, forEachArrayValue, formatA1, formatA1Range, formatA1Single, formatFieldTypeShorthand, formatNumericByMeta, formatSelectionA1, getColWidth, getFieldRegistryFromMeta, getRoundingForCommit, getRoundingForComputeMeta, getRoundingMetaFromCellMetaEntry, getRowHeight, gridColumnIndexToLetters, gridNodeId, guessSheetFontIdFromCssFontFamily, hasEmbedsToPaint, hydrateSheetFieldData, hydrateWorkbookFieldData, indexFieldRegistry, injectBaseFieldRegistryIntoWorkbookEnvelope, isComboInstanceDataV3, isErr, isFieldRegistryRecord, isInstanceFieldPackV2, isKnownSystemParamId, isLegacyInstanceDataV1, isRuntimeComputedSystemParam, isSubColumnPresent, isSubFieldRichPersist, jsPdfFormat, jsPdfOrientation, layoutFontCss, layoutLinesForCellM, lettersToColIndex, lhsToRoundingTarget, listKnownSystemParamIdsForTemplate, listTemplateSystemParamTokenEntries, lockFillAxis, mainFieldNodeId, marginsCmToMm, marginsCmToPt, matrixToTsv, mergeBakedFieldRegistry, mergeBaseFieldPartition, mergeInstanceDataJsonWithLogicalState, mergeInstanceDataJsonWithSubTables, mergeRoundingOverrideLayers, mergeSubFieldCellFromAccValue, mergeSystemAndUserParams, mmToCssPx, nextPendingSignature, normSelectionRect, normalizeFieldDef, normalizeFieldKey, normalizeFieldRegistry, normalizeFormulaRunWhen, normalizePageSettings, normalizeRect, normalizeRoundingTriggers, normalizeSheetToCompactGrid, normalizeSubFieldDef, normalizeSubFieldSlotForFormula, normalizeSystemParamId, pageAtRuleCss, paginateReportRows, paperSizeMm, paperSizeMmFromPage, paperSizeMmRaw, parseA1, parseA1Cell, parseA1OrRangeToSelection, parseA1Ref, parseA1Single, parseCellKey, parseCellMetaCompoundKey, parseFieldPath, parseFieldRegistryFromCapabilities, parseFieldTypeSpec, parseFormula, parseGridRcAddress, parseInstanceDataRoot, parseInstanceSubTables, parseInternalR1C1Ref, parseLogicalState, parseRoundingJson, parseSjsExpr, parseSjsProgram, parseWorkbookJson, physicalPaperSizeMmFromPage, pickLogicalStateFromRoot, presetToTriggers, printableSizeCssPx, printableSizeMm, ptToCssPx, pxToExcelColWidth, pxToExcelRowHeightPt, readSelectionAsTsv, rectContains, rectsOverlap, rescaleReportSheet, rescaleReportWorkbook, resolveBaseFieldDefsFromBaseSource, resolveFieldDefRegisterMode, resolveInputDeps, resolveRoundingForTarget, resolveRoundingFromFieldPath, resolveSheetLogicalPage, resolveSubRowStatKey, roundFinite, roundToInterval, roundToSignificant, roundingForCompute, runSjs, runSjsExpr, runWhenToStorage, scaleWidthsProportional, scriptNodeId, selectionIsUnmergedRectangle, serializeFieldPackV2, serializeWorkbook, setFieldRegistryOnMeta, sheetDataColWidthPx, sheetDataGridHeightPx, sheetDataGridWidthPx, sheetDataRegion, sheetDataRowHeightPx, sheetFontFamilyCss, sheetFontFamilyExcelName, sheetPrintFitScale, shouldComputeFieldByInput, shouldRunFieldFormula, shouldRunScriptBlock, signatureResultsFromEmbedStates, signatureSpecsFromEmbeds, sjsTokenize, sliceRectangles, splitBindingAndTypeSuffix, stripFieldPrefix, stripRuntimeComputedUserParams, subFieldNodeId, subFieldPersistValueFromCell, targetRectFromExtension, targetToOverrideKey, templateContainsSystemParamTokens, toA1, tokenize, triggersToPreset, tryParseNumericString, tsvToMatrix, vBool, vErr, vNum, vStr, wrapTextToWidthM };
|