@agile-team/mach-report 2.21.1 → 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.
Files changed (169) hide show
  1. package/README.md +20 -5
  2. package/dist/{ExcelBindingWizard-mnAO2qOX.js → ExcelBindingWizard-D4FLind-.js} +3 -3
  3. package/dist/{ExcelBindingWizard-Bu0LUlzl.cjs → ExcelBindingWizard-D4RS5Bpg.cjs} +1 -1
  4. package/dist/{ParamEditor-38ZfNrPU.cjs → ParamEditor-C-6C9rd2.cjs} +1 -1
  5. package/dist/{ParamEditor-C8l0EC8m.js → ParamEditor-CASZt-Ma.js} +2 -2
  6. package/dist/{ReportBatchPanel-CfUVhvkO.js → ReportBatchPanel-Bq7t8a5r.js} +2 -2
  7. package/dist/{ReportBatchPanel-nCC06Nfp.cjs → ReportBatchPanel-YVj5IO5y.cjs} +1 -1
  8. package/dist/ReportLabelStudio-Cqhita1b.cjs +1 -0
  9. package/dist/ReportLabelStudio-Dj7GXhuv.js +783 -0
  10. package/dist/ReportParamPanel-DZbFVmDL.cjs +1 -0
  11. package/dist/{ReportParamPanel-peB-KEmm.js → ReportParamPanel-Dgmqro1Y.js} +265 -244
  12. package/dist/ReportPreview-DeWzG8jQ.js +6257 -0
  13. package/dist/ReportPreview-FFIryrIr.cjs +6 -0
  14. package/dist/{ReportTemplateLibrary-DVlsf72p.cjs → ReportTemplateLibrary-BaWodmpm.cjs} +1 -1
  15. package/dist/{ReportTemplateLibrary-B5t_EcIs.js → ReportTemplateLibrary-DdAAAD2I.js} +1 -1
  16. package/dist/{RuleEditor-kT1JsZ9f.js → RuleEditor-D2UwQGF6.js} +59 -59
  17. package/dist/{RuleEditor-xFkCVlii.cjs → RuleEditor-DcT9xI1v.cjs} +1 -1
  18. package/dist/TemplateOutlinePanel-CUHFFiNM.cjs +1 -0
  19. package/dist/{TemplateOutlinePanel-BesgGR1P.js → TemplateOutlinePanel-DrT7XN0m.js} +2 -2
  20. package/dist/{TemplateReusePanel-BNFU6V-W.js → TemplateReusePanel-4eejkNqi.js} +2 -2
  21. package/dist/{TemplateReusePanel-BG9Or5-P.cjs → TemplateReusePanel-DZMyiX5I.cjs} +1 -1
  22. package/dist/{TemplateReviewPanel-CwvwyCSs.js → TemplateReviewPanel-BIhNLeNw.js} +2 -2
  23. package/dist/TemplateReviewPanel-DnYImiXu.cjs +1 -0
  24. package/dist/analytics.cjs +1 -1
  25. package/dist/analytics.js +26 -26
  26. package/dist/artifact-integrity.json +108 -106
  27. package/dist/assets-D2gHc4Mz.cjs +1 -0
  28. package/dist/assets-T_gDeFaz.js +132 -0
  29. package/dist/auto-4pK9HePf.cjs +1 -0
  30. package/dist/auto-CTIJ6PnR.js +257 -0
  31. package/dist/capabilities-DiBj4Qgl.cjs +1 -0
  32. package/dist/capabilities-pg7j7VLT.js +106 -0
  33. package/dist/charts-Cjw5AYkg.cjs +1 -0
  34. package/dist/{charts-Dlv8j2AG.js → charts-CxJZ0XaY.js} +1 -1
  35. package/dist/computed-DK6BruFz.cjs +1 -0
  36. package/dist/{computed-C8NRZQss.js → computed-f3pOqWLX.js} +381 -301
  37. package/dist/data-bar-CeZuFmYl.cjs +1 -0
  38. package/dist/{data-bar-8baGYEZ9.js → data-bar-IkI6VvMQ.js} +1 -1
  39. package/dist/designer-DhrE7jzw.js +7169 -0
  40. package/dist/designer-IAZu6kBX.cjs +2 -0
  41. package/dist/designer.cjs +1 -1
  42. package/dist/designer.d.cts +246 -46
  43. package/dist/designer.d.ts +246 -46
  44. package/dist/designer.js +15 -14
  45. package/dist/dom-ChE5D-L-.cjs +1 -0
  46. package/dist/dom-JWrchIre.js +452 -0
  47. package/dist/dom-cell-address-DLD1mkTB.cjs +1 -0
  48. package/dist/dom-cell-address-Fn-8nk7D.js +11 -0
  49. package/dist/{encoding-B79hW4zq.cjs → encoding-BefcaHdp.cjs} +1 -1
  50. package/dist/{encoding-BSeUwrN7.js → encoding-CL6rXEkR.js} +2 -2
  51. package/dist/{font-loader-Di0lQKFf.js → font-loader-BT5baV-o.js} +1 -1
  52. package/dist/{font-loader-BB372_XN.cjs → font-loader-Ga51c2VC.cjs} +1 -1
  53. package/dist/grid-strokes-Be24LGuV.cjs +1 -0
  54. package/dist/grid-strokes-EoY66L2f.js +53 -0
  55. package/dist/index.cjs +8 -8
  56. package/dist/index.d.cts +44 -1
  57. package/dist/index.d.ts +44 -1
  58. package/dist/index.js +961 -1256
  59. package/dist/json-snapshot-1tvQNzQE.cjs +2 -0
  60. package/dist/{json-snapshot-Kgn459Oj.js → json-snapshot-OqkPyUk5.js} +763 -776
  61. package/dist/matrix-B8QWbsGM.cjs +1 -0
  62. package/dist/matrix-C6e_r_vp.js +302 -0
  63. package/dist/{pdf-CARdBcuw.cjs → pdf-HiEeXe9H.cjs} +42 -42
  64. package/dist/{pdf-DmlnL5eB.js → pdf-aobetCsy.js} +20 -20
  65. package/dist/pdf.cjs +1 -1
  66. package/dist/pdf.js +2 -2
  67. package/dist/{plugin-BaRUGORD.cjs → plugin-BFANt-i8.cjs} +1 -1
  68. package/dist/{plugin-D4kAxfLG.js → plugin-DeYYAL6F.js} +1 -1
  69. package/dist/{prefill-CJSazcVY.js → prefill-Dk4C6S5R.js} +21 -21
  70. package/dist/prefill-DsUD5OoK.cjs +1 -0
  71. package/dist/prepared-DCIxhKFo.js +94 -0
  72. package/dist/prepared-Dv-XM3i1.cjs +1 -0
  73. package/dist/progress-ByiOxUD3.js +250 -0
  74. package/dist/progress-WomPRP3B.cjs +1 -0
  75. package/dist/{protocol-C8VWF9An.cjs → protocol-B9YgfQ_d.cjs} +1 -1
  76. package/dist/{protocol-Bs9-ohHN.js → protocol-DxeUKGYG.js} +3 -3
  77. package/dist/record-bindings-DatJZv_e.js +200 -0
  78. package/dist/record-bindings-MBxbeBsi.cjs +1 -0
  79. package/dist/{region-binding-workflow-Cy4GIOUo.js → region-binding-workflow-DjrXuR1q.js} +2 -2
  80. package/dist/{region-binding-workflow-JNowHd0A.cjs → region-binding-workflow-l7NGfagJ.cjs} +2 -2
  81. package/dist/report-encoding-worker.cjs +1 -1
  82. package/dist/report-encoding-worker.js +1 -1
  83. package/dist/rich-text-layout-Ciwa6D2o.js +52 -0
  84. package/dist/rich-text-layout-DK7A_a5r.cjs +3 -0
  85. package/dist/{runtime-BDf5x1i1.js → runtime-75Y5Oq5B.js} +52 -51
  86. package/dist/runtime-DKlGd_D4.cjs +1 -0
  87. package/dist/sbom.cdx.json +1 -1
  88. package/dist/server/node.d.cts +9 -0
  89. package/dist/server/node.d.ts +9 -0
  90. package/dist/server-node.cjs +5 -4
  91. package/dist/server-node.js +2178 -2044
  92. package/dist/server.cjs +1 -1
  93. package/dist/server.d.cts +81 -0
  94. package/dist/server.d.ts +81 -0
  95. package/dist/server.js +24 -24
  96. package/dist/style.css +1 -1
  97. package/dist/{template-catalog-DFwIS9aN.js → template-catalog--cjxzgH7.js} +17 -17
  98. package/dist/template-catalog-CoT7jm_6.cjs +1 -0
  99. package/dist/{template-fragments-Dng-AlHk.js → template-fragments-CPpGpQoz.js} +24 -24
  100. package/dist/{template-fragments-DZVUBhuB.cjs → template-fragments-GVjpew_q.cjs} +1 -1
  101. package/dist/template-registry-DI59PXVK.cjs +1 -0
  102. package/dist/{template-registry-DhBqoD7W.js → template-registry-O0hNIOfB.js} +333 -261
  103. package/dist/template-serialization-CWmHq7lX.js +307 -0
  104. package/dist/template-serialization-CqQY4zDg.cjs +1 -0
  105. package/dist/{textwrap-CkGjRFT3.js → textwrap-BIjtEWmq.js} +1 -1
  106. package/dist/textwrap-Cy7o1hIR.cjs +4 -0
  107. package/dist/vue/async.d.cts +121 -2
  108. package/dist/vue/async.d.ts +121 -2
  109. package/dist/vue/index.d.cts +222 -5
  110. package/dist/vue/index.d.ts +222 -5
  111. package/dist/vue-async.cjs +1 -1
  112. package/dist/vue-async.js +3 -3
  113. package/dist/vue.cjs +1 -1
  114. package/dist/vue.js +101 -91
  115. package/dist/{workbook-session-NYv01LHe.cjs → workbook-session-C6-SrnCT.cjs} +4 -4
  116. package/dist/{workbook-session-oinxX3qo.js → workbook-session-C9ZmCBwY.js} +15 -16
  117. package/dist/workbook-sheets-CaPAulQ6.cjs +2 -0
  118. package/dist/workbook-sheets-D4M7XXBh.js +44 -0
  119. package/dist/worker.cjs +1 -1
  120. package/dist/worker.d.cts +9 -0
  121. package/dist/worker.d.ts +9 -0
  122. package/dist/worker.js +4 -4
  123. package/dist/xlsx.cjs +4 -4
  124. package/dist/xlsx.d.cts +39 -2
  125. package/dist/xlsx.d.ts +39 -2
  126. package/dist/xlsx.js +300 -275
  127. package/package.json +1 -1
  128. package/dist/ReportLabelStudio-CaEvYuSK.cjs +0 -1
  129. package/dist/ReportLabelStudio-DQPBmh4v.js +0 -765
  130. package/dist/ReportParamPanel-CVpK8mFc.cjs +0 -1
  131. package/dist/ReportPreview-BBJNlu2U.js +0 -5740
  132. package/dist/ReportPreview-nf4Dk1Jc.cjs +0 -6
  133. package/dist/TemplateOutlinePanel-CDI6mfWx.cjs +0 -1
  134. package/dist/TemplateReviewPanel-BmBrjt6P.cjs +0 -1
  135. package/dist/assets-CxHunY_9.js +0 -232
  136. package/dist/assets-vbjAGgk8.cjs +0 -1
  137. package/dist/auto-BkdGiNtr.js +0 -240
  138. package/dist/auto-Tq7ReIC1.cjs +0 -1
  139. package/dist/charts-aCtoswXq.cjs +0 -1
  140. package/dist/component-tree-1_QCiQJX.js +0 -67
  141. package/dist/component-tree-BjZIp6w9.cjs +0 -1
  142. package/dist/computed-4TnxzgIh.cjs +0 -1
  143. package/dist/data-bar-YltqGTaC.cjs +0 -1
  144. package/dist/designer-DU3yDWgs.cjs +0 -2
  145. package/dist/designer-HQi-03R6.js +0 -6869
  146. package/dist/grid-geometry-D3SJgWFv.js +0 -136
  147. package/dist/grid-geometry-D8ReblRV.cjs +0 -1
  148. package/dist/json-snapshot-I5VI84Vp.cjs +0 -2
  149. package/dist/matrix-0hywp0-F.cjs +0 -1
  150. package/dist/matrix-Dy-tyY7E.js +0 -381
  151. package/dist/prefill-Bpyn58AZ.cjs +0 -1
  152. package/dist/prepared-BiSz_9vN.cjs +0 -1
  153. package/dist/prepared-BwjwEzFz.js +0 -87
  154. package/dist/progress-B0ctFpKf.cjs +0 -1
  155. package/dist/progress-Hc2vxoCs.js +0 -52
  156. package/dist/record-bindings-Ct1HkPrc.cjs +0 -1
  157. package/dist/record-bindings-VZGS-Qd8.js +0 -155
  158. package/dist/rich-text-layout-K48VHUoW.cjs +0 -3
  159. package/dist/rich-text-layout-wxBhnAS7.js +0 -102
  160. package/dist/runtime-DsJt1PIf.cjs +0 -1
  161. package/dist/template-bindings-Cg5oBLFT.cjs +0 -1
  162. package/dist/template-bindings-TKnXM7ll.js +0 -62
  163. package/dist/template-catalog-D_2jdnkL.cjs +0 -1
  164. package/dist/template-outline-DWkzZXVC.cjs +0 -1
  165. package/dist/template-outline-DiADphlq.js +0 -88
  166. package/dist/template-registry-DpLUSLwF.cjs +0 -1
  167. package/dist/template-serialization-Cc3h-miv.js +0 -247
  168. package/dist/template-serialization-D1R5oAqh.cjs +0 -1
  169. package/dist/textwrap-OTOUMr4f.cjs +0 -4
