@agile-team/mach-report 2.14.0 → 2.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -16
- package/THIRD_PARTY_NOTICES.md +3 -1
- package/dist/{ExcelBindingWizard-CLT2p7P3.cjs → ExcelBindingWizard-CP6h2x1f.cjs} +1 -1
- package/dist/{ExcelBindingWizard-CvsWR8Ga.js → ExcelBindingWizard-HhB3hAJE.js} +3 -3
- package/dist/ParamEditor-CUQLgoxa.cjs +1 -0
- package/dist/ParamEditor-OKesP_nO.js +594 -0
- package/dist/{ReportBatchPanel-DkxTzBkD.cjs → ReportBatchPanel-cZCAMAwH.cjs} +1 -1
- package/dist/{ReportBatchPanel-LqVgiqp7.js → ReportBatchPanel-ruxcbfY6.js} +39 -39
- package/dist/ReportPreview-BcDKCLiK.js +4834 -0
- package/dist/ReportPreview-Bk9nLfO9.cjs +6 -0
- package/dist/{ReportTemplateLibrary-cQ1sqNYo.cjs → ReportTemplateLibrary-BDlNT8JN.cjs} +1 -1
- package/dist/{ReportTemplateLibrary-MjWEtc7X.js → ReportTemplateLibrary-DcwrH-63.js} +1 -1
- package/dist/{RuleEditor-BaR6xUiI.cjs → RuleEditor-BX5S8RSF.cjs} +1 -1
- package/dist/{RuleEditor-ChuXMlei.js → RuleEditor-CGl9XY2s.js} +5 -5
- package/dist/{TemplateOutlinePanel-BHKP89Xz.cjs → TemplateOutlinePanel-CGrT5DFN.cjs} +1 -1
- package/dist/{TemplateOutlinePanel-Dci6aRn1.js → TemplateOutlinePanel-SXCjaPKR.js} +2 -2
- package/dist/{TemplateReusePanel-CY5eO2Sh.cjs → TemplateReusePanel-6Z3wRFz8.cjs} +1 -1
- package/dist/{TemplateReusePanel-B7Gmyc1z.js → TemplateReusePanel-lHLOS9Wn.js} +2 -2
- package/dist/{TemplateReviewPanel-DjlX3xpt.js → TemplateReviewPanel-CJ9PLc48.js} +2 -2
- package/dist/{TemplateReviewPanel-JvZe9_4G.cjs → TemplateReviewPanel-Dpk7sLcF.cjs} +1 -1
- package/dist/analytics.cjs +1 -1
- package/dist/analytics.d.cts +5 -1
- package/dist/analytics.d.ts +5 -1
- package/dist/analytics.js +154 -60
- package/dist/artifact-integrity.json +143 -0
- package/dist/assets-CqIbfbTr.js +126 -0
- package/dist/assets-e4YSke8n.cjs +1 -0
- package/dist/auto-YR7a4BtF.js +240 -0
- package/dist/auto-uVBjX1j5.cjs +1 -0
- package/dist/batch-WzDIXJAt.js +220 -0
- package/dist/batch-z6Aw5GEY.cjs +1 -0
- package/dist/capabilities-DDwXr_cA.js +103 -0
- package/dist/capabilities-DNLyZdNw.cjs +1 -0
- package/dist/codes.d.cts +4 -0
- package/dist/codes.d.ts +4 -0
- package/dist/component-tree-Ca6YYfHq.js +61 -0
- package/dist/component-tree-DkGLEfZC.cjs +1 -0
- package/dist/{computed-Bvk0W15F.js → computed-C-4C2S5h.js} +3 -3
- package/dist/config-Dg_o8e7m.cjs +1 -0
- package/dist/config-XQ4qrQ7Q.js +844 -0
- package/dist/designer-BfQSahxq.js +5163 -0
- package/dist/designer-CPPdeM5_.cjs +2 -0
- package/dist/designer.cjs +1 -1
- package/dist/designer.d.cts +197 -16
- package/dist/designer.d.ts +197 -16
- package/dist/designer.js +1 -1
- package/dist/diagnostic-notification-B9K9We3h.cjs +1 -0
- package/dist/diagnostic-notification-qGAYZdkB.js +7 -0
- package/dist/drill-CsdjgkRM.cjs +1 -0
- package/dist/drill-DIGsZfyB.js +145 -0
- package/dist/encoding-BOGq4qYL.js +21 -0
- package/dist/encoding-BYF9ZTl9.cjs +1 -0
- package/dist/{font-loader-DHto6Lra.js → font-loader-CzI1GuBc.js} +1 -1
- package/dist/{font-loader-vhCT8znW.cjs → font-loader-EKLzOJxf.cjs} +1 -1
- package/dist/index.cjs +8 -9
- package/dist/index.d.cts +84 -4
- package/dist/index.d.ts +84 -4
- package/dist/index.js +829 -833
- package/dist/json-snapshot-D6ioHth9.js +1702 -0
- package/dist/json-snapshot-DknkjvxP.cjs +2 -0
- package/dist/licenses/_bwip-js_generic-4.11.4.txt +24 -0
- package/dist/licenses/_fast-csv_format-4.3.5.txt +22 -0
- package/dist/licenses/_fast-csv_parse-4.3.6.txt +22 -0
- package/dist/licenses/_pdf-lib_fontkit-1.1.1.txt +326 -0
- package/dist/licenses/_pdf-lib_standard-fonts-1.0.0.txt +22 -0
- package/dist/licenses/_pdf-lib_upng-1.0.1.txt +22 -0
- package/dist/licenses/_types_node-14.18.63.txt +22 -0
- package/dist/licenses/_types_pako-2.0.3.txt +22 -0
- package/dist/licenses/_types_pegjs-0.10.6.txt +22 -0
- package/dist/licenses/archiver-5.3.2.txt +23 -0
- package/dist/licenses/archiver-utils-2.1.0.txt +23 -0
- package/dist/licenses/archiver-utils-3.0.4.txt +23 -0
- package/dist/licenses/async-3.2.6.txt +20 -0
- package/dist/licenses/balanced-match-1.0.2.txt +22 -0
- package/dist/licenses/base64-js-1.5.1.txt +22 -0
- package/dist/licenses/big-integer-1.6.52.txt +25 -0
- package/dist/licenses/binary-0.3.0.txt +178 -0
- package/dist/licenses/bl-4.1.0.txt +14 -0
- package/dist/licenses/bluebird-3.4.7.txt +22 -0
- package/dist/licenses/brace-expansion-1.1.21.txt +22 -0
- package/dist/licenses/brace-expansion-2.1.7.txt +22 -0
- package/dist/licenses/buffer-5.7.1.txt +22 -0
- package/dist/licenses/buffer-crc32-0.2.13.txt +20 -0
- package/dist/licenses/buffer-indexof-polyfill-1.0.2.txt +23 -0
- package/dist/licenses/buffers-0.1.1.txt +140 -0
- package/dist/licenses/chainsaw-0.1.0.txt +184 -0
- package/dist/licenses/compress-commons-4.1.2.txt +23 -0
- package/dist/licenses/concat-map-0.0.1.txt +19 -0
- package/dist/licenses/core-util-is-1.0.3.txt +20 -0
- package/dist/licenses/crc-32-1.2.2.txt +202 -0
- package/dist/licenses/crc32-stream-4.0.3.txt +23 -0
- package/dist/licenses/dayjs-1.11.23.txt +22 -0
- package/dist/licenses/duplexer2-0.1.4.txt +27 -0
- package/dist/licenses/end-of-stream-1.4.5.txt +22 -0
- package/dist/licenses/exceljs-4.4.0.txt +23 -0
- package/dist/licenses/fast-csv-4.3.6.txt +22 -0
- package/dist/licenses/fast-png-6.4.0.txt +22 -0
- package/dist/licenses/fs-constants-1.0.0.txt +22 -0
- package/dist/licenses/fs.realpath-1.0.0.txt +44 -0
- package/dist/licenses/fstream-1.0.12.txt +16 -0
- package/dist/licenses/glob-7.2.3.txt +22 -0
- package/dist/licenses/graceful-fs-4.2.11.txt +16 -0
- package/dist/licenses/ieee754-1.2.1.txt +12 -0
- package/dist/licenses/immediate-3.0.6.txt +21 -0
- package/dist/licenses/inflight-1.0.6.txt +16 -0
- package/dist/licenses/inherits-2.0.4.txt +17 -0
- package/dist/licenses/iobuffer-5.4.0.txt +23 -0
- package/dist/licenses/isarray-1.0.0.txt +61 -0
- package/dist/licenses/jszip-3.10.2.txt +652 -0
- package/dist/licenses/lazystream-1.0.1.txt +24 -0
- package/dist/licenses/lie-3.3.0.txt +8 -0
- package/dist/licenses/listenercount-1.0.1.txt +6 -0
- package/dist/licenses/lodash.defaults-4.2.0.txt +48 -0
- package/dist/licenses/lodash.difference-4.5.0.txt +48 -0
- package/dist/licenses/lodash.escaperegexp-4.1.2.txt +48 -0
- package/dist/licenses/lodash.flatten-4.4.0.txt +48 -0
- package/dist/licenses/lodash.groupby-4.6.0.txt +48 -0
- package/dist/licenses/lodash.isboolean-3.0.3.txt +23 -0
- package/dist/licenses/lodash.isequal-4.5.0.txt +48 -0
- package/dist/licenses/lodash.isfunction-3.0.9.txt +48 -0
- package/dist/licenses/lodash.isnil-4.0.0.txt +23 -0
- package/dist/licenses/lodash.isplainobject-4.0.6.txt +48 -0
- package/dist/licenses/lodash.isundefined-3.0.1.txt +23 -0
- package/dist/licenses/lodash.union-4.6.0.txt +48 -0
- package/dist/licenses/lodash.uniq-4.5.0.txt +48 -0
- package/dist/licenses/minimatch-3.1.5.txt +16 -0
- package/dist/licenses/minimatch-5.1.9.txt +16 -0
- package/dist/licenses/minimist-1.2.8.txt +19 -0
- package/dist/licenses/mkdirp-0.5.6.txt +22 -0
- package/dist/licenses/node-sql-parser-5.4.0.txt +202 -0
- package/dist/licenses/normalize-path-3.0.0.txt +22 -0
- package/dist/licenses/once-1.4.0.txt +16 -0
- package/dist/licenses/pako-1.0.11.txt +22 -0
- package/dist/licenses/pako-2.2.0.txt +22 -0
- package/dist/licenses/path-is-absolute-1.0.1.txt +22 -0
- package/dist/licenses/pdf-lib-1.17.1.txt +22 -0
- package/dist/licenses/process-nextick-args-2.0.1.txt +20 -0
- package/dist/licenses/readable-stream-2.3.8.txt +48 -0
- package/dist/licenses/readable-stream-3.6.2.txt +48 -0
- package/dist/licenses/readdir-glob-1.1.3.txt +202 -0
- package/dist/licenses/rimraf-2.7.1.txt +16 -0
- package/dist/licenses/safe-buffer-5.1.2.txt +22 -0
- package/dist/licenses/safe-buffer-5.2.1.txt +22 -0
- package/dist/licenses/saxes-5.0.1.txt +397 -0
- package/dist/licenses/setimmediate-1.0.5.txt +21 -0
- package/dist/licenses/string_decoder-1.1.1.txt +49 -0
- package/dist/licenses/string_decoder-1.3.0.txt +49 -0
- package/dist/licenses/tar-stream-2.2.0.txt +22 -0
- package/dist/licenses/tmp-0.2.7.txt +22 -0
- package/dist/licenses/traverse-0.3.9.txt +25 -0
- package/dist/licenses/tslib-1.14.1.txt +13 -0
- package/dist/licenses/unzipper-0.10.14.txt +26 -0
- package/dist/licenses/util-deprecate-1.0.2.txt +25 -0
- package/dist/licenses/uuid-11.1.1.txt +10 -0
- package/dist/licenses/wrappy-1.0.2.txt +16 -0
- package/dist/licenses/xmlchars-2.2.0.txt +19 -0
- package/dist/licenses/zip-stream-4.1.1.txt +23 -0
- package/dist/matrix-CGRGkn5s.js +112 -0
- package/dist/matrix-gEO7ZM_u.cjs +1 -0
- package/dist/media-B7vnpD8k.cjs +1 -0
- package/dist/media-Y90dHK9z.js +70 -0
- package/dist/param-validation-C3HlcLLO.cjs +1 -0
- package/dist/param-validation-Do7Eg8Zv.js +181 -0
- package/dist/{pdf-AyJGb22z.cjs → pdf-ByVCb1i6.cjs} +49 -49
- package/dist/{pdf-8UPQebOE.js → pdf-DJ5S6ukC.js} +4924 -4872
- package/dist/pdf.cjs +1 -1
- package/dist/pdf.d.cts +20 -3
- package/dist/pdf.d.ts +20 -3
- package/dist/pdf.js +2 -2
- package/dist/{plugin-BGKf-Tqg.js → plugin-C2j5_mhx.js} +2 -2
- package/dist/{plugin-CktLH_Iy.cjs → plugin-Dr39GBRG.cjs} +1 -1
- package/dist/prepared-DdrjLC7L.cjs +1 -0
- package/dist/prepared-DqtpvRTn.js +87 -0
- package/dist/progress-B0ctFpKf.cjs +1 -0
- package/dist/progress-BXzlVbIp.js +29 -0
- package/dist/progress-DJBd9Rb9.cjs +1 -0
- package/dist/progress-Hc2vxoCs.js +52 -0
- package/dist/protocol-BzwMP4Vw.cjs +1 -0
- package/dist/protocol-kt4Iy6-3.js +90 -0
- package/dist/record-bindings-CZWBJ1fU.js +195 -0
- package/dist/record-bindings-DUX1VMlR.cjs +1 -0
- package/dist/{region-binding-workflow-DEJbhpCv.js → region-binding-workflow-CWNvIjkV.js} +1 -1
- package/dist/{region-binding-workflow-BzfbxRiR.cjs → region-binding-workflow-CqSMxQ4p.cjs} +1 -1
- package/dist/report-encoding-worker.cjs +1 -0
- package/dist/report-encoding-worker.d.ts +1 -0
- package/dist/report-encoding-worker.js +2 -0
- package/dist/{report-params-B44imUd4.js → report-params-B1RzkhJj.js} +1 -1
- package/dist/{report-params-SJfhKgaX.cjs → report-params-WDGrA4oP.cjs} +1 -1
- package/dist/rich-text-layout-ALlMoYOG.cjs +3 -0
- package/dist/rich-text-layout-Ct5WrY1g.js +102 -0
- package/dist/runtime-BjKBI530.js +168 -0
- package/dist/runtime-CBFEPKEs.cjs +1 -0
- package/dist/sbom.cdx.json +3982 -0
- package/dist/server/node.d.cts +106 -2
- package/dist/server/node.d.ts +106 -2
- package/dist/server-node.cjs +5 -1
- package/dist/server-node.js +4634 -539
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +780 -5
- package/dist/server.d.ts +780 -5
- package/dist/server.js +773 -691
- package/dist/sha256-BshdOkCC.cjs +1 -0
- package/dist/sha256-DTG-Gq8i.js +157 -0
- package/dist/style-67OqfNed.js +73 -0
- package/dist/style-C22Pbv3T.cjs +1 -0
- package/dist/style.css +1 -1
- package/dist/template-bindings-C2SpvsMU.js +58 -0
- package/dist/template-bindings-CEtWyiLX.cjs +1 -0
- package/dist/template-catalog-BtR2JmCL.js +414 -0
- package/dist/template-catalog-C2NLdrwB.cjs +1 -0
- package/dist/{template-fragments-DFUpq5QM.cjs → template-fragments-BVsbxs4a.cjs} +1 -1
- package/dist/{template-fragments-CLkGo6To.js → template-fragments-By0aZC1D.js} +21 -21
- package/dist/{template-outline-B3xVkzSv.cjs → template-outline-BwRV_eRo.cjs} +1 -1
- package/dist/{template-outline-CFenM1PV.js → template-outline-cnWfT_LK.js} +3 -3
- package/dist/template-registry-C62vpv4a.cjs +1 -0
- package/dist/template-registry-Cw3vRTX2.js +801 -0
- package/dist/textwrap-BEIg2w8y.js +110 -0
- package/dist/textwrap-BI-yJ6Wt.cjs +4 -0
- package/dist/{tree-CqcQ99NM.js → tree-CjVZLRw7.js} +1 -1
- package/dist/vue/async.d.cts +189 -14
- package/dist/vue/async.d.ts +189 -14
- package/dist/vue/index.d.cts +246 -22
- package/dist/vue/index.d.ts +246 -22
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +3 -3
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +80 -78
- package/dist/{workbook-session-BfK1yHOO.js → workbook-session-BeSO8PFB.js} +5460 -5295
- package/dist/{workbook-session-DNa2RHNG.cjs → workbook-session-Cbts-22R.cjs} +19 -19
- package/dist/worker.cjs +1 -1
- package/dist/worker.d.cts +104 -2
- package/dist/worker.d.ts +104 -2
- package/dist/worker.js +12 -156
- package/dist/xlsx-node.cjs +35 -35
- package/dist/xlsx-node.js +2138 -2137
- package/dist/xlsx.cjs +4 -4
- package/dist/xlsx.d.cts +24 -10
- package/dist/xlsx.d.ts +24 -10
- package/dist/xlsx.js +303 -277
- package/package.json +7 -4
- package/dist/ParamEditor-CflQV3eQ.js +0 -526
- package/dist/ParamEditor-vIDzvpPV.cjs +0 -1
- package/dist/ReportPreview-CvbqLUzM.cjs +0 -6
- package/dist/ReportPreview-D_ywJ_-H.js +0 -4533
- package/dist/assets-C2U-e-Sz.cjs +0 -4
- package/dist/assets-Q0wUwNrV.js +0 -217
- package/dist/batch-DzaTNLWI.js +0 -371
- package/dist/batch-xMkqYiTr.cjs +0 -1
- package/dist/capabilities-CK_7hizc.js +0 -63
- package/dist/capabilities-CsZ-pNHR.cjs +0 -1
- package/dist/config-0UIohTS7.cjs +0 -1
- package/dist/config-Dt9NtCPl.js +0 -566
- package/dist/data-explanation-BktvER5B.cjs +0 -1
- package/dist/data-explanation-C_J6jYNi.js +0 -16
- package/dist/defaults-DXhiM1ZD.js +0 -10
- package/dist/defaults-xhmcLLrf.cjs +0 -1
- package/dist/designer-Ci1LizA9.js +0 -5020
- package/dist/designer-rtmVIIdN.cjs +0 -2
- package/dist/grid-strokes-Cr7DwUux.cjs +0 -1
- package/dist/grid-strokes-DyyG1q_o.js +0 -53
- package/dist/json-snapshot-BeFT3Tso.js +0 -1952
- package/dist/json-snapshot-D1NTP2oI.cjs +0 -2
- package/dist/matrix-DVyWiYsd.cjs +0 -1
- package/dist/matrix-yZsGnldA.js +0 -227
- package/dist/page-window-index-CIuT4BAv.js +0 -43
- package/dist/page-window-index-DEjnM6IB.cjs +0 -1
- package/dist/param-validation-BlHHXs6u.js +0 -153
- package/dist/param-validation-DCK039V1.cjs +0 -1
- package/dist/progress-7OSZbFok.js +0 -39
- package/dist/progress-BnLiS5eH.cjs +0 -1
- package/dist/render-plan-7xpGrCEl.cjs +0 -1
- package/dist/render-plan-Ck6koX9L.js +0 -13
- package/dist/style-CQ1PK8ZB.js +0 -67
- package/dist/style-UgIJSA1F.cjs +0 -1
- package/dist/task-events-DQ276fn2.cjs +0 -1
- package/dist/task-events-Dpsvf_t2.js +0 -47
- package/dist/template-bindings-BJR4k7qZ.cjs +0 -1
- package/dist/template-bindings-Daui7hLF.js +0 -252
- package/dist/template-registry-COXDEJEM.js +0 -570
- package/dist/template-registry-D3SjENi6.cjs +0 -1
- package/dist/validate-BJ5HIWY8.cjs +0 -1
- package/dist/validate-CkQBWCeg.js +0 -163
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const Y=require("./component-tree-DkGLEfZC.cjs"),C=require("./style-C22Pbv3T.cjs"),D=require("./textwrap-BI-yJ6Wt.cjs"),R=require("./record-bindings-DUX1VMlR.cjs"),ge=require("./computed-CGV2a809.cjs"),Ne=require("./matrix-gEO7ZM_u.cjs"),Q=require("./tree-BX380Rr7.cjs"),L=require("./template-registry-C62vpv4a.cjs"),Tt=require("./report-params-WDGrA4oP.cjs"),$e=require("./param-validation-C3HlcLLO.cjs"),he=require("./grid-geometry-CZ_cYB6O.cjs"),Ke=require("./number-format-CZ2T_5kF.cjs"),Le=require("./dataset-BkRmwgeJ.cjs");function Et(e,t,r){const o=new Set,n=e.cells.map((a,s)=>{const i=[];let c=0;for(const d of a){for(;o.has(`${s}:${c}`);)c++;const l=d?.colSpan??1,f=d?.rowSpan??1;let u=0;for(let m=c;m<c+l;m++){t.has(m)&&u++;for(let h=s+1;h<s+f;h++)o.add(`${h}:${m}`)}u&&i.push(d?{...d,colSpan:u}:null),c+=l}return i});return{...e,cells:n,colWidthsMm:r}}function je(e){if(!e.columns.some(o=>o.hidden))return e;const t=new Set,r=e.columns.filter((o,n)=>o.hidden?!1:(t.add(n),!0));if(!r.length)throw new Error("列表至少需要一列可见列");return{...e,columns:r,...e.headerGrid?{headerGrid:Et(e.headerGrid,t,r.map(o=>o.widthMm))}:{}}}function*Pt(e){const{page:t}=e;L.validateReportPageFlow(t.components,t.flow);let r=0,o=0;for(const n of L.reportFlowGroups(t.components,t.flow)){e.active();const a=n.band,s=n.components.some(l=>l.kind==="list"&&l.cardinality!=="record"),i=s?0:n.components.reduce((l,f)=>Math.max(l,f.topMm-a.topMm+(f.kind==="list"?e.height(f):f.heightMm)),a.heightMm);let c=Math.max(e.top(),o+a.topMm-r);if(!s&&i>e.bottom()-e.top()+.001)throw new Error(`静态区域 ${a.componentIds.join(",")} 高度超出单页可用范围`);!s&&c+i>e.bottom()+.001&&(e.nextPage(),yield*e.takePages(),e.active(),c=e.top());let d=c+i;for(const l of n.components){const f=c+l.topMm-a.topMm;l.kind==="list"?(yield*e.list(l,f,u=>{d=s?u:Math.max(d,u)}),e.active()):e.append({...l,topMm:f})}o=d,r=a.topMm+a.heightMm}}function Ct(e){return!!(e.computed?.length||e.groups?.length||e.groupBy||e.grandTotal||e.rowVisibleWhen||e.matrix||e.tree||e.detail||e.columns.some(t=>t.rules?.length||t.visibleWhen))}function Z(e){return e.pages.some(t=>t.components.some(r=>r.kind==="list"&&Ct(r)))}const kt=512,Ie=256*1024;function $t(){const e=new Map;let t=0,r;return(o,n,a,s)=>{s!==r&&(e.clear(),t=0,r=s);const i=JSON.stringify([o,n,a.fontSizePt,a.fontFamily,a.bold,a.italic,a.letterSpacingPt]),c=e.get(i);if(c)return e.delete(i),e.set(i,c),c.lines.slice();const d=D.wrapText(o,n,a,s),l=i.length+d.reduce((f,u)=>f+u.length,0);if(l<=Ie){for(;e.size>=kt||t+l>Ie;){const f=e.keys().next().value;t-=e.get(f).units,e.delete(f)}e.set(i,{lines:d.slice(),units:l}),t+=l}return d}}class K extends Error{constructor(t,r){super(`报表页数超出上限 ${t}(至少 ${r} 页)`),this.limit=t,this.actual=r,this.code="page-limit",this.name="PaginatePageLimitError"}}class B extends Error{constructor(t,r){super(`报表单元格数量超出上限 ${t}(至少 ${r} 格)`),this.limit=t,this.actual=r,this.code="cell-limit",this.name="PaginateCellLimitError"}}const Be=1e4,Oe=25e4;function pe(e){if(e?.aborted)throw e.reason??new DOMException("标签生成已取消","AbortError")}function De(e,t,r){const o=typeof e.copies=="object"?R.readRecordScalar(t,e.copies.field,r):e.copies??1;if(typeof o!="number"||!Number.isSafeInteger(o)||o<1||o>1e3)throw new R.ReportBindingError(`$.datasets.${r.dataset}[${r.rowIndex}]`,"每条记录复制数必须是 1..1000 的数值型整数",r.rowIndex,typeof e.copies=="object"?e.copies.field:void 0);return o}function He(e,t,r){if(e.rowKey===void 0)return;const o=R.readRecordScalar(t,e.rowKey,r);if(typeof o=="string"&&o.trim()||typeof o=="number"&&Number.isFinite(o))return o;throw new R.ReportBindingError(`$.datasets.${r.dataset}[${r.rowIndex}].${e.rowKey}`,"业务主键必须是非空字符串或有限数字",r.rowIndex,e.rowKey)}function It(e){const t=r=>1+(r.grid?.cells.reduce((o,n)=>o+1+n.length+n.reduce((a,s)=>a+(s?.children?.reduce((i,c)=>i+t(c),0)??0),0),0)??0);return e.pages.reduce((r,o)=>r+o.components.reduce((n,a)=>n+t(a),0),0)}function Ot(e,t,r){const o=e.repeat,n=Object.prototype.hasOwnProperty.call(t,o.dataset)?t[o.dataset]:void 0;if(!Array.isArray(n))throw new R.ReportBindingError(`$.datasets.${o.dataset}`,"逐记录标签数据集缺失,应提供对象数组(允许空数组)");const a=new Set,s=r.maxPages??Be,i=It(e);let c=0,d=0;for(const[l,f]of n.entries()){if(pe(r.signal),!f||typeof f!="object"||Array.isArray(f))throw new R.ReportBindingError(`$.datasets.${o.dataset}[${l}]`,"标签记录应为对象",l);const u={rowIndex:l,dataset:o.dataset},m=He(o,f,u);if(m!==void 0){const g=JSON.stringify([typeof m,m]);if(a.has(g))throw new R.ReportBindingError(`$.datasets.${o.dataset}[${l}].${o.rowKey}`,"业务主键重复;请先确认记录来源,避免重复打印标签",l,o.rowKey);a.add(g)}const h=De(o,f,u);if(c+=h*e.pages.length,d+=h*i,c>s)throw new K(s,c);if(d>Oe)throw new R.ReportBindingError("$.repeat",`标签组件总量(含网格行、槽位及嵌套组件)超过安全预算 ${Oe},请分批生成`,l)}return n}function Ft(e,t,r){if(!e.binding)return e;const{binding:o,...n}=e,a=R.resolveComponentBinding(o,t.row,t);if(e.kind==="image"){if(!a)return;if(!R.isLabelImageData(a))throw new R.ReportBindingError(`${r}.binding`,"图片字段只接受 PNG/JPEG base64 data URL;业务 URL 应由宿主安全加载后转换",t.rowIndex,o.field);return{...n,imageData:a}}return e.kind==="barcode"||e.kind==="qrcode"?(delete n.imageData,{...n,code:{...n.code,value:a},fallbackText:a}):(delete n.lines,delete n.richParagraphs,{...n,text:a})}function At(e,t,r){if(e.kind!=="text"||e.grid||e.richParagraphs?.length)return e;const o=e.style??{},n=C.resolveFontSize(o).fontSizePt,a=e.text??e.lines?.join(`
|
|
2
|
+
`)??"";if(a.length>16384)throw new R.ReportBindingError(r,"标签文本超过 16384 字符预算,请缩小字段内容",t.rowIndex);const s=t.wrapText(a,e.widthMm,{fontSizePt:n,bold:o.bold,italic:o.italic,fontFamily:o.fontFamily,letterSpacingPt:o.letterSpacing},t.options.measurer??D.heuristicMeasurer),i=s.length*n*C.resolveLineHeight(o)*25.4/72;if(i>e.heightMm+.05)throw new R.ReportBindingError(r,`标签文字需要约 ${i.toFixed(2)}mm 高,超出 ${e.heightMm}mm;请增大文本区域、减少内容或调整字号`,t.rowIndex,e.binding?.field);return{...e,lines:s}}function Ge(e,t,r){pe(t.options.signal);const o=Ft(e,t,r);if(!o)return;let n=o.grid;return n&&(n={...n,cells:n.cells.map((a,s)=>a.map((i,c)=>i?.children?.length?{...i,children:i.children.flatMap((d,l)=>{const f=Ge(d,t,`${r}.grid.cells.${s}.${c}.children.${l}`);return f?[f]:[]})}:i))}),At(n===o.grid?o:{...o,grid:n},t,r)}function Nt(e,t,r,o,n,a){return{...e,components:e.components.flatMap((s,i)=>{const c=Ge(s,r,`$.pages.${t}.components.${i}`);return c?[{...c,meta:{...c.meta,labelSource:{pageIndex:t,componentIndex:i}}}]:[]}),meta:{...e.meta,record:{dataset:r.dataset,rowIndex:r.rowIndex,...a===void 0?{}:{rowKey:a},copyIndex:o,copyCount:n,templatePageIndex:t}}}}function*Kt(e,t,r){const o=[];if(L.validateTemplateRepeat(e,o),o.length)throw new R.ReportBindingError(o[0].path,o[0].message);if(!e.repeat){for(const[i,c]of e.pages.entries())yield{page:c,pageIndex:i};return}const n=e.repeat,a=Ot(e,t,r),s=$t();for(const[i,c]of a.entries()){const d={row:c,rowIndex:i,dataset:n.dataset,options:r,wrapText:s},l=De(n,c,d),f=He(n,c,d);for(let u=0;u<l;u++)for(const[m,h]of e.pages.entries())pe(r.signal),yield{page:Nt(h,m,d,u,l,f),pageIndex:m}}}function Lt(e){return{widthMm:e.widthMm,heightMm:e.heightMm,marginTopMm:e.marginTopMm??0,marginBottomMm:e.marginBottomMm??0,marginLeftMm:e.marginLeftMm??0,marginRightMm:e.marginRightMm??0,components:[]}}function U(e,t){const r=t.heightMm-(e.layout==="wide"?t.marginBottomMm:e.marginBottomMm??t.marginBottomMm);return e.components.reduce((o,n)=>n.kind!=="list"&&n.pageAnchor==="footer"?Math.min(o,n.topMm):o,r)}function _(e){return e.components.reduce((t,r)=>r.kind!=="list"&&r.pageAnchor==="header"?Math.max(t,r.topMm+r.heightMm):t,0)}function Ve(e,t){let r=e.textMetrics.get(t);if(!r){const o=C.resolveFontSize(t).fontSizePt;r={measureOptions:{fontSizePt:o,fontFamily:t.fontFamily??C.DEFAULT_FONT_FAMILY,italic:t.italic,bold:t.bold,letterSpacingPt:t.letterSpacing},lineMm:o*(t.lineHeight??C.LINE_HEIGHT)*25.4/72},e.textMetrics.set(t,r)}return r}function jt(e){if(e===null||typeof e=="string"||typeof e=="boolean"||typeof e=="number"&&Number.isFinite(e))return e}function we(e,t){const r=e.fontSizePt??C.DEFAULT_FONT_PT,o=e.paddingMm??1,n=e.columns.map(g=>g.align??g.style?.align??e.align??"left"),a=e.columns.map((g,w)=>({...C.mergeComponentStyles({fontSize:r,verticalAlign:"middle"},g.style),align:n[w]==="auto"?"left":n[w]})),s=a.map((g,w)=>n[w]==="auto"?{left:g,center:{...g,align:"center"},right:{...g,align:"right"}}:void 0),i=e.columns.map((g,w)=>g.rules?.map(y=>{const v=s[w];if(v)return{left:C.mergeComponentStyles(v.left,y.style),center:C.mergeComponentStyles(v.center,y.style),right:C.mergeComponentStyles(v.right,y.style)};const T=C.mergeComponentStyles(a[w],y.style);return{left:T,center:T,right:T}})),c=e.columns.map(g=>R.resolveListHeaderStyle(e,g)),d=e.columns.map(g=>g.header);let l=e.rowHeightMm??0;for(let g=0;g<d.length;g++){const w=c[g],y=C.resolveFontSize(w).fontSizePt,v=D.wrapText(d[g],e.columns[g].widthMm-o*2,{fontSizePt:y,fontFamily:w.fontFamily??C.DEFAULT_FONT_FAMILY,italic:w.italic,bold:w.bold,letterSpacingPt:w.letterSpacing},t),T=y*(w.lineHeight??C.LINE_HEIGHT)*25.4/72;l=Math.max(l,Math.max(v.length,1)*T+o*2)}const f=d.map((g,w)=>({text:g,style:c[w]})),u=e.border===!1?{borderTop:!1,borderRight:!1,borderBottom:!1,borderLeft:!1}:{borderBottom:!0,borderLeft:!0,borderRight:!0,borderTop:!0},m=e.columns.map(g=>g.widthMm),h=Bt(e.headerGrid,m,{cells:[f],colWidthsMm:m,rowHeightsMm:[l],paddingMm:o});return{fontSizePt:r,paddingMm:o,cellStyles:a,autoStyles:s,ruleStyles:i,textMetrics:new WeakMap,numberFormats:e.columns.map(g=>R.toExcelNumberFormat(g.format)),derivedFields:new Set(e.computed?.map(g=>g.field)),borderStyle:u,headerHeightMm:h.rowHeightsMm.reduce((g,w)=>g+w,0),headerGrid:h,colWidthsMm:m,columns:e.columns}}function Bt(e,t,r){if(!e)return r;if(!e.cells.length)throw new Error("自定义列表表头至少需要一行");const o=e.rowHeightsMm??e.cells.map(()=>r.rowHeightsMm[0]);if(o.length!==e.cells.length||o.some(n=>!Number.isFinite(n)||n<=0))throw new Error("自定义列表表头行高无效");return{...e,colWidthsMm:t,rowHeightsMm:o}}function Dt(e,t,r){const o=t.format?.kind==="number"||t.format?.kind==="percent";t.valueType!==void 0?e.valueType=t.valueType:o&&(e.valueType="number"),t.editable!==void 0&&(e.editable=t.editable),(typeof e.value=="number"||e.value==null)&&r!==void 0&&(e.numberFormat=r)}function W(e,t,r){const o=e.columns,n=e.tree?.rows.get(t);let a=e.rowHeightFloorMm;const s=new Array(o.length);for(let i=0;i<o.length;i++){const c=o[i],d=c.visibleWhen&&!R.evalStyleRule(t,c.visibleWhen)?null:t[c.field],l=e.autoStyles[i]?R.resolveListAutoAlignment(d,c.format,c.semanticRole):"left";let f=e.autoStyles[i]?.[l]??e.cellStyles[i];if(c.rules)for(let v=0;v<c.rules.length;v++){const T=c.rules[v];if(R.evalStyleRule(t,T.when)){f=e.ruleStyles[i][v][l];break}}const u=c.format?R.formatValue(d,c.format):R.listCellText(d),m=Ht(e,c,n);f=Gt(e,c,f,n);const h=Ve(e,f),g=D.wrapText(u,Math.max(1,c.widthMm-e.paddingMm*2-m),h.measureOptions,r);a=Math.max(a,g.length*h.lineMm+e.paddingMm*2);const w=jt(d),y={text:u,style:f};w!==void 0&&(y.value=w),Dt(y,c,e.numberFormats[i]),Vt(y,c,e,n,m),e.derivedFields.has(c.field)&&(y.derived=!0,y.editable=!1),c.visibleWhen&&d===null&&!R.evalStyleRule(t,c.visibleWhen)&&(y.editable=!1),s[i]=y}return{grid:{cells:[s],colWidthsMm:e.colWidthsMm,rowHeightsMm:[a],paddingMm:e.paddingMm},heightMm:a}}function Ht(e,t,r){return!r||t.field!==e.tree.list.tree.labelField?0:R.listTreeIndent(e.tree.list,t,r,e.paddingMm)}function Gt(e,t,r,o){return!o||t.field!==e.tree.list.tree.labelField||r.align==="left"?r:{...r,align:"left"}}function Vt(e,t,r,o,n=0){o&&(n&&(e.indentMm=n),R.applyListTreeMetadata(e,t,o,r.tree.list))}function _e(e){if(e!=null&&typeof e!="string"&&typeof e!="boolean"&&!(typeof e=="number"&&Number.isFinite(e)))throw new Error("分组字段应为有限 JSON 标量");return JSON.stringify([typeof e,e??null])}function*We(e,t,r=0){const o=t[r];if(!o){for(const a of e)yield{kind:"row",row:a};return}const n=new Map;for(const a of e){const s=_e(a[o.field]),i=n.get(s);i?i.push(a):n.set(s,[a])}for(const a of n.values())yield{kind:"groupHeader",label:(o.headerTemplate??"{value}").replace(/\{value\}/g,R.listCellText(a[0][o.field])),firstRow:a[0],group:o,depth:r,rows:a},yield*We(a,t,r+1),(o.subtotal?.length||o.aggregates?.length)&&(yield{kind:"subtotal",label:o.subtotalLabel??"小计",rows:a,group:o,depth:r}),yield{kind:"groupEnd",depth:r}}function Je(e,t,r,o=[]){const n=[...r.filter(a=>!o.some(s=>s.field===a)).map(a=>({field:a,op:"sum"})),...o];return new Map(n.map(a=>{const s=e.find(c=>c.field===a.field)?.format??{kind:"number",thousands:!0},i=ge.aggregateRows(t,{...a,field:a.valueField??a.field});return[a.field,{text:R.formatValue(i,s),...i===null?{}:{value:i},...typeof i=="number"?{numberFormat:R.toExcelNumberFormat(s)}:{}}]}))}function qe(e,t){const r=e.findIndex(o=>t.includes(o.field));return r<0?1:r}function V(e,t,r,o,n,a){const s=[],i=Math.max(0,Math.min(a,e.columns.length)),c=C.mergeComponentStyles({fontSize:e.fontSizePt},n);i&&s.push({text:r,colSpan:i,style:{bold:!0,...c}});for(let u=i;u<e.columns.length;u++){const m=e.columns[u],h=o.get(m.field),g=e.autoStyles[u]?.[R.resolveListAutoAlignment(h?.value,m.format)]??e.cellStyles[u];s.push({...h,text:h?.text??"",style:C.mergeComponentStyles(g,n)})}const d={text:r,colSpan:e.columns.length,style:{bold:!0,...c}},l=i?[s]:[[d],s],f=l.map(u=>_t(e,u,t));return{grid:{cells:l,colWidthsMm:e.colWidthsMm,rowHeightsMm:f,paddingMm:e.paddingMm},heightMm:f.reduce((u,m)=>u+m,0)}}function _t(e,t,r){let o=e.rowHeightFloorMm,n=0;for(const a of t){let s=0;const i=n+(a.colSpan??1);for(;n<i;n++)s+=e.colWidthsMm[n]??0;const c=Ve(e,a.style),d=D.wrapText(a.text??"",s-e.paddingMm*2,c.measureOptions,r);o=Math.max(o,d.length*c.lineMm+e.paddingMm*2)}return o}function Wt(e,t,r){const{templatePage:o,current:n,warnings:a,nextId:s,pushCurrent:i}=r,c=()=>U(o,n),d=Math.max(n.marginTopMm,_(o)),l=o.layout==="wide"?_(o):d,f={id:r.tableId,columnKeys:e.columns.map(p=>p.field),...e.layout===void 0?{}:{layout:e.layout},...e.title===void 0?{}:{title:e.title}},u=new Map,m=new Map,h={kind:"rect",leftMm:e.leftMm,topMm:0,widthMm:e.widthMm,heightMm:t.headerHeightMm,grid:t.headerGrid,nid:s("listh"),table:{...f,role:"header",rowIndex:-1},style:t.borderStyle,...e.meta?{meta:e.meta}:{}},g=p=>n.components.push({...h,topMm:p});if(r.flow&&e.header!==!1&&t.headerHeightMm>c()-d+.001)throw new Error(`流式列表 ${e.id??e.dataset} 的表头高度超出单页可用范围`);let w=Math.max(r.startTop??e.topMm,d);e.header!==!1&&(g(w),w+=t.headerHeightMm+r.mmPerRow);function y(){const p=Math.max(r.flow||o.layout==="wide"?0:e.topMm,l);return(e.header!==!1&&e.headerEveryPage!==!1?p+t.headerHeightMm:l)+[...m.values()].reduce((x,P)=>x+P.heightMm,0)}function v(){const p=o.layout==="wide"?0:n.marginBottomMm;return Math.min(o.heightMm-p,U(o,n))-y()}function T(p){if(w+p<=c())return;i(),n.components=[],n.heightMm=o.heightMm,o.layout==="wide"&&(n.marginTopMm=0,n.marginBottomMm=0);const M=Math.max(r.flow||o.layout==="wide"?0:e.topMm,l);e.header!==!1&&e.headerEveryPage!==!1?(g(M),w=M+t.headerHeightMm):w=l;for(const x of m.values())N(x,"listgr","group-header")}function S(p,M,x,P){const k=v();if(r.flow&&p.heightMm>k+.001)throw new Error(`流式列表 ${e.id??e.dataset} 的单行高度超出单页可用范围`);p.heightMm>k&&a.push(`列表 ${e.id??e.dataset} 行高 ${p.heightMm.toFixed(2)}mm 超出单页可用高度 ${k.toFixed(2)}mm,预览与打印可能截断内容`),T(p.heightMm),N(p,M,x,P)}function N(p,M,x,P){const k=p.table?.id??f.id,A=x==="header"?-1:u.get(k)??0;x!=="header"&&u.set(k,A+p.grid.cells.length),n.components.push({kind:"rect",leftMm:e.leftMm,topMm:w,widthMm:e.widthMm,heightMm:p.heightMm,grid:p.grid,nid:s(M),table:{...f,...p.table,role:x,rowIndex:A,...P?{source:P}:{}},style:t.borderStyle,...e.meta?{meta:e.meta}:{}}),w+=p.heightMm}function F(p){p<=v()&&T(p)}return{keepTogether:F,placeGridRow:S,setGroupHeader:(p,M)=>{M?m.set(p,M):m.delete(p)},bottom:()=>w}}function Jt(e,t){if(!e.rowKey)return;const r=t[e.rowKey];if((typeof r!="string"||!r.trim())&&!(typeof r=="number"&&Number.isFinite(r)))throw new Error(`数据集 ${e.dataset} 的 ${e.rowKey} 应为稳定的字符串或有限数字主键`);const o=e.revisionField?t[e.revisionField]:void 0,n=e.sourceTokenField?t[e.sourceTokenField]:void 0;if(o!==void 0&&typeof o!="string"&&!(typeof o=="number"&&Number.isFinite(o)))throw new Error("业务修订号应为字符串或有限数字");if(n!==void 0&&typeof n!="string")throw new Error("来源令牌应为字符串");return{datasetId:e.dataset,rowKey:r,...o===void 0?{}:{revision:o},...n===void 0?{}:{sourceToken:n}}}function ee(e,t){const r=new Map;if(!e.rowKey)return r;const o=new Set;for(const n of t){const a=Jt(e,n),s=JSON.stringify(a.rowKey);if(o.has(s))throw new Error(`数据集 ${e.dataset} 的业务主键重复:${String(a.rowKey)}`);o.add(s),r.set(n,a)}return r}function qt(e,t,r,o,n){if(!e.grandTotal)return;const a=typeof e.grandTotal=="object"?e.grandTotal:void 0,s=te(e)[0],i=a?.fields??s?.subtotal??[],c=a?.aggregates??s?.aggregates??[];if(i.length===0&&c.length===0){o.warnings.push(`列表 ${e.id??""} 配置了 grandTotal 但未提供合计字段(groupBy.subtotal 或 grandTotal.fields)`);return}const d=V(r,o.measurer,a?.label??"合计",Je(e.columns,t,i,c),a?.style??{},qe(e.columns,[...i,...c.map(l=>l.field)]));n.placeGridRow(d,"listgt","grand-total")}function J(e){if(e?.aborted){const t=new Error("报表排版已取消");throw t.name="AbortError",t}}function te(e){const t=e.groups??(e.groupBy?[e.groupBy]:[]);if(t.length>16)throw new Error("列表最多支持 16 级分组");return t}function ye(e){const t=je(e),r=t.columns.reduce((n,a)=>n+a.widthMm,0),o=r>t.widthMm?t.widthMm/r:1;return o===1?t:{...t,columns:t.columns.map(n=>({...n,widthMm:n.widthMm*o}))}}function zt(e,t,r){const o=e.detail;if(!o)return;const n=new Set;for(const d of t){const l=le(d[o.parentKey]);if(n.has(l))throw new Error("主从明细的主表关联键重复");n.add(l)}const a=r.datasets[o.dataset]??[],s=new Map,i=[];for(const d of a){const l=d[o.foreignKey];if(!ze(l)&&o.unmatched==="ignore")continue;const f=le(l);if(!n.has(f)){if(o.unmatched!=="ignore")throw new Error(`明细数据集 ${o.dataset} 存在未关联的业务键`);continue}const u=s.get(f);u?u.push(d):s.set(f,[d]),i.push(d)}const c=ye({...e,id:`${e.id??e.dataset}:detail`,dataset:o.dataset,rowKey:o.rowKey,revisionField:o.revisionField,sourceTokenField:o.sourceTokenField,computed:void 0,columns:o.columns,headerGrid:void 0,rowHeightMm:o.rowHeightMm??e.rowHeightMm,detail:void 0});return{list:c,inter:{...we(c,r.measurer),rowHeightFloorMm:c.rowHeightMm??0},rows:s,sources:ee(c,i)}}function ze(e){return typeof e=="string"&&!!e.trim()||typeof e=="number"&&Number.isFinite(e)}function le(e){if(!ze(e))throw new Error("主从关联键必须是非空字符串或有限数字");return _e(e)}function*Ut(e,t,r,o,n){if(!r)return;const a=r.rows.get(le(t[e.detail.parentKey]))??[];if(!a.length)return;const s={id:`${o.tableId}:detail`,columnKeys:r.list.columns.map(i=>i.field),title:e.detail.label};e.detail.label&&n.placeGridRow({...V(r.inter,o.measurer,e.detail.label,new Map,{},r.list.columns.length),table:s},"listdl","group-header"),e.detail.header!==!1&&n.placeGridRow({grid:r.inter.headerGrid,heightMm:r.inter.headerHeightMm,table:s},"listdh","header"),yield*o.takePages();for(const i of a)J(o.signal),n.placeGridRow({...W(r.inter,i,o.measurer),table:s},"listdr","body",r.sources.get(i)),yield*o.takePages()}function Xt(e,t){if(!e.matrix)return{list:e,rows:t};if(e.detail||e.groupBy||e.groups?.length||e.grandTotal)throw new Error("矩阵不能同时配置普通分组、总计或主从明细");const r=Ne.createMatrixTable(t,e.matrix),o=r.columns.map((a,s)=>({...a,widthMm:s===0?e.matrix.rowWidthMm??40:e.matrix.columnWidthMm??28,editable:!1,align:s===0?"center":"right"})),n={...e,columns:o,headerGrid:void 0,rowKey:void 0,revisionField:void 0,sourceTokenField:void 0};return e.layout==="wide"&&(n.widthMm=o.reduce((a,s)=>a+s.widthMm,0)),{list:n,rows:r.rows}}function Ue(e){if(e.matrix||e.detail||e.groups?.length||e.groupBy||e.rowVisibleWhen)throw new Error("树形布局不能同时配置普通分组、矩阵、主从或行可见条件");if(e.rowKey&&e.rowKey!==e.tree.idField)throw new Error("树形布局的 rowKey 应与 idField 一致");if(!e.columns.some(t=>t.field===e.tree.labelField&&!t.hidden))throw new Error("树形布局需要可见的标签列");Q.validateTreeComputed(e.tree,e.computed)}function Yt(e,t,r){Ue(e);const o=Q.createTreeTable(t,e.tree,{signal:r.signal,computed:e.computed?.length?{fields:e.computed,formula:r.formula}:void 0}),n={...e,rowKey:e.tree.idField},a=ee(n,o.entries.map(c=>c.original)),s=new Map,i=new WeakMap;for(const c of o.entries)s.set(c.row,a.get(c.original)),i.set(c.row,c);return{list:n,rows:o.rows,sources:s,treeRows:i,totalRows:o.leaves}}function Qt(e,t){if(e.cardinality==="record"){if(t.length>1)throw new Error(`单记录区域 ${e.id??e.dataset} 仅允许 0 或 1 行数据`);if(e.tree||e.matrix||e.detail||e.groups?.length||e.groupBy||e.grandTotal||e.rowVisibleWhen)throw new Error("单记录区域不能配置树、矩阵、主从、分组、总计或行过滤");if(!t.length)return{list:{...e,columns:e.columns.map(r=>({...r,editable:!1}))},rows:[{}],sources:new Map}}}function Xe(e,t,r){const o=r.prepared.get(e);if(o)return o;const n=Qt(e,t);if(n)return r.prepared.set(e,n),n;if(e.tree){const c=Yt(e,t,r);return r.prepared.set(e,c),c}let a=e.computed?.length?ge.computeDataset(t,{fields:e.computed,signal:r.signal,formula:r.formula}).rows:t;const s=a===t?void 0:new Map(a.map((c,d)=>[c,t[d]]));e.rowVisibleWhen&&(a=a.filter(c=>R.evalStyleRule(c,e.rowVisibleWhen)));const i=Xt(e,a);if(!e.matrix){const c=ee(e,s?a.map(d=>s.get(d)):a);i.sources=s?new Map(a.map(d=>[d,c.get(s.get(d))])):c}return r.prepared.set(e,i),i}function Zt(e,t,r,o){if(!o.flow)return;const{current:n,templatePage:a}=o,s=Math.max(n.marginTopMm,_(a)),i=Math.max(o.startTop??e.topMm,s),c=(e.header===!1?0:t.headerHeightMm)+(r[0]?W(t,r[0],o.measurer).heightMm:0);i+c<=U(a,n)+.001||i<=s+.001||(o.pushCurrent(),n.components=[],n.heightMm=a.heightMm,a.layout==="wide"&&(n.marginTopMm=0,n.marginBottomMm=0),o.startTop=Math.max(n.marginTopMm,_(a)))}function*er(e,t,r){const o=Xe(e,t,r),n=o.rows;e=o.list,e.layout==="wide"&&(r.current.widthMm=Math.max(r.current.widthMm,e.leftMm+e.widthMm+r.current.marginRightMm));const a=o.sources??ee(e,n),s=ye(e),i=te(s),c={...we(s,r.measurer),rowHeightFloorMm:s.rowHeightMm??0,...o.treeRows?{tree:{list:s,rows:o.treeRows}}:{}};Zt(s,c,n,r);const d=Wt(s,c,r),l=zt(s,n,r);let f;for(const u of We(n,i)){if(J(r.signal),u.kind==="row")d.placeGridRow(f??W(c,u.row,r.measurer),"listr","body",a.get(u.row)),f=void 0,yield*r.takePages(),yield*Ut(s,u.row,l,r,d);else if(u.kind==="groupHeader"){const m=V(c,r.measurer,u.label,new Map,u.group.headerStyle??{},s.columns.length);f??=W(c,u.firstRow,r.measurer);const h=i.slice(u.depth+1).reduce((g,w)=>g+V(c,r.measurer,(w.headerTemplate??"{value}").replace(/\{value\}/g,R.listCellText(u.firstRow[w.field])),new Map,w.headerStyle??{},s.columns.length).heightMm,0);u.group.keepWithNext!==!1&&d.keepTogether(m.heightMm+h+f.heightMm),d.placeGridRow(m,"listg","group-header"),u.group.repeatHeader&&d.setGroupHeader(u.depth,m)}else if(u.kind==="subtotal"){const m=u.group.subtotal??[],h=u.group.aggregates??[],g=V(c,r.measurer,u.label,Je(s.columns,u.rows,m,h),u.group.subtotalStyle??{},qe(s.columns,[...m,...h.map(w=>w.field)]));d.placeGridRow(g,"listst","subtotal")}else d.setGroupHeader(u.depth);yield*r.takePages()}qt(s,o.totalRows??n,c,r,d),r.finished?.(d.bottom()),yield*r.takePages()}function re(e){return e.kind!=="list"&&(e.pageAnchor!==void 0||e.kind==="text"&&typeof e.text=="string"&&(e.text.includes("{page}")||e.text.includes("{totalPages}")))}function oe(e,t){return{...e,...e.text===void 0?{}:{text:t(e.text)},...e.lines?{lines:e.lines.map(t)}:{},...e.richParagraphs?{richParagraphs:e.richParagraphs.map(r=>({...r,segments:r.segments.map(o=>({...o,...o.text===void 0?{}:{text:t(o.text)}}))}))}:{},...e.grid?{grid:{...e.grid,cells:e.grid.cells.map(r=>r.map(o=>o?{...o,...o.text===void 0?{}:{text:t(o.text)},...o.children?{children:o.children.map(n=>oe(n,t))}:{}}:null))}}:{}}}function tr(e){let t=!1;for(const r of e.pages)for(const o of r.components)re(o)&&oe(o,n=>(n.includes("{totalPages}")&&(t=!0),n));return t}function rr(e,t,r,o,n,a){const s={pageWidthMm:t.widthMm,pageHeightMm:t.heightMm,...e.layout===void 0?{}:{layout:e.layout},marginTopMm:t.marginTopMm,marginBottomMm:t.marginBottomMm,marginLeftMm:t.marginLeftMm,marginRightMm:t.marginRightMm,components:t.components,...e.meta?{meta:e.meta}:{}},i=c=>{const d=c.replace(/\{page\}/g,String(o));return a===void 0?d:d.replace(/\{totalPages\}/g,String(a))};for(const c of r)s.components.push(oe(c,i));if(e.layout==="wide"){const c=s.components.reduce((d,l)=>Math.max(d,l.topMm+l.heightMm),0);s.marginBottomMm=n?e.marginBottomMm??0:0,s.pageHeightMm=Math.max(1,c+s.marginBottomMm)}return s}function be(e){return e.cells.reduce((t,r)=>t+r.reduce((o,n)=>o+(n?1+(n.children?.reduce((a,s)=>a+Ye(s),0)??0):0),0),0)}function Ye(e){return e.grid?be(e.grid):0}function Me(e){for(const t of["maxPages","maxCells","knownTotalPages"])if(e[t]!==void 0&&(!Number.isSafeInteger(e[t])||e[t]<1))throw new RangeError(`${t} 应为正安全整数`)}function or(e,t){const r=Xe(e,t.datasets[e.dataset]??[],t),o=ye(r.list),n={...we(o,t.measurer),rowHeightFloorMm:o.rowHeightMm??0};return(o.header===!1?0:n.headerHeightMm)+r.rows.reduce((a,s)=>a+W(n,s,t.measurer).heightMm,0)}function*nr(e){const{templatePage:t,current:r}=e,o=new Map(t.components.map((a,s)=>[a,s])),n=(a,s,i)=>{const c=e.datasets[a.dataset];return Array.isArray(c)||e.warnings.push(`数据集 ${a.dataset} 未提供数据,列表 ${a.id??""} 输出为空`),er(a,Array.isArray(c)?c:[],{...e,tableId:`${e.tableId}:${o.get(a)}`,startTop:s,finished:i,flow:!!t.flow})};if(t.flow){yield*Pt({page:t,active:()=>J(e.signal),top:()=>Math.max(r.marginTopMm,_(t)),bottom:()=>U(t,r),append:a=>{r.components.push(a)},nextPage:()=>{e.pushCurrent(),r.components=[],r.heightMm=t.heightMm,t.layout==="wide"&&(r.marginTopMm=0,r.marginBottomMm=0)},takePages:e.takePages,height:a=>or(a,e),list:n});return}for(const a of t.components)re(a)||(a.kind==="list"?yield*n(a):r.components.push(a))}function*X(e,t,r,o,n,a=new WeakMap){let s=0,i=0,c=0;const d=l=>`${l}_${(++s).toString(36)}`;for(const{pageIndex:l,page:f}of Kt(e,t,r)){J(r.signal);const u=Lt(f),m=f.components.filter(re);let h=[];const g=(y=!1)=>{if(J(r.signal),r.maxPages!==void 0&&i>=r.maxPages)throw new K(r.maxPages,i+1);if(r.maxCells!==void 0&&(c+=[...u.components,...m].reduce((v,T)=>v+Ye(T),0),c>r.maxCells))throw new B(r.maxCells,c);h.push(rr(f,u,m,++i,y,n))},w=()=>{const y=h;return h=[],y};yield*nr({templatePage:f,current:u,warnings:o,nextId:d,pushCurrent:g,takePages:w,datasets:t,signal:r.signal,formula:r.formula,prepared:a,measurer:r.measurer??D.heuristicMeasurer,mmPerRow:r.mmPerRow??0,tableId:`table:${l}`}),g(!0),yield*w()}}function ar(e,t,r={}){Me(r);let o=0;for(const n of X(e,t,{...r,onWarning:void 0},[]))o++;return o}function*Qe(e,t,r={}){Me(r);const o=tr(e),n=new WeakMap;let a=r.knownTotalPages;if(o&&a===void 0){a=0;for(const c of X(e,t,r,[],void 0,n))a++}const s=[];let i=0;for(const c of X(e,t,r,s,a,n)){for(;i<s.length;i++)r.onWarning?.(s[i]);yield c}}function ve(e,t,r={}){const o=typeof r=="number"?{mmPerRow:r}:r;Me(o);const n=[],a=[...X(e,t,o,n,o.knownTotalPages)];for(const s of a)s.components=s.components.map(i=>re(i)?oe(i,c=>c.replace(/\{totalPages\}/g,String(a.length))):i);return n.forEach(s=>o.onWarning?.(s)),{plan:{schemaVersion:Y.RENDER_PLAN_SCHEMA_VERSION,...Z(e)?{requiresRecalculation:!0}:{},pages:a},warnings:n}}function sr(e){const t=e.columns.find(a=>!a.hidden)?.field;if(!t)return{groups:0,total:0};const r=te(e),o=(a=[],s=[])=>a.includes(t)||s.some(i=>i.field===t),n=typeof e.grandTotal=="object"?e.grandTotal:void 0;return{groups:r.filter(a=>o(a.subtotal,a.aggregates)).length,total:Number(o(n?.fields??r[0]?.subtotal,n?.aggregates??r[0]?.aggregates))}}function ir(e,t,r){Ue(e);const o=Q.flattenTreeInput(t[e.dataset]??[],e.tree,r),n=e.columns.filter(s=>!s.hidden).length,a=e.header===!1?0:e.headerGrid?be(e.headerGrid):n;return o.length*n+a+ +!!e.grandTotal*2*n}function cr(e,t,r={}){if(e.tree)return ir(e,t,r.signal);if(e.matrix){let c=t[e.dataset]??[];e.computed?.length&&(c=ge.computeDataset(c,{fields:e.computed,...r}).rows),e.rowVisibleWhen&&(c=c.filter(l=>R.evalStyleRule(l,e.rowVisibleWhen)));const d=Ne.estimateMatrixTable(c,e.matrix);return d.cells+d.columnCount}const o=t[e.dataset]?.length??0,n=e.columns.filter(c=>!c.hidden).length,a=te(e).length,s=sr(e);let i=(o*(1+2*a+s.groups)+ +!!e.grandTotal*(1+s.total))*n;if(i+=e.header===!1?0:e.headerGrid?be(e.headerGrid):n,e.cardinality==="record"&&o===0&&(i+=n),e.detail){const c=t[e.detail.dataset]?.length??0,d=e.detail.columns.filter(l=>!l.hidden).length;i+=(c+o*(+(e.detail.header!==!1)+ +!!e.detail.label))*d}if(!Number.isSafeInteger(i))throw new RangeError("报表单元格估算超出安全整数预算");return i}function Ze(e){return!e||typeof e!="object"?!1:[e.pageIndex,e.componentIndex,e.rowIndex,e.columnIndex].every(t=>Number.isInteger(t)&&t>=0)}function et(e,t,r){const o=e.grid;if(!o)return null;const n=o.cells[t];if(!n)return null;const s=he.resolveGridLayout(o,e.widthMm,e.heightMm).cells.filter(c=>c.ri===t).findIndex(c=>c.ci===r),i=n[s];return i?{cell:i,sourceColumnIndex:s}:null}function lr(e){return e.value!==void 0?e.value:e.rawText??e.text??null}function dr(e,t){return e.valueType?e.valueType:typeof t=="number"?"number":typeof t=="boolean"?"boolean":t===null&&e.numberFormat&&/[0#?]/.test(e.numberFormat)?"number":"text"}function ur(e,t){if(e.derived)return"derived";if(e.editable===!1)return"cell";if(e.formula!==void 0)return"formula";if(e.children?.length||e.richParagraphs?.length)return"complex";if(t.table&&t.table.role!=="body"&&e.editable!==!0)return"structure"}function fr(e,t){const r=e.table;if(r)return{id:r.id,rowIndex:r.rowIndex+t.rowIndex,role:r.role,columnKey:r.columnKeys[t.columnIndex]}}function mr(e,t,r){if(e.derived)return;if(e.source)return{...e.source};const o=t.table?.source,n=t.table?.columnKeys[r.columnIndex];if(!(!o||o.rowKey===void 0||n===void 0))return{...o,rowKey:o.rowKey,field:n}}function tt(e,t,r){const o=lr(r),n=ur(r,e);return{address:{...t},cell:r,component:e,value:o,valueType:dr(r,o),table:fr(e,t),source:mr(r,e,t),editable:n===void 0,readOnlyReason:n}}function ne(e,t){if(!Ze(t))return null;const r=e.pages[t.pageIndex]?.components[t.componentIndex];if(!r)return null;const o=et(r,t.rowIndex,t.columnIndex);return o?tt(r,t,o.cell):null}function j(e){const t=new Map;return r=>{if(!Ze(r))return null;const o=e.pages[r.pageIndex]?.components[r.componentIndex];if(!o?.grid)return null;let n=t.get(o);if(!n){const s=new Map;n=new Map;for(const i of he.resolveGridLayout(o.grid,o.widthMm,o.heightMm).cells){const c=s.get(i.ri)??0;s.set(i.ri,c+1);const d=o.grid.cells[i.ri]?.[c];d&&n.set(`${i.ri}:${i.ci}`,d)}t.set(o,n)}const a=n.get(`${r.rowIndex}:${r.columnIndex}`);return a?tt(o,r,a):null}}class b extends Error{constructor(t){super(`Invalid report cell edit: ${t}`),this.code=t,this.name="ReportCellEditError"}}function gr(e,t){let r=e.trim();const o=t&&r.endsWith("%");if(o&&(r=r.slice(0,-1).trim()),/^[+-]?\d{1,3}(?:,\d{3})+(?:\.\d*)?(?:[eE][+-]?\d+)?$/.test(r)&&(r=r.replace(/,/g,"")),!/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(r))throw new b("number");return Number(r)/(o?100:1)}function hr(e,t){if(e===null||typeof e=="string"&&e.trim()==="")return null;if(typeof e!="string"&&typeof e!="number")throw new b("number");const r=typeof e=="number"?e:gr(e,Ke.isExcelPercentageFormat(t.cell.numberFormat));if(!Number.isFinite(r)||Number.isInteger(r)&&!Number.isSafeInteger(r))throw new b("number");return r}function pr(e){if(e===null||typeof e=="string"&&e.trim()==="")return null;if(typeof e=="boolean")return e;const t=String(e).trim().toLowerCase();if(["true","yes","是","1"].includes(t))return!0;if(["false","no","否","0"].includes(t))return!1;throw new b("boolean")}function Se(e,t){return e.valueType==="number"?hr(t,e):e.valueType==="boolean"?pr(t):t===null?null:String(t)}function wr(e,t){const r=t.cell.text,n=[["是","否"],["TRUE","FALSE"],["True","False"],["true","false"],["1","0"]].find(a=>a.includes(r??""));return n?n[e?0:1]:String(e)}function H(e,t){return t===null?"":typeof t=="boolean"?wr(t,e):typeof t=="number"?Ke.formatExcelNumber(t,e.cell.numberFormat):String(t)}function yr(e,t,r){const o=ne(e,t);if(!o)throw new b("missing");return q(o,r)}function q(e,t){if(!e.editable)throw new b("readonly");const r=Se(e,t);return{address:{...e.address},table:e.table,source:e.source,previousValue:e.value,previousText:e.cell.text??"",value:r,text:H(e,r)}}function br(e,t){const r=e.table,o=t.table;return!r||!o||r.columnKey===void 0?!1:r.id===o.id&&r.rowIndex===o.rowIndex&&r.role===o.role&&r.columnKey===o.columnKey}function rt(e,t,r){const o=e.grid,{rowIndex:n,columnIndex:a}=t.address,s=et(e,n,a),i=[...o.cells],c=[...i[n]],d=H(t,r.value),l={...s.cell,value:r.value,text:d,rawText:d};return c[s.sourceColumnIndex]=l,i[n]=c,{...e,grid:{...o,cells:i}}}function Mr(e,t){const r=e.table?.columnKeys,o=t.table?.columnKey;return r&&o!==void 0?r.flatMap((n,a)=>n===o?[a]:[]):[]}function vr(e,t,r,o,n,a){const s=t.table,i=n.table;if(!s||!i||s.id!==i.id||s.role!==i.role||!t.grid)return t;const c=i.rowIndex-s.rowIndex;if(c<0||c>=t.grid.cells.length)return t;let d=t;for(const l of Mr(t,n)){const f=ne(e,{pageIndex:r,componentIndex:o,rowIndex:c,columnIndex:l});f?.editable&&br(n,f)&&(d=rt(d,f,a))}return d}function Sr(e,t,r,o,n,a){const s=n.address;return n.table?.columnKey!==void 0?vr(e,t,r,o,n,a):s.pageIndex===r&&s.componentIndex===o?rt(t,n,a):t}function xe(e,t){const r=t.source;if(!r)return!1;const o=e.source;return!o||["sourceScope","datasetId","rowKey","field","revision","sourceToken"].some(n=>!Object.is(o[n],r[n]))}function xr(e,t){const r=ne(e,t.address);if(!r)throw new b("missing");if(!r.editable)throw new b("readonly");if(xe(r,t))throw new b("conflict");if(!Object.is(r.value,t.previousValue)||(r.cell.text??"")!==t.previousText)throw new b("conflict");const o=Se(r,t.value),n={...t,value:o,text:H(r,o)};if(Object.is(o,r.value)&&n.text===r.cell.text)return e;const a=e.pages.map((s,i)=>{const c=s.components.map((d,l)=>Sr(e,d,i,l,r,n));return c.every((d,l)=>d===s.components[l])?s:{...s,components:c}});return{...e,pages:a}}function ot(e){const t=[];for(const r of e.template.pages)for(const o of r.components)o.kind==="list"&&(t.push(o.tree?{...o,rowKey:o.tree.idField}:o),o.detail&&t.push({...o.detail,relation:{detail:o.detail,parentRows:e.datasets[o.dataset]??[]}}));return t}function G(e){return JSON.stringify([e.sourceScope,e.datasetId])}function Fe(e){return JSON.stringify([e.sourceScope,e.datasetId,e.rowKey])}function nt(e){const t=new Map,r=new Set;return e.forEach((o,n)=>{for(const a of ot(o)){if(!a.rowKey)continue;const s=a.relation,i=s?new Set(s.parentRows.map(c=>JSON.stringify(c[s.detail.parentKey]))):void 0;(o.datasets[a.dataset]??[]).forEach((c,d)=>{if(s&&!i.has(JSON.stringify(c[s.detail.foreignKey])))return;const l=c[a.rowKey];if(typeof l!="string"&&typeof l!="number")return;const f=`${n}:${a.dataset}:${d}:${a.rowKey}`;if(r.has(f))return;r.add(f);const u=Fe({sourceScope:o.sourceScope,datasetId:a.dataset,rowKey:l}),m=t.get(u)??[];m.push({partIndex:n,dataset:a.dataset,rowIndex:d,row:c,binding:a}),t.set(u,m)})}}),o=>{const n=t.get(Fe(o));if(!n?.length)throw new b("missing");if(new Set(n.map(a=>`${a.partIndex}:${a.dataset}`)).size!==n.length)throw new b("conflict");return n}}function at(e,t){const r=e.map(n=>({...n,datasets:{...n.datasets}})),o=new Set;for(const{row:n,field:a,value:s}of t){const i=r[n.partIndex],c=`${n.partIndex}:${n.dataset}`;o.has(c)||(i.datasets[n.dataset]=[...i.datasets[n.dataset]],o.add(c)),i.datasets[n.dataset][n.rowIndex]={...i.datasets[n.dataset][n.rowIndex],[a]:s}}return r}function Rr(e,t,r){const o=[],n=new Set;return e.forEach((a,s)=>{for(const i of ot(a))t.has(G({sourceScope:a.sourceScope,datasetId:i.dataset}))&&(a.datasets[i.dataset]??[]).forEach((c,d)=>{const l={partIndex:s,dataset:i.dataset,rowIndex:d,row:c,binding:i};for(const[f,u]of[[i.revisionField,r.revision],[i.sourceTokenField,r.sourceToken]]){if(!f||u===void 0)continue;const m=`${s}:${i.dataset}:${d}:${f}`;n.has(m)||(n.add(m),o.push({row:l,field:f,value:u}))}})}),o}function st(e,t,r){if(!r||r.revision===void 0&&r.sourceToken===void 0)return e;const o=new Set(t.edits.flatMap(n=>n.source?[G(n.source)]:[]));return Re(e,new Map([...o].map(n=>[n,r])))}function Re(e,t){if(!t.size)return e;function r(a){const s=a.datasetId&&t.get(G({...a,datasetId:a.datasetId}));return!s||(s.revision===void 0||Object.is(s.revision,a.revision))&&(s.sourceToken===void 0||s.sourceToken===a.sourceToken)?a:{...a,...s.revision!==void 0?{revision:s.revision}:{},...s.sourceToken!==void 0?{sourceToken:s.sourceToken}:{}}}function o(a){const s=a.map(i=>{const c=i.table?.source?r(i.table.source):void 0,d=i.table&&c!==i.table.source?{...i.table,source:c}:i.table,l=i.grid?.cells.map(u=>{const m=u.map(h=>{if(!h)return h;const g=h.source?r(h.source):void 0,w=h.children?o(h.children):void 0;return g===h.source&&w===h.children?h:{...h,source:g,children:w}});return m.some((h,g)=>h!==u[g])?m:u}),f=i.grid&&l?.some((u,m)=>u!==i.grid.cells[m])?{...i.grid,cells:l}:i.grid;return d!==i.table||f!==i.grid?{...i,table:d,grid:f}:i});return s.some((i,c)=>i!==a[c])?s:a}const n=e.pages.map(a=>{const s=o(a.components);return s!==a.components?{...a,components:s}:a});return n.some((a,s)=>a!==e.pages[s])?{...e,pages:n}:e}function Tr(e){return JSON.stringify([e.pageIndex,e.componentIndex,e.rowIndex,e.columnIndex])}function Ae(e){const t=e.table;return t?.columnKey!==void 0?JSON.stringify([t.id,t.role,t.rowIndex,t.columnKey]):Tr(e.address)}function Er(e,t){if(!t.length)return e;const r=new Map(t.map(c=>[Ae(c),c])),o=new Set(t.flatMap(c=>c.table?[c.table.id]:[])),n=new Set(t.map(c=>`${c.address.pageIndex}:${c.address.componentIndex}`)),a=j(e);function s(c,d,l){const f=c.grid;if(!f||!n.has(`${d}:${l}`)&&!o.has(c.table?.id??""))return c;const u=new Map,m=new Map;for(const h of he.resolveGridLayout(f,c.widthMm,c.heightMm).cells){const g=m.get(h.ri)??0;m.set(h.ri,g+1);const w=a({pageIndex:d,componentIndex:l,rowIndex:h.ri,columnIndex:h.ci}),y=w&&r.get(Ae(w));if(!y||!w.editable)continue;const v=u.get(h.ri)??[...f.cells[h.ri]],T=H(w,y.value);Object.is(w.value,y.value)&&T===w.cell.text||(v[g]={...h.cell,value:y.value,text:T,rawText:T},u.set(h.ri,v))}return u.size?{...c,grid:{...f,cells:f.cells.map((h,g)=>u.get(g)??h)}}:c}const i=e.pages.map((c,d)=>{const l=c.components.map((f,u)=>s(f,d,u));return l.every((f,u)=>f===c.components[u])?c:{...c,components:l}});return i.every((c,d)=>c===e.pages[d])?e:{...e,pages:i}}function I(e){const t=e.source;if(t)return JSON.stringify([t.sourceScope,t.datasetId,t.rowKey,t.field]);const r=e.table;if(r?.columnKey!==void 0)return JSON.stringify([r.id,r.role,r.rowIndex,r.columnKey]);const o=e.address;return JSON.stringify([o.pageIndex,o.componentIndex,o.rowIndex,o.columnIndex])}function Pr(e,t,r){if(typeof r!="string"||!r.trim()||!Array.isArray(t))throw new b("missing");if(t.length>1e4)throw new b("limit");const o=new Set,n=j(e),a=t.map(({address:s,value:i})=>{const c=n(s);if(!c)throw new b("missing");const d=q(c,i),l=I(d);if(o.has(l))throw new b("duplicate");return o.add(l),d});return{requestId:r,edits:a}}function Cr(e,t){if(t.edits.length>1e4)throw new b("limit");const r=j(e),o=new Set,n=t.edits.map(a=>{const s=r(a.address);if(!s)throw new b("missing");const i=I(a);if(o.has(i))throw new b("duplicate");if(o.add(i),xe(s,a)||!Object.is(s.value,a.previousValue)||(s.cell.text??"")!==a.previousText)throw new b("conflict");return q(s,a.value)});return Er(e,n)}function kr(e){const t=new Map;for(const r of e){const o=I(r),n=t.get(o),a=n?{...r,previousValue:n.previousValue,previousText:n.previousText}:{...r};Object.is(a.previousValue,a.value)?t.delete(o):t.set(o,a)}return[...t.values()]}function it(e){const t=new Map,r=j(e);return e.pages.forEach((o,n)=>o.components.forEach((a,s)=>{if(!(!a.grid||a.table?.role!=="body"))for(let i=0;i<a.grid.cells.length;i++)for(let c=0;c<a.table.columnKeys.length;c++){const d=r({pageIndex:n,componentIndex:s,rowIndex:i,columnIndex:c});d?.source&&d.editable&&t.set(I(d),d)}})),t}function $r(e,t,r){const o=it(e),n=j(e);return t.map(a=>{const s=a.source?o.get(I(a)):n(a.address);if(!s||I(s)!==I(a))throw new b("missing");return{address:{...s.address},value:a[r]}})}function ct(e,t){if(++e.nodes>1e6||t>128)throw new b("limit")}function Te(e,t){const r=Object.getOwnPropertyDescriptor(e,t);if(!r||r.get||r.set)throw new b("conflict");return r.value}function lt(e){if(Object.getOwnPropertyDescriptor(e,"toJSON"))throw new b("conflict");const t=Object.getPrototypeOf(e);if(!(e instanceof Date)&&!Array.isArray(e)&&t!==Object.prototype&&t!==null)throw new b("conflict");for(const r of Reflect.ownKeys(e))if(!(Array.isArray(e)&&r==="length")){if(typeof r=="symbol"||!Object.getOwnPropertyDescriptor(e,r)?.enumerable)throw new b("conflict");if(e instanceof Date||Array.isArray(e)&&!/^(0|[1-9]\d*)$/.test(r))throw new b("conflict")}}function dt(e,t,r,o,n){if(ct(o,n),typeof e=="function"||typeof e=="symbol")throw new b("conflict");if(e===null||typeof e!="object")return;if(lt(e),r.has(e))throw new b("conflict");r.add(e);const a=Object.keys(e),s=a.map(i=>Te(e,i));t.push({object:e,prototype:Object.getPrototypeOf(e),keys:a,values:s,...e instanceof Date?{date:Date.prototype.getTime.call(e)}:{},...Array.isArray(e)?{length:e.length}:{}});for(const i of s)dt(i,t,r,o,n+1);r.delete(e)}function Ir(e){const{object:t,keys:r,values:o}=e;if(lt(t),Object.getPrototypeOf(t)!==e.prototype||Object.getOwnPropertyDescriptor(t,"toJSON")||e.date!==void 0&&!Object.is(Date.prototype.getTime.call(t),e.date)||e.length!==void 0&&t.length!==e.length)return!1;const n=Object.keys(t);return n.length===r.length&&r.every((a,s)=>n[s]===a&&Object.is(Te(t,a),o[s]))}function Or(e){const t=[];return dt(e,t,new Set,{nodes:0},0),()=>{try{return t.every(Ir)}catch{return!1}}}function de(e,t,r){return ct(t,r),e===null||typeof e!="object"?e:e instanceof Date?new Date(Date.prototype.getTime.call(e)):Array.isArray(e)?e.map(o=>de(o,t,r+1)):Object.fromEntries(Object.keys(e).map(o=>[o,de(Te(e,o),t,r+1)]))}function Fr(e){return de(e,{nodes:0},0)}async function ut(e,t,r={}){const o=[],n={...r,knownTotalPages:void 0};for(const a of Qe(e,t,n))o.push(a),o.length%8===0&&await new Promise(s=>setTimeout(s,0));if(r.signal?.aborted){const a=new Error("报表重算已取消");throw a.name="AbortError",a}return{schemaVersion:Y.RENDER_PLAN_SCHEMA_VERSION,...Z(e)?{requiresRecalculation:!0}:{},pages:o}}const ue=new WeakMap;function Ar(e){return ue.get(e)}function z(e){if(e?.aborted){const t=new Error("报表重算已取消");throw t.name="AbortError",t}}function ft(e,t){return e[t]===void 0?"":e[t]}function Nr(e,t){if(t.edits.length>1e4)throw new b("limit");const r=j(e),o=new Set,n=[],a=t.edits.map(s=>{const i=r(s.address);if(!i?.source)throw new b("missing");const c=I(s);if(o.has(c))throw new b("duplicate");if(o.add(c),xe(i,s)||!Object.is(i.value,s.previousValue)||(i.cell.text??"")!==s.previousText)throw new b("conflict");return n.push(i),q(i,s.value)});return{batch:{requestId:t.requestId,edits:a},contexts:n}}function Kr(e,t){const r=nt(e);return t.flatMap(o=>{if(!o.source)throw new b("missing");return r(o.source).map(n=>{if(!Object.is(ft(n.row,o.source.field),o.previousValue))throw new b("conflict");if(n.binding.rowKey===o.source.field)throw new b("readonly");return{row:n,field:o.source.field,value:o.value}})})}function ce(e,t,r){const o={...e,value:t,source:{...e.source,...r?.revision===void 0?{}:{revision:r.revision},...r?.sourceToken===void 0?{}:{sourceToken:r.sourceToken}}};return o.cell={...e.cell,value:o.value,text:H(o,o.value)},o}function Lr(e,t,r){if(!r||r.revision===void 0&&r.sourceToken===void 0)return[...e];const o=new Set(t.edits.flatMap(n=>n.source?[G(n.source)]:[]));return at(e,Rr(e,o,r))}function jr(e,t,r){const o=new Set(t.edits.map(n=>G(n.source)));for(const n of o)e.set(n,{...e.get(n),...r.revision!==void 0?{revision:r.revision}:{},...r.sourceToken!==void 0?{sourceToken:r.sourceToken}:{}});return o}function Ee(e,t){let r=t.parts;const o=t.rebuild;let n=Or(r),a=e,s;const i=new Map,c=new Map;function d(u){if(u!==a)throw new b("conflict");if(s)return s;if(!n?.())throw new b("conflict");return Fr(r)}async function l(u,m,h,g={}){z(g.signal),m={requestId:m.requestId,edits:m.edits.map(S=>({...S,address:{...S.address},source:S.source?{...S.source}:void 0,table:S.table?{...S.table}:void 0}))},h=h.map(S=>({...S,address:{...S.address},source:S.source?{...S.source}:void 0,table:S.table?{...S.table}:void 0,cell:{...S.cell}})),await new Promise(S=>setTimeout(S,0)),z(g.signal);const w=d(u),y=at(w,Kr(w,m.edits)),v=Re(await o(y,g.signal),c);z(g.signal);let T=!1;return{plan:v,commit(S){if(z(g.signal),T||a!==u)throw new b("conflict");if(S?.conflicts?.length)throw new b("conflict");const N=Lr(y,m,S),F=st(v,m,S);if(S){const O=jr(c,m,S);for(const[p,M]of i)O.has(G(M.source))&&i.set(p,ce(M,M.value,S))}return h.forEach((O,p)=>i.set(I(O),ce(O,m.edits[p].value,S))),T=!0,s=N,r=void 0,n=void 0,a=F,ue.set(a,f),a}}}const f={get plan(){return a},async prepare(u,m,h){const g=Nr(u,m);return l(u,g.batch,g.contexts,h)},async prepareHistory(u,m,h,g,w){if(!g.trim()||m.length>1e4)throw new b("limit");const y=d(u),v=nt(y),T=it(u),S=new Set,F=m.map(M=>{if(!M.source)throw new b("missing");const x=I(M);if(S.has(x))throw new b("duplicate");S.add(x);const P=T.get(x)??i.get(x);if(!P?.source)throw new b("missing");const k=v(P.source)[0];return ce(P,ft(k.row,P.source.field))}).map((M,x)=>({context:M,edit:q(M,m[x][h])})).filter(({edit:M})=>!Object.is(M.previousValue,M.value)),O={requestId:g,edits:F.map(({edit:M})=>M)},p=F.map(({context:M})=>M);return{batch:O,contexts:p,prepared:await l(u,O,p,w)}}};return ue.set(e,f),f}function Br(e){const t=ve(e.template,e.datasets,e.pagination).plan;return Ee(t,{parts:[{template:e.template,datasets:e.datasets}],rebuild:(r,o)=>ut(r[0].template,r[0].datasets,{...e.pagination,signal:o})})}let Dr=0;function mt(){return`report-${Date.now()}-${++Dr}`}function fe(e,t,r){if(!r?.aborted)try{const o=e?.({...t});o&&typeof o.then=="function"&&Promise.resolve(o).catch(()=>{})}catch{}}function gt(e){const t=e.taskId??mt(),r=(o,n,a)=>{fe(e.onEvent,{taskId:t,...e.correlationId===void 0?{}:{correlationId:e.correlationId},stage:o,status:n,...a===void 0?{}:{reportId:a}},e.signal)};return{taskId:t,progress(o,n,a){fe(e.onEvent,{taskId:t,...e.correlationId===void 0?{}:{correlationId:e.correlationId},stage:o,status:"started",completed:n,total:a},e.signal)},async run(o,n,a){r(o,"started",a);try{const s=await n();return r(o,"completed",a),s}catch(s){throw r(o,"failed",a),s}},runSync(o,n,a){r(o,"started",a);try{const s=n();return r(o,"completed",a),s}catch(s){throw r(o,"failed",a),s}}}}function ht(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e,r=o=>typeof o=="string"&&o.trim().length>0&&o.length<=256;return!r(t.datasetId)||!r(t.field)||t.tableId!==void 0&&!r(t.tableId)||t.reportScope!==void 0&&(typeof t.reportScope!="string"||!t.reportScope.trim()||t.reportScope.length>4096)?!1:t.rowKey===void 0?!0:typeof t.rowKey=="string"?t.rowKey.trim().length>0&&t.rowKey.length<=1024:typeof t.rowKey=="number"&&Number.isFinite(t.rowKey)}function pt(e){return e==="missing-source"||e==="not-applicable"||e==="not-calculable"}function wt(e){return e.target!==void 0&&!ht(e.target)?!1:e.valueState===void 0||pt(e.valueState)&&e.target!==void 0}function Pe(e,t,r={}){const o=new Map;for(const a of e.pages)for(const s of a.components){if(s.kind!=="list"||s.tree?.input!=="nested")continue;const i=o.get(s.dataset);if(i&&(i.childrenField??"children")!==(s.tree.childrenField??"children"))throw new Error("同一数据集的嵌套树应使用相同 childrenField");o.set(s.dataset,s.tree)}if(!o.size)return t;const n={...t};for(const[a,s]of o){const i=Math.min(s.maxRows??1e5,r.maxRows??1/0);n[a]=Q.flattenTreeInput(t[a]??[],{...s,maxRows:i},r.signal)}return n}function Hr(e,t,r={}){return Object.values(Pe(e,t,r)).reduce((o,n)=>o+n.length,0)}function Gr(e,t,r){const o=Le.datasetJsonSchema(r),n=e?.pages.flatMap(i=>i.components).find(i=>i.kind==="list"&&i.dataset===t&&i.tree?.input==="nested");if(!n||n.kind!=="list"||!n.tree)return o;const a=o.items,s=n.tree.childrenField??"children";return{...o,items:{$ref:"#/$defs/treeNode"},$defs:{treeNode:{...a,properties:{...a.properties,[s]:{anyOf:[{type:"null"},{type:"array",items:{$ref:"#/$defs/treeNode"}}]}}}}}}function Ce(e,t){return JSON.stringify([e,t])}function yt(e,t,r){return r===void 0?Ce(e,t):JSON.stringify(["shared",r])}function bt(e,t,r){return e.map(o=>{const n=o.table?{...o.table,id:r(o.table.id),...o.table.source?{source:{...o.table.source,sourceScope:t}}:{}}:void 0,a=o.grid?.cells.map(s=>s.map(i=>!i||!i.source&&!i.children?i:{...i,...i.source?{source:{...i.source,sourceScope:t}}:{},...i.children?{children:bt(i.children,t,r)}:{}}));return n||a?{...o,...n?{table:n}:{},...a?{grid:{...o.grid,cells:a}}:{}}:o})}function Vr(e){if(!("mapData"in e))return e;const{load:t,mapData:r,...o}=e;return{...o,load:async n=>{const a=await t(n);$(n.signal);try{return r(a,n)}catch(s){throw new E("validate",`报表 ${n.reportId} 数据映射失败`,s)}}}}class E extends Error{constructor(t,r,o){super(r),this.name="ReportSourceError",this.code=t,this.cause=o}}function ae(e){const t=new Error("报表加载已取消");return t.name="AbortError",Object.defineProperty(t,"cause",{value:e.reason}),t}function $(e){if(e?.aborted)throw ae(e)}function me(e,t){return t?new Promise((r,o)=>{const n=()=>t.removeEventListener("abort",a),a=()=>{n(),o(ae(t))};t.addEventListener("abort",a,{once:!0}),t.aborted&&a(),Promise.resolve(e).then(s=>{n(),r(s)},s=>{n(),o(s)})}):Promise.resolve(e)}function _r(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new E("validate",`报表 ${t} 的数据集应为对象`);for(const[r,o]of Object.entries(e))if(!Array.isArray(o)||o.some(n=>!n||typeof n!="object"||Array.isArray(n)))throw new E("validate",`报表 ${t} 的数据集 ${r} 应为对象数组`)}async function Wr(e,t,r){const{reportId:o,signal:n}=t;try{const a=await me(e(t),n);$(n);const s=L.validateReportTemplate(a);if(!s.ok)throw new E("validate",`报表 ${o} 模板校验失败:${s.errors.slice(0,3).map(i=>`${i.path}: ${i.message}`).join("; ")}`);return r.push(...s.warnings.map(i=>`${o}: ${i.path}: ${i.message}`)),a}catch(a){throw n?.aborted?ae(n):a instanceof E?a:a instanceof L.ReportTemplateError?new E("validate",`报表 ${o} 模板校验失败:${a.message}`,a):new E("fetch",`报表 ${o} 模板加载失败:${a instanceof Error?a.message:String(a)}`,a)}}async function Jr(e,t,r,o){const n=t.signal;let a;try{if(e.load)a=await me(e.load(t),n);else if(e.provider){const s=await me(e.provider.query(t),n);$(n),qr(s,r),a=s.datasets,o?.(r,s)}else a=e.datasets??{}}catch(s){throw n?.aborted?ae(n):s instanceof E?s:new E("fetch",`报表 ${r} 取数失败:${s instanceof Error?s.message:String(s)}`,s)}return $(n),a}function qr(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new E("validate",`报表 ${t} Provider 应返回 datasets 结果对象`);for(const r of["revision","sourceToken"])if(e[r]!==void 0&&typeof e[r]!="string")throw new E("validate",`报表 ${t} Provider ${r} 应为字符串`);if(e.diagnostics!==void 0&&(!Array.isArray(e.diagnostics)||e.diagnostics.some(r=>!r||typeof r.code!="string"||typeof r.message!="string"||!["info","warning","error"].includes(r.severity))))throw new E("validate",`报表 ${t} Provider diagnostics 不符合结构化诊断契约`);if(e.diagnostics?.some(r=>!wt(r)))throw new E("validate",`报表 ${t} Provider 数据说明缺少有效的字段身份或值状态`)}function zr(e,t,r,o,n){try{t=Pe(o,t,{maxRows:e.dataValidation?.maxRows,signal:n})}catch(a){throw new E("validate",`报表 ${r} 树形数据无效:${a instanceof Error?a.message:String(a)}`,a)}for(const[a,s]of Object.entries(e.dataSchema??{})){let i;try{i=Le.validateDatasetRows(Object.prototype.hasOwnProperty.call(t,a)?t[a]:void 0,s,{...e.dataValidation,path:`$.datasets.${a}`})}catch(c){throw new E("config",`报表 ${r} 数据集 ${a} 字段契约配置无效`,c)}if(!i.ok)throw new E("validate",`报表 ${r} 数据集 ${a} 不符合字段契约:${i.issues[0]?.message}`,{issues:i.issues})}}function Mt(e,t){if(!e.repeat)return!1;const r=Object.prototype.hasOwnProperty.call(t,e.repeat.dataset)?t[e.repeat.dataset]:void 0;return Array.isArray(r)&&r.length===0}function vt(e){const t=r=>r.grid?.cells.reduce((o,n)=>o+n.reduce((a,s)=>a+(s?1+(s.children?.reduce((i,c)=>i+t(c),0)??0):0),0),0)??0;return e.pages.reduce((r,o)=>r+o.components.reduce((n,a)=>n+t(a),0),0)}function St(e,t,r,o){return{...e,signal:o??e?.signal,...t===void 0?{}:{maxPages:Math.max(1,Math.min(t,e?.maxPages??t))},...r===void 0?{}:{maxCells:Math.max(1,Math.min(r,e?.maxCells??r))}}}function Ur(e,t,r,o,n,a){const s=n.maxPages===void 0?void 0:n.maxPages-n.usedPages,i=n.maxCells===void 0?void 0:n.maxCells-n.usedCells;try{if(s!==void 0&&s<1&&e.pages.length&&!Mt(e,t))throw new K(0,1);const c=St(r.pagination,s,i,a),d=ve(e,t,c),l=vt(d.plan);if(i!==void 0&&l>i)throw new B(i,l);return{...d,cells:l}}catch(c){let d=c;throw c instanceof K&&n.maxPages!==void 0&&c.limit===s&&(d=new K(n.maxPages,n.usedPages+c.actual)),c instanceof B&&n.maxCells!==void 0&&(d=new B(n.maxCells,n.usedCells+c.actual)),new E("validate",`报表 ${o} 排版失败:${d instanceof Error?d.message:String(d)}`,d)}}function xt(e,t,r,o,n){const a=new Map,s=i=>{let c=a.get(i);return c===void 0&&(c=JSON.stringify([r,o,i]),a.set(i,c)),c};for(const i of t.pages)e.push({...i,meta:{...i.meta,reportScope:Ce(r,o)},components:bt(i.components,n??yt(r,o),s)})}async function Xr(e,t,r,o,n){const a=[];let s=0;for(const[d,l]of e.entries()){$(n);const f=o.maxPages===void 0?void 0:o.maxPages-a.length,u=o.maxCells===void 0?void 0:o.maxCells-s;if(f!==void 0&&f<1&&l.template.pages.length&&!Mt(l.template,l.datasets))throw new K(o.maxPages,a.length+1);const m=await ut(l.template,l.datasets,St(t[d]?.pagination,f,u,n));if(s+=vt(m),o.maxCells!==void 0&&s>o.maxCells)throw new B(o.maxCells,s);xt(a,m,d,r[d],l.sourceScope)}const i={schemaVersion:Y.RENDER_PLAN_SCHEMA_VERSION,...e.some(d=>Z(d.template))?{requiresRecalculation:!0}:{},pages:a},c=L.validateRenderPlan(i);if(!c.ok)throw new E("validate",`重算渲染计划校验失败:${c.errors[0]?.message}`);return i}function Yr(e,t={}){if(t.maxPages!==void 0&&(!Number.isSafeInteger(t.maxPages)||t.maxPages<1))throw new E("config","maxPages 应为正安全整数");if(t.maxCells!==void 0&&(!Number.isSafeInteger(t.maxCells)||t.maxCells<1))throw new E("config","maxCells 应为正安全整数");function r(n){const a=Object.prototype.hasOwnProperty.call(e,n)?e[n]:void 0;if(!a)throw new E("config",`未注册报表 ${n}`);if(a.sourceScope!==void 0&&(typeof a.sourceScope!="string"||!a.sourceScope.trim()||a.sourceScope.length>512))throw new E("config","sourceScope 应为不超过 512 字符的非空字符串");return a}return Object.assign(async({reportIds:n,params:a,signal:s,onWarning:i,onQueryResult:c,...d})=>{$(s);const l=gt({...d,signal:s}),f=[...n],u={...a};if(f.length===0)throw new E("config","缺少报表 ID");const m=f.map(r),h=l.runSync("validate",()=>m.map(p=>$e.assertReportParams(p.params??(typeof p.template=="function"?[]:p.template.params)??[],u))),g=[],w=[];let y=0;const v=[];for(const[p,M]of m.entries()){$(s);const x=f[p],P={reportId:x,params:h[p],signal:s},k=typeof M.template=="function"?await l.run("query",()=>Wr(M.template,P,v),x):M.template;P.params=l.runSync("validate",()=>$e.assertReportParams(M.params??k.params??[],P.params),x);const A=await l.run("query",()=>Jr(M,P,x,(ie,Rt)=>c?.(ie,Rt,p)),x);l.runSync("validate",()=>{_r(A,x),t.onDatasets?.(x,A,k),zr(M,A,x,k,s)},x),$(s);const se=l.runSync("layout",()=>Ur(k,A,M,x,{maxPages:t.maxPages,usedPages:g.length,maxCells:t.maxCells,usedCells:y},s),x);y+=se.cells;const ke=yt(p,x,M.sourceScope);w.push({template:k,datasets:A,sourceScope:ke}),xt(g,se.plan,p,x,ke),v.push(...se.warnings.map(ie=>`${x}: ${ie}`))}$(s);const T={schemaVersion:Y.RENDER_PLAN_SCHEMA_VERSION,...w.some(p=>Z(p.template))?{requiresRecalculation:!0}:{},pages:g},S=l.runSync("validate",()=>{const p=L.validateRenderPlan(T);if(!p.ok)throw new E("validate",`渲染计划校验失败:${p.errors.slice(0,3).map(M=>`${M.path}: ${M.message}`).join("; ")}`);return p});v.push(...S.warnings.map(p=>`${p.path}: ${p.message}`));const N=m.map(p=>({...p,pagination:{...p.pagination}})),F={maxPages:t.maxPages,maxCells:t.maxCells};try{Ee(T,{parts:w,rebuild:(p,M)=>Xr(p,N,f,F,M)})}catch{v.push("来源数据无法建立本地重算口径;当前预览仅支持计划内编辑,请使用可序列化模板数据启用规则重算")}const O=i??t.onWarning??(p=>console.warn("[mach-report]",p));for(const p of v)$(s),O(p);return $(s),T},{getParamDefs:n=>Tt.getReportParamDefs(e,n)})}function Qr(e,t){const r=t.maxNodes??1e6;if(![t.maxBytes,r].every(l=>Number.isSafeInteger(l)&&l>0))throw t.error("budget","快照预算应为正安全整数");let o=0,n=0;const a=new Set;function s(l){if(n+=l,n>t.maxBytes)throw t.error("budget","快照超过字节预算")}function i(l,f){if(++o>r||f>64)throw t.error("budget","快照节点或深度超过预算");if(o%1024===0&&t.check?.(),typeof l=="string")return s(l.length+2),l;if(l===null||typeof l=="boolean"||typeof l=="number"&&Number.isFinite(l))return s(String(l).length),l;if(!l||typeof l!="object"||a.has(l))throw t.error("input","快照应为无循环的有限 JSON 值");return c(l,f)}function c(l,f){const u=Array.isArray(l),m=Object.getPrototypeOf(l);if(m!==(u?Array.prototype:Object.prototype)&&!(m===null&&!u)||Object.getOwnPropertySymbols(l).length)throw t.error("input","快照应为普通 JSON 对象");const h=Object.getOwnPropertyNames(l).filter(y=>!(u&&y==="length"));if(u&&(h.length!==l.length||h.some((y,v)=>y!==String(v))))throw t.error("input","快照数组应为连续数组");a.add(l),s(2);const g=Object.create(null);let w=0;for(const y of h){const v=Object.getOwnPropertyDescriptor(l,y);if(v.get||v.set||!v.enumerable||["__proto__","constructor","prototype"].includes(y))throw t.error("input","快照不允许访问器或危险键");v.value===void 0&&!u||(s((w++?1:0)+(u?0:y.length+3)),g[y]=i(v.value===void 0?null:v.value,f+1))}return a.delete(l),u?h.map(y=>g[y]):g}t.check?.();const d=JSON.stringify(i(e,0));if(new TextEncoder().encode(d).byteLength>t.maxBytes)throw t.error("budget","快照超过字节预算");return JSON.parse(d)}exports.DEFAULT_LABEL_PAGE_LIMIT=Be;exports.PaginateCellLimitError=B;exports.PaginatePageLimitError=K;exports.ReportCellEditError=b;exports.ReportSourceError=E;exports.applyReportCellEdit=xr;exports.applyReportCellEditBatch=Cr;exports.applyReportEditResult=st;exports.applyReportSourceMetadata=Re;exports.countTemplatePages=ar;exports.createReportCellEdit=yr;exports.createReportCellEditBatch=Pr;exports.createReportCellResolver=j;exports.createReportEditSession=Br;exports.createReportSource=Yr;exports.createReportTaskReporter=gt;exports.defineReport=Vr;exports.estimateListLayoutCells=cr;exports.formatReportCellEdit=H;exports.getReportCellContext=ne;exports.getReportEditSession=Ar;exports.hasValidDataExplanation=wt;exports.isReportDataTarget=ht;exports.isReportValueState=pt;exports.notifyReportTaskEvent=fe;exports.paginateTemplate=ve;exports.paginateTemplatePages=Qe;exports.parseReportCellInput=Se;exports.projectListColumns=je;exports.registerReportEditSession=Ee;exports.relocateReportCellEdits=$r;exports.reportCellEditKey=I;exports.reportOccurrenceScope=Ce;exports.reportTaskId=mt;exports.snapshotReportJson=Qr;exports.summarizeReportCellEdits=kr;exports.templateDatasetJsonSchema=Gr;exports.templateDatasetRowCount=Hr;exports.templateValidationDatasets=Pe;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
--- LICENSE ---
|
|
2
|
+
bwip-js : Barcode Writer in Pure JavaScript
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2011-2026 Mark Warren
|
|
5
|
+
|
|
6
|
+
The MIT License
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
in the Software without restriction, including without limitation the rights
|
|
11
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
furnished to do so, subject to the following conditions:
|
|
14
|
+
|
|
15
|
+
The above copyright notice and this permission notice shall be included in
|
|
16
|
+
all copies or substantial portions of the Software.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
24
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
--- LICENSE ---
|
|
2
|
+
The MIT License
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2011-2019 C2FO
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in
|
|
14
|
+
all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
22
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
--- LICENSE ---
|
|
2
|
+
The MIT License
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2011-2019 C2FO
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in
|
|
14
|
+
all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
22
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
--- README.md ---
|
|
2
|
+
# Purpose of this Fork
|
|
3
|
+
This project is a fork of https://github.com/foliojs/fontkit created for use in https://github.com/Hopding/pdf-lib.
|
|
4
|
+
|
|
5
|
+
Listed below are changes that have been made in this fork:
|
|
6
|
+
|
|
7
|
+
* Store binary data as compressed base64 JSON so the `fs` module isn't needed to read it back:
|
|
8
|
+
* [968e35c](https://github.com/Hopding/fontkit/commit/968e35c158589294e9543818f56d0b229b95a475)
|
|
9
|
+
* [99a35c7](/Hopding/fontkit/commit/99a35c7b0f0f6549d7727bcbc1ddabb7f9ca19bf)
|
|
10
|
+
* [2f1445d](/Hopding/fontkit/commit/2f1445d9a3f8426bc259690819eea8306a98545a)
|
|
11
|
+
* [f674bf2-R24](https://github.com/Hopding/fontkit/commit/f674bf2e3c8a8e0a34083e19f0abe65df20520e3#diff-b61f8676a8a37c519e9c3c86c4676208R24), [f674bf2-R13](https://github.com/Hopding/fontkit/commit/f674bf2e3c8a8e0a34083e19f0abe65df20520e3#diff-a73febb5d14ad8d9d7ab6ac378a698aaR13)
|
|
12
|
+
* Rewrote `Makefile` to `Makefile.js` using `shelljs`:
|
|
13
|
+
* [a246e7f](https://github.com/Hopding/fontkit/commit/a246e7fda8c0bb5df4be355a993e0ba59f07300e)
|
|
14
|
+
* Update to Babel 7:
|
|
15
|
+
* [70049f8](https://github.com/Hopding/fontkit/commit/70049f8f038145cc0caca83c75e0b76f49d11f52)
|
|
16
|
+
* [8d5b29b](https://github.com/Hopding/fontkit/commit/8d5b29bd00b752a6ab9348e6be1997e201055d31)
|
|
17
|
+
* Build UMD modules:
|
|
18
|
+
* [cce995c](https://github.com/Hopding/fontkit/commit/cce995c3378c35b247ed2965e15eb92ffad9ea09)
|
|
19
|
+
* [08cacef](https://github.com/Hopding/fontkit/commit/08cacefa3e745f83a2c95051e38985b02aa2f16d)
|
|
20
|
+
* Build ES modules:
|
|
21
|
+
* [dbe8e9d](https://github.com/Hopding/fontkit/commit/dbe8e9da4e8f2e23f507ba5a767a8109e81fb7ab)
|
|
22
|
+
* [9363d1f](https://github.com/Hopding/fontkit/commit/9363d1f8e97985d8a94ee6dac1fac39631ee3c77)
|
|
23
|
+
* Bundle Node dependencies (`stream`, `util`, `Buffer`) into UMD and ES modules so consumers of this lib don't have to deal with them:
|
|
24
|
+
* [9363d1f](https://github.com/Hopding/fontkit/commit/9363d1f8e97985d8a94ee6dac1fac39631ee3c77)
|
|
25
|
+
* Accept `Uint8Array` objects for font data instead of `Buffer` objects, so consumers can stick to plain JS regardless of their environment:
|
|
26
|
+
* [9363d1f-R12](https://github.com/Hopding/fontkit/commit/9363d1f8e97985d8a94ee6dac1fac39631ee3c77#diff-d7e697eff3913f1acaacac8002c3b05eR12)
|
|
27
|
+
* Add TypeScript declaration file:
|
|
28
|
+
* [387ebc4](https://github.com/Hopding/fontkit/commit/387ebc418cc04be51d82d39e05f4db01b1bf063f)
|
|
29
|
+
* [3bafdbc](https://github.com/Hopding/fontkit/commit/3bafdbc3656ebba5251f8d4dc77dcc4b6c11afa6)
|
|
30
|
+
* [b0241e7](https://github.com/Hopding/fontkit/commit/b0241e7c30cdb83bda6867aa8c9229c1ab1cb8e3)
|
|
31
|
+
* Remove calls to `new Function()` to allow usage on CSP sites:
|
|
32
|
+
* [e3dcc8a](https://github.com/Hopding/fontkit/commit/e3dcc8aad014081b8106c47d89049ba9e6f3dd48)
|
|
33
|
+
* Released to NPM as `@pdf-lib/fontkit`
|
|
34
|
+
* [873b05d](https://github.com/Hopding/fontkit/commit/873b05d23aecb9f0142fc3ebda593fd2a7d81c17)
|
|
35
|
+
|
|
36
|
+
Also see
|
|
37
|
+
* https://github.com/Hopding/unicode-properties
|
|
38
|
+
* https://github.com/Hopding/brotli.js
|
|
39
|
+
* https://github.com/Hopding/restructure
|
|
40
|
+
* https://github.com/Hopding/png-ts
|
|
41
|
+
|
|
42
|
+
# fontkit
|
|
43
|
+
|
|
44
|
+
Fontkit is an advanced font engine for Node and the browser, used by [PDFKit](https://github.com/devongovett/pdfkit) and [`pdf-lib`](https://github.com/Hopding/pdf-lib). It supports many font formats, advanced glyph substitution and layout features, glyph path extraction, color emoji glyphs, font subsetting, and more.
|
|
45
|
+
|
|
46
|
+
## Features
|
|
47
|
+
|
|
48
|
+
* Suports TrueType (.ttf), OpenType (.otf), WOFF, WOFF2, TrueType Collection (.ttc), and Datafork TrueType (.dfont) font files
|
|
49
|
+
* Supports mapping characters to glyphs, including support for ligatures and other advanced substitutions (see below)
|
|
50
|
+
* Supports reading glyph metrics and laying out glyphs, including support for kerning and other advanced layout features (see below)
|
|
51
|
+
* Advanced OpenType features including glyph substitution (GSUB) and positioning (GPOS)
|
|
52
|
+
* Apple Advanced Typography (AAT) glyph substitution features (morx table)
|
|
53
|
+
* Support for getting glyph vector paths and converting them to SVG paths, or rendering them to a graphics context
|
|
54
|
+
* Supports TrueType (glyf) and PostScript (CFF) outlines
|
|
55
|
+
* Support for color glyphs (e.g. emoji), including Apple’s SBIX table, and Microsoft’s COLR table
|
|
56
|
+
* Support for AAT variation glyphs, allowing for nearly infinite design control over weight, width, and other axes.
|
|
57
|
+
* Font subsetting support - create a new font including only the specified glyphs
|
|
58
|
+
|
|
59
|
+
## Example
|
|
60
|
+
|
|
61
|
+
```js
|
|
62
|
+
import fontkit from '@pdf-lib/fontkit';
|
|
63
|
+
import fs from 'fs';
|
|
64
|
+
|
|
65
|
+
// open a font synchronously
|
|
66
|
+
const fontData = fs.readFileSync('font.ttf');
|
|
67
|
+
const font = fontkit.create(fontData);
|
|
68
|
+
|
|
69
|
+
// layout a string, using default shaping features.
|
|
70
|
+
// returns a GlyphRun, describing glyphs and positions.
|
|
71
|
+
const run = font.layout('hello world!');
|
|
72
|
+
|
|
73
|
+
// get an SVG path for a glyph
|
|
74
|
+
const svg = run.glyphs[0].path.toSVG();
|
|
75
|
+
|
|
76
|
+
// create a font subset
|
|
77
|
+
const subset = font.createSubset();
|
|
78
|
+
run.glyphs.forEach(function(glyph) {
|
|
79
|
+
subset.includeGlyph(glyph);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
subset.encodeStream()
|
|
83
|
+
.pipe(fs.createWriteStream('subset.ttf'));
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Installation
|
|
87
|
+
### NPM Module
|
|
88
|
+
To install the latest stable version:
|
|
89
|
+
```bash
|
|
90
|
+
# With npm
|
|
91
|
+
npm install --save @pdf-lib/fontkit
|
|
92
|
+
|
|
93
|
+
# With yarn
|
|
94
|
+
yarn add @pdf-lib/fontkit
|
|
95
|
+
```
|
|
96
|
+
This assumes you're using [npm](https://www.npmjs.com/) or [yarn](https://yarnpkg.com/lang/en/) as your package manager.
|
|
97
|
+
|
|
98
|
+
### UMD Module
|
|
99
|
+
You can also download `@pdf-lib/fontkit` as a UMD module from [unpkg](https://unpkg.com/#/). The UMD builds have been compiled to ES5, so they should work [in any modern browser](https://caniuse.com/#feat=es5). UMD builds are useful if you aren't using a package manager or module bundler. For example, you can use them directly in the `<script>` tag of an HTML page.
|
|
100
|
+
|
|
101
|
+
The following builds are available:
|
|
102
|
+
|
|
103
|
+
* https://unpkg.com/@pdf-lib/fontkit/dist/fontkit.umd.js
|
|
104
|
+
* https://unpkg.com/@pdf-lib/fontkit/dist/fontkit.umd.min.js
|
|
105
|
+
|
|
106
|
+
When using a UMD build, you will have access to a global `window.fontkit` variable. This variable contains the object exported by `@pdf-lib/fontkit`. For example:
|
|
107
|
+
|
|
108
|
+
```javascript
|
|
109
|
+
// NPM module
|
|
110
|
+
import fontkit from '@pdf-lib/fontkit';
|
|
111
|
+
|
|
112
|
+
// UMD module
|
|
113
|
+
var fontkit = window.fontkit;
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## API
|
|
117
|
+
|
|
118
|
+
### `fontkit.create(buffer, postscriptName = null)`
|
|
119
|
+
|
|
120
|
+
Returns a font object for the given buffer. For collection fonts (such as TrueType collection files), you can pass a `postscriptName` to get that font out of the collection instead of a collection object.
|
|
121
|
+
|
|
122
|
+
## Font objects
|
|
123
|
+
|
|
124
|
+
There are several different types of font objects that are returned by fontkit depending on the font format. They all inherit from the `TTFFont` class and have the same public API, described below.
|
|
125
|
+
|
|
126
|
+
### Metadata properties
|
|
127
|
+
|
|
128
|
+
The following properties are strings (or null if the font does not contain strings for them) describing the font, as specified by the font creator.
|
|
129
|
+
|
|
130
|
+
* `postscriptName`
|
|
131
|
+
* `fullName`
|
|
132
|
+
* `familyName`
|
|
133
|
+
* `subfamilyName`
|
|
134
|
+
* `copyright`
|
|
135
|
+
* `version`
|
|
136
|
+
|
|
137
|
+
### Metrics
|
|
138
|
+
|
|
139
|
+
The following properties describe the general metrics of the font. See [here](http://www.freetype.org/freetype2/docs/glyphs/glyphs-3.html) for a good overview of how all of these properties relate to one another.
|
|
140
|
+
|
|
141
|
+
* `unitsPerEm` - the size of the font’s internal coordinate grid
|
|
142
|
+
* `ascent` - the font’s [ascender](http://en.wikipedia.org/wiki/Ascender_(typography))
|
|
143
|
+
* `descent` - the font’s [descender](http://en.wikipedia.org/wiki/Descender)
|
|
144
|
+
* `lineGap` - the amount of space that should be included between lines
|
|
145
|
+
* `underlinePosition` - the offset from the normal underline position that should be used
|
|
146
|
+
* `underlineThickness` - the weight of the underline that should be used
|
|
147
|
+
* `italicAngle` - if this is an italic font, the angle the cursor should be drawn at to match the font design
|
|
148
|
+
* `capHeight` - the height of capital letters above the baseline. See [here](http://en.wikipedia.org/wiki/Cap_height) for more details.
|
|
149
|
+
* `xHeight`- the height of lower case letters. See [here](http://en.wikipedia.org/wiki/X-height) for more details.
|
|
150
|
+
* `bbox` - the font’s bounding box, i.e. the box that encloses all glyphs in the font
|
|
151
|
+
|
|
152
|
+
### Other properties
|
|
153
|
+
|
|
154
|
+
* `numGlyphs` - the number of glyphs in the font
|
|
155
|
+
* `characterSet` - an array of all of the unicode code points supported by the font
|
|
156
|
+
* `availableFeatures` - an array of all [OpenType feature tags](https://www.microsoft.com/typography/otspec/featuretags.htm) (or mapped AAT tags) supported by the font (see below for a description of this)
|
|
157
|
+
|
|
158
|
+
### Character to glyph mapping
|
|
159
|
+
|
|
160
|
+
Fontkit includes several methods for character to glyph mapping, including support for advanced OpenType and AAT substitutions.
|
|
161
|
+
|
|
162
|
+
#### `font.glyphForCodePoint(codePoint)`
|
|
163
|
+
|
|
164
|
+
Maps a single unicode code point (number) to a Glyph object. Does not perform any advanced substitutions (there is no context to do so).
|
|
165
|
+
|
|
166
|
+
#### `font.hasGlyphForCodePoint(codePoint)`
|
|
167
|
+
|
|
168
|
+
Returns whether there is glyph in the font for the given unicode code point.
|
|
169
|
+
|
|
170
|
+
#### `font.glyphsForString(string)`
|
|
171
|
+
|
|
172
|
+
This method returns an array of Glyph objects for the given string. This is only a one-to-one mapping from characters
|
|
173
|
+
to glyphs. For most uses, you should use `font.layout` (described below), which provides a much more advanced mapping
|
|
174
|
+
supporting AAT and OpenType shaping.
|
|
175
|
+
|
|
176
|
+
### Glyph metrics and layout
|
|
177
|
+
|
|
178
|
+
Fontkit includes several methods for accessing glyph metrics and performing layout, including support for kerning and other advanced OpenType positioning adjustments.
|
|
179
|
+
|
|
180
|
+
#### `font.widthOfGlyph(glyph_id)`
|
|
181
|
+
|
|
182
|
+
Returns the advance width (described above) for a single glyph id.
|
|
183
|
+
|
|
184
|
+
#### `font.layout(string, features = [])`
|
|
185
|
+
|
|
186
|
+
This method returns a `GlyphRun` object, which includes an array of `Glyph`s and `GlyphPosition`s for the given string.
|
|
187
|
+
`Glyph` objects are described below. `GlyphPosition` objects include 4 properties: `xAdvance`, `yAdvance`, `xOffset`,
|
|
188
|
+
and `yOffset`.
|
|
189
|
+
|
|
190
|
+
The `features` parameter is an array of [OpenType feature tags](https://www.microsoft.com/typography/otspec/featuretags.htm) to be applied
|
|
191
|
+
in addition to the default set. If this is an AAT font, the OpenType feature tags are mapped to AAT features.
|
|
192
|
+
|
|
193
|
+
### Variation fonts
|
|
194
|
+
|
|
195
|
+
Fontkit has support for AAT variation fonts, where glyphs can adjust their shape according to user defined settings along
|
|
196
|
+
various axes including weight, width, and slant. Font designers specify the minimum, default, and maximum values for each
|
|
197
|
+
axis they support, and allow the user fine grained control over the rendered text.
|
|
198
|
+
|
|
199
|
+
#### `font.variationAxes`
|
|
200
|
+
|
|
201
|
+
Returns an object describing the available variation axes. Keys are 4 letter axis tags, and values include `name`,
|
|
202
|
+
`min`, `default`, and `max` properties for the axis.
|
|
203
|
+
|
|
204
|
+
#### `font.namedVariations`
|
|
205
|
+
|
|
206
|
+
The font designer may have picked out some variations that they think look particularly good, for example a light, regular,
|
|
207
|
+
and bold weight which would traditionally be separate fonts. This property returns an object describing these named variation
|
|
208
|
+
instances that the designer has specified. Keys are variation names, and values are objects with axis settings.
|
|
209
|
+
|
|
210
|
+
#### `font.getVariation(variation)`
|
|
211
|
+
|
|
212
|
+
Returns a new font object representing this variation, from which you can get glyphs and perform layout as normal.
|
|
213
|
+
The `variation` parameter can either be a variation settings object or a string variation name. Variation settings objects
|
|
214
|
+
have axis names as keys, and numbers as values (should be in the range specified by `font.variationAxes`).
|
|
215
|
+
|
|
216
|
+
### Other methods
|
|
217
|
+
|
|
218
|
+
#### `font.getGlyph(glyph_id, codePoints = [])`
|
|
219
|
+
|
|
220
|
+
Returns a glyph object for the given glyph id. You can pass the array of code points this glyph represents for your use later, and it will be stored in the glyph object.
|
|
221
|
+
|
|
222
|
+
#### `font.createSubset()`
|
|
223
|
+
|
|
224
|
+
Returns a Subset object for this font, described below.
|
|
225
|
+
|
|
226
|
+
## Font Collection objects
|
|
227
|
+
|
|
228
|
+
For font collection files that contain multiple fonts in a single file, such as TrueType Collection (.ttc) and Datafork TrueType (.dfont) files, a font collection object can be returned by Fontkit.
|
|
229
|
+
|
|
230
|
+
### `collection.getFont(postscriptName)`
|
|
231
|
+
|
|
232
|
+
Gets a font from the collection by its postscript name. Returns a Font object, described above.
|
|
233
|
+
|
|
234
|
+
### `collection.fonts`
|
|
235
|
+
|
|
236
|
+
This property is a lazily-loaded array of all of the fonts in the collection.
|
|
237
|
+
|
|
238
|
+
## Glyph objects
|
|
239
|
+
|
|
240
|
+
Glyph objects represent a glyph in the font. They have various properties for accessing metrics and the actual vector path the glyph represents, and methods for rendering the glyph to a graphics context.
|
|
241
|
+
|
|
242
|
+
You do not create glyph objects directly. They are created by various methods on the font object, described above. There are several subclasses of the base `Glyph` class internally that may be returned depending on the font format, but they all include the following API.
|
|
243
|
+
|
|
244
|
+
### Properties
|
|
245
|
+
|
|
246
|
+
* `id` - the glyph id in the font
|
|
247
|
+
* `codePoints` - an array of unicode code points that are represented by this glyph. There can be multiple code points in the case of ligatures and other glyphs that represent multiple visual characters.
|
|
248
|
+
* `path` - a vector Path object representing the glyph
|
|
249
|
+
* `bbox` - the glyph’s bounding box, i.e. the rectangle that encloses the glyph outline as tightly as possible.
|
|
250
|
+
* `cbox` - the glyph’s control box. This is often the same as the bounding box, but is faster to compute. Because of the way bezier curves are defined, some of the control points can be outside of the bounding box. Where `bbox` takes this into account, `cbox` does not. Thus, `cbox` is less accurate, but faster to compute. See [here](http://www.freetype.org/freetype2/docs/glyphs/glyphs-6.html#section-2) for a more detailed description.
|
|
251
|
+
* `advanceWidth` - the glyph’s advance width.
|
|
252
|
+
|
|
253
|
+
### `glyph.render(ctx, size)`
|
|
254
|
+
|
|
255
|
+
Renders the glyph to the given graphics context, at the specified font size.
|
|
256
|
+
|
|
257
|
+
### Color glyphs (e.g. emoji)
|
|
258
|
+
|
|
259
|
+
Fontkit has support for several different color emoji font formats. Currently, these include Apple’s SBIX table (as used by the “Apple Color Emoji” font), and Microsoft’s COLR table (supported by Windows 8.1). [Here](http://blog.symbolset.com/multicolor-fonts) is an overview of the various color font formats out there.
|
|
260
|
+
|
|
261
|
+
#### `glyph.getImageForSize(size)`
|
|
262
|
+
|
|
263
|
+
For SBIX glyphs, which are bitmap based, this returns an object containing some properties about the image, along with the image data itself (usually PNG).
|
|
264
|
+
|
|
265
|
+
#### `glyph.layers`
|
|
266
|
+
|
|
267
|
+
For COLR glyphs, which are vector based, this returns an array of objects representing the glyphs and colors for each layer in render order.
|
|
268
|
+
|
|
269
|
+
## Path objects
|
|
270
|
+
|
|
271
|
+
Path objects are returned by glyphs and represent the actual vector outlines for each glyph in the font. Paths can be converted to SVG path data strings, or to functions that can be applied to render the path to a graphics context.
|
|
272
|
+
|
|
273
|
+
### `path.moveTo(x, y)`
|
|
274
|
+
|
|
275
|
+
Moves the virtual pen to the given x, y coordinates.
|
|
276
|
+
|
|
277
|
+
### `path.lineTo(x, y)`
|
|
278
|
+
|
|
279
|
+
Adds a line to the path from the current point to the given x, y coordinates.
|
|
280
|
+
|
|
281
|
+
### `path.quadraticCurveTo(cpx, cpy, x, y)`
|
|
282
|
+
|
|
283
|
+
Adds a quadratic curve to the path from the current point to the given x, y coordinates using cpx, cpy as a control point.
|
|
284
|
+
|
|
285
|
+
### `path.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y)`
|
|
286
|
+
|
|
287
|
+
Adds a bezier curve to the path from the current point to the given x, y coordinates using cp1x, cp1y and cp2x, cp2y as control points.
|
|
288
|
+
|
|
289
|
+
### `path.closePath()`
|
|
290
|
+
|
|
291
|
+
Closes the current sub-path by drawing a straight line back to the starting point.
|
|
292
|
+
|
|
293
|
+
### `path.toFunction()`
|
|
294
|
+
|
|
295
|
+
Compiles the path to a JavaScript function that can be applied with a graphics context in order to render the path.
|
|
296
|
+
|
|
297
|
+
### `path.toSVG()`
|
|
298
|
+
|
|
299
|
+
Converts the path to an SVG path data string.
|
|
300
|
+
|
|
301
|
+
### `path.bbox`
|
|
302
|
+
|
|
303
|
+
This property represents the path’s bounding box, i.e. the smallest rectangle that contains the entire path shape. This is the exact bounding box, taking into account control points that may be outside the visible shape.
|
|
304
|
+
|
|
305
|
+
### `path.cbox`
|
|
306
|
+
|
|
307
|
+
This property represents the path’s control box. It is like the bounding box, but it includes all points of the path, including control points of bezier segments. It is much faster to compute than the real bounding box, but less accurate if there are control points outside of the visible shape.
|
|
308
|
+
|
|
309
|
+
## Subsets
|
|
310
|
+
|
|
311
|
+
Fontkit can perform font subsetting, i.e. the process of creating a new font from an existing font where only the specified glyphs are included. This is useful to reduce the size of large fonts, such as in PDF generation or for web use.
|
|
312
|
+
|
|
313
|
+
Currently, subsets produce minimal fonts designed for PDF embedding that may not work as standalone files. They have no cmap tables and other essential tables for standalone use. This limitation will be removed in the future.
|
|
314
|
+
|
|
315
|
+
You create a Subset object by calling `font.createSubset()`, described above. The API on Subset objects is as follows.
|
|
316
|
+
|
|
317
|
+
### `subset.includeGlyph(glyph)`
|
|
318
|
+
|
|
319
|
+
Includes the given glyph object or glyph ID in the subset.
|
|
320
|
+
|
|
321
|
+
### `subset.encodeStream()`
|
|
322
|
+
|
|
323
|
+
Returns a [stream](https://nodejs.org/api/stream.html) containing the encoded font file that can be piped to a destination, such as a file.
|
|
324
|
+
|
|
325
|
+
## License
|
|
326
|
+
[MIT](https://choosealicense.com/licenses/mit/)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
--- LICENSE.md ---
|
|
2
|
+
MIT License
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2018 Andrew Dillon
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
--- LICENSE ---
|
|
2
|
+
MIT License
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2017 Photopea
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
--- LICENSE ---
|
|
2
|
+
MIT License
|
|
3
|
+
|
|
4
|
+
Copyright (c) Microsoft Corporation.
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
--- LICENSE ---
|
|
2
|
+
MIT License
|
|
3
|
+
|
|
4
|
+
Copyright (c) Microsoft Corporation.
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE
|