@agile-team/mach-report 2.15.0 → 2.17.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 (171) hide show
  1. package/README.md +21 -12
  2. package/dist/{ExcelBindingWizard-Bs43BGNp.cjs → ExcelBindingWizard-Bq6FYME6.cjs} +1 -1
  3. package/dist/{ExcelBindingWizard-BKH1nGNS.js → ExcelBindingWizard-Co1svTsw.js} +3 -3
  4. package/dist/{ParamEditor-Da4akw6V.cjs → ParamEditor-B5UZRgxv.cjs} +1 -1
  5. package/dist/{ParamEditor-DoAhzJsm.js → ParamEditor-DNNARyeB.js} +1 -1
  6. package/dist/{ReportBatchPanel-wP9m9Pj1.cjs → ReportBatchPanel-Ctvs2t_9.cjs} +1 -1
  7. package/dist/{ReportBatchPanel-BMf6boMA.js → ReportBatchPanel-uQh06usx.js} +3 -3
  8. package/dist/ReportPreview-BdQawRh0.js +4879 -0
  9. package/dist/ReportPreview-CJC_-j2I.cjs +6 -0
  10. package/dist/{ReportTemplateLibrary-Sxr3eD0J.cjs → ReportTemplateLibrary-CnP7_1pH.cjs} +1 -1
  11. package/dist/{ReportTemplateLibrary-C9wutIiT.js → ReportTemplateLibrary-TIL_Oj2l.js} +1 -1
  12. package/dist/RuleEditor-DkRjOLlr.js +2141 -0
  13. package/dist/RuleEditor-h5anGsDB.cjs +1 -0
  14. package/dist/{TemplateOutlinePanel-JTSR53vJ.cjs → TemplateOutlinePanel-BlLxRrfu.cjs} +1 -1
  15. package/dist/{TemplateOutlinePanel-D6Bkny59.js → TemplateOutlinePanel-BouxsuqQ.js} +1 -1
  16. package/dist/{TemplateReusePanel-rVuK1kTz.js → TemplateReusePanel-BEACLPaN.js} +2 -2
  17. package/dist/{TemplateReusePanel-Kx35S0Ql.cjs → TemplateReusePanel-yxsHSO40.cjs} +1 -1
  18. package/dist/{TemplateReviewPanel-B0ar9_zf.js → TemplateReviewPanel-B1OGRY2i.js} +1 -1
  19. package/dist/{TemplateReviewPanel-Dn6X9UmY.cjs → TemplateReviewPanel-D9Cx0m2N.cjs} +1 -1
  20. package/dist/analytics.cjs +1 -1
  21. package/dist/analytics.d.cts +65 -1
  22. package/dist/analytics.d.ts +65 -1
  23. package/dist/analytics.js +4 -4
  24. package/dist/artifact-integrity.json +105 -101
  25. package/dist/assets-BIMVwjQe.js +231 -0
  26. package/dist/assets-Dfs2ElxI.cjs +1 -0
  27. package/dist/auto-BIOmtVhk.js +240 -0
  28. package/dist/auto-DDHflI9v.cjs +1 -0
  29. package/dist/{batch-BfZHN1do.js → batch-WzDIXJAt.js} +1 -1
  30. package/dist/{batch-CLpELXBl.cjs → batch-z6Aw5GEY.cjs} +1 -1
  31. package/dist/codes.d.cts +2 -0
  32. package/dist/codes.d.ts +2 -0
  33. package/dist/component-tree-Ca6YYfHq.js +61 -0
  34. package/dist/component-tree-DkGLEfZC.cjs +1 -0
  35. package/dist/computed-BW5a8QFk.js +612 -0
  36. package/dist/computed-C2GD3XcE.cjs +1 -0
  37. package/dist/config-Dg_o8e7m.cjs +1 -0
  38. package/dist/{config-BVsJXSqS.js → config-XQ4qrQ7Q.js} +66 -64
  39. package/dist/dataset-DL83majE.js +161 -0
  40. package/dist/dataset-IrlXbUvh.cjs +1 -0
  41. package/dist/designer-D9XAxqSc.js +5178 -0
  42. package/dist/designer-uCDo5XSK.cjs +2 -0
  43. package/dist/designer.cjs +1 -1
  44. package/dist/designer.d.cts +178 -3
  45. package/dist/designer.d.ts +178 -3
  46. package/dist/designer.js +1 -1
  47. package/dist/drill-ByN8COs_.cjs +1 -0
  48. package/dist/{drill-ByJviLXS.js → drill-CKW3Xtfa.js} +5 -5
  49. package/dist/encoding-BFMFIc4r.cjs +1 -0
  50. package/dist/encoding-DP_Eaf0A.js +21 -0
  51. package/dist/{font-loader-B_UkxpzC.cjs → font-loader-7FWVlykp.cjs} +1 -1
  52. package/dist/{font-loader-Q3bQjmrI.js → font-loader-CQZowp0I.js} +1 -1
  53. package/dist/index.cjs +8 -9
  54. package/dist/index.d.cts +175 -1
  55. package/dist/index.d.ts +175 -1
  56. package/dist/index.js +1343 -915
  57. package/dist/json-snapshot-D7PE1NsU.cjs +2 -0
  58. package/dist/json-snapshot-DYmEe3sO.js +1779 -0
  59. package/dist/matrix-JLAXlux-.js +302 -0
  60. package/dist/matrix-gTHpDTGm.cjs +1 -0
  61. package/dist/{pdf-CvvrjPQg.cjs → pdf-B8JouyYv.cjs} +48 -50
  62. package/dist/{pdf-BwNyeGpt.js → pdf-l3ea86di.js} +2734 -2748
  63. package/dist/pdf.cjs +1 -1
  64. package/dist/pdf.d.cts +14 -0
  65. package/dist/pdf.d.ts +14 -0
  66. package/dist/pdf.js +2 -2
  67. package/dist/{plugin-Ca_XZG3l.js → plugin-BBp74CQZ.js} +1 -1
  68. package/dist/{plugin-DHO7X8z2.cjs → plugin-CtFX9PFG.cjs} +1 -1
  69. package/dist/prepared-CARicKYh.js +87 -0
  70. package/dist/prepared-Ch1x_Gog.cjs +1 -0
  71. package/dist/progress-BXzlVbIp.js +29 -0
  72. package/dist/progress-DJBd9Rb9.cjs +1 -0
  73. package/dist/{progress-D-OTpEav.js → progress-Hc2vxoCs.js} +2 -2
  74. package/dist/protocol-B5A2uom4.cjs +1 -0
  75. package/dist/protocol-BaiWjq5w.js +90 -0
  76. package/dist/record-bindings-B86Sur_y.cjs +1 -0
  77. package/dist/{record-bindings-Do_b3h4V.js → record-bindings-D4TuMzHs.js} +10 -11
  78. package/dist/{region-binding-workflow-BMhK_TjP.js → region-binding-workflow-BNasF5kz.js} +2 -2
  79. package/dist/{region-binding-workflow-DIYJdCUr.cjs → region-binding-workflow-O2Cni3mF.cjs} +1 -1
  80. package/dist/report-encoding-worker.cjs +1 -0
  81. package/dist/report-encoding-worker.d.ts +1 -0
  82. package/dist/report-encoding-worker.js +2 -0
  83. package/dist/rich-text-layout-ALlMoYOG.cjs +3 -0
  84. package/dist/rich-text-layout-Ct5WrY1g.js +102 -0
  85. package/dist/runtime-DakRXui3.js +170 -0
  86. package/dist/runtime-dL5ygIfa.cjs +1 -0
  87. package/dist/sbom.cdx.json +2 -2
  88. package/dist/server/node.d.cts +132 -1
  89. package/dist/server/node.d.ts +132 -1
  90. package/dist/server-node.cjs +5 -1
  91. package/dist/server-node.js +5177 -463
  92. package/dist/server.cjs +1 -1
  93. package/dist/server.d.cts +182 -2
  94. package/dist/server.d.ts +182 -2
  95. package/dist/server.js +918 -833
  96. package/dist/sha256-BshdOkCC.cjs +1 -0
  97. package/dist/sha256-DTG-Gq8i.js +157 -0
  98. package/dist/style-67OqfNed.js +73 -0
  99. package/dist/style-C22Pbv3T.cjs +1 -0
  100. package/dist/style.css +1 -1
  101. package/dist/template-catalog-Dua8h9ZA.cjs +1 -0
  102. package/dist/{template-catalog-j2B1MJlL.js → template-catalog-wT1fNeAP.js} +10 -10
  103. package/dist/{template-fragments-DcKeiylI.cjs → template-fragments-BajTajb4.cjs} +1 -1
  104. package/dist/{template-fragments-BGbQLGlV.js → template-fragments-DmX5XK4N.js} +2 -2
  105. package/dist/template-registry-CpysHAxy.cjs +1 -0
  106. package/dist/{template-registry-BtaKPELV.js → template-registry-u11fPd8D.js} +389 -321
  107. package/dist/{textwrap-DE1kgcJB.js → textwrap-BEIg2w8y.js} +1 -1
  108. package/dist/textwrap-BI-yJ6Wt.cjs +4 -0
  109. package/dist/{tree-BX380Rr7.cjs → tree-CLpxYbKa.cjs} +1 -1
  110. package/dist/{tree-CjVZLRw7.js → tree-DNJorJUf.js} +1 -1
  111. package/dist/vue/async.d.cts +174 -2
  112. package/dist/vue/async.d.ts +174 -2
  113. package/dist/vue/index.d.cts +218 -3
  114. package/dist/vue/index.d.ts +218 -3
  115. package/dist/vue-async.cjs +1 -1
  116. package/dist/vue-async.js +3 -3
  117. package/dist/vue.cjs +1 -1
  118. package/dist/vue.js +7 -7
  119. package/dist/{workbook-session-BvToI-Fd.js → workbook-session-B8pNW24X.js} +153 -140
  120. package/dist/{workbook-session-Bjv1YCRK.cjs → workbook-session-DN5LSA5C.cjs} +12 -12
  121. package/dist/worker.cjs +1 -1
  122. package/dist/worker.d.cts +84 -1
  123. package/dist/worker.d.ts +84 -1
  124. package/dist/worker.js +12 -157
  125. package/dist/xlsx-node.cjs +33 -33
  126. package/dist/xlsx-node.js +1282 -1289
  127. package/dist/xlsx.cjs +4 -3
  128. package/dist/xlsx.d.cts +90 -2
  129. package/dist/xlsx.d.ts +90 -2
  130. package/dist/xlsx.js +279 -259
  131. package/package.json +6 -3
  132. package/dist/ReportPreview-ChV19HBp.js +0 -4619
  133. package/dist/ReportPreview-DbLvvOUT.cjs +0 -6
  134. package/dist/RuleEditor-C_Clasvd.js +0 -2037
  135. package/dist/RuleEditor-XhGHK8DE.cjs +0 -1
  136. package/dist/assets-B9ImAi6_.cjs +0 -1
  137. package/dist/assets-DEaz4qsp.js +0 -124
  138. package/dist/batch-BaP6pWDE.cjs +0 -1
  139. package/dist/batch-CGyt-b2W.js +0 -273
  140. package/dist/capabilities-CAh2Nrue.cjs +0 -1
  141. package/dist/capabilities-DskCHs3V.js +0 -69
  142. package/dist/computed-C-4C2S5h.js +0 -521
  143. package/dist/computed-CGV2a809.cjs +0 -1
  144. package/dist/config-D10us76d.cjs +0 -1
  145. package/dist/data-explanation-B8MZRYVS.js +0 -16
  146. package/dist/data-explanation-DE55G30w.cjs +0 -1
  147. package/dist/dataset-BkRmwgeJ.cjs +0 -1
  148. package/dist/dataset-H5pFuQGU.js +0 -121
  149. package/dist/defaults-DXhiM1ZD.js +0 -10
  150. package/dist/defaults-xhmcLLrf.cjs +0 -1
  151. package/dist/designer-2bDlcNXQ.js +0 -5136
  152. package/dist/designer-BT7XCdbW.cjs +0 -2
  153. package/dist/drill-DYTxuL3A.cjs +0 -1
  154. package/dist/grid-strokes-Cr7DwUux.cjs +0 -1
  155. package/dist/grid-strokes-DyyG1q_o.js +0 -53
  156. package/dist/json-snapshot-DFb2eWkf.js +0 -1416
  157. package/dist/json-snapshot-WWSGlaHG.cjs +0 -2
  158. package/dist/matrix-CGRGkn5s.js +0 -112
  159. package/dist/matrix-gEO7ZM_u.cjs +0 -1
  160. package/dist/prepared-CFy9B75C.cjs +0 -1
  161. package/dist/prepared-ajM-H-9B.js +0 -69
  162. package/dist/record-bindings-By_UKZ2g.cjs +0 -1
  163. package/dist/render-plan-7xpGrCEl.cjs +0 -1
  164. package/dist/render-plan-Ck6koX9L.js +0 -13
  165. package/dist/sha256-ArEYjaTI.cjs +0 -1
  166. package/dist/sha256-DPEuJ3nh.js +0 -155
  167. package/dist/style-CQ1PK8ZB.js +0 -67
  168. package/dist/style-UgIJSA1F.cjs +0 -1
  169. package/dist/template-catalog-FJE_c9Qe.cjs +0 -1
  170. package/dist/template-registry-Co1zPq5e.cjs +0 -1
  171. package/dist/textwrap-CWHyzkBH.cjs +0 -4