@@ -1,155 +0,0 @@
1
- import { g as f, j as b } from "./grid-geometry-D3SJgWFv.js";
2
- import { k as y, h as l } from "./computed-C8NRZQss.js";
3
- function S(e) {
4
- if (!e || e.kind === "date") return;
5
- const t = e.digits;
6
- if (!(t !== void 0 && (!Number.isInteger(t) || t < 0 || t > 100))) {
7
- if (e.kind === "percent") {
8
- const r = t ?? 2;
9
- return `0${r ? `.${"0".repeat(r)}` : ""}%`;
10
- }
11
- return t === void 0 ? e.thousands ? "#,##0.###############" : void 0 : `${e.thousands ? "#,##0" : "0"}${t ? `.${"0".repeat(t)}` : ""}`;
12
- }
13
- }
14
- function N(e) {
15
- const t = /^(\d{4})[-/](\d{1,2})[-/](\d{1,2})$/.exec(e.trim());
16
- if (t) {
17
- const n = new Date(Number(t[1]), Number(t[2]) - 1, Number(t[3]));
18
- return Number.isNaN(n.getTime()) ? null : n;
19
- }
20
- const r = new Date(e);
21
- return Number.isNaN(r.getTime()) ? null : r;
22
- }
23
- function g(e, t) {
24
- return e.toLocaleString("en-US", {
25
- minimumFractionDigits: t,
26
- maximumFractionDigits: t
27
- });
28
- }
29
- function D(e, t) {
30
- const r = (n) => String(n).padStart(2, "0");
31
- return t.replace(/YYYY/g, String(e.getFullYear())).replace(/MM/g, r(e.getMonth() + 1)).replace(/DD/g, r(e.getDate())).replace(/hh/g, r(e.getHours())).replace(/mm/g, r(e.getMinutes())).replace(/ss/g, r(e.getSeconds()));
32
- }
33
- function F(e, t, r) {
34
- return r != null ? t ? g(e, r) : e.toFixed(r) : t ? g(e) : String(e);
35
- }
36
- function c(e) {
37
- const t = typeof e == "number" ? e : Number(String(e).replace(/,/g, ""));
38
- return Number.isFinite(t) ? t : null;
39
- }
40
- function h(e, t) {
41
- if (e == null || e === "" || !t) return String(e ?? "");
42
- switch (t.kind) {
43
- case "number": {
44
- if (typeof e == "string")
45
- try {
46
- return l(e, t.digits, t.thousands === !0);
47
- } catch {
48
- return e;
49
- }
50
- const r = c(e);
51
- return r == null ? String(e) : F(r, t.thousands === !0, t.digits);
52
- }
53
- case "percent": {
54
- if (typeof e == "string")
55
- try {
56
- return l(e, t.digits ?? 2, !0, !0);
57
- } catch {
58
- return e;
59
- }
60
- const r = c(e);
61
- return r == null ? String(e) : `${g(r * 100, t.digits ?? 2)}%`;
62
- }
63
- case "date": {
64
- const r = t.pattern ?? "YYYY-MM-DD", n = e instanceof Date ? e : N(String(e));
65
- return n ? D(n, r) : String(e);
66
- }
67
- default:
68
- return String(e);
69
- }
70
- }
71
- function p(e, t) {
72
- return y(t)(e);
73
- }
74
- function $(e, t, r, n = e.paddingMm ?? 1) {
75
- return t.field !== e.tree.labelField ? 0 : Math.min(r.depth * (e.tree.indentMm ?? 3), Math.max(0, t.widthMm - n * 2 - 4));
76
- }
77
- function x(e, t, r, n) {
78
- const i = n.tree;
79
- (i.input === "nested" || [i.idField, i.parentField].includes(t.field)) && (e.editable = !1), r.hasChildren && i.parentValues === "leaf-aggregate" && i.aggregates?.some((o) => o.field === t.field) && (e.derived = !0, e.editable = !1);
80
- }
81
- function M(e, t, r) {
82
- return r === "identifier" || r === "dimension" || r === "date" ? "center" : r === "measure" ? "right" : r === "text" ? "left" : t?.kind === "number" || t?.kind === "percent" ? "right" : t?.kind === "date" || e instanceof Date || typeof e == "boolean" ? "center" : typeof e == "number" && Number.isFinite(e) ? "right" : "left";
83
- }
84
- function T(e) {
85
- if (e == null) return "";
86
- if (typeof e == "string" || typeof e == "number") return String(e);
87
- if (typeof e == "boolean") return e ? "是" : "否";
88
- if (e instanceof Date) return e.toISOString().slice(0, 10);
89
- try {
90
- return JSON.stringify(e);
91
- } catch {
92
- return String(e);
93
- }
94
- }
95
- function C(e, t) {
96
- let r = f({ fontSize: e.fontSizePt ?? b, bold: e.headerBold ?? !0, align: "center", verticalAlign: "middle", backgroundColor: e.headerBackgroundColor }, t.style);
97
- return e.headerAlign !== void 0 && (r.align = e.headerAlign), r = f(r, e.headerStyle), t.headerAlign !== void 0 && (r.align = t.headerAlign), f(r, t.headerStyle);
98
- }
99
- function w(e, t, r) {
100
- (r === null || typeof r == "string" || typeof r == "boolean" || typeof r == "number" && Number.isFinite(r)) && (e.value = r);
101
- const n = t.format?.kind === "number" || t.format?.kind === "percent";
102
- t.valueType !== void 0 ? e.valueType = t.valueType : n && (e.valueType = "number"), t.editable !== void 0 && (e.editable = t.editable);
103
- const i = S(t.format);
104
- (typeof e.value == "number" || e.value == null) && i !== void 0 && (e.numberFormat = i);
105
- }
106
- function k(e, t, r) {
107
- const n = !!t.visibleWhen && !p(r, t.visibleWhen), i = n ? null : r[t.field], o = t.align ?? t.style?.align ?? e.align ?? "left";
108
- let a = f({ fontSize: e.fontSizePt ?? b, verticalAlign: "middle" }, t.style);
109
- a.align = o === "auto" ? M(i, t.format, t.semanticRole) : o;
110
- const s = t.rules?.find((u) => p(r, u.when));
111
- s && (a = f(a, s.style));
112
- const d = { text: t.format ? h(i, t.format) : T(i), style: a };
113
- return w(d, t, i), e.computed?.some((u) => u.field === t.field) && (d.derived = !0, d.editable = !1), n && (d.editable = !1), d;
114
- }
115
- function I(e, t, r) {
116
- const n = k(e, t, r.row), i = $(e, t, r);
117
- return t.field === e.tree.labelField && (n.style = { ...n.style, align: "left" }), i && (n.indentMm = i), x(n, t, r, e), n;
118
- }
119
- function R(e) {
120
- return typeof e == "string" && /^data:image\/(png|jpe?g);base64,[A-Za-z0-9+/\r\n]+=*$/.test(e);
121
- }
122
- class m extends Error {
123
- constructor(t, r, n, i) {
124
- super(`${t}: ${r}`), this.path = t, this.rowIndex = n, this.field = i, this.code = "report-binding", this.name = "ReportBindingError";
125
- }
126
- }
127
- function A(e, t, r = {}) {
128
- const n = r.rowIndex ?? 0, o = `$.datasets.${r.dataset ?? "label"}[${n}].${t}`, a = Object.getOwnPropertyDescriptor(e, t);
129
- if (!a || a.get || a.set) throw new m(o, "字段必须是记录的自有数据字段,不能缺失、使用访问器或从原型继承", n, t);
130
- const s = a.value;
131
- if (s == null || typeof s == "string" || typeof s == "boolean" || typeof s == "number" && Number.isFinite(s)) return s;
132
- throw new m(o, "绑定值应为字符串、有限数字、布尔值或空值", n, t);
133
- }
134
- function P(e, t, r = {}) {
135
- const n = A(t, e.field, r);
136
- return n == null || n === "" ? e.emptyText ?? "" : `${e.prefix ?? ""}${h(n, e.format)}${e.suffix ?? ""}`;
137
- }
138
- export {
139
- m as R,
140
- I as a,
141
- P as b,
142
- C as c,
143
- c as d,
144
- p as e,
145
- h as f,
146
- A as g,
147
- M as h,
148
- R as i,
149
- $ as j,
150
- x as k,
151
- T as l,
152
- N as p,
153
- k as r,
154
- S as t
155
- };
@@ -1,3 +0,0 @@
1
- "use strict";const d=require("./grid-geometry-D8ReblRV.cjs"),B=["borderTop","borderRight","borderBottom","borderLeft","borderColor","lineColor","lineWidthPt"];function C(n,e){const t=d.resolveBoxBorders(e.style),s=t.inner?[...n.edges]:[];t.top&&s.push({kind:"h",pos:0,from:0,to:e.widthMm}),t.bottom&&s.push({kind:"h",pos:e.heightMm,from:0,to:e.widthMm}),t.left&&s.push({kind:"v",pos:0,from:0,to:e.heightMm}),t.right&&s.push({kind:"v",pos:e.widthMm,from:0,to:e.heightMm});const o=d.resolveStroke(e.style);return s.map(i=>({...i,...o}))}function z(n,e,t){const s=n.get(e);(!s||t.widthPt>s.widthPt)&&n.set(e,t)}function v(n,e,t,s,o,i){const c=t<e.rows.length?e.rows[t].pos:e.rows[e.rows.length-1].pos+e.rows[e.rows.length-1].size;for(let r=s;r<o;r++){const h=e.columns[r];z(n,`h:${t}:${r}`,{kind:"h",pos:c,from:h.pos,to:h.pos+h.size,...i})}}function k(n,e,t,s,o,i){const c=t<e.columns.length?e.columns[t].pos:e.columns[e.columns.length-1].pos+e.columns[e.columns.length-1].size;for(let r=s;r<o;r++){const h=e.rows[r];z(n,`v:${t}:${r}`,{kind:"v",pos:c,from:h.pos,to:h.pos+h.size,...i})}}function M(n,e,t,s){const o=Math.min(e.columns.length,t.ci+(t.cell.colSpan??1)),i=Math.min(e.rows.length,t.ri+(t.cell.rowSpan??1)),c=d.mergeComponentStyles(s,t.cell.style),r=d.resolveBoxBorders(c),h=d.resolveStroke(c);r.top&&v(n,e,t.ri,t.ci,o,h),r.bottom&&v(n,e,i,t.ci,o,h),r.left&&k(n,e,t.ci,t.ri,i,h),r.right&&k(n,e,o,t.ri,i,h)}function H(n){const e=[...n.values()].sort((s,o)=>s.kind.localeCompare(o.kind)||s.pos-o.pos||s.from-o.from),t=[];for(const s of e){const o=t[t.length-1];o&&o.kind===s.kind&&o.pos===s.pos&&Math.abs(o.to-s.from)<1e-6&&o.color===s.color&&o.widthPt===s.widthPt?o.to=s.to:t.push({...s})}return t}function L(n,e){if(!n.cells.some(({cell:i})=>B.some(c=>i.style?.[c]!==void 0)))return C(n,e);const t=new Map,s=new Set,o=n.columns.length;for(const i of n.cells){M(t,n,i,e.style);const c=Math.min(n.rows.length,i.ri+(i.cell.rowSpan??1)),r=Math.min(o,i.ci+(i.cell.colSpan??1));for(let h=i.ri;h<c;h++)for(let l=i.ci;l<r;l++)s.add(h*o+l)}for(let i=0;i<n.rows.length;i++)for(let c=0;c<o;c++)s.has(i*o+c)||M(t,n,{ri:i,ci:c,cell:{}},e.style);return H(t)}function u(n){const e=d.resolveFontSize(n).fontSizePt;return{runs:[],width:0,height:e*d.resolveLineHeight(n),fontSize:e}}function R(n,e,t,s){const o=n.runs[n.runs.length-1];o?.style===t?(o.text+=e,o.width+=s):n.runs.push({text:e,style:t,width:s});const i=d.resolveFontSize(t).fontSizePt;n.width+=s,n.fontSize=Math.max(n.fontSize,i),n.height=Math.max(n.height,i*d.resolveLineHeight(t))}function T(n,e,t,s,o){const i=n.richParagraphs[e],c=d.mergeComponentStyles(n.style,{...i.lineHeight===void 0?{}:{lineHeight:i.lineHeight}}),r=[u(c)];for(const h of i.segments){const l=d.mergeComponentStyles(c,h.style),p=h.kind==="field"?h.field??"":h.text??"";for(const g of p.replace(/\r\n|\r/g,`
2
- `)){let f=r[r.length-1];if(g===`
3
- `){r.push(u(l));continue}const m=o.measure(g,l);f.runs.length&&f.width+m>t-(r.length===1?s:0)&&(f=u(l),r.push(f)),R(f,g,l,m)}}return r}function $(n,e,t){const s=n.richParagraphs.map((r,h)=>{const l=(r.indentMm??0)*72/25.4,p=T(n,h,e.width,l,t),g=p.reduce((f,m)=>f+m.height,0)+((r.spaceBeforeMm??0)+(r.spaceAfterMm??0))*72/25.4;return{paragraph:r,indent:l,lines:p,height:g}}),o=s.reduce((r,h)=>r+h.height,0),i=n.style?.verticalAlign;let c=e.yTop-(i==="middle"?(e.height-o)/2:i==="bottom"?e.height-o:0);for(const{paragraph:r,indent:h,lines:l}of s){c-=(r.spaceBeforeMm??0)*72/25.4;const p=Math.max(0,e.width-h);for(const[g,f]of l.entries()){const m=r.align??n.style?.align,P=g===0?h:0,a=g===0?p:e.width;let S=e.x+P+(m==="center"?(a-f.width)/2:m==="right"?a-f.width:0);for(const w of f.runs)t.draw(w.text,{...w.style,align:"left"},S,c-f.fontSize,w.width),S+=w.width;c-=f.height}c-=(r.spaceAfterMm??0)*72/25.4}return o>e.height+.01}exports.drawRichText=$;exports.resolveGridStrokes=L;
@@ -1,102 +0,0 @@
1
- import { f as z, e as P, g as w, a as B, c as C } from "./grid-geometry-D3SJgWFv.js";
2
- const R = ["borderTop", "borderRight", "borderBottom", "borderLeft", "borderColor", "lineColor", "lineWidthPt"];
3
- function $(n, t) {
4
- const e = z(t.style), s = e.inner ? [...n.edges] : [];
5
- e.top && s.push({ kind: "h", pos: 0, from: 0, to: t.widthMm }), e.bottom && s.push({ kind: "h", pos: t.heightMm, from: 0, to: t.widthMm }), e.left && s.push({ kind: "v", pos: 0, from: 0, to: t.heightMm }), e.right && s.push({ kind: "v", pos: t.widthMm, from: 0, to: t.heightMm });
6
- const o = P(t.style);
7
- return s.map((i) => ({ ...i, ...o }));
8
- }
9
- function H(n, t, e) {
10
- const s = n.get(t);
11
- (!s || e.widthPt > s.widthPt) && n.set(t, e);
12
- }
13
- function S(n, t, e, s, o, i) {
14
- const c = e < t.rows.length ? t.rows[e].pos : t.rows[t.rows.length - 1].pos + t.rows[t.rows.length - 1].size;
15
- for (let r = s; r < o; r++) {
16
- const h = t.columns[r];
17
- H(n, `h:${e}:${r}`, { kind: "h", pos: c, from: h.pos, to: h.pos + h.size, ...i });
18
- }
19
- }
20
- function k(n, t, e, s, o, i) {
21
- const c = e < t.columns.length ? t.columns[e].pos : t.columns[t.columns.length - 1].pos + t.columns[t.columns.length - 1].size;
22
- for (let r = s; r < o; r++) {
23
- const h = t.rows[r];
24
- H(n, `v:${e}:${r}`, { kind: "v", pos: c, from: h.pos, to: h.pos + h.size, ...i });
25
- }
26
- }
27
- function v(n, t, e, s) {
28
- const o = Math.min(t.columns.length, e.ci + (e.cell.colSpan ?? 1)), i = Math.min(t.rows.length, e.ri + (e.cell.rowSpan ?? 1)), c = w(s, e.cell.style), r = z(c), h = P(c);
29
- r.top && S(n, t, e.ri, e.ci, o, h), r.bottom && S(n, t, i, e.ci, o, h), r.left && k(n, t, e.ci, e.ri, i, h), r.right && k(n, t, o, e.ri, i, h);
30
- }
31
- function A(n) {
32
- const t = [...n.values()].sort((s, o) => s.kind.localeCompare(o.kind) || s.pos - o.pos || s.from - o.from), e = [];
33
- for (const s of t) {
34
- const o = e[e.length - 1];
35
- o && o.kind === s.kind && o.pos === s.pos && Math.abs(o.to - s.from) < 1e-6 && o.color === s.color && o.widthPt === s.widthPt ? o.to = s.to : e.push({ ...s });
36
- }
37
- return e;
38
- }
39
- function W(n, t) {
40
- if (!n.cells.some(({ cell: i }) => R.some((c) => i.style?.[c] !== void 0))) return $(n, t);
41
- const e = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Set(), o = n.columns.length;
42
- for (const i of n.cells) {
43
- v(e, n, i, t.style);
44
- const c = Math.min(n.rows.length, i.ri + (i.cell.rowSpan ?? 1)), r = Math.min(o, i.ci + (i.cell.colSpan ?? 1));
45
- for (let h = i.ri; h < c; h++) for (let l = i.ci; l < r; l++) s.add(h * o + l);
46
- }
47
- for (let i = 0; i < n.rows.length; i++) for (let c = 0; c < o; c++)
48
- s.has(i * o + c) || v(e, n, { ri: i, ci: c, cell: {} }, t.style);
49
- return A(e);
50
- }
51
- function a(n) {
52
- const t = B(n).fontSizePt;
53
- return { runs: [], width: 0, height: t * C(n), fontSize: t };
54
- }
55
- function T(n, t, e, s) {
56
- const o = n.runs[n.runs.length - 1];
57
- o?.style === e ? (o.text += t, o.width += s) : n.runs.push({ text: t, style: e, width: s });
58
- const i = B(e).fontSizePt;
59
- n.width += s, n.fontSize = Math.max(n.fontSize, i), n.height = Math.max(n.height, i * C(e));
60
- }
61
- function E(n, t, e, s, o) {
62
- const i = n.richParagraphs[t], c = w(n.style, { ...i.lineHeight === void 0 ? {} : { lineHeight: i.lineHeight } }), r = [a(c)];
63
- for (const h of i.segments) {
64
- const l = w(c, h.style), m = h.kind === "field" ? h.field ?? "" : h.text ?? "";
65
- for (const d of m.replace(/\r\n|\r/g, `
66
- `)) {
67
- let f = r[r.length - 1];
68
- if (d === `
69
- `) {
70
- r.push(a(l));
71
- continue;
72
- }
73
- const g = o.measure(d, l);
74
- f.runs.length && f.width + g > e - (r.length === 1 ? s : 0) && (f = a(l), r.push(f)), T(f, d, l, g);
75
- }
76
- }
77
- return r;
78
- }
79
- function D(n, t, e) {
80
- const s = n.richParagraphs.map((r, h) => {
81
- const l = (r.indentMm ?? 0) * 72 / 25.4, m = E(n, h, t.width, l, e), d = m.reduce((f, g) => f + g.height, 0) + ((r.spaceBeforeMm ?? 0) + (r.spaceAfterMm ?? 0)) * 72 / 25.4;
82
- return { paragraph: r, indent: l, lines: m, height: d };
83
- }), o = s.reduce((r, h) => r + h.height, 0), i = n.style?.verticalAlign;
84
- let c = t.yTop - (i === "middle" ? (t.height - o) / 2 : i === "bottom" ? t.height - o : 0);
85
- for (const { paragraph: r, indent: h, lines: l } of s) {
86
- c -= (r.spaceBeforeMm ?? 0) * 72 / 25.4;
87
- const m = Math.max(0, t.width - h);
88
- for (const [d, f] of l.entries()) {
89
- const g = r.align ?? n.style?.align, L = d === 0 ? h : 0, u = d === 0 ? m : t.width;
90
- let M = t.x + L + (g === "center" ? (u - f.width) / 2 : g === "right" ? u - f.width : 0);
91
- for (const p of f.runs)
92
- e.draw(p.text, { ...p.style, align: "left" }, M, c - f.fontSize, p.width), M += p.width;
93
- c -= f.height;
94
- }
95
- c -= (r.spaceAfterMm ?? 0) * 72 / 25.4;
96
- }
97
- return o > t.height + 0.01;
98
- }
99
- export {
100
- D as d,
101
- W as r
102
- };
@@ -1 +0,0 @@
1
- "use strict";var J=Object.create;var D=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var U=Object.getPrototypeOf,X=Object.prototype.hasOwnProperty;var z=(e,t,a,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of N(t))!X.call(e,s)&&s!==a&&D(e,s,{get:()=>t[s],enumerable:!(c=V(t,s))||c.enumerable});return e};var B=(e,t,a)=>(a=e!=null?J(U(e)):{},z(t||!e||!e.__esModule?D(a,"default",{value:e,enumerable:!0}):a,e));const n=require("./json-snapshot-I5VI84Vp.cjs"),T=require("./report-params-VTg8MoCp.cjs"),k=require("./param-validation-C-8sRJLq.cjs"),o=require("./sha256-DgZAKXqI.cjs"),W=require("./template-registry-DpLUSLwF.cjs"),G=require("./template-serialization-D1R5oAqh.cjs"),M=require("./assets-vbjAGgk8.cjs"),b=require("./prepared-BiSz_9vN.cjs");function I(e=[]){return e.map(({code:t,message:a,severity:c,pageIndex:s,componentIndex:r})=>({code:t,message:a,severity:c,path:r<0?`$.pages.${s}`:`$.pages.${s}.components.${r}`}))}async function L(e,t,a=Date.now()){const c=e.prepared;if(e.fidelity==="strict"&&c.diagnostics.some(w=>w.code==="asset-render-failed"||w.code==="asset-budget-exceeded"))throw new n.ReportSourceError("validate","严格输出拒绝已有资产渲染降级,请修复组件后重新准备报表。");const s=e.format==="pdf"?await import("@agile-team/mach-report/pdf"):void 0;o.throwIfAborted(e.signal);const r=e.pdf?.customFontFaces??(e.pdf?.customFontBytes?{regular:e.pdf.customFontBytes}:void 0),m=s&&r?s.createFontBytesMeasurer(r):void 0,g=n.createReportTaskReporter(e),u=await g.run("encode",async()=>{let w;if(e.format==="pdf"){o.throwIfAborted(e.signal);const d=await s.renderPlanToPdf(c.plan,{...e.pdf,...m?{measurer:m}:{},fidelity:e.fidelity,signal:e.signal,onProgress:(f,p)=>g.progress("encode",f,p)});w=d.bytes,c.diagnostics.push(...I(d.diagnostics)),c.diagnostics.push(...d.fidelityWarnings.map(f=>({code:"pdf-fidelity",message:f,severity:"warning"})),...d.pageErrors.map(f=>({code:"pdf-page",message:f,severity:"error"}))),d.unsupportedTextCount&&c.diagnostics.push({code:"pdf-font",message:`${d.unsupportedTextCount} 段文本包含当前字体不支持的字符`,severity:"warning"})}else{const{renderPlanToXlsx:d}=await import("@agile-team/mach-report/xlsx");o.throwIfAborted(e.signal);const f=await d(c.plan,{...e.xlsx,fidelity:e.fidelity,signal:e.signal,onProgress:(p,y)=>g.progress("encode",p,y)});w=new Uint8Array(f.buffer),c.diagnostics.push(...I(f.diagnostics)),c.diagnostics.push(...f.warnings.map(p=>({code:"xlsx-fidelity",message:p,severity:"warning"}))),c.diagnostics.push(...(f.notes??[]).map(p=>({code:"xlsx-snapshot",message:p,severity:"info"})))}return o.throwIfAborted(e.signal),w});o.assertBudget(t,"maxOutputBytes",u.byteLength);const{plan:i,...h}=c;return{...h,bytes:u,format:e.format,contentType:e.format==="pdf"?"application/pdf":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",stats:{...h.stats,durationMs:Date.now()-a,outputBytes:u.byteLength}}}function $(e){return{...e,reportIds:[...e.reportIds],...e.params?{params:{...e.params}}:{}}}function A(e,t){if(t.length===0)throw new n.ReportSourceError("config","缺少报表 ID");return t.map(a=>{if(!Object.prototype.hasOwnProperty.call(e,a))throw new n.ReportSourceError("config",`未注册报表 ${a}`);return e[a]})}function S(e){return e.grid?.cells.reduce((t,a)=>t+a.reduce((c,s)=>c+(s?1+(s.children?.reduce((r,m)=>r+S(m),0)??0):0),0),0)??0}function Q(e,t,a){return e.pages.reduce((c,s)=>c+s.components.reduce((r,m)=>m.kind!=="list"?r+S(m):r+n.estimateListLayoutCells(m,t,a),0),0)}function H(e,t=Object.keys(e)){return A(e,t).map((a,c)=>{const s=t[c],r=T.getReportParamDefs(e,[s]);return{id:s,params:JSON.parse(JSON.stringify(r)),paramsSchema:k.reportParamsJsonSchema(r),datasetsSchema:Object.fromEntries(Object.entries(a.dataSchema??{}).map(([m,g])=>[m,n.templateDatasetJsonSchema(typeof a.template=="function"?void 0:a.template,m,g)])),capabilities:{save:!!a.provider?.save,export:!!a.provider?.export,templates:!!a.provider?.templates}}})}function j(e,t){A(e,t.reportIds);const a=k.validateReportParams(T.getReportParamDefs(e,t.reportIds),t.params),c=t.reportIds.flatMap(r=>k.validateReportParams(T.getReportParamDefs(e,[r]),t.params).issues),s=new Map(c.map(r=>[JSON.stringify(r),r]));return{...a,ok:s.size===0,issues:[...s.values()]}}function F(e,t){const a=W.validateRenderPlan(e.plan);if(!a.ok)throw new n.ReportSourceError("validate",`执行器返回无效计划:${a.errors[0]?.path}`);const c=e.plan.pages.length,s=e.plan.pages.reduce((r,m)=>r+m.components.reduce((g,u)=>g+S(u),0),0);return o.assertBudget(t,"maxRows",e.stats.rows),o.assertBudget(t,"maxPages",c),o.assertBudget(t,"maxCells",s),{...e,stats:{...e.stats,pages:c,cells:s}}}function q(e,t){const a=j(e.reports,t);if(!a.ok)throw new k.ReportParamValidationError(a.issues)}function K(e){const t={...o.DEFAULT_REPORT_RUNTIME_BUDGET,...e.budget};o.validateBudget(t);const a=async(s,r)=>{const m=Date.now();let g=0,u=0;const i=[],h={},w=[],d=Object.fromEntries(Object.entries(e.reports).map(([l,x])=>[l,{...x,pagination:{...e.pagination,...x.pagination,...r?{measurer:r}:{}},dataValidation:{...x.dataValidation,maxRows:Math.min(t.maxRows??1e5,x.dataValidation?.maxRows??1/0),maxCells:Math.min(t.maxCells??2e6,x.dataValidation?.maxCells??1/0)}}])),p=await n.createReportSource(d,{maxPages:t.maxPages,maxCells:t.maxCells,maxChartComponents:t.maxChartComponents,onDatasets:(l,x,v)=>{try{g+=n.templateDatasetRowCount(v,x,{maxRows:t.maxRows,signal:s.signal})}catch(R){throw R instanceof G.TreeRowLimitError?new o.ReportRuntimeError("budget",R.message,"$.budget.maxRows"):R}o.assertBudget(t,"maxRows",g),u+=Q(v,x,d[l]?.pagination),o.assertBudget(t,"maxCells",u)}})({...s,params:s.params??{},onWarning:l=>i.push({code:"layout",message:l,severity:"warning"}),onQueryResult:(l,x,v=0)=>{const R=n.reportOccurrenceScope(v,l);Object.defineProperty(h,l,{value:{revision:x.revision,sourceToken:x.sourceToken},enumerable:!0,writable:!0}),w.push({reportId:l,reportIndex:v,reportScope:R,...x.revision===void 0?{}:{revision:x.revision},...x.sourceToken===void 0?{}:{sourceToken:x.sourceToken}}),i.push(...(x.diagnostics??[]).map(P=>({...P,...P.target?{target:{...P.target,reportScope:R,...P.target.tableId?{tableId:JSON.stringify([v,l,P.target.tableId])}:{}}}:{}})))}}).catch(l=>{throw l instanceof n.ReportSourceError&&l.cause instanceof n.PaginatePageLimitError?new o.ReportRuntimeError("budget",l.cause.message,"$.budget.maxPages"):l instanceof n.ReportSourceError&&l.cause instanceof n.PaginateCellLimitError?new o.ReportRuntimeError("budget",l.cause.message,"$.budget.maxCells"):l instanceof n.ReportSourceError&&l.cause instanceof n.PaginateChartComponentLimitError?new o.ReportRuntimeError("budget",l.cause.message,"$.budget.maxChartComponents"):l});o.throwIfAborted(s.signal);const y=e.assets?await n.createReportTaskReporter(s).run("assets",()=>M.resolvePlanAssets(p,{...e.assets,signal:s.signal})):{plan:p,diagnostics:[]},E=y.plan;i.push(...I(y.diagnostics));const O=E.pages.reduce((l,x)=>l+x.components.reduce((v,R)=>v+S(R),0),0);o.assertBudget(t,"maxPages",E.pages.length),o.assertBudget(t,"maxCells",O);const C=b.reportFontFingerprint(s.pdf),_=e.pagination?.measurer||Object.values(e.reports).some(l=>l.pagination?.measurer);return{plan:E,diagnostics:i,revisions:h,sources:w,layout:{textMetrics:C?"font-bytes":_?"provided":"heuristic",...C?{fontFingerprint:C}:{}},stats:{rows:g,pages:E.pages.length,cells:O,durationMs:Date.now()-m}}},c=async s=>{const r=Date.now();if(s.format!=="pdf"&&s.format!=="xlsx")throw new n.ReportSourceError("config","不支持的报表导出格式");const m=s.format==="pdf"?await import("@agile-team/mach-report/pdf"):void 0;o.throwIfAborted(s.signal);const g=s.pdf?.customFontFaces??(s.pdf?.customFontBytes?{regular:s.pdf.customFontBytes}:void 0),u=m&&g?m.createFontBytesMeasurer(g):void 0,i=await a(s,u);return o.throwIfAborted(s.signal),L({...s,prepared:i},t,r)};return{describe:s=>H(e.reports,s),validate:s=>j(e.reports,s),prepare:s=>o.controlled(s.signal,t.maxDurationMs,async r=>{const{signal:m,onEvent:g,...u}=$(s),i={...u,...u.pdf?{pdf:b.snapshotPdfFonts(u.pdf)}:{},taskId:u.taskId??n.reportTaskId()},h=g?y=>n.notifyReportTaskEvent(g,y,r):void 0,w={...i,signal:r,onEvent:h};n.createReportTaskReporter(w).runSync("validate",()=>q(e,i));let d;const f=i.pdf?.customFontFaces??(i.pdf?.customFontBytes?{regular:i.pdf.customFontBytes}:void 0);if(!e.executor&&f){const y=await import("@agile-team/mach-report/pdf");o.throwIfAborted(r),d=y.createFontBytesMeasurer(f)}const p=e.executor?await e.executor.prepare(i,r,h):await a(w,d);return F(p,t)}),exportPrepared:s=>o.controlled(s.signal,t.maxDurationMs,async r=>{const m=Date.now(),{signal:g,onEvent:u,...i}=s,h=F(b.snapshotPreparedReport(s.prepared,t.maxPreparedBytes??64e6,r),t),w={...i,xlsx:b.snapshotXlsxOptions(i.xlsx),prepared:h,...i.pdf?{pdf:b.snapshotPdfFonts(i.pdf)}:{},taskId:i.taskId??n.reportTaskId()};if(w.format!=="pdf"&&w.format!=="xlsx")throw new n.ReportSourceError("config","不支持的报表导出格式");const d=u?p=>n.notifyReportTaskEvent(u,p,r):void 0;if(e.executor){if(!e.executor.exportPrepared)throw new n.ReportSourceError("config","执行器未实现 exportPrepared;请升级执行器或显式使用本地运行时");const p=await e.executor.exportPrepared(w,r,d);return o.assertBudget(t,"maxRows",p.stats.rows),o.assertBudget(t,"maxPages",p.stats.pages),o.assertBudget(t,"maxCells",p.stats.cells),o.assertBudget(t,"maxOutputBytes",p.bytes.byteLength),{...p,stats:{...p.stats,outputBytes:p.bytes.byteLength}}}const f={...w,signal:r,onEvent:d};if(n.createReportTaskReporter(f).runSync("validate",()=>b.checkPreparedFont(f)),e.assets){const p=await n.createReportTaskReporter(f).run("assets",()=>M.resolvePlanAssets(h.plan,{...e.assets,signal:r}));h.plan=p.plan,h.diagnostics.push(...I(p.diagnostics))}return L(f,t,m)}),export:s=>o.controlled(s.signal,t.maxDurationMs,async r=>{const{signal:m,onEvent:g,...u}=$(s),i={...u,xlsx:b.snapshotXlsxOptions(u.xlsx),...u.pdf?{pdf:b.snapshotPdfFonts(u.pdf)}:{},taskId:u.taskId??n.reportTaskId()},h=g?f=>n.notifyReportTaskEvent(g,f,r):void 0,w={...i,signal:r,onEvent:h};if(n.createReportTaskReporter(w).runSync("validate",()=>q(e,i)),i.format!=="pdf"&&i.format!=="xlsx")throw new n.ReportSourceError("config","不支持的报表导出格式");const d=e.executor?await e.executor.export(i,r,h):await c(w);return o.assertBudget(t,"maxRows",d.stats.rows),o.assertBudget(t,"maxPages",d.stats.pages),o.assertBudget(t,"maxCells",d.stats.cells),o.assertBudget(t,"maxOutputBytes",d.bytes.byteLength),{...d,stats:{...d.stats,outputBytes:d.bytes.byteLength}}})}}exports.createReportRuntime=K;exports.enforcePrepared=F;
@@ -1 +0,0 @@
1
- "use strict";function o(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function l(e,i,r){typeof e=="string"?r.push({field:e,path:i}):Array.isArray(e)&&e.forEach((d,s)=>l(d,`${i}[${s}]`,r))}function $(e,i,r){if(Array.isArray(e)){e.forEach((d,s)=>$(d,`${i}[${s}]`,r));return}if(o(e))for(const[d,s]of Object.entries(e))["field","weightField"].includes(d)?l(s,`${i}.${d}`,r):d!=="value"&&d!=="style"&&$(s,`${i}.${d}`,r)}function a(e,i,r){Array.isArray(e)&&e.forEach((d,s)=>{if(!o(d))return;typeof d.field=="string"&&d.valueField!==void 0&&d.valueField!==d.field&&r.summaries.add(d.field);const f=d.valueField===void 0?"field":"valueField";l(d[f],`${i}[${s}].${f}`,r.fields),d.valueField!==void 0&&d.valueField===d.field&&l(d.field,`${i}[${s}].field`,r.fields),l(d.weightField,`${i}[${s}].weightField`,r.fields)})}function u(e,i,r){for(const s of["rowKey","revisionField","sourceTokenField"])l(e[s],`${i}.${s}`,r.fields);if(!e.matrix&&Array.isArray(e.columns)&&e.columns.forEach((s,f)=>{o(s)&&(typeof s.field=="string"&&r.fields.push({field:s.field,path:`${i}.columns[${f}].field`,summary:!0}),$(s.rules,`${i}.columns[${f}].rules`,r.fields),$(s.visibleWhen,`${i}.columns[${f}].visibleWhen`,r.fields))}),$(e.rowVisibleWhen,`${i}.rowVisibleWhen`,r.fields),Array.isArray(e.computed)&&e.computed.forEach((s,f)=>{o(s)&&(typeof s.field=="string"&&r.generated.add(s.field),$(s.expression,`${i}.computed[${f}].expression`,r.fields),l(s.dependsOn,`${i}.computed[${f}].dependsOn`,r.fields),l(s.groupBy,`${i}.computed[${f}].groupBy`,r.fields))}),(Array.isArray(e.groups)?e.groups.map((s,f)=>({group:s,path:`${i}.groups[${f}]`})):e.groupBy?[{group:e.groupBy,path:`${i}.groupBy`}]:[]).forEach(({group:s,path:f})=>{o(s)&&(l(s.field,`${f}.field`,r.fields),l(s.subtotal,`${f}.subtotal`,r.fields),a(s.aggregates,`${f}.aggregates`,r))}),o(e.grandTotal)&&(l(e.grandTotal.fields,`${i}.grandTotal.fields`,r.fields),a(e.grandTotal.aggregates,`${i}.grandTotal.aggregates`,r)),o(e.matrix)&&(l(e.matrix.rowFields,`${i}.matrix.rowFields`,r.fields),l(e.matrix.columnFields,`${i}.matrix.columnFields`,r.fields),a(e.matrix.measures,`${i}.matrix.measures`,r)),o(e.tree)){for(const s of["idField","parentField","labelField"])l(e.tree[s],`${i}.tree.${s}`,r.fields);a(e.tree.aggregates,`${i}.tree.aggregates`,r)}o(e.detail)&&l(e.detail.parentKey,`${i}.detail.parentKey`,r.fields)}function p(e){const i=[],r=e.repeat,d=r?{dataset:r.dataset,path:"$.template.repeat",fields:[],generated:new Set,summaries:new Set}:void 0;d&&r&&(l(r.rowKey,"$.template.repeat.rowKey",d.fields),typeof r.copies=="object"&&l(r.copies.field,"$.template.repeat.copies.field",d.fields),i.push(d));function s(f,n){if(Array.isArray(f)){f.forEach((t,c)=>s(t,`${n}[${c}]`));return}if(o(f)){if(d&&o(f.binding)&&l(f.binding.field,`${n}.binding.field`,d.fields),o(f.chartBinding)&&typeof f.chartBinding.dataset=="string"){const t=`${n}.chartBinding`,c=f.chartBinding,y={dataset:c.dataset,path:t,fields:[],generated:new Set,summaries:new Set};l(c.categoryField,`${t}.categoryField`,y.fields),$(c.measures,`${t}.measures`,y.fields),i.push(y)}if(typeof f.dataset=="string"&&Array.isArray(f.columns)){const t={dataset:f.dataset,path:n,fields:[],generated:new Set,summaries:new Set};u(f,n,t),typeof f.foreignKey=="string"&&l(f.foreignKey,`${n}.foreignKey`,t.fields),i.push(t)}for(const[t,c]of Object.entries(f))s(c,`${n}.${t}`)}}return s(e,"$.template"),i}exports.collectTemplateDatasetBindings=p;
@@ -1,62 +0,0 @@
1
- function l(e) {
2
- return !!e && typeof e == "object" && !Array.isArray(e);
3
- }
4
- function o(e, i, r) {
5
- typeof e == "string" ? r.push({ field: e, path: i }) : Array.isArray(e) && e.forEach((d, s) => o(d, `${i}[${s}]`, r));
6
- }
7
- function c(e, i, r) {
8
- if (Array.isArray(e)) {
9
- e.forEach((d, s) => c(d, `${i}[${s}]`, r));
10
- return;
11
- }
12
- if (l(e))
13
- for (const [d, s] of Object.entries(e))
14
- ["field", "weightField"].includes(d) ? o(s, `${i}.${d}`, r) : d !== "value" && d !== "style" && c(s, `${i}.${d}`, r);
15
- }
16
- function a(e, i, r) {
17
- Array.isArray(e) && e.forEach((d, s) => {
18
- if (!l(d)) return;
19
- typeof d.field == "string" && d.valueField !== void 0 && d.valueField !== d.field && r.summaries.add(d.field);
20
- const f = d.valueField === void 0 ? "field" : "valueField";
21
- o(d[f], `${i}[${s}].${f}`, r.fields), d.valueField !== void 0 && d.valueField === d.field && o(d.field, `${i}[${s}].field`, r.fields), o(d.weightField, `${i}[${s}].weightField`, r.fields);
22
- });
23
- }
24
- function u(e, i, r) {
25
- for (const s of ["rowKey", "revisionField", "sourceTokenField"]) o(e[s], `${i}.${s}`, r.fields);
26
- if (!e.matrix && Array.isArray(e.columns) && e.columns.forEach((s, f) => {
27
- l(s) && (typeof s.field == "string" && r.fields.push({ field: s.field, path: `${i}.columns[${f}].field`, summary: !0 }), c(s.rules, `${i}.columns[${f}].rules`, r.fields), c(s.visibleWhen, `${i}.columns[${f}].visibleWhen`, r.fields));
28
- }), c(e.rowVisibleWhen, `${i}.rowVisibleWhen`, r.fields), Array.isArray(e.computed) && e.computed.forEach((s, f) => {
29
- l(s) && (typeof s.field == "string" && r.generated.add(s.field), c(s.expression, `${i}.computed[${f}].expression`, r.fields), o(s.dependsOn, `${i}.computed[${f}].dependsOn`, r.fields), o(s.groupBy, `${i}.computed[${f}].groupBy`, r.fields));
30
- }), (Array.isArray(e.groups) ? e.groups.map((s, f) => ({ group: s, path: `${i}.groups[${f}]` })) : e.groupBy ? [{ group: e.groupBy, path: `${i}.groupBy` }] : []).forEach(({ group: s, path: f }) => {
31
- l(s) && (o(s.field, `${f}.field`, r.fields), o(s.subtotal, `${f}.subtotal`, r.fields), a(s.aggregates, `${f}.aggregates`, r));
32
- }), l(e.grandTotal) && (o(e.grandTotal.fields, `${i}.grandTotal.fields`, r.fields), a(e.grandTotal.aggregates, `${i}.grandTotal.aggregates`, r)), l(e.matrix) && (o(e.matrix.rowFields, `${i}.matrix.rowFields`, r.fields), o(e.matrix.columnFields, `${i}.matrix.columnFields`, r.fields), a(e.matrix.measures, `${i}.matrix.measures`, r)), l(e.tree)) {
33
- for (const s of ["idField", "parentField", "labelField"]) o(e.tree[s], `${i}.tree.${s}`, r.fields);
34
- a(e.tree.aggregates, `${i}.tree.aggregates`, r);
35
- }
36
- l(e.detail) && o(e.detail.parentKey, `${i}.detail.parentKey`, r.fields);
37
- }
38
- function p(e) {
39
- const i = [], r = e.repeat, d = r ? { dataset: r.dataset, path: "$.template.repeat", fields: [], generated: /* @__PURE__ */ new Set(), summaries: /* @__PURE__ */ new Set() } : void 0;
40
- d && r && (o(r.rowKey, "$.template.repeat.rowKey", d.fields), typeof r.copies == "object" && o(r.copies.field, "$.template.repeat.copies.field", d.fields), i.push(d));
41
- function s(f, n) {
42
- if (Array.isArray(f)) {
43
- f.forEach((t, $) => s(t, `${n}[${$}]`));
44
- return;
45
- }
46
- if (l(f)) {
47
- if (d && l(f.binding) && o(f.binding.field, `${n}.binding.field`, d.fields), l(f.chartBinding) && typeof f.chartBinding.dataset == "string") {
48
- const t = `${n}.chartBinding`, $ = f.chartBinding, y = { dataset: $.dataset, path: t, fields: [], generated: /* @__PURE__ */ new Set(), summaries: /* @__PURE__ */ new Set() };
49
- o($.categoryField, `${t}.categoryField`, y.fields), c($.measures, `${t}.measures`, y.fields), i.push(y);
50
- }
51
- if (typeof f.dataset == "string" && Array.isArray(f.columns)) {
52
- const t = { dataset: f.dataset, path: n, fields: [], generated: /* @__PURE__ */ new Set(), summaries: /* @__PURE__ */ new Set() };
53
- u(f, n, t), typeof f.foreignKey == "string" && o(f.foreignKey, `${n}.foreignKey`, t.fields), i.push(t);
54
- }
55
- for (const [t, $] of Object.entries(f)) s($, `${n}.${t}`);
56
- }
57
- }
58
- return s(e, "$.template"), i;
59
- }
60
- export {
61
- p as c
62
- };
@@ -1 +0,0 @@
1
- "use strict";const w=require("./json-snapshot-I5VI84Vp.cjs"),j=require("./assets-vbjAGgk8.cjs"),L=require("./dataset-IrlXbUvh.cjs"),h=require("./template-registry-DpLUSLwF.cjs"),E=require("./template-bindings-Cg5oBLFT.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 +0,0 @@
1
- "use strict";const u=require("./template-bindings-Cg5oBLFT.cjs");function $(e){const a=/\.pages\[(\d+)\](?:\.components\[(\d+)\])?/.exec(e);return a?{pageIndex:Number(a[1]),...a[2]===void 0?{}:{componentIndex:Number(a[2])}}:{}}function m(e,a,l){return u.collectTemplateDatasetBindings(e).filter(s=>s.dataset===a).flatMap(s=>s.fields.filter(t=>t.field===l).map(t=>({...t,...$(t.path),dataset:a,kind:/\.computed\[/.test(t.path)?"calculation":/\.columns\[\d+\]\.field$/.test(t.path)?"display":"binding"})))}function g(e,a){const l=e.kind==="list"?e.title||e.dataset:e.binding?.field||e.text||e.nid;return`${e.kind} · ${(l||String(a+1)).replace(/\s+/g," ").slice(0,80)}`}function k(e){const a=u.collectTemplateDatasetBindings(e),l=new Map;for(const t of a)for(const d of t.fields){const c=/^\$\.template\.pages\[\d+\]\.components\[\d+\]/.exec(d.path)?.[0];if(!c)continue;const n=l.get(c)??[];n.push({...d,dataset:t.dataset}),l.set(c,n)}const s=[];return e.pages.forEach((t,d)=>{const c=`$.template.pages[${d}]`;s.push({path:c,pageIndex:d,kind:"page",depth:0,title:typeof t.meta?.title=="string"?t.meta.title:`${d+1} · ${t.widthMm} × ${t.heightMm} mm`}),t.components.forEach((n,p)=>{const o=`${c}.components[${p}]`,f={pageIndex:d,componentIndex:p};s.push({path:o,...f,depth:1,kind:"component",title:g(n,p)}),n.kind==="list"&&(n.columns.forEach((i,h)=>s.push({path:`${o}.columns[${h}].field`,...f,depth:2,kind:"field",title:`${i.header} · ${i.field}`,field:i.field,dataset:n.dataset})),n.computed?.forEach((i,h)=>s.push({path:`${o}.computed[${h}]`,...f,depth:2,kind:"calculation",title:i.field,field:i.field,dataset:n.dataset})));const r=new Set;for(const i of l.get(o)??[])/\.columns\[\d+\]\.field$/.test(i.path)||r.has(i.path)||(r.add(i.path),s.push({...i,...f,depth:2,kind:"binding",title:i.field}))})}),s}exports.collectTemplateOutline=k;exports.inspectTemplateFieldUsage=m;exports.templatePathLocation=$;
@@ -1,88 +0,0 @@
1
- import { c as u } from "./template-bindings-TKnXM7ll.js";
2
- function $(e) {
3
- const s = /\.pages\[(\d+)\](?:\.components\[(\d+)\])?/.exec(e);
4
- return s ? {
5
- pageIndex: Number(s[1]),
6
- ...s[2] === void 0 ? {} : { componentIndex: Number(s[2]) }
7
- } : {};
8
- }
9
- function k(e, s, n) {
10
- return u(e).filter((a) => a.dataset === s).flatMap(
11
- (a) => a.fields.filter((t) => t.field === n).map((t) => ({
12
- ...t,
13
- ...$(t.path),
14
- dataset: s,
15
- kind: /\.computed\[/.test(t.path) ? "calculation" : /\.columns\[\d+\]\.field$/.test(t.path) ? "display" : "binding"
16
- }))
17
- );
18
- }
19
- function m(e, s) {
20
- const n = e.kind === "list" ? e.title || e.dataset : e.binding?.field || e.text || e.nid;
21
- return `${e.kind} · ${(n || String(s + 1)).replace(/\s+/g, " ").slice(0, 80)}`;
22
- }
23
- function b(e) {
24
- const s = u(e), n = /* @__PURE__ */ new Map();
25
- for (const t of s)
26
- for (const l of t.fields) {
27
- const c = /^\$\.template\.pages\[\d+\]\.components\[\d+\]/.exec(
28
- l.path
29
- )?.[0];
30
- if (!c) continue;
31
- const d = n.get(c) ?? [];
32
- d.push({ ...l, dataset: t.dataset }), n.set(c, d);
33
- }
34
- const a = [];
35
- return e.pages.forEach((t, l) => {
36
- const c = `$.template.pages[${l}]`;
37
- a.push({
38
- path: c,
39
- pageIndex: l,
40
- kind: "page",
41
- depth: 0,
42
- title: typeof t.meta?.title == "string" ? t.meta.title : `${l + 1} · ${t.widthMm} × ${t.heightMm} mm`
43
- }), t.components.forEach((d, h) => {
44
- const f = `${c}.components[${h}]`, o = { pageIndex: l, componentIndex: h };
45
- a.push({
46
- path: f,
47
- ...o,
48
- depth: 1,
49
- kind: "component",
50
- title: m(d, h)
51
- }), d.kind === "list" && (d.columns.forEach(
52
- (i, p) => a.push({
53
- path: `${f}.columns[${p}].field`,
54
- ...o,
55
- depth: 2,
56
- kind: "field",
57
- title: `${i.header} · ${i.field}`,
58
- field: i.field,
59
- dataset: d.dataset
60
- })
61
- ), d.computed?.forEach(
62
- (i, p) => a.push({
63
- path: `${f}.computed[${p}]`,
64
- ...o,
65
- depth: 2,
66
- kind: "calculation",
67
- title: i.field,
68
- field: i.field,
69
- dataset: d.dataset
70
- })
71
- ));
72
- const r = /* @__PURE__ */ new Set();
73
- for (const i of n.get(f) ?? [])
74
- /\.columns\[\d+\]\.field$/.test(i.path) || r.has(i.path) || (r.add(i.path), a.push({
75
- ...i,
76
- ...o,
77
- depth: 2,
78
- kind: "binding",
79
- title: i.field
80
- }));
81
- });
82
- }), a;
83
- }
84
- export {
85
- b as c,
86
- k as i,
87
- $ as t
88
- };
@@ -1 +0,0 @@
1
- "use strict";const I=require("./computed-4TnxzgIh.cjs"),K=require("./matrix-0hywp0-F.cjs"),v=require("./component-tree-BjZIp6w9.cjs"),ne=require("./code-options-BUTChiZZ.cjs"),H=require("./param-validation-C-8sRJLq.cjs"),M=require("./template-serialization-D1R5oAqh.cjs");function ae(e,i,t){e!==void 0&&(typeof e!="string"||!e.trim()||e.length>4096)&&t.push({path:i,message:"来源范围应为不超过 4096 字符的非空字符串"})}function J(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 oe(e,i,t){J(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:"派生结果标记应为布尔值"}),W(e.source,`${i}.source`,t,!0),e.formula!==void 0&&typeof e.formula!="string"&&t.push({path:`${i}.formula`,message:"单元格公式应为字符串"})}function W(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;ae(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 re=new Set(["text","image","barcode","qrcode","chart","line","rect","ellipse"]);function g(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function S(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 fe(e,i,t,s){const n=e[i];(typeof n!="number"||!Number.isFinite(n))&&s.push({path:`${t}.${i}`,message:`应为有限数字,实际 ${S(n)}`})}function de(e,i,t){if(e!==void 0){const s=`${i}.table`;if(!g(e))t.push({path:s,message:"逻辑表来源应为对象"});else{W(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 ue(e,i,t,s){if(e!==void 0)if(!g(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(!g(r)){t.push({path:d,message:"网格单元格应为对象或 null"});return}oe(r,d,t),r.dataBar!==void 0&&!v.validDataBar(r.dataBar)&&t.push({path:`${d}.dataBar`,message:"数据条应包含 0–1 有序比例与 #RRGGBB 颜色"}),G(r.richParagraphs,d,t),Array.isArray(r.children)&&r.children.forEach((u,p)=>{C(u,`${i}.grid.cells.${o}.${f}.children.${p}`,t,s)})})})}}function R(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 he(e,i,t){if(e!==void 0){if(!g(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"}),R(e.align,["left","center","right","justify"],`${i}.align`,t),R(e.verticalAlign,["top","middle","bottom"],`${i}.verticalAlign`,t)}}function me(e,i,t){if(!g(e)){t.push({path:i,message:"富文本片段应为对象"});return}R(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:"富文本内容应为字符串"});he(e.style,`${i}.style`,t)}function G(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(!g(s)||!Array.isArray(s.segments)){t.push({path:a,message:"段落缺少 segments 数组"});return}R(s.align,["left","center","right","justify"],`${a}.align`,t),O(s,["lineHeight","spaceBeforeMm","spaceAfterMm","indentMm"],a,t),s.segments.forEach((o,r)=>me(o,`${a}.segments.${r}`,t))})}}function _(e,i,t,s=[]){const n=v.componentTreeIssue([e],i);if(n){t.push(n);return}C(e,i,t,s)}function C(e,i,t,s=[]){if(!g(e)){t.push({path:i,message:"组件应为对象"});return}const n=e.kind;typeof n!="string"?t.push({path:`${i}.kind`,message:"组件缺少 kind 字符串"}):re.has(n)||s.push({path:`${i}.kind`,message:`未知组件类型 ${S(n)},将以兜底方式渲染`});for(const a of["leftMm","topMm","widthMm","heightMm"])fe(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:"组件尺寸不能为负数"});de(e.table,i,t),ge(e.code,n,i,t),ce(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"}),ue(e.grid,i,t,s),G(e.richParagraphs,i,t)}function ce(e,i,t){if(e.chartBinding!==void 0)try{if(K.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 ge(e,i,t,s){if(e!==void 0)for(const n of ne.codeOptionIssues(e,i))s.push({path:`${t}.code${n.path?`.${n.path}`:""}`,message:n.message})}function U(e,i,t){if(!g(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;!g(s)||!Array.isArray(s.cells)||s.cells.forEach((n,a)=>{Array.isArray(n)&&n.forEach((o,r)=>{!g(o)||!Array.isArray(o.children)||o.children.forEach((f,d)=>U(f,`${i}.grid.cells.${a}.${r}.children.${d}`,t))})})}function q(e,i,t,s=[]){if(!g(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:`页宽非法: ${S(n)}`}),(typeof a!="number"||!(a>0&&a<5e3))&&t.push({path:`${i}.pageHeightMm`,message:`页高非法: ${S(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=v.componentTreeIssue(o,`${i}.components`);if(r){t.push(r);return}o.forEach((f,d)=>{C(f,`${i}.components.${d}`,t,s),U(f,`${i}.components.${d}`,t)})}}function z(e){const i=[],t=[],s=g(e)?e.pages:void 0;if(g(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=v.renderTreeIssue(s);if(n)return{ok:!1,errors:[...i,n],warnings:t};s.forEach((o,r)=>q(o,`$.pages.${r}`,i,t)),s.length>2e3&&t.push({path:"$.pages",message:`页数异常大(${s.length} 页),渲染与打印耗时可能显著增加`});const a=s.reduce((o,r)=>o+(g(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 pe(e){const i=z(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 L(e){return e.kind==="list"?e.id:e.nid}function ye(e){return e.kind==="list"?!1:e.pageAnchor!==void 0||e.kind==="text"&&typeof e.text=="string"&&/\{(?:page|totalPages)\}/.test(e.text)}function le(e,i){const t=e.filter(n=>i.componentIds.includes(L(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 $e(e,i){if(!i)return e.map(s=>({components:[s]}));const t=new Map(e.map(s=>[L(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 X(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(ye(n))continue;const a=L(n);if(!a||t.has(a))throw new Error("流式排版组件应具有唯一标识");t.add(a)}if(be(e,i,t,s),s.size!==t.size)throw new Error("流式排版必须显式包含每个非锚点组件")}function be(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)}le(e,a),n=a.topMm+a.heightMm}}const Ae=new Set(["__proto__","prototype","constructor"]);function l(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function k(e){return typeof e=="string"&&!!e.trim()&&!Ae.has(e)}function T(e,i,t,s){for(const n of Object.keys(e))i.includes(n)||s.push({path:`${t}.${n}`,message:"存在未知配置字段"})}function we(e,i,t){if(e!==void 0){if(!l(e)||!["number","percent","date"].includes(String(e.kind))){t.push({path:i,message:"绑定格式应为 number、percent 或 date"});return}T(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 Me(e,i,t){const s=e.binding;if(s===void 0)return;const n=`${i}.binding`;if(!l(s)){t.push({path:n,message:"字段绑定应为对象"});return}(!["text","image","barcode","qrcode"].includes(String(e.kind))||e.grid!==void 0)&&t.push({path:n,message:"绑定仅支持独立文本、图片、条码与二维码组件"}),T(s,["field","format","prefix","suffix","emptyText"],n,t),k(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:"应为字符串"});we(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 Ee(e,i){if(!l(e)){i.push({path:"$.repeat",message:"逐记录配置应为对象"});return}T(e,["dataset","rowKey","copies"],"$.repeat",i),k(e.dataset)||i.push({path:"$.repeat.dataset",message:"数据集应为安全的非空名称"}),e.rowKey!==void 0&&!k(e.rowKey)&&i.push({path:"$.repeat.rowKey",message:"业务主键应为安全的非空字段名"});const t=e.copies;t!==void 0&&(l(t)?(T(t,["field"],"$.repeat.copies",i),k(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 Y(e,i,t,s){if(!l(e))return;Me(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;l(n)&&Array.isArray(n.cells)&&n.cells.forEach((a,o)=>{Array.isArray(a)&&a.forEach((r,f)=>{l(r)&&Array.isArray(r.children)&&r.children.forEach((d,u)=>Y(d,`${i}.grid.cells.${o}.${f}.children.${u}`,t,s))})})}function Q(e,i){const t=e.repeat!==void 0;t&&Ee(e.repeat,i),Array.isArray(e.pages)&&e.pages.forEach((s,n)=>{if(!l(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(Y(o,f,t,i),!t||!l(o))return;const{leftMm:d,topMm:u,widthMm:p,heightMm:y}=o;[d,u,p,y,s.widthMm,s.heightMm].every(A=>typeof A=="number"&&Number.isFinite(A))&&(Number(d)<0||Number(u)<0||Number(d)+Number(p)>Number(s.widthMm)+.001||Number(u)+Number(y)>Number(s.heightMm)+.001)&&i.push({path:f,message:"标签组件超出纸张边界,请调整位置或尺寸"})})})}function ve(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function F(e,i,t){if(e!==void 0)try{I.compileReportPredicate(e)}catch(s){t.push({path:i,message:s instanceof Error?s.message:String(s)})}}function Z(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(!ve(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{I.createAggregateAccumulator({...n,field:n.valueField??r})}catch(f){t.push({path:o,message:f instanceof Error?f.message:String(f)})}})}function ke(e,i,t){if(e===void 0)return;const s=I.validateComputedFields(e);for(const n of s.errors)t.push({path:i,message:n})}function Ne(e,i,t){if(e!==void 0)try{K.validateMatrixOptions(e)}catch(s){t.push({path:i,message:s instanceof Error?s.message:String(s)})}}function Se(e,i,t){if(e.tree===void 0)return;const s=`${i}.tree`;try{M.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)&&M.validateTreeComputed(n,e.computed)}catch(n){t.push({path:s,message:n instanceof Error?n.message:String(n)})}}const D="1.0";class w extends Error{constructor(i){super(`模板校验失败:${i.slice(0,3).map(t=>`${t.path}: ${t.message}`).join("; ")}`),this.errors=i,this.name="ReportTemplateError"}}const Re=new Set(["__proto__","prototype","constructor"]),Te=new Set(["schemaVersion","id","name","revision","description","template"]),xe=new Set(["left","center","right","justify"]),N=2e5,Pe=64;function h(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Oe(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 Fe(e,i,t,s){return Re.has(e)?(s.push({path:t,message:"模板不能包含可能污染原型的键"}),!1):i.get||i.set||!i.enumerable?(s.push({path:t,message:"模板不能包含访问器或不可枚举字段"}),!1):!0}function Ie(e){return e===null||typeof e=="boolean"||typeof e=="number"&&Number.isFinite(e)}function V(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>Pe){i.push({path:f,message:"模板嵌套层级过深"});return}if(typeof r=="string"){n+=r.length,n>M.MAX_TEMPLATE_JSON_CHARACTERS&&(a=!0,i.push({path:f,message:"模板文本超过 1000 万字符的安全上限"}));return}if(!Ie(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(Oe(r,f,i)){t.add(r);for(const[u,p]of Object.entries(Object.getOwnPropertyDescriptors(r))){if(Array.isArray(r)&&u==="length")continue;const y=`${f}.${u}`;if(Fe(u,p,y,i)&&o(p.value,y,d+1),s>N||a)break}t.delete(r)}}}};o(e,"$",0)}function m(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 c(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 b(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&&!xe.has(e)&&!(s&&e==="auto")&&t.push({path:i,message:`未知对齐方式${s?"(支持 auto)":""}`})}function $(e,i,t){if(e!==void 0){if(!h(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"])c(e,s,i,t);for(const s of["letterSpacing","rotateDeg"])c(e,s,i,t,-1/0);c(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"])b(e,s,i,t);for(const s of["fontFamily","color","backgroundColor","lineColor","borderColor"])m(e,s,i,t)}}function _e(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(!h(a)){t.push({path:r,message:"参数定义应为对象"});return}m(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"])m(a,f,r,t);b(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:"长度边界应为非负整数"})}Ce(a,r,t),a.options!==void 0&&(Array.isArray(a.options)?a.options.forEach((f,d)=>{const u=`${r}.options.${d}`;if(!h(f))t.push({path:u,message:"选项应为对象"});else for(const p of["label","value"])typeof f[p]!="string"&&t.push({path:`${u}.${p}`,message:"选项标签与值应为字符串(允许空白选项)"})}):t.push({path:`${r}.options`,message:"选项应为数组"}))}),t.length===n&&t.push(...H.validateReportParamDefinitions(e).map(a=>({path:a.path.replace("$.paramDefs",i),message:a.message})))}function Ce(e,i,t){for(const a of["min","max"]){const o=e[a];if(o===void 0)continue;H.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 ee(e,i,t){if(!Array.isArray(e)||e.length===0){t.push({path:i,message:"列表至少需要一列"});return}e.every(s=>h(s)&&s.hidden===!0)&&t.push({path:i,message:"列表至少需要一列可见列"}),e.forEach((s,n)=>{const a=`${i}.${n}`;if(!h(s)){t.push({path:a,message:"列应为对象"});return}if(J(s,a,t),s.visual!==void 0&&!M.validColumnVisual(s.visual)&&t.push({path:`${a}.visual`,message:"列可视化配置无效,请检查类型、数值范围和颜色"}),b(s,"hidden",a,t),F(s.visibleWhen,`${a}.visibleWhen`,t),typeof s.header!="string"&&t.push({path:`${a}.header`,message:"表头应为字符串(允许空白表头)"}),m(s,"field",a,t,!0),c(s,"widthMm",a,t,Number.MIN_VALUE,!0),$(s.style,`${a}.style`,t),$(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(!h(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 的整数"}),b(s.format,"thousands",`${a}.format`,t),m(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(!h(o)||!h(o.when)){t.push({path:f,message:"条件格式缺少 when 对象"});return}F(o.when,`${f}.when`,t),$(o.style,`${f}.style`,t)}):t.push({path:`${a}.rules`,message:"条件格式应为数组"}))})}function te(e,i,t){if(e!==void 0){if(!h(e)){t.push({path:i,message:"分组应为对象"});return}m(e,"field",i,t,!0);for(const s of["headerTemplate","subtotalLabel"])m(e,s,i,t);for(const s of["headerStyle","subtotalStyle"])$(e[s],`${i}.${s}`,t);b(e,"keepWithNext",i,t),b(e,"repeatHeader",i,t),Z(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 Le(e,i,t){if(!(e===void 0||typeof e=="boolean")){if(!h(e)){t.push({path:i,message:"合计应为布尔值或对象"});return}m(e,"label",i,t),Z(e.aggregates,`${i}.aggregates`,t),$(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 De(e,i,t,s){const n={kind:"rect",leftMm:0,topMm:0,widthMm:1,heightMm:1,grid:e};if(_(n,t,s,[]),B(n,t,s),!h(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:"表头行高数量应与行数一致"}),Ve(a,o,t,s)}function Ve(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=h(f)&&typeof f.colSpan=="number"?f.colSpan:1,p=h(f)&&typeof f.rowSpan=="number"?f.rowSpan:1;(r+u>i||o+p>e.length)&&s.push({path:`${t}.cells.${o}.${d}`,message:"表头合并区域超出表头边界"});for(let y=o;y<Math.min(e.length,o+p);y++)for(let A=r;A<Math.min(i,r+u);A++)n.has(`${y}:${A}`)&&s.push({path:`${t}.cells.${o}.${d}`,message:"表头合并区域重叠"}),n.add(`${y}:${A}`);r+=u})})}function Be(e,i,t){if(Se(e,i,t),ke(e.computed,`${i}.computed`,t),Ne(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 汇总,不能同时配置普通分组、总计或主从明细"}),F(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)=>te(a,`${i}.groups.${o}`,t))),e.detail===void 0)return;const s=e.detail,n=`${i}.detail`;if(!h(s)){t.push({path:n,message:"主从关联应为对象"});return}for(const a of["dataset","parentKey","foreignKey"])m(s,a,n,t,!0);for(const a of["rowKey","revisionField","sourceTokenField"])m(s,a,n,t,s[a]!==void 0);m(s,"label",n,t),b(s,"header",n,t),c(s,"rowHeightMm",n,t,Number.MIN_VALUE),ee(s.columns,`${n}.columns`,t),s.unmatched!==void 0&&s.unmatched!=="error"&&s.unmatched!=="ignore"&&t.push({path:`${n}.unmatched`,message:"未关联明细策略应为 error 或 ignore"})}function je(e,i,t){for(const s of["leftMm","topMm"])c(e,s,i,t,-1/0,!0);c(e,"widthMm",i,t,Number.MIN_VALUE,!0),m(e,"dataset",i,t,!0),m(e,"title",i,t);for(const s of["rowKey","revisionField","sourceTokenField"])m(e,s,i,t,e[s]!==void 0);e.headerGrid!==void 0&&De(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"}),ee(e.columns,`${i}.columns`,t);for(const s of["fontSizePt","rowHeightMm"])c(e,s,i,t,Number.MIN_VALUE);c(e,"paddingMm",i,t);for(const s of["header","headerBold","headerEveryPage","border"])b(e,s,i,t);e.cardinality!==void 0&&e.cardinality!=="record"&&t.push({path:`${i}.cardinality`,message:"单记录区域类型应为 record"}),m(e,"headerBackgroundColor",i,t),E(e.align,`${i}.align`,t,!0),E(e.headerAlign,`${i}.headerAlign`,t),$(e.headerStyle,`${i}.headerStyle`,t),Be(e,i,t),te(e.groupBy,`${i}.groupBy`,t),Le(e.grandTotal,`${i}.grandTotal`,t)}function j(e,i,t){Array.isArray(e.richParagraphs)&&e.richParagraphs.forEach((s,n)=>{if(!h(s))return;const a=`${i}.richParagraphs.${n}`;E(s.align,`${a}.align`,t);for(const o of["lineHeight","spaceBeforeMm","spaceAfterMm","indentMm"])c(s,o,a,t);Array.isArray(s.segments)&&s.segments.forEach((o,r)=>{const f=`${a}.segments.${r}`;if(!h(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"])m(o,d,f,t);$(o.style,`${f}.style`,t)})})}function B(e,i,t){$(e.style,`${i}.style`,t);for(const n of["text","rawText","imageData","fallbackText","nid","rkey"])m(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:"文本行应为字符串数组"}),j(e,i,t),!h(e.grid))return;const s=e.grid;c(s,"gapMm",`${i}.grid`,t),c(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(!h(o)){t.push({path:f,message:"网格单元格应为对象或 null"});return}for(const d of["text","rawText","numberFormat"])m(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"}),$(o.style,`${f}.style`,t),j(o,f,t),o.children!==void 0&&(Array.isArray(o.children)?o.children.forEach((d,u)=>{h(d)&&B(d,`${f}.children.${u}`,t)}):t.push({path:`${f}.children`,message:"嵌套组件应为数组"}))}})})}function Ke(e,i,t){if(!(e.flow===void 0||!Array.isArray(e.components)))try{X(e.components,e.flow)}catch(s){t.push({path:`${i}.flow`,message:s instanceof Error?s.message:String(s)})}}function ie(e){const i=[],t=[];return V(e,i),i.length?{ok:!1,errors:i,warnings:t}:(h(e)?(e.schemaVersion!==void 0&&e.schemaVersion!==v.RENDER_PLAN_SCHEMA_VERSION&&i.push({path:"$.schemaVersion",message:"不支持的模板 schemaVersion"}),_e(e.params,"$.params",i),Q(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(!h(s)){i.push({path:a,message:"页应为对象"});return}c(s,"widthMm",a,i,Number.MIN_VALUE,!0),c(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"])c(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}`;h(o)&&o.kind==="list"?je(o,f,i):(_(o,f,i,t),h(o)&&B(o,f,i))}):i.push({path:`${a}.components`,message:"组件应为数组"}),Ke(s,a,i)})):i.push({path:"$",message:"模板应为对象"}),{ok:i.length===0,errors:i,warnings:t})}function se(e){const i=[],t=[];if(V(e,i),i.length)return{ok:!1,errors:i,warnings:t};if(!h(e))i.push({path:"$",message:"模板文档应为对象"});else{for(const n of Object.keys(e))Te.has(n)||i.push({path:`$.${n}`,message:"模板文档存在未知字段;只保存模板与描述,不保存取数或业务数据"});e.schemaVersion!==D&&i.push({path:"$.schemaVersion",message:"不支持的模板文档版本"});for(const n of["id","name"])m(e,n,"$",i,!0);for(const n of["revision","description"])m(e,n,"$",i);const s=ie(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 P(e){const i=se(e);if(!i.ok)throw new w(i.errors)}function He(e){const i=[];if(V(e,i),i.length)throw new w(i);const t={...e,schemaVersion:e.schemaVersion??D};return P(t),x(t)}function Je(e){let i=e;if(typeof e=="string"){if(e.length>M.MAX_TEMPLATE_JSON_CHARACTERS)throw new w([{path:"$",message:"模板 JSON 超过 1000 万字符的导出/导入上限"}]);try{i=JSON.parse(e)}catch{throw new w([{path:"$",message:"模板 JSON 语法无效"}])}}return P(i),x(i)}function We(e){P(e);try{return M.stringifyValidatedTemplate(e)}catch(i){throw i instanceof RangeError?new w([{path:"$",message:i.message}]):i}}function x(e){return JSON.parse(JSON.stringify(e))}function Ge(e=[]){const i=new Map,t={get:s=>{const n=i.get(s);return n?x(n):void 0},list:()=>Array.from(i.values(),({template:s,...n})=>({...n})),register:(s,n={})=>{if(P(s),i.has(s.id)&&!n.replace)throw new w([{path:"$.id",message:`模板 ID ${s.id} 已注册;更新需显式 replace:true`}]);i.set(s.id,x(s))},remove:s=>i.delete(s)};for(const s of e)t.register(s);return t}exports.REPORT_TEMPLATE_DOCUMENT_VERSION=D;exports.ReportTemplateError=w;exports.assertRenderPlan=pe;exports.createTemplateRegistry=Ge;exports.defineReportTemplate=He;exports.parseReportTemplate=Je;exports.reportFlowGroups=$e;exports.serializeReportTemplate=We;exports.validateComponent=_;exports.validatePage=q;exports.validateRenderPlan=z;exports.validateReportPageFlow=X;exports.validateReportTemplate=ie;exports.validateReportTemplateDocument=se;exports.validateTemplateRepeat=Q;