@agile-team/mach-report 2.14.0 → 2.15.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 +16 -11
- package/THIRD_PARTY_NOTICES.md +3 -1
- package/dist/{ExcelBindingWizard-CvsWR8Ga.js → ExcelBindingWizard-BKH1nGNS.js} +3 -3
- package/dist/{ExcelBindingWizard-CLT2p7P3.cjs → ExcelBindingWizard-Bs43BGNp.cjs} +1 -1
- package/dist/ParamEditor-Da4akw6V.cjs +1 -0
- package/dist/ParamEditor-DoAhzJsm.js +594 -0
- package/dist/{ReportBatchPanel-LqVgiqp7.js → ReportBatchPanel-BMf6boMA.js} +39 -39
- package/dist/{ReportBatchPanel-DkxTzBkD.cjs → ReportBatchPanel-wP9m9Pj1.cjs} +1 -1
- package/dist/ReportPreview-ChV19HBp.js +4619 -0
- package/dist/ReportPreview-DbLvvOUT.cjs +6 -0
- package/dist/{ReportTemplateLibrary-MjWEtc7X.js → ReportTemplateLibrary-C9wutIiT.js} +1 -1
- package/dist/{ReportTemplateLibrary-cQ1sqNYo.cjs → ReportTemplateLibrary-Sxr3eD0J.cjs} +1 -1
- package/dist/{RuleEditor-ChuXMlei.js → RuleEditor-C_Clasvd.js} +5 -5
- package/dist/{RuleEditor-BaR6xUiI.cjs → RuleEditor-XhGHK8DE.cjs} +1 -1
- package/dist/{TemplateOutlinePanel-Dci6aRn1.js → TemplateOutlinePanel-D6Bkny59.js} +2 -2
- package/dist/{TemplateOutlinePanel-BHKP89Xz.cjs → TemplateOutlinePanel-JTSR53vJ.cjs} +1 -1
- package/dist/{TemplateReusePanel-CY5eO2Sh.cjs → TemplateReusePanel-Kx35S0Ql.cjs} +1 -1
- package/dist/{TemplateReusePanel-B7Gmyc1z.js → TemplateReusePanel-rVuK1kTz.js} +2 -2
- package/dist/{TemplateReviewPanel-DjlX3xpt.js → TemplateReviewPanel-B0ar9_zf.js} +2 -2
- package/dist/{TemplateReviewPanel-JvZe9_4G.cjs → TemplateReviewPanel-Dn6X9UmY.cjs} +1 -1
- package/dist/analytics.cjs +1 -1
- package/dist/analytics.d.cts +3 -1
- package/dist/analytics.d.ts +3 -1
- package/dist/analytics.js +154 -60
- package/dist/artifact-integrity.json +135 -0
- package/dist/assets-B9ImAi6_.cjs +1 -0
- package/dist/assets-DEaz4qsp.js +124 -0
- package/dist/batch-BaP6pWDE.cjs +1 -0
- package/dist/batch-BfZHN1do.js +220 -0
- package/dist/batch-CGyt-b2W.js +273 -0
- package/dist/batch-CLpELXBl.cjs +1 -0
- package/dist/capabilities-CAh2Nrue.cjs +1 -0
- package/dist/capabilities-DskCHs3V.js +69 -0
- package/dist/codes.d.cts +2 -0
- package/dist/codes.d.ts +2 -0
- package/dist/{computed-Bvk0W15F.js → computed-C-4C2S5h.js} +3 -3
- package/dist/config-BVsJXSqS.js +842 -0
- package/dist/config-D10us76d.cjs +1 -0
- package/dist/data-explanation-B8MZRYVS.js +16 -0
- package/dist/data-explanation-DE55G30w.cjs +1 -0
- package/dist/designer-2bDlcNXQ.js +5136 -0
- package/dist/designer-BT7XCdbW.cjs +2 -0
- package/dist/designer.cjs +1 -1
- package/dist/designer.d.cts +144 -16
- package/dist/designer.d.ts +144 -16
- package/dist/designer.js +1 -1
- package/dist/drill-ByJviLXS.js +145 -0
- package/dist/drill-DYTxuL3A.cjs +1 -0
- package/dist/{font-loader-vhCT8znW.cjs → font-loader-B_UkxpzC.cjs} +1 -1
- package/dist/{font-loader-DHto6Lra.js → font-loader-Q3bQjmrI.js} +1 -1
- package/dist/index.cjs +8 -8
- package/dist/index.d.cts +82 -4
- package/dist/index.d.ts +82 -4
- package/dist/index.js +785 -820
- package/dist/json-snapshot-DFb2eWkf.js +1416 -0
- package/dist/json-snapshot-WWSGlaHG.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-8UPQebOE.js → pdf-BwNyeGpt.js} +4385 -4321
- package/dist/{pdf-AyJGb22z.cjs → pdf-CvvrjPQg.cjs} +51 -49
- package/dist/pdf.cjs +1 -1
- package/dist/pdf.d.cts +18 -3
- package/dist/pdf.d.ts +18 -3
- package/dist/pdf.js +2 -2
- package/dist/{plugin-BGKf-Tqg.js → plugin-Ca_XZG3l.js} +2 -2
- package/dist/{plugin-CktLH_Iy.cjs → plugin-DHO7X8z2.cjs} +1 -1
- package/dist/prepared-CFy9B75C.cjs +1 -0
- package/dist/prepared-ajM-H-9B.js +69 -0
- package/dist/progress-B0ctFpKf.cjs +1 -0
- package/dist/progress-D-OTpEav.js +52 -0
- package/dist/record-bindings-By_UKZ2g.cjs +1 -0
- package/dist/record-bindings-Do_b3h4V.js +196 -0
- package/dist/{region-binding-workflow-DEJbhpCv.js → region-binding-workflow-BMhK_TjP.js} +1 -1
- package/dist/{region-binding-workflow-BzfbxRiR.cjs → region-binding-workflow-DIYJdCUr.cjs} +1 -1
- 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/sbom.cdx.json +3982 -0
- package/dist/server/node.d.cts +20 -1
- package/dist/server/node.d.ts +20 -1
- package/dist/server-node.cjs +1 -1
- package/dist/server-node.js +247 -237
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +772 -4
- package/dist/server.d.ts +772 -4
- package/dist/server.js +885 -645
- package/dist/sha256-ArEYjaTI.cjs +1 -0
- package/dist/sha256-DPEuJ3nh.js +155 -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-FJE_c9Qe.cjs +1 -0
- package/dist/template-catalog-j2B1MJlL.js +414 -0
- package/dist/{template-fragments-CLkGo6To.js → template-fragments-BGbQLGlV.js} +21 -21
- package/dist/{template-fragments-DFUpq5QM.cjs → template-fragments-DcKeiylI.cjs} +1 -1
- 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-COXDEJEM.js → template-registry-BtaKPELV.js} +364 -201
- package/dist/template-registry-Co1zPq5e.cjs +1 -0
- package/dist/textwrap-CWHyzkBH.cjs +4 -0
- package/dist/textwrap-DE1kgcJB.js +110 -0
- package/dist/{tree-CqcQ99NM.js → tree-CjVZLRw7.js} +1 -1
- package/dist/vue/async.d.cts +123 -14
- package/dist/vue/async.d.ts +123 -14
- package/dist/vue/index.d.cts +158 -22
- package/dist/vue/index.d.ts +158 -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-DNa2RHNG.cjs → workbook-session-Bjv1YCRK.cjs} +18 -18
- package/dist/{workbook-session-BfK1yHOO.js → workbook-session-BvToI-Fd.js} +5440 -5288
- package/dist/worker.cjs +1 -1
- package/dist/worker.d.cts +20 -1
- package/dist/worker.d.ts +20 -1
- package/dist/worker.js +33 -32
- package/dist/xlsx-node.cjs +34 -34
- package/dist/xlsx-node.js +878 -870
- package/dist/xlsx.cjs +3 -4
- package/dist/xlsx.d.cts +22 -10
- package/dist/xlsx.d.ts +22 -10
- package/dist/xlsx.js +261 -253
- package/package.json +2 -2
- 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/designer-Ci1LizA9.js +0 -5020
- package/dist/designer-rtmVIIdN.cjs +0 -2
- 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/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-D3SjENi6.cjs +0 -1
- package/dist/validate-BJ5HIWY8.cjs +0 -1
- package/dist/validate-CkQBWCeg.js +0 -163
package/dist/pdf.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./font-loader-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./font-loader-B_UkxpzC.cjs"),t=require("./pdf-CvvrjPQg.cjs");exports.clearFontCache=e.clearFontCache;exports.configureFontCache=e.configureFontCache;exports.getFontCacheStats=e.getFontCacheStats;exports.invalidateFontCache=e.invalidateFontCache;exports.loadFontWithCache=e.loadFontWithCache;exports.createFontBytesMeasurer=t.createFontBytesMeasurer;exports.renderPlanToPdf=t.renderPlanToPdf;
|
package/dist/pdf.d.cts
CHANGED
|
@@ -9,7 +9,7 @@ declare interface AssetRenderBudget {
|
|
|
9
9
|
maxDurationMs?: number;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
declare interface AssetRenderOptions extends OutputDiagnosticOptions {
|
|
12
|
+
declare interface AssetRenderOptions extends OutputDiagnosticOptions, ImageMediaOptions {
|
|
13
13
|
assetRenderers?: Partial<Record<ImageComponentKind, ComponentImageRenderer>>;
|
|
14
14
|
assetBudget?: AssetRenderBudget;
|
|
15
15
|
/** Default throw prevents an incomplete export; placeholder retains the component and emits diagnostics. */
|
|
@@ -164,6 +164,19 @@ declare interface GridCell {
|
|
|
164
164
|
|
|
165
165
|
declare type ImageComponentKind = "image" | "chart" | "barcode" | "qrcode";
|
|
166
166
|
|
|
167
|
+
/** Bounded binary image inspection shared by PDF, Excel and template import. No decoder is loaded. */
|
|
168
|
+
export declare interface ImageMediaOptions {
|
|
169
|
+
maxImageBytes?: number;
|
|
170
|
+
maxTotalImageBytes?: number;
|
|
171
|
+
maxImages?: number;
|
|
172
|
+
/** Decoded pixels per unique image, default 16 million. */
|
|
173
|
+
maxImagePixels?: number;
|
|
174
|
+
/** Total decoded pixels for unique media, default 64 million. */
|
|
175
|
+
maxTotalImagePixels?: number;
|
|
176
|
+
/** Maximum source dimension, default 16384 pixels. */
|
|
177
|
+
maxImageDimension?: number;
|
|
178
|
+
}
|
|
179
|
+
|
|
167
180
|
/** Invalidating or clearing also fences late downloads from repopulating the cache. */
|
|
168
181
|
export declare function invalidateFontCache(url: string): Promise<void>;
|
|
169
182
|
|
|
@@ -175,7 +188,7 @@ export declare function invalidateFontCache(url: string): Promise<void>;
|
|
|
175
188
|
export declare function loadFontWithCache(url: string, options?: FontLoadOptions): Promise<Uint8Array | null>;
|
|
176
189
|
|
|
177
190
|
declare interface OutputDiagnostic {
|
|
178
|
-
code: "missing-image" | "unsupported-component" | "unsupported-image-format" | "unsupported-style" | "rich-text-flattened" | "nested-components-omitted" | "async-image-required" | "image-decode-failed" | "asset-render-failed" | "asset-budget-exceeded";
|
|
191
|
+
code: "invalid-image-data" | "image-budget-exceeded" | "component-render-failed" | "unsupported-text" | "output-degraded" | "missing-image" | "unsupported-component" | "unsupported-image-format" | "unsupported-style" | "rich-text-flattened" | "nested-components-omitted" | "async-image-required" | "image-decode-failed" | "asset-render-failed" | "asset-budget-exceeded";
|
|
179
192
|
severity: "warning";
|
|
180
193
|
format: OutputFormat;
|
|
181
194
|
pageIndex: number;
|
|
@@ -210,7 +223,7 @@ export declare type PdfDocumentHandle = {
|
|
|
210
223
|
save(): Promise<Uint8Array>;
|
|
211
224
|
};
|
|
212
225
|
|
|
213
|
-
export declare interface PdfRenderOptions extends AssetRenderOptions, OutputTaskOptions {
|
|
226
|
+
export declare interface PdfRenderOptions extends AssetRenderOptions, OutputTaskOptions, ImageMediaOptions {
|
|
214
227
|
/** 嵌入字体字节(TTF,如黑体);缺省用 Helvetica(不支持 CJK) */
|
|
215
228
|
customFontBytes?: Uint8Array | ArrayBuffer;
|
|
216
229
|
customFontName?: string;
|
|
@@ -315,6 +328,8 @@ export declare function renderPlanToPdf(plan: RenderPlan, options?: PdfRenderOpt
|
|
|
315
328
|
|
|
316
329
|
/** 可持久化的业务身份与计划坐标独立;权限及并发校验仍由业务服务器执行。 */
|
|
317
330
|
declare interface ReportCellSource {
|
|
331
|
+
/** Source identity across report occurrences; sharing must be explicitly declared. */
|
|
332
|
+
sourceScope?: string;
|
|
318
333
|
datasetId: string;
|
|
319
334
|
rowKey: string | number;
|
|
320
335
|
field: string;
|
package/dist/pdf.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ declare interface AssetRenderBudget {
|
|
|
9
9
|
maxDurationMs?: number;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
declare interface AssetRenderOptions extends OutputDiagnosticOptions {
|
|
12
|
+
declare interface AssetRenderOptions extends OutputDiagnosticOptions, ImageMediaOptions {
|
|
13
13
|
assetRenderers?: Partial<Record<ImageComponentKind, ComponentImageRenderer>>;
|
|
14
14
|
assetBudget?: AssetRenderBudget;
|
|
15
15
|
/** Default throw prevents an incomplete export; placeholder retains the component and emits diagnostics. */
|
|
@@ -164,6 +164,19 @@ declare interface GridCell {
|
|
|
164
164
|
|
|
165
165
|
declare type ImageComponentKind = "image" | "chart" | "barcode" | "qrcode";
|
|
166
166
|
|
|
167
|
+
/** Bounded binary image inspection shared by PDF, Excel and template import. No decoder is loaded. */
|
|
168
|
+
export declare interface ImageMediaOptions {
|
|
169
|
+
maxImageBytes?: number;
|
|
170
|
+
maxTotalImageBytes?: number;
|
|
171
|
+
maxImages?: number;
|
|
172
|
+
/** Decoded pixels per unique image, default 16 million. */
|
|
173
|
+
maxImagePixels?: number;
|
|
174
|
+
/** Total decoded pixels for unique media, default 64 million. */
|
|
175
|
+
maxTotalImagePixels?: number;
|
|
176
|
+
/** Maximum source dimension, default 16384 pixels. */
|
|
177
|
+
maxImageDimension?: number;
|
|
178
|
+
}
|
|
179
|
+
|
|
167
180
|
/** Invalidating or clearing also fences late downloads from repopulating the cache. */
|
|
168
181
|
export declare function invalidateFontCache(url: string): Promise<void>;
|
|
169
182
|
|
|
@@ -175,7 +188,7 @@ export declare function invalidateFontCache(url: string): Promise<void>;
|
|
|
175
188
|
export declare function loadFontWithCache(url: string, options?: FontLoadOptions): Promise<Uint8Array | null>;
|
|
176
189
|
|
|
177
190
|
declare interface OutputDiagnostic {
|
|
178
|
-
code: "missing-image" | "unsupported-component" | "unsupported-image-format" | "unsupported-style" | "rich-text-flattened" | "nested-components-omitted" | "async-image-required" | "image-decode-failed" | "asset-render-failed" | "asset-budget-exceeded";
|
|
191
|
+
code: "invalid-image-data" | "image-budget-exceeded" | "component-render-failed" | "unsupported-text" | "output-degraded" | "missing-image" | "unsupported-component" | "unsupported-image-format" | "unsupported-style" | "rich-text-flattened" | "nested-components-omitted" | "async-image-required" | "image-decode-failed" | "asset-render-failed" | "asset-budget-exceeded";
|
|
179
192
|
severity: "warning";
|
|
180
193
|
format: OutputFormat;
|
|
181
194
|
pageIndex: number;
|
|
@@ -210,7 +223,7 @@ export declare type PdfDocumentHandle = {
|
|
|
210
223
|
save(): Promise<Uint8Array>;
|
|
211
224
|
};
|
|
212
225
|
|
|
213
|
-
export declare interface PdfRenderOptions extends AssetRenderOptions, OutputTaskOptions {
|
|
226
|
+
export declare interface PdfRenderOptions extends AssetRenderOptions, OutputTaskOptions, ImageMediaOptions {
|
|
214
227
|
/** 嵌入字体字节(TTF,如黑体);缺省用 Helvetica(不支持 CJK) */
|
|
215
228
|
customFontBytes?: Uint8Array | ArrayBuffer;
|
|
216
229
|
customFontName?: string;
|
|
@@ -315,6 +328,8 @@ export declare function renderPlanToPdf(plan: RenderPlan, options?: PdfRenderOpt
|
|
|
315
328
|
|
|
316
329
|
/** 可持久化的业务身份与计划坐标独立;权限及并发校验仍由业务服务器执行。 */
|
|
317
330
|
declare interface ReportCellSource {
|
|
331
|
+
/** Source identity across report occurrences; sharing must be explicitly declared. */
|
|
332
|
+
sourceScope?: string;
|
|
318
333
|
datasetId: string;
|
|
319
334
|
rowKey: string | number;
|
|
320
335
|
field: string;
|
package/dist/pdf.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { clearFontCache as t, configureFontCache as o, getFontCacheStats as r, invalidateFontCache as n, loadFontWithCache as c } from "./font-loader-
|
|
2
|
-
import { c as F, r as s } from "./pdf-
|
|
1
|
+
import { clearFontCache as t, configureFontCache as o, getFontCacheStats as r, invalidateFontCache as n, loadFontWithCache as c } from "./font-loader-Q3bQjmrI.js";
|
|
2
|
+
import { c as F, r as s } from "./pdf-BwNyeGpt.js";
|
|
3
3
|
export {
|
|
4
4
|
t as clearFontCache,
|
|
5
5
|
o as configureFontCache,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineAsyncComponent as c, computed as m } from "vue";
|
|
2
2
|
import { b as i, c as l, a as s } from "./injection-keys-e85udZCp.js";
|
|
3
|
-
import { g as d } from "./report-params-
|
|
4
|
-
const p = c(() => import("./ReportPreview-
|
|
3
|
+
import { g as d } from "./report-params-B1RzkhJj.js";
|
|
4
|
+
const p = c(() => import("./ReportPreview-ChV19HBp.js").then((r) => r.s)), _ = {
|
|
5
5
|
install(r, e = {}) {
|
|
6
6
|
let t = e.fetcher;
|
|
7
7
|
if (!t && e.reports) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var R=Object.create;var f=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var d=Object.getPrototypeOf,p=Object.prototype.hasOwnProperty;var m=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of P(e))!p.call(r,o)&&o!==t&&f(r,o,{get:()=>e[o],enumerable:!(n=u(e,o))||n.enumerable});return r};var E=(r,e,t)=>(t=r!=null?R(d(r)):{},m(e||!r||!r.__esModule?f(t,"default",{value:r,enumerable:!0}):t,r));const l=require("vue"),i=require("./injection-keys-Db_DyLkm.cjs"),h=require("./report-params-
|
|
1
|
+
"use strict";var R=Object.create;var f=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var d=Object.getPrototypeOf,p=Object.prototype.hasOwnProperty;var m=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of P(e))!p.call(r,o)&&o!==t&&f(r,o,{get:()=>e[o],enumerable:!(n=u(e,o))||n.enumerable});return r};var E=(r,e,t)=>(t=r!=null?R(d(r)):{},m(e||!r||!r.__esModule?f(t,"default",{value:r,enumerable:!0}):t,r));const l=require("vue"),i=require("./injection-keys-Db_DyLkm.cjs"),h=require("./report-params-WDGrA4oP.cjs"),s=l.defineAsyncComponent(()=>Promise.resolve().then(()=>require("./ReportPreview-DbLvvOUT.cjs")).then(r=>r.ReportPreview$1)),v={install(r,e={}){let t=e.fetcher;if(!t&&e.reports){const n=e.reports;let o;t=async c=>(o??=import("@agile-team/mach-report").then(({createReportSource:a})=>a(n)),(await o)(c)),t.getParamDefs=c=>h.getReportParamDefs(n,c)}t&&r.provide(i.MACH_REPORT_FETCHER_KEY,t),e.pdfExporter&&r.provide(i.MACH_REPORT_PDF_EXPORTER_KEY,e.pdfExporter),r.provide(i.MACH_REPORT_CONFIG_KEY,l.computed(()=>{if(e.pdfFontUrl===void 0)return e.config??null;const n=e.config??{defaults:{},presets:{}};return{...n,defaults:{...n.defaults,pdfFontUrl:e.pdfFontUrl}}})),e.globalComponent!==!1&&!r.component("MachReportPreview")&&r.component("MachReportPreview",s)}};exports.MachReportPreview=s;exports.machReportPlugin=v;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const u=require("./data-explanation-DE55G30w.cjs"),n=require("./json-snapshot-WWSGlaHG.cjs"),a=require("./sha256-ArEYjaTI.cjs");function p(r){return r&&{...r}}function l(r){if(!r)return;const t=e=>{if(!(e instanceof Uint8Array)&&!(e instanceof ArrayBuffer))throw new n.ReportSourceError("validate","字体应为 Uint8Array 或 ArrayBuffer");if(e.byteLength>32e6)throw new a.ReportRuntimeError("budget","单份字体超过 32 MB","$.pdf");return new Uint8Array(e instanceof Uint8Array?e:new Uint8Array(e))};if(r.customFontFaces){const e=r.customFontFaces;return{customFontName:r.customFontName,customFontFaces:{regular:t(e.regular),...e.bold?{bold:t(e.bold)}:{},...e.italic?{italic:t(e.italic)}:{},...e.boldItalic?{boldItalic:t(e.boldItalic)}:{}}}}return{customFontName:r.customFontName,...r.customFontBytes?{customFontBytes:t(r.customFontBytes)}:{}}}function c(r){const t=r?.customFontFaces??(r?.customFontBytes?{regular:r.customFontBytes}:void 0);if(!t)return;const e=["regular","bold","italic","boldItalic"].map(o=>{const i=t[o];if(!i)return[o,null];const s=i instanceof Uint8Array?i:new Uint8Array(i);if(s.byteLength>32e6)throw new a.ReportRuntimeError("budget","单份字体超过 32 MB","$.pdf");return[o,a.portableSha256Hex(s)]});return a.portableSha256Hex(new TextEncoder().encode(JSON.stringify(e)))}function y(r,t,e){const o=n.snapshotReportJson(r,{maxBytes:t,check:()=>a.throwIfAborted(e),error:(i,s)=>i==="budget"?new a.ReportRuntimeError("budget",s,"$.budget.maxPreparedBytes"):new n.ReportSourceError("validate",s)});return f(o),o}function d(r){if(r===void 0)return!0;if(!Array.isArray(r))return!1;const t=new Set;return r.every(e=>!e||typeof e!="object"||Array.isArray(e)||typeof e.reportId!="string"||!e.reportId.trim()||!Number.isSafeInteger(e.reportIndex)||e.reportIndex<0||t.has(e.reportIndex)||typeof e.reportScope!="string"||!e.reportScope.trim()||e.reportScope.length>4096||e.revision!==void 0&&typeof e.revision!="string"||e.sourceToken!==void 0&&typeof e.sourceToken!="string"?!1:(t.add(e.reportIndex),!0))}function f(r){if(!d(r.sources))throw new n.ReportSourceError("validate","准备结果来源清单无效");if(!r?.stats||["rows","pages","cells"].some(t=>!Number.isSafeInteger(r.stats[t])||r.stats[t]<0)||!Number.isFinite(r.stats.durationMs)||r.stats.durationMs<0)throw new n.ReportSourceError("validate","准备结果统计无效");if(!Array.isArray(r.diagnostics)||r.diagnostics.some(t=>!t||typeof t.code!="string"||typeof t.message!="string"||!["info","warning","error"].includes(t.severity)||!u.hasValidDataExplanation(t)))throw new n.ReportSourceError("validate","准备结果诊断无效");if(!r.revisions||typeof r.revisions!="object"||Array.isArray(r.revisions)||Object.values(r.revisions).some(t=>!t||typeof t!="object"||t.revision!==void 0&&typeof t.revision!="string"||t.sourceToken!==void 0&&typeof t.sourceToken!="string"))throw new n.ReportSourceError("validate","准备结果修订无效");if(r.layout&&(!["heuristic","provided","font-bytes"].includes(r.layout.textMetrics)||r.layout.fontFingerprint!==void 0&&!/^[a-f0-9]{64}$/.test(r.layout.fontFingerprint)))throw new n.ReportSourceError("validate","准备结果字体度量标识无效")}function g(r){if(r.format!=="pdf")return;const t=r.prepared.layout?.fontFingerprint,e=c(r.pdf);if(t===e&&(t!==void 0||r.prepared.layout?.textMetrics==="heuristic"&&!e))return;const o="已准备计划的字体度量无法与本次 PDF 字体确认一致;保持现有分页,未重新查询或排版。请在 prepare 和 exportPrepared 提供相同字体字节。";if(r.fidelity==="strict")throw new n.ReportSourceError("validate",o);r.prepared.diagnostics.push({code:"prepared-font-metrics",severity:"warning",message:o})}exports.checkPreparedFont=g;exports.reportFontFingerprint=c;exports.snapshotPdfFonts=l;exports.snapshotPreparedReport=y;exports.snapshotXlsxOptions=p;exports.validPreparedSources=d;exports.validatePreparedMetadata=f;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { h as f } from "./data-explanation-B8MZRYVS.js";
|
|
2
|
+
import { R as o, s as d } from "./json-snapshot-DFb2eWkf.js";
|
|
3
|
+
import { R as s, t as u, p as c } from "./sha256-DPEuJ3nh.js";
|
|
4
|
+
function b(t) {
|
|
5
|
+
return t && { ...t };
|
|
6
|
+
}
|
|
7
|
+
function F(t) {
|
|
8
|
+
if (!t) return;
|
|
9
|
+
const r = (e) => {
|
|
10
|
+
if (!(e instanceof Uint8Array) && !(e instanceof ArrayBuffer)) throw new o("validate", "字体应为 Uint8Array 或 ArrayBuffer");
|
|
11
|
+
if (e.byteLength > 32e6) throw new s("budget", "单份字体超过 32 MB", "$.pdf");
|
|
12
|
+
return new Uint8Array(e instanceof Uint8Array ? e : new Uint8Array(e));
|
|
13
|
+
};
|
|
14
|
+
if (t.customFontFaces) {
|
|
15
|
+
const e = t.customFontFaces;
|
|
16
|
+
return { customFontName: t.customFontName, customFontFaces: { regular: r(e.regular), ...e.bold ? { bold: r(e.bold) } : {}, ...e.italic ? { italic: r(e.italic) } : {}, ...e.boldItalic ? { boldItalic: r(e.boldItalic) } : {} } };
|
|
17
|
+
}
|
|
18
|
+
return { customFontName: t.customFontName, ...t.customFontBytes ? { customFontBytes: r(t.customFontBytes) } : {} };
|
|
19
|
+
}
|
|
20
|
+
function l(t) {
|
|
21
|
+
const r = t?.customFontFaces ?? (t?.customFontBytes ? { regular: t.customFontBytes } : void 0);
|
|
22
|
+
if (!r) return;
|
|
23
|
+
const e = ["regular", "bold", "italic", "boldItalic"].map((i) => {
|
|
24
|
+
const n = r[i];
|
|
25
|
+
if (!n) return [i, null];
|
|
26
|
+
const a = n instanceof Uint8Array ? n : new Uint8Array(n);
|
|
27
|
+
if (a.byteLength > 32e6) throw new s("budget", "单份字体超过 32 MB", "$.pdf");
|
|
28
|
+
return [i, c(a)];
|
|
29
|
+
});
|
|
30
|
+
return c(new TextEncoder().encode(JSON.stringify(e)));
|
|
31
|
+
}
|
|
32
|
+
function v(t, r, e) {
|
|
33
|
+
const i = d(t, {
|
|
34
|
+
maxBytes: r,
|
|
35
|
+
check: () => u(e),
|
|
36
|
+
error: (n, a) => n === "budget" ? new s("budget", a, "$.budget.maxPreparedBytes") : new o("validate", a)
|
|
37
|
+
});
|
|
38
|
+
return p(i), i;
|
|
39
|
+
}
|
|
40
|
+
function y(t) {
|
|
41
|
+
if (t === void 0) return !0;
|
|
42
|
+
if (!Array.isArray(t)) return !1;
|
|
43
|
+
const r = /* @__PURE__ */ new Set();
|
|
44
|
+
return t.every((e) => !e || typeof e != "object" || Array.isArray(e) || typeof e.reportId != "string" || !e.reportId.trim() || !Number.isSafeInteger(e.reportIndex) || e.reportIndex < 0 || r.has(e.reportIndex) || typeof e.reportScope != "string" || !e.reportScope.trim() || e.reportScope.length > 4096 || e.revision !== void 0 && typeof e.revision != "string" || e.sourceToken !== void 0 && typeof e.sourceToken != "string" ? !1 : (r.add(e.reportIndex), !0));
|
|
45
|
+
}
|
|
46
|
+
function p(t) {
|
|
47
|
+
if (!y(t.sources)) throw new o("validate", "准备结果来源清单无效");
|
|
48
|
+
if (!t?.stats || ["rows", "pages", "cells"].some((r) => !Number.isSafeInteger(t.stats[r]) || t.stats[r] < 0) || !Number.isFinite(t.stats.durationMs) || t.stats.durationMs < 0) throw new o("validate", "准备结果统计无效");
|
|
49
|
+
if (!Array.isArray(t.diagnostics) || t.diagnostics.some((r) => !r || typeof r.code != "string" || typeof r.message != "string" || !["info", "warning", "error"].includes(r.severity) || !f(r))) throw new o("validate", "准备结果诊断无效");
|
|
50
|
+
if (!t.revisions || typeof t.revisions != "object" || Array.isArray(t.revisions) || Object.values(t.revisions).some((r) => !r || typeof r != "object" || r.revision !== void 0 && typeof r.revision != "string" || r.sourceToken !== void 0 && typeof r.sourceToken != "string")) throw new o("validate", "准备结果修订无效");
|
|
51
|
+
if (t.layout && (!["heuristic", "provided", "font-bytes"].includes(t.layout.textMetrics) || t.layout.fontFingerprint !== void 0 && !/^[a-f0-9]{64}$/.test(t.layout.fontFingerprint))) throw new o("validate", "准备结果字体度量标识无效");
|
|
52
|
+
}
|
|
53
|
+
function A(t) {
|
|
54
|
+
if (t.format !== "pdf") return;
|
|
55
|
+
const r = t.prepared.layout?.fontFingerprint, e = l(t.pdf);
|
|
56
|
+
if (r === e && (r !== void 0 || t.prepared.layout?.textMetrics === "heuristic" && !e)) return;
|
|
57
|
+
const i = "已准备计划的字体度量无法与本次 PDF 字体确认一致;保持现有分页,未重新查询或排版。请在 prepare 和 exportPrepared 提供相同字体字节。";
|
|
58
|
+
if (t.fidelity === "strict") throw new o("validate", i);
|
|
59
|
+
t.prepared.diagnostics.push({ code: "prepared-font-metrics", severity: "warning", message: i });
|
|
60
|
+
}
|
|
61
|
+
export {
|
|
62
|
+
b as a,
|
|
63
|
+
v as b,
|
|
64
|
+
A as c,
|
|
65
|
+
y as d,
|
|
66
|
+
l as r,
|
|
67
|
+
F as s,
|
|
68
|
+
p as v
|
|
69
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function o(t){if(t?.aborted)throw t.reason??new DOMException("The operation was aborted.","AbortError")}function c(t){try{Promise.resolve(t()).catch(()=>{})}catch{}}function b(t,e,r){o(t.signal),c(()=>t.onProgress?.(e,r)),o(t.signal)}function d(t,e){const r=Promise.resolve(t);return e?.aborted?(r.catch(()=>{}),Promise.reject(e.reason??new DOMException("The operation was aborted.","AbortError"))):e?new Promise((n,u)=>{const a=()=>e.removeEventListener("abort",i),i=()=>{a(),u(e.reason??new DOMException("The operation was aborted.","AbortError"))};e.addEventListener("abort",i,{once:!0}),r.then(s=>{a(),n(s)},s=>{a(),u(s)}),e.aborted&&i()}):r}function f(t,e){const r=()=>e.abort(t?.reason);return t?.addEventListener("abort",r,{once:!0}),t?.aborted&&r(),()=>t?.removeEventListener("abort",r)}async function w(t,e,r){b(t,e,r),(t.signal||t.onProgress)&&await new Promise(n=>setTimeout(n,0)),o(t.signal)}function p(t){let e=0,r=Date.now();return(n=1)=>{if(o(t.signal),e+=n,!(e<4096&&Date.now()-r<8))return e=0,new Promise(u=>setTimeout(u,0)).then(()=>{r=Date.now(),o(t.signal)})}}exports.assertOutputActive=o;exports.createOutputScheduler=p;exports.forwardOutputAbort=f;exports.notifyOutputProgress=b;exports.observeOutput=c;exports.outputCheckpoint=w;exports.waitForOutput=d;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
function n(e) {
|
|
2
|
+
if (e?.aborted) throw e.reason ?? new DOMException("The operation was aborted.", "AbortError");
|
|
3
|
+
}
|
|
4
|
+
function c(e) {
|
|
5
|
+
try {
|
|
6
|
+
Promise.resolve(e()).catch(() => {
|
|
7
|
+
});
|
|
8
|
+
} catch {
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function b(e, t, r) {
|
|
12
|
+
n(e.signal), c(() => e.onProgress?.(t, r)), n(e.signal);
|
|
13
|
+
}
|
|
14
|
+
function d(e, t) {
|
|
15
|
+
const r = Promise.resolve(e);
|
|
16
|
+
return t?.aborted ? (r.catch(() => {
|
|
17
|
+
}), Promise.reject(t.reason ?? new DOMException("The operation was aborted.", "AbortError"))) : t ? new Promise((o, a) => {
|
|
18
|
+
const s = () => t.removeEventListener("abort", i), i = () => {
|
|
19
|
+
s(), a(t.reason ?? new DOMException("The operation was aborted.", "AbortError"));
|
|
20
|
+
};
|
|
21
|
+
t.addEventListener("abort", i, { once: !0 }), r.then((u) => {
|
|
22
|
+
s(), o(u);
|
|
23
|
+
}, (u) => {
|
|
24
|
+
s(), a(u);
|
|
25
|
+
}), t.aborted && i();
|
|
26
|
+
}) : r;
|
|
27
|
+
}
|
|
28
|
+
function f(e, t) {
|
|
29
|
+
const r = () => t.abort(e?.reason);
|
|
30
|
+
return e?.addEventListener("abort", r, { once: !0 }), e?.aborted && r(), () => e?.removeEventListener("abort", r);
|
|
31
|
+
}
|
|
32
|
+
async function w(e, t, r) {
|
|
33
|
+
b(e, t, r), (e.signal || e.onProgress) && await new Promise((o) => setTimeout(o, 0)), n(e.signal);
|
|
34
|
+
}
|
|
35
|
+
function v(e) {
|
|
36
|
+
let t = 0, r = Date.now();
|
|
37
|
+
return (o = 1) => {
|
|
38
|
+
if (n(e.signal), t += o, !(t < 4096 && Date.now() - r < 8))
|
|
39
|
+
return t = 0, new Promise((a) => setTimeout(a, 0)).then(() => {
|
|
40
|
+
r = Date.now(), n(e.signal);
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export {
|
|
45
|
+
n as a,
|
|
46
|
+
c as b,
|
|
47
|
+
v as c,
|
|
48
|
+
f,
|
|
49
|
+
b as n,
|
|
50
|
+
w as o,
|
|
51
|
+
d as w
|
|
52
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const y=require("./defaults-xhmcLLrf.cjs"),d=require("./style-UgIJSA1F.cjs"),u=require("./computed-CGV2a809.cjs");function S(e){if(!e||e.kind==="date")return;const t=e.digits;if(!(t!==void 0&&(!Number.isInteger(t)||t<0||t>100))){if(e.kind==="percent"){const r=t??2;return`0${r?`.${"0".repeat(r)}`:""}%`}return t===void 0?e.thousands?"#,##0.###############":void 0:`${e.thousands?"#,##0":"0"}${t?`.${"0".repeat(t)}`:""}`}}function h(e){const t=/^(\d{4})[-/](\d{1,2})[-/](\d{1,2})$/.exec(e.trim());if(t){const n=new Date(Number(t[1]),Number(t[2])-1,Number(t[3]));return Number.isNaN(n.getTime())?null:n}const r=new Date(e);return Number.isNaN(r.getTime())?null:r}function c(e,t){return e.toLocaleString("en-US",{minimumFractionDigits:t,maximumFractionDigits:t})}function x(e,t){const r=n=>String(n).padStart(2,"0");return t.replace(/YYYY/g,String(e.getFullYear())).replace(/MM/g,r(e.getMonth()+1)).replace(/DD/g,r(e.getDate())).replace(/hh/g,r(e.getHours())).replace(/mm/g,r(e.getMinutes())).replace(/ss/g,r(e.getSeconds()))}function C(e,t,r){return r!=null?t?c(e,r):e.toFixed(r):t?c(e):String(e)}function g(e){const t=typeof e=="number"?e:Number(String(e).replace(/,/g,""));return Number.isFinite(t)?t:null}function b(e,t){if(e==null||e===""||!t)return String(e??"");switch(t.kind){case"number":{if(typeof e=="string")try{return u.formatDecimal(e,t.digits,t.thousands===!0)}catch{return e}const r=g(e);return r==null?String(e):C(r,t.thousands===!0,t.digits)}case"percent":{if(typeof e=="string")try{return u.formatDecimal(e,t.digits??2,!0,!0)}catch{return e}const r=g(e);return r==null?String(e):`${c(r*100,t.digits??2)}%`}case"date":{const r=t.pattern??"YYYY-MM-DD",n=e instanceof Date?e:h(String(e));return n?x(n,r):String(e)}default:return String(e)}}function p(e,t){const r=e[t.field];if(r==null||r==="")return!1;if(typeof t.value=="number"||t.numeric!==void 0){let a;try{a=u.compareDecimal(u.parseDecimal(r),u.parseDecimal(t.value))}catch{return!1}if(!Number.isFinite(a))return!1;switch(t.op){case">":return a>0;case">=":return a>=0;case"<":return a<0;case"<=":return a<=0;case"==":return a===0;case"!=":return a!==0}}const n=String(r),i=String(t.value);switch(t.op){case"==":return n===i;case"!=":return n!==i;case">":return n>i;case">=":return n>=i;case"<":return n<i;case"<=":return n<=i}return!1}function D(e,t,r,n=e.paddingMm??1){return t.field!==e.tree.labelField?0:Math.min(r.depth*(e.tree.indentMm??3),Math.max(0,t.widthMm-n*2-4))}function N(e,t,r,n){const i=n.tree;(i.input==="nested"||[i.idField,i.parentField].includes(t.field))&&(e.editable=!1),r.hasChildren&&i.parentValues==="leaf-aggregate"&&i.aggregates?.some(a=>a.field===t.field)&&(e.derived=!0,e.editable=!1)}function T(e,t,r){return r==="identifier"||r==="dimension"||r==="date"?"center":r==="measure"?"right":r==="text"?"left":t?.kind==="number"||t?.kind==="percent"?"right":t?.kind==="date"||e instanceof Date||typeof e=="boolean"?"center":typeof e=="number"&&Number.isFinite(e)?"right":"left"}function F(e){if(e==null)return"";if(typeof e=="string"||typeof e=="number")return String(e);if(typeof e=="boolean")return e?"是":"否";if(e instanceof Date)return e.toISOString().slice(0,10);try{return JSON.stringify(e)}catch{return String(e)}}function M(e,t){let r=d.mergeComponentStyles({fontSize:e.fontSizePt??y.DEFAULT_FONT_PT,bold:e.headerBold??!0,align:"center",verticalAlign:"middle",backgroundColor:e.headerBackgroundColor},t.style);return e.headerAlign!==void 0&&(r.align=e.headerAlign),r=d.mergeComponentStyles(r,e.headerStyle),t.headerAlign!==void 0&&(r.align=t.headerAlign),d.mergeComponentStyles(r,t.headerStyle)}function A(e,t,r){(r===null||typeof r=="string"||typeof r=="boolean"||typeof r=="number"&&Number.isFinite(r))&&(e.value=r);const n=t.format?.kind==="number"||t.format?.kind==="percent";t.valueType!==void 0?e.valueType=t.valueType:n&&(e.valueType="number"),t.editable!==void 0&&(e.editable=t.editable);const i=S(t.format);(typeof e.value=="number"||e.value==null)&&i!==void 0&&(e.numberFormat=i)}function $(e,t,r){const n=!!t.visibleWhen&&!p(r,t.visibleWhen),i=n?null:r[t.field],a=t.align??t.style?.align??e.align??"left";let s=d.mergeComponentStyles({fontSize:e.fontSizePt??y.DEFAULT_FONT_PT,verticalAlign:"middle"},t.style);s.align=a==="auto"?T(i,t.format,t.semanticRole):a;const o=t.rules?.find(f=>p(r,f.when));o&&(s=d.mergeComponentStyles(s,o.style));const l={text:t.format?b(i,t.format):F(i),style:s};return A(l,t,i),e.computed?.some(f=>f.field===t.field)&&(l.derived=!0,l.editable=!1),n&&(l.editable=!1),l}function k(e,t,r){const n=$(e,t,r.row),i=D(e,t,r);return t.field===e.tree.labelField&&(n.style={...n.style,align:"left"}),i&&(n.indentMm=i),N(n,t,r,e),n}function w(e){return typeof e=="string"&&/^data:image\/(png|jpe?g);base64,[A-Za-z0-9+/\r\n]+=*$/.test(e)}class m extends Error{constructor(t,r,n,i){super(`${t}: ${r}`),this.path=t,this.rowIndex=n,this.field=i,this.code="report-binding",this.name="ReportBindingError"}}function L(e,t,r={}){const n=r.rowIndex??0,a=`$.datasets.${r.dataset??"label"}[${n}].${t}`,s=Object.getOwnPropertyDescriptor(e,t);if(!s||s.get||s.set)throw new m(a,"字段必须是记录的自有数据字段,不能缺失、使用访问器或从原型继承",n,t);const o=s.value;if(o==null||typeof o=="string"||typeof o=="boolean"||typeof o=="number"&&Number.isFinite(o))return o;throw new m(a,"绑定值应为字符串、有限数字、布尔值或空值",n,t)}function I(e,t,r={}){const n=L(t,e.field,r);return n==null||n===""?e.emptyText??"":`${e.prefix??""}${b(n,e.format)}${e.suffix??""}`}exports.ReportBindingError=m;exports.applyListTreeMetadata=N;exports.evalStyleRule=p;exports.formatValue=b;exports.isLabelImageData=w;exports.listCellText=F;exports.listTreeIndent=D;exports.parseDateLocal=h;exports.readRecordScalar=L;exports.resolveComponentBinding=I;exports.resolveListAutoAlignment=T;exports.resolveListHeaderStyle=M;exports.resolveListSampleCell=$;exports.resolveTreeListSampleCell=k;exports.toExcelNumberFormat=S;exports.toNumber=g;
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { c as h } from "./defaults-DXhiM1ZD.js";
|
|
2
|
+
import { e as d } from "./style-CQ1PK8ZB.js";
|
|
3
|
+
import { d as S, p as l, h as g } from "./computed-C-4C2S5h.js";
|
|
4
|
+
function N(e) {
|
|
5
|
+
if (!e || e.kind === "date") return;
|
|
6
|
+
const t = e.digits;
|
|
7
|
+
if (!(t !== void 0 && (!Number.isInteger(t) || t < 0 || t > 100))) {
|
|
8
|
+
if (e.kind === "percent") {
|
|
9
|
+
const r = t ?? 2;
|
|
10
|
+
return `0${r ? `.${"0".repeat(r)}` : ""}%`;
|
|
11
|
+
}
|
|
12
|
+
return t === void 0 ? e.thousands ? "#,##0.###############" : void 0 : `${e.thousands ? "#,##0" : "0"}${t ? `.${"0".repeat(t)}` : ""}`;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function D(e) {
|
|
16
|
+
const t = /^(\d{4})[-/](\d{1,2})[-/](\d{1,2})$/.exec(e.trim());
|
|
17
|
+
if (t) {
|
|
18
|
+
const n = new Date(Number(t[1]), Number(t[2]) - 1, Number(t[3]));
|
|
19
|
+
return Number.isNaN(n.getTime()) ? null : n;
|
|
20
|
+
}
|
|
21
|
+
const r = new Date(e);
|
|
22
|
+
return Number.isNaN(r.getTime()) ? null : r;
|
|
23
|
+
}
|
|
24
|
+
function c(e, t) {
|
|
25
|
+
return e.toLocaleString("en-US", {
|
|
26
|
+
minimumFractionDigits: t,
|
|
27
|
+
maximumFractionDigits: t
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function F(e, t) {
|
|
31
|
+
const r = (n) => String(n).padStart(2, "0");
|
|
32
|
+
return t.replace(/YYYY/g, String(e.getFullYear())).replace(/MM/g, r(e.getMonth() + 1)).replace(/DD/g, r(e.getDate())).replace(/hh/g, r(e.getHours())).replace(/mm/g, r(e.getMinutes())).replace(/ss/g, r(e.getSeconds()));
|
|
33
|
+
}
|
|
34
|
+
function $(e, t, r) {
|
|
35
|
+
return r != null ? t ? c(e, r) : e.toFixed(r) : t ? c(e) : String(e);
|
|
36
|
+
}
|
|
37
|
+
function p(e) {
|
|
38
|
+
const t = typeof e == "number" ? e : Number(String(e).replace(/,/g, ""));
|
|
39
|
+
return Number.isFinite(t) ? t : null;
|
|
40
|
+
}
|
|
41
|
+
function y(e, t) {
|
|
42
|
+
if (e == null || e === "" || !t) return String(e ?? "");
|
|
43
|
+
switch (t.kind) {
|
|
44
|
+
case "number": {
|
|
45
|
+
if (typeof e == "string")
|
|
46
|
+
try {
|
|
47
|
+
return g(e, t.digits, t.thousands === !0);
|
|
48
|
+
} catch {
|
|
49
|
+
return e;
|
|
50
|
+
}
|
|
51
|
+
const r = p(e);
|
|
52
|
+
return r == null ? String(e) : $(r, t.thousands === !0, t.digits);
|
|
53
|
+
}
|
|
54
|
+
case "percent": {
|
|
55
|
+
if (typeof e == "string")
|
|
56
|
+
try {
|
|
57
|
+
return g(e, t.digits ?? 2, !0, !0);
|
|
58
|
+
} catch {
|
|
59
|
+
return e;
|
|
60
|
+
}
|
|
61
|
+
const r = p(e);
|
|
62
|
+
return r == null ? String(e) : `${c(r * 100, t.digits ?? 2)}%`;
|
|
63
|
+
}
|
|
64
|
+
case "date": {
|
|
65
|
+
const r = t.pattern ?? "YYYY-MM-DD", n = e instanceof Date ? e : D(String(e));
|
|
66
|
+
return n ? F(n, r) : String(e);
|
|
67
|
+
}
|
|
68
|
+
default:
|
|
69
|
+
return String(e);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function m(e, t) {
|
|
73
|
+
const r = e[t.field];
|
|
74
|
+
if (r == null || r === "") return !1;
|
|
75
|
+
if (typeof t.value == "number" || t.numeric !== void 0) {
|
|
76
|
+
let a;
|
|
77
|
+
try {
|
|
78
|
+
a = S(l(r), l(t.value));
|
|
79
|
+
} catch {
|
|
80
|
+
return !1;
|
|
81
|
+
}
|
|
82
|
+
if (!Number.isFinite(a)) return !1;
|
|
83
|
+
switch (t.op) {
|
|
84
|
+
case ">":
|
|
85
|
+
return a > 0;
|
|
86
|
+
case ">=":
|
|
87
|
+
return a >= 0;
|
|
88
|
+
case "<":
|
|
89
|
+
return a < 0;
|
|
90
|
+
case "<=":
|
|
91
|
+
return a <= 0;
|
|
92
|
+
case "==":
|
|
93
|
+
return a === 0;
|
|
94
|
+
case "!=":
|
|
95
|
+
return a !== 0;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const n = String(r), i = String(t.value);
|
|
99
|
+
switch (t.op) {
|
|
100
|
+
case "==":
|
|
101
|
+
return n === i;
|
|
102
|
+
case "!=":
|
|
103
|
+
return n !== i;
|
|
104
|
+
case ">":
|
|
105
|
+
return n > i;
|
|
106
|
+
case ">=":
|
|
107
|
+
return n >= i;
|
|
108
|
+
case "<":
|
|
109
|
+
return n < i;
|
|
110
|
+
case "<=":
|
|
111
|
+
return n <= i;
|
|
112
|
+
}
|
|
113
|
+
return !1;
|
|
114
|
+
}
|
|
115
|
+
function x(e, t, r, n = e.paddingMm ?? 1) {
|
|
116
|
+
return t.field !== e.tree.labelField ? 0 : Math.min(r.depth * (e.tree.indentMm ?? 3), Math.max(0, t.widthMm - n * 2 - 4));
|
|
117
|
+
}
|
|
118
|
+
function M(e, t, r, n) {
|
|
119
|
+
const i = n.tree;
|
|
120
|
+
(i.input === "nested" || [i.idField, i.parentField].includes(t.field)) && (e.editable = !1), r.hasChildren && i.parentValues === "leaf-aggregate" && i.aggregates?.some((a) => a.field === t.field) && (e.derived = !0, e.editable = !1);
|
|
121
|
+
}
|
|
122
|
+
function T(e, t, r) {
|
|
123
|
+
return r === "identifier" || r === "dimension" || r === "date" ? "center" : r === "measure" ? "right" : r === "text" ? "left" : t?.kind === "number" || t?.kind === "percent" ? "right" : t?.kind === "date" || e instanceof Date || typeof e == "boolean" ? "center" : typeof e == "number" && Number.isFinite(e) ? "right" : "left";
|
|
124
|
+
}
|
|
125
|
+
function k(e) {
|
|
126
|
+
if (e == null) return "";
|
|
127
|
+
if (typeof e == "string" || typeof e == "number") return String(e);
|
|
128
|
+
if (typeof e == "boolean") return e ? "是" : "否";
|
|
129
|
+
if (e instanceof Date) return e.toISOString().slice(0, 10);
|
|
130
|
+
try {
|
|
131
|
+
return JSON.stringify(e);
|
|
132
|
+
} catch {
|
|
133
|
+
return String(e);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function R(e, t) {
|
|
137
|
+
let r = d({ fontSize: e.fontSizePt ?? h, bold: e.headerBold ?? !0, align: "center", verticalAlign: "middle", backgroundColor: e.headerBackgroundColor }, t.style);
|
|
138
|
+
return e.headerAlign !== void 0 && (r.align = e.headerAlign), r = d(r, e.headerStyle), t.headerAlign !== void 0 && (r.align = t.headerAlign), d(r, t.headerStyle);
|
|
139
|
+
}
|
|
140
|
+
function w(e, t, r) {
|
|
141
|
+
(r === null || typeof r == "string" || typeof r == "boolean" || typeof r == "number" && Number.isFinite(r)) && (e.value = r);
|
|
142
|
+
const n = t.format?.kind === "number" || t.format?.kind === "percent";
|
|
143
|
+
t.valueType !== void 0 ? e.valueType = t.valueType : n && (e.valueType = "number"), t.editable !== void 0 && (e.editable = t.editable);
|
|
144
|
+
const i = N(t.format);
|
|
145
|
+
(typeof e.value == "number" || e.value == null) && i !== void 0 && (e.numberFormat = i);
|
|
146
|
+
}
|
|
147
|
+
function A(e, t, r) {
|
|
148
|
+
const n = !!t.visibleWhen && !m(r, t.visibleWhen), i = n ? null : r[t.field], a = t.align ?? t.style?.align ?? e.align ?? "left";
|
|
149
|
+
let s = d({ fontSize: e.fontSizePt ?? h, verticalAlign: "middle" }, t.style);
|
|
150
|
+
s.align = a === "auto" ? T(i, t.format, t.semanticRole) : a;
|
|
151
|
+
const o = t.rules?.find((u) => m(r, u.when));
|
|
152
|
+
o && (s = d(s, o.style));
|
|
153
|
+
const f = { text: t.format ? y(i, t.format) : k(i), style: s };
|
|
154
|
+
return w(f, t, i), e.computed?.some((u) => u.field === t.field) && (f.derived = !0, f.editable = !1), n && (f.editable = !1), f;
|
|
155
|
+
}
|
|
156
|
+
function z(e, t, r) {
|
|
157
|
+
const n = A(e, t, r.row), i = x(e, t, r);
|
|
158
|
+
return t.field === e.tree.labelField && (n.style = { ...n.style, align: "left" }), i && (n.indentMm = i), M(n, t, r, e), n;
|
|
159
|
+
}
|
|
160
|
+
function B(e) {
|
|
161
|
+
return typeof e == "string" && /^data:image\/(png|jpe?g);base64,[A-Za-z0-9+/\r\n]+=*$/.test(e);
|
|
162
|
+
}
|
|
163
|
+
class b extends Error {
|
|
164
|
+
constructor(t, r, n, i) {
|
|
165
|
+
super(`${t}: ${r}`), this.path = t, this.rowIndex = n, this.field = i, this.code = "report-binding", this.name = "ReportBindingError";
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
function L(e, t, r = {}) {
|
|
169
|
+
const n = r.rowIndex ?? 0, a = `$.datasets.${r.dataset ?? "label"}[${n}].${t}`, s = Object.getOwnPropertyDescriptor(e, t);
|
|
170
|
+
if (!s || s.get || s.set) throw new b(a, "字段必须是记录的自有数据字段,不能缺失、使用访问器或从原型继承", n, t);
|
|
171
|
+
const o = s.value;
|
|
172
|
+
if (o == null || typeof o == "string" || typeof o == "boolean" || typeof o == "number" && Number.isFinite(o)) return o;
|
|
173
|
+
throw new b(a, "绑定值应为字符串、有限数字、布尔值或空值", n, t);
|
|
174
|
+
}
|
|
175
|
+
function E(e, t, r = {}) {
|
|
176
|
+
const n = L(t, e.field, r);
|
|
177
|
+
return n == null || n === "" ? e.emptyText ?? "" : `${e.prefix ?? ""}${y(n, e.format)}${e.suffix ?? ""}`;
|
|
178
|
+
}
|
|
179
|
+
export {
|
|
180
|
+
b as R,
|
|
181
|
+
z as a,
|
|
182
|
+
E as b,
|
|
183
|
+
R as c,
|
|
184
|
+
p as d,
|
|
185
|
+
m as e,
|
|
186
|
+
y as f,
|
|
187
|
+
L as g,
|
|
188
|
+
T as h,
|
|
189
|
+
B as i,
|
|
190
|
+
x as j,
|
|
191
|
+
M as k,
|
|
192
|
+
k as l,
|
|
193
|
+
D as p,
|
|
194
|
+
A as r,
|
|
195
|
+
N as t
|
|
196
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { v as F } from "./dataset-H5pFuQGU.js";
|
|
2
|
-
import { v as D,
|
|
2
|
+
import { v as D, e as z, p as Z } from "./template-registry-BtaKPELV.js";
|
|
3
3
|
import { r as N } from "./grid-geometry-BNptEcMm.js";
|
|
4
4
|
function v(t) {
|
|
5
5
|
let e = "";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";const F=require("./dataset-BkRmwgeJ.cjs"),R=require("./template-registry-D3SjENi6.cjs"),N=require("./grid-geometry-CZ_cYB6O.cjs");function S(t){let e="";for(let o=t;o>0;o=Math.floor((o-1)/26))e=String.fromCharCode(65+(o-1)%26)+e;return e}function M(t){return`${S(t.left)}${t.top}:${S(t.right)}${t.bottom}`}function _(t){let e=0;for(const o of t.toUpperCase())e=e*26+o.charCodeAt(0)-64;return e}function d(t){if(typeof t!="string")throw new Error("Excel 范围应为 A1:B20 格式的字符串");const e=/^\$?([A-Z]{1,3})\$?([1-9]\d{0,6})(?::\$?([A-Z]{1,3})\$?([1-9]\d{0,6}))?$/i.exec(t.trim());if(!e)throw new Error(`Excel 范围无效:${t}`);const o={left:_(e[1]),top:Number(e[2]),right:_(e[3]??e[1]),bottom:Number(e[4]??e[2])};if(o.right<o.left||o.bottom<o.top||o.right>16384||o.bottom>1048576)throw new Error(`Excel 范围超出边界或顺序无效:${t}`);return o}function mt(t,e){if(e!==void 0)return d(e);const o=t.model.rows??[];if(!o.length)return{top:1,left:1,bottom:1,right:1};const r={top:1/0,left:1/0,bottom:1,right:1};for(const n of o)r.top=Math.min(r.top,n.number),r.bottom=Math.max(r.bottom,n.number),r.left=Math.min(r.left,n.min||1),r.right=Math.max(r.right,n.max||1);return r}function dt(t,e,o){const r=t.bottom-t.top+1,n=t.right-t.left+1;if(r>e.limits.maxRows||n>e.limits.maxColumns||r*n>o)throw new Error(`Excel 范围 ${M(t)} 超过导入行、列或单元格上限;请用 sheets/range 缩小范围`);return r*n}function pt(t,e){return t.top<=e.bottom&&t.bottom>=e.top&&t.left<=e.right&&t.right>=e.left}function ut(t,e){const o=[];for(const r of t.model.merges){const n=d(r);if(pt(e,n)){if(n.left<e.left||n.right>e.right||n.top<e.top||n.bottom>e.bottom)throw new Error(`${t.name}: 范围 ${M(e)} 截断合并单元格 ${r},请包含完整合并区域`);o.push(n)}}return o}function wt(t,e){const o=new Map;for(const n of e)o.set(n.top,Math.max(o.get(n.top)??n.top,n.bottom));const r=[];for(let n=t.top;n<=t.bottom;){let s=o.get(n)??n;for(let a=n;a<=s;a++)s=Math.max(s,o.get(a)??a);r.push({top:n,bottom:s}),n=s+1}return r}function yt(t,e,o,r){const n=[];let s,a=0;for(const i of t){const c=i.bottom-i.top+1;if(c>200)throw new Error("合并单元格跨越超过 200 行,无法安全分段;请先缩小或拆分该合并区域");let l=0;for(let h=i.top;h<=i.bottom;h++)l+=r(h);if(l>o&&Number.isFinite(o))throw new Error("合并区域或单行高度超过标准纸张可用高度;请使用 wide 或调整原模板行高");const f=s?i.bottom-s.top+1:c;s&&(f>e||a+l>o)&&(n.push(s),s=void 0,a=0),s?s.bottom=i.bottom:s={...i},a+=l}return s&&n.push(s),n}function Et(t){const e=new Map,o=new Set;for(const r of t){e.set(`${r.top}:${r.left}`,r);for(let n=r.top;n<=r.bottom;n++)for(let s=r.left;s<=r.right;s++)(n!==r.top||s!==r.left)&&o.add(`${n}:${s}`)}return{masters:e,covered:o}}function O(t){return JSON.parse(JSON.stringify(t))}function Mt(t,e){const o=t.template.pages.slice(e.pageStart,e.pageStart+e.pageCount),r=o[0];if(!r)throw new Error(`工作表 ${e.name} 没有可绑定页面`);const n=new Map;let s=[];for(const a of o)for(const i of a.components){if(i.kind==="list"||!i.grid||i.meta?.xlsxSheet!==e.name)continue;const c=d(String(i.meta.xlsxRange)),l=i.grid;s=l.colWidthsMm??[],l.cells.forEach((f,h)=>n.set(c.top+h,{cells:O(f),height:l.rowHeightsMm?.[h]??6}))}if(!s.length||!n.size)throw new Error(`工作表 ${e.name} 缺少导入几何元数据`);return{rows:n,widths:[...s],page:r,range:d(e.range)}}function G(t,e,o){const r=[],n=[];for(let s=e;s<=o;s++){const a=t.rows.get(s);if(!a)throw new Error(`导入模板缺少第 ${s} 行`);for(const i of a.cells)if(i&&s+(i.rowSpan??1)-1>o)throw new Error(`第 ${s} 行合并区域跨越绑定边界,请调整 header/detail 范围`);r.push(O(a.cells)),n.push(a.height)}return{cells:r,rowHeightsMm:n,colWidthsMm:t.widths,paddingMm:.25}}function xt(t,e){const o=d(t.header),r=t.detail?d(t.detail):{...e.range,top:o.bottom+1};for(const n of[o,r])if(n.left!==e.range.left||n.right!==e.range.right||n.top<e.range.top||n.bottom>e.range.bottom||n.top>n.bottom)throw new Error("绑定区域必须位于导入选区内并覆盖其完整列宽");if(r.top!==o.bottom+1)throw new Error("detail 应紧接 header,避免静态内容被隐式删除");if(t.columns.length!==e.widths.length)throw new Error("columns 应逐列映射整个选区;不能自动猜测业务字段");return bt(e,[o.top,o.bottom+1,r.bottom+1]),{header:o,detail:r}}function bt(t,e){for(const[o,r]of t.rows)for(const n of r.cells){const s=o+(n?.rowSpan??1);if(e.some(a=>o<a&&s>a))throw new Error(`第 ${o} 行合并区域跨越绑定边界,请调整 header/detail 范围`)}}function $t(t,e){const o=[];for(const r of N.resolveGridLayout(t,e.reduce((n,s)=>n+s,0),100).cells)for(let n=r.ci;n<Math.min(e.length,r.ci+(r.cell.colSpan??1));n++)o[n]=r.cell;return o}function St(t,e,o,r){if(e)return e;const n=t?.numberFormat;if(!n||n==="General")return;const s=/^(#,##)?0(?:\.(0+))?(%)?$/.exec(n);if(s){const a=s[2]?.length??0;if(a<=100)return s[3]?{kind:"percent",digits:a}:{kind:"number",digits:a,...s[1]?{thousands:!0}:{}}}r.push(`${o}: Excel 数字格式 ${n} 未自动套用到动态数据,请在 columns 中显式声明 format`)}function Rt(t,e,o,r,n){const s=$t(e,r),a=N.resolveGridLayout(o,r.reduce((f,h)=>f+h,0),20).cells;if(a.some(({cell:f})=>(f.colSpan??1)!==1||(f.rowSpan??1)!==1))throw new Error("动态明细样例行不能包含合并格;合并表头可以保留");const i=new Map(a.map(f=>[f.ci,f.cell])),c=new Set,l=t.columns.map((f,h)=>{const g=typeof f=="string"?{field:f}:f;if(!g||typeof g.field!="string"||!g.field.trim()||c.has(g.field))throw new Error(`columns[${h}] 需要唯一的非空 field`);c.add(g.field);const m=s[h]?.text??g.field,p=i.get(h),w=t.inferSampleFormats===!1?g.format:St(p,g.format,g.field,n);return{...g,...w?{format:w}:{},header:g.header??m,widthMm:r[h],style:{...p?.style,...g.style},...g.semanticRole&&!g.align?{align:"auto"}:{},...g.editable===void 0&&p?.editable===!1?{editable:!1}:{}}});return vt(t,s,l),l}function vt(t,e,o){const r=new Map;t.columns.forEach((n,s)=>{const a=e[s];if(!a||typeof n=="string")return;const i=r.get(a)??{style:{}};if(n.header!==void 0){if(i.text!==void 0&&i.text!==n.header)throw new Error("同一合并表头不能配置不同 header");i.text=n.header}kt(i.style,{...n.headerAlign?{align:n.headerAlign}:{},...n.headerStyle}),r.set(a,i)});for(const[n,s]of r)s.text!==void 0&&Object.assign(n,{text:s.text,rawText:s.text,value:s.text}),n.style={...n.style,...s.style},e.forEach((a,i)=>{a===n&&(s.text!==void 0&&(o[i].header=s.text),s.style.align!==void 0&&(o[i].headerAlign=s.style.align))})}function kt(t,e){for(const o of Object.keys(e))if(e[o]!==void 0){if(t[o]!==void 0&&t[o]!==e[o])throw new Error(`同一合并表头不能配置不同 ${o}`);Object.assign(t,{[o]:e[o]})}}function Bt(t,e){const o=t.page,r=e.rowHeightsMm.reduce((n,s)=>n+s,0);return{...o,heightMm:Math.max(o.heightMm,r+(o.marginTopMm??0)+(o.marginBottomMm??0)),components:[{kind:"rect",leftMm:o.marginLeftMm??0,topMm:o.marginTopMm??0,widthMm:t.widths.reduce((n,s)=>n+s,0),heightMm:r,grid:e}]}}function At(t,e,o,r){const n=Mt(t,e),{header:s,detail:a}=xt(o,n),i=G(n,n.range.top,s.bottom),c=G(n,a.top,a.top),l={...n.page,components:[]},f={kind:"list",id:`bound:${e.name}`,dataset:o.dataset??"detail",title:e.name,leftMm:l.marginLeftMm??0,topMm:l.marginTopMm??0,widthMm:n.widths.reduce((h,g)=>h+g,0),layout:l.layout??"page",headerGrid:i,columns:Rt(o,i,c,n.widths,r),rowHeightMm:c.rowHeightsMm[0],headerEveryPage:!0,align:"auto",paddingMm:.25,...o.rowKey?{rowKey:o.rowKey}:{},...o.revisionField?{revisionField:o.revisionField}:{},...o.sourceTokenField?{sourceTokenField:o.sourceTokenField}:{},...o.groupBy?{groupBy:o.groupBy}:{},...o.grandTotal===void 0?{}:{grandTotal:o.grandTotal}};return l.components.push(f),a.bottom===n.range.bottom?[l]:(r.push(`${e.name}: 明细区域后的静态内容保留为后续独立页面,不推断动态页脚定位`),[l,Bt(n,G(n,a.bottom+1,n.range.bottom))])}function V(t,e){const o=R.validateReportTemplate(t.template);if(!o.ok)throw new Error(`导入模板无效:${o.errors[0]?.message}`);if(!e.length)throw new Error("至少需要一个 Excel 业务绑定");const r=new Map;for(const c of e){if(!t.sheets.some(l=>l.name===c.sheet)||r.has(c.sheet))throw new Error(`绑定工作表不存在或重复:${c.sheet}`);r.set(c.sheet,c)}const n=[...t.warnings],s=t.sheets.flatMap(c=>{const l=r.get(c.name);return l?At(t,c,l,n):O(t.template.pages.slice(c.pageStart,c.pageStart+c.pageCount))}),a={...O(t.template),pages:s},i=R.validateReportTemplate(a);if(!i.ok)throw new Error(`业务模板无效:${i.errors[0]?.path} ${i.errors[0]?.message}`);return{template:a,warnings:n}}function z(t){const e=t.semanticRole??(t.type==="number"||t.type==="decimal"?"measure":t.type==="date"?"date":"text");return{field:t.field,semanticRole:e,editable:!1,...t.type==="number"&&t.digits!==void 0?{format:{kind:"number",digits:t.digits}}:{},...t.type==="date"?{format:{kind:"date",pattern:"YYYY-MM-DD"}}:{}}}function Ct(t){return t===null||typeof t=="string"||typeof t=="boolean"||typeof t=="number"&&Number.isFinite(t)}function H(t,e=0){if(Ct(t))return;if(!t||typeof t!="object"||e>16)throw new Error("绑定会话元数据只允许有限深度的普通 JSON 值");const o=Object.getPrototypeOf(t);if(Array.isArray(t)?o!==Array.prototype:o!==Object.prototype&&o!==null)throw new Error("绑定会话不能包含特殊对象原型");if(Object.getOwnPropertySymbols(t).length)throw new Error("绑定会话不能包含 Symbol");if(Array.isArray(t)&&Object.keys(t).length!==t.length)throw new Error("绑定会话数组不能包含空位或额外属性");for(const[r,n]of Object.entries(Object.getOwnPropertyDescriptors(t)))if(!(Array.isArray(t)&&r==="length")){if(["__proto__","prototype","constructor"].includes(r)||n.get||n.set||!n.enumerable)throw new Error("绑定会话包含不安全元数据");H(n.value,e+1)}}function Ot(t,e){return Tt(t,e)}function Tt(t,e){const o=t.sheets.find(c=>c.name===e.sheet);if(!o)return[];const r=d(e.regions.header),n=d(e.regions.detail),s=[r.top,r.bottom+1,n.bottom+1],a=[],i=new Set;for(const c of t.template.pages.slice(o.pageStart,o.pageStart+o.pageCount))for(const l of c.components){if(l.kind==="list"||!l.grid||l.meta?.xlsxSheet!==e.sheet)continue;const f=d(String(l.meta.xlsxRange));l.grid.cells.forEach((h,g)=>{const m=f.top+g;for(const p of h){const w=s.some(b=>m<b&&m+(p?.rowSpan??1)>b),x=m===n.top&&((p?.rowSpan??1)>1||(p?.colSpan??1)>1);if(!w&&!x)continue;const E=w?"$.recipe.regions":"$.recipe.regions.detail";i.has(E)||(i.add(E),a.push({path:E,code:"region",message:w?`第 ${m} 行合并区域跨越绑定边界,请选择完整合并区域`:"动态明细原型行不能包含合并格"}))}})}return a}function Z(t){return JSON.parse(JSON.stringify(t))}function T(t){return t instanceof Error?t.message:String(t)}function u(t,e,o,r){t.push({path:e,code:o,message:r})}function U(t,e){return{fields:t.fields,...e?{rowKey:e}:{}}}function Ft(t,e){const o=new Set;for(const[r,n]of t.entries()){const s=`$.datasets[${r}]`;if(!n||typeof n.id!="string"||!n.id.trim()||o.has(n.id)){u(e,s,"schema","数据集标识应非空且唯一");continue}o.add(n.id);try{F.validateDatasetRows([],U(n,n.rowKey));for(const[a,i]of n.fields.entries())i.digits!==void 0&&(!Number.isInteger(i.digits)||i.digits<0||i.digits>100)&&u(e,`${s}.fields[${a}].digits`,"schema","显示精度应为 0–100 的整数")}catch(a){u(e,s,"schema",T(a))}}}function Nt(t,e,o){const r=t.sheets.find(i=>i.name===e.sheet);if(!r){u(o,"$.recipe.sheet","source","指定的工作表不存在");return}let n;try{n=d(r.range)}catch(i){u(o,"$.source.sheets","source",T(i));return}const s=new Map;for(const i of["title","header","detail","footer"]){const c=e.regions?.[i];if(!(!c&&(i==="title"||i==="footer")))try{const l=d(c??"");if(l.left!==n.left||l.right!==n.right||l.top<n.top||l.bottom>n.bottom)throw new Error("区域必须覆盖选区完整列宽,并位于原始工作表内");s.set(i,l)}catch(l){u(o,`$.recipe.regions.${i}`,"region",T(l))}}const a=[...s.values()];a.length&&(a[0].top!==n.top||a[a.length-1].bottom!==n.bottom)&&u(o,"$.recipe.regions","region","标题、表头、明细、页脚应完整覆盖来源,不能隐式删除静态内容");for(let i=1;i<a.length;i++)a[i].top!==a[i-1].bottom+1&&u(o,"$.recipe.regions","region","各区域应顺序相邻且不重叠")}function It(t,e,o,r){if(!Array.isArray(t.fields)||t.fields.length!==o)return u(r,"$.recipe.fields","mapping","每个物理 Excel 列必须显式绑定一个业务字段"),0;const n=new Set(e.fields.map(i=>i.field)),s=new Set;let a=0;t.fields.forEach((i,c)=>{typeof i!="string"||!n.has(i)?u(r,`$.recipe.fields[${c}]`,"mapping","请选择契约中已声明的字段"):s.has(i)?u(r,`$.recipe.fields[${c}]`,"mapping","同一业务字段不能重复绑定物理列"):(a++,s.add(i))});try{if(!t.rowKey)throw new Error("请明确选择稳定业务主键,不能使用展示行号");const i=U(e,t.rowKey),c=F.validateDatasetRows(e.samples??[],i,{path:`$.datasets.${e.id}.samples`,maxRows:100,maxCells:2e5,maxIssues:30});for(const l of c.issues)u(r,l.path,l.code==="row-key"?"row-key":"schema",l.message)}catch(i){u(r,"$.recipe.rowKey","row-key",T(i))}return a}function Q(t,e){const o=[];return!e||e.version!=="1.0"?[{path:"$.recipe.version",code:"schema",message:"不支持的 Excel 绑定配置版本"}]:(Nt(t,e,o),o.length||o.push(...Ot(t,e)),o)}function X(t,e,o){const r=[];if(!e||e.version!=="1.0")return{ok:!1,issues:[{path:"$.recipe.version",code:"schema",message:"不支持的 Excel 绑定配置版本"}],mapped:0,total:0};Ft(o,r);const n=t.sheets.find(i=>i.name===e.sheet)?.columnCount??0,s=o.find(i=>i.id===e.dataset);let a=0;return s?r.some(i=>i.code==="schema")||(a=It(e,s,n,r)):u(r,"$.recipe.dataset","schema","请明确选择宿主提供的数据集契约"),{ok:r.length===0,issues:r,mapped:a,total:n}}function tt(t,e,o){const r=X(t,e,o);if(!e||e.version!=="1.0")return r;const n=[...Q(t,e),...r.issues];return{...r,ok:n.length===0,issues:n}}function Kt(t,e,o,r){const n=tt(t,e,o);if(!n.ok)throw new Error(n.issues.map(f=>`${f.path}: ${f.message}`).join(`
|
|
1
|
+
"use strict";const F=require("./dataset-BkRmwgeJ.cjs"),R=require("./template-registry-Co1zPq5e.cjs"),N=require("./grid-geometry-CZ_cYB6O.cjs");function S(t){let e="";for(let o=t;o>0;o=Math.floor((o-1)/26))e=String.fromCharCode(65+(o-1)%26)+e;return e}function M(t){return`${S(t.left)}${t.top}:${S(t.right)}${t.bottom}`}function _(t){let e=0;for(const o of t.toUpperCase())e=e*26+o.charCodeAt(0)-64;return e}function d(t){if(typeof t!="string")throw new Error("Excel 范围应为 A1:B20 格式的字符串");const e=/^\$?([A-Z]{1,3})\$?([1-9]\d{0,6})(?::\$?([A-Z]{1,3})\$?([1-9]\d{0,6}))?$/i.exec(t.trim());if(!e)throw new Error(`Excel 范围无效:${t}`);const o={left:_(e[1]),top:Number(e[2]),right:_(e[3]??e[1]),bottom:Number(e[4]??e[2])};if(o.right<o.left||o.bottom<o.top||o.right>16384||o.bottom>1048576)throw new Error(`Excel 范围超出边界或顺序无效:${t}`);return o}function mt(t,e){if(e!==void 0)return d(e);const o=t.model.rows??[];if(!o.length)return{top:1,left:1,bottom:1,right:1};const r={top:1/0,left:1/0,bottom:1,right:1};for(const n of o)r.top=Math.min(r.top,n.number),r.bottom=Math.max(r.bottom,n.number),r.left=Math.min(r.left,n.min||1),r.right=Math.max(r.right,n.max||1);return r}function dt(t,e,o){const r=t.bottom-t.top+1,n=t.right-t.left+1;if(r>e.limits.maxRows||n>e.limits.maxColumns||r*n>o)throw new Error(`Excel 范围 ${M(t)} 超过导入行、列或单元格上限;请用 sheets/range 缩小范围`);return r*n}function pt(t,e){return t.top<=e.bottom&&t.bottom>=e.top&&t.left<=e.right&&t.right>=e.left}function ut(t,e){const o=[];for(const r of t.model.merges){const n=d(r);if(pt(e,n)){if(n.left<e.left||n.right>e.right||n.top<e.top||n.bottom>e.bottom)throw new Error(`${t.name}: 范围 ${M(e)} 截断合并单元格 ${r},请包含完整合并区域`);o.push(n)}}return o}function wt(t,e){const o=new Map;for(const n of e)o.set(n.top,Math.max(o.get(n.top)??n.top,n.bottom));const r=[];for(let n=t.top;n<=t.bottom;){let s=o.get(n)??n;for(let a=n;a<=s;a++)s=Math.max(s,o.get(a)??a);r.push({top:n,bottom:s}),n=s+1}return r}function yt(t,e,o,r){const n=[];let s,a=0;for(const i of t){const c=i.bottom-i.top+1;if(c>200)throw new Error("合并单元格跨越超过 200 行,无法安全分段;请先缩小或拆分该合并区域");let l=0;for(let h=i.top;h<=i.bottom;h++)l+=r(h);if(l>o&&Number.isFinite(o))throw new Error("合并区域或单行高度超过标准纸张可用高度;请使用 wide 或调整原模板行高");const f=s?i.bottom-s.top+1:c;s&&(f>e||a+l>o)&&(n.push(s),s=void 0,a=0),s?s.bottom=i.bottom:s={...i},a+=l}return s&&n.push(s),n}function Et(t){const e=new Map,o=new Set;for(const r of t){e.set(`${r.top}:${r.left}`,r);for(let n=r.top;n<=r.bottom;n++)for(let s=r.left;s<=r.right;s++)(n!==r.top||s!==r.left)&&o.add(`${n}:${s}`)}return{masters:e,covered:o}}function O(t){return JSON.parse(JSON.stringify(t))}function Mt(t,e){const o=t.template.pages.slice(e.pageStart,e.pageStart+e.pageCount),r=o[0];if(!r)throw new Error(`工作表 ${e.name} 没有可绑定页面`);const n=new Map;let s=[];for(const a of o)for(const i of a.components){if(i.kind==="list"||!i.grid||i.meta?.xlsxSheet!==e.name)continue;const c=d(String(i.meta.xlsxRange)),l=i.grid;s=l.colWidthsMm??[],l.cells.forEach((f,h)=>n.set(c.top+h,{cells:O(f),height:l.rowHeightsMm?.[h]??6}))}if(!s.length||!n.size)throw new Error(`工作表 ${e.name} 缺少导入几何元数据`);return{rows:n,widths:[...s],page:r,range:d(e.range)}}function G(t,e,o){const r=[],n=[];for(let s=e;s<=o;s++){const a=t.rows.get(s);if(!a)throw new Error(`导入模板缺少第 ${s} 行`);for(const i of a.cells)if(i&&s+(i.rowSpan??1)-1>o)throw new Error(`第 ${s} 行合并区域跨越绑定边界,请调整 header/detail 范围`);r.push(O(a.cells)),n.push(a.height)}return{cells:r,rowHeightsMm:n,colWidthsMm:t.widths,paddingMm:.25}}function xt(t,e){const o=d(t.header),r=t.detail?d(t.detail):{...e.range,top:o.bottom+1};for(const n of[o,r])if(n.left!==e.range.left||n.right!==e.range.right||n.top<e.range.top||n.bottom>e.range.bottom||n.top>n.bottom)throw new Error("绑定区域必须位于导入选区内并覆盖其完整列宽");if(r.top!==o.bottom+1)throw new Error("detail 应紧接 header,避免静态内容被隐式删除");if(t.columns.length!==e.widths.length)throw new Error("columns 应逐列映射整个选区;不能自动猜测业务字段");return bt(e,[o.top,o.bottom+1,r.bottom+1]),{header:o,detail:r}}function bt(t,e){for(const[o,r]of t.rows)for(const n of r.cells){const s=o+(n?.rowSpan??1);if(e.some(a=>o<a&&s>a))throw new Error(`第 ${o} 行合并区域跨越绑定边界,请调整 header/detail 范围`)}}function $t(t,e){const o=[];for(const r of N.resolveGridLayout(t,e.reduce((n,s)=>n+s,0),100).cells)for(let n=r.ci;n<Math.min(e.length,r.ci+(r.cell.colSpan??1));n++)o[n]=r.cell;return o}function St(t,e,o,r){if(e)return e;const n=t?.numberFormat;if(!n||n==="General")return;const s=/^(#,##)?0(?:\.(0+))?(%)?$/.exec(n);if(s){const a=s[2]?.length??0;if(a<=100)return s[3]?{kind:"percent",digits:a}:{kind:"number",digits:a,...s[1]?{thousands:!0}:{}}}r.push(`${o}: Excel 数字格式 ${n} 未自动套用到动态数据,请在 columns 中显式声明 format`)}function Rt(t,e,o,r,n){const s=$t(e,r),a=N.resolveGridLayout(o,r.reduce((f,h)=>f+h,0),20).cells;if(a.some(({cell:f})=>(f.colSpan??1)!==1||(f.rowSpan??1)!==1))throw new Error("动态明细样例行不能包含合并格;合并表头可以保留");const i=new Map(a.map(f=>[f.ci,f.cell])),c=new Set,l=t.columns.map((f,h)=>{const g=typeof f=="string"?{field:f}:f;if(!g||typeof g.field!="string"||!g.field.trim()||c.has(g.field))throw new Error(`columns[${h}] 需要唯一的非空 field`);c.add(g.field);const m=s[h]?.text??g.field,p=i.get(h),w=t.inferSampleFormats===!1?g.format:St(p,g.format,g.field,n);return{...g,...w?{format:w}:{},header:g.header??m,widthMm:r[h],style:{...p?.style,...g.style},...g.semanticRole&&!g.align?{align:"auto"}:{},...g.editable===void 0&&p?.editable===!1?{editable:!1}:{}}});return vt(t,s,l),l}function vt(t,e,o){const r=new Map;t.columns.forEach((n,s)=>{const a=e[s];if(!a||typeof n=="string")return;const i=r.get(a)??{style:{}};if(n.header!==void 0){if(i.text!==void 0&&i.text!==n.header)throw new Error("同一合并表头不能配置不同 header");i.text=n.header}kt(i.style,{...n.headerAlign?{align:n.headerAlign}:{},...n.headerStyle}),r.set(a,i)});for(const[n,s]of r)s.text!==void 0&&Object.assign(n,{text:s.text,rawText:s.text,value:s.text}),n.style={...n.style,...s.style},e.forEach((a,i)=>{a===n&&(s.text!==void 0&&(o[i].header=s.text),s.style.align!==void 0&&(o[i].headerAlign=s.style.align))})}function kt(t,e){for(const o of Object.keys(e))if(e[o]!==void 0){if(t[o]!==void 0&&t[o]!==e[o])throw new Error(`同一合并表头不能配置不同 ${o}`);Object.assign(t,{[o]:e[o]})}}function Bt(t,e){const o=t.page,r=e.rowHeightsMm.reduce((n,s)=>n+s,0);return{...o,heightMm:Math.max(o.heightMm,r+(o.marginTopMm??0)+(o.marginBottomMm??0)),components:[{kind:"rect",leftMm:o.marginLeftMm??0,topMm:o.marginTopMm??0,widthMm:t.widths.reduce((n,s)=>n+s,0),heightMm:r,grid:e}]}}function At(t,e,o,r){const n=Mt(t,e),{header:s,detail:a}=xt(o,n),i=G(n,n.range.top,s.bottom),c=G(n,a.top,a.top),l={...n.page,components:[]},f={kind:"list",id:`bound:${e.name}`,dataset:o.dataset??"detail",title:e.name,leftMm:l.marginLeftMm??0,topMm:l.marginTopMm??0,widthMm:n.widths.reduce((h,g)=>h+g,0),layout:l.layout??"page",headerGrid:i,columns:Rt(o,i,c,n.widths,r),rowHeightMm:c.rowHeightsMm[0],headerEveryPage:!0,align:"auto",paddingMm:.25,...o.rowKey?{rowKey:o.rowKey}:{},...o.revisionField?{revisionField:o.revisionField}:{},...o.sourceTokenField?{sourceTokenField:o.sourceTokenField}:{},...o.groupBy?{groupBy:o.groupBy}:{},...o.grandTotal===void 0?{}:{grandTotal:o.grandTotal}};return l.components.push(f),a.bottom===n.range.bottom?[l]:(r.push(`${e.name}: 明细区域后的静态内容保留为后续独立页面,不推断动态页脚定位`),[l,Bt(n,G(n,a.bottom+1,n.range.bottom))])}function V(t,e){const o=R.validateReportTemplate(t.template);if(!o.ok)throw new Error(`导入模板无效:${o.errors[0]?.message}`);if(!e.length)throw new Error("至少需要一个 Excel 业务绑定");const r=new Map;for(const c of e){if(!t.sheets.some(l=>l.name===c.sheet)||r.has(c.sheet))throw new Error(`绑定工作表不存在或重复:${c.sheet}`);r.set(c.sheet,c)}const n=[...t.warnings],s=t.sheets.flatMap(c=>{const l=r.get(c.name);return l?At(t,c,l,n):O(t.template.pages.slice(c.pageStart,c.pageStart+c.pageCount))}),a={...O(t.template),pages:s},i=R.validateReportTemplate(a);if(!i.ok)throw new Error(`业务模板无效:${i.errors[0]?.path} ${i.errors[0]?.message}`);return{template:a,warnings:n}}function z(t){const e=t.semanticRole??(t.type==="number"||t.type==="decimal"?"measure":t.type==="date"?"date":"text");return{field:t.field,semanticRole:e,editable:!1,...t.type==="number"&&t.digits!==void 0?{format:{kind:"number",digits:t.digits}}:{},...t.type==="date"?{format:{kind:"date",pattern:"YYYY-MM-DD"}}:{}}}function Ct(t){return t===null||typeof t=="string"||typeof t=="boolean"||typeof t=="number"&&Number.isFinite(t)}function H(t,e=0){if(Ct(t))return;if(!t||typeof t!="object"||e>16)throw new Error("绑定会话元数据只允许有限深度的普通 JSON 值");const o=Object.getPrototypeOf(t);if(Array.isArray(t)?o!==Array.prototype:o!==Object.prototype&&o!==null)throw new Error("绑定会话不能包含特殊对象原型");if(Object.getOwnPropertySymbols(t).length)throw new Error("绑定会话不能包含 Symbol");if(Array.isArray(t)&&Object.keys(t).length!==t.length)throw new Error("绑定会话数组不能包含空位或额外属性");for(const[r,n]of Object.entries(Object.getOwnPropertyDescriptors(t)))if(!(Array.isArray(t)&&r==="length")){if(["__proto__","prototype","constructor"].includes(r)||n.get||n.set||!n.enumerable)throw new Error("绑定会话包含不安全元数据");H(n.value,e+1)}}function Ot(t,e){return Tt(t,e)}function Tt(t,e){const o=t.sheets.find(c=>c.name===e.sheet);if(!o)return[];const r=d(e.regions.header),n=d(e.regions.detail),s=[r.top,r.bottom+1,n.bottom+1],a=[],i=new Set;for(const c of t.template.pages.slice(o.pageStart,o.pageStart+o.pageCount))for(const l of c.components){if(l.kind==="list"||!l.grid||l.meta?.xlsxSheet!==e.sheet)continue;const f=d(String(l.meta.xlsxRange));l.grid.cells.forEach((h,g)=>{const m=f.top+g;for(const p of h){const w=s.some(b=>m<b&&m+(p?.rowSpan??1)>b),x=m===n.top&&((p?.rowSpan??1)>1||(p?.colSpan??1)>1);if(!w&&!x)continue;const E=w?"$.recipe.regions":"$.recipe.regions.detail";i.has(E)||(i.add(E),a.push({path:E,code:"region",message:w?`第 ${m} 行合并区域跨越绑定边界,请选择完整合并区域`:"动态明细原型行不能包含合并格"}))}})}return a}function Z(t){return JSON.parse(JSON.stringify(t))}function T(t){return t instanceof Error?t.message:String(t)}function u(t,e,o,r){t.push({path:e,code:o,message:r})}function U(t,e){return{fields:t.fields,...e?{rowKey:e}:{}}}function Ft(t,e){const o=new Set;for(const[r,n]of t.entries()){const s=`$.datasets[${r}]`;if(!n||typeof n.id!="string"||!n.id.trim()||o.has(n.id)){u(e,s,"schema","数据集标识应非空且唯一");continue}o.add(n.id);try{F.validateDatasetRows([],U(n,n.rowKey));for(const[a,i]of n.fields.entries())i.digits!==void 0&&(!Number.isInteger(i.digits)||i.digits<0||i.digits>100)&&u(e,`${s}.fields[${a}].digits`,"schema","显示精度应为 0–100 的整数")}catch(a){u(e,s,"schema",T(a))}}}function Nt(t,e,o){const r=t.sheets.find(i=>i.name===e.sheet);if(!r){u(o,"$.recipe.sheet","source","指定的工作表不存在");return}let n;try{n=d(r.range)}catch(i){u(o,"$.source.sheets","source",T(i));return}const s=new Map;for(const i of["title","header","detail","footer"]){const c=e.regions?.[i];if(!(!c&&(i==="title"||i==="footer")))try{const l=d(c??"");if(l.left!==n.left||l.right!==n.right||l.top<n.top||l.bottom>n.bottom)throw new Error("区域必须覆盖选区完整列宽,并位于原始工作表内");s.set(i,l)}catch(l){u(o,`$.recipe.regions.${i}`,"region",T(l))}}const a=[...s.values()];a.length&&(a[0].top!==n.top||a[a.length-1].bottom!==n.bottom)&&u(o,"$.recipe.regions","region","标题、表头、明细、页脚应完整覆盖来源,不能隐式删除静态内容");for(let i=1;i<a.length;i++)a[i].top!==a[i-1].bottom+1&&u(o,"$.recipe.regions","region","各区域应顺序相邻且不重叠")}function It(t,e,o,r){if(!Array.isArray(t.fields)||t.fields.length!==o)return u(r,"$.recipe.fields","mapping","每个物理 Excel 列必须显式绑定一个业务字段"),0;const n=new Set(e.fields.map(i=>i.field)),s=new Set;let a=0;t.fields.forEach((i,c)=>{typeof i!="string"||!n.has(i)?u(r,`$.recipe.fields[${c}]`,"mapping","请选择契约中已声明的字段"):s.has(i)?u(r,`$.recipe.fields[${c}]`,"mapping","同一业务字段不能重复绑定物理列"):(a++,s.add(i))});try{if(!t.rowKey)throw new Error("请明确选择稳定业务主键,不能使用展示行号");const i=U(e,t.rowKey),c=F.validateDatasetRows(e.samples??[],i,{path:`$.datasets.${e.id}.samples`,maxRows:100,maxCells:2e5,maxIssues:30});for(const l of c.issues)u(r,l.path,l.code==="row-key"?"row-key":"schema",l.message)}catch(i){u(r,"$.recipe.rowKey","row-key",T(i))}return a}function Q(t,e){const o=[];return!e||e.version!=="1.0"?[{path:"$.recipe.version",code:"schema",message:"不支持的 Excel 绑定配置版本"}]:(Nt(t,e,o),o.length||o.push(...Ot(t,e)),o)}function X(t,e,o){const r=[];if(!e||e.version!=="1.0")return{ok:!1,issues:[{path:"$.recipe.version",code:"schema",message:"不支持的 Excel 绑定配置版本"}],mapped:0,total:0};Ft(o,r);const n=t.sheets.find(i=>i.name===e.sheet)?.columnCount??0,s=o.find(i=>i.id===e.dataset);let a=0;return s?r.some(i=>i.code==="schema")||(a=It(e,s,n,r)):u(r,"$.recipe.dataset","schema","请明确选择宿主提供的数据集契约"),{ok:r.length===0,issues:r,mapped:a,total:n}}function tt(t,e,o){const r=X(t,e,o);if(!e||e.version!=="1.0")return r;const n=[...Q(t,e),...r.issues];return{...r,ok:n.length===0,issues:n}}function Kt(t,e,o,r){const n=tt(t,e,o);if(!n.ok)throw new Error(n.issues.map(f=>`${f.path}: ${f.message}`).join(`
|
|
2
2
|
`));const s=t.sheets.find(f=>f.name===e.sheet),a={...t,sheets:[{...s,pageStart:0}],template:{...t.template,pages:t.template.pages.slice(s.pageStart,s.pageStart+s.pageCount)}},i=new Map(o.find(f=>f.id===e.dataset).fields.map(f=>[f.field,f])),c={sheet:e.sheet,dataset:e.dataset,header:e.regions.header,detail:e.regions.detail,rowKey:e.rowKey,inferSampleFormats:!1,columns:e.fields.map(f=>z(i.get(f)))},l=V(a,[c]);return{document:R.defineReportTemplate({...r,template:l.template}),recipe:Z(e),warnings:l.warnings}}function Gt(t,e){if(t?.version!=="1.0"||!Array.isArray(t.fields)||t.fields.length>16384||t.fields.some(o=>typeof o!="string"))throw new Error("Excel 绑定配置无效");if(typeof t.dataset!="string"||typeof t.rowKey!="string"||!t.regions||typeof e?.id!="string"||typeof e.name!="string")throw new Error("Excel 绑定参数或标识无效");for(const o of Object.values(t.regions))o!==""&&d(o)}function jt(t){for(const e of t.sheets)if(d(e.range),typeof e.name!="string"||![e.index,e.rowCount,e.columnCount,e.pageCount].every(o=>Number.isInteger(o)&&o>0)||!Number.isInteger(e.pageStart)||e.pageStart<0||e.pageStart+e.pageCount>t.template.pages.length)throw new Error("Excel 绑定工作表几何元数据无效")}function Ht(t,e,o){if(H({sheets:t.sheets,warnings:t.warnings,recipe:e,identity:o}),!Array.isArray(t.sheets)||!t.sheets.length||t.sheets.length>32||!Array.isArray(t.warnings)||t.warnings.some(r=>typeof r!="string"))throw new Error("Excel 绑定来源元数据无效");if(Gt(e,o),!t.sheets.some(r=>r.name===e.sheet))throw new Error("Excel 绑定工作表不存在");jt(t)}function et(t,e,o){return Ht(t,e,o),R.parseReportTemplate({schemaVersion:"1.0",id:o.id,name:o.name,template:t.template}),Z({version:"1.0",source:t,recipe:e,identity:o})}function Dt(t){if(typeof t=="string"&&t.length>1e7)throw new Error("Excel 绑定会话超过 1000 万字符上限");const e=typeof t=="string"?JSON.parse(t):t;if(!e||e.version!=="1.0"||e.recipe?.version!=="1.0"||!Array.isArray(e.source?.sheets))throw new Error("Excel 绑定会话结构或版本无效");return et(e.source,e.recipe,e.identity)}function Lt(t,e,o,r){const n=t.sheets.find(c=>c.name===e);if(!n)throw new Error("工作表不存在");const s=d(n.range),a=Math.min(o,r),i=Math.max(o,r);if(!Number.isInteger(a)||!Number.isInteger(i)||a<s.top||i>s.bottom)throw new Error("选中行超出来源区域");return M({...s,top:a,bottom:i})}function P(t,e,o){const r=t??e;if(!Number.isInteger(r)||r<1||r>o)throw new Error(`预览窗口大小应为 1–${o} 的整数`);return r}function Y(t,e,o){const r=t??e;if(!Number.isInteger(r))throw new Error("预览起点应为整数");return Math.max(e,Math.min(o,r))}function Jt(t,e,o={}){const r=t.sheets.find(g=>g.name===e);if(!r)throw new Error("指定的工作表不存在");const n=d(r.range),s=Y(o.row,n.top,n.bottom),a=Y(o.column,n.left,n.right),i=Math.min(n.bottom,s+P(o.rows,24,100)-1),c=Math.min(n.right,a+P(o.columns,12,32)-1),l=Array.from({length:i-s+1},(g,m)=>({row:s+m,cells:[]})),f=new Set;for(const g of t.template.pages.slice(r.pageStart,r.pageStart+r.pageCount))for(const m of g.components){if(m.kind==="list"||!m.grid||m.meta?.xlsxSheet!==e)continue;const p=d(String(m.meta.xlsxRange));if(p.bottom<s||p.top>i)continue;const w=N.resolveGridLayout(m.grid,m.widthMm,m.heightMm);for(const x of w.cells)h(x.cell,p.top+x.ri,p.left+x.ci)}for(const g of l){for(let m=a;m<=c;m++)f.has(`${g.row}:${m}`)||g.cells.push({address:`${S(m)}${g.row}`,row:g.row,column:m,text:"",rowSpan:1,colSpan:1,continued:!1});g.cells.sort((m,p)=>m.column-p.column)}return{top:s,bottom:i,left:a,right:c,source:n,rows:l,columns:Array.from({length:c-a+1},(g,m)=>({column:a+m,name:S(a+m)}))};function h(g,m,p){const w=m+(g.rowSpan??1)-1,x=p+(g.colSpan??1)-1;if(w<s||m>i||x<a||p>c)return;const E=Math.max(s,m),b=Math.max(a,p),J=Math.min(i,w)-E+1,W=Math.min(c,x)-b+1;l[E-s].cells.push({address:`${S(p)}${m}`,row:E,column:b,text:g.text??g.rawText??String(g.value??""),rowSpan:J,colSpan:W,continued:E!==m||b!==p,style:g.style});for(let I=E;I<E+J;I++)for(let K=b;K<b+W;K++)f.add(`${I}:${K}`)}}function v(t){return JSON.parse(JSON.stringify(t))}function ot(t,e){const o=t.sheets.find(i=>i.name===e);if(!o)throw new Error("指定的工作表不存在");const r=t.template.pages.slice(o.pageStart,o.pageStart+o.pageCount),n=r[0];if(!n)throw new Error("工作表没有可绑定的页面");const s={page:n,range:d(o.range),widths:[],heights:new Map,cells:[],cellsByRow:new Map,topOffsets:new Map};for(const i of r)for(const c of i.components){if(c.kind==="list"||!c.grid||c.meta?.xlsxSheet!==e)continue;const l=d(String(c.meta.xlsxRange));s.widths.length||(s.widths=[...c.grid.colWidthsMm??[]]),c.grid.cells.forEach((f,h)=>s.heights.set(l.top+h,c.grid.rowHeightsMm?.[h]??6));for(const f of N.resolveGridLayout(c.grid,c.widthMm,c.heightMm).cells){const h=l.top+f.ri,g=l.left+f.ci;s.cells.push({top:h,left:g,bottom:h+(f.cell.rowSpan??1)-1,right:g+(f.cell.colSpan??1)-1,cell:f.cell})}}if(s.widths.length!==s.range.right-s.range.left+1||s.heights.size!==s.range.bottom-s.range.top+1)throw new Error("来源工作表几何元数据不完整");let a=0;for(let i=s.range.top;i<=s.range.bottom;i++)s.topOffsets.set(i,a),a+=s.heights.get(i);s.topOffsets.set(s.range.bottom+1,a);for(const i of s.cells)for(let c=i.top;c<=i.bottom;c++){const l=s.cellsByRow.get(c)??[];l.push(i),s.cellsByRow.set(c,l)}return s}function rt(t,e){return t.left<=e.right&&e.left<=t.right&&t.top<=e.bottom&&e.top<=t.bottom}function k(t,e){return t.top<=e.top&&t.bottom>=e.bottom&&t.left<=e.left&&t.right>=e.right}function nt(t,e){return t.widths.slice(e.left-t.range.left,e.right-t.range.left+1).reduce((o,r)=>o+r,0)}function C(t,e){return(t.topOffsets.get(e.bottom+1)??0)-(t.topOffsets.get(e.top)??0)}function A(t,e){const o=new Set;for(let r=e.top;r<=e.bottom;r++)for(const n of t.cellsByRow.get(r)??[])rt(n,e)&&o.add(n);return[...o]}function st(t,e){for(const o of A(t,e))if(!k(e,o))throw new Error(`合并区域 ${M(o)} 跨越选区 ${M(e)}`)}function j(t,e,o=[]){const r=A(t,e);for(const i of r)if(!k(e,i))throw new Error(`合并区域 ${M(i)} 跨越选区 ${M(e)}`);const n=[],s=new Map,a=new Set;for(const i of r)if(!o.some(c=>k(c,i))){s.set(`${i.top}:${i.left}`,i);for(let c=i.top;c<=i.bottom;c++)for(let l=i.left;l<=i.right;l++)a.add(`${c}:${l}`)}for(let i=e.top;i<=e.bottom;i++){const c=[];for(let l=e.left;l<=e.right;l++){const f=s.get(`${i}:${l}`);f?(c.push(v(f.cell)),l=f.right):a.has(`${i}:${l}`)||c.push(null)}n.push(c)}return{cells:n,colWidthsMm:t.widths.slice(e.left-t.range.left,e.right-t.range.left+1),rowHeightsMm:Array.from({length:e.bottom-e.top+1},(i,c)=>t.heights.get(e.top+c)),paddingMm:.25}}function B(t){const e=d(t.range);return t.headerRange?{...e,top:d(t.headerRange).top}:e}function D(t,e){return(t.page.marginTopMm??0)+(t.topOffsets.get(e)??0)}function it(t,e){return{xlsxFlow:{version:"1.0",columnStart:e.left-t.range.left}}}function at(t,e,o,r,n=[]){const s=j(t,o,n);for(const a of s.cells)for(const i of a)i&&(i.editable=!1,delete i.source);return{kind:"rect",nid:r,leftMm:t.page.marginLeftMm??0,topMm:D(t,o.top),widthMm:nt(t,o),heightMm:C(t,o),grid:s,meta:it(t,o)}}function Wt(t,e,o,r){const n=d(o.range),s=B(o),a=j(t,n),i=new Map(r.fields.map(f=>[f.field,f])),c=a.colWidthsMm,l=o.fields.map((f,h)=>({...z(i.get(f)),header:i.get(f).label??f,widthMm:c[h],style:v(a.cells[0]?.[h]?.style??{}),align:"auto"}));return{kind:"list",id:`xlsx-region:${o.id}`,dataset:o.dataset,rowKey:o.rowKey,...o.revisionField?{revisionField:o.revisionField}:{},...o.sourceTokenField?{sourceTokenField:o.sourceTokenField}:{},title:`${e.sheet} · ${o.id}`,layout:t.page.layout??"wide",leftMm:(t.page.marginLeftMm??0)+t.widths.slice(0,n.left-t.range.left).reduce((f,h)=>f+h,0),topMm:D(t,s.top),widthMm:nt(t,n),rowHeightMm:a.rowHeightsMm[0],header:!!o.headerRange,headerEveryPage:o.mode==="repeat",...o.mode==="record"?{cardinality:"record"}:{},...o.headerRange?{headerGrid:j(t,d(o.headerRange))}:{},columns:l,paddingMm:a.paddingMm,meta:it(t,n)}}function q(t,e,o,r=0){const n=[],s=t.page.heightMm-(t.page.marginTopMm??0)-(t.page.marginBottomMm??0)-r,a=Math.max(1,Math.min(100,Math.floor(1e4/t.widths.length)));for(let i=e;i<=o;){const c=i;let l=i,f=0;for(;i<=o;){let h=i;for(let m=i;m<=h;m++)for(const p of t.cellsByRow.get(m)??[])h=Math.max(h,p.bottom);if(h>o)throw new Error("静态合并区域跨越动态绑定边界,请调整区域");const g=C(t,{...t.range,top:i,bottom:h});if(i>c&&(h-c+1>a||f+g>s))break;if(g>s)throw new Error("静态合并区域高度超过单页可用高度,请调整原始模板");f+=g,l=h,i=h+1}n.push({range:{...t.range,top:c,bottom:l},bindings:[]})}return n}function _t(t,e){const o=[...e.regions].sort((i,c)=>B(i).top-B(c).top),r=[];let n=t.range.top;const s=e.footerRange?C(t,d(e.footerRange)):0;for(const i of o){const c=B(i),l=r[r.length-1];if(l?.bindings.length&&l.range.top===c.top&&l.range.bottom===c.bottom){l.bindings.push(i);continue}n<c.top&&r.push(...q(t,n,c.top-1,s)),r.push({range:{...t.range,top:c.top,bottom:c.bottom},bindings:[i]}),n=c.bottom+1}const a=e.footerRange?d(e.footerRange).top-1:t.range.bottom;return n<=a&&r.push(...q(t,n,a,s)),r}function Pt(t,e,o,r,n){const s=[],a=o.bindings.map(B),i=o.bindings.some(l=>l.mode==="repeat"),c=A(t,o.range).some(l=>!a.some(f=>k(f,l)));!i&&(!o.bindings.length||c)&&s.push(at(t,e,o.range,`xlsx-static:${r}`,a));for(const l of o.bindings)s.push(Wt(t,e,l,n.find(f=>f.id===l.dataset)));return{components:s,flow:{componentIds:s.map(l=>l.kind==="list"?l.id:l.nid),topMm:D(t,o.range.top),heightMm:C(t,o.range)}}}function Yt(t,e,o,r){const n=ot(t,e.sheet),s={...v(n.page),components:[]},a=_t(n,e).map((i,c)=>Pt(n,e,i,c,o));if(s.components=a.flatMap(i=>i.components),s.flow={bands:a.map(i=>i.flow)},s.meta={xlsxFlow:{version:"1.0",templateId:r,sheet:e.sheet,fullWidthsMm:n.widths}},e.footerRange){const i=d(e.footerRange),c=at(n,e,i,"xlsx-footer");c.pageAnchor="footer",c.topMm=s.heightMm-(s.marginBottomMm??0)-c.heightMm,s.components.push(c)}return{...v(t.template),pages:[s]}}function $(t){return t instanceof Error?t.message:String(t)}function y(t,e,o,r){t.push({path:e,code:o,message:r})}function L(t,e,o=!1){const r=d(t);if(!k(e.range,r))throw new Error("绑定范围应完整位于来源工作表内");if(o&&r.top!==r.bottom)throw new Error("每个动态区域应选择一行原型;多个数据行由 repeat 自动扩展");return st(e,r),r}function qt(t){const e=t.cell;return!!e.formula||!!e.children?.length||e.value!==null&&e.value!==void 0&&e.value!==""||!!e.text||!!e.rawText}function Vt(t,e,o){if(!t.headerRange)return;const r=L(t.headerRange,e);if(r.left!==o.left||r.right!==o.right||r.bottom+1!==o.top)throw new Error("区域表头应与原型等列宽,并紧接原型上方");return r}function zt(t,e){const o=L(t.range,e,!0),r=Vt(t,e,o);if(st(e,{...e.range,top:r?.top??o.top,bottom:o.bottom}),A(e,o).some(s=>s.bottom!==s.top||s.left!==s.right))throw new Error("动态原型行不能包含合并格;请保留合并表头并选择其下方数据行");if(t.mode==="repeat"){const s={...e.range,top:r?.top??o.top,bottom:o.bottom};if(A(e,s).some(a=>!k({...o,top:s.top},a)&&qt(a)))throw new Error("纵向重复区域的旁列存在静态内容,无法安全拉伸;请扩大区域或将静态内容移至独立行")}return{...o,top:r?.top??o.top}}function lt(t){if(!t||t.version!=="2.0"||typeof t.sheet!="string"||!Array.isArray(t.regions)||!t.regions.length||t.regions.length>128)throw new Error("多区域绑定应为 version 2.0,并包含 1–128 个区域")}function ct(t,e){const o=[];try{lt(e)}catch(a){return[{path:"$.recipe",code:"schema",message:$(a)}]}let r;try{r=ot(t,e.sheet)}catch(a){return[{path:"$.recipe.sheet",code:"source",message:$(a)}]}const n=new Set,s=[];if(e.regions.forEach((a,i)=>{const c=`$.recipe.regions[${i}]`;try{if(!a||typeof a.id!="string"||!a.id.trim()||n.has(a.id))throw new Error("区域标识应非空且唯一");if(n.add(a.id),!["record","repeat"].includes(a.mode))throw new Error("区域模式应为 record 或 repeat");const l=zt(a,r);for(const f of s){if(rt(l,f.range))throw new Error(`区域与 ${f.path} 重叠(含表头)`);if(l.top<=f.range.bottom&&f.range.top<=l.bottom&&(a.mode==="repeat"||f.mode==="repeat"))throw new Error("同一行不能并排放置重复区域;请按纵向顺序排列");if(l.top<=f.range.bottom&&f.range.top<=l.bottom&&(l.top!==f.range.top||l.bottom!==f.range.bottom))throw new Error("并排单记录区域应使用相同的起止行(包括表头),避免不明确的位移")}s.push({range:l,mode:a.mode,path:c})}catch(l){y(o,c,"region",$(l))}}),e.footerRange)try{const a=L(e.footerRange,r);if(a.left!==r.range.left||a.right!==r.range.right||a.bottom!==r.range.bottom)throw new Error("重复页尾应覆盖完整列宽并位于来源最后几行");if(s.some(i=>i.range.bottom>=a.top))throw new Error("页尾与动态区域或区域表头相交");if(C(r,a)>=r.page.heightMm-(r.page.marginTopMm??0)-(r.page.marginBottomMm??0))throw new Error("页尾高度占满单页,不能为报表明细预留空间")}catch(a){y(o,"$.recipe.footerRange","region",$(a))}return o}function Zt(t,e){const o=new Map;for(const[r,n]of t.entries())try{if(!n||typeof n.id!="string"||!n.id.trim()||o.has(n.id))throw new Error("数据集标识应非空且唯一");F.validateDatasetRows([],{fields:n.fields,...n.rowKey?{rowKey:n.rowKey}:{}});for(const s of n.fields)if(s.digits!==void 0&&(!Number.isInteger(s.digits)||s.digits<0||s.digits>100))throw new Error("显示精度应为 0–100 的整数");o.set(n.id,n)}catch(s){y(e,`$.datasets[${r}]`,"schema",$(s))}return o}function Ut(t,e,o,r){const n=d(t.range),s=n.right-n.left+1;if(!Array.isArray(t.fields)||t.fields.length!==s)return y(r,`${o}.fields`,"mapping","区域每个物理列应显式绑定一个字段"),0;const a=new Set(e.fields.map(l=>l.field)),i=new Set;let c=0;if(t.fields.forEach((l,f)=>{!a.has(l)||i.has(l)?y(r,`${o}.fields[${f}]`,"mapping","请选择契约内已声明且不重复的字段"):(i.add(l),c++)}),!t.rowKey)y(r,`${o}.rowKey`,"row-key","每个区域应声明稳定业务主键");else{const l=F.validateDatasetRows(e.samples??[],{fields:e.fields,rowKey:t.rowKey},{path:`$.datasets.${e.id}.samples`,maxRows:100,maxIssues:30});for(const f of l.issues)y(r,f.path,f.code==="row-key"?"row-key":"schema",f.message)}for(const l of["revisionField","sourceTokenField"])t[l]!==void 0&&!a.has(t[l])&&y(r,`${o}.${l}`,"source","并发字段应引用同一区域数据集契约内的字段");return t.mode==="record"&&(e.samples?.length??0)>1&&y(r,o,"schema","record 区域数据集最多一行;多行请使用 repeat"),c}function ft(t,e){const o=[];try{lt(t)}catch(a){return{ok:!1,issues:[{path:"$.recipe",code:"schema",message:$(a)}],mapped:0,total:0}}const r=Zt(e,o);let n=0,s=0;for(const[a,i]of t.regions.entries()){const c=`$.recipe.regions[${a}]`;try{const l=d(i.range);s+=l.right-l.left+1;const f=r.get(i.dataset);f?n+=Ut(i,f,c,o):y(o,`${c}.dataset`,"source","请选择宿主提供的数据集契约")}catch(l){y(o,c,"schema",$(l))}}return{ok:o.length===0,issues:o,mapped:n,total:s}}function gt(t,e,o){const r=ft(e,o),n=[...ct(t,e),...r.issues];return{...r,ok:!n.length,issues:n}}function Qt(t,e,o,r){const n=gt(t,e,o);if(!n.ok)throw new Error(n.issues.map(s=>`${s.path}: ${s.message}`).join(`
|
|
3
3
|
`));return{document:R.defineReportTemplate({...r,template:Yt(t,e,o,r.id)}),recipe:v(e),warnings:[...t.warnings]}}function Xt(t){if(!t||t.version!=="2.0"||typeof t.sheet!="string"||!Array.isArray(t.regions)||!t.regions.length||t.regions.length>128)throw new Error("多区域绑定会话配置或版本无效");for(const e of t.regions){if(!e||typeof e.id!="string"||typeof e.dataset!="string"||typeof e.rowKey!="string"||!["record","repeat"].includes(e.mode)||!Array.isArray(e.fields)||e.fields.length>2048||e.fields.some(o=>typeof o!="string"))throw new Error("多区域绑定会话的区域结构无效");e.range&&d(e.range),e.headerRange&&d(e.headerRange)}t.footerRange&&d(t.footerRange)}function ht(t,e,o){if(H({sheets:t.sheets,warnings:t.warnings,recipe:e,identity:o}),Xt(e),!Array.isArray(t.sheets)||!t.sheets.length||!Array.isArray(t.warnings)||t.warnings.some(r=>typeof r!="string")||!t.sheets.some(r=>r.name===e.sheet))throw new Error("多区域绑定会话的来源无效");for(const r of t.sheets)if(d(r.range),![r.index,r.rowCount,r.columnCount,r.pageCount].every(n=>Number.isInteger(n)&&n>0)||!Number.isInteger(r.pageStart)||r.pageStart<0||r.pageStart+r.pageCount>t.template.pages.length)throw new Error("多区域绑定会话的工作表几何无效");return R.parseReportTemplate({schemaVersion:"1.0",...o,template:t.template}),v({version:"2.0",source:t,recipe:e,identity:o})}function te(t){if(typeof t=="string"&&t.length>1e7)throw new Error("绑定会话超过 1000 万字符上限");const e=typeof t=="string"?JSON.parse(t):t;if(!e||e.version!=="2.0"||!e.source||!e.recipe||!e.identity)throw new Error("多区域绑定会话结构或版本无效");return ht(e.source,e.recipe,e.identity)}function ee(t,e,o,r=o){const n=t.sheets.find(i=>i.name===e);if(!n)throw new Error("工作表不存在");const s=d(n.range);if(![o.row,o.column,r.row,r.column].every(Number.isInteger))throw new Error("单元格坐标应为整数");const a={top:Math.min(o.row,r.row),bottom:Math.max(o.row,r.row),left:Math.min(o.column,r.column),right:Math.max(o.column,r.column)};if(a.top<s.top||a.bottom>s.bottom||a.left<s.left||a.right>s.right)throw new Error("选区超出来源工作表");return M(a)}exports.bindExcelTemplate=V;exports.checkedRange=dt;exports.columnName=S;exports.createExcelBindingDocument=Kt;exports.createExcelBindingSession=et;exports.createExcelRegionBindingDocument=Qt;exports.createExcelRegionBindingSession=ht;exports.excelBindingCellRange=ee;exports.excelBindingRowRange=Lt;exports.getExcelSheetWindow=Jt;exports.mergeLookup=Et;exports.mergeRowGroups=wt;exports.parseExcelBindingSession=Dt;exports.parseExcelRegionBindingSession=te;exports.parseImportRange=d;exports.rangeName=M;exports.rowSegments=yt;exports.selectedMerges=ut;exports.selectedRange=mt;exports.validateExcelBindingFields=X;exports.validateExcelBindingRecipe=tt;exports.validateExcelBindingRegions=Q;exports.validateExcelRegionBindings=gt;exports.validateExcelRegionFields=ft;exports.validateExcelRegionGeometry=ct;
|