@evotecit/officeimo 0.1.2 → 0.1.4
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 +59 -51
- package/bundles/officeimo-canopyx.js +1553 -314
- package/bundles/officeimo-canopyx.mjs +1497 -269
- package/bundles/officeimo-csv.js +18 -15
- package/bundles/officeimo-csv.mjs +16 -13
- package/bundles/officeimo-datatables.js +463 -301
- package/bundles/officeimo-datatables.mjs +420 -259
- package/bundles/officeimo-pdf.js +148 -65
- package/bundles/officeimo-pdf.mjs +124 -41
- package/bundles/officeimo-xlsx.js +177 -101
- package/bundles/officeimo-xlsx.mjs +149 -74
- package/bundles/officeimo.js +461 -299
- package/bundles/officeimo.mjs +419 -258
- package/dist/csv/index.js +16 -13
- package/dist/integrations/canopyx/diagnostics.d.ts +3 -0
- package/dist/integrations/canopyx/diagnostics.js +17 -0
- package/dist/integrations/canopyx/grouping.d.ts +6 -0
- package/dist/integrations/canopyx/grouping.js +198 -0
- package/dist/integrations/canopyx/index.d.ts +2 -2
- package/dist/integrations/canopyx/index.js +89 -15
- package/dist/integrations/canopyx/metadata.d.ts +4 -0
- package/dist/integrations/canopyx/metadata.js +51 -0
- package/dist/integrations/canopyx/pdf-layout.d.ts +5 -0
- package/dist/integrations/canopyx/pdf-layout.js +97 -0
- package/dist/integrations/canopyx/pdf-number.d.ts +3 -0
- package/dist/integrations/canopyx/pdf-number.js +64 -0
- package/dist/integrations/canopyx/pivot.d.ts +15 -0
- package/dist/integrations/canopyx/pivot.js +67 -0
- package/dist/integrations/canopyx/presentation.d.ts +8 -0
- package/dist/integrations/canopyx/presentation.js +40 -0
- package/dist/integrations/canopyx/rule-predicates.d.ts +3 -0
- package/dist/integrations/canopyx/rule-predicates.js +110 -0
- package/dist/integrations/canopyx/rules.d.ts +6 -0
- package/dist/integrations/canopyx/rules.js +176 -0
- package/dist/integrations/canopyx/source.js +69 -31
- package/dist/integrations/canopyx/types.d.ts +134 -10
- package/dist/integrations/canopyx/workbook.d.ts +6 -0
- package/dist/integrations/canopyx/workbook.js +52 -0
- package/dist/opc/index.js +9 -0
- package/dist/pdf/font-resources.js +33 -14
- package/dist/pdf/pages.js +60 -14
- package/dist/pdf/table-band-flow.js +7 -2
- package/dist/pdf/table-band-plan.js +9 -1
- package/dist/pdf/table-layout.js +6 -2
- package/dist/pdf/table-structure.js +9 -8
- package/dist/xlsx/index.d.ts +1 -1
- package/dist/xlsx/options.js +1 -1
- package/dist/xlsx/outlines.d.ts +3 -0
- package/dist/xlsx/outlines.js +39 -0
- package/dist/xlsx/types.d.ts +9 -0
- package/dist/xlsx/values.js +11 -2
- package/dist/xlsx/workbook.js +2 -0
- package/dist/xlsx/worksheet.js +14 -6
- package/package.json +2 -2
|
@@ -1389,7 +1389,7 @@ const { captureFields } = _m10;
|
|
|
1389
1389
|
/** @internal The workbook owner captures these settings before validation or adapter merging. */
|
|
1390
1390
|
const workbookOptionFields = ["signal", "onProgress", "limits", "sink", "dateMode", "compression", "invalidCharacterPolicy", "appProperties", "cellValueWriters", "oversizedText", "creator", "title", "subject", "description", "created", "modified"];
|
|
1391
1391
|
/** @internal Worksheet settings also used by the portable sheet owner. */
|
|
1392
|
-
const sheetOptionFields = ["columns", "includeHeader", "headerRows", "freezeHeader", "autoFilter", "boldHeader", "headerFill", "headerStyle", "alternatingRowStyle", "rowStyle", "cellStyle", "rowOutline", "maxOutlineLevel", "rowHeight", "headerHeight", "defaultColumnWidth", "freezeColumns", "table", "autoSize", "footer", "print", "title", "mergedCells", "hyperlinks", "conditionalFormats", "dataValidation"];
|
|
1392
|
+
const sheetOptionFields = ["columns", "includeHeader", "headerRows", "freezeHeader", "autoFilter", "boldHeader", "headerFill", "headerStyle", "alternatingRowStyle", "rowStyle", "cellStyle", "rowOutline", "maxOutlineLevel", "outlineSummaryBelow", "outlineSummaryRight", "columnOutlines", "rowHeight", "headerHeight", "defaultColumnWidth", "freezeColumns", "table", "autoSize", "footer", "print", "title", "mergedCells", "hyperlinks", "conditionalFormats", "dataValidation"];
|
|
1393
1393
|
/** @internal Includes inherited format-specific ceilings before a wrapper combines stream settings. */
|
|
1394
1394
|
const workbookLimitFields = ["maxRows", "maxCells", "maxTextCharacters", "maxOutputBytes", "maxStyles", "maxSheets", "maxOverflowCharacters", "maxHyperlinks", "maxImageBytes", "maxBufferedCells", "maxBufferedCharacters", "maxMergedRanges", "maxConditionalFormats", "maxDifferentialStyles", "maxCharts", "maxChartPoints", "maxChartTextCharacters", "maxFormulaCharacters", "maxDataValidations", "maxValidationTextCharacters"];
|
|
1395
1395
|
/** @internal Capture the workbook's known ceilings without dropping supported prototype fields. */
|
|
@@ -2092,7 +2092,16 @@ class OpcPackage {
|
|
|
2092
2092
|
throw new OfficeIMOError("INVALID_STATE", "OPC package is finalized."); }
|
|
2093
2093
|
reserve(uri, type) {
|
|
2094
2094
|
this.open();
|
|
2095
|
+
// OPC part names become ZIP entry names. Reject oversized and deeply nested
|
|
2096
|
+
// names before collecting every ancestor prefix.
|
|
2097
|
+
if (typeof uri === "string" && uri.length > 65536)
|
|
2098
|
+
throw new OfficeIMOError("RESOURCE_LIMIT", "OPC part name exceeds the ZIP entry-name limit.");
|
|
2095
2099
|
uri = partUri(uri);
|
|
2100
|
+
let depth = 0;
|
|
2101
|
+
for (let index = 0; index < uri.length; index++) {
|
|
2102
|
+
if (uri[index] === "/" && ++depth > 64)
|
|
2103
|
+
throw new OfficeIMOError("RESOURCE_LIMIT", "OPC part name exceeds the directory-depth limit.");
|
|
2104
|
+
}
|
|
2096
2105
|
if (/\/_rels(?:\/|$)/i.test(uri) || uri.toLowerCase() === "/[content_types].xml")
|
|
2097
2106
|
throw new TypeError("Package metadata part names are reserved.");
|
|
2098
2107
|
const key = uri.toLowerCase();
|
|
@@ -2771,14 +2780,23 @@ function columnName(index) {
|
|
|
2771
2780
|
return name;
|
|
2772
2781
|
}
|
|
2773
2782
|
function clipName(text, length) { return text.slice(0, length).replace(/[\ud800-\udbff]$/, ""); }
|
|
2783
|
+
function trimSheetNameEdges(text) {
|
|
2784
|
+
let start = 0, end = text.length;
|
|
2785
|
+
const removable = (character) => character === "'" || /\s/u.test(character);
|
|
2786
|
+
while (start < end && removable(text[start]))
|
|
2787
|
+
start++;
|
|
2788
|
+
while (end > start && removable(text[end - 1]))
|
|
2789
|
+
end--;
|
|
2790
|
+
return text.slice(start, end);
|
|
2791
|
+
}
|
|
2774
2792
|
function sheetName(requested, names, policy, register = true) {
|
|
2775
2793
|
if (typeof requested !== "string")
|
|
2776
2794
|
throw new TypeError("Sheet name must be a string.");
|
|
2777
2795
|
// Validate and deduplicate the decoded literal value, before ST_Xstring attribute encoding.
|
|
2778
2796
|
// A requested _xHHHH_ token is literal text; the serializer protects its leading underscore.
|
|
2779
|
-
let base = cleanXml(requested, policy).replace(/[\[\]:*?/\\]/g, "_")
|
|
2797
|
+
let base = trimSheetNameEdges(cleanXml(requested, policy).replace(/[\[\]:*?/\\]/g, "_"));
|
|
2780
2798
|
// Clipping can expose an internal apostrophe or the reserved History name.
|
|
2781
|
-
base = clipName(base, 31)
|
|
2799
|
+
base = trimSheetNameEdges(clipName(base, 31));
|
|
2782
2800
|
if (!base)
|
|
2783
2801
|
base = "Sheet";
|
|
2784
2802
|
if (base.toLowerCase() === "history")
|
|
@@ -2808,7 +2826,52 @@ const _exports = Object.freeze({ Cell: Cell, assertXlsxValue: assertXlsxValue, c
|
|
|
2808
2826
|
return _exports;
|
|
2809
2827
|
})();
|
|
2810
2828
|
|
|
2811
|
-
const
|
|
2829
|
+
const _m37 = (() => {
|
|
2830
|
+
const { captureFields } = _m10;
|
|
2831
|
+
|
|
2832
|
+
/** Capture bounded disjoint ranges before asynchronous serialization; absent columns stay visible. */
|
|
2833
|
+
function captureColumnOutlines(input, columns) {
|
|
2834
|
+
if (input === undefined)
|
|
2835
|
+
return undefined;
|
|
2836
|
+
if (!Array.isArray(input) || input.length > columns)
|
|
2837
|
+
throw new TypeError("Column outlines must be bounded, non-overlapping ranges.");
|
|
2838
|
+
let end = 0;
|
|
2839
|
+
return Object.freeze(input.map(range => {
|
|
2840
|
+
if (!range || typeof range !== "object")
|
|
2841
|
+
throw new TypeError("Column outlines require range metadata.");
|
|
2842
|
+
return captureFields(range, ["firstColumn", "columnCount", "level", "hidden", "collapsed"]);
|
|
2843
|
+
}).sort((a, b) => a.firstColumn - b.firstColumn).map(range => {
|
|
2844
|
+
const { firstColumn, columnCount, level = 0, hidden, collapsed } = range;
|
|
2845
|
+
if (!Number.isSafeInteger(firstColumn) || firstColumn < end || !Number.isSafeInteger(columnCount) || columnCount < 1 || firstColumn + columnCount > columns)
|
|
2846
|
+
throw new RangeError("Column outline ranges must be disjoint and within the declared columns.");
|
|
2847
|
+
if (!Number.isInteger(level) || level < 0 || level > 7)
|
|
2848
|
+
throw new RangeError("Column outline level must be from zero through seven.");
|
|
2849
|
+
for (const flag of [hidden, collapsed])
|
|
2850
|
+
if (flag !== undefined && typeof flag !== "boolean")
|
|
2851
|
+
throw new TypeError("Column outline flags must be booleans.");
|
|
2852
|
+
end = firstColumn + columnCount;
|
|
2853
|
+
return Object.freeze({ firstColumn, columnCount, level, ...(hidden === undefined ? {} : { hidden }), ...(collapsed === undefined ? {} : { collapsed }) });
|
|
2854
|
+
}));
|
|
2855
|
+
}
|
|
2856
|
+
/** @internal Positions are captured even when a sheet has only column outlines. */
|
|
2857
|
+
function validateOutlinePositions(options) {
|
|
2858
|
+
for (const flag of [options.outlineSummaryBelow, options.outlineSummaryRight])
|
|
2859
|
+
if (flag !== undefined && typeof flag !== "boolean")
|
|
2860
|
+
throw new TypeError("Outline summary positions must be booleans.");
|
|
2861
|
+
}
|
|
2862
|
+
/** @internal Resolve at most 16,384 columns once, without retaining any worksheet body. */
|
|
2863
|
+
function columnOutlineMap(ranges) {
|
|
2864
|
+
const result = new Map();
|
|
2865
|
+
for (const range of ranges ?? [])
|
|
2866
|
+
for (let index = range.firstColumn; index < range.firstColumn + range.columnCount; index++)
|
|
2867
|
+
result.set(index, range);
|
|
2868
|
+
return result;
|
|
2869
|
+
}
|
|
2870
|
+
const _exports = Object.freeze({ captureColumnOutlines: captureColumnOutlines, validateOutlinePositions: validateOutlinePositions, columnOutlineMap: columnOutlineMap });
|
|
2871
|
+
return _exports;
|
|
2872
|
+
})();
|
|
2873
|
+
|
|
2874
|
+
const _m40 = (() => {
|
|
2812
2875
|
const { ChunkedTextSink } = _m3;
|
|
2813
2876
|
|
|
2814
2877
|
const { escapeXml, xmlDeclaration } = _m28;
|
|
@@ -2920,14 +2983,14 @@ const _exports = Object.freeze({ chartNamespace: chartNamespace, chartContentTyp
|
|
|
2920
2983
|
return _exports;
|
|
2921
2984
|
})();
|
|
2922
2985
|
|
|
2923
|
-
const
|
|
2986
|
+
const _m39 = (() => {
|
|
2924
2987
|
const { cleanXml, escapeXml, escapeOoxmlAttribute, xmlDeclaration } = _m28;
|
|
2925
2988
|
|
|
2926
2989
|
const { copyExportLink } = _m7;
|
|
2927
2990
|
|
|
2928
2991
|
const { officeRelationshipsNamespace } = _m25;
|
|
2929
2992
|
|
|
2930
|
-
const { chartAnchorXml } =
|
|
2993
|
+
const { chartAnchorXml } = _m40;
|
|
2931
2994
|
|
|
2932
2995
|
const { captureFields } = _m10;
|
|
2933
2996
|
|
|
@@ -2997,10 +3060,10 @@ const _exports = Object.freeze({ copyDrawingAnchor: copyDrawingAnchor, cellPosit
|
|
|
2997
3060
|
return _exports;
|
|
2998
3061
|
})();
|
|
2999
3062
|
|
|
3000
|
-
const
|
|
3063
|
+
const _m42 = (() => {
|
|
3001
3064
|
const { OfficeIMOError } = _m2;
|
|
3002
3065
|
|
|
3003
|
-
const { cellPosition } =
|
|
3066
|
+
const { cellPosition } = _m39;
|
|
3004
3067
|
|
|
3005
3068
|
function indexRows(regions) {
|
|
3006
3069
|
if (!regions.length)
|
|
@@ -3101,7 +3164,7 @@ const _exports = Object.freeze({ MergeRegions: MergeRegions });
|
|
|
3101
3164
|
return _exports;
|
|
3102
3165
|
})();
|
|
3103
3166
|
|
|
3104
|
-
const
|
|
3167
|
+
const _m43 = (() => {
|
|
3105
3168
|
const { ExportCell } = _m5;
|
|
3106
3169
|
|
|
3107
3170
|
const { tableSpans } = _m18;
|
|
@@ -3137,7 +3200,7 @@ const _exports = Object.freeze({ StructuredRows: StructuredRows });
|
|
|
3137
3200
|
return _exports;
|
|
3138
3201
|
})();
|
|
3139
3202
|
|
|
3140
|
-
const
|
|
3203
|
+
const _m41 = (() => {
|
|
3141
3204
|
const { ExportCell } = _m5;
|
|
3142
3205
|
|
|
3143
3206
|
const { isDate } = _m6;
|
|
@@ -3148,13 +3211,13 @@ const { FormulaCell } = _m36;
|
|
|
3148
3211
|
|
|
3149
3212
|
const { escapeOoxmlAttribute } = _m28;
|
|
3150
3213
|
|
|
3151
|
-
const { MergeRegions } =
|
|
3214
|
+
const { MergeRegions } = _m42;
|
|
3152
3215
|
|
|
3153
3216
|
const { OfficeIMOError } = _m2;
|
|
3154
3217
|
|
|
3155
3218
|
const { createTotals } = _m12;
|
|
3156
3219
|
|
|
3157
|
-
const { StructuredRows } =
|
|
3220
|
+
const { StructuredRows } = _m43;
|
|
3158
3221
|
|
|
3159
3222
|
/** @internal A computed formula with a numeric cache; no public arbitrary-formula input. */
|
|
3160
3223
|
class ComputedTotal {
|
|
@@ -3337,7 +3400,7 @@ const _exports = Object.freeze({ ComputedTotal: ComputedTotal, ReportLayout: Rep
|
|
|
3337
3400
|
return _exports;
|
|
3338
3401
|
})();
|
|
3339
3402
|
|
|
3340
|
-
const
|
|
3403
|
+
const _m45 = (() => {
|
|
3341
3404
|
const { columnName } = _m35;
|
|
3342
3405
|
|
|
3343
3406
|
/** @internal Data-column selectors use stable keys or one-based worksheet columns. */
|
|
@@ -3367,7 +3430,7 @@ const _exports = Object.freeze({ resolveDataColumn: resolveDataColumn, qualified
|
|
|
3367
3430
|
return _exports;
|
|
3368
3431
|
})();
|
|
3369
3432
|
|
|
3370
|
-
const
|
|
3433
|
+
const _m46 = (() => {
|
|
3371
3434
|
const { OfficeIMOError } = _m2;
|
|
3372
3435
|
|
|
3373
3436
|
const { columnName } = _m35;
|
|
@@ -3413,18 +3476,18 @@ const _exports = Object.freeze({ retainDataRowRanges: retainDataRowRanges, dataR
|
|
|
3413
3476
|
return _exports;
|
|
3414
3477
|
})();
|
|
3415
3478
|
|
|
3416
|
-
const
|
|
3479
|
+
const _m44 = (() => {
|
|
3417
3480
|
const { cleanXml, escapeXml, escapeOoxmlAttribute } = _m28;
|
|
3418
3481
|
|
|
3419
|
-
const { cellPosition } =
|
|
3482
|
+
const { cellPosition } = _m39;
|
|
3420
3483
|
|
|
3421
3484
|
const { colorArgb } = _m33;
|
|
3422
3485
|
|
|
3423
3486
|
const { fields, optionalBoolean, differentialXml } = _m34;
|
|
3424
3487
|
|
|
3425
|
-
const { resolveDataColumn } =
|
|
3488
|
+
const { resolveDataColumn } = _m45;
|
|
3426
3489
|
|
|
3427
|
-
const { dataRowReference } =
|
|
3490
|
+
const { dataRowReference } = _m46;
|
|
3428
3491
|
|
|
3429
3492
|
function target(range, columns) {
|
|
3430
3493
|
if (typeof range === "string") {
|
|
@@ -3582,7 +3645,7 @@ const _exports = Object.freeze({ prepareConditionalFormats: prepareConditionalFo
|
|
|
3582
3645
|
return _exports;
|
|
3583
3646
|
})();
|
|
3584
3647
|
|
|
3585
|
-
const
|
|
3648
|
+
const _m47 = (() => {
|
|
3586
3649
|
const { OfficeIMOError } = _m2;
|
|
3587
3650
|
|
|
3588
3651
|
const { checkAbort } = _m4;
|
|
@@ -3591,9 +3654,9 @@ const { cleanXml, escapeOoxmlAttribute, escapeXml } = _m28;
|
|
|
3591
3654
|
|
|
3592
3655
|
const { fields, optionalBoolean } = _m34;
|
|
3593
3656
|
|
|
3594
|
-
const { resolveDataColumn } =
|
|
3657
|
+
const { resolveDataColumn } = _m45;
|
|
3595
3658
|
|
|
3596
|
-
const { dataRowReference } =
|
|
3659
|
+
const { dataRowReference } = _m46;
|
|
3597
3660
|
|
|
3598
3661
|
function message(value, maximum, name) {
|
|
3599
3662
|
if (value === undefined)
|
|
@@ -3685,7 +3748,7 @@ const _exports = Object.freeze({ prepareDataValidations: prepareDataValidations,
|
|
|
3685
3748
|
return _exports;
|
|
3686
3749
|
})();
|
|
3687
3750
|
|
|
3688
|
-
const
|
|
3751
|
+
const _m38 = (() => {
|
|
3689
3752
|
const { checkAbort, consumeRows, inputRows, pause, taskYieldDue } = _m4;
|
|
3690
3753
|
|
|
3691
3754
|
const { ChunkedTextSink, BlobByteSink } = _m3;
|
|
@@ -3706,25 +3769,27 @@ const { Cell, cellText, columnName, inlineText, excelDate, copyValue } = _m35;
|
|
|
3706
3769
|
|
|
3707
3770
|
const { spreadsheetNamespace, colorArgb, validateStylePatch, copyStylePatch } = _m32;
|
|
3708
3771
|
|
|
3709
|
-
const { copyHyperlink, copyImage, hyperlinksXml, cellPosition } =
|
|
3772
|
+
const { copyHyperlink, copyImage, hyperlinksXml, cellPosition } = _m39;
|
|
3710
3773
|
|
|
3711
3774
|
const { ExportCell, assertScalar } = _m5;
|
|
3712
3775
|
|
|
3713
|
-
const { ReportLayout, ComputedTotal, printXml } =
|
|
3776
|
+
const { ReportLayout, ComputedTotal, printXml } = _m41;
|
|
3714
3777
|
|
|
3715
3778
|
const { cleanXml } = _m28;
|
|
3716
3779
|
|
|
3717
|
-
const { ConditionalFormats, prepareConditionalFormats } =
|
|
3780
|
+
const { ConditionalFormats, prepareConditionalFormats } = _m44;
|
|
3718
3781
|
|
|
3719
3782
|
const { isDate } = _m6;
|
|
3720
3783
|
|
|
3721
3784
|
const { FormulaCell, formulaXml, isSubtotalFormula } = _m36;
|
|
3722
3785
|
|
|
3723
|
-
const { prepareDataValidations, dataValidationsXml } =
|
|
3786
|
+
const { prepareDataValidations, dataValidationsXml } = _m47;
|
|
3724
3787
|
|
|
3725
|
-
const { qualifiedCell, qualifiedColumnRange, resolveDataColumn } =
|
|
3788
|
+
const { qualifiedCell, qualifiedColumnRange, resolveDataColumn } = _m45;
|
|
3726
3789
|
|
|
3727
|
-
const { dataRowRanges, dataRowCount } =
|
|
3790
|
+
const { dataRowRanges, dataRowCount } = _m46;
|
|
3791
|
+
|
|
3792
|
+
const { captureColumnOutlines, columnOutlineMap, validateOutlinePositions } = _m37;
|
|
3728
3793
|
|
|
3729
3794
|
const maximumHyperlinks = 65530;
|
|
3730
3795
|
function checkHyperlinkCount(count) {
|
|
@@ -3856,6 +3921,8 @@ class Worksheet {
|
|
|
3856
3921
|
throw new TypeError("Row and style callbacks must be functions.");
|
|
3857
3922
|
if (options.maxOutlineLevel !== undefined && (!Number.isInteger(options.maxOutlineLevel) || options.maxOutlineLevel < 0 || options.maxOutlineLevel > 7))
|
|
3858
3923
|
throw new RangeError("Maximum outline level must be an integer from zero through seven.");
|
|
3924
|
+
validateOutlinePositions(options);
|
|
3925
|
+
captureColumnOutlines(options.columnOutlines, columns.length);
|
|
3859
3926
|
if (options.rowOutline && options.maxOutlineLevel === undefined)
|
|
3860
3927
|
throw new TypeError("A row outline callback requires maxOutlineLevel before streamed rows are written.");
|
|
3861
3928
|
if (!options.rowOutline && options.maxOutlineLevel !== undefined)
|
|
@@ -4140,17 +4207,22 @@ class Worksheet {
|
|
|
4140
4207
|
const buffer = this.buffer = new ChunkedTextSink(this.entry, this.book.settings.signal), opts = this.options;
|
|
4141
4208
|
const x = opts.freezeColumns ?? 0, y = opts.freezeHeader ? this.headerRows : 0;
|
|
4142
4209
|
const pane = x && y ? "bottomRight" : x ? "topRight" : "bottomLeft", cell = columnName(x + 1) + (y + 1);
|
|
4210
|
+
const outlines = columnOutlineMap(opts.columnOutlines), hasOutline = !!opts.rowOutline || outlines.size > 0;
|
|
4211
|
+
const maxColumnLevel = Math.max(0, ...Array.from(outlines.values(), value => value.level ?? 0));
|
|
4143
4212
|
await buffer.write(xmlDeclaration + '<worksheet xmlns="' + spreadsheetNamespace + '" xmlns:r="' + officeRelationshipsNamespace + '">' +
|
|
4144
|
-
(opts.print ||
|
|
4213
|
+
(opts.print || hasOutline ? '<sheetPr>' + (hasOutline ? '<outlinePr summaryBelow="' + (opts.outlineSummaryBelow === false ? "0" : "1") + '"' + (opts.outlineSummaryRight === undefined ? "" : ' summaryRight="' + (opts.outlineSummaryRight ? "1" : "0") + '"') + ' showOutlineSymbols="1"/>' : "") + (opts.print ? '<pageSetUpPr fitToPage="1"/>' : "") + '</sheetPr>' : "") + '<sheetViews><sheetView workbookViewId="0">' +
|
|
4145
4214
|
(x || y ? '<pane' + (x ? ' xSplit="' + x + '"' : "") + (y ? ' ySplit="' + y + '"' : "") + ' topLeftCell="' + cell + '" activePane="' + pane + '" state="frozen"/><selection pane="' + pane + '" activeCell="' + cell + '" sqref="' + cell + '"/>' : "") + '</sheetView></sheetViews>' +
|
|
4146
|
-
(
|
|
4215
|
+
(hasOutline ? '<sheetFormatPr defaultRowHeight="15"' + (opts.rowOutline ? ' outlineLevelRow="' + opts.maxOutlineLevel + '"' : "") + (outlines.size ? ' outlineLevelCol="' + maxColumnLevel + '"' : "") + '/>' : ""));
|
|
4147
4216
|
const defaultWidth = opts.defaultColumnWidth ?? (this.table ? 20 : undefined);
|
|
4148
|
-
if (this.columns.some((_, i) => this.layout.widths[i] !== undefined || defaultWidth !== undefined)) {
|
|
4217
|
+
if (this.columns.some((_, i) => this.layout.widths[i] !== undefined || defaultWidth !== undefined || outlines.has(i))) {
|
|
4149
4218
|
await buffer.write('<cols>');
|
|
4150
4219
|
for (let i = 0; i < this.columns.length; i++) {
|
|
4151
|
-
const width = this.layout.widths[i] ?? defaultWidth;
|
|
4152
|
-
if (width !== undefined)
|
|
4153
|
-
await buffer.write('<col min="' + (i + 1) + '" max="' + (i + 1) + '"
|
|
4220
|
+
const width = this.layout.widths[i] ?? defaultWidth, outline = outlines.get(i);
|
|
4221
|
+
if (width !== undefined || outline)
|
|
4222
|
+
await buffer.write('<col min="' + (i + 1) + '" max="' + (i + 1) + '"' +
|
|
4223
|
+
(width === undefined ? "" : ' width="' + width + '" customWidth="1"') +
|
|
4224
|
+
(outline?.level ? ' outlineLevel="' + outline.level + '"' : "") + (outline?.hidden ? ' hidden="1"' : "") +
|
|
4225
|
+
(outline?.collapsed ? ' collapsed="1"' : "") + '/>');
|
|
4154
4226
|
}
|
|
4155
4227
|
await buffer.write('</cols>');
|
|
4156
4228
|
}
|
|
@@ -4411,7 +4483,7 @@ const _exports = Object.freeze({ Worksheet: Worksheet });
|
|
|
4411
4483
|
return _exports;
|
|
4412
4484
|
})();
|
|
4413
4485
|
|
|
4414
|
-
const
|
|
4486
|
+
const _m48 = (() => {
|
|
4415
4487
|
const { escapeOoxmlAttribute, escapeXml, xmlDeclaration } = _m28;
|
|
4416
4488
|
|
|
4417
4489
|
const { cellText, columnName } = _m35;
|
|
@@ -4422,7 +4494,7 @@ const { ExportCell } = _m5;
|
|
|
4422
4494
|
|
|
4423
4495
|
const { Cell } = _m35;
|
|
4424
4496
|
|
|
4425
|
-
const { totalFormula } =
|
|
4497
|
+
const { totalFormula } = _m41;
|
|
4426
4498
|
|
|
4427
4499
|
function defineTable(id, options, columns, policy) {
|
|
4428
4500
|
const name = options.name ?? "Table" + id;
|
|
@@ -4457,7 +4529,7 @@ const _exports = Object.freeze({ defineTable: defineTable, tableXml: tableXml })
|
|
|
4457
4529
|
return _exports;
|
|
4458
4530
|
})();
|
|
4459
4531
|
|
|
4460
|
-
const
|
|
4532
|
+
const _m49 = (() => {
|
|
4461
4533
|
const { OfficeIMOError } = _m2;
|
|
4462
4534
|
|
|
4463
4535
|
const { cleanXml } = _m28;
|
|
@@ -4524,7 +4596,7 @@ const _exports = Object.freeze({ TextOverflow: TextOverflow, clipText: clipText
|
|
|
4524
4596
|
return _exports;
|
|
4525
4597
|
})();
|
|
4526
4598
|
|
|
4527
|
-
const
|
|
4599
|
+
const _m51 = (() => {
|
|
4528
4600
|
const { checkAbort } = _m4;
|
|
4529
4601
|
|
|
4530
4602
|
const { NotSupportedError, OfficeIMOError } = _m2;
|
|
@@ -4655,18 +4727,18 @@ const _exports = Object.freeze({ captureChartRange: captureChartRange, prepareCh
|
|
|
4655
4727
|
return _exports;
|
|
4656
4728
|
})();
|
|
4657
4729
|
|
|
4658
|
-
const
|
|
4730
|
+
const _m50 = (() => {
|
|
4659
4731
|
const { checkAbort } = _m4;
|
|
4660
4732
|
|
|
4661
4733
|
const { NotSupportedError, OfficeIMOError } = _m2;
|
|
4662
4734
|
|
|
4663
4735
|
const { cleanXml } = _m28;
|
|
4664
4736
|
|
|
4665
|
-
const { copyDrawingAnchor } =
|
|
4737
|
+
const { copyDrawingAnchor } = _m39;
|
|
4666
4738
|
|
|
4667
4739
|
const { captureFields } = _m10;
|
|
4668
4740
|
|
|
4669
|
-
const { captureChartRange, prepareChartBinding } =
|
|
4741
|
+
const { captureChartRange, prepareChartBinding } = _m51;
|
|
4670
4742
|
|
|
4671
4743
|
function fields(value, allowed, context) {
|
|
4672
4744
|
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
@@ -4848,25 +4920,27 @@ const { copyColumns } = _m11;
|
|
|
4848
4920
|
|
|
4849
4921
|
const { captureFields } = _m10;
|
|
4850
4922
|
|
|
4923
|
+
const { captureColumnOutlines } = _m37;
|
|
4924
|
+
|
|
4851
4925
|
const { captureTableSpans } = _m18;
|
|
4852
4926
|
|
|
4853
4927
|
const { assertExportValue } = _m5;
|
|
4854
4928
|
|
|
4855
|
-
const { Worksheet } =
|
|
4929
|
+
const { Worksheet } = _m38;
|
|
4856
4930
|
|
|
4857
|
-
const { defineTable, tableXml } =
|
|
4931
|
+
const { defineTable, tableXml } = _m48;
|
|
4858
4932
|
|
|
4859
|
-
const { copyHyperlink, drawingXml, drawingContentType } =
|
|
4933
|
+
const { copyHyperlink, drawingXml, drawingContentType } = _m39;
|
|
4860
4934
|
|
|
4861
|
-
const { TextOverflow } =
|
|
4935
|
+
const { TextOverflow } = _m49;
|
|
4862
4936
|
|
|
4863
4937
|
const { captureWorkbookOptions, sheetOptionFields } = _m22;
|
|
4864
4938
|
|
|
4865
|
-
const { prepareChart } =
|
|
4939
|
+
const { prepareChart } = _m50;
|
|
4866
4940
|
|
|
4867
|
-
const { qualifiedColumnRange, resolveDataColumn } =
|
|
4941
|
+
const { qualifiedColumnRange, resolveDataColumn } = _m45;
|
|
4868
4942
|
|
|
4869
|
-
const { chartContentType, writeChartXml } =
|
|
4943
|
+
const { chartContentType, writeChartXml } = _m40;
|
|
4870
4944
|
|
|
4871
4945
|
const xlsxMime = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
|
4872
4946
|
const formatType = (name) => "application/vnd.openxmlformats-officedocument.spreadsheetml." + name + "+xml";
|
|
@@ -4877,6 +4951,7 @@ function captureSheet(options, policy) {
|
|
|
4877
4951
|
const footer = captured.footer && captureFields(captured.footer, ["rows", "values", "totals", "style"]);
|
|
4878
4952
|
const print = captured.print && captureFields(captured.print, ["paper", "orientation", "fitToWidth", "fitToHeight", "repeatHeaders", "margins", "header", "footer"]);
|
|
4879
4953
|
return { ...captured, columns,
|
|
4954
|
+
...(captured.columnOutlines === undefined ? {} : { columnOutlines: captureColumnOutlines(captured.columnOutlines, columns.length) }),
|
|
4880
4955
|
...(captured.headerRows === undefined ? {} : { headerRows: captureTableSpans(captured.headerRows, columns.length) }),
|
|
4881
4956
|
...(footer ? { footer: { ...footer,
|
|
4882
4957
|
...(footer.rows === undefined ? {} : { rows: captureTableSpans(footer.rows, columns.length) }),
|
|
@@ -5306,7 +5381,7 @@ const _exports = Object.freeze({ Workbook: Workbook });
|
|
|
5306
5381
|
return _exports;
|
|
5307
5382
|
})();
|
|
5308
5383
|
|
|
5309
|
-
const
|
|
5384
|
+
const _m53 = (() => {
|
|
5310
5385
|
const { ExportCell, assertScalar } = _m5;
|
|
5311
5386
|
|
|
5312
5387
|
const { captureWorkbookOptions, sheetOptionFields } = _m22;
|
|
@@ -5358,14 +5433,14 @@ const _exports = Object.freeze({ portableSheet: portableSheet, portableWorkbook:
|
|
|
5358
5433
|
return _exports;
|
|
5359
5434
|
})();
|
|
5360
5435
|
|
|
5361
|
-
const
|
|
5436
|
+
const _m52 = (() => {
|
|
5362
5437
|
const { withDestination } = _m3;
|
|
5363
5438
|
|
|
5364
5439
|
const { copyColumns } = _m11;
|
|
5365
5440
|
|
|
5366
5441
|
const { Workbook } = _m24;
|
|
5367
5442
|
|
|
5368
|
-
const { portableSheet, portableWorkbook } =
|
|
5443
|
+
const { portableSheet, portableWorkbook } = _m53;
|
|
5369
5444
|
|
|
5370
5445
|
const { captureFields } = _m10;
|
|
5371
5446
|
|
|
@@ -5416,7 +5491,7 @@ const _exports = Object.freeze({ writeXlsx: writeXlsx, writeXlsxTo: writeXlsxTo
|
|
|
5416
5491
|
return _exports;
|
|
5417
5492
|
})();
|
|
5418
5493
|
|
|
5419
|
-
const
|
|
5494
|
+
const _m55 = (() => {
|
|
5420
5495
|
const { assertGroupedReportSource } = _m8;
|
|
5421
5496
|
|
|
5422
5497
|
const { captureFields } = _m10;
|
|
@@ -5427,9 +5502,9 @@ const { fields } = _m34;
|
|
|
5427
5502
|
|
|
5428
5503
|
const { sheetOptionFields } = _m22;
|
|
5429
5504
|
|
|
5430
|
-
const { portableSheet } =
|
|
5505
|
+
const { portableSheet } = _m53;
|
|
5431
5506
|
|
|
5432
|
-
const { resolveDataColumn } =
|
|
5507
|
+
const { resolveDataColumn } = _m45;
|
|
5433
5508
|
|
|
5434
5509
|
const { copyStylePatch } = _m32;
|
|
5435
5510
|
|
|
@@ -5508,7 +5583,7 @@ const _exports = Object.freeze({ groupedOptionFields: groupedOptionFields, prepa
|
|
|
5508
5583
|
return _exports;
|
|
5509
5584
|
})();
|
|
5510
5585
|
|
|
5511
|
-
const
|
|
5586
|
+
const _m54 = (() => {
|
|
5512
5587
|
const { groupedReportOperation } = _m8;
|
|
5513
5588
|
|
|
5514
5589
|
const { checkAbort, withAbort } = _m4;
|
|
@@ -5525,9 +5600,9 @@ const { columnName } = _m35;
|
|
|
5525
5600
|
|
|
5526
5601
|
const { captureWorkbookLimits, workbookOptionFields } = _m22;
|
|
5527
5602
|
|
|
5528
|
-
const { retainDataRowRanges } =
|
|
5603
|
+
const { retainDataRowRanges } = _m46;
|
|
5529
5604
|
|
|
5530
|
-
const { groupedOptionFields, prepareGroupedSheet } =
|
|
5605
|
+
const { groupedOptionFields, prepareGroupedSheet } = _m55;
|
|
5531
5606
|
|
|
5532
5607
|
const subtotalOperations = { average: 1, count: 2, max: 4, min: 5, sum: 9 };
|
|
5533
5608
|
function label(value) {
|
|
@@ -5686,11 +5761,11 @@ return _exports;
|
|
|
5686
5761
|
|
|
5687
5762
|
const _m23 = (() => {
|
|
5688
5763
|
|
|
5689
|
-
const _exports = Object.freeze({ Workbook: _m24.Workbook, writeXlsx:
|
|
5764
|
+
const _exports = Object.freeze({ Workbook: _m24.Workbook, writeXlsx: _m52.writeXlsx, writeXlsxTo: _m52.writeXlsxTo, writeGroupedXlsx: _m54.writeGroupedXlsx, writeGroupedXlsxTo: _m54.writeGroupedXlsxTo, addGroupedXlsx: _m54.addGroupedXlsx, createGroupedReport: _m8.createGroupedReport, Worksheet: _m38.Worksheet, Cell: _m35.Cell, FormulaCell: _m36.FormulaCell, StyleRegistry: _m32.StyleRegistry, NumberFormats: _m32.NumberFormats, saveBlob: _m1.saveBlob, ExportCell: _m5.ExportCell });
|
|
5690
5765
|
return _exports;
|
|
5691
5766
|
})();
|
|
5692
5767
|
|
|
5693
|
-
const
|
|
5768
|
+
const _m57 = (() => {
|
|
5694
5769
|
const { captureTableSpans, tableSpans } = _m18;
|
|
5695
5770
|
|
|
5696
5771
|
/** Snapshot small report matrices; flattening is an explicit format decision, never inferred from labels. */
|
|
@@ -5711,7 +5786,7 @@ const _exports = Object.freeze({ csvStructuredRows: csvStructuredRows });
|
|
|
5711
5786
|
return _exports;
|
|
5712
5787
|
})();
|
|
5713
5788
|
|
|
5714
|
-
const
|
|
5789
|
+
const _m56 = (() => {
|
|
5715
5790
|
const { beginTask, checkAbort, consumeRows, taskYieldDue, withAbort } = _m4;
|
|
5716
5791
|
|
|
5717
5792
|
const { BlobByteSink, ChunkedTextSink, withDestination } = _m3;
|
|
@@ -5726,7 +5801,7 @@ const { notifyProgress } = _m14;
|
|
|
5726
5801
|
|
|
5727
5802
|
const { copyColumns, createRowProjector } = _m11;
|
|
5728
5803
|
|
|
5729
|
-
const { csvStructuredRows } =
|
|
5804
|
+
const { csvStructuredRows } = _m57;
|
|
5730
5805
|
|
|
5731
5806
|
const { captureBooleanText } = _m21;
|
|
5732
5807
|
|
|
@@ -5736,29 +5811,32 @@ const { captureCsvOptions } = _m16;
|
|
|
5736
5811
|
|
|
5737
5812
|
|
|
5738
5813
|
|
|
5739
|
-
function csvField(value, delimiter, protect, quote, booleanText
|
|
5740
|
-
|
|
5741
|
-
value = nullValue;
|
|
5814
|
+
function csvField(value, delimiter, protect, quote, booleanText) {
|
|
5815
|
+
const kind = typeof value;
|
|
5742
5816
|
let text;
|
|
5743
5817
|
if (value == null)
|
|
5744
5818
|
text = "";
|
|
5819
|
+
else if (kind === "string")
|
|
5820
|
+
text = value;
|
|
5821
|
+
else if (kind === "number") {
|
|
5822
|
+
text = Number.isFinite(value) ? String(value) : "";
|
|
5823
|
+
// Numeric text has no CSV delimiter, quote or line break to escape.
|
|
5824
|
+
return quote === "all" ? '"' + text + '"' : text;
|
|
5825
|
+
}
|
|
5826
|
+
else if (kind === "boolean")
|
|
5827
|
+
text = booleanText[value ? "true" : "false"];
|
|
5745
5828
|
else if (isDate(value))
|
|
5746
5829
|
text = Number.isFinite(value.getTime()) ? value.toISOString() : "";
|
|
5747
|
-
else if (typeof value === "boolean")
|
|
5748
|
-
text = booleanText[value ? "true" : "false"];
|
|
5749
|
-
else if (typeof value === "number")
|
|
5750
|
-
text = Number.isFinite(value) ? String(value) : "";
|
|
5751
|
-
else if (typeof value === "string")
|
|
5752
|
-
text = value;
|
|
5753
5830
|
else {
|
|
5754
5831
|
if (typeof value.then === "function")
|
|
5755
5832
|
void Promise.resolve(value).catch(() => { });
|
|
5756
5833
|
throw new TypeError("CSV cells and formatter results must be synchronous strings, numbers, booleans, Dates or null.");
|
|
5757
5834
|
}
|
|
5758
|
-
|
|
5835
|
+
// Only ASCII spaces, controls and markers through @ can begin the protected prefix.
|
|
5836
|
+
if (protect && (kind === "string" || kind === "boolean") && text.charCodeAt(0) <= 64 && /^ *[=+\-@\t\r\n]/.test(text))
|
|
5759
5837
|
text = "'" + text;
|
|
5760
|
-
return quote === "all" || (quote === "strings" &&
|
|
5761
|
-
? '"' + text.replace(/"/g, '""') + '"' : text;
|
|
5838
|
+
return quote === "all" || (quote === "strings" && kind === "string") || text.includes(delimiter) || /["\r\n]/.test(text)
|
|
5839
|
+
? '"' + (text.includes('"') ? text.replace(/"/g, '""') : text) + '"' : text;
|
|
5762
5840
|
}
|
|
5763
5841
|
async function writeCsvTo(rows, destination, configuration) {
|
|
5764
5842
|
const options = captureCsvOptions(configuration);
|
|
@@ -5810,7 +5888,7 @@ async function write(rows, sink, options) {
|
|
|
5810
5888
|
value = options.nullValue;
|
|
5811
5889
|
budget.cell(typeof value === "boolean" ? booleanText[value ? "true" : "false"] : value);
|
|
5812
5890
|
checkAbort(signal);
|
|
5813
|
-
text += (i ? delimiter : "") + csvField(value, delimiter, protect, quote, booleanText
|
|
5891
|
+
text += (i ? delimiter : "") + csvField(value, delimiter, protect, quote, booleanText);
|
|
5814
5892
|
if (text.length >= buffer.chunkSize || (i & 127) === 127 && taskYieldDue()) {
|
|
5815
5893
|
if (buffer.append(text))
|
|
5816
5894
|
return buffer.flush().then(() => record(values, header, i + 1, snapshot));
|
|
@@ -5861,7 +5939,7 @@ const _exports = Object.freeze({ saveBlob: _m1.saveBlob, ExportCell: _m5.ExportC
|
|
|
5861
5939
|
return _exports;
|
|
5862
5940
|
})();
|
|
5863
5941
|
|
|
5864
|
-
const
|
|
5942
|
+
const _m62 = (() => {
|
|
5865
5943
|
/** @internal One type byte, an eight-byte offset/container number and a two-byte generation/index. */
|
|
5866
5944
|
const pdfXrefEntryBytes = 11;
|
|
5867
5945
|
function unsigned(bytes, offset, value, width) {
|
|
@@ -5896,12 +5974,12 @@ const _exports = Object.freeze({ pdfXrefEntryBytes: pdfXrefEntryBytes, pdfXrefCh
|
|
|
5896
5974
|
return _exports;
|
|
5897
5975
|
})();
|
|
5898
5976
|
|
|
5899
|
-
const
|
|
5977
|
+
const _m61 = (() => {
|
|
5900
5978
|
const { checkAbort, withAbort, pause, taskYieldDue } = _m4;
|
|
5901
5979
|
|
|
5902
5980
|
const { OfficeIMOError } = _m2;
|
|
5903
5981
|
|
|
5904
|
-
const { pdfXrefChunks, pdfXrefEntryBytes } =
|
|
5982
|
+
const { pdfXrefChunks, pdfXrefEntryBytes } = _m62;
|
|
5905
5983
|
|
|
5906
5984
|
const compactObjectCount = 256, compactObjectBytes = 32768;
|
|
5907
5985
|
const compactIndexChunkEntries = 4096;
|
|
@@ -6224,7 +6302,7 @@ const _exports = Object.freeze({ pdfNumber: pdfNumber, unicodeHex: unicodeHex, P
|
|
|
6224
6302
|
return _exports;
|
|
6225
6303
|
})();
|
|
6226
6304
|
|
|
6227
|
-
const
|
|
6305
|
+
const _m66 = (() => {
|
|
6228
6306
|
/** @internal Bounded big-endian reader used for caller-provided TrueType programs. */
|
|
6229
6307
|
class FontReader {
|
|
6230
6308
|
bytes;
|
|
@@ -6253,8 +6331,8 @@ const _exports = Object.freeze({ FontReader: FontReader, checksum: checksum, ali
|
|
|
6253
6331
|
return _exports;
|
|
6254
6332
|
})();
|
|
6255
6333
|
|
|
6256
|
-
const
|
|
6257
|
-
const { align4 } =
|
|
6334
|
+
const _m67 = (() => {
|
|
6335
|
+
const { align4 } = _m66;
|
|
6258
6336
|
|
|
6259
6337
|
const { checkAbort, pause, taskYieldDue } = _m4;
|
|
6260
6338
|
|
|
@@ -6477,12 +6555,12 @@ const _exports = Object.freeze({ subsetTrueType: subsetTrueType, subsetTrueTypeC
|
|
|
6477
6555
|
return _exports;
|
|
6478
6556
|
})();
|
|
6479
6557
|
|
|
6480
|
-
const
|
|
6558
|
+
const _m65 = (() => {
|
|
6481
6559
|
const { NotSupportedError } = _m2;
|
|
6482
6560
|
|
|
6483
|
-
const { FontReader } =
|
|
6561
|
+
const { FontReader } = _m66;
|
|
6484
6562
|
|
|
6485
|
-
const { subsetTrueType, subsetTrueTypeCooperatively } =
|
|
6563
|
+
const { subsetTrueType, subsetTrueTypeCooperatively } = _m67;
|
|
6486
6564
|
|
|
6487
6565
|
const { checkAbort, pause, taskYieldDue } = _m4;
|
|
6488
6566
|
|
|
@@ -6721,8 +6799,8 @@ const _exports = Object.freeze({ TrueTypeFont: TrueTypeFont });
|
|
|
6721
6799
|
return _exports;
|
|
6722
6800
|
})();
|
|
6723
6801
|
|
|
6724
|
-
const
|
|
6725
|
-
const { TrueTypeFont } =
|
|
6802
|
+
const _m64 = (() => {
|
|
6803
|
+
const { TrueTypeFont } = _m65;
|
|
6726
6804
|
|
|
6727
6805
|
const { beginTask, checkAbort } = _m4;
|
|
6728
6806
|
|
|
@@ -6784,7 +6862,7 @@ const _exports = Object.freeze({ fontProgram: fontProgram, PdfFont: PdfFont });
|
|
|
6784
6862
|
return _exports;
|
|
6785
6863
|
})();
|
|
6786
6864
|
|
|
6787
|
-
const
|
|
6865
|
+
const _m69 = (() => {
|
|
6788
6866
|
// Generated by scripts/pdf-widths.mjs from OfficeIMO.Pdf's Adobe AFM-derived metrics.
|
|
6789
6867
|
const helveticaWidths = new Map([
|
|
6790
6868
|
[32, [278, 278]],
|
|
@@ -7106,12 +7184,12 @@ const _exports = Object.freeze({ helveticaWidths: helveticaWidths });
|
|
|
7106
7184
|
return _exports;
|
|
7107
7185
|
})();
|
|
7108
7186
|
|
|
7109
|
-
const
|
|
7187
|
+
const _m68 = (() => {
|
|
7110
7188
|
const { OfficeIMOError } = _m2;
|
|
7111
7189
|
|
|
7112
|
-
const { PdfFont, fontProgram } =
|
|
7190
|
+
const { PdfFont, fontProgram } = _m64;
|
|
7113
7191
|
|
|
7114
|
-
const { helveticaWidths } =
|
|
7192
|
+
const { helveticaWidths } = _m69;
|
|
7115
7193
|
|
|
7116
7194
|
const winAnsiExtras = new Map([0x20ac, 0, 0x201a, 0x192, 0x201e, 0x2026, 0x2020, 0x2021, 0x2c6, 0x2030, 0x160, 0x2039, 0x152, 0, 0x17d, 0, 0, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, 0x2dc, 0x2122, 0x161, 0x203a, 0x153, 0, 0x17e, 0x178].map((cp, i) => [cp, i + 128]));
|
|
7117
7195
|
/** @internal Called after scalar support succeeds when encoding a standard-font run. */
|
|
@@ -7174,18 +7252,19 @@ const _exports = Object.freeze({ standardCode: standardCode, resolveScalar: reso
|
|
|
7174
7252
|
return _exports;
|
|
7175
7253
|
})();
|
|
7176
7254
|
|
|
7177
|
-
const
|
|
7255
|
+
const _m63 = (() => {
|
|
7178
7256
|
const { NotSupportedError, OfficeIMOError } = _m2;
|
|
7179
7257
|
|
|
7180
|
-
const { fontProgram } =
|
|
7258
|
+
const { fontProgram } = _m64;
|
|
7181
7259
|
|
|
7182
|
-
const { resolveScalar, selectFont, standardCode, validateFonts } =
|
|
7260
|
+
const { resolveScalar, selectFont, standardCode, validateFonts } = _m68;
|
|
7183
7261
|
|
|
7184
|
-
const { pdfNumber, unicodeHex } =
|
|
7262
|
+
const { pdfNumber, unicodeHex } = _m61;
|
|
7185
7263
|
|
|
7186
7264
|
const { checkAbort, pause, taskYieldDue } = _m4;
|
|
7187
7265
|
|
|
7188
|
-
const
|
|
7266
|
+
const hexBytes = Object.freeze(Array.from({ length: 256 }, (_, byte) => byte.toString(16).padStart(2, "0")));
|
|
7267
|
+
function cidHex(cid) { return hexBytes[cid >>> 8] + hexBytes[cid & 255]; }
|
|
7189
7268
|
class PdfFontResource {
|
|
7190
7269
|
index;
|
|
7191
7270
|
bold;
|
|
@@ -7216,12 +7295,16 @@ class PdfFontResource {
|
|
|
7216
7295
|
width(scalar) {
|
|
7217
7296
|
if (this.shared)
|
|
7218
7297
|
return this.shared.width(scalar);
|
|
7219
|
-
|
|
7220
|
-
|
|
7221
|
-
|
|
7222
|
-
|
|
7223
|
-
|
|
7224
|
-
|
|
7298
|
+
if (this.program) {
|
|
7299
|
+
const existing = this.mappings.get(scalar);
|
|
7300
|
+
if (existing)
|
|
7301
|
+
return existing.width;
|
|
7302
|
+
}
|
|
7303
|
+
else {
|
|
7304
|
+
const standard = this.standardWidths.get(scalar);
|
|
7305
|
+
if (standard !== undefined)
|
|
7306
|
+
return standard;
|
|
7307
|
+
}
|
|
7225
7308
|
const resolved = resolveScalar(scalar, this.program, this.bold);
|
|
7226
7309
|
if (!resolved.supported) {
|
|
7227
7310
|
if (resolved.code === "unpaired-surrogate")
|
|
@@ -7234,7 +7317,8 @@ class PdfFontResource {
|
|
|
7234
7317
|
}
|
|
7235
7318
|
if (this.mappings.size >= 65535)
|
|
7236
7319
|
throw new OfficeIMOError("RESOURCE_LIMIT", "A PDF font supports at most 65,535 distinct Unicode scalars.");
|
|
7237
|
-
const
|
|
7320
|
+
const cid = this.mappings.size + 1;
|
|
7321
|
+
const mapping = { cid, hex: cidHex(cid), glyph: resolved.glyph, width: resolved.width, text: String.fromCodePoint(scalar) };
|
|
7238
7322
|
this.mappings.set(scalar, mapping);
|
|
7239
7323
|
return mapping.width;
|
|
7240
7324
|
}
|
|
@@ -7247,8 +7331,20 @@ class PdfFontResource {
|
|
|
7247
7331
|
let hex = "";
|
|
7248
7332
|
for (const char of text) {
|
|
7249
7333
|
const cp = char.codePointAt(0);
|
|
7250
|
-
this.
|
|
7251
|
-
|
|
7334
|
+
if (this.program) {
|
|
7335
|
+
let mapping = this.mappings.get(cp);
|
|
7336
|
+
// Layout normally registered the scalar already; validate only a newly painted scalar.
|
|
7337
|
+
if (!mapping) {
|
|
7338
|
+
this.width(cp);
|
|
7339
|
+
mapping = this.mappings.get(cp);
|
|
7340
|
+
}
|
|
7341
|
+
hex += mapping.hex;
|
|
7342
|
+
}
|
|
7343
|
+
else {
|
|
7344
|
+
if (!this.standardWidths.has(cp))
|
|
7345
|
+
this.width(cp);
|
|
7346
|
+
hex += hexBytes[standardCode(cp)];
|
|
7347
|
+
}
|
|
7252
7348
|
}
|
|
7253
7349
|
return "<" + hex + ">";
|
|
7254
7350
|
}
|
|
@@ -7263,10 +7359,11 @@ class PdfFontResource {
|
|
|
7263
7359
|
if (!mapping) {
|
|
7264
7360
|
if (this.mappings.size >= 65535)
|
|
7265
7361
|
throw new OfficeIMOError("RESOURCE_LIMIT", "A PDF font supports at most 65,535 distinct CID mappings.");
|
|
7266
|
-
|
|
7362
|
+
const cid = this.mappings.size + 1;
|
|
7363
|
+
mapping = { cid, hex: cidHex(cid), glyph, width: this.program.widths[glyph], text };
|
|
7267
7364
|
this.mappings.set(key, mapping);
|
|
7268
7365
|
}
|
|
7269
|
-
return "<" + mapping.
|
|
7366
|
+
return "<" + mapping.hex + ">";
|
|
7270
7367
|
}
|
|
7271
7368
|
async write(objects, compression) {
|
|
7272
7369
|
checkAbort(this.signal);
|
|
@@ -7315,7 +7412,7 @@ class PdfFontResource {
|
|
|
7315
7412
|
const batch = mapped.slice(i, i + 100);
|
|
7316
7413
|
cmap += batch.length + " beginbfchar\n";
|
|
7317
7414
|
for (const [, m] of batch)
|
|
7318
|
-
cmap += "<" + m.
|
|
7415
|
+
cmap += "<" + m.hex + "> <" + unicodeHex(m.text) + ">\n";
|
|
7319
7416
|
cmap += "endbfchar\n";
|
|
7320
7417
|
if (taskYieldDue())
|
|
7321
7418
|
await pause();
|
|
@@ -7366,7 +7463,7 @@ class PdfFontResources {
|
|
|
7366
7463
|
if (!found)
|
|
7367
7464
|
this.explicitSelections.set(explicit, selections);
|
|
7368
7465
|
}
|
|
7369
|
-
const key =
|
|
7466
|
+
const key = (bold ? 2 : 0) | (italic ? 1 : 0), existing = selections.get(key);
|
|
7370
7467
|
if (existing)
|
|
7371
7468
|
return existing;
|
|
7372
7469
|
const { font, syntheticBold, syntheticItalic } = explicit ? { font: explicit, syntheticBold: bold, syntheticItalic: italic } : selectFont(this.fonts, bold, italic);
|
|
@@ -7386,7 +7483,7 @@ const _exports = Object.freeze({ PdfFontResource: PdfFontResource, PdfFontResour
|
|
|
7386
7483
|
return _exports;
|
|
7387
7484
|
})();
|
|
7388
7485
|
|
|
7389
|
-
const
|
|
7486
|
+
const _m71 = (() => {
|
|
7390
7487
|
const { OfficeIMOError } = _m2;
|
|
7391
7488
|
|
|
7392
7489
|
const { ExportCell, assertExportValue } = _m5;
|
|
@@ -7497,7 +7594,7 @@ const _exports = Object.freeze({ pdfBudgetText: pdfBudgetText, synchronousText:
|
|
|
7497
7594
|
return _exports;
|
|
7498
7595
|
})();
|
|
7499
7596
|
|
|
7500
|
-
const
|
|
7597
|
+
const _m73 = (() => {
|
|
7501
7598
|
const { NotSupportedError, OfficeIMOError } = _m2;
|
|
7502
7599
|
|
|
7503
7600
|
const { checkAbort, pause, taskYieldDue, withAbort } = _m4;
|
|
@@ -7709,7 +7806,7 @@ const _exports = Object.freeze({ wrapShapedPdfText: wrapShapedPdfText });
|
|
|
7709
7806
|
return _exports;
|
|
7710
7807
|
})();
|
|
7711
7808
|
|
|
7712
|
-
const
|
|
7809
|
+
const _m72 = (() => {
|
|
7713
7810
|
const { NotSupportedError, OfficeIMOError } = _m2;
|
|
7714
7811
|
|
|
7715
7812
|
const { copyExportLink } = _m7;
|
|
@@ -7718,11 +7815,11 @@ const { checkAbort, pause, taskYieldDue } = _m4;
|
|
|
7718
7815
|
|
|
7719
7816
|
const { presentation, color } = _m17;
|
|
7720
7817
|
|
|
7721
|
-
const { wrapShapedPdfText } =
|
|
7818
|
+
const { wrapShapedPdfText } = _m73;
|
|
7722
7819
|
|
|
7723
|
-
const { PdfFont } =
|
|
7820
|
+
const { PdfFont } = _m64;
|
|
7724
7821
|
|
|
7725
|
-
const { pdfBudgetText } =
|
|
7822
|
+
const { pdfBudgetText } = _m71;
|
|
7726
7823
|
|
|
7727
7824
|
/** @internal Callers supply an owned, validated, frozen base presentation. A run list is a PDF presentation value, never an alternate shared table value model. */
|
|
7728
7825
|
function capturePdfText(value, base, settings, fonts, countEmpty = true, reserveBudget = true) {
|
|
@@ -7904,10 +8001,10 @@ const _exports = Object.freeze({ capturePdfText: capturePdfText, wrapPdfText: wr
|
|
|
7904
8001
|
return _exports;
|
|
7905
8002
|
})();
|
|
7906
8003
|
|
|
7907
|
-
const
|
|
8004
|
+
const _m74 = (() => {
|
|
7908
8005
|
const { OfficeIMOError } = _m2;
|
|
7909
8006
|
|
|
7910
|
-
const { wrapPdfText } =
|
|
8007
|
+
const { wrapPdfText } = _m72;
|
|
7911
8008
|
|
|
7912
8009
|
/** Plan without opening a source. Exact column widths never shrink in band mode. */
|
|
7913
8010
|
function planTableBands(widths, settings) {
|
|
@@ -7952,6 +8049,14 @@ async function projectBandRows(rows, band, widths, settings, fonts) {
|
|
|
7952
8049
|
for (const row of rows) {
|
|
7953
8050
|
const cells = [];
|
|
7954
8051
|
for (const cell of row.cells) {
|
|
8052
|
+
// Ordinary data and leaf headings keep their captured width and lines in every band.
|
|
8053
|
+
// Look up their physical position without allocating another per-row column index.
|
|
8054
|
+
if (cell.span === 1) {
|
|
8055
|
+
const first = band.columns.indexOf(cell.first);
|
|
8056
|
+
if (first >= 0)
|
|
8057
|
+
cells.push({ ...cell, source: cell.source ?? cell, first });
|
|
8058
|
+
continue;
|
|
8059
|
+
}
|
|
7955
8060
|
for (let first = 0; first < band.columns.length;) {
|
|
7956
8061
|
const source = band.columns[first];
|
|
7957
8062
|
if (source < cell.first || source >= cell.first + cell.span) {
|
|
@@ -7962,7 +8067,7 @@ async function projectBandRows(rows, band, widths, settings, fonts) {
|
|
|
7962
8067
|
while (end < band.columns.length && band.columns[end] === band.columns[end - 1] + 1 && band.columns[end] < cell.first + cell.span)
|
|
7963
8068
|
end++;
|
|
7964
8069
|
const width = band.columns.slice(first, end).reduce((sum, index) => sum + widths[index], 0);
|
|
7965
|
-
const lines =
|
|
8070
|
+
const lines = await wrapPdfText(cell.captured, fonts, settings.fontSize, width - settings.padding * 2, settings, cell.style.wrapText !== false);
|
|
7966
8071
|
cells.push({ ...cell, source: cell.source ?? cell, first, span: end - first, width, lines,
|
|
7967
8072
|
lineHeight: lines.reduce((height, line) => Math.max(height, line.lineHeight), cell.font.lineHeight(settings.fontSize)) });
|
|
7968
8073
|
first = end;
|
|
@@ -7994,7 +8099,7 @@ const _exports = Object.freeze({ planTableBands: planTableBands, projectBandRows
|
|
|
7994
8099
|
return _exports;
|
|
7995
8100
|
})();
|
|
7996
8101
|
|
|
7997
|
-
const
|
|
8102
|
+
const _m70 = (() => {
|
|
7998
8103
|
const { ExportCell } = _m5;
|
|
7999
8104
|
|
|
8000
8105
|
const { copyExportLink } = _m7;
|
|
@@ -8005,11 +8110,11 @@ const { createTotals } = _m12;
|
|
|
8005
8110
|
|
|
8006
8111
|
const { presentation, positive } = _m17;
|
|
8007
8112
|
|
|
8008
|
-
const { displayText, pdfBudgetText } =
|
|
8113
|
+
const { displayText, pdfBudgetText } = _m71;
|
|
8009
8114
|
|
|
8010
|
-
const { capturePdfText, wrapPdfText } =
|
|
8115
|
+
const { capturePdfText, wrapPdfText } = _m72;
|
|
8011
8116
|
|
|
8012
|
-
const { planTableBands, projectBandRows, alignBandBlocks } =
|
|
8117
|
+
const { planTableBands, projectBandRows, alignBandBlocks } = _m74;
|
|
8013
8118
|
|
|
8014
8119
|
class PdfTableLayout {
|
|
8015
8120
|
settings;
|
|
@@ -8114,8 +8219,12 @@ class PdfTableLayout {
|
|
|
8114
8219
|
lines };
|
|
8115
8220
|
}
|
|
8116
8221
|
row(cells) {
|
|
8117
|
-
|
|
8118
|
-
|
|
8222
|
+
let lines = 1, lineHeight = this.lineHeight;
|
|
8223
|
+
for (let index = 0; index < cells.length; index++) {
|
|
8224
|
+
const cell = cells[index];
|
|
8225
|
+
lines = Math.max(lines, cell.lines.length);
|
|
8226
|
+
lineHeight = Math.max(lineHeight, cell.lineHeight);
|
|
8227
|
+
}
|
|
8119
8228
|
return { cells, lines, lineHeight, height: lines * lineHeight + this.settings.padding * 2 };
|
|
8120
8229
|
}
|
|
8121
8230
|
async headers() {
|
|
@@ -8224,7 +8333,7 @@ const _exports = Object.freeze({ PdfTableLayout: PdfTableLayout });
|
|
|
8224
8333
|
return _exports;
|
|
8225
8334
|
})();
|
|
8226
8335
|
|
|
8227
|
-
const
|
|
8336
|
+
const _m76 = (() => {
|
|
8228
8337
|
const { OfficeIMOError } = _m2;
|
|
8229
8338
|
|
|
8230
8339
|
const { checkAbort } = _m4;
|
|
@@ -8268,7 +8377,7 @@ class PdfTableBandFlow {
|
|
|
8268
8377
|
await this.flush();
|
|
8269
8378
|
}
|
|
8270
8379
|
async row(row, allowFirstFragment = false) {
|
|
8271
|
-
const { padding, fontSize, options } = this.layout.settings, minimumLines = this.layout.minimumRowLines(row), minimumHeight =
|
|
8380
|
+
const { padding, fontSize, options } = this.layout.settings, minimumLines = this.layout.minimumRowLines(row), minimumHeight = minimumLines * row.lineHeight + padding * 2;
|
|
8272
8381
|
if (minimumHeight > this.painter.firstFullCapacity + .001 || minimumHeight > this.painter.continuationCapacity + .001)
|
|
8273
8382
|
throw new RangeError("Repeated PDF identifiers must fit intact below the first and continued band headings/context.");
|
|
8274
8383
|
// Keep ordinary rows intact when they fit fresh. A kept heading/caption can deliberately
|
|
@@ -8302,9 +8411,14 @@ class PdfTableBandFlow {
|
|
|
8302
8411
|
let remaining = false;
|
|
8303
8412
|
const cells = rows[0].cells.map(cell => {
|
|
8304
8413
|
const source = this.layout.bands[index].columns[cell.first];
|
|
8305
|
-
const repeated = this.layout.repeatedColumn(source),
|
|
8414
|
+
const repeated = this.layout.repeatedColumn(source), reusable = cell.span === 1 && (cell.source?.span ?? 1) === 1 && (cell.rowSpan ?? 1) === 1 &&
|
|
8415
|
+
cell.height === undefined && first === 0 && (repeated || lines >= cell.lines.length);
|
|
8416
|
+
const visible = repeated || reusable ? cell.lines : cell.lines.slice(first, first + lines);
|
|
8306
8417
|
if (!repeated && (visible.length > 0 || cell.link !== undefined))
|
|
8307
8418
|
remaining = true;
|
|
8419
|
+
// A complete first fragment already owns these lines and their maximum font metrics.
|
|
8420
|
+
if (reusable)
|
|
8421
|
+
return cell;
|
|
8308
8422
|
const { height: _height, ...plain } = cell;
|
|
8309
8423
|
return { ...plain, lines: visible,
|
|
8310
8424
|
lineHeight: visible.reduce((value, line) => Math.max(value, line.lineHeight), cell.font.lineHeight(fontSize)),
|
|
@@ -8360,7 +8474,7 @@ const _exports = Object.freeze({ PdfTableBandFlow: PdfTableBandFlow });
|
|
|
8360
8474
|
return _exports;
|
|
8361
8475
|
})();
|
|
8362
8476
|
|
|
8363
|
-
const
|
|
8477
|
+
const _m77 = (() => {
|
|
8364
8478
|
/** @internal Source-cell identities survive page fragments and horizontal band projections.
|
|
8365
8479
|
* Only column headers and still-owned row objects remain reachable from this table owner. */
|
|
8366
8480
|
class PdfTableStructure {
|
|
@@ -8412,30 +8526,31 @@ class PdfTableStructure {
|
|
|
8412
8526
|
return row.cells.map(cell => this.cells.get(cell));
|
|
8413
8527
|
const rowId = this.structure.element("TR", parent);
|
|
8414
8528
|
this.rows.set(row, rowId);
|
|
8415
|
-
const headers = row.cells.map((cell, index) => rowHeaderIndex === undefined ? cell.rowHeader === true : index === rowHeaderIndex);
|
|
8416
8529
|
// Allocate in source order, then resolve every row header before associating even earlier data cells.
|
|
8417
8530
|
// Generated summary labels override detail roles so numeric subtotal cells never become row headers.
|
|
8418
8531
|
const ids = row.cells.map((cell, index) => {
|
|
8419
|
-
const
|
|
8532
|
+
const header = rowHeaderIndex === undefined ? cell.rowHeader === true : index === rowHeaderIndex;
|
|
8533
|
+
const id = this.structure.element(header ? "TH" : "TD", rowId);
|
|
8420
8534
|
this.cells.set(cell, id);
|
|
8421
8535
|
return id;
|
|
8422
8536
|
});
|
|
8423
|
-
|
|
8537
|
+
let rowHeaders;
|
|
8424
8538
|
for (let index = 0; index < ids.length; index++)
|
|
8425
|
-
if (
|
|
8426
|
-
rowHeaders.push(await this.structure.identifier(ids[index]));
|
|
8539
|
+
if (rowHeaderIndex === undefined ? row.cells[index].rowHeader === true : index === rowHeaderIndex)
|
|
8540
|
+
(rowHeaders ??= []).push(await this.structure.identifier(ids[index]));
|
|
8427
8541
|
for (let index = 0; index < row.cells.length; index++) {
|
|
8428
8542
|
const cell = row.cells[index];
|
|
8429
|
-
if (!rowHeaders
|
|
8543
|
+
if (!rowHeaders && cell.span === 1 && (cell.rowSpan ?? 1) === 1) {
|
|
8430
8544
|
const attributes = this.ordinaryAttributes[cell.first] ??=
|
|
8431
8545
|
await this.structure.attributeReference(this.attributeDictionary(cell, this.associations(cell)));
|
|
8432
8546
|
this.structure.setAttributes(ids[index], attributes);
|
|
8433
8547
|
continue;
|
|
8434
8548
|
}
|
|
8435
8549
|
const associations = this.associations(cell);
|
|
8436
|
-
|
|
8550
|
+
const header = rowHeaderIndex === undefined ? cell.rowHeader === true : index === rowHeaderIndex;
|
|
8551
|
+
if (!header && rowHeaders)
|
|
8437
8552
|
associations.push(...rowHeaders);
|
|
8438
|
-
this.structure.setAttributes(ids[index], this.attributes(cell, associations,
|
|
8553
|
+
this.structure.setAttributes(ids[index], this.attributes(cell, associations, header ? "Row" : undefined));
|
|
8439
8554
|
}
|
|
8440
8555
|
return ids;
|
|
8441
8556
|
}
|
|
@@ -8473,10 +8588,10 @@ const _exports = Object.freeze({ PdfTableStructure: PdfTableStructure });
|
|
|
8473
8588
|
return _exports;
|
|
8474
8589
|
})();
|
|
8475
8590
|
|
|
8476
|
-
const
|
|
8591
|
+
const _m78 = (() => {
|
|
8477
8592
|
const { OfficeIMOError } = _m2;
|
|
8478
8593
|
|
|
8479
|
-
const { pdfNumber, unicodeHex } =
|
|
8594
|
+
const { pdfNumber, unicodeHex } = _m61;
|
|
8480
8595
|
|
|
8481
8596
|
const encoder = new TextEncoder();
|
|
8482
8597
|
/** @internal URI actions are byte strings; tooltips are Unicode PDF text strings. */
|
|
@@ -8518,10 +8633,10 @@ const _exports = Object.freeze({ linkAnnotation: linkAnnotation });
|
|
|
8518
8633
|
return _exports;
|
|
8519
8634
|
})();
|
|
8520
8635
|
|
|
8521
|
-
const
|
|
8636
|
+
const _m79 = (() => {
|
|
8522
8637
|
const { OfficeIMOError } = _m2;
|
|
8523
8638
|
|
|
8524
|
-
const { unicodeHex } =
|
|
8639
|
+
const { unicodeHex } = _m61;
|
|
8525
8640
|
|
|
8526
8641
|
const { captureFields } = _m10;
|
|
8527
8642
|
|
|
@@ -8566,7 +8681,7 @@ const _exports = Object.freeze({ captureBookmark: captureBookmark, captureSectio
|
|
|
8566
8681
|
return _exports;
|
|
8567
8682
|
})();
|
|
8568
8683
|
|
|
8569
|
-
const
|
|
8684
|
+
const _m80 = (() => {
|
|
8570
8685
|
const { settings } = _m17;
|
|
8571
8686
|
|
|
8572
8687
|
/** @internal Every section derives from captured document defaults, never the preceding section. */
|
|
@@ -8584,28 +8699,28 @@ const _exports = Object.freeze({ sectionSettings: sectionSettings });
|
|
|
8584
8699
|
return _exports;
|
|
8585
8700
|
})();
|
|
8586
8701
|
|
|
8587
|
-
const
|
|
8702
|
+
const _m75 = (() => {
|
|
8588
8703
|
const { OfficeIMOError } = _m2;
|
|
8589
8704
|
|
|
8590
8705
|
const { checkAbort } = _m4;
|
|
8591
8706
|
|
|
8592
|
-
const { pdfNumber } =
|
|
8707
|
+
const { pdfNumber } = _m61;
|
|
8593
8708
|
|
|
8594
8709
|
const { color } = _m17;
|
|
8595
8710
|
|
|
8596
|
-
const { PdfTableBandFlow } =
|
|
8711
|
+
const { PdfTableBandFlow } = _m76;
|
|
8597
8712
|
|
|
8598
|
-
const { PdfTableStructure } =
|
|
8713
|
+
const { PdfTableStructure } = _m77;
|
|
8599
8714
|
|
|
8600
|
-
const { wrapText, wrapTextCooperatively, synchronousText, pdfBudgetText } =
|
|
8715
|
+
const { wrapText, wrapTextCooperatively, synchronousText, pdfBudgetText } = _m71;
|
|
8601
8716
|
|
|
8602
|
-
const { linkAnnotation } =
|
|
8717
|
+
const { linkAnnotation } = _m78;
|
|
8603
8718
|
|
|
8604
|
-
const { unicodeHex } =
|
|
8719
|
+
const { unicodeHex } = _m61;
|
|
8605
8720
|
|
|
8606
|
-
const { captureSection, captureBookmark } =
|
|
8721
|
+
const { captureSection, captureBookmark } = _m79;
|
|
8607
8722
|
|
|
8608
|
-
const { sectionSettings } =
|
|
8723
|
+
const { sectionSettings } = _m80;
|
|
8609
8724
|
|
|
8610
8725
|
/** @internal One page of drawing commands and O(page count) references, never the complete report body. */
|
|
8611
8726
|
class PdfPages {
|
|
@@ -8619,7 +8734,8 @@ class PdfPages {
|
|
|
8619
8734
|
outlines;
|
|
8620
8735
|
references = [];
|
|
8621
8736
|
current = 0;
|
|
8622
|
-
commands =
|
|
8737
|
+
commands = "";
|
|
8738
|
+
commandParts = [];
|
|
8623
8739
|
commandBytes = 0;
|
|
8624
8740
|
annotations = [];
|
|
8625
8741
|
hyperlinks = 0;
|
|
@@ -8637,6 +8753,12 @@ class PdfPages {
|
|
|
8637
8753
|
pendingBookmarks = [];
|
|
8638
8754
|
pageNumberWidth = 0;
|
|
8639
8755
|
colors = new Map();
|
|
8756
|
+
textFont;
|
|
8757
|
+
textSize = 0;
|
|
8758
|
+
textColor = "";
|
|
8759
|
+
textPrefix = "";
|
|
8760
|
+
rectangleLefts;
|
|
8761
|
+
rectangleColumns = [];
|
|
8640
8762
|
externalObjects = new Map();
|
|
8641
8763
|
bandFlow;
|
|
8642
8764
|
bandCellBudget = false;
|
|
@@ -8703,7 +8825,7 @@ class PdfPages {
|
|
|
8703
8825
|
}
|
|
8704
8826
|
add(command) {
|
|
8705
8827
|
this.retainPageBytes(command.length);
|
|
8706
|
-
this.commands
|
|
8828
|
+
this.commands += command;
|
|
8707
8829
|
}
|
|
8708
8830
|
retainPageBytes(length) {
|
|
8709
8831
|
this.commandBytes += length;
|
|
@@ -8723,9 +8845,17 @@ class PdfPages {
|
|
|
8723
8845
|
return this.structure ? "/Artifact << /Type /" + type + " >> BDC\n" + command + "EMC\n" : command;
|
|
8724
8846
|
}
|
|
8725
8847
|
text(text, font, size, x, baseline, foreground = "111827", element) {
|
|
8726
|
-
const n = pdfNumber
|
|
8727
|
-
|
|
8728
|
-
|
|
8848
|
+
const n = pdfNumber;
|
|
8849
|
+
if (font !== this.textFont || size !== this.textSize || foreground !== this.textColor) {
|
|
8850
|
+
const shear = font.syntheticItalic ? .213 : 0, rgb = this.rgb(foreground);
|
|
8851
|
+
// Keep one prefix, independent of report size. Resource identity includes synthetic styling.
|
|
8852
|
+
this.textPrefix = "q " + rgb + " rg " + rgb + " RG\nBT /" + font.name + " " + n(size) + " Tf " +
|
|
8853
|
+
(font.syntheticBold ? n(size * .025) + " w 2 Tr " : "0 Tr ") + "1 0 " + n(shear) + " 1 ";
|
|
8854
|
+
this.textFont = font;
|
|
8855
|
+
this.textSize = size;
|
|
8856
|
+
this.textColor = foreground;
|
|
8857
|
+
}
|
|
8858
|
+
const command = this.textPrefix + n(x) + " " + n(baseline) + " Tm " + font.encode(text) + " Tj ET Q\n";
|
|
8729
8859
|
this.add(this.structure && element !== undefined ? this.structure.mark(element) + command + "EMC\n" : this.artifact(command, "Pagination"));
|
|
8730
8860
|
}
|
|
8731
8861
|
link(link, x, bottom, width, height, element) {
|
|
@@ -8755,8 +8885,8 @@ class PdfPages {
|
|
|
8755
8885
|
for (const segment of line.segments) {
|
|
8756
8886
|
const registered = marks?.get(segment), owner = registered?.owner ?? (segment.link && this.structure && element !== undefined ? this.structure.link(element, segment.link) : element);
|
|
8757
8887
|
if (segment.glyphs) {
|
|
8758
|
-
const font = segment.font, n = pdfNumber, shear = font.syntheticItalic ? .213 : 0;
|
|
8759
|
-
let cursor = x, command = "q " +
|
|
8888
|
+
const font = segment.font, n = pdfNumber, shear = font.syntheticItalic ? .213 : 0, rgb = this.rgb(segment.color ?? "111827");
|
|
8889
|
+
let cursor = x, command = "q " + rgb + " rg " + rgb + " RG\nBT /" + font.name + " " + n(size) + " Tf " +
|
|
8760
8890
|
(font.syntheticBold ? n(size * .025) + " w 2 Tr " : "0 Tr ");
|
|
8761
8891
|
for (const glyph of segment.glyphs) {
|
|
8762
8892
|
command += "1 0 " + n(shear) + " 1 " + n(cursor + (glyph.xOffset + shear * glyph.yOffset) * size / 1000) + " " + n(baseline + glyph.yOffset * size / 1000) + " Tm " + font.encodeGlyph(glyph.id, glyph.logicalText) + " Tj\n";
|
|
@@ -8804,7 +8934,8 @@ class PdfPages {
|
|
|
8804
8934
|
this.current = this.objects.reserve();
|
|
8805
8935
|
this.references.push(this.current);
|
|
8806
8936
|
}
|
|
8807
|
-
this.commands =
|
|
8937
|
+
this.commands = "";
|
|
8938
|
+
this.commandParts = [];
|
|
8808
8939
|
this.annotations = [];
|
|
8809
8940
|
this.commandBytes = 0;
|
|
8810
8941
|
this.bodyAdded = false;
|
|
@@ -8887,15 +9018,32 @@ class PdfPages {
|
|
|
8887
9018
|
if (!this.layout)
|
|
8888
9019
|
throw new Error("A table layout is required before drawing rows.");
|
|
8889
9020
|
this.bodyAdded = true;
|
|
8890
|
-
const { padding, fontSize } = this.settings, n = pdfNumber, height = lineCount * row.lineHeight + padding * 2;
|
|
9021
|
+
const { padding, fontSize } = this.settings, n = pdfNumber, height = lineCount * row.lineHeight + padding * 2, lefts = this.layout.lefts;
|
|
9022
|
+
// One geometry token per active physical column; table/band changes release the old tokens.
|
|
9023
|
+
if (this.rectangleLefts !== lefts) {
|
|
9024
|
+
this.rectangleLefts = lefts;
|
|
9025
|
+
this.rectangleColumns = [];
|
|
9026
|
+
}
|
|
9027
|
+
let rectangleHeight, rectangleBottom = "", rectangleHeightText = "";
|
|
8891
9028
|
for (const [index, cell] of row.cells.entries()) {
|
|
8892
9029
|
if (this.bandCellBudget)
|
|
8893
9030
|
this.settings.budget.cell(this.settings.budget.limits.maxTextCharacters === undefined ? "" :
|
|
8894
9031
|
(cell.height === undefined ? cell.lines.slice(firstLine, firstLine + lineCount) : cell.lines).map(line => line.text).join(""));
|
|
8895
|
-
const x =
|
|
9032
|
+
const x = lefts[cell.first], cellHeight = cell.height ?? height;
|
|
9033
|
+
if (cellHeight !== rectangleHeight) {
|
|
9034
|
+
rectangleBottom = n(this.y - cellHeight);
|
|
9035
|
+
rectangleHeightText = n(cellHeight);
|
|
9036
|
+
rectangleHeight = cellHeight;
|
|
9037
|
+
}
|
|
9038
|
+
let horizontal = this.rectangleColumns[cell.first];
|
|
9039
|
+
if (!horizontal || horizontal.x !== x || horizontal.width !== cell.width) {
|
|
9040
|
+
horizontal = { x, width: cell.width, left: n(x), widthText: n(cell.width) };
|
|
9041
|
+
this.rectangleColumns[cell.first] = horizontal;
|
|
9042
|
+
}
|
|
9043
|
+
const rectangle = horizontal.left + " " + rectangleBottom + " " + horizontal.widthText + " " + rectangleHeightText;
|
|
8896
9044
|
if (cell.style.background)
|
|
8897
|
-
this.add(this.artifact("q " + this.rgb(cell.style.background) + " rg " +
|
|
8898
|
-
this.add(this.artifact("q 0.82 0.85 0.89 RG 0.4 w " +
|
|
9045
|
+
this.add(this.artifact("q " + this.rgb(cell.style.background) + " rg " + rectangle + " re f Q\n"));
|
|
9046
|
+
this.add(this.artifact("q 0.82 0.85 0.89 RG 0.4 w " + rectangle + " re S Q\n"));
|
|
8899
9047
|
const element = elements?.[index], artifact = cell.semanticArtifact || repeated[index], owner = cell.link && this.structure && element !== undefined ? this.structure.link(element, cell.link) : element;
|
|
8900
9048
|
for (let line = firstLine; line < Math.min(cell.lines.length, cell.height ? cell.lines.length : firstLine + lineCount); line++) {
|
|
8901
9049
|
const text = cell.lines[line], left = cell.style.alignment === "right" ? cell.width - padding - text.width : cell.style.alignment === "center" ? (cell.width - text.width) / 2 : padding;
|
|
@@ -8905,6 +9053,7 @@ class PdfPages {
|
|
|
8905
9053
|
this.link(cell.link, x, this.y - cellHeight, cell.width, cellHeight, owner);
|
|
8906
9054
|
}
|
|
8907
9055
|
this.y -= row.structured ? row.height : height;
|
|
9056
|
+
this.sealCommands();
|
|
8908
9057
|
}
|
|
8909
9058
|
async block(rows) {
|
|
8910
9059
|
if (this.bandFlow)
|
|
@@ -9230,9 +9379,22 @@ class PdfPages {
|
|
|
9230
9379
|
marker: { line: item.marker, gap: item.markerGap, ...(label === undefined ? {} : { owner: label }) } });
|
|
9231
9380
|
await this.structure?.complete(li);
|
|
9232
9381
|
}
|
|
9382
|
+
sealCommands() {
|
|
9383
|
+
if (this.commands) {
|
|
9384
|
+
this.commandParts.push(this.commands);
|
|
9385
|
+
this.commands = "";
|
|
9386
|
+
}
|
|
9387
|
+
}
|
|
9388
|
+
takeCommands() {
|
|
9389
|
+
this.sealCommands();
|
|
9390
|
+
const content = this.commandParts.join("");
|
|
9391
|
+
// Encoding and awaited delivery own the page value; the next page starts independently.
|
|
9392
|
+
this.commandParts = [];
|
|
9393
|
+
return content;
|
|
9394
|
+
}
|
|
9233
9395
|
async finishPage() {
|
|
9234
9396
|
const contents = this.objects.reserve(), { page, options } = this.settings;
|
|
9235
|
-
await this.objects.stream(contents, this.
|
|
9397
|
+
await this.objects.stream(contents, this.takeCommands(), "", options.compression !== false);
|
|
9236
9398
|
const annotations = [];
|
|
9237
9399
|
for (const annotation of this.annotations) {
|
|
9238
9400
|
annotations.push(annotation.id);
|
|
@@ -9244,7 +9406,6 @@ class PdfPages {
|
|
|
9244
9406
|
(annotations.length ? " /Annots [" + annotations.map(id => id + " 0 R").join(" ") + "]" : "") + " >>");
|
|
9245
9407
|
if (this.structure)
|
|
9246
9408
|
await this.structure.finishPage();
|
|
9247
|
-
this.commands = [];
|
|
9248
9409
|
this.annotations = [];
|
|
9249
9410
|
this.commandBytes = 0;
|
|
9250
9411
|
this.current = 0;
|
|
@@ -9279,7 +9440,7 @@ const _exports = Object.freeze({ PdfPages: PdfPages });
|
|
|
9279
9440
|
return _exports;
|
|
9280
9441
|
})();
|
|
9281
9442
|
|
|
9282
|
-
const
|
|
9443
|
+
const _m82 = (() => {
|
|
9283
9444
|
/** @internal Incremental PDF number tree: at most 64 entries/children per retained level. */
|
|
9284
9445
|
class PdfParentTree {
|
|
9285
9446
|
objects;
|
|
@@ -9341,14 +9502,14 @@ const _exports = Object.freeze({ PdfParentTree: PdfParentTree });
|
|
|
9341
9502
|
return _exports;
|
|
9342
9503
|
})();
|
|
9343
9504
|
|
|
9344
|
-
const
|
|
9505
|
+
const _m81 = (() => {
|
|
9345
9506
|
const { OfficeIMOError } = _m2;
|
|
9346
9507
|
|
|
9347
9508
|
const { checkAbort } = _m4;
|
|
9348
9509
|
|
|
9349
|
-
const { unicodeHex } =
|
|
9510
|
+
const { unicodeHex } = _m61;
|
|
9350
9511
|
|
|
9351
|
-
const { PdfParentTree } =
|
|
9512
|
+
const { PdfParentTree } = _m82;
|
|
9352
9513
|
|
|
9353
9514
|
/** Same-page marked content uses integer K; cross-page MCR and annotation OBJR stay explicit. */
|
|
9354
9515
|
function structureChild(child) {
|
|
@@ -9652,12 +9813,12 @@ const _exports = Object.freeze({ PdfStructure: PdfStructure, graphicAlternative:
|
|
|
9652
9813
|
return _exports;
|
|
9653
9814
|
})();
|
|
9654
9815
|
|
|
9655
|
-
const
|
|
9816
|
+
const _m83 = (() => {
|
|
9656
9817
|
const { OfficeIMOError } = _m2;
|
|
9657
9818
|
|
|
9658
9819
|
const { checkAbort } = _m4;
|
|
9659
9820
|
|
|
9660
|
-
const { pdfNumber, unicodeHex } =
|
|
9821
|
+
const { pdfNumber, unicodeHex } = _m61;
|
|
9661
9822
|
|
|
9662
9823
|
/** @internal Bounded native bookmarks; destinations are captured only when their content is painted. */
|
|
9663
9824
|
class PdfOutlines {
|
|
@@ -9715,18 +9876,18 @@ const _exports = Object.freeze({ PdfOutlines: PdfOutlines });
|
|
|
9715
9876
|
return _exports;
|
|
9716
9877
|
})();
|
|
9717
9878
|
|
|
9718
|
-
const
|
|
9719
|
-
const { PdfObjects, unicodeHex } =
|
|
9879
|
+
const _m60 = (() => {
|
|
9880
|
+
const { PdfObjects, unicodeHex } = _m61;
|
|
9720
9881
|
|
|
9721
|
-
const { PdfFontResources } =
|
|
9882
|
+
const { PdfFontResources } = _m63;
|
|
9722
9883
|
|
|
9723
|
-
const { PdfTableLayout } =
|
|
9884
|
+
const { PdfTableLayout } = _m70;
|
|
9724
9885
|
|
|
9725
|
-
const { PdfPages } =
|
|
9886
|
+
const { PdfPages } = _m75;
|
|
9726
9887
|
|
|
9727
|
-
const { PdfStructure } =
|
|
9888
|
+
const { PdfStructure } = _m81;
|
|
9728
9889
|
|
|
9729
|
-
const { PdfOutlines } =
|
|
9890
|
+
const { PdfOutlines } = _m83;
|
|
9730
9891
|
|
|
9731
9892
|
/** One resource/catalog owner shared by table convenience exports and composed documents. */
|
|
9732
9893
|
class PdfWriteSession {
|
|
@@ -9781,7 +9942,7 @@ const _exports = Object.freeze({ PdfWriteSession: PdfWriteSession });
|
|
|
9781
9942
|
return _exports;
|
|
9782
9943
|
})();
|
|
9783
9944
|
|
|
9784
|
-
const
|
|
9945
|
+
const _m59 = (() => {
|
|
9785
9946
|
const { BlobByteSink, withDestination } = _m3;
|
|
9786
9947
|
|
|
9787
9948
|
const { beginTask, checkAbort, consumeRows, pause, taskYieldDue } = _m4;
|
|
@@ -9792,7 +9953,7 @@ const { createRowProjector } = _m11;
|
|
|
9792
9953
|
|
|
9793
9954
|
const { settings } = _m17;
|
|
9794
9955
|
|
|
9795
|
-
const { PdfWriteSession } =
|
|
9956
|
+
const { PdfWriteSession } = _m60;
|
|
9796
9957
|
|
|
9797
9958
|
async function writePdf(rows, configuration) {
|
|
9798
9959
|
const sink = new BlobByteSink();
|
|
@@ -9849,7 +10010,7 @@ const _exports = Object.freeze({ writePdf: writePdf, writePdfTo: writePdfTo });
|
|
|
9849
10010
|
return _exports;
|
|
9850
10011
|
})();
|
|
9851
10012
|
|
|
9852
|
-
const
|
|
10013
|
+
const _m87 = (() => {
|
|
9853
10014
|
const { NotSupportedError, OfficeIMOError } = _m2;
|
|
9854
10015
|
|
|
9855
10016
|
const { checkAbort, pause, taskYieldDue, withAbort } = _m4;
|
|
@@ -10116,12 +10277,12 @@ const _exports = Object.freeze({ pngPixels: pngPixels });
|
|
|
10116
10277
|
return _exports;
|
|
10117
10278
|
})();
|
|
10118
10279
|
|
|
10119
|
-
const
|
|
10280
|
+
const _m86 = (() => {
|
|
10120
10281
|
const { NotSupportedError, OfficeIMOError } = _m2;
|
|
10121
10282
|
|
|
10122
10283
|
const { checkAbort, pause, taskYieldDue } = _m4;
|
|
10123
10284
|
|
|
10124
|
-
const { pngPixels } =
|
|
10285
|
+
const { pngPixels } = _m87;
|
|
10125
10286
|
|
|
10126
10287
|
/** Shared document image resources; source objects are captured on first consumption. */
|
|
10127
10288
|
class PdfDocumentImages {
|
|
@@ -10249,14 +10410,14 @@ const _exports = Object.freeze({ PdfDocumentImages: PdfDocumentImages });
|
|
|
10249
10410
|
return _exports;
|
|
10250
10411
|
})();
|
|
10251
10412
|
|
|
10252
|
-
const
|
|
10413
|
+
const _m88 = (() => {
|
|
10253
10414
|
const { OfficeIMOError } = _m2;
|
|
10254
10415
|
|
|
10255
10416
|
const { checkAbort, pause, taskYieldDue } = _m4;
|
|
10256
10417
|
|
|
10257
10418
|
const { color, positive } = _m17;
|
|
10258
10419
|
|
|
10259
|
-
const { pdfNumber: n } =
|
|
10420
|
+
const { pdfNumber: n } = _m61;
|
|
10260
10421
|
|
|
10261
10422
|
/** Capture and serialize one bounded display path, with no markup parser or resource loading. */
|
|
10262
10423
|
async function vectorCommands(block, settings, used) {
|
|
@@ -10335,14 +10496,14 @@ const _exports = Object.freeze({ vectorCommands: vectorCommands });
|
|
|
10335
10496
|
return _exports;
|
|
10336
10497
|
})();
|
|
10337
10498
|
|
|
10338
|
-
const
|
|
10499
|
+
const _m89 = (() => {
|
|
10339
10500
|
const { NotSupportedError, OfficeIMOError } = _m2;
|
|
10340
10501
|
|
|
10341
10502
|
const { checkAbort, pause, taskYieldDue } = _m4;
|
|
10342
10503
|
|
|
10343
10504
|
const { color, positive } = _m17;
|
|
10344
10505
|
|
|
10345
|
-
const { pdfNumber: n } =
|
|
10506
|
+
const { pdfNumber: n } = _m61;
|
|
10346
10507
|
|
|
10347
10508
|
/** Portable drawings are an exact schema: unsupported data must never be silently discarded. */
|
|
10348
10509
|
function record(value, keys, name) {
|
|
@@ -10581,20 +10742,20 @@ const _exports = Object.freeze({ checkDrawingBlock: checkDrawingBlock, prepareDr
|
|
|
10581
10742
|
return _exports;
|
|
10582
10743
|
})();
|
|
10583
10744
|
|
|
10584
|
-
const
|
|
10745
|
+
const _m90 = (() => {
|
|
10585
10746
|
const { OfficeIMOError } = _m2;
|
|
10586
10747
|
|
|
10587
|
-
const { capturePdfText, wrapPdfText } =
|
|
10748
|
+
const { capturePdfText, wrapPdfText } = _m72;
|
|
10588
10749
|
|
|
10589
10750
|
const { positive } = _m17;
|
|
10590
10751
|
|
|
10591
10752
|
const { resolveParagraphStyle } = _m19;
|
|
10592
10753
|
|
|
10593
|
-
const { captureBookmark } =
|
|
10754
|
+
const { captureBookmark } = _m79;
|
|
10594
10755
|
|
|
10595
10756
|
const { captureFields } = _m10;
|
|
10596
10757
|
|
|
10597
|
-
const { pdfBudgetText } =
|
|
10758
|
+
const { pdfBudgetText } = _m71;
|
|
10598
10759
|
|
|
10599
10760
|
/** @internal Copy public paragraph input before any cooperative layout or source enumeration. */
|
|
10600
10761
|
function captureParagraph(block, settings, fonts, budgetOnPaint = false) {
|
|
@@ -10664,10 +10825,10 @@ const _exports = Object.freeze({ captureParagraph: captureParagraph, captureCapt
|
|
|
10664
10825
|
return _exports;
|
|
10665
10826
|
})();
|
|
10666
10827
|
|
|
10667
|
-
const
|
|
10668
|
-
const { capturePdfText, wrapPdfText } =
|
|
10828
|
+
const _m91 = (() => {
|
|
10829
|
+
const { capturePdfText, wrapPdfText } = _m72;
|
|
10669
10830
|
|
|
10670
|
-
const { captureParagraph, prepareParagraph } =
|
|
10831
|
+
const { captureParagraph, prepareParagraph } = _m90;
|
|
10671
10832
|
|
|
10672
10833
|
const { resolveParagraphStyle } = _m19;
|
|
10673
10834
|
|
|
@@ -10721,7 +10882,7 @@ const _exports = Object.freeze({ captureListOptions: captureListOptions, prepare
|
|
|
10721
10882
|
return _exports;
|
|
10722
10883
|
})();
|
|
10723
10884
|
|
|
10724
|
-
const
|
|
10885
|
+
const _m93 = (() => {
|
|
10725
10886
|
const { assertGroupedReportSource } = _m8;
|
|
10726
10887
|
|
|
10727
10888
|
const { captureFields } = _m10;
|
|
@@ -10770,22 +10931,22 @@ const _exports = Object.freeze({ groupedPdfLabelFields: groupedPdfLabelFields, g
|
|
|
10770
10931
|
return _exports;
|
|
10771
10932
|
})();
|
|
10772
10933
|
|
|
10773
|
-
const
|
|
10934
|
+
const _m92 = (() => {
|
|
10774
10935
|
const { assertGroupedReportSource, groupedReportOperation } = _m8;
|
|
10775
10936
|
|
|
10776
10937
|
const { consumeRows } = _m4;
|
|
10777
10938
|
|
|
10778
10939
|
const { ExportCell } = _m5;
|
|
10779
10940
|
|
|
10780
|
-
const { captureGroupedPdfTableOptions } =
|
|
10941
|
+
const { captureGroupedPdfTableOptions } = _m93;
|
|
10781
10942
|
|
|
10782
10943
|
const { settings } = _m17;
|
|
10783
10944
|
|
|
10784
|
-
const { PdfTableLayout } =
|
|
10945
|
+
const { PdfTableLayout } = _m70;
|
|
10785
10946
|
|
|
10786
|
-
const { captureCaption, captureParagraph, prepareParagraph } =
|
|
10947
|
+
const { captureCaption, captureParagraph, prepareParagraph } = _m90;
|
|
10787
10948
|
|
|
10788
|
-
const { synchronousText } =
|
|
10949
|
+
const { synchronousText } = _m71;
|
|
10789
10950
|
|
|
10790
10951
|
/** @internal Render one analytical source in the existing document session. Retain one detail row and
|
|
10791
10952
|
* at most four closing subtotals. All captions, rows, pages, bytes and fonts use the document owners. */
|
|
@@ -11027,7 +11188,7 @@ const _exports = Object.freeze({ renderGroupedPdfTable: renderGroupedPdfTable })
|
|
|
11027
11188
|
return _exports;
|
|
11028
11189
|
})();
|
|
11029
11190
|
|
|
11030
|
-
const
|
|
11191
|
+
const _m85 = (() => {
|
|
11031
11192
|
const { BlobByteSink, withDestination } = _m3;
|
|
11032
11193
|
|
|
11033
11194
|
const { OfficeIMOError } = _m2;
|
|
@@ -11042,27 +11203,27 @@ const { captureFields } = _m10;
|
|
|
11042
11203
|
|
|
11043
11204
|
const { settings, captureWideTable } = _m17;
|
|
11044
11205
|
|
|
11045
|
-
const { pdfNumber: n } =
|
|
11206
|
+
const { pdfNumber: n } = _m61;
|
|
11046
11207
|
|
|
11047
|
-
const { PdfTableLayout } =
|
|
11208
|
+
const { PdfTableLayout } = _m70;
|
|
11048
11209
|
|
|
11049
|
-
const { PdfWriteSession } =
|
|
11210
|
+
const { PdfWriteSession } = _m60;
|
|
11050
11211
|
|
|
11051
|
-
const { PdfDocumentImages } =
|
|
11212
|
+
const { PdfDocumentImages } = _m86;
|
|
11052
11213
|
|
|
11053
|
-
const { vectorCommands } =
|
|
11214
|
+
const { vectorCommands } = _m88;
|
|
11054
11215
|
|
|
11055
|
-
const { graphicAlternative } =
|
|
11216
|
+
const { graphicAlternative } = _m81;
|
|
11056
11217
|
|
|
11057
|
-
const { checkDrawingBlock, prepareDrawing } =
|
|
11218
|
+
const { checkDrawingBlock, prepareDrawing } = _m89;
|
|
11058
11219
|
|
|
11059
|
-
const { captureParagraph, captureCaption, prepareParagraph, checkParagraphBuffer, paragraphStartHeight } =
|
|
11220
|
+
const { captureParagraph, captureCaption, prepareParagraph, checkParagraphBuffer, paragraphStartHeight } = _m90;
|
|
11060
11221
|
|
|
11061
|
-
const { captureListOptions, prepareListItem } =
|
|
11222
|
+
const { captureListOptions, prepareListItem } = _m91;
|
|
11062
11223
|
|
|
11063
|
-
const { captureSection } =
|
|
11224
|
+
const { captureSection } = _m79;
|
|
11064
11225
|
|
|
11065
|
-
const { renderGroupedPdfTable } =
|
|
11226
|
+
const { renderGroupedPdfTable } = _m92;
|
|
11066
11227
|
|
|
11067
11228
|
const tableOptionFields = ["columns", "includeHeader", "headerRows", "footer", "headerPresentation", "footerPresentation", "alternateRowColor", "columnWidths", "wideTable", "formatValue", "formatRuns"];
|
|
11068
11229
|
/** Capture typed columns for a single-use table source in a composed document. */
|
|
@@ -11320,18 +11481,18 @@ const _exports = Object.freeze({ pdfTable: pdfTable, writePdfDocument: writePdfD
|
|
|
11320
11481
|
return _exports;
|
|
11321
11482
|
})();
|
|
11322
11483
|
|
|
11323
|
-
const
|
|
11484
|
+
const _m84 = (() => {
|
|
11324
11485
|
const { assertGroupedReportSource } = _m8;
|
|
11325
11486
|
|
|
11326
11487
|
const { BlobByteSink } = _m3;
|
|
11327
11488
|
|
|
11328
|
-
const { writePdfDocumentTo } =
|
|
11489
|
+
const { writePdfDocumentTo } = _m85;
|
|
11329
11490
|
|
|
11330
11491
|
const { pdfOptionFields } = _m17;
|
|
11331
11492
|
|
|
11332
11493
|
const { captureFields } = _m10;
|
|
11333
11494
|
|
|
11334
|
-
const { pdfGroupedTable, groupedPdfLabelFields, groupedPdfTableFields } =
|
|
11495
|
+
const { pdfGroupedTable, groupedPdfLabelFields, groupedPdfTableFields } = _m93;
|
|
11335
11496
|
|
|
11336
11497
|
|
|
11337
11498
|
|
|
@@ -11365,14 +11526,14 @@ async function writeGroupedPdfTo(report, destination, configuration) {
|
|
|
11365
11526
|
delete documentOptions.footer;
|
|
11366
11527
|
return writePdfDocumentTo([pdfGroupedTable(report, tableOptions)], destination, documentOptions);
|
|
11367
11528
|
}
|
|
11368
|
-
const _exports = Object.freeze({ pdfGroupedTable:
|
|
11529
|
+
const _exports = Object.freeze({ pdfGroupedTable: _m93.pdfGroupedTable, writeGroupedPdf: writeGroupedPdf, writeGroupedPdfTo: writeGroupedPdfTo });
|
|
11369
11530
|
return _exports;
|
|
11370
11531
|
})();
|
|
11371
11532
|
|
|
11372
|
-
const
|
|
11373
|
-
const { fontProgram } =
|
|
11533
|
+
const _m94 = (() => {
|
|
11534
|
+
const { fontProgram } = _m64;
|
|
11374
11535
|
|
|
11375
|
-
const { resolveScalar, selectFont, validateFonts } =
|
|
11536
|
+
const { resolveScalar, selectFont, validateFonts } = _m68;
|
|
11376
11537
|
|
|
11377
11538
|
/**
|
|
11378
11539
|
* Check one text run against the writer's selected font and scalar-layout rules.
|
|
@@ -11408,13 +11569,107 @@ const _exports = Object.freeze({ preflightPdfText: preflightPdfText });
|
|
|
11408
11569
|
return _exports;
|
|
11409
11570
|
})();
|
|
11410
11571
|
|
|
11411
|
-
const
|
|
11572
|
+
const _m58 = (() => {
|
|
11412
11573
|
|
|
11413
|
-
const _exports = Object.freeze({ writePdf:
|
|
11574
|
+
const _exports = Object.freeze({ writePdf: _m59.writePdf, writePdfTo: _m59.writePdfTo, writeGroupedPdf: _m84.writeGroupedPdf, writeGroupedPdfTo: _m84.writeGroupedPdfTo, pdfGroupedTable: _m84.pdfGroupedTable, createGroupedReport: _m8.createGroupedReport, writePdfDocument: _m85.writePdfDocument, writePdfDocumentTo: _m85.writePdfDocumentTo, pdfTable: _m85.pdfTable, PdfFont: _m64.PdfFont, preflightPdfText: _m94.preflightPdfText, ExportCell: _m5.ExportCell, saveBlob: _m1.saveBlob });
|
|
11414
11575
|
return _exports;
|
|
11415
11576
|
})();
|
|
11416
11577
|
|
|
11417
11578
|
const _m95 = (() => {
|
|
11579
|
+
/** One policy for capture diagnostics and unsupported adapter mappings; callbacks stay synchronous. */
|
|
11580
|
+
function canopyDiagnostics(format, options) {
|
|
11581
|
+
const policy = options.unsupportedPresentation ?? (format === "csv" ? "text" : "reject"), notify = options.onDiagnostic;
|
|
11582
|
+
if (policy !== "reject" && policy !== "text")
|
|
11583
|
+
throw new TypeError("unsupportedPresentation must be reject or text.");
|
|
11584
|
+
if (notify !== undefined && typeof notify !== "function")
|
|
11585
|
+
throw new TypeError("onDiagnostic must be a synchronous function.");
|
|
11586
|
+
return diagnostic => {
|
|
11587
|
+
if (policy === "reject")
|
|
11588
|
+
throw new TypeError("Unsupported Canopy presentation: " + diagnostic.code + (diagnostic.columnId ? " (" + diagnostic.columnId + ")" : ""));
|
|
11589
|
+
const result = notify?.(Object.freeze(diagnostic));
|
|
11590
|
+
if (result && typeof result.then === "function") {
|
|
11591
|
+
void Promise.resolve(result).catch(() => { });
|
|
11592
|
+
throw new TypeError("onDiagnostic must be synchronous.");
|
|
11593
|
+
}
|
|
11594
|
+
};
|
|
11595
|
+
}
|
|
11596
|
+
const _exports = Object.freeze({ canopyDiagnostics: canopyDiagnostics });
|
|
11597
|
+
return _exports;
|
|
11598
|
+
})();
|
|
11599
|
+
|
|
11600
|
+
const _m97 = (() => {
|
|
11601
|
+
function presentation(input, axes) {
|
|
11602
|
+
const { axisKey, outlineLevel, summary, grandTotal, hidden, collapsed } = input;
|
|
11603
|
+
if (typeof axisKey !== "string" || !axes.has(axisKey) || !Number.isInteger(outlineLevel) || outlineLevel < 0 || outlineLevel > 7 ||
|
|
11604
|
+
[summary, grandTotal, hidden, collapsed].some(flag => typeof flag !== "boolean"))
|
|
11605
|
+
throw new TypeError("Invalid frozen Canopy pivot axis presentation.");
|
|
11606
|
+
return Object.freeze({ level: outlineLevel, hidden: hidden, collapsed: collapsed });
|
|
11607
|
+
}
|
|
11608
|
+
/** Qualify the explicit pivot path before flat/grouped handling; never evaluate query or aggregate data. */
|
|
11609
|
+
function canopyPivot(request) {
|
|
11610
|
+
if (request.pivot === undefined)
|
|
11611
|
+
return undefined;
|
|
11612
|
+
const pivot = request.pivot;
|
|
11613
|
+
if (!pivot || typeof pivot !== "object" || request.grouping !== undefined || !Array.isArray(request.columns) ||
|
|
11614
|
+
request.scope !== "filtered" || !Number.isSafeInteger(request.recordCount) || request.recordCount < 0 ||
|
|
11615
|
+
!pivot.definition || !Array.isArray(pivot.definition.rows) || pivot.definition.rows.length > 4 ||
|
|
11616
|
+
!Array.isArray(pivot.definition.columns) || pivot.definition.columns.length > 2 ||
|
|
11617
|
+
!Array.isArray(pivot.definition.values) || !pivot.definition.values.length || pivot.definition.values.length > 32 ||
|
|
11618
|
+
pivot.definition.values.some(value => typeof value !== "string") ||
|
|
11619
|
+
!Number.isSafeInteger(pivot.distinctColumns) || pivot.distinctColumns < 0 || typeof pivot.columnsLimited !== "boolean" ||
|
|
11620
|
+
!Array.isArray(pivot.retainedColumns) || !Array.isArray(pivot.columnGroups))
|
|
11621
|
+
throw new TypeError("Invalid explicit Canopy pivot descriptor.");
|
|
11622
|
+
const axes = (nodes) => {
|
|
11623
|
+
if (!Array.isArray(nodes) || nodes.length > 100001)
|
|
11624
|
+
throw new TypeError("Pivot axes require bounded accepted identities.");
|
|
11625
|
+
const keys = new Set();
|
|
11626
|
+
for (const node of nodes) {
|
|
11627
|
+
if (!node || typeof node.key !== "string" || !node.key || keys.has(node.key) || !Array.isArray(node.path) || typeof node.other !== "boolean")
|
|
11628
|
+
throw new TypeError("Invalid or duplicate Canopy pivot axis identity.");
|
|
11629
|
+
keys.add(node.key);
|
|
11630
|
+
}
|
|
11631
|
+
for (const node of nodes)
|
|
11632
|
+
if (node.parent !== undefined && !keys.has(node.parent))
|
|
11633
|
+
throw new TypeError("Unknown Canopy pivot parent identity.");
|
|
11634
|
+
return keys;
|
|
11635
|
+
};
|
|
11636
|
+
const rowKeys = axes(pivot.rowAxis), columnKeys = axes(pivot.columnAxis);
|
|
11637
|
+
const columns = request.columns.map((column, index) => {
|
|
11638
|
+
if (index === 0 && column.axisKey === undefined && column.kind === "text")
|
|
11639
|
+
return Object.freeze({ ...column });
|
|
11640
|
+
const outline = presentation(column, columnKeys);
|
|
11641
|
+
return Object.freeze({ ...column, outlineLevel: outline.level, hidden: outline.hidden, collapsed: outline.collapsed });
|
|
11642
|
+
});
|
|
11643
|
+
// Ranges are descriptor metadata, not another body. Validate them against the same ordered columns.
|
|
11644
|
+
if (pivot.columnGroups.length > columns.length)
|
|
11645
|
+
throw new RangeError("Pivot column group count exceeds projected columns.");
|
|
11646
|
+
for (const group of pivot.columnGroups) {
|
|
11647
|
+
if (!group || !columnKeys.has(group.key) || !Number.isSafeInteger(group.firstColumn) || group.firstColumn < 0 ||
|
|
11648
|
+
!Number.isSafeInteger(group.columnCount) || group.columnCount < 1 || group.firstColumn + group.columnCount > columns.length ||
|
|
11649
|
+
!Number.isInteger(group.depth) || group.depth < 1 || group.depth > 7 ||
|
|
11650
|
+
typeof group.hidden !== "boolean" || typeof group.collapsed !== "boolean")
|
|
11651
|
+
throw new TypeError("Invalid Canopy pivot column range.");
|
|
11652
|
+
}
|
|
11653
|
+
let current;
|
|
11654
|
+
const sheet = Object.freeze({ outlineSummaryBelow: false, outlineSummaryRight: false,
|
|
11655
|
+
maxOutlineLevel: 7, rowOutline: () => current,
|
|
11656
|
+
columnOutlines: Object.freeze(columns.flatMap((column, firstColumn) => column.axisKey === undefined ? [] :
|
|
11657
|
+
[Object.freeze({ firstColumn, columnCount: 1, level: column.outlineLevel, hidden: column.hidden, collapsed: column.collapsed })])) });
|
|
11658
|
+
return Object.freeze({ columns: Object.freeze(columns), sheet,
|
|
11659
|
+
observe(row) { current = presentation(row, rowKeys); } });
|
|
11660
|
+
}
|
|
11661
|
+
/** Per-cell formats preserve already-computed fractional percentages, ranks and differences. */
|
|
11662
|
+
function pivotNumberFormat(cell) {
|
|
11663
|
+
if (!["value", "percentGrandTotal", "percentParent", "percentColumn", "percentRow", "runningTotal", "rank", "difference", "percentChange"].includes(cell.mode ?? "") ||
|
|
11664
|
+
typeof cell.numberFormat !== "string" || !cell.numberFormat.length)
|
|
11665
|
+
throw new TypeError("Numeric pivot cells require a frozen mode and native numberFormat.");
|
|
11666
|
+
return cell.numberFormat;
|
|
11667
|
+
}
|
|
11668
|
+
const _exports = Object.freeze({ canopyPivot: canopyPivot, pivotNumberFormat: pivotNumberFormat });
|
|
11669
|
+
return _exports;
|
|
11670
|
+
})();
|
|
11671
|
+
|
|
11672
|
+
const _m98 = (() => {
|
|
11418
11673
|
/** @internal Typed conversion follows declared datetime intent, never localized display text. */
|
|
11419
11674
|
function datetime(value, mode, clock) {
|
|
11420
11675
|
if (mode === "text")
|
|
@@ -11453,10 +11708,57 @@ const _exports = Object.freeze({ datetime: datetime });
|
|
|
11453
11708
|
return _exports;
|
|
11454
11709
|
})();
|
|
11455
11710
|
|
|
11456
|
-
const
|
|
11711
|
+
const _m99 = (() => {
|
|
11712
|
+
/** Calibri 11, 96-DPI CSS pixels, seven-pixel maximum digit and five-pixel cell padding.
|
|
11713
|
+
* Quantize to native 1/256-character units; this is a reproducible profile, not pixel-identical rendering. */
|
|
11714
|
+
function canopyXlsxWidth(pixels) {
|
|
11715
|
+
const width = Math.floor((pixels < 12 ? pixels / 12 : (pixels - 5) / 7) * 256) / 256;
|
|
11716
|
+
if (!Number.isFinite(width) || width <= 0 || width > 255)
|
|
11717
|
+
throw new RangeError("Captured width exceeds the Calibri-11 XLSX width profile.");
|
|
11718
|
+
return width;
|
|
11719
|
+
}
|
|
11720
|
+
/** Escape literal prefixes/suffixes; no browser formatter or CSS becomes workbook code. */
|
|
11721
|
+
function canopyNumberFormat(input, report, id) {
|
|
11722
|
+
if (!input || typeof input !== "object" || Array.isArray(input))
|
|
11723
|
+
throw new TypeError("Canopy numeric format must be an object.");
|
|
11724
|
+
if (Object.keys(input).some(key => !["minimumFractionDigits", "maximumFractionDigits", "prefix", "suffix"].includes(key))) {
|
|
11725
|
+
report({ code: "UNSUPPORTED_NUMBER_FORMAT", columnId: id });
|
|
11726
|
+
return undefined;
|
|
11727
|
+
}
|
|
11728
|
+
const { minimumFractionDigits: minimum = 0, maximumFractionDigits: maximum = 3, prefix = "", suffix = "" } = input;
|
|
11729
|
+
if (!Number.isInteger(minimum) || !Number.isInteger(maximum) || minimum < 0 || maximum < minimum || maximum > 10 ||
|
|
11730
|
+
typeof prefix !== "string" || typeof suffix !== "string" || prefix.length > 16 || suffix.length > 16)
|
|
11731
|
+
throw new TypeError("Canopy numeric fraction bounds must be ordered integers from zero through ten, with literal affixes of at most sixteen characters.");
|
|
11732
|
+
const literal = (value) => value ? '"' + value.replace(/"/g, '"\\""') + '"' : "";
|
|
11733
|
+
return literal(prefix) + "0" + (maximum ? "." + "0".repeat(minimum) + "#".repeat(maximum - minimum) : "") + literal(suffix);
|
|
11734
|
+
}
|
|
11735
|
+
/** Only a contiguous leading left pin can be represented by an Excel freeze pane. */
|
|
11736
|
+
function canopyPins(columns, report) {
|
|
11737
|
+
let leading = 0, ended = false;
|
|
11738
|
+
for (const column of columns) {
|
|
11739
|
+
const pin = column.pinned;
|
|
11740
|
+
if (pin !== undefined && pin !== null && pin !== "left" && pin !== "right")
|
|
11741
|
+
throw new TypeError("Invalid Canopy pin.");
|
|
11742
|
+
if (!ended && pin === "left")
|
|
11743
|
+
leading++;
|
|
11744
|
+
else {
|
|
11745
|
+
ended = true;
|
|
11746
|
+
if (pin === "left" || pin === "right")
|
|
11747
|
+
report({ code: "UNREPRESENTABLE_PIN:" + pin, columnId: column.id });
|
|
11748
|
+
}
|
|
11749
|
+
}
|
|
11750
|
+
return leading;
|
|
11751
|
+
}
|
|
11752
|
+
const _exports = Object.freeze({ canopyXlsxWidth: canopyXlsxWidth, canopyNumberFormat: canopyNumberFormat, canopyPins: canopyPins });
|
|
11753
|
+
return _exports;
|
|
11754
|
+
})();
|
|
11755
|
+
|
|
11756
|
+
const _m96 = (() => {
|
|
11457
11757
|
const { ExportCell, checkAbort, inputRows } = _m1;
|
|
11458
11758
|
|
|
11459
|
-
const {
|
|
11759
|
+
const { canopyPivot, pivotNumberFormat } = _m97;
|
|
11760
|
+
|
|
11761
|
+
const { datetime } = _m98;
|
|
11460
11762
|
|
|
11461
11763
|
const { captureFields } = _m10;
|
|
11462
11764
|
|
|
@@ -11464,48 +11766,56 @@ const { copyColumns } = _m11;
|
|
|
11464
11766
|
|
|
11465
11767
|
const { copyCellPresentation } = _m5;
|
|
11466
11768
|
|
|
11769
|
+
const { canopyDiagnostics } = _m95;
|
|
11770
|
+
|
|
11771
|
+
const { canopyNumberFormat, canopyXlsxWidth } = _m99;
|
|
11772
|
+
|
|
11467
11773
|
const columnFields = ["width", "format", "wrapText", "alignment", "rowHeader", "groups"];
|
|
11774
|
+
const rawIdentities = new WeakMap();
|
|
11775
|
+
/** @internal Grouping uses captured identity even when a detail cell displays a relative-link label. */
|
|
11776
|
+
function canopyIdentityValue(value) {
|
|
11777
|
+
if (!(value instanceof ExportCell))
|
|
11778
|
+
return value;
|
|
11779
|
+
const original = rawIdentities.get(value);
|
|
11780
|
+
return original === undefined ? value.value : original;
|
|
11781
|
+
}
|
|
11468
11782
|
/** Map an immutable CanopyX record capture to a writer without querying the grid or retaining its body. */
|
|
11469
11783
|
function createCanopyExport(capture, format, options = {}) {
|
|
11784
|
+
return prepareCanopyExport(capture, format, options).source;
|
|
11785
|
+
}
|
|
11786
|
+
/** @internal Capture the input once before full-writer metadata mapping and asynchronous enumeration. */
|
|
11787
|
+
function prepareCanopyExport(capture, format, options = {}) {
|
|
11470
11788
|
options = captureFields(options, ["tones", "columnOptions", "unsupportedPresentation", "datetime", "xlsx", "signal", "onDiagnostic"]);
|
|
11471
11789
|
if (format !== "xlsx" && format !== "csv" && format !== "pdf")
|
|
11472
11790
|
throw new TypeError("Canopy export format must be xlsx, csv or pdf.");
|
|
11473
11791
|
if (!capture || typeof capture.rows !== "function" || !capture.request)
|
|
11474
11792
|
throw new TypeError("A portable CanopyX capture with request and rows() is required.");
|
|
11475
|
-
const
|
|
11793
|
+
const request = captureFields(capture.request, ["columns", "recordCount", "values", "presentation", "timeZone", "revision", "scope", "total", "matched", "selection", "query", "generatedAt", "grouping", "pivot", "formatRules"]);
|
|
11794
|
+
const pivot = canopyPivot(request);
|
|
11795
|
+
const signal = options.signal, values = request.values;
|
|
11476
11796
|
if (!Array.isArray(request.columns) || !request.columns.length || (request.recordCount !== null && (!Number.isSafeInteger(request.recordCount) || request.recordCount < 0)) ||
|
|
11477
11797
|
(values !== "raw" && values !== "display") || (request.timeZone !== "utc" && request.timeZone !== "local") || typeof request.revision !== "string")
|
|
11478
11798
|
throw new TypeError("Invalid portable CanopyX capture metadata.");
|
|
11479
|
-
const
|
|
11799
|
+
const dateMode = options.datetime ?? "preserve", report = canopyDiagnostics(format, options);
|
|
11800
|
+
// These captured presentations have a complete scalar/text projection. Report
|
|
11801
|
+
// their visual loss without treating an ordinary report export as unsupported.
|
|
11802
|
+
const fallback = canopyDiagnostics(format, { ...options, unsupportedPresentation: "text" });
|
|
11480
11803
|
const clock = options.xlsx?.dateMode ?? request.timeZone;
|
|
11481
11804
|
if (clock !== "utc" && clock !== "local")
|
|
11482
11805
|
throw new TypeError("XLSX dateMode must be utc or local.");
|
|
11483
|
-
if (policy !== "reject" && policy !== "text")
|
|
11484
|
-
throw new TypeError("unsupportedPresentation must be reject or text.");
|
|
11485
11806
|
if (dateMode !== "preserve" && dateMode !== "typed" && dateMode !== "text")
|
|
11486
11807
|
throw new TypeError("datetime must be preserve, typed or text.");
|
|
11487
|
-
if (notify !== undefined && typeof notify !== "function")
|
|
11488
|
-
throw new TypeError("onDiagnostic must be a synchronous function.");
|
|
11489
|
-
const report = (diagnostic) => {
|
|
11490
|
-
if (policy === "reject")
|
|
11491
|
-
throw new TypeError("Unsupported Canopy presentation: " + diagnostic.code + (diagnostic.columnId ? " (" + diagnostic.columnId + ")" : ""));
|
|
11492
|
-
const result = notify?.(Object.freeze(diagnostic));
|
|
11493
|
-
if (result && typeof result.then === "function") {
|
|
11494
|
-
void Promise.resolve(result).catch(() => { });
|
|
11495
|
-
throw new TypeError("onDiagnostic must be synchronous.");
|
|
11496
|
-
}
|
|
11497
|
-
};
|
|
11498
11808
|
const diagnostics = (items, rowId, columnId) => {
|
|
11499
11809
|
if (items === undefined)
|
|
11500
11810
|
return;
|
|
11501
11811
|
if (!Array.isArray(items) || items.some(item => typeof item !== "string"))
|
|
11502
11812
|
throw new TypeError("Canopy presentation diagnostics must be strings.");
|
|
11503
|
-
for (const code of items)
|
|
11504
|
-
|
|
11813
|
+
for (const code of items) {
|
|
11814
|
+
const diagnostic = { code, ...(rowId === undefined ? {} : { rowId }), ...(columnId === undefined ? {} : { columnId }) };
|
|
11815
|
+
(code === "relative-link" || code === "history-series" ? fallback : report)(diagnostic);
|
|
11816
|
+
}
|
|
11505
11817
|
};
|
|
11506
|
-
if (request.presentation
|
|
11507
|
-
report({ code: "TEXT_ONLY_CAPTURE" });
|
|
11508
|
-
else if (request.presentation !== "semantic")
|
|
11818
|
+
if (request.presentation !== "text" && request.presentation !== "semantic")
|
|
11509
11819
|
throw new TypeError("Canopy captures must declare text or semantic presentation.");
|
|
11510
11820
|
const tones = new Map(Object.entries(options.tones ?? {}).map(([name, style]) => {
|
|
11511
11821
|
if (!style || typeof style !== "object" || Array.isArray(style))
|
|
@@ -11518,19 +11828,23 @@ function createCanopyExport(capture, format, options = {}) {
|
|
|
11518
11828
|
if (typeof name !== "string")
|
|
11519
11829
|
throw new TypeError("Canopy tones must be strings.");
|
|
11520
11830
|
const style = tones.get(name);
|
|
11521
|
-
if (!style)
|
|
11522
|
-
|
|
11831
|
+
if (!style && name !== "neutral")
|
|
11832
|
+
fallback({ code: "UNMAPPED_TONE:" + name, rowId, ...(columnId === undefined ? {} : { columnId }) });
|
|
11523
11833
|
return style;
|
|
11524
11834
|
};
|
|
11525
11835
|
const ids = new Set();
|
|
11526
|
-
const specs = request.columns.map(
|
|
11836
|
+
const specs = (pivot?.columns ?? request.columns).map(input => {
|
|
11837
|
+
const fields = captureFields(input, ["id", "title", "kind", "width", "pinned", "format", "wrap", "alignment", "diagnostics"]);
|
|
11838
|
+
const column = Object.freeze({ ...fields,
|
|
11839
|
+
...(fields.width === undefined ? {} : { width: Object.freeze(captureFields(fields.width, ["unit", "preferred", "minimum", "maximum"])) }),
|
|
11840
|
+
...(fields.format === undefined ? {} : { format: Object.freeze(captureFields(fields.format, ["minimumFractionDigits", "maximumFractionDigits", "prefix", "suffix"])) }) });
|
|
11527
11841
|
if (!column || typeof column.id !== "string" || !column.id || ids.has(column.id) || typeof column.title !== "string" ||
|
|
11528
11842
|
!["text", "number", "datetime"].includes(column.kind) ||
|
|
11529
11843
|
(column.wrap !== undefined && typeof column.wrap !== "boolean") || (column.alignment !== undefined && !["left", "right"].includes(column.alignment)) ||
|
|
11530
11844
|
(column.width !== undefined && (column.width.unit !== "css-px" || !Number.isFinite(column.width.preferred) ||
|
|
11531
11845
|
!Number.isFinite(column.width.minimum) || column.width.minimum <= 0 || column.width.preferred < column.width.minimum ||
|
|
11532
11846
|
column.width.maximum !== undefined && (!Number.isFinite(column.width.maximum) || column.width.maximum < column.width.preferred))) ||
|
|
11533
|
-
(request.presentation === "semantic" && (column.wrap === undefined || column.alignment === undefined || column.width === undefined)))
|
|
11847
|
+
(!pivot && request.presentation === "semantic" && (column.wrap === undefined || column.alignment === undefined || column.width === undefined)))
|
|
11534
11848
|
throw new TypeError("Invalid or duplicate Canopy export column.");
|
|
11535
11849
|
ids.add(column.id);
|
|
11536
11850
|
diagnostics(column.diagnostics, undefined, column.id);
|
|
@@ -11539,20 +11853,30 @@ function createCanopyExport(capture, format, options = {}) {
|
|
|
11539
11853
|
if (!columnFields.includes(key))
|
|
11540
11854
|
throw new TypeError("Unsupported Canopy column option: " + key);
|
|
11541
11855
|
const override = captureFields(selected, columnFields);
|
|
11856
|
+
const numericFormat = (format === "xlsx" || format === "pdf") && values === "raw" && column.kind === "number" && column.format !== undefined && override.format === undefined
|
|
11857
|
+
? canopyNumberFormat(column.format, report, column.id) : undefined;
|
|
11542
11858
|
const [captured] = copyColumns([{ ...override, key: column.id, header: column.title,
|
|
11859
|
+
...(format === "xlsx" && override.width === undefined && column.width !== undefined ? { width: canopyXlsxWidth(column.width.preferred) } : {}),
|
|
11860
|
+
...(override.format === undefined && numericFormat !== undefined ? { format: numericFormat } : {}),
|
|
11861
|
+
...(format === "xlsx" && values === "raw" && column.kind === "datetime" && override.format === undefined ? { format: "yyyy-mm-dd hh:mm:ss.000" } : {}),
|
|
11543
11862
|
...(values === "raw" && column.kind === "number" ? { type: "number" } : {}),
|
|
11544
|
-
|
|
11545
|
-
|
|
11546
|
-
|
|
11863
|
+
// Screen nowrap is not a promise that its CSS width will survive PDF fitting.
|
|
11864
|
+
// PDF defaults to lossless wrapping; an explicit writer override stays strict.
|
|
11865
|
+
...(format === "pdf" ? { wrapText: override.wrapText ?? true } :
|
|
11866
|
+
override.wrapText === undefined && column.wrap === undefined ? {} : { wrapText: override.wrapText ?? column.wrap }),
|
|
11867
|
+
...(override.alignment === undefined && column.alignment === undefined ?
|
|
11868
|
+
format === "pdf" && column.kind === "number" ? { alignment: "right" } : {} : { alignment: override.alignment ?? column.alignment }) }]);
|
|
11869
|
+
return Object.freeze({ id: column.id, kind: column.kind, input: column, nativeFormatOverride: override.format, column: Object.freeze(captured) });
|
|
11547
11870
|
});
|
|
11548
11871
|
const rowCount = request.recordCount;
|
|
11549
|
-
|
|
11872
|
+
const source = Object.freeze({ columns: Object.freeze(specs.map(spec => spec.column)), rowCount, async *rows() {
|
|
11550
11873
|
checkAbort(signal);
|
|
11551
11874
|
let count = 0;
|
|
11552
11875
|
for await (const row of inputRows(capture.rows(signal ? { signal } : {}), signal)) {
|
|
11553
11876
|
checkAbort(signal);
|
|
11554
11877
|
if (!row || typeof row.id !== "string" || !row.cells || typeof row.cells !== "object")
|
|
11555
11878
|
throw new TypeError("Invalid Canopy export record.");
|
|
11879
|
+
pivot?.observe(row);
|
|
11556
11880
|
diagnostics(row.diagnostics, row.id);
|
|
11557
11881
|
const rowStyle = tone(row.tone, row.id), result = [];
|
|
11558
11882
|
for (const spec of specs) {
|
|
@@ -11564,13 +11888,29 @@ function createCanopyExport(capture, format, options = {}) {
|
|
|
11564
11888
|
(typeof cell.value === "number" && (!Number.isFinite(cell.value) || Math.abs(cell.value) > Number.MAX_SAFE_INTEGER)))
|
|
11565
11889
|
throw new TypeError("A portable Canopy GridExportCell with scalar value and resolved text is required.");
|
|
11566
11890
|
diagnostics(cell.diagnostics, row.id, spec.id);
|
|
11567
|
-
|
|
11891
|
+
// A relative destination is navigation metadata, not the visible label.
|
|
11892
|
+
// History captures already carry their frozen latest scalar (or null).
|
|
11893
|
+
const relativeLabel = spec.kind === "text" && cell.diagnostics?.includes("relative-link");
|
|
11894
|
+
let value = values === "display" || relativeLabel ? cell.text : cell.value;
|
|
11568
11895
|
if (format === "xlsx" && values === "raw" && spec.kind === "datetime" && typeof value === "string")
|
|
11569
11896
|
value = datetime(value, dateMode, clock);
|
|
11570
|
-
const
|
|
11897
|
+
const capturedFormat = pivot && spec.kind === "number" && cell.value !== null ? pivotNumberFormat(cell) : undefined;
|
|
11898
|
+
const nativeFormat = capturedFormat === undefined ? undefined : spec.nativeFormatOverride === "" ? "General" : spec.nativeFormatOverride ?? capturedFormat;
|
|
11899
|
+
const summary = format === "pdf" && pivot && (row.summary || row.grandTotal);
|
|
11900
|
+
const cellStyle = tone(cell.tone, row.id, spec.id), presentation = rowStyle || cellStyle || nativeFormat || summary ? {
|
|
11901
|
+
...rowStyle, ...(summary ? { bold: true } : {}), ...cellStyle,
|
|
11902
|
+
...((format === "xlsx" || format === "pdf") && values === "raw" && nativeFormat !== undefined ? { numberFormat: nativeFormat } : {})
|
|
11903
|
+
} : undefined;
|
|
11571
11904
|
// CSV has no presentation or link metadata: emit its selected scalar directly.
|
|
11572
11905
|
// This also avoids a frozen wrapper for every cell in large CSV captures.
|
|
11573
|
-
|
|
11906
|
+
if (format === "csv")
|
|
11907
|
+
result.push(value);
|
|
11908
|
+
else {
|
|
11909
|
+
const exported = new ExportCell(value, { text: cell.text, ...(presentation ? { presentation } : {}), ...(cell.link === undefined ? {} : { link: cell.link }) });
|
|
11910
|
+
if (relativeLabel)
|
|
11911
|
+
rawIdentities.set(exported, cell.value);
|
|
11912
|
+
result.push(exported);
|
|
11913
|
+
}
|
|
11574
11914
|
}
|
|
11575
11915
|
if (rowCount !== null && count >= rowCount)
|
|
11576
11916
|
throw new TypeError("Canopy capture exceeded its declared recordCount.");
|
|
@@ -11580,13 +11920,820 @@ function createCanopyExport(capture, format, options = {}) {
|
|
|
11580
11920
|
if (rowCount !== null && count !== rowCount)
|
|
11581
11921
|
throw new TypeError("Canopy capture did not produce its declared recordCount.");
|
|
11582
11922
|
} });
|
|
11923
|
+
return Object.freeze({ source, request: Object.freeze({ ...request, columns: Object.freeze(specs.map(spec => spec.input)) }), report, tones, pivot });
|
|
11924
|
+
}
|
|
11925
|
+
const _exports = Object.freeze({ canopyIdentityValue: canopyIdentityValue, createCanopyExport: createCanopyExport, prepareCanopyExport: prepareCanopyExport });
|
|
11926
|
+
return _exports;
|
|
11927
|
+
})();
|
|
11928
|
+
|
|
11929
|
+
const _m101 = (() => {
|
|
11930
|
+
const { columnName, excelDate } = _m35;
|
|
11931
|
+
|
|
11932
|
+
const { captureFields } = _m10;
|
|
11933
|
+
|
|
11934
|
+
const { datetime } = _m98;
|
|
11935
|
+
|
|
11936
|
+
/** Compile only comparisons whose raw types and native encodings have a faithful bounded mapping. */
|
|
11937
|
+
function canopyPredicate(request, grouped, options, root, unsupported, cellTypes) {
|
|
11938
|
+
let nodes = 0;
|
|
11939
|
+
const operations = { eq: "=", ne: "<>", gt: ">", ge: ">=", lt: "<", le: "<=" };
|
|
11940
|
+
const numeric = (value) => {
|
|
11941
|
+
const number = typeof value === "boolean" ? Number(value) : typeof value === "string" ? Number(value) : value;
|
|
11942
|
+
// Use platform decimal conversion; separator/culture profiles need a diagnostic, not a second parser.
|
|
11943
|
+
if (typeof value === "string") {
|
|
11944
|
+
const text = value.trim().toLowerCase();
|
|
11945
|
+
if (Number.parseFloat(value) !== number || ["0x", "0b", "0o"].some(prefix => text.startsWith(prefix)))
|
|
11946
|
+
return unsupported("UNSUPPORTED_NUMERIC_RULE_LITERAL");
|
|
11947
|
+
}
|
|
11948
|
+
if (!Number.isFinite(number) || Math.abs(number) > Number.MAX_SAFE_INTEGER)
|
|
11949
|
+
throw new TypeError("Canopy rule comparison values must be finite safe-range numbers.");
|
|
11950
|
+
return number;
|
|
11951
|
+
};
|
|
11952
|
+
const date = (value) => {
|
|
11953
|
+
if (options.datetime !== "typed" || (options.xlsx?.dateMode ?? request.timeZone) !== "utc")
|
|
11954
|
+
return unsupported("DATETIME_RULE_REQUIRES_TYPED_UTC");
|
|
11955
|
+
if (typeof value === "boolean")
|
|
11956
|
+
return unsupported("UNSUPPORTED_DATETIME_RULE_LITERAL");
|
|
11957
|
+
if (typeof value === "number" && !Number.isSafeInteger(value))
|
|
11958
|
+
return unsupported("UNSUPPORTED_DATETIME_RULE_LITERAL");
|
|
11959
|
+
try {
|
|
11960
|
+
const literal = typeof value === "number" ? new Date(value).toISOString() : value;
|
|
11961
|
+
const captured = datetime(literal, "typed", "utc");
|
|
11962
|
+
if (!(captured instanceof Date))
|
|
11963
|
+
return unsupported("UNSUPPORTED_DATETIME_RULE_LITERAL");
|
|
11964
|
+
const serial = excelDate(captured, "utc");
|
|
11965
|
+
if (serial === null)
|
|
11966
|
+
return unsupported("UNSUPPORTED_DATETIME_RULE_LITERAL");
|
|
11967
|
+
return serial;
|
|
11968
|
+
}
|
|
11969
|
+
catch (error) {
|
|
11970
|
+
if (!(error instanceof TypeError) && !(error instanceof RangeError))
|
|
11971
|
+
throw error;
|
|
11972
|
+
return unsupported("UNSUPPORTED_DATETIME_RULE_LITERAL");
|
|
11973
|
+
}
|
|
11974
|
+
};
|
|
11975
|
+
const leaf = (input) => {
|
|
11976
|
+
if (++nodes > 64)
|
|
11977
|
+
return unsupported("RULE_PREDICATE_LIMIT");
|
|
11978
|
+
const filter = captureFields(input, ["column", "operator", "values"]), operation = operations[filter.operator];
|
|
11979
|
+
if (Object.keys(filter).some(key => !["column", "operator", "values"].includes(key)))
|
|
11980
|
+
return unsupported("UNSUPPORTED_RULE_FILTER_OPTIONS");
|
|
11981
|
+
const index = request.columns.findIndex(column => column.id === filter.column);
|
|
11982
|
+
if (index < 0)
|
|
11983
|
+
return unsupported("RULE_COLUMN_NOT_EXPORTED:" + filter.column);
|
|
11984
|
+
const column = request.columns[index], letter = columnName(index + 1 + (grouped ? 1 : 0));
|
|
11985
|
+
const reference = "INDEX($" + letter + ":$" + letter + ",ROW())", present = "NOT(ISBLANK(" + reference + "))";
|
|
11986
|
+
if (column.kind === "number")
|
|
11987
|
+
cellTypes.set(index, "number");
|
|
11988
|
+
if (column.kind === "datetime") {
|
|
11989
|
+
if (options.datetime !== "typed" || (options.xlsx?.dateMode ?? request.timeZone) !== "utc")
|
|
11990
|
+
return unsupported("DATETIME_RULE_REQUIRES_TYPED_UTC");
|
|
11991
|
+
cellTypes.set(index, "date");
|
|
11992
|
+
}
|
|
11993
|
+
if (filter.operator === "isNull" || filter.operator === "isNotNull") {
|
|
11994
|
+
if (filter.values !== undefined && filter.values.length)
|
|
11995
|
+
return unsupported("UNSUPPORTED_NULL_RULE_OPERANDS");
|
|
11996
|
+
return filter.operator === "isNull" ? "ISBLANK(" + reference + ")" : present;
|
|
11997
|
+
}
|
|
11998
|
+
if (!operation || !Array.isArray(filter.values) || filter.values.length !== 1)
|
|
11999
|
+
return unsupported("UNSUPPORTED_RULE_FILTER:" + filter.operator);
|
|
12000
|
+
const value = filter.values[0];
|
|
12001
|
+
if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean")
|
|
12002
|
+
throw new TypeError("Canopy rule values must be portable scalars.");
|
|
12003
|
+
if (column.kind === "number" || column.kind === "datetime") {
|
|
12004
|
+
const operand = column.kind === "number" ? numeric(value) : date(value);
|
|
12005
|
+
return "AND(" + present + ",ISNUMBER(" + reference + ")," + reference + operation + String(operand) + ")";
|
|
12006
|
+
}
|
|
12007
|
+
if (filter.operator !== "eq" && filter.operator !== "ne")
|
|
12008
|
+
return unsupported("UNSUPPORTED_TEXT_RULE_COMPARISON");
|
|
12009
|
+
// Canopy's Unicode text folding is not the native workbook's comparison contract.
|
|
12010
|
+
if (typeof value === "string")
|
|
12011
|
+
return unsupported("UNQUALIFIED_NATIVE_TEXT_COMPARISON");
|
|
12012
|
+
const kind = typeof value === "boolean" ? "ISLOGICAL" : "ISNUMBER";
|
|
12013
|
+
const literal = typeof value === "boolean" ? value ? "TRUE" : "FALSE" : String(numeric(value));
|
|
12014
|
+
const sameType = kind + "(" + reference + ")", comparison = reference + operation + literal;
|
|
12015
|
+
return filter.operator === "eq" ? "AND(" + present + "," + sameType + "," + comparison + ")"
|
|
12016
|
+
: "AND(" + present + ",OR(NOT(" + sameType + ")," + comparison + "))";
|
|
12017
|
+
};
|
|
12018
|
+
const visit = (input, depth) => {
|
|
12019
|
+
if (depth > 4 || ++nodes > 64)
|
|
12020
|
+
return unsupported("RULE_PREDICATE_LIMIT");
|
|
12021
|
+
if (!input || typeof input !== "object")
|
|
12022
|
+
throw new TypeError("Canopy rule predicate must be an object.");
|
|
12023
|
+
const captured = captureFields(input, ["operator", "filters", "groups"]);
|
|
12024
|
+
if (captured.operator !== "and" && captured.operator !== "or")
|
|
12025
|
+
return unsupported("UNSUPPORTED_RULE_BOOLEAN:" + captured.operator);
|
|
12026
|
+
const filters = captured.filters ?? [], groups = captured.groups ?? [];
|
|
12027
|
+
if (!Array.isArray(filters) || !Array.isArray(groups))
|
|
12028
|
+
throw new TypeError("Canopy predicate filters and groups must be arrays.");
|
|
12029
|
+
const terms = [];
|
|
12030
|
+
for (const filter of filters)
|
|
12031
|
+
terms.push(leaf(filter));
|
|
12032
|
+
for (const group of groups)
|
|
12033
|
+
terms.push(visit(group, depth + 1));
|
|
12034
|
+
if (!terms.length)
|
|
12035
|
+
return unsupported("EMPTY_RULE_PREDICATE");
|
|
12036
|
+
return captured.operator.toUpperCase() + "(" + terms.join(",") + ")";
|
|
12037
|
+
};
|
|
12038
|
+
const formula = visit(root, 1);
|
|
12039
|
+
if (formula.length > 8192)
|
|
12040
|
+
return unsupported("RULE_FORMULA_LIMIT");
|
|
12041
|
+
return formula;
|
|
12042
|
+
}
|
|
12043
|
+
const _exports = Object.freeze({ canopyPredicate: canopyPredicate });
|
|
12044
|
+
return _exports;
|
|
12045
|
+
})();
|
|
12046
|
+
|
|
12047
|
+
const _m100 = (() => {
|
|
12048
|
+
const { captureFields } = _m10;
|
|
12049
|
+
|
|
12050
|
+
const { canopyPredicate } = _m101;
|
|
12051
|
+
|
|
12052
|
+
// Stable document palette. Browser CSS variables and resolved cell.format are never interpreted.
|
|
12053
|
+
const palette = {
|
|
12054
|
+
info: { color: "4472C4", background: "DDEBF7", foreground: "1F4E78" },
|
|
12055
|
+
success: { color: "70AD47", background: "E2F0D9", foreground: "375623" },
|
|
12056
|
+
warning: { color: "FFC000", background: "FFF2CC", foreground: "9C6500" },
|
|
12057
|
+
danger: { color: "C00000", background: "FFC7CE", foreground: "9C0006" }
|
|
12058
|
+
};
|
|
12059
|
+
class UnsupportedRule extends Error {
|
|
12060
|
+
}
|
|
12061
|
+
const unsupported = (message) => { throw new UnsupportedRule(message); };
|
|
12062
|
+
/** Compile declarations in source order, then emit native target/aspect priorities.
|
|
12063
|
+
* Data-column selectors let grouped writers exclude generated headings, subtotals and grand totals. */
|
|
12064
|
+
function canopyRules(request, format, grouped, tones, report, options = {}, cellTypes) {
|
|
12065
|
+
if (request.formatRules === undefined || format === "csv")
|
|
12066
|
+
return [];
|
|
12067
|
+
if (!Array.isArray(request.formatRules) || request.formatRules.length > 1000)
|
|
12068
|
+
throw new TypeError("Canopy formatRules must be a bounded array of at most 1,000 declarations.");
|
|
12069
|
+
const visuals = [], cells = [], rows = [], ids = new Set(), columns = request.columns;
|
|
12070
|
+
const inputs = request.formatRules;
|
|
12071
|
+
const declarations = inputs.map(input => {
|
|
12072
|
+
if (!input || typeof input !== "object")
|
|
12073
|
+
throw new TypeError("Canopy rule declarations must be objects.");
|
|
12074
|
+
const rule = captureFields(input, ["id", "enabled", "stopIfTrue", "column", "when", "target", "style"]);
|
|
12075
|
+
if (typeof rule.id !== "string" || !rule.id || ids.has(rule.id))
|
|
12076
|
+
throw new TypeError("Canopy rule IDs must be unique nonempty strings.");
|
|
12077
|
+
ids.add(rule.id);
|
|
12078
|
+
if (rule.enabled !== undefined && typeof rule.enabled !== "boolean" || rule.stopIfTrue !== undefined && typeof rule.stopIfTrue !== "boolean")
|
|
12079
|
+
throw new TypeError("Canopy rule flags must be boolean.");
|
|
12080
|
+
const style = rule.style && typeof rule.style === "object" ? captureFields(rule.style, ["tone", "bar", "scale"]) : rule.style;
|
|
12081
|
+
return { ...rule, style };
|
|
12082
|
+
});
|
|
12083
|
+
if (format === "pdf") {
|
|
12084
|
+
for (const rule of declarations)
|
|
12085
|
+
if (rule.enabled !== false)
|
|
12086
|
+
report({ code: "PDF_NATIVE_RULE_NOT_RENDERED:" + rule.id });
|
|
12087
|
+
return [];
|
|
12088
|
+
}
|
|
12089
|
+
const hasStops = declarations.some(rule => rule.enabled !== false && rule.stopIfTrue);
|
|
12090
|
+
if (hasStops && declarations.some(rule => rule.enabled !== false && (rule.style?.bar !== undefined || rule.style?.scale !== undefined))) {
|
|
12091
|
+
report({ code: "UNSUPPORTED_GLOBAL_STOP_WITH_NATIVE_VISUALS" });
|
|
12092
|
+
return [];
|
|
12093
|
+
}
|
|
12094
|
+
const barColumns = new Set(declarations.filter(rule => rule.enabled !== false && rule.style?.bar !== undefined).map(rule => rule.column));
|
|
12095
|
+
const barTone = declarations.find(rule => rule.enabled !== false && rule.target !== "row" && rule.style?.tone !== undefined && rule.column !== undefined && barColumns.has(rule.column));
|
|
12096
|
+
if (barTone) {
|
|
12097
|
+
// Canopy suppresses a cell tone's fill only where its bar resolves. A single native tone patch cannot express both cases.
|
|
12098
|
+
report({ code: "UNSUPPORTED_CELL_TONE_WITH_DATA_BAR", columnId: barTone.column });
|
|
12099
|
+
return [];
|
|
12100
|
+
}
|
|
12101
|
+
const priorStops = [];
|
|
12102
|
+
const priorRows = [], priorCells = new Map();
|
|
12103
|
+
const requiredCells = new Map();
|
|
12104
|
+
const column = (id) => {
|
|
12105
|
+
const index = columns.findIndex(column => column.id === id);
|
|
12106
|
+
if (index < 0)
|
|
12107
|
+
return unsupported("RULE_COLUMN_NOT_EXPORTED:" + id);
|
|
12108
|
+
return index;
|
|
12109
|
+
};
|
|
12110
|
+
const numeric = (id) => {
|
|
12111
|
+
if (columns[column(id)].kind !== "number")
|
|
12112
|
+
unsupported("RULE_COLUMN_NOT_NUMERIC:" + id);
|
|
12113
|
+
};
|
|
12114
|
+
const color = (name) => {
|
|
12115
|
+
const mapping = tones.get(name), value = mapping?.background ?? mapping?.color ?? palette[name]?.color;
|
|
12116
|
+
if (value === undefined)
|
|
12117
|
+
return unsupported("UNMAPPED_RULE_TONE:" + name);
|
|
12118
|
+
return value;
|
|
12119
|
+
};
|
|
12120
|
+
const style = (name) => {
|
|
12121
|
+
const defaults = palette[name];
|
|
12122
|
+
const mapping = tones.get(name) ?? (defaults ? { background: defaults.background, color: defaults.foreground } : undefined);
|
|
12123
|
+
if (!mapping)
|
|
12124
|
+
return unsupported("UNMAPPED_RULE_TONE:" + name);
|
|
12125
|
+
if ("alignment" in mapping || "wrapText" in mapping)
|
|
12126
|
+
return unsupported("UNSUPPORTED_RULE_TONE_STYLE:" + name);
|
|
12127
|
+
return {
|
|
12128
|
+
...("background" in mapping && mapping.background !== undefined ? { fill: { color: mapping.background } } : {}),
|
|
12129
|
+
font: { ...(mapping.color === undefined ? {} : { color: mapping.color }),
|
|
12130
|
+
...("bold" in mapping && mapping.bold !== undefined ? { bold: mapping.bold } : {}),
|
|
12131
|
+
...("italic" in mapping && mapping.italic !== undefined ? { italic: mapping.italic } : {}) },
|
|
12132
|
+
...("numberFormat" in mapping && mapping.numberFormat !== undefined ? { numberFormat: mapping.numberFormat } : {})
|
|
12133
|
+
};
|
|
12134
|
+
};
|
|
12135
|
+
for (const rule of declarations) {
|
|
12136
|
+
if (rule.enabled === false)
|
|
12137
|
+
continue;
|
|
12138
|
+
try {
|
|
12139
|
+
if (request.values !== "raw")
|
|
12140
|
+
unsupported("NATIVE_RULE_REQUIRES_RAW_VALUES");
|
|
12141
|
+
if (rule.target === "columns" || "columns" in rule && rule.columns !== undefined)
|
|
12142
|
+
unsupported("UNSUPPORTED_RULE_COLUMNS_TARGET");
|
|
12143
|
+
if (!rule.style || typeof rule.style !== "object" || Array.isArray(rule.style))
|
|
12144
|
+
throw new TypeError("Canopy rule style must be an object.");
|
|
12145
|
+
const styleInput = captureFields(rule.style, ["tone", "bar", "scale"]);
|
|
12146
|
+
if (Object.keys(styleInput).some(key => !["tone", "bar", "scale"].includes(key)))
|
|
12147
|
+
unsupported("UNSUPPORTED_RULE_STYLE");
|
|
12148
|
+
const supplied = [styleInput.bar, styleInput.scale, styleInput.tone].filter(value => value !== undefined);
|
|
12149
|
+
if (supplied.length !== 1)
|
|
12150
|
+
unsupported("UNSUPPORTED_RULE_STYLE_COMBINATION");
|
|
12151
|
+
if (styleInput.bar !== undefined) {
|
|
12152
|
+
if (rule.column === undefined || rule.when !== undefined || rule.target === "row")
|
|
12153
|
+
unsupported("UNSUPPORTED_BAR_TARGET");
|
|
12154
|
+
numeric(rule.column);
|
|
12155
|
+
if (rule.stopIfTrue)
|
|
12156
|
+
unsupported("UNSUPPORTED_BAR_STOP");
|
|
12157
|
+
const { minimum, maximum, tone = "info", showValue } = captureFields(styleInput.bar, ["minimum", "maximum", "tone", "showValue"]);
|
|
12158
|
+
if (minimum === undefined || maximum === undefined)
|
|
12159
|
+
return unsupported("UNBOUNDED_CANOPY_BAR");
|
|
12160
|
+
if (!Number.isFinite(minimum) || !Number.isFinite(maximum) || maximum <= minimum)
|
|
12161
|
+
throw new TypeError("Canopy bar bounds must be finite and increasing.");
|
|
12162
|
+
visuals.push({ type: "dataBar", range: { column: rule.column }, color: color(tone),
|
|
12163
|
+
minimum: { type: "number", value: minimum }, maximum: { type: "number", value: maximum }, ...(showValue === undefined ? {} : { showValue }) });
|
|
12164
|
+
requiredCells.set(column(rule.column), "number");
|
|
12165
|
+
}
|
|
12166
|
+
else if (styleInput.scale !== undefined) {
|
|
12167
|
+
if (rule.stopIfTrue)
|
|
12168
|
+
unsupported("UNSUPPORTED_SCALE_STOP");
|
|
12169
|
+
if (rule.column === undefined || rule.when !== undefined || rule.target === "row")
|
|
12170
|
+
unsupported("UNSUPPORTED_SCALE_TARGET");
|
|
12171
|
+
numeric(rule.column);
|
|
12172
|
+
const { stops } = captureFields(styleInput.scale, ["stops"]);
|
|
12173
|
+
if (!Array.isArray(stops) || stops.length < 2 || stops.length > 3)
|
|
12174
|
+
unsupported("UNSUPPORTED_SCALE_STOPS");
|
|
12175
|
+
const mapped = stops.map((input) => {
|
|
12176
|
+
const stop = captureFields(input, ["type", "value", "tone"]);
|
|
12177
|
+
if (!["min", "max", "number", "percent", "percentile"].includes(stop.type))
|
|
12178
|
+
unsupported("UNSUPPORTED_SCALE_THRESHOLD:" + stop.type);
|
|
12179
|
+
const threshold = stop.type === "min" || stop.type === "max" ? { type: stop.type }
|
|
12180
|
+
: { type: stop.type, value: stop.value };
|
|
12181
|
+
return { threshold, color: color(stop.tone) };
|
|
12182
|
+
});
|
|
12183
|
+
visuals.push({ type: "colorScale", range: { column: rule.column },
|
|
12184
|
+
stops: mapped });
|
|
12185
|
+
requiredCells.set(column(rule.column), "number");
|
|
12186
|
+
}
|
|
12187
|
+
else {
|
|
12188
|
+
if (rule.when === undefined || styleInput.tone === undefined || rule.target !== "row" && rule.column === undefined)
|
|
12189
|
+
unsupported("UNSUPPORTED_HIGHLIGHT_TARGET");
|
|
12190
|
+
if (rule.target !== undefined && rule.target !== "row" && rule.target !== "cell")
|
|
12191
|
+
unsupported("UNSUPPORTED_RULE_TARGET");
|
|
12192
|
+
const range = rule.target === "row" ? { column: columns[0].id, through: columns.at(-1).id } : { column: rule.column };
|
|
12193
|
+
if (rule.column !== undefined)
|
|
12194
|
+
column(rule.column);
|
|
12195
|
+
const ruleCells = new Map();
|
|
12196
|
+
const ownPredicate = canopyPredicate(request, grouped, options, rule.when, unsupported, ruleCells);
|
|
12197
|
+
const reachable = priorStops.length ? "AND(" + ownPredicate + ",NOT(OR(" + priorStops.join(",") + ")))" : ownPredicate;
|
|
12198
|
+
const previous = rule.target === "row" ? priorRows : priorCells.get(rule.column) ?? [];
|
|
12199
|
+
const formula = previous.length ? "AND(" + reachable + ",NOT(OR(" + previous.join(",") + ")))" : reachable;
|
|
12200
|
+
if (formula.length > 8192)
|
|
12201
|
+
unsupported("RULE_FORMULA_LIMIT");
|
|
12202
|
+
(rule.target === "row" ? rows : cells).push({ type: "expression", range, formula, style: style(styleInput.tone) });
|
|
12203
|
+
previous.push(ownPredicate);
|
|
12204
|
+
if (rule.target !== "row")
|
|
12205
|
+
priorCells.set(rule.column, previous);
|
|
12206
|
+
for (const [column, type] of ruleCells)
|
|
12207
|
+
requiredCells.set(column, type);
|
|
12208
|
+
// A matched declaration still stops the row when an earlier tone on that target already won.
|
|
12209
|
+
if (rule.stopIfTrue)
|
|
12210
|
+
priorStops.push(ownPredicate);
|
|
12211
|
+
}
|
|
12212
|
+
}
|
|
12213
|
+
catch (error) {
|
|
12214
|
+
if (!(error instanceof UnsupportedRule))
|
|
12215
|
+
throw error;
|
|
12216
|
+
report({ code: error.message + ":" + rule.id, ...(rule.column === undefined ? {} : { columnId: rule.column }) });
|
|
12217
|
+
if (hasStops)
|
|
12218
|
+
return []; // A partial sequence cannot claim to preserve its row-global stopping behavior.
|
|
12219
|
+
}
|
|
12220
|
+
}
|
|
12221
|
+
for (const [column, type] of requiredCells)
|
|
12222
|
+
cellTypes?.set(column, type);
|
|
12223
|
+
// Canopy paints cell visuals/tones over the row tint. Build masks before changing native priority order.
|
|
12224
|
+
return Object.freeze([...visuals, ...cells, ...rows]);
|
|
12225
|
+
}
|
|
12226
|
+
const _exports = Object.freeze({ canopyRules: canopyRules });
|
|
12227
|
+
return _exports;
|
|
12228
|
+
})();
|
|
12229
|
+
|
|
12230
|
+
const _m102 = (() => {
|
|
12231
|
+
const { createGroupedReport } = _m8;
|
|
12232
|
+
|
|
12233
|
+
const { checkAbort } = _m4;
|
|
12234
|
+
|
|
12235
|
+
const { createTotals } = _m12;
|
|
12236
|
+
|
|
12237
|
+
const { captureFields } = _m10;
|
|
12238
|
+
|
|
12239
|
+
const { datetime } = _m98;
|
|
12240
|
+
|
|
12241
|
+
const { canopyIdentityValue } = _m96;
|
|
12242
|
+
|
|
12243
|
+
const identity = (value) => value instanceof Date ? "date:" + value.getTime() : typeof value + ":" + String(value);
|
|
12244
|
+
const scalar = canopyIdentityValue;
|
|
12245
|
+
/** Validate captured ranges, then use the owned grouping factory and its existing writers.
|
|
12246
|
+
* Only ranges, labels and at most four active aggregate vectors are retained; no detail body is buffered. */
|
|
12247
|
+
function canopyGrouped(source, request, options, limits, report, format) {
|
|
12248
|
+
const input = request.grouping;
|
|
12249
|
+
if (input === undefined)
|
|
12250
|
+
return undefined; // query.groupBy never manufactures a group snapshot.
|
|
12251
|
+
if (request.values !== "raw") {
|
|
12252
|
+
report({ code: "GROUPING_REQUIRES_RAW_VALUES" });
|
|
12253
|
+
return undefined;
|
|
12254
|
+
}
|
|
12255
|
+
if (source.rowCount === null)
|
|
12256
|
+
throw new TypeError("Captured grouping requires its exact scope recordCount.");
|
|
12257
|
+
const grouping = captureFields(input, ["levels", "aggregates", "totals", "groups"]);
|
|
12258
|
+
if (!Array.isArray(grouping.levels) || grouping.levels.length < 1 || grouping.levels.length > 4 || !Array.isArray(grouping.aggregates) || !Array.isArray(grouping.groups))
|
|
12259
|
+
throw new TypeError("Canopy grouping needs one through four levels, aggregates and ordered groups.");
|
|
12260
|
+
const levels = grouping.levels.map(level => Object.freeze(captureFields(level, ["column", "direction", "title"])));
|
|
12261
|
+
if (levels.some(level => typeof level.column !== "string" || !level.column || level.direction !== "asc" && level.direction !== "desc") ||
|
|
12262
|
+
new Set(levels.map(level => level.column)).size !== levels.length)
|
|
12263
|
+
throw new TypeError("Canopy grouping levels need unique stable columns and directions.");
|
|
12264
|
+
const declarations = grouping.aggregates.map(aggregate => Object.freeze(captureFields(aggregate, ["id", "column", "operation", "label"])));
|
|
12265
|
+
const ids = new Set(), totals = Object.create(null);
|
|
12266
|
+
const operations = { sum: "sum", count: "count", average: "average", minimum: "min", maximum: "max" };
|
|
12267
|
+
for (const aggregate of declarations) {
|
|
12268
|
+
if (typeof aggregate.id !== "string" || !aggregate.id || ids.has(aggregate.id))
|
|
12269
|
+
throw new TypeError("Canopy aggregate IDs must be unique nonempty strings.");
|
|
12270
|
+
ids.add(aggregate.id);
|
|
12271
|
+
const column = source.columns.find(column => column.key === aggregate.column);
|
|
12272
|
+
if (!column || column.type !== "number")
|
|
12273
|
+
throw new TypeError("Canopy aggregate declarations require an exported raw numeric column.");
|
|
12274
|
+
if (Object.hasOwn(totals, aggregate.column))
|
|
12275
|
+
throw new TypeError("The grouped report supports one aggregate operation per column.");
|
|
12276
|
+
const operation = operations[aggregate.operation];
|
|
12277
|
+
if (operation === undefined) {
|
|
12278
|
+
report({ code: "UNSUPPORTED_GROUP_AGGREGATE:" + aggregate.operation, columnId: aggregate.column });
|
|
12279
|
+
return undefined;
|
|
12280
|
+
}
|
|
12281
|
+
totals[aggregate.column] = operation;
|
|
12282
|
+
}
|
|
12283
|
+
// Reuse the canonical operation validator rather than implementing aggregate semantics here.
|
|
12284
|
+
createTotals(source.columns, totals);
|
|
12285
|
+
const expected = (input) => {
|
|
12286
|
+
if (!input || typeof input !== "object" || Array.isArray(input))
|
|
12287
|
+
throw new TypeError("Canopy aggregate values must be an ID-keyed object.");
|
|
12288
|
+
const snapshot = { ...input };
|
|
12289
|
+
if (Object.keys(snapshot).some(key => !ids.has(key)) || declarations.some(aggregate => !Object.hasOwn(snapshot, aggregate.id)))
|
|
12290
|
+
throw new TypeError("Canopy aggregate values must reference exactly the captured declarations.");
|
|
12291
|
+
for (const value of Object.values(snapshot))
|
|
12292
|
+
if (value !== null && (typeof value !== "number" || !Number.isFinite(value)))
|
|
12293
|
+
throw new TypeError("Canopy aggregate values must be finite numbers or null.");
|
|
12294
|
+
return Object.freeze(snapshot);
|
|
12295
|
+
};
|
|
12296
|
+
const grandExpected = expected(grouping.totals), byDepth = levels.map(() => []), labels = levels.map(() => new Map());
|
|
12297
|
+
let groups = 0, characters = 0;
|
|
12298
|
+
const ranges = (inputs, offset, end, depth) => {
|
|
12299
|
+
if (!Array.isArray(inputs))
|
|
12300
|
+
throw new TypeError("Canopy groups must be ordered arrays.");
|
|
12301
|
+
let cursor = offset;
|
|
12302
|
+
const keys = new Set(), values = new Set();
|
|
12303
|
+
for (const input of inputs) {
|
|
12304
|
+
const group = captureFields(input, ["key", "value", "text", "offset", "count", "aggregates", "groups"]);
|
|
12305
|
+
if (!group || typeof group.key !== "string" || keys.has(group.key) || !Number.isSafeInteger(group.offset) || !Number.isSafeInteger(group.count) ||
|
|
12306
|
+
group.count <= 0 || group.offset !== cursor || group.count > end - group.offset)
|
|
12307
|
+
throw new TypeError("Canopy group ranges must be nonempty contiguous half-open partitions within their parent.");
|
|
12308
|
+
if (group.value !== null && !["string", "number", "boolean"].includes(typeof group.value) ||
|
|
12309
|
+
typeof group.value === "number" && !Number.isFinite(group.value))
|
|
12310
|
+
throw new TypeError("Canopy group values must be portable finite scalars.");
|
|
12311
|
+
const dateColumn = request.columns.find(column => column.id === levels[depth].column)?.kind === "datetime";
|
|
12312
|
+
const value = format === "xlsx" && dateColumn && typeof group.value === "string"
|
|
12313
|
+
? datetime(group.value, options.datetime ?? "preserve", options.xlsx?.dateMode ?? request.timeZone) : group.value;
|
|
12314
|
+
const key = identity(value), text = group.text ?? String(group.value ?? "");
|
|
12315
|
+
if (typeof text !== "string" || values.has(key))
|
|
12316
|
+
throw new TypeError("A Canopy group key cannot recur within the same parent.");
|
|
12317
|
+
const previousLabel = labels[depth].get(key);
|
|
12318
|
+
if (previousLabel !== undefined && previousLabel !== text)
|
|
12319
|
+
throw new TypeError("The same grouping value needs consistent captured text at one level.");
|
|
12320
|
+
labels[depth].set(key, text);
|
|
12321
|
+
keys.add(group.key);
|
|
12322
|
+
values.add(key);
|
|
12323
|
+
if (++groups > 1000 || (characters += group.key.length + key.length + text.length) > 1000000)
|
|
12324
|
+
throw new RangeError("Canopy group metadata exceeds the existing bounded report profile.");
|
|
12325
|
+
const next = group.offset + group.count;
|
|
12326
|
+
byDepth[depth].push(Object.freeze({ offset: group.offset, end: next, value, text, expected: expected(group.aggregates) }));
|
|
12327
|
+
if (depth + 1 < levels.length)
|
|
12328
|
+
ranges(group.groups ?? [], group.offset, next, depth + 1);
|
|
12329
|
+
else if (group.groups !== undefined && group.groups.length)
|
|
12330
|
+
throw new TypeError("Canopy nested groups exceed their declared levels.");
|
|
12331
|
+
cursor = next;
|
|
12332
|
+
}
|
|
12333
|
+
if (cursor !== end)
|
|
12334
|
+
throw new TypeError("Canopy grouping does not cover its complete exported detail range.");
|
|
12335
|
+
};
|
|
12336
|
+
ranges(grouping.groups, 0, source.rowCount, 0);
|
|
12337
|
+
// Validate the producer's wire arithmetic separately from the grouped writer's native formula caches.
|
|
12338
|
+
// Canopy sum/average use compensated accumulation and return null without numeric inputs.
|
|
12339
|
+
const wireTotals = () => {
|
|
12340
|
+
const ordinary = createTotals(source.columns, totals), sums = source.columns.map(() => 0), corrections = source.columns.map(() => 0), counts = source.columns.map(() => 0);
|
|
12341
|
+
return {
|
|
12342
|
+
accept(values) {
|
|
12343
|
+
for (let index = 0; index < values.length; index++) {
|
|
12344
|
+
const value = scalar(values[index]), operation = totals[source.columns[index].key];
|
|
12345
|
+
if (operation !== "sum" && operation !== "average") {
|
|
12346
|
+
ordinary[index].accept(value);
|
|
12347
|
+
continue;
|
|
12348
|
+
}
|
|
12349
|
+
if (typeof value !== "number" || !Number.isFinite(value))
|
|
12350
|
+
continue;
|
|
12351
|
+
counts[index] = counts[index] + 1;
|
|
12352
|
+
const next = value - corrections[index], total = sums[index] + next;
|
|
12353
|
+
corrections[index] = total - sums[index] - next;
|
|
12354
|
+
sums[index] = total;
|
|
12355
|
+
}
|
|
12356
|
+
},
|
|
12357
|
+
value(index) {
|
|
12358
|
+
const operation = totals[source.columns[index].key];
|
|
12359
|
+
return operation === "sum" || operation === "average" ? !counts[index] ? null
|
|
12360
|
+
: operation === "sum" ? sums[index] : sums[index] / counts[index] : ordinary[index].value();
|
|
12361
|
+
}
|
|
12362
|
+
};
|
|
12363
|
+
};
|
|
12364
|
+
const indexes = levels.map(() => 0), active = levels.map(() => undefined);
|
|
12365
|
+
const at = (depth, row) => {
|
|
12366
|
+
const list = byDepth[depth];
|
|
12367
|
+
while (list[indexes[depth]] && list[indexes[depth]].end <= row)
|
|
12368
|
+
indexes[depth] = indexes[depth] + 1;
|
|
12369
|
+
const range = list[indexes[depth]];
|
|
12370
|
+
if (!range || row < range.offset || row >= range.end)
|
|
12371
|
+
throw new TypeError("A detail row is outside its captured Canopy grouping.");
|
|
12372
|
+
return range;
|
|
12373
|
+
};
|
|
12374
|
+
const verify = (actual, expected) => {
|
|
12375
|
+
for (const declaration of declarations) {
|
|
12376
|
+
const position = source.columns.findIndex(column => column.key === declaration.column), observed = actual.value(position), declared = expected[declaration.id];
|
|
12377
|
+
// Exact producer-wire comparison retains wrong-scope rejection without rounding native caches or applying an epsilon.
|
|
12378
|
+
if (observed !== declared)
|
|
12379
|
+
throw new TypeError("Canopy captured aggregate differs from its consumed rows: " + declaration.id + ".");
|
|
12380
|
+
}
|
|
12381
|
+
};
|
|
12382
|
+
const same = (actual, expected) => actual instanceof Date && expected instanceof Date
|
|
12383
|
+
? actual.getTime() === expected.getTime() : actual === expected;
|
|
12384
|
+
async function* rows() {
|
|
12385
|
+
let index = 0;
|
|
12386
|
+
const grand = wireTotals();
|
|
12387
|
+
for await (const values of source.rows()) {
|
|
12388
|
+
checkAbort(options.signal);
|
|
12389
|
+
for (let depth = 0; depth < levels.length; depth++) {
|
|
12390
|
+
const range = at(depth, index), column = source.columns.findIndex(column => column.key === levels[depth].column);
|
|
12391
|
+
if (column >= 0 && !same(scalar(values[column]), range.value))
|
|
12392
|
+
throw new TypeError("Canopy detail value disagrees with its captured group range.");
|
|
12393
|
+
if (range.offset === index)
|
|
12394
|
+
active[depth] = { range, aggregates: wireTotals() };
|
|
12395
|
+
}
|
|
12396
|
+
grand.accept(values);
|
|
12397
|
+
for (const group of active)
|
|
12398
|
+
group.aggregates.accept(values);
|
|
12399
|
+
yield values;
|
|
12400
|
+
index++;
|
|
12401
|
+
for (let depth = levels.length - 1; depth >= 0; depth--) {
|
|
12402
|
+
const group = active[depth];
|
|
12403
|
+
if (group.range.end === index) {
|
|
12404
|
+
verify(group.aggregates, group.range.expected);
|
|
12405
|
+
active[depth] = undefined;
|
|
12406
|
+
}
|
|
12407
|
+
}
|
|
12408
|
+
}
|
|
12409
|
+
verify(grand, grandExpected);
|
|
12410
|
+
}
|
|
12411
|
+
// The factory's hidden fields keep raw group identity separate from projected
|
|
12412
|
+
// detail labels. Never override a declared output column's value getter.
|
|
12413
|
+
const groupKeys = new Set([...source.columns.map(column => column.key), ...levels.map(level => level.column)]);
|
|
12414
|
+
const groupBy = levels.map((level, depth) => {
|
|
12415
|
+
const column = source.columns.findIndex(column => column.key === level.column);
|
|
12416
|
+
let key = level.column;
|
|
12417
|
+
if (column >= 0) {
|
|
12418
|
+
do {
|
|
12419
|
+
key += "#raw";
|
|
12420
|
+
} while (groupKeys.has(key));
|
|
12421
|
+
groupKeys.add(key);
|
|
12422
|
+
}
|
|
12423
|
+
return { key,
|
|
12424
|
+
value: (row, context) => column < 0 ? at(depth, context.rowIndex).value : scalar(row[column]),
|
|
12425
|
+
label: (value) => labels[depth].get(identity(value)) ?? String(value ?? "") };
|
|
12426
|
+
});
|
|
12427
|
+
const sourceLimits = limits === undefined ? undefined : {
|
|
12428
|
+
...(limits.maxRows === undefined ? {} : { maxRows: limits.maxRows }),
|
|
12429
|
+
...(limits.maxCells === undefined ? {} : { maxCells: limits.maxCells }),
|
|
12430
|
+
...(limits.maxTextCharacters === undefined ? {} : { maxTextCharacters: limits.maxTextCharacters })
|
|
12431
|
+
};
|
|
12432
|
+
return createGroupedReport(rows(), { columns: source.columns, groupBy, totals,
|
|
12433
|
+
...(options.signal === undefined ? {} : { signal: options.signal }), ...(sourceLimits === undefined ? {} : { limits: sourceLimits }) });
|
|
11583
12434
|
}
|
|
11584
|
-
const _exports = Object.freeze({
|
|
12435
|
+
const _exports = Object.freeze({ canopyGrouped: canopyGrouped });
|
|
12436
|
+
return _exports;
|
|
12437
|
+
})();
|
|
12438
|
+
|
|
12439
|
+
const _m103 = (() => {
|
|
12440
|
+
const { cellText } = _m35;
|
|
12441
|
+
|
|
12442
|
+
const { cleanXml } = _m28;
|
|
12443
|
+
|
|
12444
|
+
/** Snapshot optional About metadata before enumeration. The accepted query is serialized, never evaluated. */
|
|
12445
|
+
function canopyAbout(request, options) {
|
|
12446
|
+
const result = [["revision", request.revision], ["recordCount", request.recordCount === null ? "unknown" : request.recordCount]];
|
|
12447
|
+
if (request.scope !== undefined) {
|
|
12448
|
+
if (!["filtered", "selected", "all"].includes(request.scope))
|
|
12449
|
+
throw new TypeError("Invalid Canopy export scope.");
|
|
12450
|
+
result.push(["scope", request.scope]);
|
|
12451
|
+
}
|
|
12452
|
+
for (const key of ["total", "matched"])
|
|
12453
|
+
if (request[key] !== undefined) {
|
|
12454
|
+
const value = request[key];
|
|
12455
|
+
if (value === null) {
|
|
12456
|
+
result.push([key, "unknown"]);
|
|
12457
|
+
continue;
|
|
12458
|
+
}
|
|
12459
|
+
if (!Number.isSafeInteger(value) || value < 0)
|
|
12460
|
+
throw new TypeError("Canopy metadata counts must be nonnegative safe integers.");
|
|
12461
|
+
result.push([key, value]);
|
|
12462
|
+
}
|
|
12463
|
+
if (request.generatedAt !== undefined) {
|
|
12464
|
+
if (typeof request.generatedAt !== "string" || !/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.\d{1,9})?Z$/.test(request.generatedAt) || !Number.isFinite(new Date(request.generatedAt).getTime()))
|
|
12465
|
+
throw new TypeError("Canopy generatedAt must be a captured UTC ISO instant.");
|
|
12466
|
+
result.push(["generatedAt", request.generatedAt]);
|
|
12467
|
+
}
|
|
12468
|
+
if (request.selection !== undefined) {
|
|
12469
|
+
if (!Array.isArray(request.selection) || request.selection.some(id => typeof id !== "string"))
|
|
12470
|
+
throw new TypeError("Canopy selection metadata must contain stable string IDs.");
|
|
12471
|
+
result.push(["selection", JSON.stringify(request.selection)]);
|
|
12472
|
+
}
|
|
12473
|
+
if (request.query !== undefined) {
|
|
12474
|
+
if (!request.query || typeof request.query !== "object" || Array.isArray(request.query))
|
|
12475
|
+
throw new TypeError("Canopy accepted query must be a captured object.");
|
|
12476
|
+
const query = JSON.stringify(request.query);
|
|
12477
|
+
if (typeof query !== "string")
|
|
12478
|
+
throw new TypeError("Canopy accepted query must serialize as JSON metadata.");
|
|
12479
|
+
result.push(["query", query]);
|
|
12480
|
+
}
|
|
12481
|
+
if (result.reduce((sum, row) => sum + row[0].length + String(row[1]).length, 0) > 65536)
|
|
12482
|
+
throw new RangeError("Canopy About metadata exceeds 65,536 captured characters.");
|
|
12483
|
+
// Validate known cell text before consuming details; overflow preservation and XML policy stay workbook-owned.
|
|
12484
|
+
for (const [field, value] of result) {
|
|
12485
|
+
cellText(field, options.invalidCharacterPolicy);
|
|
12486
|
+
if (options.oversizedText === "preserve")
|
|
12487
|
+
cleanXml(value, options.invalidCharacterPolicy);
|
|
12488
|
+
else
|
|
12489
|
+
cellText(value, options.invalidCharacterPolicy);
|
|
12490
|
+
}
|
|
12491
|
+
return Object.freeze(result.map(row => Object.freeze(row)));
|
|
12492
|
+
}
|
|
12493
|
+
const _exports = Object.freeze({ canopyAbout: canopyAbout });
|
|
12494
|
+
return _exports;
|
|
12495
|
+
})();
|
|
12496
|
+
|
|
12497
|
+
const _m104 = (() => {
|
|
12498
|
+
const { Workbook, addGroupedXlsx } = _m23;
|
|
12499
|
+
|
|
12500
|
+
const { portableWorkbook } = _m53;
|
|
12501
|
+
|
|
12502
|
+
const { withDestination } = _m3;
|
|
12503
|
+
|
|
12504
|
+
/** Compose only the adapter's data/grouped sheet and optional metadata sheet in the existing workbook owner. */
|
|
12505
|
+
async function writeCanopyWorkbook(source, grouped, destination, options, labels, about) {
|
|
12506
|
+
const { sheet: sheetSettings = {}, columns: _columns, ...settings } = options;
|
|
12507
|
+
const { name = "Data", ...sheet } = sheetSettings;
|
|
12508
|
+
if (about && name.toLowerCase() === "about")
|
|
12509
|
+
throw new TypeError("The optional About worksheet needs a distinct data-sheet name.");
|
|
12510
|
+
if (grouped && settings.cellValueWriters !== undefined)
|
|
12511
|
+
throw new TypeError("Grouped Canopy exports use resolved source values rather than custom cellValueWriters.");
|
|
12512
|
+
return withDestination(destination, async (sink) => {
|
|
12513
|
+
const workbookOptions = { ...portableWorkbook(settings), sink };
|
|
12514
|
+
// Grouped worksheets generate native FormulaCells; flat tables keep the portable-value boundary.
|
|
12515
|
+
const book = grouped ? new Workbook(workbookOptions) : Workbook.forTable(workbookOptions);
|
|
12516
|
+
try {
|
|
12517
|
+
let rows, columns;
|
|
12518
|
+
if (grouped) {
|
|
12519
|
+
const { conditionalFormats, ...groupedSheet } = sheet;
|
|
12520
|
+
const written = await addGroupedXlsx(book, grouped, {
|
|
12521
|
+
labelColumn: { header: labels?.labelColumn?.header ?? "Group", width: 18 },
|
|
12522
|
+
subtotalLabel: labels?.subtotalLabel ?? (group => group.label + " total"),
|
|
12523
|
+
grandTotalLabel: labels?.grandTotalLabel ?? (() => "Grand total"),
|
|
12524
|
+
...(labels?.includeGrandTotal === undefined ? {} : { includeGrandTotal: labels.includeGrandTotal }),
|
|
12525
|
+
sheet: { ...groupedSheet, name }, ...(conditionalFormats === undefined ? {} : { conditionalFormats })
|
|
12526
|
+
});
|
|
12527
|
+
rows = written.rows;
|
|
12528
|
+
columns = written.columns;
|
|
12529
|
+
}
|
|
12530
|
+
else {
|
|
12531
|
+
const data = book.addWorksheet(name, { boldHeader: true, autoFilter: sheet.includeHeader !== false,
|
|
12532
|
+
autoSize: { minWidth: 6, maxWidth: 54 }, ...sheet, columns: source.columns });
|
|
12533
|
+
await data.addRows(source.rows());
|
|
12534
|
+
await data.close();
|
|
12535
|
+
rows = data.rowCount;
|
|
12536
|
+
columns = source.columns.length;
|
|
12537
|
+
}
|
|
12538
|
+
if (about) {
|
|
12539
|
+
const metadata = book.addWorksheet("About", { columns: [{ header: "Field", width: 18 }, { header: "Value", width: 72, wrapText: true }],
|
|
12540
|
+
boldHeader: true, freezeHeader: true });
|
|
12541
|
+
await metadata.addRows(about);
|
|
12542
|
+
await metadata.close();
|
|
12543
|
+
}
|
|
12544
|
+
const result = await book.finish();
|
|
12545
|
+
return { rows, columns, bytes: result.bytes };
|
|
12546
|
+
}
|
|
12547
|
+
catch (error) {
|
|
12548
|
+
await book.discard(error);
|
|
12549
|
+
throw error;
|
|
12550
|
+
}
|
|
12551
|
+
});
|
|
12552
|
+
}
|
|
12553
|
+
const _exports = Object.freeze({ writeCanopyWorkbook: writeCanopyWorkbook });
|
|
12554
|
+
return _exports;
|
|
12555
|
+
})();
|
|
12556
|
+
|
|
12557
|
+
const _m106 = (() => {
|
|
12558
|
+
const { ExportCell } = _m1;
|
|
12559
|
+
|
|
12560
|
+
/** Fixed numeric formats affect PDF text, not the frozen numeric value used by other writers. */
|
|
12561
|
+
function numericProfile(format) {
|
|
12562
|
+
if (format === undefined)
|
|
12563
|
+
return undefined;
|
|
12564
|
+
const match = /^((?:"[^"\\]*")*)(#,##)?0(?:\.([0#]+))?(%)?((?:"[^"\\]*")*)$/.exec(format);
|
|
12565
|
+
if (!match || (match[3]?.length ?? 0) > 10)
|
|
12566
|
+
return undefined;
|
|
12567
|
+
return { minimumFractionDigits: (match[3]?.match(/0/g) ?? []).length, maximumFractionDigits: match[3]?.length ?? 0,
|
|
12568
|
+
percent: !!match[4], grouping: !!match[2], prefix: match[1].replace(/"/g, ""), suffix: match[5].replace(/"/g, "") };
|
|
12569
|
+
}
|
|
12570
|
+
/** Preserve the captured decimal convention across a column, including whole percentages without a separator. */
|
|
12571
|
+
function canopyPdfNumbers(sample, columns) {
|
|
12572
|
+
const formatters = new Map();
|
|
12573
|
+
const decimal = columns.map((column, index) => {
|
|
12574
|
+
let fallback = ".";
|
|
12575
|
+
for (const row of sample) {
|
|
12576
|
+
const cell = row[index];
|
|
12577
|
+
if (!(cell instanceof ExportCell) || typeof cell.value !== "number")
|
|
12578
|
+
continue;
|
|
12579
|
+
const profile = numericProfile(cell.presentation?.numberFormat ?? column.format);
|
|
12580
|
+
if (!profile?.maximumFractionDigits)
|
|
12581
|
+
continue;
|
|
12582
|
+
const match = /([.,])(\d+)[^\d.,]*$/.exec(cell.text ?? "");
|
|
12583
|
+
if (match && match[2].length <= profile.maximumFractionDigits) {
|
|
12584
|
+
const numeric = /([+-]?\d[\d.,]*)[^\d]*$/.exec(cell.text ?? "")?.[1] ?? "";
|
|
12585
|
+
const scaled = cell.value * (profile.percent ? 100 : 1);
|
|
12586
|
+
if (/^[+-]?\d{1,3}(?:,\d{3})+$/.test(numeric) || /^[+-]?\d{1,3}(?:\.\d{3})+$/.test(numeric)) {
|
|
12587
|
+
if (Math.abs(Number(numeric.replace(/[.,]/g, "")) - scaled) < .5) {
|
|
12588
|
+
fallback = match[1] === "," ? "." : ",";
|
|
12589
|
+
continue;
|
|
12590
|
+
}
|
|
12591
|
+
}
|
|
12592
|
+
return match[1];
|
|
12593
|
+
}
|
|
12594
|
+
}
|
|
12595
|
+
return fallback;
|
|
12596
|
+
});
|
|
12597
|
+
return row => row.map((value, index) => {
|
|
12598
|
+
if (!(value instanceof ExportCell) || typeof value.value !== "number")
|
|
12599
|
+
return value;
|
|
12600
|
+
const profile = numericProfile(value.presentation?.numberFormat ?? columns[index].format);
|
|
12601
|
+
if (!profile)
|
|
12602
|
+
return value;
|
|
12603
|
+
const captured = /^([^0-9+-]*)([+-]?\d[\d., \u00a0\u202f]*?)([^0-9]*)$/.exec(value.text ?? "");
|
|
12604
|
+
if (value.text && !captured)
|
|
12605
|
+
return value;
|
|
12606
|
+
const key = [decimal[index], profile.minimumFractionDigits, profile.maximumFractionDigits, profile.grouping].join(":");
|
|
12607
|
+
let formatter = formatters.get(key);
|
|
12608
|
+
if (!formatter) {
|
|
12609
|
+
formatter = new Intl.NumberFormat(decimal[index] === "," ? "de-DE" : "en-US", {
|
|
12610
|
+
minimumFractionDigits: profile.minimumFractionDigits, maximumFractionDigits: profile.maximumFractionDigits, useGrouping: profile.grouping
|
|
12611
|
+
});
|
|
12612
|
+
formatters.set(key, formatter);
|
|
12613
|
+
}
|
|
12614
|
+
const formatted = formatter.format(value.value * (profile.percent ? 100 : 1));
|
|
12615
|
+
const prefix = profile.prefix || captured?.[1] || "";
|
|
12616
|
+
let suffix = profile.suffix || captured?.[3] || "";
|
|
12617
|
+
if (profile.percent && !profile.suffix)
|
|
12618
|
+
suffix = suffix.replace(/%/g, "");
|
|
12619
|
+
return new ExportCell(value.value, { text: prefix + formatted + (profile.percent ? "%" : "") + suffix,
|
|
12620
|
+
...(value.presentation ? { presentation: value.presentation } : {}), ...(value.link ? { link: value.link } : {}) });
|
|
12621
|
+
});
|
|
12622
|
+
}
|
|
12623
|
+
const _exports = Object.freeze({ canopyPdfNumbers: canopyPdfNumbers });
|
|
12624
|
+
return _exports;
|
|
12625
|
+
})();
|
|
12626
|
+
|
|
12627
|
+
const _m105 = (() => {
|
|
12628
|
+
const { ExportCell, NotSupportedError, OfficeIMOError } = _m1;
|
|
12629
|
+
|
|
12630
|
+
const { inputRows, checkAbort, pause, taskYieldDue } = _m4;
|
|
12631
|
+
|
|
12632
|
+
const { fontProgram } = _m64;
|
|
12633
|
+
|
|
12634
|
+
const { resolveScalar, selectFont, validateFonts } = _m68;
|
|
12635
|
+
|
|
12636
|
+
const { settings } = _m17;
|
|
12637
|
+
|
|
12638
|
+
const { canopyPdfNumbers } = _m106;
|
|
12639
|
+
|
|
12640
|
+
/** A bounded lookahead is replayed once; no second capture, full-dataset copy or smaller font is needed. */
|
|
12641
|
+
async function withCanopyPdfLayout(source, captured, options, write) {
|
|
12642
|
+
const prepared = settings({ ...options, columns: source.columns }), { fontSize, padding, page, margins, limits } = prepared;
|
|
12643
|
+
options = prepared.options;
|
|
12644
|
+
validateFonts(options.fonts, limits.maxFontBytes);
|
|
12645
|
+
const available = page.width - margins.left - margins.right;
|
|
12646
|
+
const iterator = inputRows(source.rows(), options.signal)[Symbol.asyncIterator](), sample = [];
|
|
12647
|
+
let done = false, characters = 0;
|
|
12648
|
+
try {
|
|
12649
|
+
while (sample.length < Math.min(128, options.limits?.maxRows ?? 128) && characters < 262144) {
|
|
12650
|
+
const item = await iterator.next();
|
|
12651
|
+
if (item.done) {
|
|
12652
|
+
done = true;
|
|
12653
|
+
break;
|
|
12654
|
+
}
|
|
12655
|
+
sample.push(item.value);
|
|
12656
|
+
characters += item.value.reduce((n, cell) => n + (cell instanceof ExportCell ? cell.text?.length ?? 0 : String(cell ?? "").length), 0);
|
|
12657
|
+
}
|
|
12658
|
+
const format = canopyPdfNumbers(sample, source.columns), rows = sample.map(format);
|
|
12659
|
+
const measure = (text, bold = false, italic = false) => {
|
|
12660
|
+
if (text.length > limits.maxCellCharacters)
|
|
12661
|
+
throw new OfficeIMOError("RESOURCE_LIMIT", "maxCellCharacters exceeded.");
|
|
12662
|
+
const face = selectFont(options.fonts, bold, italic), program = face.font ? fontProgram(face.font) : undefined;
|
|
12663
|
+
let width = 0;
|
|
12664
|
+
for (const character of text.replace(/\t/g, " ")) {
|
|
12665
|
+
const scalar = resolveScalar(character.codePointAt(0), program, bold);
|
|
12666
|
+
if (!scalar.supported)
|
|
12667
|
+
throw new NotSupportedError(scalar.message);
|
|
12668
|
+
width += scalar.width * fontSize / 1000;
|
|
12669
|
+
}
|
|
12670
|
+
return width;
|
|
12671
|
+
};
|
|
12672
|
+
const largest = (parts, bold = false, italic = false) => parts.reduce((width, part) => Math.max(width, measure(part, bold, italic)), 0);
|
|
12673
|
+
let layout = {};
|
|
12674
|
+
// Explicit points/bands and shaping providers retain their own layout policy.
|
|
12675
|
+
if (!options.columnWidths && typeof options.wideTable !== "object" && !options.textShaper) {
|
|
12676
|
+
const minimum = source.columns.map(column => Math.min(available, largest(column.header.split(/\s+/), prepared.options.headerPresentation?.bold) + padding * 2 + .01));
|
|
12677
|
+
const natural = source.columns.map((column, index) => Math.min(available, Math.max(minimum[index], largest(column.header.split(/\r\n?|\n/), prepared.options.headerPresentation?.bold) + padding * 2 + .01)));
|
|
12678
|
+
for (const row of rows) {
|
|
12679
|
+
for (let i = 0; i < row.length; i++) {
|
|
12680
|
+
const cell = row[i], text = cell instanceof ExportCell ? cell.text ?? String(cell.value ?? "") : String(cell ?? "");
|
|
12681
|
+
const style = cell instanceof ExportCell ? cell.presentation : undefined;
|
|
12682
|
+
const line = largest(text.split(/\r\n?|\n/), style?.bold, style?.italic) + padding * 2 + .01;
|
|
12683
|
+
const word = largest(text.split(/\s+/), style?.bold, style?.italic) + padding * 2 + .01;
|
|
12684
|
+
natural[i] = Math.min(available, Math.max(natural[i], line));
|
|
12685
|
+
minimum[i] = Math.min(available, Math.max(minimum[i], captured[i].kind === "text" ? word : line));
|
|
12686
|
+
}
|
|
12687
|
+
if (taskYieldDue())
|
|
12688
|
+
await pause();
|
|
12689
|
+
checkAbort(options.signal);
|
|
12690
|
+
}
|
|
12691
|
+
const sum = minimum.reduce((total, width) => total + width, 0), widths = [...minimum];
|
|
12692
|
+
if (sum > available + .001)
|
|
12693
|
+
layout = { columnWidths: widths, wideTable: options.wideTable === "reject" ? "reject" : {
|
|
12694
|
+
mode: "bands", repeatColumns: widths[0] + Math.max(...widths.slice(1)) <= available ? [0] : []
|
|
12695
|
+
} };
|
|
12696
|
+
else {
|
|
12697
|
+
let spare = available - sum;
|
|
12698
|
+
const needs = natural.map((width, index) => Math.max(0, width - widths[index])), total = needs.reduce((n, width) => n + width, 0);
|
|
12699
|
+
for (let i = 0; i < widths.length; i++)
|
|
12700
|
+
widths[i] += total ? needs[i] * Math.min(1, spare / total) : 0;
|
|
12701
|
+
spare = available - widths.reduce((n, width) => n + width, 0);
|
|
12702
|
+
const text = captured.flatMap((column, index) => column.kind === "text" ? [index] : []);
|
|
12703
|
+
for (const i of text.length ? text : widths.map((_, index) => index))
|
|
12704
|
+
widths[i] += spare / (text.length || widths.length);
|
|
12705
|
+
layout = { columnWidths: widths };
|
|
12706
|
+
}
|
|
12707
|
+
}
|
|
12708
|
+
const replay = async function* () {
|
|
12709
|
+
for (const row of rows)
|
|
12710
|
+
yield row;
|
|
12711
|
+
while (!done) {
|
|
12712
|
+
const item = await iterator.next();
|
|
12713
|
+
if (item.done) {
|
|
12714
|
+
done = true;
|
|
12715
|
+
break;
|
|
12716
|
+
}
|
|
12717
|
+
yield format(item.value);
|
|
12718
|
+
}
|
|
12719
|
+
};
|
|
12720
|
+
return await write(replay(), layout, prepared.options);
|
|
12721
|
+
}
|
|
12722
|
+
finally {
|
|
12723
|
+
if (!done) {
|
|
12724
|
+
try {
|
|
12725
|
+
void iterator.return(undefined).catch(() => { });
|
|
12726
|
+
}
|
|
12727
|
+
catch { /* Keep the writer's original failure. */ }
|
|
12728
|
+
}
|
|
12729
|
+
}
|
|
12730
|
+
}
|
|
12731
|
+
const _exports = Object.freeze({ withCanopyPdfLayout: withCanopyPdfLayout });
|
|
11585
12732
|
return _exports;
|
|
11586
12733
|
})();
|
|
11587
12734
|
|
|
11588
12735
|
const _m0 = (() => {
|
|
11589
|
-
const { BlobByteSink } = _m1;
|
|
12736
|
+
const { BlobByteSink, ExportCell } = _m1;
|
|
11590
12737
|
|
|
11591
12738
|
const { notifyProgress } = _m14;
|
|
11592
12739
|
|
|
@@ -11596,38 +12743,119 @@ const { captureCommonLimits, captureXlsxOptions, captureCsvOptions, capturePdfOp
|
|
|
11596
12743
|
|
|
11597
12744
|
const { writeXlsxTo } = _m23;
|
|
11598
12745
|
|
|
11599
|
-
const { writeCsvTo } =
|
|
12746
|
+
const { writeCsvTo } = _m56;
|
|
12747
|
+
|
|
12748
|
+
const { writePdfTo, writeGroupedPdfTo } = _m58;
|
|
12749
|
+
|
|
12750
|
+
const { canopyDiagnostics } = _m95;
|
|
11600
12751
|
|
|
11601
|
-
const {
|
|
12752
|
+
const { prepareCanopyExport } = _m96;
|
|
11602
12753
|
|
|
11603
|
-
const {
|
|
12754
|
+
const { canopyPins } = _m99;
|
|
11604
12755
|
|
|
12756
|
+
const { canopyRules } = _m100;
|
|
11605
12757
|
|
|
12758
|
+
const { canopyGrouped } = _m102;
|
|
11606
12759
|
|
|
12760
|
+
const { canopyAbout } = _m103;
|
|
11607
12761
|
|
|
12762
|
+
const { writeCanopyWorkbook } = _m104;
|
|
11608
12763
|
|
|
12764
|
+
const { withCanopyPdfLayout } = _m105;
|
|
11609
12765
|
|
|
11610
12766
|
|
|
11611
|
-
|
|
12767
|
+
|
|
12768
|
+
|
|
12769
|
+
|
|
12770
|
+
|
|
12771
|
+
|
|
12772
|
+
/** Write a captured CanopyX grid to a caller-owned destination; partial bytes remain caller-owned on failure. */
|
|
11612
12773
|
async function writeCanopyTo(capture, format, destination, options = {}) {
|
|
11613
|
-
const selected = captureFields(options, ["tones", "columnOptions", "unsupportedPresentation", "datetime", "xlsx", "csv", "pdf", "signal", "onDiagnostic", "limits", "onProgress"]);
|
|
12774
|
+
const selected = captureFields(options, ["tones", "columnOptions", "unsupportedPresentation", "datetime", "xlsx", "csv", "pdf", "signal", "onDiagnostic", "limits", "onProgress", "grouped", "about"]);
|
|
11614
12775
|
const { signal, onProgress } = selected, limits = captureCommonLimits(selected.limits);
|
|
11615
12776
|
const xlsx = captureXlsxOptions(format === "xlsx" ? selected.xlsx : undefined);
|
|
11616
12777
|
const csv = captureCsvOptions(format === "csv" ? selected.csv : undefined);
|
|
11617
12778
|
const pdf = capturePdfOptions(format === "pdf" ? selected.pdf : undefined);
|
|
11618
|
-
const
|
|
12779
|
+
const prepared = prepareCanopyExport(capture, format, { ...selected, xlsx }), { request, report, tones, pivot } = prepared;
|
|
12780
|
+
if (selected.about !== undefined && typeof selected.about !== "boolean")
|
|
12781
|
+
throw new TypeError("Canopy about must be boolean.");
|
|
12782
|
+
const labels = selected.grouped === undefined ? undefined : captureFields(selected.grouped, ["labelColumn", "subtotalLabel", "grandTotalLabel", "includeGrandTotal", "continuationLabel", "groupHeadingLevel"]);
|
|
12783
|
+
const capturedLabels = labels && { ...labels, ...(labels.labelColumn === undefined ? {} : { labelColumn: Object.freeze({ header: labels.labelColumn.header }) }) };
|
|
12784
|
+
const about = format === "xlsx" && selected.about ? canopyAbout(request, xlsx) : undefined;
|
|
12785
|
+
const ruleCellTypes = new Map();
|
|
12786
|
+
let consumed = 0;
|
|
12787
|
+
const source = Object.freeze({ ...prepared.source, async *rows() {
|
|
12788
|
+
for await (const row of prepared.source.rows()) {
|
|
12789
|
+
for (const [column, type] of ruleCellTypes) {
|
|
12790
|
+
const cell = row[column], raw = cell instanceof ExportCell ? cell.value : cell;
|
|
12791
|
+
if (raw == null || type === "number" && typeof raw === "number" && Number.isFinite(raw) || type === "date" && raw instanceof Date && Number.isFinite(raw.getTime()))
|
|
12792
|
+
continue;
|
|
12793
|
+
const code = "UNSUPPORTED_NATIVE_RULE_CELL_TYPE:" + type;
|
|
12794
|
+
report({ code, columnId: source.columns[column].key });
|
|
12795
|
+
// Text fallback cannot retract an already captured native declaration after streaming starts.
|
|
12796
|
+
throw new TypeError("Unsupported Canopy presentation: " + code + " (" + source.columns[column].key + ")");
|
|
12797
|
+
}
|
|
12798
|
+
consumed++;
|
|
12799
|
+
yield row;
|
|
12800
|
+
}
|
|
12801
|
+
} });
|
|
11619
12802
|
const progress = onProgress ? { onProgress: (event) => {
|
|
11620
|
-
|
|
12803
|
+
// About and generated group rows consume output budgets, but never become exported source details.
|
|
12804
|
+
notifyProgress(onProgress, { ...event, rows: consumed,
|
|
12805
|
+
...(event.sheetRows === undefined ? {} : { sheetRows: about !== undefined && event.sheetName === "About" ? 0 : consumed }),
|
|
12806
|
+
...(source.rowCount === null ? {} : { totalRows: source.rowCount }) });
|
|
11621
12807
|
} } : {};
|
|
11622
12808
|
const stream = { ...(signal ? { signal } : {}), ...progress };
|
|
11623
|
-
if (format === "xlsx")
|
|
11624
|
-
|
|
11625
|
-
|
|
11626
|
-
|
|
11627
|
-
|
|
11628
|
-
|
|
11629
|
-
|
|
11630
|
-
|
|
12809
|
+
if (format === "xlsx") {
|
|
12810
|
+
const formatLimits = mergeAdapterLimits(xlsx.limits, limits), grouped = pivot ? undefined : canopyGrouped(source, request, { ...selected, xlsx }, formatLimits, report, format);
|
|
12811
|
+
const pinned = canopyPins(request.columns, report), rules = canopyRules(request, format, grouped !== undefined, tones, report, { ...selected, xlsx }, ruleCellTypes);
|
|
12812
|
+
if (pivot && (xlsx.sheet?.rowOutline !== undefined || xlsx.sheet?.columnOutlines !== undefined || xlsx.sheet?.maxOutlineLevel !== undefined ||
|
|
12813
|
+
xlsx.sheet?.outlineSummaryBelow !== undefined || xlsx.sheet?.outlineSummaryRight !== undefined || xlsx.sheet?.table !== undefined || xlsx.sheet?.footer !== undefined))
|
|
12814
|
+
throw new TypeError("Captured pivot metadata owns outlines and totals; worksheet overrides cannot regroup or recalculate it.");
|
|
12815
|
+
if (pivot && xlsx.cellValueWriters !== undefined)
|
|
12816
|
+
throw new TypeError("Captured pivot exports use frozen values rather than custom cellValueWriters.");
|
|
12817
|
+
const sheet = { ...xlsx.sheet, ...(pivot?.sheet ?? {}), ...(pivot ? { autoFilter: false } : {}),
|
|
12818
|
+
freezeHeader: xlsx.sheet?.freezeHeader ?? (xlsx.sheet?.includeHeader !== false),
|
|
12819
|
+
freezeColumns: xlsx.sheet?.freezeColumns ?? (pinned ? pinned + (grouped ? 1 : 0) : 0),
|
|
12820
|
+
conditionalFormats: [...rules, ...(xlsx.sheet?.conditionalFormats ?? [])] };
|
|
12821
|
+
const settings = { ...xlsx, ...stream, columns: source.columns, sheet, dateMode: xlsx.dateMode ?? request.timeZone, limits: formatLimits };
|
|
12822
|
+
if (grouped || about)
|
|
12823
|
+
return writeCanopyWorkbook(source, grouped, destination, settings, capturedLabels, about);
|
|
12824
|
+
return writeXlsxTo(source.rows(), destination, settings);
|
|
12825
|
+
}
|
|
12826
|
+
if (pivot)
|
|
12827
|
+
canopyDiagnostics(format, { ...selected, unsupportedPresentation: "text" })({ code: "PIVOT_OUTLINES_XLSX_ONLY" });
|
|
12828
|
+
if (format === "pdf") {
|
|
12829
|
+
if (pivot && pdf.footer?.totals !== undefined)
|
|
12830
|
+
throw new TypeError("Captured pivot metadata owns totals; PDF footer totals cannot recalculate it.");
|
|
12831
|
+
const formatLimits = mergeAdapterLimits(pdf.limits, limits), grouped = pivot ? undefined : canopyGrouped(source, request, selected, formatLimits, report, format);
|
|
12832
|
+
canopyRules(request, format, grouped !== undefined, tones, report, selected);
|
|
12833
|
+
// CSS pixels become points before the existing fit/band policy. Explicit PDF point widths win.
|
|
12834
|
+
const fitted = request.columns.every(column => column.width !== undefined) ? request.columns.map(column => column.width.preferred * 72 / 96) : undefined;
|
|
12835
|
+
const widths = pdf.columnWidths ?? fitted;
|
|
12836
|
+
const settings = { orientation: "landscape", wideTable: "fit", ...pdf, ...stream, limits: formatLimits };
|
|
12837
|
+
if (grouped) {
|
|
12838
|
+
if (pdf.headerRows !== undefined || pdf.footer !== undefined)
|
|
12839
|
+
throw new TypeError("Grouped Canopy PDF owns heading and summary rows.");
|
|
12840
|
+
const { headerRows: _headers, footer: _footer, ...groupedSettings } = settings;
|
|
12841
|
+
return writeGroupedPdfTo(grouped, destination, { ...groupedSettings,
|
|
12842
|
+
...(widths === undefined ? {} : { columnWidths: [72, ...widths] }),
|
|
12843
|
+
labelColumn: { header: capturedLabels?.labelColumn?.header ?? "Group", width: 12 },
|
|
12844
|
+
subtotalLabel: capturedLabels?.subtotalLabel ?? (group => group.label + " total"),
|
|
12845
|
+
grandTotalLabel: capturedLabels?.grandTotalLabel ?? (() => "Grand total"),
|
|
12846
|
+
...(capturedLabels?.includeGrandTotal === undefined ? {} : { includeGrandTotal: capturedLabels.includeGrandTotal }),
|
|
12847
|
+
...(capturedLabels?.continuationLabel === undefined ? {} : { continuationLabel: capturedLabels.continuationLabel }),
|
|
12848
|
+
...(capturedLabels?.groupHeadingLevel === undefined ? {} : { groupHeadingLevel: capturedLabels.groupHeadingLevel }) });
|
|
12849
|
+
}
|
|
12850
|
+
return withCanopyPdfLayout(prepared.source, request.columns, settings, async (rows, layout, captured) => {
|
|
12851
|
+
const counted = async function* () { for await (const row of rows) {
|
|
12852
|
+
consumed++;
|
|
12853
|
+
yield row;
|
|
12854
|
+
} };
|
|
12855
|
+
return writePdfTo(counted(), destination, { ...captured, ...layout, columns: source.columns });
|
|
12856
|
+
});
|
|
12857
|
+
}
|
|
12858
|
+
return writeCsvTo(source.rows(), destination, { ...csv, ...stream, columns: source.columns, valueMode: request.values,
|
|
11631
12859
|
limits: mergeAdapterLimits(csv.limits, limits) });
|
|
11632
12860
|
}
|
|
11633
12861
|
/** Export an immutable native capture as a Blob without loading or registering CanopyX. */
|
|
@@ -11642,7 +12870,7 @@ async function exportCanopy(capture, format, options = {}) {
|
|
|
11642
12870
|
throw error;
|
|
11643
12871
|
}
|
|
11644
12872
|
}
|
|
11645
|
-
const _exports = Object.freeze({ createCanopyExport:
|
|
12873
|
+
const _exports = Object.freeze({ createCanopyExport: _m96.createCanopyExport, ExportCell: _m5.ExportCell, PdfFont: _m64.PdfFont, writeCanopyTo: writeCanopyTo, exportCanopy: exportCanopy });
|
|
11646
12874
|
return _exports;
|
|
11647
12875
|
})();
|
|
11648
12876
|
const { createCanopyExport, ExportCell, PdfFont, writeCanopyTo, exportCanopy } = _m0;
|