@softwear/latestcollectioncore 1.0.179 → 1.0.180
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/dist/reports.js +11 -1
- package/package.json +1 -1
- package/src/reports.ts +14 -2
package/dist/reports.js
CHANGED
|
@@ -381,6 +381,7 @@ function drawSimpleObject(x, y, doc, object, printBuffer, width, height, options
|
|
|
381
381
|
}
|
|
382
382
|
function addPage(originX, originY, doc, layout, rootPrintBuffer, paperSize, options, containerChain, context) {
|
|
383
383
|
context.pendingRootStartBumpTenths = 0;
|
|
384
|
+
context.applyRootStartBumpToThisCall = false;
|
|
384
385
|
if (context.mode === 'measurement') {
|
|
385
386
|
// Track page count in measurement mode
|
|
386
387
|
if (context.currentPageCount === undefined) {
|
|
@@ -455,7 +456,12 @@ function drawBottomDwellers(object, originX, originY, absoluteLowerRightHandSide
|
|
|
455
456
|
*/
|
|
456
457
|
addObjectToPDF = function (originX, originY, doc, object, printBuffer, paperSize, layout, options, rootPrintBuffer, containerChain, context) {
|
|
457
458
|
var _a, _b;
|
|
458
|
-
|
|
459
|
+
let rootBump = 0;
|
|
460
|
+
if (context.applyRootStartBumpToThisCall) {
|
|
461
|
+
rootBump = (_a = context.pendingRootStartBumpTenths) !== null && _a !== void 0 ? _a : 0;
|
|
462
|
+
context.applyRootStartBumpToThisCall = false;
|
|
463
|
+
context.pendingRootStartBumpTenths = 0;
|
|
464
|
+
}
|
|
459
465
|
const x = (originX + object.x) / 10;
|
|
460
466
|
const y = (originY + object.y + rootBump) / 10;
|
|
461
467
|
const width = object.width / 10;
|
|
@@ -689,12 +695,14 @@ function genPDF(layout, printBuffer, options = {}) {
|
|
|
689
695
|
!object.printOnlyAtEnd &&
|
|
690
696
|
!object.printOnlyAtStart)
|
|
691
697
|
.forEach((object) => {
|
|
698
|
+
measurementContext.applyRootStartBumpToThisCall = true;
|
|
692
699
|
measurementContext.pendingRootStartBumpTenths = Math.max(0, measurementTopPrintedStartBottomTenths - object.y);
|
|
693
700
|
addObjectToPDF(0, 0, measurementDoc, object, printBuffer, paperSize, layout, options, printBuffer, [], measurementContext);
|
|
694
701
|
});
|
|
695
702
|
layout.objects
|
|
696
703
|
.filter((object) => object.type == 'container' && object.printOnlyAtEnd)
|
|
697
704
|
.forEach((object) => {
|
|
705
|
+
measurementContext.applyRootStartBumpToThisCall = true;
|
|
698
706
|
measurementContext.pendingRootStartBumpTenths = Math.max(0, measurementTopPrintedStartBottomTenths - object.y);
|
|
699
707
|
addObjectToPDF(0, 0, measurementDoc, object, printBuffer, paperSize, layout, options, printBuffer, [], measurementContext);
|
|
700
708
|
});
|
|
@@ -728,12 +736,14 @@ function genPDF(layout, printBuffer, options = {}) {
|
|
|
728
736
|
!object.printOnlyAtEnd &&
|
|
729
737
|
!object.printOnlyAtStart)
|
|
730
738
|
.forEach((object) => {
|
|
739
|
+
renderContext.applyRootStartBumpToThisCall = true;
|
|
731
740
|
renderContext.pendingRootStartBumpTenths = Math.max(0, renderTopPrintedStartBottomTenths - object.y);
|
|
732
741
|
addObjectToPDF(0, 0, doc, object, printBuffer, paperSize, layout, options, printBuffer, [], renderContext);
|
|
733
742
|
});
|
|
734
743
|
// Draw printOnlyAtEnd containers once at the end (at their layout coordinates on current page)
|
|
735
744
|
const printOnlyAtEndContainers = layout.objects.filter((object) => object.type == 'container' && object.printOnlyAtEnd);
|
|
736
745
|
printOnlyAtEndContainers.forEach((object) => {
|
|
746
|
+
renderContext.applyRootStartBumpToThisCall = true;
|
|
737
747
|
renderContext.pendingRootStartBumpTenths = Math.max(0, renderTopPrintedStartBottomTenths - object.y);
|
|
738
748
|
addObjectToPDF(0, 0, doc, object, printBuffer, paperSize, layout, options, printBuffer, [], renderContext);
|
|
739
749
|
});
|
package/package.json
CHANGED
package/src/reports.ts
CHANGED
|
@@ -46,7 +46,9 @@ interface RenderContext {
|
|
|
46
46
|
imageAssets?: Map<string, PdfImageAsset>
|
|
47
47
|
/** Layout default font used when object.fontFamily is undefined */
|
|
48
48
|
defaultFontFamily?: string
|
|
49
|
-
/**
|
|
49
|
+
/** Set with {@link pendingRootStartBumpTenths} only for top-level genPDF container draws; consumed on first addObjectToPDF read. */
|
|
50
|
+
applyRootStartBumpToThisCall?: boolean
|
|
51
|
+
/** Vertical pad (tenths-mm) so body roots sit below rendered printOnlyAtStart siblings; use with applyRootStartBumpToThisCall only. */
|
|
50
52
|
pendingRootStartBumpTenths?: number
|
|
51
53
|
}
|
|
52
54
|
|
|
@@ -448,6 +450,7 @@ function addPage(
|
|
|
448
450
|
context: RenderContext
|
|
449
451
|
): { originX: number; originY: number; x: number; y: number } {
|
|
450
452
|
context.pendingRootStartBumpTenths = 0
|
|
453
|
+
context.applyRootStartBumpToThisCall = false
|
|
451
454
|
if (context.mode === 'measurement') {
|
|
452
455
|
// Track page count in measurement mode
|
|
453
456
|
if (context.currentPageCount === undefined) {
|
|
@@ -544,7 +547,12 @@ addObjectToPDF = function (
|
|
|
544
547
|
containerChain: { object: ContainerLayoutObject; printBuffer: any }[],
|
|
545
548
|
context: RenderContext
|
|
546
549
|
): { x: number; y: number } {
|
|
547
|
-
|
|
550
|
+
let rootBump = 0
|
|
551
|
+
if (context.applyRootStartBumpToThisCall) {
|
|
552
|
+
rootBump = context.pendingRootStartBumpTenths ?? 0
|
|
553
|
+
context.applyRootStartBumpToThisCall = false
|
|
554
|
+
context.pendingRootStartBumpTenths = 0
|
|
555
|
+
}
|
|
548
556
|
const x = (originX + object.x) / 10
|
|
549
557
|
const y = (originY + object.y + rootBump) / 10
|
|
550
558
|
const width = object.width / 10
|
|
@@ -817,12 +825,14 @@ export async function genPDF(layout: Layout, printBuffer: any, options: GenPdfOp
|
|
|
817
825
|
!(object as ContainerLayoutObject).printOnlyAtStart
|
|
818
826
|
)
|
|
819
827
|
.forEach((object) => {
|
|
828
|
+
measurementContext.applyRootStartBumpToThisCall = true
|
|
820
829
|
measurementContext.pendingRootStartBumpTenths = Math.max(0, measurementTopPrintedStartBottomTenths - object.y)
|
|
821
830
|
addObjectToPDF(0, 0, measurementDoc, object, printBuffer, paperSize, layout, options, printBuffer, [], measurementContext)
|
|
822
831
|
})
|
|
823
832
|
layout.objects
|
|
824
833
|
.filter((object) => object.type == 'container' && (object as ContainerLayoutObject).printOnlyAtEnd)
|
|
825
834
|
.forEach((object) => {
|
|
835
|
+
measurementContext.applyRootStartBumpToThisCall = true
|
|
826
836
|
measurementContext.pendingRootStartBumpTenths = Math.max(0, measurementTopPrintedStartBottomTenths - object.y)
|
|
827
837
|
addObjectToPDF(0, 0, measurementDoc, object, printBuffer, paperSize, layout, options, printBuffer, [], measurementContext)
|
|
828
838
|
})
|
|
@@ -863,6 +873,7 @@ export async function genPDF(layout: Layout, printBuffer: any, options: GenPdfOp
|
|
|
863
873
|
!(object as ContainerLayoutObject).printOnlyAtStart
|
|
864
874
|
)
|
|
865
875
|
.forEach((object) => {
|
|
876
|
+
renderContext.applyRootStartBumpToThisCall = true
|
|
866
877
|
renderContext.pendingRootStartBumpTenths = Math.max(0, renderTopPrintedStartBottomTenths - object.y)
|
|
867
878
|
addObjectToPDF(0, 0, doc, object, printBuffer, paperSize, layout, options, printBuffer, [], renderContext)
|
|
868
879
|
})
|
|
@@ -872,6 +883,7 @@ export async function genPDF(layout: Layout, printBuffer: any, options: GenPdfOp
|
|
|
872
883
|
(object) => object.type == 'container' && (object as ContainerLayoutObject).printOnlyAtEnd
|
|
873
884
|
)
|
|
874
885
|
printOnlyAtEndContainers.forEach((object) => {
|
|
886
|
+
renderContext.applyRootStartBumpToThisCall = true
|
|
875
887
|
renderContext.pendingRootStartBumpTenths = Math.max(0, renderTopPrintedStartBottomTenths - object.y)
|
|
876
888
|
addObjectToPDF(0, 0, doc, object, printBuffer, paperSize, layout, options, printBuffer, [], renderContext)
|
|
877
889
|
})
|