docgen-utils 1.0.28 → 1.0.30
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 +3 -3
- package/dist/bundle.js +48 -27
- package/dist/bundle.min.js +77 -77
- package/dist/cli.js +140 -77
- package/dist/packages/cli/commands/export-docs.d.ts +1 -0
- package/dist/packages/cli/commands/export-docs.d.ts.map +1 -1
- package/dist/packages/cli/commands/export-docs.js +15 -5
- package/dist/packages/cli/commands/export-docs.js.map +1 -1
- package/dist/packages/cli/commands/export-slides.d.ts +1 -1
- package/dist/packages/cli/commands/export-slides.d.ts.map +1 -1
- package/dist/packages/cli/commands/export-slides.js +15 -5
- package/dist/packages/cli/commands/export-slides.js.map +1 -1
- package/dist/packages/cli/index.js +9 -6
- package/dist/packages/cli/index.js.map +1 -1
- package/dist/packages/shared/convert-to-pdf.d.ts +16 -0
- package/dist/packages/shared/convert-to-pdf.d.ts.map +1 -0
- package/dist/packages/shared/convert-to-pdf.js +65 -0
- package/dist/packages/shared/convert-to-pdf.js.map +1 -0
- package/dist/packages/slides/common.d.ts +14 -0
- package/dist/packages/slides/common.d.ts.map +1 -1
- package/dist/packages/slides/parse.d.ts.map +1 -1
- package/dist/packages/slides/parse.js +31 -0
- package/dist/packages/slides/parse.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -42,15 +42,15 @@ The CLI is used in the agent sandbox to transform artifacts.
|
|
|
42
42
|
alias docgen='npx tsx packages/cli'
|
|
43
43
|
docgen import docx --file=file.docx --out-dir=./output [--name=<filename>]
|
|
44
44
|
docgen import pptx --file=file.pptx --out-dir=./output [--name=<filename>]
|
|
45
|
-
docgen export docs --file=file.html --out-dir=./output [--name=<filename>] [--pageless]
|
|
46
|
-
docgen export slides --files=slide-1.html,slide-2.html --out-dir=./output [--name=<filename>]
|
|
45
|
+
docgen export docs --file=file.html --out-dir=./output [--name=<filename>] [--pageless] [--pdf]
|
|
46
|
+
docgen export slides --files=slide-1.html,slide-2.html --out-dir=./output [--name=<filename>] [--pdf]
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
## Visual Comparison
|
|
50
50
|
|
|
51
51
|
The `output` directory contains the rendered output in target formats. e.g. DOCX or PPTX vs HTML
|
|
52
52
|
|
|
53
|
-
- Files in `test-data/docs/` (
|
|
53
|
+
- Files in `test-data/docs/` (28 HTML files) → converted to DOCX → `docx-render.jpg`
|
|
54
54
|
- Files in `test-data/slides/` (90 HTML files) → converted to PPTX → `pptx-render.jpg`
|
|
55
55
|
- Files in `test-data/pptx/` (145 PPTX files) → imported to HTML → `html-render.jpg`
|
|
56
56
|
- Files in `test-data/docx/` (22 DOCX files) → imported to HTML → `html-render.jpg`
|
package/dist/bundle.js
CHANGED
|
@@ -65528,6 +65528,15 @@ ${generateStylesCss(styleMap, themeFonts)}
|
|
|
65528
65528
|
const alpha = parseFloat(match[4]);
|
|
65529
65529
|
return Math.round((1 - alpha) * 100);
|
|
65530
65530
|
}
|
|
65531
|
+
function extractZIndex(computed) {
|
|
65532
|
+
const zIndex = computed.zIndex;
|
|
65533
|
+
if (zIndex === "auto" || zIndex === "")
|
|
65534
|
+
return void 0;
|
|
65535
|
+
const parsed = parseInt(zIndex, 10);
|
|
65536
|
+
if (isNaN(parsed))
|
|
65537
|
+
return void 0;
|
|
65538
|
+
return parsed;
|
|
65539
|
+
}
|
|
65531
65540
|
function getEffectiveOpacity(element, win) {
|
|
65532
65541
|
let effectiveOpacity = 1;
|
|
65533
65542
|
let current = element;
|
|
@@ -66585,6 +66594,8 @@ ${generateStylesCss(styleMap, themeFonts)}
|
|
|
66585
66594
|
const parentRect = el.getBoundingClientRect();
|
|
66586
66595
|
if (parentRect.width <= 0 || parentRect.height <= 0)
|
|
66587
66596
|
return results;
|
|
66597
|
+
const parentComputed = win.getComputedStyle(el);
|
|
66598
|
+
const parentZIndex = extractZIndex(parentComputed);
|
|
66588
66599
|
for (const pseudo of ["::before", "::after"]) {
|
|
66589
66600
|
const pComputed = win.getComputedStyle(el, pseudo);
|
|
66590
66601
|
const content = pComputed.content;
|
|
@@ -66622,16 +66633,16 @@ ${generateStylesCss(styleMap, themeFonts)}
|
|
|
66622
66633
|
pTop = 0;
|
|
66623
66634
|
const pseudoPos = pComputed.position;
|
|
66624
66635
|
if (!pseudoPos || pseudoPos === "static") {
|
|
66625
|
-
const
|
|
66626
|
-
const parentDisplay =
|
|
66636
|
+
const parentComputed2 = win.getComputedStyle(el);
|
|
66637
|
+
const parentDisplay = parentComputed2.display;
|
|
66627
66638
|
const isFlex = parentDisplay === "flex" || parentDisplay === "inline-flex";
|
|
66628
66639
|
const isGrid = parentDisplay === "grid" || parentDisplay === "inline-grid";
|
|
66629
66640
|
if (isFlex) {
|
|
66630
|
-
const flexDir =
|
|
66641
|
+
const flexDir = parentComputed2.flexDirection || "row";
|
|
66631
66642
|
const isRow = flexDir === "row" || flexDir === "row-reverse";
|
|
66632
66643
|
const isReverse = flexDir.endsWith("-reverse");
|
|
66633
66644
|
const alignSelf = pComputed.alignSelf;
|
|
66634
|
-
const effectiveAlign = alignSelf && alignSelf !== "auto" ? alignSelf :
|
|
66645
|
+
const effectiveAlign = alignSelf && alignSelf !== "auto" ? alignSelf : parentComputed2.alignItems || "stretch";
|
|
66635
66646
|
const mTop = parseFloat(pComputed.marginTop) || 0;
|
|
66636
66647
|
const mRight = parseFloat(pComputed.marginRight) || 0;
|
|
66637
66648
|
const mBottom = parseFloat(pComputed.marginBottom) || 0;
|
|
@@ -66654,8 +66665,8 @@ ${generateStylesCss(styleMap, themeFonts)}
|
|
|
66654
66665
|
crossOffset = crossMarginBefore;
|
|
66655
66666
|
break;
|
|
66656
66667
|
}
|
|
66657
|
-
const gapProp = isRow ?
|
|
66658
|
-
const mainGap = parseFloat(gapProp) || parseFloat(
|
|
66668
|
+
const gapProp = isRow ? parentComputed2.columnGap : parentComputed2.rowGap;
|
|
66669
|
+
const mainGap = parseFloat(gapProp) || parseFloat(parentComputed2.gap) || 0;
|
|
66659
66670
|
const realChildren = Array.from(el.children).filter((c) => {
|
|
66660
66671
|
const s = win.getComputedStyle(c);
|
|
66661
66672
|
return s.display !== "none" && s.position !== "absolute" && s.position !== "fixed";
|
|
@@ -66679,7 +66690,7 @@ ${generateStylesCss(styleMap, themeFonts)}
|
|
|
66679
66690
|
mainOffset = marginBefore;
|
|
66680
66691
|
}
|
|
66681
66692
|
} else {
|
|
66682
|
-
const justify =
|
|
66693
|
+
const justify = parentComputed2.justifyContent || "normal";
|
|
66683
66694
|
const mainSize = isRow ? parentRect.width : parentRect.height;
|
|
66684
66695
|
const pseudoMainOuter = isRow ? pWidth + mLeft + mRight : pHeight + mTop + mBottom;
|
|
66685
66696
|
const marginBefore = isRow ? mLeft : mTop;
|
|
@@ -66695,9 +66706,9 @@ ${generateStylesCss(styleMap, themeFonts)}
|
|
|
66695
66706
|
pTop = isRow ? crossOffset : mainOffset;
|
|
66696
66707
|
} else if (isGrid) {
|
|
66697
66708
|
const alignSelf = pComputed.alignSelf;
|
|
66698
|
-
const alignItems = alignSelf && alignSelf !== "auto" ? alignSelf :
|
|
66709
|
+
const alignItems = alignSelf && alignSelf !== "auto" ? alignSelf : parentComputed2.alignItems || "stretch";
|
|
66699
66710
|
const justifySelf = pComputed.justifySelf;
|
|
66700
|
-
const justifyItems = justifySelf && justifySelf !== "auto" ? justifySelf :
|
|
66711
|
+
const justifyItems = justifySelf && justifySelf !== "auto" ? justifySelf : parentComputed2.justifyItems || "stretch";
|
|
66701
66712
|
if (alignItems === "center") {
|
|
66702
66713
|
pTop = (parentRect.height - pHeight) / 2;
|
|
66703
66714
|
} else if (alignItems === "end") {
|
|
@@ -66774,15 +66785,15 @@ ${generateStylesCss(styleMap, themeFonts)}
|
|
|
66774
66785
|
const pseudoRotation = extractRotationAngle(pComputed);
|
|
66775
66786
|
let effectiveRectRadius = isEllipse ? 0 : rectRadius;
|
|
66776
66787
|
if (rectRadius === 0 && !isEllipse) {
|
|
66777
|
-
const
|
|
66778
|
-
const parentOverflow =
|
|
66788
|
+
const parentComputed2 = win.getComputedStyle(el);
|
|
66789
|
+
const parentOverflow = parentComputed2.overflow;
|
|
66779
66790
|
if (parentOverflow === "hidden" || parentOverflow === "clip") {
|
|
66780
|
-
const parentRadius = parseFloat(
|
|
66791
|
+
const parentRadius = parseFloat(parentComputed2.borderRadius);
|
|
66781
66792
|
if (parentRadius > 0) {
|
|
66782
|
-
const parentBorderLeft = parseFloat(
|
|
66783
|
-
const parentBorderRight = parseFloat(
|
|
66784
|
-
const parentBorderTop = parseFloat(
|
|
66785
|
-
const parentBorderBottom = parseFloat(
|
|
66793
|
+
const parentBorderLeft = parseFloat(parentComputed2.borderLeftWidth) || 0;
|
|
66794
|
+
const parentBorderRight = parseFloat(parentComputed2.borderRightWidth) || 0;
|
|
66795
|
+
const parentBorderTop = parseFloat(parentComputed2.borderTopWidth) || 0;
|
|
66796
|
+
const parentBorderBottom = parseFloat(parentComputed2.borderBottomWidth) || 0;
|
|
66786
66797
|
const parentInnerWidth = parentRect.width - parentBorderLeft - parentBorderRight;
|
|
66787
66798
|
const parentInnerHeight = parentRect.height - parentBorderTop - parentBorderBottom;
|
|
66788
66799
|
const flushTop = Math.abs(pTop) < 2;
|
|
@@ -66799,15 +66810,15 @@ ${generateStylesCss(styleMap, themeFonts)}
|
|
|
66799
66810
|
}
|
|
66800
66811
|
let asymmetricCornerGeometry = null;
|
|
66801
66812
|
if (rectRadius === 0 && !isEllipse && effectiveRectRadius > 0) {
|
|
66802
|
-
const
|
|
66803
|
-
const parentRadius = parseFloat(
|
|
66813
|
+
const parentComputed2 = win.getComputedStyle(el);
|
|
66814
|
+
const parentRadius = parseFloat(parentComputed2.borderRadius);
|
|
66804
66815
|
const isThinHorizontal = pHeight < parentRadius && pWidth >= parentRadius * 2;
|
|
66805
66816
|
const isThinVertical = pWidth < parentRadius && pHeight >= parentRadius * 2;
|
|
66806
66817
|
if (isThinHorizontal || isThinVertical) {
|
|
66807
|
-
const parentBorderLeft = parseFloat(
|
|
66808
|
-
const parentBorderRight = parseFloat(
|
|
66809
|
-
const parentBorderTop = parseFloat(
|
|
66810
|
-
const parentBorderBottom = parseFloat(
|
|
66818
|
+
const parentBorderLeft = parseFloat(parentComputed2.borderLeftWidth) || 0;
|
|
66819
|
+
const parentBorderRight = parseFloat(parentComputed2.borderRightWidth) || 0;
|
|
66820
|
+
const parentBorderTop = parseFloat(parentComputed2.borderTopWidth) || 0;
|
|
66821
|
+
const parentBorderBottom = parseFloat(parentComputed2.borderBottomWidth) || 0;
|
|
66811
66822
|
const parentInnerWidth = parentRect.width - parentBorderLeft - parentBorderRight;
|
|
66812
66823
|
const parentInnerHeight = parentRect.height - parentBorderTop - parentBorderBottom;
|
|
66813
66824
|
const flushTop = Math.abs(pTop) < 2;
|
|
@@ -67064,7 +67075,8 @@ ${generateStylesCss(styleMap, themeFonts)}
|
|
|
67064
67075
|
rotate: pseudoRotation,
|
|
67065
67076
|
cssTriangle: null,
|
|
67066
67077
|
customGeometry: asymmetricCornerGeometry
|
|
67067
|
-
}
|
|
67078
|
+
},
|
|
67079
|
+
zIndex: parentZIndex
|
|
67068
67080
|
};
|
|
67069
67081
|
results.push(shapeElement);
|
|
67070
67082
|
for (const extraGrad of extraPseudoGradients) {
|
|
@@ -67087,7 +67099,8 @@ ${generateStylesCss(styleMap, themeFonts)}
|
|
|
67087
67099
|
rotate: null,
|
|
67088
67100
|
cssTriangle: null,
|
|
67089
67101
|
customGeometry: null
|
|
67090
|
-
}
|
|
67102
|
+
},
|
|
67103
|
+
zIndex: parentZIndex
|
|
67091
67104
|
};
|
|
67092
67105
|
results.push(extraShape);
|
|
67093
67106
|
}
|
|
@@ -67419,7 +67432,8 @@ ${generateStylesCss(styleMap, themeFonts)}
|
|
|
67419
67432
|
rotate: null,
|
|
67420
67433
|
cssTriangle: null,
|
|
67421
67434
|
customGeometry: null
|
|
67422
|
-
}
|
|
67435
|
+
},
|
|
67436
|
+
zIndex: extractZIndex(computed2)
|
|
67423
67437
|
};
|
|
67424
67438
|
elements.push(shapeElement);
|
|
67425
67439
|
if (hasBorder && !hasUniformBorder) {
|
|
@@ -67925,7 +67939,8 @@ ${generateStylesCss(styleMap, themeFonts)}
|
|
|
67925
67939
|
rotate: null,
|
|
67926
67940
|
cssTriangle: null,
|
|
67927
67941
|
customGeometry: null
|
|
67928
|
-
}
|
|
67942
|
+
},
|
|
67943
|
+
zIndex: extractZIndex(computed2)
|
|
67929
67944
|
};
|
|
67930
67945
|
elements.push(shapeElement);
|
|
67931
67946
|
if (hasBorder && !hasUniformBorder) {
|
|
@@ -70283,7 +70298,8 @@ ${generateStylesCss(styleMap, themeFonts)}
|
|
|
70283
70298
|
points.push({ x: 0, y: 0, close: true });
|
|
70284
70299
|
return points;
|
|
70285
70300
|
})() : null
|
|
70286
|
-
}
|
|
70301
|
+
},
|
|
70302
|
+
zIndex: extractZIndex(computed2)
|
|
70287
70303
|
};
|
|
70288
70304
|
if (hasPadding && shapeElement.style && (shapeText || shapeTextRuns && shapeTextRuns.length > 0)) {
|
|
70289
70305
|
let effectiveLeftPadding = paddingLeft;
|
|
@@ -71054,6 +71070,11 @@ ${generateStylesCss(styleMap, themeFonts)}
|
|
|
71054
71070
|
const pseudoElements = extractPseudoElements(htmlDiv, win);
|
|
71055
71071
|
elements.push(...pseudoElements);
|
|
71056
71072
|
});
|
|
71073
|
+
elements.sort((a, b) => {
|
|
71074
|
+
const zIndexA = "zIndex" in a && a.zIndex !== void 0 ? a.zIndex : 0;
|
|
71075
|
+
const zIndexB = "zIndex" in b && b.zIndex !== void 0 ? b.zIndex : 0;
|
|
71076
|
+
return zIndexA - zIndexB;
|
|
71077
|
+
});
|
|
71057
71078
|
return { background, elements, placeholders, errors };
|
|
71058
71079
|
}
|
|
71059
71080
|
|