docgen-utils 1.0.13 → 1.0.14

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.
Files changed (31) hide show
  1. package/dist/bundle.js +46 -1
  2. package/dist/bundle.min.js +38 -38
  3. package/dist/cli.js +24020 -77
  4. package/dist/packages/cli/commands/export-docs.d.ts +10 -1
  5. package/dist/packages/cli/commands/export-docs.d.ts.map +1 -1
  6. package/dist/packages/cli/commands/export-docs.js +262 -44
  7. package/dist/packages/cli/commands/export-docs.js.map +1 -1
  8. package/dist/packages/cli/commands/export-slides.d.ts +1 -1
  9. package/dist/packages/cli/commands/export-slides.d.ts.map +1 -1
  10. package/dist/packages/cli/commands/export-slides.js +82 -25
  11. package/dist/packages/cli/commands/export-slides.js.map +1 -1
  12. package/dist/packages/cli/commands/import-docx.d.ts +1 -1
  13. package/dist/packages/cli/commands/import-docx.d.ts.map +1 -1
  14. package/dist/packages/cli/commands/import-docx.js +3 -3
  15. package/dist/packages/cli/commands/import-docx.js.map +1 -1
  16. package/dist/packages/cli/commands/import-pptx.d.ts +1 -1
  17. package/dist/packages/cli/commands/import-pptx.d.ts.map +1 -1
  18. package/dist/packages/cli/commands/import-pptx.js +2 -2
  19. package/dist/packages/cli/commands/import-pptx.js.map +1 -1
  20. package/dist/packages/cli/index.js +14 -8
  21. package/dist/packages/cli/index.js.map +1 -1
  22. package/dist/packages/docs/parse-helpers.d.ts.map +1 -1
  23. package/dist/packages/docs/parse-helpers.js +7 -1
  24. package/dist/packages/docs/parse-helpers.js.map +1 -1
  25. package/dist/packages/slides/createPresentation.d.ts.map +1 -1
  26. package/dist/packages/slides/createPresentation.js +20 -0
  27. package/dist/packages/slides/createPresentation.js.map +1 -1
  28. package/dist/packages/slides/transform.d.ts.map +1 -1
  29. package/dist/packages/slides/transform.js +45 -0
  30. package/dist/packages/slides/transform.js.map +1 -1
  31. package/package.json +3 -2
package/dist/bundle.js CHANGED
@@ -48969,7 +48969,9 @@ var docgen = (() => {
48969
48969
  }
48970
48970
  const cssBorder = styles.border || "";
48971
48971
  const hasCssBorder = cssBorder.includes("solid") || cssBorder.includes("px");
48972
- const hasBackground = !!styles.backgroundColor && styles.backgroundColor !== "transparent" && styles.backgroundColor !== "inherit";
48972
+ const bgColor = styles.backgroundColor?.toLowerCase() || "";
48973
+ const isWhiteBackground = bgColor === "#ffffff" || bgColor === "#fff" || bgColor === "white" || bgColor === "rgb(255, 255, 255)" || bgColor === "rgba(255, 255, 255, 1)";
48974
+ const hasBackground = !!styles.backgroundColor && styles.backgroundColor !== "transparent" && styles.backgroundColor !== "inherit" && !isWhiteBackground;
48973
48975
  if (hasBackground && (hasBorderLeft || hasCssBorder)) {
48974
48976
  return true;
48975
48977
  }
@@ -67530,6 +67532,23 @@ ${generateStylesCss(styleMap, themeFonts)}
67530
67532
  // 3s timeout for slow CDN
67531
67533
  ]);
67532
67534
  }
67535
+ const images = doc.querySelectorAll("img");
67536
+ if (images.length > 0) {
67537
+ const imagePromises = Array.from(images).map((img) => {
67538
+ if (img.complete && img.naturalWidth > 0) {
67539
+ return Promise.resolve();
67540
+ }
67541
+ return new Promise((resolve) => {
67542
+ img.onload = () => resolve();
67543
+ img.onerror = () => resolve();
67544
+ });
67545
+ });
67546
+ await Promise.race([
67547
+ Promise.all(imagePromises),
67548
+ new Promise((r) => setTimeout(r, 5e3))
67549
+ // 5s timeout for slow images
67550
+ ]);
67551
+ }
67533
67552
  return { iframe, doc };
67534
67553
  }
67535
67554
  async function addSlideFromHtml(source, pres, options = {}) {
@@ -67737,6 +67756,32 @@ ${validationErrors.map((e, i) => ` ${i + 1}. ${e}`).join("\n")}`;
67737
67756
  html = html.replace(/<\/style>/i, `body { width: ${targetWidth}pt; height: ${targetHeight}pt; overflow: hidden; margin: 0; }
67738
67757
  </style>`);
67739
67758
  }
67759
+ const maskImagePattern = /mask-image|--webkit-mask-image/i;
67760
+ const cssRules = html.match(/<style[^>]*>([\s\S]*?)<\/style>/gi) || [];
67761
+ const classesWithMask = /* @__PURE__ */ new Set();
67762
+ for (const styleBlock of cssRules) {
67763
+ const classMatches = styleBlock.matchAll(/\.([a-zA-Z_][\w-]*)\s*\{[^}]*mask-image[^}]*\}/gi);
67764
+ for (const m of classMatches) {
67765
+ classesWithMask.add(m[1]);
67766
+ }
67767
+ }
67768
+ html = html.replace(/<img\s+([^>]*?)src="(https?:\/\/[^"]+)"([^>]*)>/gi, (match, before2, url, after2) => {
67769
+ if (/crossorigin\s*=/i.test(before2 + after2)) {
67770
+ return match;
67771
+ }
67772
+ const fullAttrs = before2 + after2;
67773
+ const hasInlineMask = maskImagePattern.test(fullAttrs);
67774
+ let hasClassMask = false;
67775
+ const classMatch = fullAttrs.match(/class\s*=\s*["']([^"']+)["']/i);
67776
+ if (classMatch) {
67777
+ const classes = classMatch[1].split(/\s+/);
67778
+ hasClassMask = classes.some((c) => classesWithMask.has(c));
67779
+ }
67780
+ if (hasInlineMask || hasClassMask) {
67781
+ return `<img ${before2}src="${url}"${after2} crossorigin="anonymous">`;
67782
+ }
67783
+ return match;
67784
+ });
67740
67785
  return html;
67741
67786
  }
67742
67787