@@ -1 +0,0 @@
1
- "use strict";const w=require("./json-snapshot-WWSGlaHG.cjs"),j=require("./capabilities-CAh2Nrue.cjs"),L=require("./dataset-BkRmwgeJ.cjs"),h=require("./template-registry-Co1zPq5e.cjs"),E=require("./template-bindings-CEtWyiLX.cjs"),P=require("./param-validation-C3HlcLLO.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 Q=require("./matrix-gEO7ZM_u.cjs"),L=require("./computed-CGV2a809.cjs"),Z=require("./render-plan-7xpGrCEl.cjs"),ee=require("./code-options-BUTChiZZ.cjs"),C=require("./param-validation-C3HlcLLO.cjs"),_=require("./tree-BX380Rr7.cjs");function te(e,i,t){e!==void 0&&(typeof e!="string"||!e.trim()||e.length>4096)&&t.push({path:i,message:"来源范围应为不超过 4096 字符的非空字符串"})}function D(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 ie(e,i,t){D(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:"派生结果标记应为布尔值"}),V(e.source,`${i}.source`,t,!0),e.formula!==void 0&&typeof e.formula!="string"&&t.push({path:`${i}.formula`,message:"单元格公式应为字符串"})}function V(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;te(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 se=new Set(["text","image","barcode","qrcode","chart","line","rect","ellipse"]);function p(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ne(e,i,t,s){const n=e[i];(typeof n!="number"||!Number.isFinite(n))&&s.push({path:`${t}.${i}`,message:`应为有限数字,实际 ${JSON.stringify(n)}`})}function ae(e,i,t){if(e!==void 0){const s=`${i}.table`;if(!p(e))t.push({path:s,message:"逻辑表来源应为对象"});else{V(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 oe(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((f,r)=>{if(f==null)return;const d=`${i}.grid.cells.${o}.${r}`;if(!p(f)){t.push({path:d,message:"网格单元格应为对象或 null"});return}ie(f,d,t),Array.isArray(f.children)&&f.children.forEach((u,g)=>{v(u,`${i}.grid.cells.${o}.${r}.children.${g}`,t,s)})})})}}function fe(e,i,t){e!==void 0&&(Array.isArray(e)?e.forEach((s,n)=>{(!p(s)||!Array.isArray(s.segments))&&t.push({path:`${i}.richParagraphs.${n}`,message:"段落缺少 segments 数组"})}):t.push({path:`${i}.richParagraphs`,message:"richParagraphs 应为数组"}))}function v(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 字符串"}):se.has(n)||s.push({path:`${i}.kind`,message:`未知组件类型 ${JSON.stringify(n)},将以兜底方式渲染`});for(const a of["leftMm","topMm","widthMm","heightMm"])ne(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:"组件尺寸不能为负数"});ae(e.table,i,t),re(e.code,n,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"}),oe(e.grid,i,t,s),fe(e.richParagraphs,i,t)}function re(e,i,t,s){if(e!==void 0)for(const n of ee.codeOptionIssues(e,i))s.push({path:`${t}.code${n.path?`.${n.path}`:""}`,message:n.message})}function J(e,i,t){if(!p(e))return;e.binding!==void 0&&t.push({path:`${i}.binding`,message:"渲染计划不允许未解析字段绑定"});const s=e.grid;!p(s)||!Array.isArray(s.cells)||s.cells.forEach((n,a)=>{Array.isArray(n)&&n.forEach((o,f)=>{!p(o)||!Array.isArray(o.children)||o.children.forEach((r,d)=>J(r,`${i}.grid.cells.${a}.${f}.children.${d}`,t))})})}function j(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:`页宽非法: ${JSON.stringify(n)}`}),(typeof a!="number"||!(a>0&&a<5e3))&&t.push({path:`${i}.pageHeightMm`,message:`页高非法: ${JSON.stringify(a)}`}),e.layout!==void 0&&e.layout!=="page"&&e.layout!=="wide"&&t.push({path:`${i}.layout`,message:"布局应为 page 或 wide"});const o=e.components;Array.isArray(o)?Array.isArray(o)&&o.forEach((f,r)=>{v(f,`${i}.components.${r}`,t,s),J(f,`${i}.components.${r}`,t)}):t.push({path:`${i}.components`,message:"components 应为数组"})}function K(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{s.forEach((a,o)=>j(a,`$.pages.${o}`,i,t)),s.length>2e3&&t.push({path:"$.pages",message:`页数异常大(${s.length} 页),渲染与打印耗时可能显著增加`});const n=s.reduce((a,o)=>a+(p(o)&&Array.isArray(o.components)?o.components.length:0),0);n>5e4&&t.push({path:"$.pages",message:`组件总数异常大(${n} 个),可能触发浏览器性能限制`})}return{ok:i.length===0,errors:i,warnings:t}}function de(e){const i=K(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 T(e){return e.kind==="list"?e.id:e.nid}function ue(e){return e.kind==="list"?!1:e.pageAnchor!==void 0||e.kind==="text"&&typeof e.text=="string"&&/\{(?:page|totalPages)\}/.test(e.text)}function he(e,i){const t=e.filter(n=>i.componentIds.includes(T(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=>[T(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 H(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(ue(n))continue;const a=T(n);if(!a||t.has(a))throw new Error("流式排版组件应具有唯一标识");t.add(a)}if(ce(e,i,t,s),s.size!==t.size)throw new Error("流式排版必须显式包含每个非锚点组件")}function ce(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)}he(e,a),n=a.topMm+a.heightMm}}const ge=new Set(["__proto__","prototype","constructor"]);function l(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function N(e){return typeof e=="string"&&!!e.trim()&&!ge.has(e)}function k(e,i,t,s){for(const n of Object.keys(e))i.includes(n)||s.push({path:`${t}.${n}`,message:"存在未知配置字段"})}function pe(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}k(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 ye(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:"绑定仅支持独立文本、图片、条码与二维码组件"}),k(s,["field","format","prefix","suffix","emptyText"],n,t),N(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:"应为字符串"});pe(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 le(e,i){if(!l(e)){i.push({path:"$.repeat",message:"逐记录配置应为对象"});return}k(e,["dataset","rowKey","copies"],"$.repeat",i),N(e.dataset)||i.push({path:"$.repeat.dataset",message:"数据集应为安全的非空名称"}),e.rowKey!==void 0&&!N(e.rowKey)&&i.push({path:"$.repeat.rowKey",message:"业务主键应为安全的非空字段名"});const t=e.copies;t!==void 0&&(l(t)?(k(t,["field"],"$.repeat.copies",i),N(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 W(e,i,t,s){if(!l(e))return;ye(e,i,s),e.binding!==void 0&&!t&&s.push({path:`${i}.binding`,message:"字段绑定需要模板 repeat 数据集;普通报表请使用列表字段"}),t&&e.kind==="list"&&s.push({path:i,message:"逐记录标签使用固定组件;动态列表请使用普通报表模板"});const n=e.grid;l(n)&&Array.isArray(n.cells)&&n.cells.forEach((a,o)=>{Array.isArray(a)&&a.forEach((f,r)=>{l(f)&&Array.isArray(f.children)&&f.children.forEach((d,u)=>W(d,`${i}.grid.cells.${o}.${r}.children.${u}`,t,s))})})}function G(e,i){const t=e.repeat!==void 0;t&&le(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,f)=>{const r=`${a}.components.${f}`;if(W(o,r,t,i),!t||!l(o))return;const{leftMm:d,topMm:u,widthMm:g,heightMm:y}=o;[d,u,g,y,s.widthMm,s.heightMm].every(A=>typeof A=="number"&&Number.isFinite(A))&&(Number(d)<0||Number(u)<0||Number(d)+Number(g)>Number(s.widthMm)+.001||Number(u)+Number(y)>Number(s.heightMm)+.001)&&i.push({path:r,message:"标签组件超出纸张边界,请调整位置或尺寸"})})})}function U(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function R(e,i,t){if(e!==void 0){if(!U(e)){t.push({path:i,message:"条件应为对象"});return}(typeof e.field!="string"||!e.field.trim())&&t.push({path:`${i}.field`,message:"条件需要字段"}),e.numeric!==void 0&&e.numeric!=="number"&&e.numeric!=="decimal"&&t.push({path:`${i}.numeric`,message:"未知条件数值模式"}),[">",">=","<","<=","==","!="].includes(e.op)||t.push({path:`${i}.op`,message:"未知条件运算符"}),typeof e.value!="string"&&!(typeof e.value=="number"&&Number.isFinite(e.value))&&t.push({path:`${i}.value`,message:"条件值应为字符串或有限数字"})}}function q(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(!U(n)){t.push({path:o,message:"聚合应为对象"});return}const f=n.field;typeof f!="string"||!f.trim()||s.has(f)?t.push({path:`${o}.field`,message:"聚合输出字段应非空且唯一"}):s.add(f),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{L.createAggregateAccumulator({...n,field:n.valueField??f})}catch(r){t.push({path:o,message:r instanceof Error?r.message:String(r)})}})}function $e(e,i,t){if(e===void 0)return;const s=L.validateComputedFields(e);for(const n of s.errors)t.push({path:i,message:n})}function be(e,i,t){if(e!==void 0)try{Q.validateMatrixOptions(e)}catch(s){t.push({path:i,message:s instanceof Error?s.message:String(s)})}}function Ae(e,i,t){if(e.tree===void 0)return;const s=`${i}.tree`;try{_.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)&&_.validateTreeComputed(n,e.computed)}catch(n){t.push({path:s,message:n instanceof Error?n.message:String(n)})}}const O="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 we=new Set(["__proto__","prototype","constructor"]),Me=new Set(["schemaVersion","id","name","revision","description","template"]),ve=new Set(["left","center","right","justify"]),E=2e5,Ne=64,P=1e7;function h(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Ee(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 we.has(e)?(s.push({path:t,message:"模板不能包含可能污染原型的键"}),!1):i.get||i.set||!i.enumerable?(s.push({path:t,message:"模板不能包含访问器或不可枚举字段"}),!1):!0}function Se(e){return e===null||typeof e=="boolean"||typeof e=="number"&&Number.isFinite(e)}function F(e,i){const t=new Set;let s=0,n=0,a=!1;const o=(f,r,d)=>{if(!a){if(++s>E){s===E+1&&i.push({path:r,message:"模板超过 JSON 节点安全上限"});return}if(d>Ne){i.push({path:r,message:"模板嵌套层级过深"});return}if(typeof f=="string"){n+=f.length,n>P&&(a=!0,i.push({path:r,message:"模板文本超过 1000 万字符的安全上限"}));return}if(!Se(f)){if(!f||typeof f!="object"){i.push({path:r,message:"模板只允许 JSON 值,不允许函数、undefined 或非有限数字"});return}if(t.has(f)){i.push({path:r,message:"模板不能包含循环引用"});return}if(Ee(f,r,i)){t.add(f);for(const[u,g]of Object.entries(Object.getOwnPropertyDescriptors(f))){if(Array.isArray(f)&&u==="length")continue;const y=`${r}.${u}`;if(ke(u,g,y,i)&&o(g.value,y,d+1),s>E||a)break}t.delete(f)}}}};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 M(e,i,t,s=!1){e!==void 0&&!ve.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}M(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 xe(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 f=`${i}.${o}`;if(!h(a)){t.push({path:f,message:"参数定义应为对象"});return}m(a,"field",f,t,!0),typeof a.field=="string"&&(s.has(a.field)&&t.push({path:`${f}.field`,message:"参数名重复"}),s.add(a.field)),a.type!==void 0&&!["text","number","date","month","year","dateRange","select"].includes(a.type)&&t.push({path:`${f}.type`,message:"未知参数类型"});for(const r of["label","defaultValue","placeholder"])m(a,r,f,t);b(a,"required",f,t);for(const r of["minLength","maxLength"]){const d=a[r];d!==void 0&&(typeof d!="number"||!Number.isSafeInteger(d)||d<0)&&t.push({path:`${f}.${r}`,message:"长度边界应为非负整数"})}Re(a,f,t),a.options!==void 0&&(Array.isArray(a.options)?a.options.forEach((r,d)=>{const u=`${f}.options.${d}`;if(!h(r))t.push({path:u,message:"选项应为对象"});else for(const g of["label","value"])typeof r[g]!="string"&&t.push({path:`${u}.${g}`,message:"选项标签与值应为字符串(允许空白选项)"})}):t.push({path:`${f}.options`,message:"选项应为数组"}))}),t.length===n&&t.push(...C.validateReportParamDefinitions(e).map(a=>({path:a.path.replace("$.paramDefs",i),message:a.message})))}function Re(e,i,t){for(const a of["min","max"]){const o=e[a];if(o===void 0)continue;C.isReportTemporalBound(e.type,o)||e.type==="number"&&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 B(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(D(s,a,t),b(s,"hidden",a,t),R(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),M(s.align,`${a}.align`,t,!0),M(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,f)=>{const r=`${a}.rules.${f}`;if(!h(o)||!h(o.when)){t.push({path:r,message:"条件格式缺少 when 对象"});return}R(o.when,`${r}.when`,t),m(o.when,"field",`${r}.when`,t,!0),[">",">=","<","<=","==","!="].includes(o.when.op)||t.push({path:`${r}.when.op`,message:"未知条件运算符"}),typeof o.when.value!="number"&&typeof o.when.value!="string"&&t.push({path:`${r}.when.value`,message:"条件值应为数字或字符串"}),$(o.style,`${r}.style`,t)}):t.push({path:`${a}.rules`,message:"条件格式应为数组"}))})}function z(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),q(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 Te(e,i,t){if(!(e===void 0||typeof e=="boolean")){if(!h(e)){t.push({path:i,message:"合计应为布尔值或对象"});return}m(e,"label",i,t),q(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 Oe(e,i,t,s){const n={kind:"rect",leftMm:0,topMm:0,widthMm:1,heightMm:1,grid:e};if(v(n,t,s,[]),I(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>E){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:"表头行高数量应与行数一致"}),Pe(a,o,t,s)}function Pe(e,i,t,s){const n=new Set;e.forEach((a,o)=>{if(!Array.isArray(a))return;let f=0;a.forEach((r,d)=>{for(;n.has(`${o}:${f}`);)f++;const u=h(r)&&typeof r.colSpan=="number"?r.colSpan:1,g=h(r)&&typeof r.rowSpan=="number"?r.rowSpan:1;(f+u>i||o+g>e.length)&&s.push({path:`${t}.cells.${o}.${d}`,message:"表头合并区域超出表头边界"});for(let y=o;y<Math.min(e.length,o+g);y++)for(let A=f;A<Math.min(i,f+u);A++)n.has(`${y}:${A}`)&&s.push({path:`${t}.cells.${o}.${d}`,message:"表头合并区域重叠"}),n.add(`${y}:${A}`);f+=u})})}function Fe(e,i,t){if(Ae(e,i,t),$e(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 汇总,不能同时配置普通分组、总计或主从明细"}),R(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)=>z(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),B(s.columns,`${n}.columns`,t),s.unmatched!==void 0&&s.unmatched!=="error"&&s.unmatched!=="ignore"&&t.push({path:`${n}.unmatched`,message:"未关联明细策略应为 error 或 ignore"})}function Ie(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&&Oe(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"}),B(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),M(e.align,`${i}.align`,t,!0),M(e.headerAlign,`${i}.headerAlign`,t),$(e.headerStyle,`${i}.headerStyle`,t),Fe(e,i,t),z(e.groupBy,`${i}.groupBy`,t),Te(e.grandTotal,`${i}.grandTotal`,t)}function I(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:"文本行应为字符串数组"}),Array.isArray(e.richParagraphs)&&e.richParagraphs.forEach((n,a)=>{if(!h(n))return;const o=`${i}.richParagraphs.${a}`;M(n.align,`${o}.align`,t);for(const f of["lineHeight","spaceBeforeMm","spaceAfterMm","indentMm"])c(n,f,o,t);Array.isArray(n.segments)&&n.segments.forEach((f,r)=>{const d=`${o}.segments.${r}`;if(!h(f)){t.push({path:d,message:"富文本片段应为对象"});return}f.kind!==void 0&&f.kind!=="text"&&f.kind!=="field"&&t.push({path:`${d}.kind`,message:"未知富文本片段类型"});for(const u of["text","field"])m(f,u,d,t);$(f.style,`${d}.style`,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,f)=>{const r=`${i}.grid.cells.${a}.${f}`;if(o!==null){if(!h(o)){t.push({path:r,message:"网格单元格应为对象或 null"});return}for(const d of["text","rawText","numberFormat"])m(o,d,r,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:`${r}.${d}`,message:"跨度应为正整数"})}o.value!==void 0&&o.value!==null&&!["string","number","boolean"].includes(typeof o.value)&&t.push({path:`${r}.value`,message:"Excel 原始值应为字符串、数字、布尔值或 null"}),$(o.style,`${r}.style`,t),o.children!==void 0&&(Array.isArray(o.children)?o.children.forEach((d,u)=>{h(d)&&I(d,`${r}.children.${u}`,t)}):t.push({path:`${r}.children`,message:"嵌套组件应为数组"}))}})})}function _e(e,i,t){if(!(e.flow===void 0||!Array.isArray(e.components)))try{H(e.components,e.flow)}catch(s){t.push({path:`${i}.flow`,message:s instanceof Error?s.message:String(s)})}}function X(e){const i=[],t=[];return F(e,i),i.length?{ok:!1,errors:i,warnings:t}:(h(e)?(e.schemaVersion!==void 0&&e.schemaVersion!==Z.RENDER_PLAN_SCHEMA_VERSION&&i.push({path:"$.schemaVersion",message:"不支持的模板 schemaVersion"}),xe(e.params,"$.params",i),G(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,f)=>{const r=`${a}.components.${f}`;h(o)&&o.kind==="list"?Ie(o,r,i):(v(o,r,i,t),h(o)&&I(o,r,i))}):i.push({path:`${a}.components`,message:"组件应为数组"}),_e(s,a,i)})):i.push({path:"$",message:"模板应为对象"}),{ok:i.length===0,errors:i,warnings:t})}function Y(e){const i=[],t=[];if(F(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))Me.has(n)||i.push({path:`$.${n}`,message:"模板文档存在未知字段;只保存模板与描述,不保存取数或业务数据"});e.schemaVersion!==O&&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=X(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 x(e){const i=Y(e);if(!i.ok)throw new w(i.errors)}function Le(e){const i=[];if(F(e,i),i.length)throw new w(i);const t={...e,schemaVersion:e.schemaVersion??O};return x(t),S(t)}function Ce(e){let i=e;if(typeof e=="string"){if(e.length>P)throw new w([{path:"$",message:"模板 JSON 超过 1000 万字符的导出/导入上限"}]);try{i=JSON.parse(e)}catch{throw new w([{path:"$",message:"模板 JSON 语法无效"}])}}return x(i),S(i)}function De(e){x(e);const i=JSON.stringify(e,null,2);if(i.length>P)throw new w([{path:"$",message:"模板 JSON 超过 1000 万字符的导出/导入上限"}]);return i}function S(e){return JSON.parse(JSON.stringify(e))}function Ve(e=[]){const i=new Map,t={get:s=>{const n=i.get(s);return n?S(n):void 0},list:()=>Array.from(i.values(),({template:s,...n})=>({...n})),register:(s,n={})=>{if(x(s),i.has(s.id)&&!n.replace)throw new w([{path:"$.id",message:`模板 ID ${s.id} 已注册;更新需显式 replace:true`}]);i.set(s.id,S(s))},remove:s=>i.delete(s)};for(const s of e)t.register(s);return t}exports.REPORT_TEMPLATE_DOCUMENT_VERSION=O;exports.ReportTemplateError=w;exports.assertRenderPlan=de;exports.createTemplateRegistry=Ve;exports.defineReportTemplate=Le;exports.parseReportTemplate=Ce;exports.reportFlowGroups=me;exports.serializeReportTemplate=De;exports.validateComponent=v;exports.validatePage=j;exports.validateRenderPlan=K;exports.validateReportPageFlow=H;exports.validateReportTemplate=X;exports.validateReportTemplateDocument=Y;exports.validateTemplateRepeat=G;
@@ -1,4 +0,0 @@
1
- "use strict";const w=require("./defaults-xhmcLLrf.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 g=[.54,.26,.95,.59,.67,.3];function d(t){const e=t.charCodeAt(0);return e<128?g[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??w.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;