@agile-team/mach-report 2.8.4 → 2.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -9
- package/dist/ExcelBindingWizard-DiaxvWpQ.cjs +1 -0
- package/dist/ExcelBindingWizard-RLJIXKKG.js +816 -0
- package/dist/{ReportPreview-DTWiCH5a.js → ReportPreview-B5ZNEasW.js} +22 -21
- package/dist/ReportPreview-DRtVPUYo.cjs +6 -0
- package/dist/RuleEditor-CskN5Fr3.cjs +1 -0
- package/dist/RuleEditor-CtJFzKuY.js +1578 -0
- package/dist/TemplateReviewPanel-C_Lmzis6.cjs +1 -0
- package/dist/TemplateReviewPanel-Cn32OY4_.js +173 -0
- package/dist/analytics.cjs +1 -1
- package/dist/analytics.d.cts +188 -5
- package/dist/analytics.d.ts +188 -5
- package/dist/analytics.js +68 -202
- package/dist/{assets-B9qJku3V.js → assets-DDsfEi8R.js} +3 -3
- package/dist/{assets-RZan7EyL.cjs → assets-ahTRUXRk.cjs} +1 -1
- package/dist/binding-preview-B5834rml.cjs +2 -0
- package/dist/binding-preview-ChXjN5L5.js +649 -0
- package/dist/{capabilities-joSutDF8.js → capabilities-Cm9hZ3uV.js} +5 -5
- package/dist/{capabilities-xGTpnPjJ.cjs → capabilities-DYzWL7KS.cjs} +1 -1
- package/dist/dataset-BkRmwgeJ.cjs +1 -0
- package/dist/dataset-H5pFuQGU.js +121 -0
- package/dist/defaults-DXhiM1ZD.js +10 -0
- package/dist/defaults-xhmcLLrf.cjs +1 -0
- package/dist/designer.cjs +2 -1
- package/dist/designer.d.cts +1373 -6
- package/dist/designer.d.ts +1373 -6
- package/dist/designer.js +2495 -767
- package/dist/grid-geometry-BNptEcMm.js +65 -0
- package/dist/grid-geometry-CZ_cYB6O.cjs +1 -0
- package/dist/import-template-CNMLJSQw.js +23030 -0
- package/dist/import-template-CpxunKVp.cjs +29 -0
- package/dist/index.cjs +7 -7
- package/dist/index.d.cts +202 -3
- package/dist/index.d.ts +202 -3
- package/dist/index.js +554 -535
- package/dist/matrix-CNPDJxED.js +745 -0
- package/dist/matrix-Div9Ilh3.cjs +1 -0
- package/dist/pdf.cjs +46 -46
- package/dist/pdf.d.cts +2 -0
- package/dist/pdf.d.ts +2 -0
- package/dist/pdf.js +17 -16
- package/dist/{plugin-CQmJXNcA.js → plugin-BWwIgZXV.js} +1 -1
- package/dist/{plugin-DSFu51Ua.cjs → plugin-Dg-J1Rbm.cjs} +1 -1
- package/dist/progress-7OSZbFok.js +39 -0
- package/dist/progress-BnLiS5eH.cjs +1 -0
- package/dist/render-plan-7xpGrCEl.cjs +1 -0
- package/dist/render-plan-Ck6koX9L.js +13 -0
- package/dist/server/node.d.cts +62 -0
- package/dist/server/node.d.ts +62 -0
- package/dist/server-node.cjs +1 -1
- package/dist/server-node.js +373 -145
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +311 -0
- package/dist/server.d.ts +311 -0
- package/dist/server.js +590 -186
- package/dist/{style-Dv5o_x6b.js → style-CQ1PK8ZB.js} +5 -5
- package/dist/style-UgIJSA1F.cjs +1 -0
- package/dist/style.css +1 -1
- package/dist/template-registry-CHMYZ7SD.cjs +1 -0
- package/dist/template-registry-R61AMCr0.js +433 -0
- package/dist/template-review-hvWWQFsi.js +1027 -0
- package/dist/template-review-jEcOfmGr.cjs +1 -0
- package/dist/textwrap-CWHyzkBH.cjs +4 -0
- package/dist/{textwrap-DOl04hCQ.js → textwrap-DE1kgcJB.js} +1 -1
- package/dist/{validate-DfHPD8wX.cjs → validate-BDiMqkJC.cjs} +1 -1
- package/dist/{validate-S6CgIm5d.js → validate-DWPF7icl.js} +13 -13
- package/dist/vue/async.d.cts +186 -0
- package/dist/vue/async.d.ts +186 -0
- package/dist/vue/index.d.cts +271 -3
- package/dist/vue/index.d.ts +271 -3
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +3 -3
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +4 -4
- package/dist/worker.cjs +1 -1
- package/dist/worker.d.cts +2 -0
- package/dist/worker.d.ts +2 -0
- package/dist/worker.js +1 -1
- package/dist/xlsx.cjs +2 -30
- package/dist/xlsx.d.cts +268 -0
- package/dist/xlsx.d.ts +268 -0
- package/dist/xlsx.js +220 -23440
- package/package.json +1 -1
- package/dist/ReportPreview-DjGeWHY-.cjs +0 -6
- package/dist/progress-DD964VAB.js +0 -102
- package/dist/progress-KvhwXZ1Q.cjs +0 -1
- package/dist/render-plan-CckPEQyf.cjs +0 -1
- package/dist/render-plan-uzZYYSy1.js +0 -19
- package/dist/report-source-BXHNy_AD.js +0 -755
- package/dist/report-source-CCAvFE3t.cjs +0 -1
- package/dist/style-CpwiOPyB.cjs +0 -1
- package/dist/template-registry-DWExx0gU.cjs +0 -1
- package/dist/template-registry-NpOakidD.js +0 -354
- package/dist/textwrap-CnGsEum6.cjs +0 -4
package/dist/analytics.d.ts
CHANGED
|
@@ -1,3 +1,32 @@
|
|
|
1
|
+
export declare function addDecimal(a: DecimalValue, b: DecimalValue): DecimalValue;
|
|
2
|
+
|
|
3
|
+
export declare interface AggregateAccumulator {
|
|
4
|
+
add(row: Readonly<Record<string, unknown>>): void;
|
|
5
|
+
value(): number | string | null;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export declare interface AggregateDefinition {
|
|
9
|
+
/** Output column; valueField defaults to this field. */
|
|
10
|
+
field: string;
|
|
11
|
+
op: AggregateOperation;
|
|
12
|
+
valueField?: string;
|
|
13
|
+
weightField?: string;
|
|
14
|
+
numeric?: "number" | "decimal";
|
|
15
|
+
digits?: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export declare type AggregateOperation = "sum" | "count" | "avg" | "min" | "max" | "weightedAvg";
|
|
19
|
+
|
|
20
|
+
export declare interface AggregateRequest {
|
|
21
|
+
op: AggregateOperation;
|
|
22
|
+
field?: string;
|
|
23
|
+
weightField?: string;
|
|
24
|
+
numeric?: "number" | "decimal";
|
|
25
|
+
digits?: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export declare function aggregateRows(rows: readonly Record<string, unknown>[], request: AggregateRequest): number | string | null;
|
|
29
|
+
|
|
1
30
|
/**
|
|
2
31
|
* 列值格式化(声明式、JSON 可序列化)。
|
|
3
32
|
* 在 paginate 的 cellText 出口统一消费:格式化发生在进 RenderPlan 之前,
|
|
@@ -21,6 +50,8 @@ declare type ColumnFormat = {
|
|
|
21
50
|
pattern?: string;
|
|
22
51
|
};
|
|
23
52
|
|
|
53
|
+
export declare function compareDecimal(a: DecimalValue, b: DecimalValue): number;
|
|
54
|
+
|
|
24
55
|
declare type ComponentKind = "text" | "image" | "barcode" | "qrcode" | "chart" | "line" | "rect" | "ellipse";
|
|
25
56
|
|
|
26
57
|
declare interface ComponentStyle {
|
|
@@ -53,7 +84,14 @@ export declare interface ComputationIssue {
|
|
|
53
84
|
message: string;
|
|
54
85
|
}
|
|
55
86
|
|
|
56
|
-
|
|
87
|
+
export declare interface ComputationValidation {
|
|
88
|
+
valid: boolean;
|
|
89
|
+
errors: string[];
|
|
90
|
+
fields: ComputedFieldDiagnostic[];
|
|
91
|
+
order: string[];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Topologically ordered column passes keep aggregate dependencies correct and avoid quadratic group scans. */
|
|
57
95
|
export declare function computeDataset(input: readonly Record<string, unknown>[], options: ComputedDatasetOptions): {
|
|
58
96
|
rows: Record<string, unknown>[];
|
|
59
97
|
issues: ComputationIssue[];
|
|
@@ -63,30 +101,51 @@ export declare interface ComputedDatasetOptions {
|
|
|
63
101
|
fields: readonly ComputedField[];
|
|
64
102
|
formula?: FormulaAdapter;
|
|
65
103
|
maxRows?: number;
|
|
66
|
-
/** Calculated cells (rows × fields), default 2 million; at most 2048 field definitions. */
|
|
67
104
|
maxCells?: number;
|
|
68
105
|
signal?: AbortSignal;
|
|
69
106
|
onError?: "throw" | "null";
|
|
70
107
|
}
|
|
71
108
|
|
|
72
|
-
export declare interface ComputedField {
|
|
109
|
+
export declare interface ComputedField extends ExpressionOptions {
|
|
73
110
|
field: string;
|
|
74
111
|
expression: ReportExpression | string;
|
|
112
|
+
/** Scope controls aggregate inputs; row expressions may reference the current row in any scope. */
|
|
113
|
+
scope?: "row" | "group" | "dataset";
|
|
114
|
+
groupBy?: readonly string[];
|
|
115
|
+
/** String adapter expressions cannot be inspected; declare dependencies explicitly. */
|
|
116
|
+
dependsOn?: readonly string[];
|
|
75
117
|
}
|
|
76
118
|
|
|
119
|
+
export declare interface ComputedFieldDiagnostic {
|
|
120
|
+
field: string;
|
|
121
|
+
dependencies: string[];
|
|
122
|
+
scope: "row" | "group" | "dataset";
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** Nulls are skipped; count with no field counts rows, all-null numeric aggregates stay null. */
|
|
126
|
+
export declare function createAggregateAccumulator(request: AggregateRequest): AggregateAccumulator;
|
|
127
|
+
|
|
77
128
|
/** 轻量柱/折线图展开为共用基础图元,无外部图表依赖,DOM/Canvas/PDF 使用同一计划。 */
|
|
78
129
|
export declare function createChartComponents(options: ReportChartOptions): PlanComponent[];
|
|
79
130
|
|
|
80
131
|
/** 通用交叉聚合;合计直接累计原始度量,平均值不会错误地平均各分组合计。 */
|
|
81
132
|
export declare function createCrossTable(input: readonly Record<string, unknown>[], options: CrossTableOptions): CrossTableResult;
|
|
82
133
|
|
|
134
|
+
/** Multi-dimension/multi-measure pivot; each total aggregates original rows, never averages averages. */
|
|
135
|
+
export declare function createMatrixTable(input: readonly Record<string, unknown>[], options: MatrixTableOptions): CrossTableResult;
|
|
136
|
+
|
|
83
137
|
export declare interface CrossTableOptions {
|
|
84
138
|
rowField: string;
|
|
85
139
|
columnField: string;
|
|
86
140
|
valueField?: string;
|
|
87
|
-
aggregate?:
|
|
141
|
+
aggregate?: AggregateOperation;
|
|
142
|
+
weightField?: string;
|
|
143
|
+
numeric?: "number" | "decimal";
|
|
144
|
+
digits?: number;
|
|
88
145
|
totals?: boolean;
|
|
89
146
|
rowHeader?: string;
|
|
147
|
+
/** Existing count defaults to row counts; opt-in SQL COUNT(field) skips nulls. */
|
|
148
|
+
countMode?: "rows" | "nonNull";
|
|
90
149
|
maxRows?: number;
|
|
91
150
|
maxColumns?: number;
|
|
92
151
|
maxInputRows?: number;
|
|
@@ -99,14 +158,94 @@ export declare interface CrossTableResult {
|
|
|
99
158
|
rows: Record<string, unknown>[];
|
|
100
159
|
}
|
|
101
160
|
|
|
161
|
+
export declare function decimalDigits(digits: number): void;
|
|
162
|
+
|
|
163
|
+
/** Bounded base-ten arithmetic. Decimal strings never pass through IEEE-754 numbers. */
|
|
164
|
+
export declare interface DecimalValue {
|
|
165
|
+
coefficient: bigint;
|
|
166
|
+
scale: number;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export declare function divideDecimal(a: DecimalValue, b: DecimalValue, digits?: number): DecimalValue;
|
|
170
|
+
|
|
171
|
+
/** Cardinality pass checks expansion budgets before allocating the dense pivot output. */
|
|
172
|
+
export declare function estimateMatrixTable(input: readonly Record<string, unknown>[], options: MatrixTableOptions): MatrixTableShape;
|
|
173
|
+
|
|
174
|
+
declare interface ExpressionOptions {
|
|
175
|
+
numeric?: "number" | "decimal";
|
|
176
|
+
digits?: number;
|
|
177
|
+
nulls?: "propagate" | "error";
|
|
178
|
+
divisionByZero?: "null" | "error";
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** Formats decimal data exactly while preserving it as text in Excel. */
|
|
182
|
+
export declare function formatDecimal(input: string, digits?: number, thousands?: boolean, percent?: boolean): string;
|
|
183
|
+
|
|
102
184
|
export declare interface FormulaAdapter {
|
|
103
|
-
/**
|
|
185
|
+
/** Explicit trusted engine; core never evaluates source code/macros/external workbook references. */
|
|
104
186
|
evaluate(expression: string, context: {
|
|
105
187
|
row: Readonly<Record<string, unknown>>;
|
|
106
188
|
rowIndex: number;
|
|
189
|
+
rows: readonly Record<string, unknown>[];
|
|
107
190
|
}): unknown;
|
|
108
191
|
}
|
|
109
192
|
|
|
193
|
+
export declare function getComputationMetadata(fields?: readonly {
|
|
194
|
+
field: string;
|
|
195
|
+
type: string;
|
|
196
|
+
label?: string;
|
|
197
|
+
}[]): {
|
|
198
|
+
fields: {
|
|
199
|
+
field: string;
|
|
200
|
+
type: string;
|
|
201
|
+
label?: string;
|
|
202
|
+
}[];
|
|
203
|
+
functions: readonly [{
|
|
204
|
+
readonly name: "add";
|
|
205
|
+
readonly minArgs: 2;
|
|
206
|
+
readonly maxArgs: 256;
|
|
207
|
+
readonly input: "numeric";
|
|
208
|
+
readonly output: "numeric";
|
|
209
|
+
}, {
|
|
210
|
+
readonly name: "subtract";
|
|
211
|
+
readonly minArgs: 2;
|
|
212
|
+
readonly maxArgs: 2;
|
|
213
|
+
readonly input: "numeric";
|
|
214
|
+
readonly output: "numeric";
|
|
215
|
+
}, {
|
|
216
|
+
readonly name: "multiply";
|
|
217
|
+
readonly minArgs: 2;
|
|
218
|
+
readonly maxArgs: 256;
|
|
219
|
+
readonly input: "numeric";
|
|
220
|
+
readonly output: "numeric";
|
|
221
|
+
}, {
|
|
222
|
+
readonly name: "divide";
|
|
223
|
+
readonly minArgs: 2;
|
|
224
|
+
readonly maxArgs: 2;
|
|
225
|
+
readonly input: "numeric";
|
|
226
|
+
readonly output: "numeric";
|
|
227
|
+
}, {
|
|
228
|
+
readonly name: "coalesce";
|
|
229
|
+
readonly minArgs: 2;
|
|
230
|
+
readonly maxArgs: 256;
|
|
231
|
+
readonly input: "scalar";
|
|
232
|
+
readonly output: "scalar";
|
|
233
|
+
}];
|
|
234
|
+
operations: readonly ["add", "subtract", "multiply", "divide", "coalesce"];
|
|
235
|
+
aggregates: readonly ["sum", "count", "avg", "min", "max", "weightedAvg"];
|
|
236
|
+
scopes: readonly ["row", "group", "dataset"];
|
|
237
|
+
numericModes: readonly ["number", "decimal"];
|
|
238
|
+
rules: {
|
|
239
|
+
readonly nulls: "propagate";
|
|
240
|
+
readonly aggregateNulls: "skip";
|
|
241
|
+
readonly emptyAggregate: null;
|
|
242
|
+
readonly countEmpty: 0;
|
|
243
|
+
readonly divisionByZero: "error";
|
|
244
|
+
readonly decimalOutput: "string";
|
|
245
|
+
readonly rounding: "half-away-from-zero";
|
|
246
|
+
};
|
|
247
|
+
};
|
|
248
|
+
|
|
110
249
|
declare interface GridCell {
|
|
111
250
|
text?: string;
|
|
112
251
|
rawText?: string;
|
|
@@ -151,9 +290,40 @@ declare interface ListColumn {
|
|
|
151
290
|
valueType?: GridCell["valueType"];
|
|
152
291
|
/** 字段语义用于 auto 对齐;明确声明编号,避免把数字编号当成度量。 */
|
|
153
292
|
semanticRole?: "identifier" | "dimension" | "measure" | "date" | "text";
|
|
293
|
+
hidden?: boolean;
|
|
294
|
+
/** Condition hides cell content, preserving its physical layout in preview and exports. */
|
|
295
|
+
visibleWhen?: StyleRule["when"];
|
|
154
296
|
}
|
|
155
297
|
|
|
298
|
+
export declare interface MatrixTableOptions {
|
|
299
|
+
rowFields: readonly string[];
|
|
300
|
+
columnFields: readonly string[];
|
|
301
|
+
measures: readonly (AggregateDefinition & {
|
|
302
|
+
label?: string;
|
|
303
|
+
})[];
|
|
304
|
+
totals?: boolean;
|
|
305
|
+
rowHeader?: string;
|
|
306
|
+
columnWidthMm?: number;
|
|
307
|
+
rowWidthMm?: number;
|
|
308
|
+
maxRows?: number;
|
|
309
|
+
maxColumns?: number;
|
|
310
|
+
maxInputRows?: number;
|
|
311
|
+
maxCells?: number;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
export declare interface MatrixTableShape {
|
|
315
|
+
rowCount: number;
|
|
316
|
+
columnCount: number;
|
|
317
|
+
cells: number;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
export declare function multiplyDecimal(a: DecimalValue, b: DecimalValue): DecimalValue;
|
|
321
|
+
|
|
322
|
+
export declare function parseDecimal(input: unknown): DecimalValue;
|
|
323
|
+
|
|
156
324
|
declare interface PlanComponent {
|
|
325
|
+
/** Template page furniture repeats per page and reserves its vertical band. */
|
|
326
|
+
pageAnchor?: "header" | "footer";
|
|
157
327
|
kind: ComponentKind;
|
|
158
328
|
leftMm: number;
|
|
159
329
|
topMm: number;
|
|
@@ -203,6 +373,8 @@ declare interface PlanTableFragment {
|
|
|
203
373
|
};
|
|
204
374
|
}
|
|
205
375
|
|
|
376
|
+
export declare function printDecimal(value: DecimalValue, digits?: number): string;
|
|
377
|
+
|
|
206
378
|
/** 可持久化的业务身份与计划坐标独立;权限及并发校验仍由业务服务器执行。 */
|
|
207
379
|
declare interface ReportCellSource {
|
|
208
380
|
datasetId: string;
|
|
@@ -234,6 +406,10 @@ export declare type ReportExpression = {
|
|
|
234
406
|
field: string;
|
|
235
407
|
} | {
|
|
236
408
|
value: string | number | boolean | null;
|
|
409
|
+
} | {
|
|
410
|
+
aggregate: AggregateOperation;
|
|
411
|
+
field?: string;
|
|
412
|
+
weightField?: string;
|
|
237
413
|
} | {
|
|
238
414
|
op: "add" | "subtract" | "multiply" | "divide" | "coalesce";
|
|
239
415
|
args: readonly ReportExpression[];
|
|
@@ -261,6 +437,8 @@ declare interface StyleRule {
|
|
|
261
437
|
field: string;
|
|
262
438
|
op: ">" | ">=" | "<" | "<=" | "==" | "!=";
|
|
263
439
|
value: number | string;
|
|
440
|
+
/** Explicit decimal comparisons retain decimal thresholds as text. */
|
|
441
|
+
numeric?: "number" | "decimal";
|
|
264
442
|
};
|
|
265
443
|
/** 命中时合并进单元格样式(color/bold/backgroundColor 等) */
|
|
266
444
|
style: Record<string, unknown>;
|
|
@@ -273,4 +451,9 @@ declare type TableTemplateColumn = Omit<ListColumn, "widthMm"> & {
|
|
|
273
451
|
flex?: number;
|
|
274
452
|
};
|
|
275
453
|
|
|
454
|
+
/** Design-time validation: no input data, adapters, evaluation or DOM required. */
|
|
455
|
+
export declare function validateComputedFields(definitions: readonly ComputedField[]): ComputationValidation;
|
|
456
|
+
|
|
457
|
+
export declare function validateMatrixOptions(options: MatrixTableOptions): void;
|
|
458
|
+
|
|
276
459
|
export { }
|
package/dist/analytics.js
CHANGED
|
@@ -1,223 +1,89 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { a as A, b as S, c as z, d as F, e as N, f as R, g as T, h as W, i as B, j as G, k as L, l as O, m as P, p as $, n as j, v as V, o as q } from "./matrix-CNPDJxED.js";
|
|
2
|
+
const u = ["#2563eb", "#0d9488", "#d97706", "#7c3aed", "#dc2626", "#0284c7"];
|
|
3
|
+
function w(e) {
|
|
3
4
|
if (e.type !== "bar" && e.type !== "line") throw new Error("图表 type 应为 bar 或 line");
|
|
4
5
|
if (!Array.isArray(e.categories) || !Array.isArray(e.series) || !e.categories.length || e.categories.length > 200 || !e.series.length || e.series.length > 12) throw new Error("图表支持 1–200 个分类、1–12 个系列;大数据应先聚合");
|
|
5
|
-
if (e.categories.some((
|
|
6
|
-
|
|
7
|
-
for (const
|
|
6
|
+
if (e.categories.some((t) => typeof t != "string")) throw new Error("图表分类应为字符串");
|
|
7
|
+
b(e);
|
|
8
|
+
for (const t of e.series) y(t, e.categories.length);
|
|
8
9
|
}
|
|
9
|
-
function
|
|
10
|
-
for (const
|
|
11
|
-
if (!Number.isFinite(e[
|
|
10
|
+
function b(e) {
|
|
11
|
+
for (const t of ["leftMm", "topMm", "widthMm", "heightMm"])
|
|
12
|
+
if (!Number.isFinite(e[t]) || e[t] < 0) throw new Error(`${t} 应为有限非负数`);
|
|
12
13
|
if (e.widthMm < 45 || e.heightMm < 35) throw new Error("图表至少需要 45×35mm");
|
|
13
14
|
if (!Number.isFinite(e.leftMm + e.widthMm) || !Number.isFinite(e.topMm + e.heightMm)) throw new Error("图表几何范围溢出");
|
|
14
15
|
}
|
|
15
|
-
function
|
|
16
|
-
if (!e || typeof e.name != "string" || !Array.isArray(e.values) || e.values.length !==
|
|
16
|
+
function y(e, t) {
|
|
17
|
+
if (!e || typeof e.name != "string" || !Array.isArray(e.values) || e.values.length !== t || e.values.some((r) => r !== null && !Number.isFinite(r))) throw new Error("图表系列应提供名称及逐分类的有限数字或 null");
|
|
17
18
|
if (e.color !== void 0 && !/^#[\da-f]{6}$/i.test(e.color)) throw new Error("图表颜色应为 #RRGGBB");
|
|
18
19
|
}
|
|
19
|
-
function
|
|
20
|
-
return { kind: "line", leftMm: Math.min(e,
|
|
20
|
+
function d(e, t, r, l, h, a = 0.8) {
|
|
21
|
+
return { kind: "line", leftMm: Math.min(e, r), topMm: Math.min(t, l), widthMm: Math.abs(r - e), heightMm: Math.abs(l - t), lineDirection: l < t ? "up" : "down", style: { lineColor: h, lineWidthPt: a } };
|
|
21
22
|
}
|
|
22
|
-
function
|
|
23
|
-
return { kind: "text", text: e, leftMm:
|
|
23
|
+
function M(e, t, r, l, h = "center") {
|
|
24
|
+
return { kind: "text", text: e, leftMm: t, topMm: r, widthMm: l, heightMm: 5, style: { fontSize: 8, color: "#475569", align: h, verticalAlign: "middle" } };
|
|
24
25
|
}
|
|
25
|
-
function
|
|
26
|
+
function o(e) {
|
|
26
27
|
return Number(e.toPrecision(5)).toString();
|
|
27
28
|
}
|
|
28
|
-
function
|
|
29
|
-
let
|
|
30
|
-
for (const
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
return { left:
|
|
34
|
-
}
|
|
35
|
-
function
|
|
36
|
-
const
|
|
37
|
-
e.title &&
|
|
38
|
-
for (let
|
|
39
|
-
const
|
|
40
|
-
|
|
29
|
+
function k(e) {
|
|
30
|
+
let t = 0, r = 0;
|
|
31
|
+
for (const s of e.series) for (const m of s.values) m !== null && (t = Math.min(t, m), r = Math.max(r, m));
|
|
32
|
+
t === r && (r = t + 1);
|
|
33
|
+
const l = e.leftMm + 13, h = e.topMm + 8, a = e.widthMm - 17, i = e.heightMm - 23, n = Math.max(Math.abs(t), Math.abs(r), 1), c = t / n, g = r / n - c;
|
|
34
|
+
return { left: l, top: h, width: a, height: i, min: t, max: r, y: (s) => h + i * (1 - (s / n - c) / g) };
|
|
35
|
+
}
|
|
36
|
+
function v(e, t) {
|
|
37
|
+
const r = [];
|
|
38
|
+
e.title && r.push({ ...M(e.title, e.leftMm, e.topMm, e.widthMm), style: { fontSize: 10, bold: !0, align: "left" } });
|
|
39
|
+
for (let a = 0; a <= 4; a++) {
|
|
40
|
+
const i = a / 4, n = t.min * (1 - i) + t.max * i, c = t.y(n);
|
|
41
|
+
r.push(d(t.left, c, t.left + t.width, c, "#e2e8f0", 0.4), M(o(n), e.leftMm, c - 2.5, 11, "right"));
|
|
41
42
|
}
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
e.categories.forEach((
|
|
45
|
-
|
|
43
|
+
r.push(d(t.left, t.top, t.left, t.top + t.height, "#94a3b8"));
|
|
44
|
+
const l = Math.max(1, Math.ceil(e.categories.length / Math.max(1, Math.floor(t.width / 14))));
|
|
45
|
+
e.categories.forEach((a, i) => {
|
|
46
|
+
i % l === 0 && r.push(M(a, t.left + (i + 0.5) * t.width / e.categories.length - 7, t.top + t.height + 1, 14));
|
|
46
47
|
});
|
|
47
|
-
const
|
|
48
|
-
return e.series.forEach((
|
|
49
|
-
|
|
50
|
-
}),
|
|
51
|
-
}
|
|
52
|
-
function
|
|
53
|
-
const
|
|
54
|
-
let
|
|
55
|
-
return
|
|
56
|
-
if (
|
|
57
|
-
|
|
48
|
+
const h = t.width / e.series.length;
|
|
49
|
+
return e.series.forEach((a, i) => {
|
|
50
|
+
r.push({ ...M(a.name, t.left + i * h, e.topMm + e.heightMm - 5, h), style: { fontSize: 8, color: a.color ?? u[i % u.length], align: "center" } });
|
|
51
|
+
}), r;
|
|
52
|
+
}
|
|
53
|
+
function x(e, t, r, l) {
|
|
54
|
+
const h = [], a = r.color ?? u[l % u.length], i = t.width / e.categories.length, n = i * 0.75 / e.series.length;
|
|
55
|
+
let c;
|
|
56
|
+
return r.values.forEach((g, s) => {
|
|
57
|
+
if (g === null) {
|
|
58
|
+
c = void 0;
|
|
58
59
|
return;
|
|
59
60
|
}
|
|
60
|
-
const
|
|
61
|
-
e.type === "bar" ?
|
|
62
|
-
}),
|
|
63
|
-
}
|
|
64
|
-
function U(e) {
|
|
65
|
-
$(e);
|
|
66
|
-
const r = j(e);
|
|
67
|
-
return [...x(e, r), ...e.series.flatMap((t, n) => P(e, r, t, n))];
|
|
68
|
-
}
|
|
69
|
-
function y() {
|
|
70
|
-
return { count: 0, sum: 0, correction: 0, min: 1 / 0, max: -1 / 0 };
|
|
71
|
-
}
|
|
72
|
-
function w(e, r) {
|
|
73
|
-
return Object.prototype.hasOwnProperty.call(e, r) ? e[r] : void 0;
|
|
74
|
-
}
|
|
75
|
-
function A(e) {
|
|
76
|
-
if (e == null) return "null";
|
|
77
|
-
if (typeof e != "string" && typeof e != "boolean" && !(typeof e == "number" && Number.isFinite(e))) throw new Error("交叉表维度应为字符串、布尔、有限数字或空值");
|
|
78
|
-
return JSON.stringify([typeof e, e]);
|
|
79
|
-
}
|
|
80
|
-
function N(e) {
|
|
81
|
-
return e == null ? "" : String(e);
|
|
82
|
-
}
|
|
83
|
-
function W(e, r, t) {
|
|
84
|
-
const n = t === "count";
|
|
85
|
-
if (!n && r == null) return;
|
|
86
|
-
if (!n && (typeof r != "number" || !Number.isFinite(r))) throw new Error("交叉表度量必须是有限数字;编号和小数文本不能隐式转为数字");
|
|
87
|
-
const i = n ? 1 : r;
|
|
88
|
-
(t === "sum" || t === "avg") && _(e, i), e.count++, e.min = Math.min(e.min, i), e.max = Math.max(e.max, i);
|
|
89
|
-
}
|
|
90
|
-
function _(e, r) {
|
|
91
|
-
const t = r - e.correction, n = e.sum + t;
|
|
92
|
-
if (!Number.isFinite(n)) throw new Error("交叉表聚合溢出");
|
|
93
|
-
e.correction = n - e.sum - t, e.sum = n;
|
|
94
|
-
}
|
|
95
|
-
function b(e, r) {
|
|
96
|
-
return e?.count ? r === "count" ? e.count : r === "avg" ? e.sum / e.count : r === "sum" ? e.sum : e[r] : r === "count" ? 0 : null;
|
|
97
|
-
}
|
|
98
|
-
function M(e, r) {
|
|
99
|
-
const t = e ?? r;
|
|
100
|
-
if (!Number.isInteger(t) || t < 1) throw new Error("交叉表预算应为正整数");
|
|
101
|
-
return t;
|
|
102
|
-
}
|
|
103
|
-
function B(e, r, t, n) {
|
|
104
|
-
const i = t ? 1 : 0;
|
|
105
|
-
if ((e + i) * (r + 1 + i) > n) throw new Error("交叉表输出单元格超出 maxCells 预算,请减少维度或服务端预聚合");
|
|
106
|
-
}
|
|
107
|
-
function V(e, r) {
|
|
108
|
-
const t = r.aggregate ?? "sum";
|
|
109
|
-
if (!["sum", "count", "avg", "min", "max"].includes(t)) throw new Error("未知交叉表聚合类型");
|
|
110
|
-
if (!r.rowField || !r.columnField || t !== "count" && !r.valueField) throw new Error("交叉表需要明确的行维度、列维度和度量字段");
|
|
111
|
-
if (e.length > M(r.maxInputRows, 1e5)) throw new Error("交叉表输入超出预算,请在服务端预聚合");
|
|
112
|
-
const n = M(r.maxRows, 1e3), i = M(r.maxColumns, 200), l = M(r.maxCells, 2e6), c = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), u = y();
|
|
113
|
-
for (const a of e) {
|
|
114
|
-
const m = A(w(a, r.rowField)), s = A(w(a, r.columnField));
|
|
115
|
-
if (c.has(s) || c.set(s, N(w(a, r.columnField))), f.has(m) || f.set(m, { label: N(w(a, r.rowField)), cells: /* @__PURE__ */ new Map(), total: y() }), c.size > i || f.size > n) throw new Error("交叉表维度数量超出预算");
|
|
116
|
-
B(f.size, c.size, r.totals, l);
|
|
117
|
-
const g = f.get(m);
|
|
118
|
-
g.cells.has(s) || g.cells.set(s, y()), o.has(s) || o.set(s, y());
|
|
119
|
-
const k = r.valueField ? w(a, r.valueField) : void 0;
|
|
120
|
-
for (const R of [g.cells.get(s), g.total, o.get(s), u]) W(R, k, t);
|
|
121
|
-
}
|
|
122
|
-
const h = {
|
|
123
|
-
columns: [{ header: r.rowHeader ?? r.rowField, field: "rowLabel", semanticRole: "dimension" }, ...[...c.values()].map((a, m) => ({ header: a, field: `c${m}`, semanticRole: "measure" }))],
|
|
124
|
-
rows: [...f.values()].map((a) => ({ rowLabel: a.label, ...Object.fromEntries([...c.keys()].map((m, s) => [`c${s}`, b(a.cells.get(m), t)])), ...r.totals ? { total: b(a.total, t) } : {} }))
|
|
125
|
-
};
|
|
126
|
-
return r.totals && (h.columns.push({ header: "合计", field: "total", semanticRole: "measure" }), e.length && h.rows.push({ rowLabel: "合计", ...Object.fromEntries([...c.keys()].map((a, m) => [`c${m}`, b(o.get(a), t)])), total: b(u, t) })), h;
|
|
61
|
+
const m = t.left + (s + 0.5) * i, f = t.y(g);
|
|
62
|
+
e.type === "bar" ? h.push({ kind: "rect", leftMm: t.left + s * i + i * 0.125 + l * n, topMm: Math.min(f, t.y(0)), widthMm: n, heightMm: Math.abs(t.y(0) - f), style: { backgroundColor: a, borderTop: !1, borderRight: !1, borderBottom: !1, borderLeft: !1 } }) : (c && h.push(d(c.x, c.y, m, f, a, 1.2)), h.push({ kind: "ellipse", leftMm: m - 0.7, topMm: f - 0.7, widthMm: 1.4, heightMm: 1.4, style: { backgroundColor: a, borderColor: a } }), c = { x: m, y: f }), e.showValues && h.push({ ...M(o(g), m - i / 2, Math.max(t.top, f - 5), i), style: { fontSize: 7, color: a, align: "center" } });
|
|
63
|
+
}), h;
|
|
127
64
|
}
|
|
128
|
-
const G = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
129
65
|
function C(e) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
return e === null || ["string", "boolean"].includes(typeof e) || typeof e == "number" && Number.isFinite(e);
|
|
134
|
-
}
|
|
135
|
-
function I(e) {
|
|
136
|
-
if (e.some((r) => typeof r != "number" || !Number.isFinite(r))) throw new Error("算术参数必须是有限数字;空值和小数文本不会隐式转换");
|
|
137
|
-
return e;
|
|
138
|
-
}
|
|
139
|
-
function J(e, r) {
|
|
140
|
-
const t = I(r);
|
|
141
|
-
let n;
|
|
142
|
-
if (e === "add") n = t.reduce((i, l) => i + l, 0);
|
|
143
|
-
else if (e === "multiply") n = t.reduce((i, l) => i * l, 1);
|
|
144
|
-
else if (e === "subtract") n = t[0] - t[1];
|
|
145
|
-
else {
|
|
146
|
-
if (t[1] === 0) throw new Error("不能除以零");
|
|
147
|
-
n = t[0] / t[1];
|
|
148
|
-
}
|
|
149
|
-
if (!Number.isFinite(n)) throw new Error("计算结果不是有限数字");
|
|
150
|
-
return n;
|
|
151
|
-
}
|
|
152
|
-
function O(e, r, t = 0) {
|
|
153
|
-
if (++r.nodes > 256 || t > 16) throw new Error("计算表达式超出深度或节点预算");
|
|
154
|
-
if (!e || typeof e != "object" || Array.isArray(e)) throw new Error("计算表达式应为声明式对象");
|
|
155
|
-
if ("field" in e) {
|
|
156
|
-
C(e.field);
|
|
157
|
-
const i = e.field;
|
|
158
|
-
return (l) => Object.prototype.hasOwnProperty.call(l, i) ? l[i] : void 0;
|
|
159
|
-
}
|
|
160
|
-
if ("value" in e) {
|
|
161
|
-
if (!v(e.value)) throw new Error("常量应为有限 JSON 标量");
|
|
162
|
-
return () => e.value;
|
|
163
|
-
}
|
|
164
|
-
if (!["add", "subtract", "multiply", "divide", "coalesce"].includes(e.op) || !Array.isArray(e.args)) throw new Error("未知计算操作");
|
|
165
|
-
if (e.args.length < 2 || ["subtract", "divide"].includes(e.op) && e.args.length !== 2) throw new Error("运算参数数量不正确");
|
|
166
|
-
const n = e.args.map((i) => O(i, r, t + 1));
|
|
167
|
-
return e.op === "coalesce" ? (i, l) => T(n, i, l) : (i, l) => J(e.op, n.map((c) => c(i, l)));
|
|
168
|
-
}
|
|
169
|
-
function T(e, r, t) {
|
|
170
|
-
for (const n of e) {
|
|
171
|
-
const i = n(r, t);
|
|
172
|
-
if (i != null) return i;
|
|
173
|
-
}
|
|
174
|
-
return null;
|
|
175
|
-
}
|
|
176
|
-
function D(e) {
|
|
177
|
-
const r = /* @__PURE__ */ new Set();
|
|
178
|
-
return e.fields.map((t) => {
|
|
179
|
-
if (C(t.field), r.has(t.field)) throw new Error(`计算字段重复:${t.field}`);
|
|
180
|
-
r.add(t.field);
|
|
181
|
-
const n = t.expression;
|
|
182
|
-
let i;
|
|
183
|
-
if (typeof n == "string") {
|
|
184
|
-
if (!e.formula) throw new Error("字符串公式需要显式配置 formula adapter");
|
|
185
|
-
i = (l, c) => e.formula.evaluate(n, { row: l, rowIndex: c });
|
|
186
|
-
} else i = O(n, { nodes: 0 });
|
|
187
|
-
return { field: t.field, read: i };
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
function H(e, r) {
|
|
191
|
-
const t = r.maxRows ?? 1e5, n = r.maxCells ?? 2e6;
|
|
192
|
-
if (!Array.isArray(e) || !Number.isSafeInteger(t) || t < 1 || e.length > t) throw new Error("计算数据行数超出预算或输入不是数组");
|
|
193
|
-
if (!Array.isArray(r.fields) || r.fields.length > 2048) throw new Error("计算字段应为数组且最多2048项");
|
|
194
|
-
if (!Number.isSafeInteger(n) || n < 1 || e.length * r.fields.length > n) throw new Error("计算单元格超出 maxCells 预算");
|
|
195
|
-
}
|
|
196
|
-
function q(e, r) {
|
|
197
|
-
H(e, r);
|
|
198
|
-
const t = D(r), n = [];
|
|
199
|
-
return { rows: e.map((l, c) => {
|
|
200
|
-
if (!l || typeof l != "object" || Array.isArray(l)) throw new Error(`第 ${c + 1} 行应为对象`);
|
|
201
|
-
if (r.signal?.aborted) {
|
|
202
|
-
const o = new Error("数据计算已取消");
|
|
203
|
-
throw o.name = "AbortError", o;
|
|
204
|
-
}
|
|
205
|
-
const f = { ...l };
|
|
206
|
-
for (const o of t)
|
|
207
|
-
try {
|
|
208
|
-
const u = o.read(f, c);
|
|
209
|
-
if (u !== void 0 && !v(u)) throw new Error("计算结果应为有限 JSON 标量,异步公式请先在数据源中求值");
|
|
210
|
-
f[o.field] = u ?? null;
|
|
211
|
-
} catch (u) {
|
|
212
|
-
const h = u instanceof Error ? u.message : String(u);
|
|
213
|
-
if (r.onError !== "null") throw Object.assign(new Error(`第 ${c + 1} 行 ${o.field}:${h}`), { cause: u });
|
|
214
|
-
f[o.field] = null, n.push({ rowIndex: c, field: o.field, message: h });
|
|
215
|
-
}
|
|
216
|
-
return f;
|
|
217
|
-
}), issues: n };
|
|
66
|
+
w(e);
|
|
67
|
+
const t = k(e);
|
|
68
|
+
return [...v(e, t), ...e.series.flatMap((r, l) => x(e, t, r, l))];
|
|
218
69
|
}
|
|
219
70
|
export {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
71
|
+
A as addDecimal,
|
|
72
|
+
S as aggregateRows,
|
|
73
|
+
z as compareDecimal,
|
|
74
|
+
F as computeDataset,
|
|
75
|
+
N as createAggregateAccumulator,
|
|
76
|
+
C as createChartComponents,
|
|
77
|
+
R as createCrossTable,
|
|
78
|
+
T as createMatrixTable,
|
|
79
|
+
W as decimalDigits,
|
|
80
|
+
B as divideDecimal,
|
|
81
|
+
G as estimateMatrixTable,
|
|
82
|
+
L as formatDecimal,
|
|
83
|
+
O as getComputationMetadata,
|
|
84
|
+
P as multiplyDecimal,
|
|
85
|
+
$ as parseDecimal,
|
|
86
|
+
j as printDecimal,
|
|
87
|
+
V as validateComputedFields,
|
|
88
|
+
q as validateMatrixOptions
|
|
223
89
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { d as v, c as k, e as S } from "./style-
|
|
2
|
-
import { n as x } from "./capabilities-
|
|
3
|
-
import { w as y } from "./progress-
|
|
1
|
+
import { d as v, c as k, e as S } from "./style-CQ1PK8ZB.js";
|
|
2
|
+
import { n as x } from "./capabilities-Cm9hZ3uV.js";
|
|
3
|
+
import { w as y } from "./progress-7OSZbFok.js";
|
|
4
4
|
const A = ["borderTop", "borderRight", "borderBottom", "borderLeft", "borderColor", "lineColor", "lineWidthPt"];
|
|
5
5
|
function O(n, e) {
|
|
6
6
|
const t = v(e.style), r = t.inner ? [...n.edges] : [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const m=require("./style-
|
|
1
|
+
"use strict";const m=require("./style-UgIJSA1F.cjs"),k=require("./capabilities-DYzWL7KS.cjs"),E=require("./progress-BnLiS5eH.cjs"),S=["borderTop","borderRight","borderBottom","borderLeft","borderColor","lineColor","lineWidthPt"];function y(n,e){const t=m.resolveBoxBorders(e.style),r=t.inner?[...n.edges]:[];t.top&&r.push({kind:"h",pos:0,from:0,to:e.widthMm}),t.bottom&&r.push({kind:"h",pos:e.heightMm,from:0,to:e.widthMm}),t.left&&r.push({kind:"v",pos:0,from:0,to:e.heightMm}),t.right&&r.push({kind:"v",pos:e.widthMm,from:0,to:e.heightMm});const o=m.resolveStroke(e.style);return r.map(s=>({...s,...o}))}function x(n,e,t){const r=n.get(e);(!r||t.widthPt>r.widthPt)&&n.set(e,t)}function w(n,e,t,r,o,s){const i=t<e.rows.length?e.rows[t].pos:e.rows[e.rows.length-1].pos+e.rows[e.rows.length-1].size;for(let c=r;c<o;c++){const d=e.columns[c];x(n,`h:${t}:${c}`,{kind:"h",pos:i,from:d.pos,to:d.pos+d.size,...s})}}function b(n,e,t,r,o,s){const i=t<e.columns.length?e.columns[t].pos:e.columns[e.columns.length-1].pos+e.columns[e.columns.length-1].size;for(let c=r;c<o;c++){const d=e.rows[c];x(n,`v:${t}:${c}`,{kind:"v",pos:i,from:d.pos,to:d.pos+d.size,...s})}}function v(n,e,t,r){const o=Math.min(e.columns.length,t.ci+(t.cell.colSpan??1)),s=Math.min(e.rows.length,t.ri+(t.cell.rowSpan??1)),i=m.mergeComponentStyles(r,t.cell.style),c=m.resolveBoxBorders(i),d=m.resolveStroke(i);c.top&&w(n,e,t.ri,t.ci,o,d),c.bottom&&w(n,e,s,t.ci,o,d),c.left&&b(n,e,t.ci,t.ri,s,d),c.right&&b(n,e,o,t.ri,s,d)}function A(n){const e=[...n.values()].sort((r,o)=>r.kind.localeCompare(o.kind)||r.pos-o.pos||r.from-o.from),t=[];for(const r of e){const o=t[t.length-1];o&&o.kind===r.kind&&o.pos===r.pos&&Math.abs(o.to-r.from)<1e-6&&o.color===r.color&&o.widthPt===r.widthPt?o.to=r.to:t.push({...r})}return t}function B(n,e){if(!n.cells.some(({cell:s})=>S.some(i=>s.style?.[i]!==void 0)))return y(n,e);const t=new Map,r=new Set,o=n.columns.length;for(const s of n.cells){v(t,n,s,e.style);const i=Math.min(n.rows.length,s.ri+(s.cell.rowSpan??1)),c=Math.min(o,s.ci+(s.cell.colSpan??1));for(let d=s.ri;d<i;d++)for(let a=s.ci;a<c;a++)r.add(d*o+a)}for(let s=0;s<n.rows.length;s++)for(let i=0;i<o;i++)r.has(s*o+i)||v(t,n,{ri:s,ci:i,cell:{}},e.style);return A(t)}class p extends Error{constructor(e,t){super(e.message),this.name="OutputAssetError",this.diagnostic=e,this.cause=t}}function f(n){if(n.aborted)throw n.reason??new DOMException("The operation was aborted.","AbortError")}function O(n){const e={maxAssets:1e3,maxImageBytes:33554432,maxTotalImageBytes:134217728,maxDurationMs:3e4,...n.assetBudget};for(const[t,r]of Object.entries(e))if(!Number.isSafeInteger(r)||r<=0||r>2147483647)throw new RangeError(`${t} must be a positive safe integer at most 2147483647.`);return e}function P(n){const e=/^data:image\/[a-z0-9.+-]+(;base64)?,(.*)$/is.exec(n);if(!e)throw new TypeError("Asset renderers must return an image data URL.");return e[1]?Math.ceil(e[2].length*3/4):new TextEncoder().encode(decodeURIComponent(e[2])).byteLength}function h(n,e,t,r,o){const s={code:t,message:r,severity:"warning",format:n.options.format??"dom",pageIndex:e.pageIndex,componentIndex:e.componentIndex,componentPath:e.componentPath,kind:e.component.kind,nid:e.component.nid};if(n.diagnostics.push(s),k.notifyOutputDiagnostic(s,{...n.options,signal:n.signal}),n.options.assetFailure!=="placeholder")throw new p(s,o)}async function D(n,e,t){const r=n.options.assetRenderers?.[e.kind];if(e.imageData||!r)return e.imageData;if(++n.rendered>n.budget.maxAssets)return h(n,t,"asset-budget-exceeded","Output exceeded the asset count budget.");let o;try{if(n.active=t,o=await E.waitForOutput(r({...t,signal:n.signal}),n.signal),f(n.signal),o.length>n.budget.maxImageBytes*4+1024)return h(n,t,"asset-budget-exceeded","Output exceeded the image payload byte budget.");const s=P(o);if(s>n.budget.maxImageBytes||n.bytes+s>n.budget.maxTotalImageBytes)return h(n,t,"asset-budget-exceeded","Output exceeded the encoded image byte budget.");n.bytes+=s}catch(s){if(n.signal.aborted||s instanceof p)throw s;return h(n,t,"asset-render-failed",`Asset renderer failed for ${e.kind}; output was not silently omitted.`,s)}return o}function T(n,e){const t=n.active;if(!t){e.abort(new Error("Asset rendering exceeded maxDurationMs."));return}const r={code:"asset-budget-exceeded",message:"Asset rendering exceeded maxDurationMs.",severity:"warning",format:n.options.format??"dom",pageIndex:t.pageIndex,componentIndex:t.componentIndex,componentPath:t.componentPath,kind:t.component.kind,nid:t.component.nid};n.diagnostics.push(r);try{k.notifyOutputDiagnostic(r,{...n.options,signal:n.signal})}catch(o){e.abort(o);return}e.abort(new p(r))}async function C(n,e,t,r,o){if(!e?.children?.length)return e;const s=[];for(const[i,c]of e.children.entries())s.push(await I(n,c,{...t,component:c,componentPath:[...r,i]},o));return s.some((i,c)=>i!==e.children[c])?{...e,children:s}:e}async function I(n,e,t,r){if(f(n.signal),r.has(e))throw new TypeError("Cyclic grid children cannot be rendered.");let o=n.cache.get(e);o||(o=D(n,e,t),n.cache.set(e,o));const s=await o;f(n.signal);let i=e.grid;if(i){const c=new Set(r).add(e),d=[];for(const[a,u]of i.cells.entries()){const g=[];for(const[l,M]of u.entries())g.push(await C(n,M,t,[...t.componentPath,a,l],c));d.push(g)}d.some((a,u)=>a.some((g,l)=>g!==i.cells[u][l]))&&(i={...i,cells:d})}return s!==e.imageData||i!==e.grid?{...e,imageData:s,grid:i}:e}async function R(n,e={}){const t=O(e);if(e.signal?.aborted)throw e.signal.reason??new DOMException("The operation was aborted.","AbortError");const r=new AbortController,o=()=>r.abort(e.signal?.reason);if(e.signal?.addEventListener("abort",o,{once:!0}),!e.assetRenderers||!Object.keys(e.assetRenderers).length)return e.signal?.removeEventListener("abort",o),{plan:n,diagnostics:[]};const s={options:e,signal:r.signal,diagnostics:[],rendered:0,bytes:0,budget:t,cache:new WeakMap},i=setTimeout(()=>T(s,r),t.maxDurationMs);try{const c=[];for(const[d,a]of n.pages.entries()){if(d<(e.start??0)||d>(e.end??n.pages.length-1)){c.push(a);continue}const u=[];for(const[g,l]of a.components.entries())u.push(await I(s,l,{component:l,pageIndex:d,componentIndex:g,componentPath:[]},new Set));c.push(u.some((g,l)=>g!==a.components[l])?{...a,components:u}:a)}return f(s.signal),{plan:c.some((d,a)=>d!==n.pages[a])?{...n,pages:c}:n,diagnostics:s.diagnostics}}finally{clearTimeout(i),e.signal?.removeEventListener("abort",o)}}exports.OutputAssetError=p;exports.resolveGridStrokes=B;exports.resolvePlanAssets=R;
|