docgen-utils 1.0.30 → 1.0.32
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/bundle.js +43 -27
- package/dist/bundle.min.js +78 -78
- package/dist/cli.js +6165 -82
- package/dist/packages/cli/commands/export-slides.d.ts +4 -9
- package/dist/packages/cli/commands/export-slides.d.ts.map +1 -1
- package/dist/packages/cli/commands/export-slides.js +233 -100
- package/dist/packages/cli/commands/export-slides.js.map +1 -1
- package/dist/packages/slides/convert.d.ts +2 -0
- package/dist/packages/slides/convert.d.ts.map +1 -1
- package/dist/packages/slides/convert.js +36 -28
- package/dist/packages/slides/convert.js.map +1 -1
- package/dist/packages/slides/createPresentation.d.ts.map +1 -1
- package/dist/packages/slides/createPresentation.js +18 -18
- package/dist/packages/slides/createPresentation.js.map +1 -1
- package/package.json +1 -1
package/dist/bundle.js
CHANGED
|
@@ -71192,24 +71192,38 @@ ${generateStylesCss(styleMap, themeFonts)}
|
|
|
71192
71192
|
return null;
|
|
71193
71193
|
return { x, y, w, h };
|
|
71194
71194
|
}
|
|
71195
|
-
async function
|
|
71196
|
-
|
|
71197
|
-
|
|
71198
|
-
|
|
71199
|
-
|
|
71200
|
-
|
|
71201
|
-
|
|
71202
|
-
} catch (e) {
|
|
71203
|
-
const message = e instanceof Error ? e.message : String(e);
|
|
71204
|
-
console.warn(`Could not fetch image ${src}: ${message}`);
|
|
71205
|
-
return null;
|
|
71195
|
+
async function addElementsToSlide(elements, slide, pres) {
|
|
71196
|
+
const imageUrls = /* @__PURE__ */ new Set();
|
|
71197
|
+
for (const el of elements) {
|
|
71198
|
+
if (el.type === "image" || el.type === "backgroundImage" || el.type === "slideBackgroundImage") {
|
|
71199
|
+
if (el.src && !el.src.startsWith("data:")) {
|
|
71200
|
+
imageUrls.add(el.src);
|
|
71201
|
+
}
|
|
71206
71202
|
}
|
|
71207
71203
|
}
|
|
71208
|
-
|
|
71209
|
-
|
|
71204
|
+
const imageCache = /* @__PURE__ */ new Map();
|
|
71205
|
+
if (imageUrls.size > 0) {
|
|
71206
|
+
const fetchPromises = Array.from(imageUrls).map(async (url) => {
|
|
71207
|
+
try {
|
|
71208
|
+
const dataUrl = await fetchImageAsDataUrl(url);
|
|
71209
|
+
imageCache.set(url, { data: dataUrl });
|
|
71210
|
+
} catch (e) {
|
|
71211
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
71212
|
+
console.warn(`Could not fetch image ${url}: ${message}`);
|
|
71213
|
+
imageCache.set(url, null);
|
|
71214
|
+
}
|
|
71215
|
+
});
|
|
71216
|
+
await Promise.all(fetchPromises);
|
|
71217
|
+
}
|
|
71218
|
+
const getCachedImageSource = (src) => {
|
|
71219
|
+
if (src.startsWith("data:")) {
|
|
71220
|
+
return { data: src };
|
|
71221
|
+
}
|
|
71222
|
+
return imageCache.get(src) ?? null;
|
|
71223
|
+
};
|
|
71210
71224
|
for (const el of elements) {
|
|
71211
71225
|
if (el.type === "slideBackgroundImage") {
|
|
71212
|
-
const imgSrc =
|
|
71226
|
+
const imgSrc = getCachedImageSource(el.src);
|
|
71213
71227
|
if (!imgSrc) {
|
|
71214
71228
|
console.warn(`Skipping slide background image (CORS failure): ${el.src}`);
|
|
71215
71229
|
continue;
|
|
@@ -71255,7 +71269,7 @@ ${generateStylesCss(styleMap, themeFonts)}
|
|
|
71255
71269
|
el.position.h = clipped.h;
|
|
71256
71270
|
}
|
|
71257
71271
|
if (el.type === "image") {
|
|
71258
|
-
const imgSrc =
|
|
71272
|
+
const imgSrc = getCachedImageSource(el.src);
|
|
71259
71273
|
if (!imgSrc) {
|
|
71260
71274
|
console.warn(`Skipping image (CORS failure): ${el.src}`);
|
|
71261
71275
|
continue;
|
|
@@ -71288,7 +71302,7 @@ ${generateStylesCss(styleMap, themeFonts)}
|
|
|
71288
71302
|
imageOptions.transparency = el.transparency;
|
|
71289
71303
|
slide.addImage(imageOptions);
|
|
71290
71304
|
} else if (el.type === "backgroundImage") {
|
|
71291
|
-
const imgSrc =
|
|
71305
|
+
const imgSrc = getCachedImageSource(el.src);
|
|
71292
71306
|
if (!imgSrc) {
|
|
71293
71307
|
console.warn(`Skipping background image (CORS failure): ${el.src}`);
|
|
71294
71308
|
continue;
|
|
@@ -71705,16 +71719,17 @@ ${generateStylesCss(styleMap, themeFonts)}
|
|
|
71705
71719
|
resolve();
|
|
71706
71720
|
};
|
|
71707
71721
|
iframe.onload = resolveOnce;
|
|
71708
|
-
setTimeout(resolveOnce,
|
|
71722
|
+
setTimeout(resolveOnce, 1e3);
|
|
71709
71723
|
});
|
|
71710
71724
|
const doc = iframe.contentDocument || iframe.contentWindow.document;
|
|
71711
71725
|
const iframeWin = iframe.contentWindow;
|
|
71726
|
+
const waitPromises = [];
|
|
71712
71727
|
if (iframeWin && iframeWin.document.fonts && iframeWin.document.fonts.ready) {
|
|
71713
|
-
|
|
71714
|
-
iframeWin.document.fonts.ready
|
|
71715
|
-
|
|
71716
|
-
|
|
71717
|
-
]);
|
|
71728
|
+
waitPromises.push(Promise.race([
|
|
71729
|
+
iframeWin.document.fonts.ready.then(() => {
|
|
71730
|
+
}),
|
|
71731
|
+
new Promise((r) => setTimeout(r, 500))
|
|
71732
|
+
]));
|
|
71718
71733
|
}
|
|
71719
71734
|
const images = doc.querySelectorAll("img");
|
|
71720
71735
|
if (images.length > 0) {
|
|
@@ -71727,12 +71742,13 @@ ${generateStylesCss(styleMap, themeFonts)}
|
|
|
71727
71742
|
img.onerror = () => resolve();
|
|
71728
71743
|
});
|
|
71729
71744
|
});
|
|
71730
|
-
|
|
71731
|
-
Promise.all(imagePromises)
|
|
71732
|
-
|
|
71733
|
-
|
|
71734
|
-
]);
|
|
71745
|
+
waitPromises.push(Promise.race([
|
|
71746
|
+
Promise.all(imagePromises).then(() => {
|
|
71747
|
+
}),
|
|
71748
|
+
new Promise((r) => setTimeout(r, 500))
|
|
71749
|
+
]));
|
|
71735
71750
|
}
|
|
71751
|
+
await Promise.all(waitPromises);
|
|
71736
71752
|
return { iframe, doc };
|
|
71737
71753
|
}
|
|
71738
71754
|
async function addSlideFromHtml(source, pres, options = {}) {
|