@agile-team/mach-report 2.22.0 → 2.23.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/README.md +7 -6
- package/dist/{ExcelBindingWizard-CZyppD7I.js → ExcelBindingWizard-D4FLind-.js} +3 -3
- package/dist/{ExcelBindingWizard-CW79I6Gl.cjs → ExcelBindingWizard-D4RS5Bpg.cjs} +1 -1
- package/dist/{ParamEditor-CiYCJI0b.cjs → ParamEditor-C-6C9rd2.cjs} +1 -1
- package/dist/{ParamEditor-DQit-Gdf.js → ParamEditor-CASZt-Ma.js} +2 -2
- package/dist/{ReportBatchPanel-DKTpV7MU.js → ReportBatchPanel-Bq7t8a5r.js} +2 -2
- package/dist/{ReportBatchPanel-Db6TAfG5.cjs → ReportBatchPanel-YVj5IO5y.cjs} +1 -1
- package/dist/ReportLabelStudio-Cqhita1b.cjs +1 -0
- package/dist/{ReportLabelStudio-BYnRqmje.js → ReportLabelStudio-Dj7GXhuv.js} +295 -292
- package/dist/ReportParamPanel-DZbFVmDL.cjs +1 -0
- package/dist/{ReportParamPanel-BHSKVL8k.js → ReportParamPanel-Dgmqro1Y.js} +93 -79
- package/dist/ReportPreview-DeWzG8jQ.js +6257 -0
- package/dist/ReportPreview-FFIryrIr.cjs +6 -0
- package/dist/{ReportTemplateLibrary-DEXH07ND.cjs → ReportTemplateLibrary-BaWodmpm.cjs} +1 -1
- package/dist/{ReportTemplateLibrary-BZuKn0YK.js → ReportTemplateLibrary-DdAAAD2I.js} +1 -1
- package/dist/{RuleEditor-CIQn547x.js → RuleEditor-D2UwQGF6.js} +59 -59
- package/dist/{RuleEditor-zSUmPjKa.cjs → RuleEditor-DcT9xI1v.cjs} +1 -1
- package/dist/TemplateOutlinePanel-CUHFFiNM.cjs +1 -0
- package/dist/{TemplateOutlinePanel-D0PgOSQE.js → TemplateOutlinePanel-DrT7XN0m.js} +2 -2
- package/dist/{TemplateReusePanel-BKlAEF8-.js → TemplateReusePanel-4eejkNqi.js} +2 -2
- package/dist/{TemplateReusePanel-DAy_Hwqz.cjs → TemplateReusePanel-DZMyiX5I.cjs} +1 -1
- package/dist/{TemplateReviewPanel-div-EH_m.js → TemplateReviewPanel-BIhNLeNw.js} +2 -2
- package/dist/{TemplateReviewPanel-CowmHaQQ.cjs → TemplateReviewPanel-DnYImiXu.cjs} +1 -1
- package/dist/analytics.cjs +1 -1
- package/dist/analytics.js +26 -26
- package/dist/artifact-integrity.json +106 -104
- package/dist/assets-D2gHc4Mz.cjs +1 -0
- package/dist/assets-T_gDeFaz.js +132 -0
- package/dist/auto-4pK9HePf.cjs +1 -0
- package/dist/auto-CTIJ6PnR.js +257 -0
- package/dist/capabilities-DiBj4Qgl.cjs +1 -0
- package/dist/capabilities-pg7j7VLT.js +106 -0
- package/dist/charts-Cjw5AYkg.cjs +1 -0
- package/dist/{charts-Dlv8j2AG.js → charts-CxJZ0XaY.js} +1 -1
- package/dist/computed-DK6BruFz.cjs +1 -0
- package/dist/{computed-C8NRZQss.js → computed-f3pOqWLX.js} +381 -301
- package/dist/data-bar-CeZuFmYl.cjs +1 -0
- package/dist/{data-bar-8baGYEZ9.js → data-bar-IkI6VvMQ.js} +1 -1
- package/dist/designer-DhrE7jzw.js +7169 -0
- package/dist/designer-IAZu6kBX.cjs +2 -0
- package/dist/designer.cjs +1 -1
- package/dist/designer.d.cts +98 -45
- package/dist/designer.d.ts +98 -45
- package/dist/designer.js +3 -3
- package/dist/dom-ChE5D-L-.cjs +1 -0
- package/dist/dom-JWrchIre.js +452 -0
- package/dist/dom-cell-address-DLD1mkTB.cjs +1 -0
- package/dist/dom-cell-address-Fn-8nk7D.js +11 -0
- package/dist/{encoding-ncQAvyOv.cjs → encoding-BefcaHdp.cjs} +1 -1
- package/dist/{encoding-DbnhbwI8.js → encoding-CL6rXEkR.js} +2 -2
- package/dist/{font-loader-Di0lQKFf.js → font-loader-BT5baV-o.js} +1 -1
- package/dist/{font-loader-BB372_XN.cjs → font-loader-Ga51c2VC.cjs} +1 -1
- package/dist/grid-strokes-Be24LGuV.cjs +1 -0
- package/dist/grid-strokes-EoY66L2f.js +53 -0
- package/dist/index.cjs +8 -8
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +944 -1259
- package/dist/json-snapshot-1tvQNzQE.cjs +2 -0
- package/dist/{json-snapshot-DvQbZlD7.js → json-snapshot-OqkPyUk5.js} +763 -776
- package/dist/matrix-B8QWbsGM.cjs +1 -0
- package/dist/matrix-C6e_r_vp.js +302 -0
- package/dist/{pdf-CARdBcuw.cjs → pdf-HiEeXe9H.cjs} +42 -42
- package/dist/{pdf-DmlnL5eB.js → pdf-aobetCsy.js} +20 -20
- package/dist/pdf.cjs +1 -1
- package/dist/pdf.js +2 -2
- package/dist/{plugin-AcAQ2m9X.cjs → plugin-BFANt-i8.cjs} +1 -1
- package/dist/{plugin-w5Nyt08U.js → plugin-DeYYAL6F.js} +1 -1
- package/dist/{prefill-BXBxx5We.js → prefill-Dk4C6S5R.js} +21 -21
- package/dist/prefill-DsUD5OoK.cjs +1 -0
- package/dist/prepared-DCIxhKFo.js +94 -0
- package/dist/prepared-Dv-XM3i1.cjs +1 -0
- package/dist/progress-ByiOxUD3.js +250 -0
- package/dist/progress-WomPRP3B.cjs +1 -0
- package/dist/{protocol-C9ZaylID.cjs → protocol-B9YgfQ_d.cjs} +1 -1
- package/dist/{protocol-fjaeKkjf.js → protocol-DxeUKGYG.js} +3 -3
- package/dist/record-bindings-DatJZv_e.js +200 -0
- package/dist/record-bindings-MBxbeBsi.cjs +1 -0
- package/dist/{region-binding-workflow-aA8nxmkZ.js → region-binding-workflow-DjrXuR1q.js} +2 -2
- package/dist/{region-binding-workflow-BiJQ7NU6.cjs → region-binding-workflow-l7NGfagJ.cjs} +2 -2
- package/dist/report-encoding-worker.cjs +1 -1
- package/dist/report-encoding-worker.js +1 -1
- package/dist/rich-text-layout-Ciwa6D2o.js +52 -0
- package/dist/rich-text-layout-DK7A_a5r.cjs +3 -0
- package/dist/{runtime-BTtpjF3D.js → runtime-75Y5Oq5B.js} +52 -51
- package/dist/runtime-DKlGd_D4.cjs +1 -0
- package/dist/sbom.cdx.json +1 -1
- package/dist/server-node.cjs +5 -5
- package/dist/server-node.js +1642 -1586
- package/dist/server.cjs +1 -1
- package/dist/server.js +24 -24
- package/dist/style.css +1 -1
- package/dist/{template-catalog-JSxSqk5y.js → template-catalog--cjxzgH7.js} +17 -17
- package/dist/template-catalog-CoT7jm_6.cjs +1 -0
- package/dist/{template-fragments-D2JFj7Du.js → template-fragments-CPpGpQoz.js} +12 -12
- package/dist/template-fragments-GVjpew_q.cjs +1 -0
- package/dist/template-registry-DI59PXVK.cjs +1 -0
- package/dist/{template-registry-Do1Uav2Z.js → template-registry-O0hNIOfB.js} +17 -17
- package/dist/{template-serialization-CU4n_Miu.js → template-serialization-CWmHq7lX.js} +1 -1
- package/dist/{template-serialization-CgqBo6s-.cjs → template-serialization-CqQY4zDg.cjs} +1 -1
- package/dist/{textwrap-CkGjRFT3.js → textwrap-BIjtEWmq.js} +1 -1
- package/dist/textwrap-Cy7o1hIR.cjs +4 -0
- package/dist/vue/async.d.cts +24 -0
- package/dist/vue/async.d.ts +24 -0
- package/dist/vue/index.d.cts +25 -1
- package/dist/vue/index.d.ts +25 -1
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +3 -3
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +52 -47
- package/dist/{workbook-session-BvEBRRMz.cjs → workbook-session-C6-SrnCT.cjs} +4 -4
- package/dist/{workbook-session-f0wVlzst.js → workbook-session-C9ZmCBwY.js} +15 -16
- package/dist/worker.cjs +1 -1
- package/dist/worker.js +4 -4
- package/dist/xlsx.cjs +4 -4
- package/dist/xlsx.js +184 -179
- package/package.json +1 -1
- package/dist/ReportLabelStudio-B0i9ohQj.cjs +0 -1
- package/dist/ReportParamPanel-lngONOEz.cjs +0 -1
- package/dist/ReportPreview-BDgKssYR.js +0 -5887
- package/dist/ReportPreview-Dw-4icG6.cjs +0 -6
- package/dist/TemplateOutlinePanel-B5SfGYVN.cjs +0 -1
- package/dist/assets-CxHunY_9.js +0 -232
- package/dist/assets-vbjAGgk8.cjs +0 -1
- package/dist/auto-DcUHlKob.cjs +0 -1
- package/dist/auto-moShblh1.js +0 -240
- package/dist/charts-aCtoswXq.cjs +0 -1
- package/dist/component-tree-1_QCiQJX.js +0 -67
- package/dist/component-tree-BjZIp6w9.cjs +0 -1
- package/dist/computed-4TnxzgIh.cjs +0 -1
- package/dist/data-bar-YltqGTaC.cjs +0 -1
- package/dist/designer-B7jJeAeG.js +0 -6914
- package/dist/designer-BWQVpJeN.cjs +0 -2
- package/dist/grid-geometry-D3SJgWFv.js +0 -136
- package/dist/grid-geometry-D8ReblRV.cjs +0 -1
- package/dist/json-snapshot-nyV63AbB.cjs +0 -2
- package/dist/matrix-0hywp0-F.cjs +0 -1
- package/dist/matrix-Dy-tyY7E.js +0 -381
- package/dist/prefill-DUvejVt1.cjs +0 -1
- package/dist/prepared-YXy-fVLw.cjs +0 -1
- package/dist/prepared-rXCKqdHY.js +0 -88
- package/dist/progress-B0ctFpKf.cjs +0 -1
- package/dist/progress-Hc2vxoCs.js +0 -52
- package/dist/record-bindings-Ct1HkPrc.cjs +0 -1
- package/dist/record-bindings-VZGS-Qd8.js +0 -155
- package/dist/rich-text-layout-K48VHUoW.cjs +0 -3
- package/dist/rich-text-layout-wxBhnAS7.js +0 -102
- package/dist/runtime-Dq0LUsyS.cjs +0 -1
- package/dist/template-catalog-CLAM4w7H.cjs +0 -1
- package/dist/template-fragments-Ca25Jt7e.cjs +0 -1
- package/dist/template-outline-CDWXptuj.js +0 -88
- package/dist/template-outline-K4jGhATu.cjs +0 -1
- package/dist/template-registry-CWnuGqyP.cjs +0 -1
- package/dist/textwrap-OTOUMr4f.cjs +0 -4
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as
|
|
3
|
-
import { v as
|
|
4
|
-
import { p as h } from "./template-registry-
|
|
5
|
-
import { b as S } from "./template-serialization-
|
|
1
|
+
import { y as O, J as k, I as j } from "./json-snapshot-OqkPyUk5.js";
|
|
2
|
+
import { i as P } from "./capabilities-pg7j7VLT.js";
|
|
3
|
+
import { v as L } from "./dataset-DL83majE.js";
|
|
4
|
+
import { p as h } from "./template-registry-O0hNIOfB.js";
|
|
5
|
+
import { b as S } from "./template-serialization-CWmHq7lX.js";
|
|
6
6
|
import { l as N } from "./param-validation-CnDEd2l-.js";
|
|
7
7
|
function $(e) {
|
|
8
8
|
if (e === void 0) return;
|
|
@@ -59,7 +59,7 @@ function F(e, t, r = {}) {
|
|
|
59
59
|
}
|
|
60
60
|
return i(a, n, "$"), s.truncated = s.totalChanges > s.changes.length, s;
|
|
61
61
|
}
|
|
62
|
-
function
|
|
62
|
+
function J(e, t, r) {
|
|
63
63
|
for (const a of S(e)) {
|
|
64
64
|
const n = Object.prototype.hasOwnProperty.call(
|
|
65
65
|
t,
|
|
@@ -86,7 +86,7 @@ function B(e, t, r) {
|
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
function
|
|
89
|
+
function B(e, t, r, a) {
|
|
90
90
|
const n = r.maxSampleRows ?? 1e3;
|
|
91
91
|
let o;
|
|
92
92
|
try {
|
|
@@ -121,7 +121,7 @@ function J(e, t, r, a) {
|
|
|
121
121
|
([c]) => f.has(c)
|
|
122
122
|
))
|
|
123
123
|
try {
|
|
124
|
-
const c =
|
|
124
|
+
const c = L(o[d], i, {
|
|
125
125
|
path: `$.datasets.${d}`,
|
|
126
126
|
maxRows: n
|
|
127
127
|
});
|
|
@@ -143,7 +143,7 @@ function J(e, t, r, a) {
|
|
|
143
143
|
}
|
|
144
144
|
return !0;
|
|
145
145
|
}
|
|
146
|
-
function
|
|
146
|
+
function W(e, t) {
|
|
147
147
|
const r = e.pages[t.pageIndex]?.components[t.componentIndex]?.meta?.labelSource;
|
|
148
148
|
if (r && typeof r == "object" && "pageIndex" in r && "componentIndex" in r && typeof r.pageIndex == "number" && typeof r.componentIndex == "number")
|
|
149
149
|
return {
|
|
@@ -159,8 +159,8 @@ function K(e, t) {
|
|
|
159
159
|
componentIndex: t.componentIndex
|
|
160
160
|
};
|
|
161
161
|
}
|
|
162
|
-
function
|
|
163
|
-
const a =
|
|
162
|
+
function q(e, t, r) {
|
|
163
|
+
const a = W(t, r);
|
|
164
164
|
if (a) return a;
|
|
165
165
|
const n = t.pages[r.pageIndex]?.components[r.componentIndex], o = /^table:(\d+):(\d+)(?::|$)/.exec(n?.table?.id ?? "");
|
|
166
166
|
if (o)
|
|
@@ -182,7 +182,7 @@ function W(e, t, r) {
|
|
|
182
182
|
}
|
|
183
183
|
return { path: "$.template" };
|
|
184
184
|
}
|
|
185
|
-
function
|
|
185
|
+
function K(e, t, r, a, n) {
|
|
186
186
|
const o = N(
|
|
187
187
|
e.template.params ?? [],
|
|
188
188
|
t.params ?? {}
|
|
@@ -195,7 +195,7 @@ function q(e, t, r, a, n) {
|
|
|
195
195
|
fixture: t.name,
|
|
196
196
|
path: s.path.replace(/^\$\.params/, `$.fixtures[${r}].params`)
|
|
197
197
|
}))
|
|
198
|
-
), !!o.ok &&
|
|
198
|
+
), !!o.ok && B(t, e.template, a, n.issues))
|
|
199
199
|
try {
|
|
200
200
|
const { plan: s, warnings: f } = O(
|
|
201
201
|
e.template,
|
|
@@ -205,7 +205,7 @@ function q(e, t, r, a, n) {
|
|
|
205
205
|
maxCells: a.maxCells ?? 25e4
|
|
206
206
|
}
|
|
207
207
|
), d = (a.formats ?? ["pdf", "xlsx"]).flatMap(
|
|
208
|
-
(i) =>
|
|
208
|
+
(i) => P(s, i)
|
|
209
209
|
);
|
|
210
210
|
n.issues.push(
|
|
211
211
|
...f.map((i) => ({
|
|
@@ -219,7 +219,7 @@ function q(e, t, r, a, n) {
|
|
|
219
219
|
...d.map((i) => ({
|
|
220
220
|
code: "output",
|
|
221
221
|
severity: a.strictOutputs ? "error" : "warning",
|
|
222
|
-
...
|
|
222
|
+
...q(e.template, s, i),
|
|
223
223
|
fixture: t.name,
|
|
224
224
|
message: `${i.format}: ${i.message}`,
|
|
225
225
|
diagnostic: i
|
|
@@ -280,13 +280,13 @@ function* A(e, t, r) {
|
|
|
280
280
|
}
|
|
281
281
|
}), t.dataSchemas && (yield {
|
|
282
282
|
stage: "bindings",
|
|
283
|
-
run: () =>
|
|
283
|
+
run: () => J(a.template, t.dataSchemas, r.issues)
|
|
284
284
|
});
|
|
285
285
|
for (const [o, s] of (t.fixtures ?? []).entries())
|
|
286
286
|
yield {
|
|
287
287
|
stage: "fixture",
|
|
288
288
|
fixture: s.name,
|
|
289
|
-
run: () =>
|
|
289
|
+
run: () => K(a, s, o, t, r)
|
|
290
290
|
};
|
|
291
291
|
t.fixtures?.length || r.issues.push({
|
|
292
292
|
code: "sample",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const w=require("./json-snapshot-1tvQNzQE.cjs"),j=require("./capabilities-DiBj4Qgl.cjs"),L=require("./dataset-IrlXbUvh.cjs"),h=require("./template-registry-DI59PXVK.cjs"),E=require("./template-serialization-CqQY4zDg.cjs"),P=require("./param-validation-C-8sRJLq.cjs");function R(e){if(e===void 0)return;const t=typeof e=="string"?e:JSON.stringify(e);return t.length>160?t.slice(0,157)+"…":t}function N(e){return/\.(?:repeat|binding)(?:\.|$)/.test(e)?/\.format(?:\.|$)/.test(e)?"format":"binding":/\.tree\.(?:idField|parentField|childrenField|labelField|input)$/.test(e)?"binding":/\.tree\.parentValues$/.test(e)?"calculation":/\.tree\.indentMm$/.test(e)?"format":/\.(?:computed|computeOptions|groups|groupBy|aggregates|grandTotal)(?:\.|\[|$)/.test(e)?"calculation":/\.(?:dataset|field|rowKey|revisionField|sourceTokenField|foreignKey|parentKey)$/.test(e)?"binding":/\.(?:style|headerStyle|format|rules|align|headerAlign|semanticRole|unit)(?:\.|\[|$)/.test(e)?"format":e.startsWith("$.template")?"structure":"metadata"}function T(e){const t=new Map;for(const r of e){if(!r||typeof r!="object"||!("field"in r)||typeof r.field!="string"||t.has(r.field))return;t.set(r.field,r)}return t}function D(e,t,r){return!e.startsWith("$.template.params")||t==="moved"?!1:/\.(?:type|required|min|max|minLength|maxLength|options|defaultValue)(?:\[|$)/.test(e)?!0:t!=="added"?!1:Array.isArray(r)?r.some(a=>!!a&&typeof a=="object"&&"required"in a&&a.required===!0):!!r&&typeof r=="object"&&"required"in r&&r.required===!0}function A(e,t,r={}){const a=h.parseReportTemplate(e),n=h.parseReportTemplate(t),o=r.maxChanges??500;if(!Number.isSafeInteger(o)||o<1||o>1e4)throw new RangeError("maxChanges must be between 1 and 10000");const s={changes:[],totalChanges:0,breakingChanges:0,truncated:!1};function d(c,l,u,m){const f=N(l),y=c!=="moved"&&(f==="binding"||l==="$.id"||c==="removed"&&f==="structure"||D(l,c,m));s.totalChanges++,y&&s.breakingChanges++,s.changes.length<o&&s.changes.push({kind:c,category:f,path:l,before:R(u),after:R(m),breaking:y})}function p(c,l,u){const m=T(c),f=T(l);if(!m||!f)return!1;const y=new Map(l.map((g,b)=>[g.field,b]));Array.from(m).forEach(([g,b],$)=>{const x=`${u}[${JSON.stringify(g)}]`;f.has(g)?(y.get(g)!==$&&d("moved",x,$,y.get(g)),i(b,f.get(g),x)):d("removed",x,b,void 0)});for(const[g,b]of f)m.has(g)||d("added",`${u}[${JSON.stringify(g)}]`,void 0,b);return!0}function i(c,l,u){if(!(Object.is(c,l)||u==="$.revision")){if(c===void 0||l===void 0){d(c===void 0?"added":"removed",u,c,l);return}if(Array.isArray(c)&&Array.isArray(l)){if((u.endsWith(".columns")||u.endsWith(".params"))&&p(c,l,u))return;for(let m=0;m<Math.max(c.length,l.length);m++)i(c[m],l[m],`${u}[${m}]`)}else if(c&&l&&typeof c=="object"&&typeof l=="object"&&!Array.isArray(c)&&!Array.isArray(l)){const m=c,f=l;for(const y of new Set([...Object.keys(m),...Object.keys(f)]))i(m[y],f[y],`${u}.${y}`)}else d("modified",u,c,l)}}return i(a,n,"$"),s.truncated=s.totalChanges>s.changes.length,s}function M(e,t,r){for(const a of E.collectTemplateDatasetBindings(e)){const n=Object.prototype.hasOwnProperty.call(t,a.dataset)?t[a.dataset]:void 0;if(!n){r.push({code:"dataset",severity:"error",path:`${a.path}.dataset`,message:`未声明数据集 ${a.dataset}`});continue}const o=new Set(n.fields.map(s=>s.field));a.fields.forEach(({field:s,path:d,summary:p})=>{!o.has(s)&&!a.generated.has(s)&&!(p&&a.summaries.has(s))&&r.push({code:"field",severity:"error",path:d,field:s,message:`数据集 ${a.dataset} 缺少字段 ${s}`})})}}function q(e,t,r,a){const n=r.maxSampleRows??1e3;let o;try{o=w.templateValidationDatasets(t,e.datasets,{maxRows:n})}catch(p){return a.push({code:"sample",severity:"error",path:"$.fixtures",fixture:e.name,message:p instanceof Error?p.message:String(p)}),!1}const s=Object.values(o).reduce((p,i)=>p+i.length,0);if(s>n)return a.push({code:"sample",severity:"error",path:"$.fixtures",fixture:e.name,message:`样例 ${s} 行超过预算 ${n},请显式选择验收样例`}),!1;const d=new Set(E.collectTemplateDatasetBindings(t).map(p=>p.dataset));for(const[p,i]of Object.entries(r.dataSchemas??{}).filter(([c])=>d.has(c)))try{const c=L.validateDatasetRows(o[p],i,{path:`$.datasets.${p}`,maxRows:n});if(a.push(...c.issues.map(l=>({...l,code:"sample",severity:"error",fixture:e.name}))),!c.ok)return!1}catch(c){return a.push({code:"dataset",severity:"error",path:`$.dataSchemas.${p}`,message:String(c)}),!1}return!0}function F(e,t){const r=e.pages[t.pageIndex]?.components[t.componentIndex]?.meta?.labelSource;if(r&&typeof r=="object"&&"pageIndex"in r&&"componentIndex"in r&&typeof r.pageIndex=="number"&&typeof r.componentIndex=="number")return{path:`$.template.pages[${r.pageIndex}].components[${r.componentIndex}]`,pageIndex:r.pageIndex,componentIndex:r.componentIndex};const a=e.pages[t.pageIndex]?.meta?.record;if(a&&typeof a=="object"&&"templatePageIndex"in a&&typeof a.templatePageIndex=="number")return{path:`$.template.pages[${a.templatePageIndex}].components[${t.componentIndex}]`,pageIndex:a.templatePageIndex,componentIndex:t.componentIndex}}function B(e,t,r){const a=F(t,r);if(a)return a;const n=t.pages[r.pageIndex]?.components[r.componentIndex],o=/^table:(\d+):(\d+)(?::|$)/.exec(n?.table?.id??"");if(o)return{path:`$.template.pages[${o[1]}].components[${o[2]}]`,pageIndex:Number(o[1]),componentIndex:Number(o[2])};for(const[s,d]of e.pages.entries()){const p=d.components.findIndex(i=>i===n||n?.nid!==void 0&&"nid"in i&&i.nid===n.nid);if(p>=0)return{path:`$.template.pages[${s}].components[${p}]`,pageIndex:s,componentIndex:p}}return{path:"$.template"}}function J(e,t,r,a,n){const o=P.validateReportParams(e.template.params??[],t.params??{});if(n.issues.push(...o.issues.map(s=>({...s,code:"params",severity:"error",fixture:t.name,path:s.path.replace(/^\$\.params/,`$.fixtures[${r}].params`)}))),!!o.ok&&q(t,e.template,a,n.issues))try{const{plan:s,warnings:d}=w.paginateTemplate(e.template,t.datasets,{maxPages:a.maxPages??100,maxCells:a.maxCells??25e4}),p=(a.formats??["pdf","xlsx"]).flatMap(i=>j.inspectOutputCapabilities(s,i));n.issues.push(...d.map(i=>({code:"layout",severity:"warning",path:"$.template",fixture:t.name,message:i}))),n.issues.push(...p.map(i=>({code:"output",severity:a.strictOutputs?"error":"warning",...B(e.template,s,i),fixture:t.name,message:`${i.format}: ${i.message}`,diagnostic:i}))),n.samples.push({name:t.name,pages:s.pages.length,rows:w.templateDatasetRowCount(e.template,t.datasets),diagnostics:p})}catch(s){n.issues.push({code:"layout",severity:"error",path:"$.template",fixture:t.name,message:s instanceof Error?s.message:String(s)})}}function V(e){for(const[r,a]of[["maxPages",e.maxPages],["maxCells",e.maxCells],["maxSampleRows",e.maxSampleRows]])if(a!==void 0&&(!Number.isSafeInteger(a)||a<1))throw new RangeError(`${r} must be a positive safe integer`);if((e.fixtures?.length??0)>20)throw new RangeError("At most 20 review fixtures are allowed");const t=new Set;for(const r of e.fixtures??[]){if(typeof r.name!="string"||!r.name.trim()||r.name.length>120||t.has(r.name))throw new Error("Review fixtures require unique non-empty names of at most 120 characters");t.add(r.name)}}function*C(e,t,r){let a;yield{stage:"template",run:()=>{V(t),a=h.parseReportTemplate(e)}};const n=t.previous;n&&(yield{stage:"baseline",run:()=>{r.changes=A(n,a),r.changes.breakingChanges&&!t.allowBreakingChanges&&r.issues.push({code:"compatibility",severity:"error",path:"$.template",message:`${r.changes.breakingChanges} 项字段或结构变更需要明确确认兼容性`})}}),t.dataSchemas&&(yield{stage:"bindings",run:()=>M(a.template,t.dataSchemas,r.issues)});for(const[o,s]of(t.fixtures??[]).entries())yield{stage:"fixture",fixture:s.name,run:()=>J(a,s,o,t,r)};t.fixtures?.length||r.issues.push({code:"sample",severity:"warning",path:"$.fixtures",message:"未提供验收样例,仅完成结构和字段检查,尚未验证排版与输出"})}function O(e){return e.ok=e.issues.every(t=>t.severity!=="error"),e}function k(e,t){e.issues.push({code:"template",severity:"error",path:"$",message:t instanceof Error?t.message:String(t)})}function W(e,t={}){const r={ok:!1,issues:[],samples:[]};try{for(const a of C(e,t,r))a.run()}catch(a){k(r,a)}return O(r)}function v(e){if(e?.aborted)throw e.reason??new DOMException("Template review was aborted","AbortError")}function K(e){return v(e),new Promise((t,r)=>{const a=()=>{clearTimeout(n),e?.removeEventListener("abort",a),r(e?.reason??new DOMException("Template review was aborted","AbortError"))},n=setTimeout(()=>{e?.removeEventListener("abort",a),t()},0);e?.addEventListener("abort",a,{once:!0}),e?.aborted&&a()})}function I(e,t){try{e.onProgress?.(t)}catch{}}async function _(e,t={}){const r={ok:!1,issues:[],samples:[]},a=t.fixtures?.length??0;let n=0;v(t.signal);try{const o=C(e,t,r),s=o.next();s.done||(s.value.run(),I(t,{completed:n,total:a,stage:s.value.stage})),v(t.signal);for(const d of o)await K(t.signal),v(t.signal),d.run(),d.stage==="fixture"&&n++,I(t,{completed:n,total:a,stage:d.stage,...d.fixture?{fixture:d.fixture}:{}}),v(t.signal)}catch(o){v(t.signal),k(r,o)}return O(r)}function z(e,t){const r=e.publishedRevision??e.published?.revision;for(const a of[e.draftRevision,r])if(a!==void 0&&(typeof a!="string"||!a.trim()))throw new TypeError("模板生命周期修订应为非空字符串");if(e.draftRevision!==void 0&&e.draftRevision!==t.revision)throw new TypeError("可编辑文档应与草稿修订一致");if(e.published&&(e.published.id!==t.id||e.published.revision!==r))throw new TypeError("发布文档身份或修订不一致");if(!e.published&&r!==void 0&&r!==t.revision)throw new TypeError("发布修订需要对应的独立文档");return{...e.draftRevision===void 0?{}:{draftRevision:e.draftRevision},...r===void 0?{}:{publishedRevision:r}}}function G(e,t){const r=h.parseReportTemplate(e);if(t.id===r.id)throw new Error("复制模板应使用新的 ID");const{revision:a,...n}=r;return h.parseReportTemplate({...n,id:t.id,name:t.name})}function H(e){if(!Array.isArray(e)||e.length>1e3)throw new RangeError("本地模板目录最多 1000 项");const t=new Map,r=new Map,a=[];for(const n of e){const o=h.parseReportTemplate(n.document);if(t.has(o.id))throw new Error(`模板 ID 重复:${o.id}`);if(n.category!==void 0&&(typeof n.category!="string"||n.category.length>128)||n.tags!==void 0&&(!Array.isArray(n.tags)||n.tags.length>20||n.tags.some(i=>typeof i!="string"||i.length>128)))throw new TypeError("模板分类和标签无效");const s=z(n,o),{template:d,...p}=o;t.set(o.id,o),n.published?r.set(o.id,h.parseReportTemplate(n.published)):s.publishedRevision&&r.set(o.id,h.parseReportTemplate(o)),a.push({...p,...s,...n.category?{category:n.category}:{},...n.tags?{tags:[...n.tags]}:{}})}return a.sort((n,o)=>n.id<o.id?-1:1),{search:async n=>{S(n.signal);const o=n.limit??30;if(!Number.isSafeInteger(o)||o<1||o>100)throw new RangeError("模板每页数量应为 1–100");const s=n.query?.trim().toLocaleLowerCase()??"",d=a.filter(i=>(!n.category||i.category===n.category)&&(!n.cursor||i.id>n.cursor)&&(!s||[i.id,i.name,i.description,...i.tags??[]].some(c=>c?.toLocaleLowerCase().includes(s)))),p=new Map;for(const i of a)i.category&&p.set(i.category,(p.get(i.category)??0)+1);return JSON.parse(JSON.stringify({items:d.slice(0,o),...d.length>o?{next:d[o-1].id}:{},categories:Array.from(p,([i,c])=>({id:i,label:i,count:c}))}))},get:async(n,o)=>{S(o.signal);const s=o.mode==="published"?r.get(n):t.get(n);return s?h.parseReportTemplate(s):void 0}}}function S(e){if(!e?.aborted)return;const t=new Error("模板目录操作已取消");throw t.name="AbortError",t}exports.cloneReportTemplate=G;exports.createLocalTemplateCatalog=H;exports.diffReportTemplates=A;exports.reviewReportTemplate=W;exports.reviewReportTemplateAsync=_;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { p } from "./template-registry-
|
|
2
|
-
import { b } from "./template-serialization-
|
|
3
|
-
import {
|
|
1
|
+
import { p } from "./template-registry-O0hNIOfB.js";
|
|
2
|
+
import { b } from "./template-serialization-CWmHq7lX.js";
|
|
3
|
+
import { m as h } from "./progress-ByiOxUD3.js";
|
|
4
4
|
function c(t) {
|
|
5
5
|
return JSON.parse(JSON.stringify(t));
|
|
6
6
|
}
|
|
@@ -75,10 +75,10 @@ function S(t, a, e = {}) {
|
|
|
75
75
|
s !== void 0 && E(n, `${r.path}.dataset`, s);
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
-
function
|
|
78
|
+
function g(t) {
|
|
79
79
|
if (!t || typeof t != "object") return;
|
|
80
80
|
if (Array.isArray(t)) {
|
|
81
|
-
t.forEach(
|
|
81
|
+
t.forEach(g);
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
84
|
const a = t;
|
|
@@ -86,7 +86,7 @@ function h(t) {
|
|
|
86
86
|
if (a.kind === "list" && delete a.id, a.meta && typeof a.meta == "object")
|
|
87
87
|
for (const e of ["fragment", "labelSource", "record"])
|
|
88
88
|
delete a.meta[e];
|
|
89
|
-
Object.values(a).forEach(
|
|
89
|
+
Object.values(a).forEach(g);
|
|
90
90
|
}
|
|
91
91
|
function x(t) {
|
|
92
92
|
const a = new Set(
|
|
@@ -133,7 +133,7 @@ function v(t, a, e) {
|
|
|
133
133
|
const s = F(r, a, e.replaceInstance), l = s.replacing, i = e.leftMm ?? s.left, m = e.topMm ?? s.top, o = c(a.components), w = e.replaceInstance ?? x(n);
|
|
134
134
|
if (a.repeatDataset && n.template.repeat?.dataset !== (e.bindings?.datasets?.[a.repeatDataset] ?? a.repeatDataset))
|
|
135
135
|
throw new Error("Bind this label fragment to the current record dataset");
|
|
136
|
-
S(a, o, e.bindings), o.forEach(
|
|
136
|
+
S(a, o, e.bindings), o.forEach(g), o.forEach((f, d) => {
|
|
137
137
|
f.leftMm += i, f.topMm += m, f.meta = {
|
|
138
138
|
...f.meta,
|
|
139
139
|
fragment: {
|
|
@@ -160,8 +160,8 @@ function B(t, a, e, n) {
|
|
|
160
160
|
const i = s.components[l];
|
|
161
161
|
if (!i) throw new Error("Component no longer exists");
|
|
162
162
|
i.kind === "list" ? n.target === "header" ? D(i, n.style) : i.columns.forEach((m) => {
|
|
163
|
-
m.style =
|
|
164
|
-
}) : i.style =
|
|
163
|
+
m.style = h(m.style, c(n.style)), n.style.align && (m.align = n.style.align);
|
|
164
|
+
}) : i.style = h(
|
|
165
165
|
i.style,
|
|
166
166
|
c(n.style)
|
|
167
167
|
);
|
|
@@ -169,15 +169,15 @@ function B(t, a, e, n) {
|
|
|
169
169
|
return p(r);
|
|
170
170
|
}
|
|
171
171
|
function D(t, a) {
|
|
172
|
-
if (t.headerStyle =
|
|
172
|
+
if (t.headerStyle = h(
|
|
173
173
|
t.headerStyle,
|
|
174
174
|
c(a)
|
|
175
175
|
), t.columns.forEach((e) => {
|
|
176
|
-
e.headerStyle =
|
|
176
|
+
e.headerStyle = h(e.headerStyle, c(a)), a.align && (e.headerAlign = a.align);
|
|
177
177
|
}), t.headerGrid)
|
|
178
178
|
for (const e of t.headerGrid.cells)
|
|
179
179
|
for (const n of e)
|
|
180
|
-
n && (n.style =
|
|
180
|
+
n && (n.style = h(n.style, c(a)));
|
|
181
181
|
}
|
|
182
182
|
export {
|
|
183
183
|
B as a,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const f=require("./template-registry-DI59PXVK.cjs"),T=require("./template-serialization-CqQY4zDg.cjs"),g=require("./progress-WomPRP3B.cjs");function p(t){return JSON.parse(JSON.stringify(t))}function u(t){return{...t.repeatDataset?{repeat:{dataset:t.repeatDataset}}:{},pages:[{widthMm:4999,heightMm:4999,components:t.components}]}}function y(t){if(!t.id.trim()||!t.name.trim()||!t.revision.trim())throw new Error("Fragment identity, name and revision are required");if(!t.components.length||t.components.length>200)throw new RangeError("A fragment must contain 1–200 components");f.parseReportTemplate({schemaVersion:"1.0",id:t.id,name:t.name,template:u(t)})}function E(t,n,e,a){const r=f.parseReportTemplate(t).template.pages[n];if(!r||!e.length||e.some(o=>!Number.isSafeInteger(o)||!r.components[o]))throw new Error("Select existing components to capture a fragment");const s=[...new Set(e)].map(o=>r.components[o]),l=Math.min(...s.map(o=>o.leftMm)),i=Math.min(...s.map(o=>o.topMm)),m={...a,...t.template.repeat?{repeatDataset:t.template.repeat.dataset}:{},components:p(s).map(o=>({...o,leftMm:o.leftMm-l,topMm:o.topMm-i}))};return y(m),m}function b(t){y(t);const n=new Map;for(const e of T.collectTemplateDatasetBindings(u(t))){const a=n.get(e.dataset)??new Set;for(const r of e.fields)!e.generated.has(r.field)&&!e.summaries.has(r.field)&&a.add(r.field);n.set(e.dataset,a)}return[...n].map(([e,a])=>({dataset:e,fields:[...a]}))}function S(t,n,e){const a=n.replace(/^\$\.template\./,"").replace(/\[(\d+)\]/g,".$1").split(".");let r=t;for(const s of a.slice(0,-1))r=r[s];r[a[a.length-1]]=e}function F(t,n,e={}){const a=u({...t,components:n});for(const r of T.collectTemplateDatasetBindings(a)){for(const l of r.fields){const i=e.fields?.[r.dataset]?.[l.field];i!==void 0&&S(a,l.path,i)}const s=e.datasets?.[r.dataset];s!==void 0&&S(a,`${r.path}.dataset`,s)}}function h(t){if(!t||typeof t!="object")return;if(Array.isArray(t)){t.forEach(h);return}const n=t;for(const e of["nid","rkey","table","source"])delete n[e];if(n.kind==="list"&&delete n.id,n.meta&&typeof n.meta=="object")for(const e of["fragment","labelSource","record"])delete n.meta[e];Object.values(n).forEach(h)}function D(t){const n=new Set(t.template.pages.flatMap(a=>a.components.map(r=>r.meta?.fragment?.instance)));let e=1;for(;n.has(`fragment-${e}`);)e++;return`fragment-${e}`}function R(t,n,e){const a=e?t.components.flatMap((s,l)=>s.meta?.fragment?.instance===e?[l]:[]):[];if(e&&!a.length)throw new Error("Fragment instance no longer exists");const r=a.map(s=>t.components[s]);if(r.some(s=>s.meta?.fragment?.id!==n.id))throw new Error("An upgrade must use the same fragment identity");return{replacing:a,left:r.length?Math.min(...r.map(s=>s.leftMm)):t.marginLeftMm??0,top:r.length?Math.min(...r.map(s=>s.topMm)):t.marginTopMm??0}}function x(t,n){if(n.some(e=>e.leftMm<0||e.topMm<0||e.leftMm+e.widthMm>t.widthMm+.001||e.topMm+(e.kind==="list"?e.rowHeightMm??7:e.heightMm)>t.heightMm+.001))throw new Error("Fragment exceeds the target page; choose a larger page or adjust its placement")}function k(t,n,e){y(n);const a=f.parseReportTemplate(t),r=a.template.pages[e.pageIndex];if(!r||r.flow)throw new Error("Choose a fixed page before inserting a fragment");const s=R(r,n,e.replaceInstance),l=s.replacing,i=e.leftMm??s.left,m=e.topMm??s.top,o=p(n.components),M=e.replaceInstance??D(a);if(n.repeatDataset&&a.template.repeat?.dataset!==(e.bindings?.datasets?.[n.repeatDataset]??n.repeatDataset))throw new Error("Bind this label fragment to the current record dataset");F(n,o,e.bindings),o.forEach(h),o.forEach((c,d)=>{c.leftMm+=i,c.topMm+=m,c.meta={...c.meta,fragment:{id:n.id,revision:n.revision,instance:M,slot:d}}}),x(r,o);const w=l[0]??r.components.length;return r.components=r.components.filter((c,d)=>!l.includes(d)),r.components.splice(w,0,...o),{document:f.parseReportTemplate(a),componentIndices:o.map((c,d)=>w+d),instance:M}}function C(t,n,e,a){const r=f.parseReportTemplate(t),s=r.template.pages[n];if(!s)throw new Error("Page no longer exists");for(const l of e){const i=s.components[l];if(!i)throw new Error("Component no longer exists");i.kind==="list"?a.target==="header"?I(i,a.style):i.columns.forEach(m=>{m.style=g.mergeComponentStyles(m.style,p(a.style)),a.style.align&&(m.align=a.style.align)}):i.style=g.mergeComponentStyles(i.style,p(a.style))}return f.parseReportTemplate(r)}function I(t,n){if(t.headerStyle=g.mergeComponentStyles(t.headerStyle,p(n)),t.columns.forEach(e=>{e.headerStyle=g.mergeComponentStyles(e.headerStyle,p(n)),n.align&&(e.headerAlign=n.align)}),t.headerGrid)for(const e of t.headerGrid.cells)for(const a of e)a&&(a.style=g.mergeComponentStyles(a.style,p(n)))}exports.applyReportDocumentStyle=C;exports.captureTemplateFragment=E;exports.insertTemplateFragment=k;exports.inspectTemplateFragmentBindings=b;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const C=require("./computed-DK6BruFz.cjs"),re=require("./matrix-B8QWbsGM.cjs"),k=require("./progress-WomPRP3B.cjs"),fe=require("./code-options-BUTChiZZ.cjs"),G=require("./param-validation-C-8sRJLq.cjs"),w=require("./template-serialization-CqQY4zDg.cjs");function de(e,i,t){e!==void 0&&(typeof e!="string"||!e.trim()||e.length>4096)&&t.push({path:i,message:"来源范围应为不超过 4096 字符的非空字符串"})}function U(e,i,t){e.editable!==void 0&&typeof e.editable!="boolean"&&t.push({path:`${i}.editable`,message:"编辑控制应为布尔值"}),e.valueType!==void 0&&!["text","number","boolean"].includes(e.valueType)&&t.push({path:`${i}.valueType`,message:"编辑类型应为 text、number 或 boolean"})}function ue(e,i,t){U(e,i,t),e.indentMm!==void 0&&(typeof e.indentMm!="number"||!Number.isFinite(e.indentMm)||e.indentMm<0)&&t.push({path:`${i}.indentMm`,message:"单元格缩进应为有限非负数"}),e.derived!==void 0&&typeof e.derived!="boolean"&&t.push({path:`${i}.derived`,message:"派生结果标记应为布尔值"}),z(e.source,`${i}.source`,t,!0),e.formula!==void 0&&typeof e.formula!="string"&&t.push({path:`${i}.formula`,message:"单元格公式应为字符串"})}function z(e,i,t,s=!1){if(e===void 0)return;if(!e||typeof e!="object"||Array.isArray(e)){t.push({path:i,message:"业务来源应为对象"});return}const n=e;de(n.sourceScope,`${i}.sourceScope`,t);for(const a of["datasetId",...s?["field"]:[]])(typeof n[a]!="string"||!n[a].trim())&&t.push({path:`${i}.${a}`,message:"业务标识应为非空字符串"});for(const a of["rowKey","revision"]){const o=n[a];o===void 0&&!(s&&a==="rowKey")||typeof o!="string"&&!(typeof o=="number"&&Number.isFinite(o))&&t.push({path:`${i}.${a}`,message:"业务键及修订号应为字符串或有限数字"})}n.sourceToken!==void 0&&typeof n.sourceToken!="string"&&t.push({path:`${i}.sourceToken`,message:"来源令牌应为字符串"})}const ce=new Set(["text","image","barcode","qrcode","chart","line","rect","ellipse"]);function p(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function R(e){return e===null?"null":typeof e=="string"?JSON.stringify(e.slice(0,120)):["number","boolean","undefined"].includes(typeof e)?String(e):`[${typeof e}]`}function he(e,i,t,s){const n=e[i];(typeof n!="number"||!Number.isFinite(n))&&s.push({path:`${t}.${i}`,message:`应为有限数字,实际 ${R(n)}`})}function me(e,i,t){if(e!==void 0){const s=`${i}.table`;if(!p(e))t.push({path:s,message:"逻辑表来源应为对象"});else{z(e.source,`${s}.source`,t),(typeof e.id!="string"||!e.id.trim())&&t.push({path:`${s}.id`,message:"逻辑表 ID 应为非空字符串"});const n=e.role;["header","body","group-header","subtotal","grand-total"].includes(n)||t.push({path:`${s}.role`,message:"未知逻辑表行角色"});const a=e.rowIndex;(typeof a!="number"||!Number.isInteger(a)||(n==="header"?a!==-1:a<0))&&t.push({path:`${s}.rowIndex`,message:"表头索引应为 -1,内容行索引应为非负整数"}),(!Array.isArray(e.columnKeys)||e.columnKeys.some(o=>typeof o!="string"))&&t.push({path:`${s}.columnKeys`,message:"逻辑列字段应为字符串数组"}),e.layout!==void 0&&e.layout!=="page"&&e.layout!=="wide"&&t.push({path:`${s}.layout`,message:"布局应为 page 或 wide"}),e.title!==void 0&&typeof e.title!="string"&&t.push({path:`${s}.title`,message:"逻辑表名称应为字符串"})}}}function ge(e,i,t,s){if(e!==void 0)if(!p(e)||!Array.isArray(e.cells))t.push({path:`${i}.grid.cells`,message:"grid.cells 应为二维数组"});else{const n=e.paddingMm;n!==void 0&&(typeof n!="number"||!Number.isFinite(n)||n<0)&&t.push({path:`${i}.grid.paddingMm`,message:"单元格内距应为有限非负数"}),e.cells.forEach((a,o)=>{if(!Array.isArray(a)){t.push({path:`${i}.grid.cells.${o}`,message:"行应为数组"});return}a.forEach((r,f)=>{if(r==null)return;const d=`${i}.grid.cells.${o}.${f}`;if(!p(r)){t.push({path:d,message:"网格单元格应为对象或 null"});return}ue(r,d,t),r.dataBar!==void 0&&!k.validDataBar(r.dataBar)&&t.push({path:`${d}.dataBar`,message:"数据条应包含 0–1 有序比例与 #RRGGBB 颜色"}),q(r.richParagraphs,d,t),Array.isArray(r.children)&&r.children.forEach((u,m)=>{B(u,`${i}.grid.cells.${o}.${f}.children.${m}`,t,s)})})})}}function T(e,i,t,s){e!==void 0&&!i.includes(e)&&s.push({path:t,message:"未知富文本属性值"})}function O(e,i,t,s,n=0){for(const a of i){const o=e[a];o!==void 0&&(typeof o!="number"||!Number.isFinite(o)||o<n)&&s.push({path:`${t}.${a}`,message:"富文本数值应为范围内有限数字"})}}function pe(e,i,t){if(e!==void 0){if(!p(e)){t.push({path:i,message:"富文本样式应为对象"});return}for(const s of["fontFamily","color","backgroundColor","lineColor","borderColor"])e[s]!==void 0&&typeof e[s]!="string"&&t.push({path:`${i}.${s}`,message:"富文本样式应为字符串"});for(const s of["bold","italic","underline","borderTop","borderRight","borderBottom","borderLeft"])e[s]!==void 0&&typeof e[s]!="boolean"&&t.push({path:`${i}.${s}`,message:"富文本样式应为布尔值"});O(e,["fontSize","fontSizePx","lineWidthPt","lineHeight","opacity"],i,t),O(e,["letterSpacing","rotateDeg"],i,t,-1/0),typeof e.opacity=="number"&&e.opacity>1&&t.push({path:`${i}.opacity`,message:"透明度不能大于1"}),T(e.align,["left","center","right","justify"],`${i}.align`,t),T(e.verticalAlign,["top","middle","bottom"],`${i}.verticalAlign`,t)}}function le(e,i,t){if(!p(e)){t.push({path:i,message:"富文本片段应为对象"});return}T(e.kind,["text","field"],`${i}.kind`,t);for(const s of["text","field"])e[s]!==void 0&&typeof e[s]!="string"&&t.push({path:`${i}.${s}`,message:"富文本内容应为字符串"});pe(e.style,`${i}.style`,t)}function q(e,i,t){if(e!==void 0){if(!Array.isArray(e)){t.push({path:`${i}.richParagraphs`,message:"richParagraphs 应为数组"});return}e.forEach((s,n)=>{const a=`${i}.richParagraphs.${n}`;if(!p(s)||!Array.isArray(s.segments)){t.push({path:a,message:"段落缺少 segments 数组"});return}T(s.align,["left","center","right","justify"],`${a}.align`,t),O(s,["lineHeight","spaceBeforeMm","spaceAfterMm","indentMm"],a,t),s.segments.forEach((o,r)=>le(o,`${a}.segments.${r}`,t))})}}function D(e,i,t,s=[]){const n=k.componentTreeIssue([e],i);if(n){t.push(n);return}B(e,i,t,s)}function B(e,i,t,s=[]){if(!p(e)){t.push({path:i,message:"组件应为对象"});return}const n=e.kind;typeof n!="string"?t.push({path:`${i}.kind`,message:"组件缺少 kind 字符串"}):ce.has(n)||s.push({path:`${i}.kind`,message:`未知组件类型 ${R(n)},将以兜底方式渲染`});for(const a of["leftMm","topMm","widthMm","heightMm"])he(e,a,i,t);typeof e.leftMm=="number"&&e.leftMm<-100&&t.push({path:`${i}.leftMm`,message:"几何数值异常(leftMm<-100)"});for(const a of["widthMm","heightMm"])typeof e[a]=="number"&&e[a]<0&&t.push({path:`${i}.${a}`,message:"组件尺寸不能为负数"});me(e.table,i,t),$e(e.code,n,i,t),ye(e,i,t),e.pageAnchor!==void 0&&!["header","footer"].includes(e.pageAnchor)&&t.push({path:`${i}.pageAnchor`,message:"页面锚点应为 header 或 footer"}),e.lineDirection!==void 0&&!["down","up"].includes(e.lineDirection)&&t.push({path:`${i}.lineDirection`,message:"线段方向应为 down 或 up"}),ge(e.grid,i,t,s),q(e.richParagraphs,i,t)}function ye(e,i,t){if(e.chartBinding!==void 0)try{if(C.validateReportChartBinding(e.chartBinding),e.kind!=="chart"||["binding","imageData","grid","pageAnchor"].some(s=>e[s]!==void 0))throw new Error("绑定图表不能设置图片、网格、记录绑定或页眉页脚");if(typeof e.widthMm!="number"||e.widthMm<45||typeof e.heightMm!="number"||e.heightMm<35)throw new Error("绑定图表至少需要 45×35mm")}catch(s){t.push({path:`${i}.chartBinding`,message:s instanceof Error?s.message:String(s)})}}function $e(e,i,t,s){if(e!==void 0)for(const n of fe.codeOptionIssues(e,i))s.push({path:`${t}.code${n.path?`.${n.path}`:""}`,message:n.message})}function X(e,i,t){if(!p(e))return;e.binding!==void 0&&t.push({path:`${i}.binding`,message:"渲染计划不允许未解析字段绑定"}),e.chartBinding!==void 0&&t.push({path:`${i}.chartBinding`,message:"渲染计划不允许未解析图表绑定"});const s=e.grid;!p(s)||!Array.isArray(s.cells)||s.cells.forEach((n,a)=>{Array.isArray(n)&&n.forEach((o,r)=>{!p(o)||!Array.isArray(o.children)||o.children.forEach((f,d)=>X(f,`${i}.grid.cells.${a}.${r}.children.${d}`,t))})})}function Y(e,i,t,s=[]){if(!p(e)){t.push({path:i,message:"页应为对象"});return}const n=e.pageWidthMm,a=e.pageHeightMm;(typeof n!="number"||!Number.isFinite(n)||n<=0)&&t.push({path:`${i}.pageWidthMm`,message:`页宽非法: ${R(n)}`}),(typeof a!="number"||!(a>0&&a<5e3))&&t.push({path:`${i}.pageHeightMm`,message:`页高非法: ${R(a)}`}),e.layout!==void 0&&e.layout!=="page"&&e.layout!=="wide"&&t.push({path:`${i}.layout`,message:"布局应为 page 或 wide"});const o=e.components;if(!Array.isArray(o))t.push({path:`${i}.components`,message:"components 应为数组"});else if(Array.isArray(o)){const r=k.componentTreeIssue(o,`${i}.components`);if(r){t.push(r);return}o.forEach((f,d)=>{B(f,`${i}.components.${d}`,t,s),X(f,`${i}.components.${d}`,t)})}}function Q(e){const i=[],t=[],s=p(e)?e.pages:void 0;if(p(e)&&e.requiresRecalculation!==void 0&&typeof e.requiresRecalculation!="boolean"&&i.push({path:"$.requiresRecalculation",message:"重算能力要求应为布尔值"}),!Array.isArray(s))i.push({path:"$.pages",message:e==null?"渲染计划为空":"渲染计划缺少 pages 数组"});else{const n=k.renderTreeIssue(s);if(n)return{ok:!1,errors:[...i,n],warnings:t};s.forEach((o,r)=>Y(o,`$.pages.${r}`,i,t)),s.length>2e3&&t.push({path:"$.pages",message:`页数异常大(${s.length} 页),渲染与打印耗时可能显著增加`});const a=s.reduce((o,r)=>o+(p(r)&&Array.isArray(r.components)?r.components.length:0),0);a>5e4&&t.push({path:"$.pages",message:`组件总数异常大(${a} 个),可能触发浏览器性能限制`})}return{ok:i.length===0,errors:i,warnings:t}}function be(e){const i=Q(e);if(!i.ok){const t=i.errors.slice(0,3).map(s=>`${s.path}: ${s.message}`).join("; ");throw new Error(`渲染计划校验失败(${i.errors.length} 处): ${t}`)}return e.pages}function V(e){return e.kind==="list"?e.id:e.nid}function Ae(e){return e.kind==="list"?!1:e.pageAnchor!==void 0||e.kind==="text"&&typeof e.text=="string"&&/\{(?:page|totalPages)\}/.test(e.text)}function we(e,i){const t=e.filter(n=>i.componentIds.includes(V(n)??""));if(t.filter(n=>n.kind==="list"&&n.cardinality!=="record").length&&t.length!==1)throw new Error("纵向重复区域必须独占流式分段,不能与静态或单记录区域并排");for(const n of t){const a=n.kind==="list"?n.topMm+(n.rowHeightMm??0):n.topMm+n.heightMm;if(n.topMm<i.topMm-.001||a>i.topMm+i.heightMm+.001)throw new Error("流式分段应完整包含其组件的原始纵向范围")}}function Me(e,i){if(!i)return e.map(s=>({components:[s]}));const t=new Map(e.map(s=>[V(s),s]));return i.bands.map(s=>({band:s,components:s.componentIds.map(n=>{const a=t.get(n);if(!a)throw new Error(`流式区域引用不存在的组件:${n}`);return a})}))}function Z(e,i){if(!i||!Array.isArray(i.bands)||!i.bands.length||i.bands.length>1e4)throw new Error("流式排版应包含 1–10000 个区域");const t=new Set,s=new Set;for(const n of e){if(Ae(n))continue;const a=V(n);if(!a||t.has(a))throw new Error("流式排版组件应具有唯一标识");t.add(a)}if(Ee(e,i,t,s),s.size!==t.size)throw new Error("流式排版必须显式包含每个非锚点组件")}function Ee(e,i,t,s){let n=-1/0;for(const a of i.bands){if(!Number.isFinite(a.topMm)||!Number.isFinite(a.heightMm)||a.topMm<0||a.heightMm<=0||a.topMm<n-.001)throw new Error("流式区域应按原始位置排序,尺寸有效且不重叠");if(!Array.isArray(a.componentIds)||!a.componentIds.length)throw new Error("流式区域不能没有组件");for(const o of a.componentIds){if(!t.has(o)||s.has(o))throw new Error(`流式区域组件缺失、重复或包含页锚点:${o}`);s.add(o)}we(e,a),n=a.topMm+a.heightMm}}const ke=new Set(["__proto__","prototype","constructor"]);function $(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function S(e){return typeof e=="string"&&!!e.trim()&&!ke.has(e)}function x(e,i,t,s){for(const n of Object.keys(e))i.includes(n)||s.push({path:`${t}.${n}`,message:"存在未知配置字段"})}function Se(e,i,t){if(e!==void 0){if(!$(e)||!["number","percent","date"].includes(String(e.kind))){t.push({path:i,message:"绑定格式应为 number、percent 或 date"});return}x(e,e.kind==="date"?["kind","pattern"]:e.kind==="number"?["kind","digits","thousands"]:["kind","digits"],i,t),e.digits!==void 0&&(!Number.isInteger(e.digits)||Number(e.digits)<0||Number(e.digits)>100)&&t.push({path:`${i}.digits`,message:"精度应为 0..100 整数"}),e.thousands!==void 0&&typeof e.thousands!="boolean"&&t.push({path:`${i}.thousands`,message:"千分位开关应为布尔值"}),e.pattern!==void 0&&typeof e.pattern!="string"&&t.push({path:`${i}.pattern`,message:"日期格式应为字符串"})}}function ve(e,i,t){const s=e.binding;if(s===void 0)return;const n=`${i}.binding`;if(!$(s)){t.push({path:n,message:"字段绑定应为对象"});return}(!["text","image","barcode","qrcode"].includes(String(e.kind))||e.grid!==void 0)&&t.push({path:n,message:"绑定仅支持独立文本、图片、条码与二维码组件"}),x(s,["field","format","prefix","suffix","emptyText"],n,t),S(s.field)||t.push({path:`${n}.field`,message:"绑定字段应为安全的非空字段名(按字面读取自有字段)"});for(const a of["prefix","suffix","emptyText"])s[a]!==void 0&&typeof s[a]!="string"&&t.push({path:`${n}.${a}`,message:"应为字符串"});Se(s.format,`${n}.format`,t),e.kind==="image"&&["format","prefix","suffix"].some(a=>s[a]!==void 0)&&t.push({path:n,message:"图片绑定直接读取 PNG/JPEG data URL,不支持文本格式或前后缀"})}function Ne(e,i){if(!$(e)){i.push({path:"$.repeat",message:"逐记录配置应为对象"});return}x(e,["dataset","rowKey","copies"],"$.repeat",i),S(e.dataset)||i.push({path:"$.repeat.dataset",message:"数据集应为安全的非空名称"}),e.rowKey!==void 0&&!S(e.rowKey)&&i.push({path:"$.repeat.rowKey",message:"业务主键应为安全的非空字段名"});const t=e.copies;t!==void 0&&($(t)?(x(t,["field"],"$.repeat.copies",i),S(t.field)||i.push({path:"$.repeat.copies.field",message:"复制数字段应为安全的非空字段名"})):(!Number.isSafeInteger(t)||Number(t)<1||Number(t)>1e3)&&i.push({path:"$.repeat.copies",message:"每条记录复制数应为 1..1000 整数"}))}function ee(e,i,t,s){if(!$(e))return;ve(e,i,s),e.binding!==void 0&&!t&&s.push({path:`${i}.binding`,message:"字段绑定需要模板 repeat 数据集;普通报表请使用列表字段"}),t&&e.kind==="list"&&s.push({path:i,message:"逐记录标签使用固定组件;动态列表请使用普通报表模板"}),e.chartBinding!==void 0&&(t||i.includes(".children."))&&s.push({path:`${i}.chartBinding`,message:"数据图表应放在普通报表的页面或流式分区,不放在逐记录标签或嵌套单元格内"});const n=e.grid;$(n)&&Array.isArray(n.cells)&&n.cells.forEach((a,o)=>{Array.isArray(a)&&a.forEach((r,f)=>{$(r)&&Array.isArray(r.children)&&r.children.forEach((d,u)=>ee(d,`${i}.grid.cells.${o}.${f}.children.${u}`,t,s))})})}function te(e,i){const t=e.repeat!==void 0;t&&Ne(e.repeat,i),Array.isArray(e.pages)&&e.pages.forEach((s,n)=>{if(!$(s))return;const a=`$.pages.${n}`;t&&(s.layout==="wide"||s.flow!==void 0)&&i.push({path:a,message:"逐记录标签仅支持固定尺寸页面,不支持宽表或流式分区"}),Array.isArray(s.components)&&s.components.forEach((o,r)=>{const f=`${a}.components.${r}`;if(ee(o,f,t,i),!t||!$(o))return;const{leftMm:d,topMm:u,widthMm:m,heightMm:l}=o;[d,u,m,l,s.widthMm,s.heightMm].every(y=>typeof y=="number"&&Number.isFinite(y))&&(Number(d)<0||Number(u)<0||Number(d)+Number(m)>Number(s.widthMm)+.001||Number(u)+Number(l)>Number(s.heightMm)+.001)&&i.push({path:f,message:"标签组件超出纸张边界,请调整位置或尺寸"})})})}function Re(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function _(e,i,t){if(e!==void 0)try{C.compileReportPredicate(e)}catch(s){t.push({path:i,message:s instanceof Error?s.message:String(s)})}}function ie(e,i,t){if(e===void 0)return;if(!Array.isArray(e)||e.length>2048){t.push({path:i,message:"聚合应为数组且最多 2048 项"});return}const s=new Set;e.forEach((n,a)=>{const o=`${i}.${a}`;if(!Re(n)){t.push({path:o,message:"聚合应为对象"});return}const r=n.field;typeof r!="string"||!r.trim()||s.has(r)?t.push({path:`${o}.field`,message:"聚合输出字段应非空且唯一"}):s.add(r),n.numeric!==void 0&&n.numeric!=="number"&&n.numeric!=="decimal"&&t.push({path:`${o}.numeric`,message:"数值模式应为 number 或 decimal"}),n.digits!==void 0&&(!Number.isInteger(n.digits)||Number(n.digits)<0||Number(n.digits)>100)&&t.push({path:`${o}.digits`,message:"小数位应为 0–100 的整数"});try{C.createAggregateAccumulator({...n,field:n.valueField??r})}catch(f){t.push({path:o,message:f instanceof Error?f.message:String(f)})}})}function Te(e,i,t){if(e===void 0)return;const s=C.validateComputedFields(e);for(const n of s.errors)t.push({path:i,message:n})}function xe(e,i,t){if(e!==void 0)try{re.validateMatrixOptions(e)}catch(s){t.push({path:i,message:s instanceof Error?s.message:String(s)})}}function Pe(e,i,t){if(e.tree===void 0)return;const s=`${i}.tree`;try{w.validateTreeOptions(e.tree);const n=e.tree;if(e.matrix||e.detail||e.groupBy||Array.isArray(e.groups)&&e.groups.length||e.rowVisibleWhen)throw new Error("树形布局不能同时配置普通分组、矩阵、主从或行可见条件");if(e.rowKey!==void 0&&e.rowKey!==n.idField)throw new Error("树形 rowKey 应与 idField 一致");if(!Array.isArray(e.columns)||!e.columns.some(a=>a&&a.field===n.labelField&&!a.hidden))throw new Error("树形布局需要可见的标签列");Array.isArray(e.computed)&&w.validateTreeComputed(n,e.computed)}catch(n){t.push({path:s,message:n instanceof Error?n.message:String(n)})}}const Ce=new Set(["__proto__","prototype","constructor"]),Fe=new Set(["text","number","boolean","date","decimal"]);function v(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function I(e){return typeof e=="string"&&!!e.trim()&&e.length<=4096&&!Ce.has(e)}function Oe(e,i,t){if(!Array.isArray(e)||!e.length||e.length>2048){t.push({path:i,message:"绑定契约应包含 1–2048 个字段"});return}const s=new Set;e.forEach((n,a)=>{const o=`${i}.${a}`;if(!v(n)||!I(n.field)||s.has(n.field)){t.push({path:o,message:"字段名应安全、非空且唯一"});return}s.add(n.field);for(const r of["label","semanticKey","unit"])n[r]!==void 0&&(typeof n[r]!="string"||String(n[r]).length>4096)&&t.push({path:`${o}.${r}`,message:"应为不超过 4096 位的字符串"});n.type!==void 0&&!Fe.has(String(n.type))&&t.push({path:`${o}.type`,message:"未知绑定字段类型"})})}function L(e,i,t){if(e===void 0)return;if(!v(e)||!v(e.datasets)){t.push({path:i,message:"模板数据契约应声明 datasets"});return}e.source!==void 0&&!I(e.source)&&t.push({path:`${i}.source`,message:"来源应为安全的非空业务标识"});const s=Object.entries(e.datasets);(!s.length||s.length>256)&&t.push({path:`${i}.datasets`,message:"应声明 1–256 个数据集"});for(const[n,a]of s){const o=`${i}.datasets.${n}`;!I(n)||!v(a)?t.push({path:o,message:"数据集应使用安全名称和字段契约"}):Oe(a.fields,`${o}.fields`,t)}}function J(e,i){return new Map(e.datasets[i]?.fields.map(t=>[t.field,t])??[])}function _e(e,i,t,s){const n=e.label||e.field;for(const[a,o,r]of[["semanticKey","semantic","业务含义"],["type","type","类型"],["unit","unit","单位"]])e[a]!==i[a]&&(e[a]!==void 0||i[a]!==void 0)&&s.push({...t,code:o,message:`字段“${n}”的${r}不兼容(${e[a]??"未声明"} → ${i[a]??"未声明"}),请重新绑定`})}function Ie(e,i){const t=[],s=[];if(L(i,"$.target",s),L(e.dataContract,"$.template.dataContract",s),s.length)return{ok:!1,issues:s.map(o=>({...o,code:"contract"}))};const n=e.dataContract;if(!n)return{ok:!1,issues:[{code:"contract",path:"$.template.dataContract",message:"模板未声明数据来源,请核对业务字段并重新绑定"}]};n.source!==i.source&&t.push({code:"source",path:"$.template.dataContract.source",message:`模板来源与当前报表不一致(${n.source??"未声明"} → ${i.source??"未声明"}),请从当前报表创建或重新绑定模板`});const a=new Set;for(const o of w.collectTemplateDatasetBindings(e)){const r=J(n,o.dataset),f=J(i,o.dataset);if(!r.size||!f.size){t.push({code:"dataset",dataset:o.dataset,path:o.path,message:`数据集“${o.dataset}”缺少来源或目标字段契约`});continue}for(const d of o.fields){if(o.generated.has(d.field)||d.summary&&o.summaries.has(d.field))continue;const u=`${o.dataset}\0${d.field}`;if(a.has(u))continue;a.add(u);const m=r.get(d.field),l=f.get(d.field),y={...d,dataset:o.dataset};!m||!l?t.push({...y,code:"field",message:`数据集“${o.dataset}”的字段“${d.field}”未声明,请重新绑定`}):_e(m,l,y,t)}}return{ok:t.length===0,issues:t}}const j="1.0";class M extends Error{constructor(i){super(`模板校验失败:${i.slice(0,3).map(t=>`${t.path}: ${t.message}`).join("; ")}`),this.errors=i,this.name="ReportTemplateError"}}const Le=new Set(["__proto__","prototype","constructor"]),De=new Set(["schemaVersion","id","name","revision","description","template"]),Be=new Set(["left","center","right","justify"]),N=2e5,Ve=64;function c(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function je(e,i,t){const s=Object.getPrototypeOf(e),n=Array.isArray(e);if(n?s!==Array.prototype:s!==Object.prototype&&s!==null)return t.push({path:i,message:"模板对象必须使用普通 JSON 对象原型"}),!1;if(n){const a=Object.keys(e);if(a.length!==e.length||a.some(o=>!/^(0|[1-9]\d*)$/.test(o)||Number(o)>=e.length))return t.push({path:i,message:"模板数组不能包含空位或额外属性"}),!1}return Object.getOwnPropertySymbols(e).length>0?(t.push({path:i,message:"模板不能包含 Symbol 键"}),!1):!0}function Ke(e,i,t,s){return Le.has(e)?(s.push({path:t,message:"模板不能包含可能污染原型的键"}),!1):i.get||i.set||!i.enumerable?(s.push({path:t,message:"模板不能包含访问器或不可枚举字段"}),!1):!0}function He(e){return e===null||typeof e=="boolean"||typeof e=="number"&&Number.isFinite(e)}function K(e,i){const t=new Set;let s=0,n=0,a=!1;const o=(r,f,d)=>{if(!a){if(++s>N){s===N+1&&i.push({path:f,message:"模板超过 JSON 节点安全上限"});return}if(d>Ve){i.push({path:f,message:"模板嵌套层级过深"});return}if(typeof r=="string"){n+=r.length,n>w.MAX_TEMPLATE_JSON_CHARACTERS&&(a=!0,i.push({path:f,message:"模板文本超过 1000 万字符的安全上限"}));return}if(!He(r)){if(!r||typeof r!="object"){i.push({path:f,message:"模板只允许 JSON 值,不允许函数、undefined 或非有限数字"});return}if(t.has(r)){i.push({path:f,message:"模板不能包含循环引用"});return}if(je(r,f,i)){t.add(r);for(const[u,m]of Object.entries(Object.getOwnPropertyDescriptors(r))){if(Array.isArray(r)&&u==="length")continue;const l=`${f}.${u}`;if(Ke(u,m,l,i)&&o(m.value,l,d+1),s>N||a)break}t.delete(r)}}}};o(e,"$",0)}function h(e,i,t,s,n=!1){const a=e[i];a===void 0&&!n||(typeof a!="string"||n&&!a.trim())&&s.push({path:`${t}.${i}`,message:n?"应为非空字符串":"应为字符串"})}function g(e,i,t,s,n=0,a=!1){const o=e[i];o===void 0&&!a||(typeof o!="number"||!Number.isFinite(o)||o<n)&&s.push({path:`${t}.${i}`,message:`应为大于等于 ${n} 的有限数字`})}function A(e,i,t,s){e[i]!==void 0&&typeof e[i]!="boolean"&&s.push({path:`${t}.${i}`,message:"应为布尔值"})}function E(e,i,t,s=!1){e!==void 0&&!Be.has(e)&&!(s&&e==="auto")&&t.push({path:i,message:`未知对齐方式${s?"(支持 auto)":""}`})}function b(e,i,t){if(e!==void 0){if(!c(e)){t.push({path:i,message:"样式应为对象"});return}E(e.align,`${i}.align`,t),e.verticalAlign!==void 0&&!["top","middle","bottom"].includes(e.verticalAlign)&&t.push({path:`${i}.verticalAlign`,message:"未知垂直对齐方式"});for(const s of["fontSize","fontSizePx","lineWidthPt","lineHeight"])g(e,s,i,t);for(const s of["letterSpacing","rotateDeg"])g(e,s,i,t,-1/0);g(e,"opacity",i,t),typeof e.opacity=="number"&&e.opacity>1&&t.push({path:`${i}.opacity`,message:"透明度不能大于 1"});for(const s of["bold","italic","underline","borderTop","borderRight","borderBottom","borderLeft"])A(e,s,i,t);for(const s of["fontFamily","color","backgroundColor","lineColor","borderColor"])h(e,s,i,t)}}function Je(e,i,t){if(e===void 0)return;if(!Array.isArray(e)){t.push({path:i,message:"参数定义应为数组"});return}const s=new Set,n=t.length;e.forEach((a,o)=>{const r=`${i}.${o}`;if(!c(a)){t.push({path:r,message:"参数定义应为对象"});return}h(a,"field",r,t,!0),typeof a.field=="string"&&(s.has(a.field)&&t.push({path:`${r}.field`,message:"参数名重复"}),s.add(a.field)),a.type!==void 0&&!["text","number","date","month","year","dateRange","select","multiSelect","cascader","numberRange"].includes(a.type)&&t.push({path:`${r}.type`,message:"未知参数类型"});for(const f of["label","defaultValue","placeholder"])h(a,f,r,t);A(a,"required",r,t);for(const f of["minLength","maxLength"]){const d=a[f];d!==void 0&&(typeof d!="number"||!Number.isSafeInteger(d)||d<0)&&t.push({path:`${r}.${f}`,message:"长度边界应为非负整数"})}We(a,r,t),a.options!==void 0&&(Array.isArray(a.options)?a.options.forEach((f,d)=>{const u=`${r}.options.${d}`;if(!c(f))t.push({path:u,message:"选项应为对象"});else for(const m of["label","value"])typeof f[m]!="string"&&t.push({path:`${u}.${m}`,message:"选项标签与值应为字符串(允许空白选项)"})}):t.push({path:`${r}.options`,message:"选项应为数组"}))}),t.length===n&&t.push(...G.validateReportParamDefinitions(e).map(a=>({path:a.path.replace("$.paramDefs",i),message:a.message})))}function We(e,i,t){for(const a of["min","max"]){const o=e[a];if(o===void 0)continue;G.isReportTemporalBound(e.type,o)||["number","numberRange"].includes(e.type)&&typeof o=="number"&&Number.isFinite(o)||t.push({path:`${i}.${a}`,message:"数字使用有限数字边界,日期/月/年使用对应规范字符串边界"})}const s=typeof e.min=="number"&&typeof e.max=="number"&&e.min>e.max,n=typeof e.min=="string"&&typeof e.max=="string"&&e.min>e.max;(s||n)&&t.push({path:i,message:"最小边界不能大于最大边界"}),typeof e.minLength=="number"&&typeof e.maxLength=="number"&&e.minLength>e.maxLength&&t.push({path:i,message:"最小长度不能大于最大长度"})}function se(e,i,t){if(!Array.isArray(e)||e.length===0){t.push({path:i,message:"列表至少需要一列"});return}e.every(s=>c(s)&&s.hidden===!0)&&t.push({path:i,message:"列表至少需要一列可见列"}),e.forEach((s,n)=>{const a=`${i}.${n}`;if(!c(s)){t.push({path:a,message:"列应为对象"});return}if(U(s,a,t),s.visual!==void 0&&!w.validColumnVisual(s.visual)&&t.push({path:`${a}.visual`,message:"列可视化配置无效,请检查类型、数值范围和颜色"}),A(s,"hidden",a,t),_(s.visibleWhen,`${a}.visibleWhen`,t),typeof s.header!="string"&&t.push({path:`${a}.header`,message:"表头应为字符串(允许空白表头)"}),h(s,"field",a,t,!0),g(s,"widthMm",a,t,Number.MIN_VALUE,!0),b(s.style,`${a}.style`,t),b(s.headerStyle,`${a}.headerStyle`,t),E(s.align,`${a}.align`,t,!0),E(s.headerAlign,`${a}.headerAlign`,t),s.semanticRole!==void 0&&!["identifier","dimension","measure","date","text"].includes(s.semanticRole)&&t.push({path:`${a}.semanticRole`,message:"未知列语义"}),s.format!==void 0)if(!c(s.format)||!["number","percent","date"].includes(s.format.kind))t.push({path:`${a}.format`,message:"未知列格式"});else{const o=s.format.digits;o!==void 0&&(typeof o!="number"||!Number.isInteger(o)||o<0||o>100)&&t.push({path:`${a}.format.digits`,message:"小数位应为 0–100 的整数"}),A(s.format,"thousands",`${a}.format`,t),h(s.format,"pattern",`${a}.format`,t)}s.rules!==void 0&&(Array.isArray(s.rules)?s.rules.forEach((o,r)=>{const f=`${a}.rules.${r}`;if(!c(o)||!c(o.when)){t.push({path:f,message:"条件格式缺少 when 对象"});return}_(o.when,`${f}.when`,t),b(o.style,`${f}.style`,t)}):t.push({path:`${a}.rules`,message:"条件格式应为数组"}))})}function ne(e,i,t){if(e!==void 0){if(!c(e)){t.push({path:i,message:"分组应为对象"});return}h(e,"field",i,t,!0);for(const s of["headerTemplate","subtotalLabel"])h(e,s,i,t);for(const s of["headerStyle","subtotalStyle"])b(e[s],`${i}.${s}`,t);A(e,"keepWithNext",i,t),A(e,"repeatHeader",i,t),ie(e.aggregates,`${i}.aggregates`,t),e.subtotal!==void 0&&(!Array.isArray(e.subtotal)||e.subtotal.some(s=>typeof s!="string"))&&t.push({path:`${i}.subtotal`,message:"小计字段应为字符串数组"})}}function Ge(e,i,t){if(!(e===void 0||typeof e=="boolean")){if(!c(e)){t.push({path:i,message:"合计应为布尔值或对象"});return}h(e,"label",i,t),ie(e.aggregates,`${i}.aggregates`,t),b(e.style,`${i}.style`,t),e.fields!==void 0&&(!Array.isArray(e.fields)||e.fields.some(s=>typeof s!="string"))&&t.push({path:`${i}.fields`,message:"合计字段应为字符串数组"})}}function Ue(e,i,t,s){const n={kind:"rect",leftMm:0,topMm:0,widthMm:1,heightMm:1,grid:e};if(D(n,t,s,[]),H(n,t,s),!c(e)||!Array.isArray(e.cells))return;const a=e.cells,o=Array.isArray(i)?i.length:0;if(a.length*o>N){s.push({path:t,message:"表头逻辑网格超过 20 万格安全上限"});return}e.cells.length||s.push({path:`${t}.cells`,message:"表头至少需要一行"}),Array.isArray(e.colWidthsMm)&&e.colWidthsMm.length!==o&&s.push({path:`${t}.colWidthsMm`,message:"表头列宽数量应与列表列数一致"}),Array.isArray(e.rowHeightsMm)&&e.rowHeightsMm.length!==e.cells.length&&s.push({path:`${t}.rowHeightsMm`,message:"表头行高数量应与行数一致"}),ze(a,o,t,s)}function ze(e,i,t,s){const n=new Set;e.forEach((a,o)=>{if(!Array.isArray(a))return;let r=0;a.forEach((f,d)=>{for(;n.has(`${o}:${r}`);)r++;const u=c(f)&&typeof f.colSpan=="number"?f.colSpan:1,m=c(f)&&typeof f.rowSpan=="number"?f.rowSpan:1;(r+u>i||o+m>e.length)&&s.push({path:`${t}.cells.${o}.${d}`,message:"表头合并区域超出表头边界"});for(let l=o;l<Math.min(e.length,o+m);l++)for(let y=r;y<Math.min(i,r+u);y++)n.has(`${l}:${y}`)&&s.push({path:`${t}.cells.${o}.${d}`,message:"表头合并区域重叠"}),n.add(`${l}:${y}`);r+=u})})}function qe(e,i,t){if(Pe(e,i,t),Te(e.computed,`${i}.computed`,t),xe(e.matrix,`${i}.matrix`,t),e.matrix&&(e.detail||e.groupBy||Array.isArray(e.groups)&&e.groups.length||e.grandTotal)&&t.push({path:`${i}.matrix`,message:"矩阵请使用自身 totals 汇总,不能同时配置普通分组、总计或主从明细"}),_(e.rowVisibleWhen,`${i}.rowVisibleWhen`,t),e.groups!==void 0&&(!Array.isArray(e.groups)||e.groups.length>16?t.push({path:`${i}.groups`,message:"分组应为数组,最多 16 级"}):e.groups.forEach((a,o)=>ne(a,`${i}.groups.${o}`,t))),e.detail===void 0)return;const s=e.detail,n=`${i}.detail`;if(!c(s)){t.push({path:n,message:"主从关联应为对象"});return}for(const a of["dataset","parentKey","foreignKey"])h(s,a,n,t,!0);for(const a of["rowKey","revisionField","sourceTokenField"])h(s,a,n,t,s[a]!==void 0);h(s,"label",n,t),A(s,"header",n,t),g(s,"rowHeightMm",n,t,Number.MIN_VALUE),se(s.columns,`${n}.columns`,t),s.unmatched!==void 0&&s.unmatched!=="error"&&s.unmatched!=="ignore"&&t.push({path:`${n}.unmatched`,message:"未关联明细策略应为 error 或 ignore"})}function Xe(e,i,t){for(const s of["leftMm","topMm"])g(e,s,i,t,-1/0,!0);g(e,"widthMm",i,t,Number.MIN_VALUE,!0),h(e,"dataset",i,t,!0),h(e,"title",i,t);for(const s of["rowKey","revisionField","sourceTokenField"])h(e,s,i,t,e[s]!==void 0);e.headerGrid!==void 0&&Ue(e.headerGrid,e.columns,`${i}.headerGrid`,t),e.layout!==void 0&&e.layout!=="page"&&e.layout!=="wide"&&t.push({path:`${i}.layout`,message:"布局应为 page 或 wide"}),se(e.columns,`${i}.columns`,t);for(const s of["fontSizePt","rowHeightMm"])g(e,s,i,t,Number.MIN_VALUE);g(e,"paddingMm",i,t);for(const s of["header","headerBold","headerEveryPage","border"])A(e,s,i,t);e.cardinality!==void 0&&e.cardinality!=="record"&&t.push({path:`${i}.cardinality`,message:"单记录区域类型应为 record"}),h(e,"headerBackgroundColor",i,t),E(e.align,`${i}.align`,t,!0),E(e.headerAlign,`${i}.headerAlign`,t),b(e.headerStyle,`${i}.headerStyle`,t),qe(e,i,t),ne(e.groupBy,`${i}.groupBy`,t),Ge(e.grandTotal,`${i}.grandTotal`,t)}function W(e,i,t){Array.isArray(e.richParagraphs)&&e.richParagraphs.forEach((s,n)=>{if(!c(s))return;const a=`${i}.richParagraphs.${n}`;E(s.align,`${a}.align`,t);for(const o of["lineHeight","spaceBeforeMm","spaceAfterMm","indentMm"])g(s,o,a,t);Array.isArray(s.segments)&&s.segments.forEach((o,r)=>{const f=`${a}.segments.${r}`;if(!c(o)){t.push({path:f,message:"富文本片段应为对象"});return}o.kind!==void 0&&o.kind!=="text"&&o.kind!=="field"&&t.push({path:`${f}.kind`,message:"未知富文本片段类型"});for(const d of["text","field"])h(o,d,f,t);b(o.style,`${f}.style`,t)})})}function H(e,i,t){b(e.style,`${i}.style`,t);for(const n of["text","rawText","imageData","fallbackText","nid","rkey"])h(e,n,i,t);if(e.lines!==void 0&&(!Array.isArray(e.lines)||e.lines.some(n=>typeof n!="string"))&&t.push({path:`${i}.lines`,message:"文本行应为字符串数组"}),W(e,i,t),!c(e.grid))return;const s=e.grid;g(s,"gapMm",`${i}.grid`,t),g(s,"paddingMm",`${i}.grid`,t);for(const n of["colWidthsMm","rowHeightsMm"]){const a=s[n];a!==void 0&&(!Array.isArray(a)||a.some(o=>typeof o!="number"||!Number.isFinite(o)||o<0))&&t.push({path:`${i}.grid.${n}`,message:"网格尺寸应为有限非负数字数组"})}Array.isArray(s.cells)&&s.cells.forEach((n,a)=>{Array.isArray(n)&&n.forEach((o,r)=>{const f=`${i}.grid.cells.${a}.${r}`;if(o!==null){if(!c(o)){t.push({path:f,message:"网格单元格应为对象或 null"});return}for(const d of["text","rawText","numberFormat"])h(o,d,f,t);for(const d of["colSpan","rowSpan"]){const u=o[d];u!==void 0&&(typeof u!="number"||!Number.isInteger(u)||u<=0)&&t.push({path:`${f}.${d}`,message:"跨度应为正整数"})}o.value!==void 0&&o.value!==null&&!["string","number","boolean"].includes(typeof o.value)&&t.push({path:`${f}.value`,message:"Excel 原始值应为字符串、数字、布尔值或 null"}),b(o.style,`${f}.style`,t),W(o,f,t),o.children!==void 0&&(Array.isArray(o.children)?o.children.forEach((d,u)=>{c(d)&&H(d,`${f}.children.${u}`,t)}):t.push({path:`${f}.children`,message:"嵌套组件应为数组"}))}})})}function Ye(e,i,t){if(!(e.flow===void 0||!Array.isArray(e.components)))try{Z(e.components,e.flow)}catch(s){t.push({path:`${i}.flow`,message:s instanceof Error?s.message:String(s)})}}function ae(e){const i=[],t=[];return K(e,i),i.length?{ok:!1,errors:i,warnings:t}:(c(e)?(e.schemaVersion!==void 0&&e.schemaVersion!==k.RENDER_PLAN_SCHEMA_VERSION&&i.push({path:"$.schemaVersion",message:"不支持的模板 schemaVersion"}),Je(e.params,"$.params",i),L(e.dataContract,"$.dataContract",i),te(e,i),!Array.isArray(e.pages)||e.pages.length===0?i.push({path:"$.pages",message:"模板至少需要一页"}):e.pages.forEach((s,n)=>{const a=`$.pages.${n}`;if(!c(s)){i.push({path:a,message:"页应为对象"});return}g(s,"widthMm",a,i,Number.MIN_VALUE,!0),g(s,"heightMm",a,i,Number.MIN_VALUE,!0),s.layout!==void 0&&s.layout!=="page"&&s.layout!=="wide"&&i.push({path:`${a}.layout`,message:"布局应为 page 或 wide"}),typeof s.heightMm=="number"&&s.heightMm>=5e3&&i.push({path:`${a}.heightMm`,message:"页高应小于 5000mm"});for(const o of["marginTopMm","marginBottomMm","marginLeftMm","marginRightMm"])g(s,o,a,i);typeof s.widthMm=="number"&&Number(s.marginLeftMm??0)+Number(s.marginRightMm??0)>=s.widthMm&&i.push({path:a,message:"横向页边距占满页面"}),typeof s.heightMm=="number"&&Number(s.marginTopMm??0)+Number(s.marginBottomMm??0)>=s.heightMm&&i.push({path:a,message:"纵向页边距占满页面"}),Array.isArray(s.components)?s.components.forEach((o,r)=>{const f=`${a}.components.${r}`;c(o)&&o.kind==="list"?Xe(o,f,i):(D(o,f,i,t),c(o)&&H(o,f,i))}):i.push({path:`${a}.components`,message:"组件应为数组"}),Ye(s,a,i)})):i.push({path:"$",message:"模板应为对象"}),{ok:i.length===0,errors:i,warnings:t})}function oe(e){const i=[],t=[];if(K(e,i),i.length)return{ok:!1,errors:i,warnings:t};if(!c(e))i.push({path:"$",message:"模板文档应为对象"});else{for(const n of Object.keys(e))De.has(n)||i.push({path:`$.${n}`,message:"模板文档存在未知字段;只保存模板与描述,不保存取数或业务数据"});e.schemaVersion!==j&&i.push({path:"$.schemaVersion",message:"不支持的模板文档版本"});for(const n of["id","name"])h(e,n,"$",i,!0);for(const n of["revision","description"])h(e,n,"$",i);const s=ae(e.template);i.push(...s.errors.map(n=>({...n,path:`$.template${n.path.slice(1)}`}))),t.push(...s.warnings.map(n=>({...n,path:`$.template${n.path.slice(1)}`})))}return{ok:i.length===0,errors:i,warnings:t}}function F(e){const i=oe(e);if(!i.ok)throw new M(i.errors)}function Qe(e){const i=[];if(K(e,i),i.length)throw new M(i);const t={...e,schemaVersion:e.schemaVersion??j};return F(t),P(t)}function Ze(e){let i=e;if(typeof e=="string"){if(e.length>w.MAX_TEMPLATE_JSON_CHARACTERS)throw new M([{path:"$",message:"模板 JSON 超过 1000 万字符的导出/导入上限"}]);try{i=JSON.parse(e)}catch{throw new M([{path:"$",message:"模板 JSON 语法无效"}])}}return F(i),P(i)}function et(e){F(e);try{return w.stringifyValidatedTemplate(e)}catch(i){throw i instanceof RangeError?new M([{path:"$",message:i.message}]):i}}function P(e){return JSON.parse(JSON.stringify(e))}function tt(e=[]){const i=new Map,t={get:s=>{const n=i.get(s);return n?P(n):void 0},list:()=>Array.from(i.values(),({template:s,...n})=>({...n})),register:(s,n={})=>{if(F(s),i.has(s.id)&&!n.replace)throw new M([{path:"$.id",message:`模板 ID ${s.id} 已注册;更新需显式 replace:true`}]);i.set(s.id,P(s))},remove:s=>i.delete(s)};for(const s of e)t.register(s);return t}exports.REPORT_TEMPLATE_DOCUMENT_VERSION=j;exports.ReportTemplateError=M;exports.assertRenderPlan=be;exports.createTemplateRegistry=tt;exports.defineReportTemplate=Qe;exports.inspectReportTemplateCompatibility=Ie;exports.parseReportTemplate=Ze;exports.reportFlowGroups=Me;exports.serializeReportTemplate=et;exports.validateComponent=D;exports.validatePage=Y;exports.validateRenderPlan=Q;exports.validateReportPageFlow=Z;exports.validateReportTemplate=ae;exports.validateReportTemplateDocument=oe;exports.validateTemplateRepeat=te;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { l as Z, n as ee, v as te, c as ie } from "./computed-f3pOqWLX.js";
|
|
2
|
+
import { v as se } from "./matrix-C6e_r_vp.js";
|
|
3
|
+
import { A as V, y as ne, B as ae, R as oe } from "./progress-ByiOxUD3.js";
|
|
4
4
|
import { c as fe } from "./code-options-BKXXY7NI.js";
|
|
5
5
|
import { v as re, m as de } from "./param-validation-CnDEd2l-.js";
|
|
6
|
-
import { a as he, d as ce, b as ue, M as K, v as me, s as ge } from "./template-serialization-
|
|
6
|
+
import { a as he, d as ce, b as ue, M as K, v as me, s as ge } from "./template-serialization-CWmHq7lX.js";
|
|
7
7
|
function pe(e, i, t) {
|
|
8
8
|
e !== void 0 && (typeof e != "string" || !e.trim() || e.length > 4096) && t.push({ path: i, message: "来源范围应为不超过 4096 字符的非空字符串" });
|
|
9
9
|
}
|
|
@@ -163,7 +163,7 @@ function O(e, i, t, s = []) {
|
|
|
163
163
|
function ke(e, i, t) {
|
|
164
164
|
if (e.chartBinding !== void 0)
|
|
165
165
|
try {
|
|
166
|
-
if (
|
|
166
|
+
if (Z(e.chartBinding), e.kind !== "chart" || ["binding", "imageData", "grid", "pageAnchor"].some((s) => e[s] !== void 0)) throw new Error("绑定图表不能设置图片、网格、记录绑定或页眉页脚");
|
|
167
167
|
if (typeof e.widthMm != "number" || e.widthMm < 45 || typeof e.heightMm != "number" || e.heightMm < 35) throw new Error("绑定图表至少需要 45×35mm");
|
|
168
168
|
} catch (s) {
|
|
169
169
|
t.push({ path: `${i}.chartBinding`, message: s instanceof Error ? s.message : String(s) });
|
|
@@ -352,7 +352,7 @@ function _e(e) {
|
|
|
352
352
|
function C(e, i, t) {
|
|
353
353
|
if (e !== void 0)
|
|
354
354
|
try {
|
|
355
|
-
|
|
355
|
+
ee(e);
|
|
356
356
|
} catch (s) {
|
|
357
357
|
t.push({ path: i, message: s instanceof Error ? s.message : String(s) });
|
|
358
358
|
}
|
|
@@ -382,7 +382,7 @@ function q(e, i, t) {
|
|
|
382
382
|
message: "小数位应为 0–100 的整数"
|
|
383
383
|
});
|
|
384
384
|
try {
|
|
385
|
-
|
|
385
|
+
ie({
|
|
386
386
|
...n,
|
|
387
387
|
field: n.valueField ?? f
|
|
388
388
|
});
|
|
@@ -396,10 +396,10 @@ function q(e, i, t) {
|
|
|
396
396
|
}
|
|
397
397
|
function Le(e, i, t) {
|
|
398
398
|
if (e === void 0) return;
|
|
399
|
-
const s =
|
|
399
|
+
const s = te(e);
|
|
400
400
|
for (const n of s.errors) t.push({ path: i, message: n });
|
|
401
401
|
}
|
|
402
|
-
function
|
|
402
|
+
function Be(e, i, t) {
|
|
403
403
|
if (e !== void 0)
|
|
404
404
|
try {
|
|
405
405
|
se(e);
|
|
@@ -410,7 +410,7 @@ function je(e, i, t) {
|
|
|
410
410
|
});
|
|
411
411
|
}
|
|
412
412
|
}
|
|
413
|
-
function
|
|
413
|
+
function je(e, i, t) {
|
|
414
414
|
if (e.tree === void 0) return;
|
|
415
415
|
const s = `${i}.tree`;
|
|
416
416
|
try {
|
|
@@ -463,7 +463,7 @@ function I(e, i, t) {
|
|
|
463
463
|
!P(n) || !E(a) ? t.push({ path: o, message: "数据集应使用安全名称和字段契约" }) : Ke(a.fields, `${o}.fields`, t);
|
|
464
464
|
}
|
|
465
465
|
}
|
|
466
|
-
function
|
|
466
|
+
function j(e, i) {
|
|
467
467
|
return new Map(e.datasets[i]?.fields.map((t) => [t.field, t]) ?? []);
|
|
468
468
|
}
|
|
469
469
|
function He(e, i, t, s) {
|
|
@@ -479,7 +479,7 @@ function pt(e, i) {
|
|
|
479
479
|
n.source !== i.source && t.push({ code: "source", path: "$.template.dataContract.source", message: `模板来源与当前报表不一致(${n.source ?? "未声明"} → ${i.source ?? "未声明"}),请从当前报表创建或重新绑定模板` });
|
|
480
480
|
const a = /* @__PURE__ */ new Set();
|
|
481
481
|
for (const o of ue(e)) {
|
|
482
|
-
const f =
|
|
482
|
+
const f = j(n, o.dataset), r = j(i, o.dataset);
|
|
483
483
|
if (!f.size || !r.size) {
|
|
484
484
|
t.push({ code: "dataset", dataset: o.dataset, path: o.path, message: `数据集“${o.dataset}”缺少来源或目标字段契约` });
|
|
485
485
|
continue;
|
|
@@ -678,7 +678,7 @@ function Ze(e, i, t) {
|
|
|
678
678
|
}
|
|
679
679
|
function et(e, i, t, s) {
|
|
680
680
|
const n = { kind: "rect", leftMm: 0, topMm: 0, widthMm: 1, heightMm: 1, grid: e };
|
|
681
|
-
if (G(n, t, s, []),
|
|
681
|
+
if (G(n, t, s, []), B(n, t, s), !c(e) || !Array.isArray(e.cells)) return;
|
|
682
682
|
const a = e.cells, o = Array.isArray(i) ? i.length : 0;
|
|
683
683
|
if (a.length * o > S) {
|
|
684
684
|
s.push({ path: t, message: "表头逻辑网格超过 20 万格安全上限" });
|
|
@@ -703,7 +703,7 @@ function tt(e, i, t, s) {
|
|
|
703
703
|
});
|
|
704
704
|
}
|
|
705
705
|
function it(e, i, t) {
|
|
706
|
-
if (
|
|
706
|
+
if (je(e, i, t), Le(e.computed, `${i}.computed`, t), Be(e.matrix, `${i}.matrix`, t), e.matrix && (e.detail || e.groupBy || Array.isArray(e.groups) && e.groups.length || e.grandTotal) && t.push({ path: `${i}.matrix`, message: "矩阵请使用自身 totals 汇总,不能同时配置普通分组、总计或主从明细" }), C(e.rowVisibleWhen, `${i}.rowVisibleWhen`, t), e.groups !== void 0 && (!Array.isArray(e.groups) || e.groups.length > 16 ? t.push({ path: `${i}.groups`, message: "分组应为数组,最多 16 级" }) : e.groups.forEach((a, o) => Q(a, `${i}.groups.${o}`, t))), e.detail === void 0) return;
|
|
707
707
|
const s = e.detail, n = `${i}.detail`;
|
|
708
708
|
if (!c(s)) {
|
|
709
709
|
t.push({ path: n, message: "主从关联应为对象" });
|
|
@@ -741,7 +741,7 @@ function D(e, i, t) {
|
|
|
741
741
|
});
|
|
742
742
|
});
|
|
743
743
|
}
|
|
744
|
-
function
|
|
744
|
+
function B(e, i, t) {
|
|
745
745
|
b(e.style, `${i}.style`, t);
|
|
746
746
|
for (const n of ["text", "rawText", "imageData", "fallbackText", "nid", "rkey"]) u(e, n, i, t);
|
|
747
747
|
if (e.lines !== void 0 && (!Array.isArray(e.lines) || e.lines.some((n) => typeof n != "string")) && t.push({ path: `${i}.lines`, message: "文本行应为字符串数组" }), D(e, i, t), !c(e.grid)) return;
|
|
@@ -765,7 +765,7 @@ function j(e, i, t) {
|
|
|
765
765
|
h !== void 0 && (typeof h != "number" || !Number.isInteger(h) || h <= 0) && t.push({ path: `${r}.${d}`, message: "跨度应为正整数" });
|
|
766
766
|
}
|
|
767
767
|
o.value !== void 0 && o.value !== null && !["string", "number", "boolean"].includes(typeof o.value) && t.push({ path: `${r}.value`, message: "Excel 原始值应为字符串、数字、布尔值或 null" }), b(o.style, `${r}.style`, t), D(o, r, t), o.children !== void 0 && (Array.isArray(o.children) ? o.children.forEach((d, h) => {
|
|
768
|
-
c(d) &&
|
|
768
|
+
c(d) && B(d, `${r}.children.${h}`, t);
|
|
769
769
|
}) : t.push({ path: `${r}.children`, message: "嵌套组件应为数组" }));
|
|
770
770
|
}
|
|
771
771
|
});
|
|
@@ -791,7 +791,7 @@ function at(e) {
|
|
|
791
791
|
for (const o of ["marginTopMm", "marginBottomMm", "marginLeftMm", "marginRightMm"]) g(s, o, a, i);
|
|
792
792
|
typeof s.widthMm == "number" && Number(s.marginLeftMm ?? 0) + Number(s.marginRightMm ?? 0) >= s.widthMm && i.push({ path: a, message: "横向页边距占满页面" }), typeof s.heightMm == "number" && Number(s.marginTopMm ?? 0) + Number(s.marginBottomMm ?? 0) >= s.heightMm && i.push({ path: a, message: "纵向页边距占满页面" }), Array.isArray(s.components) ? s.components.forEach((o, f) => {
|
|
793
793
|
const r = `${a}.components.${f}`;
|
|
794
|
-
c(o) && o.kind === "list" ? st(o, r, i) : (G(o, r, i, t), c(o) &&
|
|
794
|
+
c(o) && o.kind === "list" ? st(o, r, i) : (G(o, r, i, t), c(o) && B(o, r, i));
|
|
795
795
|
}) : i.push({ path: `${a}.components`, message: "组件应为数组" }), nt(s, a, i);
|
|
796
796
|
})) : i.push({ path: "$", message: "模板应为对象" }), { ok: i.length === 0, errors: i, warnings: t });
|
|
797
797
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const b=require("./computed-4TnxzgIh.cjs");function c(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function a(e,r,i){typeof e=="string"?i.push({field:e,path:r}):Array.isArray(e)&&e.forEach((n,t)=>a(n,`${r}[${t}]`,i))}function w(e,r,i){if(Array.isArray(e)){e.forEach((n,t)=>w(n,`${r}[${t}]`,i));return}if(c(e))for(const[n,t]of Object.entries(e))["field","weightField"].includes(n)?a(t,`${r}.${n}`,i):n!=="value"&&n!=="style"&&w(t,`${r}.${n}`,i)}function p(e,r,i){Array.isArray(e)&&e.forEach((n,t)=>{if(!c(n))return;typeof n.field=="string"&&n.valueField!==void 0&&n.valueField!==n.field&&i.summaries.add(n.field);const o=n.valueField===void 0?"field":"valueField";a(n[o],`${r}[${t}].${o}`,i.fields),n.valueField!==void 0&&n.valueField===n.field&&a(n.field,`${r}[${t}].field`,i.fields),a(n.weightField,`${r}[${t}].weightField`,i.fields)})}function I(e,r,i){for(const t of["rowKey","revisionField","sourceTokenField"])a(e[t],`${r}.${t}`,i.fields);if(!e.matrix&&Array.isArray(e.columns)&&e.columns.forEach((t,o)=>{c(t)&&(typeof t.field=="string"&&i.fields.push({field:t.field,path:`${r}.columns[${o}].field`,summary:!0}),w(t.rules,`${r}.columns[${o}].rules`,i.fields),w(t.visibleWhen,`${r}.columns[${o}].visibleWhen`,i.fields))}),w(e.rowVisibleWhen,`${r}.rowVisibleWhen`,i.fields),Array.isArray(e.computed)&&e.computed.forEach((t,o)=>{c(t)&&(typeof t.field=="string"&&i.generated.add(t.field),w(t.expression,`${r}.computed[${o}].expression`,i.fields),a(t.dependsOn,`${r}.computed[${o}].dependsOn`,i.fields),a(t.groupBy,`${r}.computed[${o}].groupBy`,i.fields))}),(Array.isArray(e.groups)?e.groups.map((t,o)=>({group:t,path:`${r}.groups[${o}]`})):e.groupBy?[{group:e.groupBy,path:`${r}.groupBy`}]:[]).forEach(({group:t,path:o})=>{c(t)&&(a(t.field,`${o}.field`,i.fields),a(t.subtotal,`${o}.subtotal`,i.fields),p(t.aggregates,`${o}.aggregates`,i))}),c(e.grandTotal)&&(a(e.grandTotal.fields,`${r}.grandTotal.fields`,i.fields),p(e.grandTotal.aggregates,`${r}.grandTotal.aggregates`,i)),c(e.matrix)&&(a(e.matrix.rowFields,`${r}.matrix.rowFields`,i.fields),a(e.matrix.columnFields,`${r}.matrix.columnFields`,i.fields),p(e.matrix.measures,`${r}.matrix.measures`,i)),c(e.tree)){for(const t of["idField","parentField","labelField"])a(e.tree[t],`${r}.tree.${t}`,i.fields);p(e.tree.aggregates,`${r}.tree.aggregates`,i)}c(e.detail)&&a(e.detail.parentKey,`${r}.detail.parentKey`,i.fields)}function L(e){const r=[],i=e.repeat,n=i?{dataset:i.dataset,path:"$.template.repeat",fields:[],generated:new Set,summaries:new Set}:void 0;n&&i&&(a(i.rowKey,"$.template.repeat.rowKey",n.fields),typeof i.copies=="object"&&a(i.copies.field,"$.template.repeat.copies.field",n.fields),r.push(n));function t(o,s){if(Array.isArray(o)){o.forEach((f,l)=>t(f,`${s}[${l}]`));return}if(c(o)){if(n&&c(o.binding)&&a(o.binding.field,`${s}.binding.field`,n.fields),c(o.chartBinding)&&typeof o.chartBinding.dataset=="string"){const f=`${s}.chartBinding`,l=o.chartBinding,d={dataset:l.dataset,path:f,fields:[],generated:new Set,summaries:new Set};a(l.categoryField,`${f}.categoryField`,d.fields),w(l.measures,`${f}.measures`,d.fields),r.push(d)}if(typeof o.dataset=="string"&&Array.isArray(o.columns)){const f={dataset:o.dataset,path:s,fields:[],generated:new Set,summaries:new Set};I(o,s,f),typeof o.foreignKey=="string"&&a(o.foreignKey,`${s}.foreignKey`,f.fields),r.push(f)}for(const[f,l]of Object.entries(o))t(l,`${s}.${f}`)}}return t(e,"$.template"),r}class M extends Error{constructor(r){super(`树节点超出行数预算 ${r}`),this.limit=r,this.code="tree-row-limit",this.name="TreeRowLimitError"}}function F(e,r,i,n){const t=e??r;if(!Number.isInteger(t)||t<1||t>i)throw new Error(`${n}应为 1–${i} 的整数`);return t}function T(e){return{rows:F(e.maxRows,1e5,1e6,"树行数预算"),depth:F(e.maxDepth,64,256,"树深度预算"),visits:F(e.maxAggregationVisits,1e6,1e7,"树聚合访问预算")}}function S(e){return typeof e=="string"&&!!e.trim()}function m(e){return S(e)&&!["__proto__","prototype","constructor"].includes(e)}function C(e){if(S(e)||typeof e=="number"&&Number.isFinite(e))return e;throw new Error("树节点业务键应为非空字符串或有限数字")}function N(e){return JSON.stringify([typeof e,e])}function O(e){return[e.idField,...e.input==="flat"?[e.parentField??""]:[e.childrenField??"children"]]}function V(e,r){const i=O(e);if(r?.some(n=>n.scope&&n.scope!=="row"||i.includes(n.field)))throw new Error("树形布局仅支持不覆盖结构键的当前行计算")}function g(e){if(!e?.aborted)return;const r=new Error("树报表处理已取消");throw r.name="AbortError",r}function D(e){const r=e.aggregates??[];if(!Array.isArray(r)||r.length>32)throw new Error("树聚合最多 32 项");if(e.parentValues!=="leaf-aggregate"&&r.length)throw new Error("树聚合需显式选择 leaf-aggregate 父级取值策略");if(e.parentValues==="leaf-aggregate"&&!r.length)throw new Error("叶子聚合策略至少需要一个聚合字段");const i=new Set;for(const n of r){if(!n||!m(n.field)||i.has(n.field))throw new Error("树聚合输出字段应安全、非空且唯一");for(const t of[n.valueField,n.weightField])if(t!==void 0&&!m(t))throw new Error("树聚合来源字段应安全且非空");if([...O(e),e.labelField].includes(n.field))throw new Error("树聚合不能覆盖结构键或标签字段");i.add(n.field),b.createAggregateAccumulator({...n,field:n.valueField??n.field})}}function J(e){if(!m(e.idField)||!m(e.labelField))throw new Error("树需要安全的业务键和标签字段");if(e.input==="flat"&&(!m(e.parentField)||e.parentField===e.idField))throw new Error("扁平树需要独立的父键字段");if(e.childrenField!==void 0&&!m(e.childrenField))throw new Error("子节点字段应安全且非空");if(e.input==="nested"&&[e.idField,e.labelField].includes(e.childrenField??"children"))throw new Error("子节点字段不能覆盖业务键或标签字段")}function x(e){if(!e||typeof e!="object"||!["flat","nested"].includes(e.input))throw new Error("树输入应为 flat 或 nested");if(J(e),e.orphan!==void 0&&!["error","root"].includes(e.orphan))throw new Error("树孤儿策略应为 error 或 root");if(e.parentValues!==void 0&&!["source","leaf-aggregate"].includes(e.parentValues))throw new Error("未知树父级取值策略");if(e.indentMm!==void 0&&(!Number.isFinite(e.indentMm)||e.indentMm<0||e.indentMm>20))throw new Error("树每级缩进应为 0–20 mm");T(e),D(e)}function B(e,r,i,n){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("树节点应为对象");if(i.size>=n.rows)throw new M(n.rows);const t=C(e[r.idField]),o=N(t);if(i.has(o))throw new Error(`树节点业务键重复:${String(t)}`);const s={original:e,row:e,key:t,depth:0,children:[]};return i.set(o,s),s}function W(e,r,i,n,t){for(const s of e)g(t),B(s,r,i,n);const o=[];for(const s of i.values()){g(t);const f=s.row[r.parentField];if(f==null){o.push(s);continue}const l=i.get(N(C(f)));if(!l){if(r.orphan!=="root")throw new Error(`树节点 ${String(s.key)} 的父节点不存在`);o.push(s);continue}if(l===s)throw new Error("树节点不能以自身为父节点");s.parent=l,l.children.push(s)}return o}function z(e,r,i,n,t){const o=[],s=[{rows:e,next:0}];for(;s.length;){g(t);const f=s[s.length-1];if(f.next>=f.rows.length){s.pop();continue}const l=B(f.rows[f.next++],r,i,n);if(l.parent=f.parent,l.depth=s.length-1,s.length>n.depth)throw new Error(`树节点超出深度预算 ${n.depth}`);(f.parent?.children??o).push(l);const d=l.row[r.childrenField??"children"];if(d!=null){if(!Array.isArray(d))throw new Error("嵌套树 children 字段应为数组");d.length&&s.push({rows:d,next:0,parent:l})}}return o}function H(e,r,i,n){const t=[],o=[{nodes:e,next:0}];for(;o.length;){g(n);const s=o[o.length-1];if(s.next>=s.nodes.length){o.pop();continue}if(o.length>i.depth)throw new Error(`树节点超出深度预算 ${i.depth}`);const f=s.nodes[s.next++];f.depth=o.length-1,t.push(f),f.children.length&&o.push({nodes:f.children,next:0})}if(t.length!==r)throw new Error("树父子关系存在循环");return t}function X(e,r,i,n){if(r.parentValues!=="leaf-aggregate")return;const t=r.aggregates,o=new Map;for(const f of e)f.children.length&&o.set(f,t.map(l=>b.createAggregateAccumulator({...l,field:l.valueField??l.field})));let s=0;for(const f of e)if(!f.children.length)for(let l=f.parent;l;l=l.parent){if(g(n),s+=t.length,s>i.visits)throw new Error(`树聚合超出访问预算 ${i.visits}`);for(const d of o.get(l))d.add(f.row)}for(const[f,l]of o)f.row={...f.row},t.forEach((d,u)=>{f.row[d.field]=l[u].value()})}function R(e,r,i){if(x(r),g(i),!Array.isArray(e))throw new Error("树数据应为节点数组");const n=T(r),t=new Map,o=r.input==="flat"?W(e,r,t,n,i):z(e,r,t,n,i);return H(o,t.size,n,i)}function q(e,r,i){return R(e,r,i).map(n=>n.original)}function P(e,r,i={}){const n=R(e,r,i.signal);if(V(r,i.computed?.fields),i.computed?.fields.length){const t=b.computeDataset(n.map(o=>o.row),{...i.computed,signal:i.signal}).rows;n.forEach((o,s)=>{o.row=t[s]})}return X(n,r,T(r),i.signal),{rows:n.map(t=>t.row),entries:n.map(t=>({row:t.row,original:t.original,key:t.key,depth:t.depth,hasChildren:!!t.children.length})),leaves:n.filter(t=>!t.children.length).map(t=>t.row)}}const G=/^#[0-9a-f]{6}$/i;function j(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const r=e;return r.kind!=="colorScale"&&r.kind!=="dataBar"||r.field!==void 0&&(typeof r.field!="string"||!r.field.trim())||r.numeric!==void 0&&!["number","decimal"].includes(r.numeric)||[r.min,r.max].some(i=>i!==void 0&&(typeof i!="number"||!Number.isFinite(i)))||r.min!==void 0&&r.max!==void 0&&r.min>r.max?!1:Object.entries(r).every(([i,n])=>!["color","negativeColor","lowColor","highColor"].includes(i)||typeof n=="string"&&G.test(n))}function _(e,r){if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(r!=="decimal"||typeof e!="string"||e.length>1024||!/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(e))return;const i=Number(e);return Number.isFinite(i)?i:void 0}function Q(e,r,i){let n="#";for(const t of[1,3,5]){const o=parseInt(e.slice(t,t+2),16),s=parseInt(r.slice(t,t+2),16);n+=Math.round(o+(s-o)*i).toString(16).padStart(2,"0")}return n}function A(e,r,i){if(r===i)return e<r?0:e>i?1:.5;if(e<=r)return 0;if(e>=i)return 1;const n=i-r;return Number.isFinite(n)?(e-r)/n:(e/2-r/2)/(i/2-r/2)}function U(e,r,i,n){const t=new WeakMap;return{apply(o,s){const f=_(s[r],e.numeric);if(f===void 0)return;if(e.kind==="dataBar"){const h=Math.min(i,0),$=Math.max(n,0),E=A(0,h,$),v=h===$?E:A(f,h,$);o.dataBar={start:Math.min(E,v),end:Math.max(E,v),color:f<0?e.negativeColor??"#f3bcc3":e.color??"#bad8fa"};return}const l=Q(e.lowColor??"#f0f7ff",e.highColor??"#8bbcf1",A(f,i,n)),d=o.style??{},u=t.get(d)??new Map;t.set(d,u);let y=u.get(l);y||(y={...d,backgroundColor:l},u.set(l,y)),o.style=y}}}function Y(e,r,i){return e.map(n=>{k(i);const t=n.visual;if(!t)return;if(!j(t))throw new TypeError("Invalid column visual rule");const o=t.field??n.field;let s=1/0,f=-1/0,l=0;if(t.min===void 0||t.max===void 0)for(const y of r){(l++&1023)===0&&k(i);const h=_(y[o],t.numeric);h!==void 0&&(s=Math.min(s,h),f=Math.max(f,h))}let d=t.min??s,u=t.max??f;if(!(!Number.isFinite(d)||!Number.isFinite(u)))return d>u&&(t.min!==void 0?u=d:d=u),U(t,o,d,u)})}function k(e){if(e?.aborted)throw e.reason??new DOMException("Aborted","AbortError")}const K=1e7;function Z(e){const r=JSON.stringify(e,null,2);if(r.length>K)throw new RangeError("模板 JSON 超过 1000 万字符的导出/导入上限");return r}exports.MAX_TEMPLATE_JSON_CHARACTERS=K;exports.TreeRowLimitError=M;exports.collectTemplateDatasetBindings=L;exports.createColumnVisualResolvers=Y;exports.createTreeTable=P;exports.flattenTreeInput=q;exports.stringifyValidatedTemplate=Z;exports.validColumnVisual=j;exports.validateTreeComputed=V;exports.validateTreeOptions=x;
|
|
1
|
+
"use strict";const b=require("./computed-DK6BruFz.cjs");function c(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function a(e,r,i){typeof e=="string"?i.push({field:e,path:r}):Array.isArray(e)&&e.forEach((n,t)=>a(n,`${r}[${t}]`,i))}function w(e,r,i){if(Array.isArray(e)){e.forEach((n,t)=>w(n,`${r}[${t}]`,i));return}if(c(e))for(const[n,t]of Object.entries(e))["field","weightField"].includes(n)?a(t,`${r}.${n}`,i):n!=="value"&&n!=="style"&&w(t,`${r}.${n}`,i)}function p(e,r,i){Array.isArray(e)&&e.forEach((n,t)=>{if(!c(n))return;typeof n.field=="string"&&n.valueField!==void 0&&n.valueField!==n.field&&i.summaries.add(n.field);const o=n.valueField===void 0?"field":"valueField";a(n[o],`${r}[${t}].${o}`,i.fields),n.valueField!==void 0&&n.valueField===n.field&&a(n.field,`${r}[${t}].field`,i.fields),a(n.weightField,`${r}[${t}].weightField`,i.fields)})}function I(e,r,i){for(const t of["rowKey","revisionField","sourceTokenField"])a(e[t],`${r}.${t}`,i.fields);if(!e.matrix&&Array.isArray(e.columns)&&e.columns.forEach((t,o)=>{c(t)&&(typeof t.field=="string"&&i.fields.push({field:t.field,path:`${r}.columns[${o}].field`,summary:!0}),w(t.rules,`${r}.columns[${o}].rules`,i.fields),w(t.visibleWhen,`${r}.columns[${o}].visibleWhen`,i.fields))}),w(e.rowVisibleWhen,`${r}.rowVisibleWhen`,i.fields),Array.isArray(e.computed)&&e.computed.forEach((t,o)=>{c(t)&&(typeof t.field=="string"&&i.generated.add(t.field),w(t.expression,`${r}.computed[${o}].expression`,i.fields),a(t.dependsOn,`${r}.computed[${o}].dependsOn`,i.fields),a(t.groupBy,`${r}.computed[${o}].groupBy`,i.fields))}),(Array.isArray(e.groups)?e.groups.map((t,o)=>({group:t,path:`${r}.groups[${o}]`})):e.groupBy?[{group:e.groupBy,path:`${r}.groupBy`}]:[]).forEach(({group:t,path:o})=>{c(t)&&(a(t.field,`${o}.field`,i.fields),a(t.subtotal,`${o}.subtotal`,i.fields),p(t.aggregates,`${o}.aggregates`,i))}),c(e.grandTotal)&&(a(e.grandTotal.fields,`${r}.grandTotal.fields`,i.fields),p(e.grandTotal.aggregates,`${r}.grandTotal.aggregates`,i)),c(e.matrix)&&(a(e.matrix.rowFields,`${r}.matrix.rowFields`,i.fields),a(e.matrix.columnFields,`${r}.matrix.columnFields`,i.fields),p(e.matrix.measures,`${r}.matrix.measures`,i)),c(e.tree)){for(const t of["idField","parentField","labelField"])a(e.tree[t],`${r}.tree.${t}`,i.fields);p(e.tree.aggregates,`${r}.tree.aggregates`,i)}c(e.detail)&&a(e.detail.parentKey,`${r}.detail.parentKey`,i.fields)}function L(e){const r=[],i=e.repeat,n=i?{dataset:i.dataset,path:"$.template.repeat",fields:[],generated:new Set,summaries:new Set}:void 0;n&&i&&(a(i.rowKey,"$.template.repeat.rowKey",n.fields),typeof i.copies=="object"&&a(i.copies.field,"$.template.repeat.copies.field",n.fields),r.push(n));function t(o,s){if(Array.isArray(o)){o.forEach((f,l)=>t(f,`${s}[${l}]`));return}if(c(o)){if(n&&c(o.binding)&&a(o.binding.field,`${s}.binding.field`,n.fields),c(o.chartBinding)&&typeof o.chartBinding.dataset=="string"){const f=`${s}.chartBinding`,l=o.chartBinding,d={dataset:l.dataset,path:f,fields:[],generated:new Set,summaries:new Set};a(l.categoryField,`${f}.categoryField`,d.fields),w(l.measures,`${f}.measures`,d.fields),r.push(d)}if(typeof o.dataset=="string"&&Array.isArray(o.columns)){const f={dataset:o.dataset,path:s,fields:[],generated:new Set,summaries:new Set};I(o,s,f),typeof o.foreignKey=="string"&&a(o.foreignKey,`${s}.foreignKey`,f.fields),r.push(f)}for(const[f,l]of Object.entries(o))t(l,`${s}.${f}`)}}return t(e,"$.template"),r}class M extends Error{constructor(r){super(`树节点超出行数预算 ${r}`),this.limit=r,this.code="tree-row-limit",this.name="TreeRowLimitError"}}function F(e,r,i,n){const t=e??r;if(!Number.isInteger(t)||t<1||t>i)throw new Error(`${n}应为 1–${i} 的整数`);return t}function T(e){return{rows:F(e.maxRows,1e5,1e6,"树行数预算"),depth:F(e.maxDepth,64,256,"树深度预算"),visits:F(e.maxAggregationVisits,1e6,1e7,"树聚合访问预算")}}function S(e){return typeof e=="string"&&!!e.trim()}function m(e){return S(e)&&!["__proto__","prototype","constructor"].includes(e)}function C(e){if(S(e)||typeof e=="number"&&Number.isFinite(e))return e;throw new Error("树节点业务键应为非空字符串或有限数字")}function N(e){return JSON.stringify([typeof e,e])}function O(e){return[e.idField,...e.input==="flat"?[e.parentField??""]:[e.childrenField??"children"]]}function V(e,r){const i=O(e);if(r?.some(n=>n.scope&&n.scope!=="row"||i.includes(n.field)))throw new Error("树形布局仅支持不覆盖结构键的当前行计算")}function g(e){if(!e?.aborted)return;const r=new Error("树报表处理已取消");throw r.name="AbortError",r}function D(e){const r=e.aggregates??[];if(!Array.isArray(r)||r.length>32)throw new Error("树聚合最多 32 项");if(e.parentValues!=="leaf-aggregate"&&r.length)throw new Error("树聚合需显式选择 leaf-aggregate 父级取值策略");if(e.parentValues==="leaf-aggregate"&&!r.length)throw new Error("叶子聚合策略至少需要一个聚合字段");const i=new Set;for(const n of r){if(!n||!m(n.field)||i.has(n.field))throw new Error("树聚合输出字段应安全、非空且唯一");for(const t of[n.valueField,n.weightField])if(t!==void 0&&!m(t))throw new Error("树聚合来源字段应安全且非空");if([...O(e),e.labelField].includes(n.field))throw new Error("树聚合不能覆盖结构键或标签字段");i.add(n.field),b.createAggregateAccumulator({...n,field:n.valueField??n.field})}}function J(e){if(!m(e.idField)||!m(e.labelField))throw new Error("树需要安全的业务键和标签字段");if(e.input==="flat"&&(!m(e.parentField)||e.parentField===e.idField))throw new Error("扁平树需要独立的父键字段");if(e.childrenField!==void 0&&!m(e.childrenField))throw new Error("子节点字段应安全且非空");if(e.input==="nested"&&[e.idField,e.labelField].includes(e.childrenField??"children"))throw new Error("子节点字段不能覆盖业务键或标签字段")}function x(e){if(!e||typeof e!="object"||!["flat","nested"].includes(e.input))throw new Error("树输入应为 flat 或 nested");if(J(e),e.orphan!==void 0&&!["error","root"].includes(e.orphan))throw new Error("树孤儿策略应为 error 或 root");if(e.parentValues!==void 0&&!["source","leaf-aggregate"].includes(e.parentValues))throw new Error("未知树父级取值策略");if(e.indentMm!==void 0&&(!Number.isFinite(e.indentMm)||e.indentMm<0||e.indentMm>20))throw new Error("树每级缩进应为 0–20 mm");T(e),D(e)}function B(e,r,i,n){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("树节点应为对象");if(i.size>=n.rows)throw new M(n.rows);const t=C(e[r.idField]),o=N(t);if(i.has(o))throw new Error(`树节点业务键重复:${String(t)}`);const s={original:e,row:e,key:t,depth:0,children:[]};return i.set(o,s),s}function W(e,r,i,n,t){for(const s of e)g(t),B(s,r,i,n);const o=[];for(const s of i.values()){g(t);const f=s.row[r.parentField];if(f==null){o.push(s);continue}const l=i.get(N(C(f)));if(!l){if(r.orphan!=="root")throw new Error(`树节点 ${String(s.key)} 的父节点不存在`);o.push(s);continue}if(l===s)throw new Error("树节点不能以自身为父节点");s.parent=l,l.children.push(s)}return o}function z(e,r,i,n,t){const o=[],s=[{rows:e,next:0}];for(;s.length;){g(t);const f=s[s.length-1];if(f.next>=f.rows.length){s.pop();continue}const l=B(f.rows[f.next++],r,i,n);if(l.parent=f.parent,l.depth=s.length-1,s.length>n.depth)throw new Error(`树节点超出深度预算 ${n.depth}`);(f.parent?.children??o).push(l);const d=l.row[r.childrenField??"children"];if(d!=null){if(!Array.isArray(d))throw new Error("嵌套树 children 字段应为数组");d.length&&s.push({rows:d,next:0,parent:l})}}return o}function H(e,r,i,n){const t=[],o=[{nodes:e,next:0}];for(;o.length;){g(n);const s=o[o.length-1];if(s.next>=s.nodes.length){o.pop();continue}if(o.length>i.depth)throw new Error(`树节点超出深度预算 ${i.depth}`);const f=s.nodes[s.next++];f.depth=o.length-1,t.push(f),f.children.length&&o.push({nodes:f.children,next:0})}if(t.length!==r)throw new Error("树父子关系存在循环");return t}function X(e,r,i,n){if(r.parentValues!=="leaf-aggregate")return;const t=r.aggregates,o=new Map;for(const f of e)f.children.length&&o.set(f,t.map(l=>b.createAggregateAccumulator({...l,field:l.valueField??l.field})));let s=0;for(const f of e)if(!f.children.length)for(let l=f.parent;l;l=l.parent){if(g(n),s+=t.length,s>i.visits)throw new Error(`树聚合超出访问预算 ${i.visits}`);for(const d of o.get(l))d.add(f.row)}for(const[f,l]of o)f.row={...f.row},t.forEach((d,u)=>{f.row[d.field]=l[u].value()})}function R(e,r,i){if(x(r),g(i),!Array.isArray(e))throw new Error("树数据应为节点数组");const n=T(r),t=new Map,o=r.input==="flat"?W(e,r,t,n,i):z(e,r,t,n,i);return H(o,t.size,n,i)}function q(e,r,i){return R(e,r,i).map(n=>n.original)}function P(e,r,i={}){const n=R(e,r,i.signal);if(V(r,i.computed?.fields),i.computed?.fields.length){const t=b.computeDataset(n.map(o=>o.row),{...i.computed,signal:i.signal}).rows;n.forEach((o,s)=>{o.row=t[s]})}return X(n,r,T(r),i.signal),{rows:n.map(t=>t.row),entries:n.map(t=>({row:t.row,original:t.original,key:t.key,depth:t.depth,hasChildren:!!t.children.length})),leaves:n.filter(t=>!t.children.length).map(t=>t.row)}}const G=/^#[0-9a-f]{6}$/i;function j(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const r=e;return r.kind!=="colorScale"&&r.kind!=="dataBar"||r.field!==void 0&&(typeof r.field!="string"||!r.field.trim())||r.numeric!==void 0&&!["number","decimal"].includes(r.numeric)||[r.min,r.max].some(i=>i!==void 0&&(typeof i!="number"||!Number.isFinite(i)))||r.min!==void 0&&r.max!==void 0&&r.min>r.max?!1:Object.entries(r).every(([i,n])=>!["color","negativeColor","lowColor","highColor"].includes(i)||typeof n=="string"&&G.test(n))}function _(e,r){if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(r!=="decimal"||typeof e!="string"||e.length>1024||!/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(e))return;const i=Number(e);return Number.isFinite(i)?i:void 0}function Q(e,r,i){let n="#";for(const t of[1,3,5]){const o=parseInt(e.slice(t,t+2),16),s=parseInt(r.slice(t,t+2),16);n+=Math.round(o+(s-o)*i).toString(16).padStart(2,"0")}return n}function A(e,r,i){if(r===i)return e<r?0:e>i?1:.5;if(e<=r)return 0;if(e>=i)return 1;const n=i-r;return Number.isFinite(n)?(e-r)/n:(e/2-r/2)/(i/2-r/2)}function U(e,r,i,n){const t=new WeakMap;return{apply(o,s){const f=_(s[r],e.numeric);if(f===void 0)return;if(e.kind==="dataBar"){const h=Math.min(i,0),$=Math.max(n,0),E=A(0,h,$),v=h===$?E:A(f,h,$);o.dataBar={start:Math.min(E,v),end:Math.max(E,v),color:f<0?e.negativeColor??"#f3bcc3":e.color??"#bad8fa"};return}const l=Q(e.lowColor??"#f0f7ff",e.highColor??"#8bbcf1",A(f,i,n)),d=o.style??{},u=t.get(d)??new Map;t.set(d,u);let y=u.get(l);y||(y={...d,backgroundColor:l},u.set(l,y)),o.style=y}}}function Y(e,r,i){return e.map(n=>{k(i);const t=n.visual;if(!t)return;if(!j(t))throw new TypeError("Invalid column visual rule");const o=t.field??n.field;let s=1/0,f=-1/0,l=0;if(t.min===void 0||t.max===void 0)for(const y of r){(l++&1023)===0&&k(i);const h=_(y[o],t.numeric);h!==void 0&&(s=Math.min(s,h),f=Math.max(f,h))}let d=t.min??s,u=t.max??f;if(!(!Number.isFinite(d)||!Number.isFinite(u)))return d>u&&(t.min!==void 0?u=d:d=u),U(t,o,d,u)})}function k(e){if(e?.aborted)throw e.reason??new DOMException("Aborted","AbortError")}const K=1e7;function Z(e){const r=JSON.stringify(e,null,2);if(r.length>K)throw new RangeError("模板 JSON 超过 1000 万字符的导出/导入上限");return r}exports.MAX_TEMPLATE_JSON_CHARACTERS=K;exports.TreeRowLimitError=M;exports.collectTemplateDatasetBindings=L;exports.createColumnVisualResolvers=Y;exports.createTreeTable=P;exports.flattenTreeInput=q;exports.stringifyValidatedTemplate=Z;exports.validColumnVisual=j;exports.validateTreeComputed=V;exports.validateTreeOptions=x;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
"use strict";const g=require("./progress-WomPRP3B.cjs"),M=/[\u3000-\u9fff\uff00-\uffef]/,s=new Uint8Array(128);{for(const t of"iljtf.,:;'`|!()[]")s[t.charCodeAt(0)]=1;for(const t of"mwMW@")s[t.charCodeAt(0)]=2;for(let t=48;t<=57;t++)s[t]=3;for(let t=65;t<=90;t++)s[t]=4;s[32]=5}const w=[.54,.26,.95,.59,.67,.3];function d(t){const e=t.charCodeAt(0);return e<128?w[s[e]]:M.test(t)?1:/[A-Z]/.test(t)?.67:.54}const o={measureMm(t,e){const{fontSizePt:i,bold:c=!1,letterSpacingPt:u=0}=e,r=25.4/72;let n=0;for(const h of t)n+=d(h);return c&&(n*=1.04),(n*i+u*Math.max(0,Array.from(t).length-1))*r}};function p(){return o}function A(t,e){return o.measureMm(t,e)}function x(t){let e;return{measureMm(i,c){if(e===void 0&&(e=t()),!e)return o.measureMm(i,c);const u=c.fontSizePt*96/72;e.font=`${c.italic?"italic ":""}${c.bold?"bold ":""}${u}px ${c.fontFamily??g.DEFAULT_FONT_FAMILY}`,"letterSpacing"in e&&(e.letterSpacing="0px");const r=(c.letterSpacingPt??0)*Math.max(0,Array.from(i).length-1);return e.measureText(i).width*25.4/96+r*25.4/72}}}function T(t,e,i){const c=[];let u="";const r=()=>{u&&(c.push({text:u,widthMm:i.measureMm(u,e),cjk:!1}),u="")};for(const n of t){if(n===`
|
|
2
|
+
`){r(),c.push({text:`
|
|
3
|
+
`,widthMm:0,cjk:!1,br:!0});continue}if(n===" "){r(),c.push({text:n,widthMm:i.measureMm(n,e),cjk:!1,space:!0});continue}if(M.test(n)){r(),c.push({text:n,widthMm:i.measureMm(n,e),cjk:!0});continue}u+=n}return r(),c}function S(t,e,i,c=o){if(!t)return[""];t=t.replace(/\r\n?/g,`
|
|
4
|
+
`);const u=[];let r="",n=0;const h=(i.letterSpacingPt??0)*25.4/72,a=()=>{u.push(r),r="",n=0};for(const f of T(t,i,c)){if(f.br){a();continue}const m=r.length>0?h:0;if(n+m+f.widthMm<=e){r+=f.text,n+=m+f.widthMm;continue}if(f.space){a();continue}if(f.cjk){r.length>0&&a(),r=f.text,n=f.widthMm;continue}if(r.length>0&&a(),f.widthMm<=e){r=f.text,n=f.widthMm;continue}for(const l of f.text)c.measureMm(r+l,i)>e&&r.length>0&&a(),r+=l,n=c.measureMm(r,i)}return a(),u}exports.charWidthEm=d;exports.createCanvasMeasurer=x;exports.createHeuristicMeasurer=p;exports.heuristicMeasurer=o;exports.measureTextMm=A;exports.wrapText=S;
|
package/dist/vue/async.d.cts
CHANGED
|
@@ -1015,6 +1015,20 @@ declare interface MachReportMessages extends Partial<ReportCalculationMessages>,
|
|
|
1015
1015
|
importing?: string;
|
|
1016
1016
|
editCell?: string;
|
|
1017
1017
|
editingHint?: string;
|
|
1018
|
+
editCellEditable?: string;
|
|
1019
|
+
editCellReadOnly?: string;
|
|
1020
|
+
editCellFormula?: string;
|
|
1021
|
+
editCellProtected?: string;
|
|
1022
|
+
editCellComplex?: string;
|
|
1023
|
+
editCellStructure?: string;
|
|
1024
|
+
editCellDerived?: string;
|
|
1025
|
+
editCellPermission?: string;
|
|
1026
|
+
editCellBusy?: string;
|
|
1027
|
+
editHistoryLimited?: string;
|
|
1028
|
+
changesSearch?: string;
|
|
1029
|
+
changesAllDatasets?: string;
|
|
1030
|
+
changesNoMatches?: string;
|
|
1031
|
+
changesRange?: string;
|
|
1018
1032
|
saving?: string;
|
|
1019
1033
|
editInvalidNumber?: string;
|
|
1020
1034
|
editInvalidBoolean?: string;
|
|
@@ -2068,11 +2082,21 @@ declare interface ReportEditConflict {
|
|
|
2068
2082
|
currentValue?: ReportCellValue_2;
|
|
2069
2083
|
revision?: string | number;
|
|
2070
2084
|
}
|
|
2085
|
+
declare interface ReportEditHistoryOptions {
|
|
2086
|
+
/** Retained undo/redo transactions. Default 100. Zero disables undo retention. */
|
|
2087
|
+
maxSteps?: number;
|
|
2088
|
+
/** Conservative retained transaction size in bytes. Default 8 MiB. */
|
|
2089
|
+
maxBytes?: number;
|
|
2090
|
+
}
|
|
2071
2091
|
/** Opt in with true for local drafts, or provide host validation and persistence. */
|
|
2072
2092
|
declare interface ReportEditingOptions {
|
|
2073
2093
|
/** Optional field controls, keyed by source.field / table.columnKey; a resolver supports dataset-specific rules. */
|
|
2074
2094
|
fields?: Readonly<Record<string, ReportCellFieldOptions>> | ((context: ReportCellContext) => ReportCellFieldOptions | undefined);
|
|
2075
2095
|
canEdit?(context: ReportCellContext): boolean;
|
|
2096
|
+
/** Optional explanation when canEdit rejects a cell. Does not grant editing access. */
|
|
2097
|
+
readOnlyReason?(context: ReportCellContext): string | undefined;
|
|
2098
|
+
/** Bounds undo/redo retention. Net differences and getChanges remain complete. */
|
|
2099
|
+
history?: ReportEditHistoryOptions;
|
|
2076
2100
|
/** Return an error message or throw to reject the edit. */
|
|
2077
2101
|
validate?(edit: Readonly<ReportCellEdit_2>, operation: ReportEditOperation): void | string | Promise<void | string>;
|
|
2078
2102
|
/** Same declarative rules can be run in Node via validateReportDataset. Requires a source-backed session. */
|