mnfst 0.5.79 → 0.5.80

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.
@@ -241,6 +241,13 @@ function initializeExportPlugin() {
241
241
  // produce a missing image rather than rejecting the whole snapshot.
242
242
  imageTimeout: 5000,
243
243
  logging: false,
244
+ // Pin the capture origin to (0, 0) so the snapshot starts at the
245
+ // document top regardless of the user's current scroll position.
246
+ // Without this, html2canvas defaults scrollY to window.pageYOffset,
247
+ // which clips the snapshot to "below the current scroll" — anything
248
+ // above the fold renders as blank white space.
249
+ scrollX: 0,
250
+ scrollY: 0,
244
251
  };
245
252
  if (opts.backgroundColor) out.backgroundColor = opts.backgroundColor;
246
253
  if (opts.width) out.width = Number(opts.width);
@@ -248,6 +255,23 @@ function initializeExportPlugin() {
248
255
  return out;
249
256
  }
250
257
 
258
+ // Await all <img> loads inside the target so freshly-mounted images don't
259
+ // appear blank in the snapshot. Bounded by a timeout — a single slow image
260
+ // shouldn't stall the export indefinitely.
261
+ async function waitForImages(target, timeoutMs = 5000) {
262
+ if (!target || typeof target.querySelectorAll !== 'function') return;
263
+ const imgs = Array.from(target.querySelectorAll('img'));
264
+ const pending = imgs.filter((img) => !img.complete || img.naturalWidth === 0);
265
+ if (pending.length === 0) return;
266
+ await Promise.race([
267
+ Promise.all(pending.map((img) => new Promise((resolve) => {
268
+ img.addEventListener('load', resolve, { once: true });
269
+ img.addEventListener('error', resolve, { once: true });
270
+ }))),
271
+ new Promise((resolve) => setTimeout(resolve, timeoutMs)),
272
+ ]);
273
+ }
274
+
251
275
  // html2canvas-pro paints directly to canvas via computed styles, so the
252
276
  // SVG-foreignObject failure modes (oversized SVGs, @layer/oklch parsing
253
277
  // issues) don't apply. The fallback path is retained for the rare case
@@ -270,6 +294,7 @@ function initializeExportPlugin() {
270
294
  if ((ext === 'jpeg' || ext === 'webp') && !so.backgroundColor) {
271
295
  so.backgroundColor = effectivePageBackground();
272
296
  }
297
+ await waitForImages(target);
273
298
  const canvas = await snapshotToCanvas(lib, target, so);
274
299
  const quality = Number(opts.quality) > 0 && Number(opts.quality) <= 1
275
300
  ? Number(opts.quality)
@@ -295,6 +320,7 @@ function initializeExportPlugin() {
295
320
  const target = resolveTarget(opts);
296
321
  const so = snapshotOptions(opts);
297
322
  if (!so.backgroundColor) so.backgroundColor = effectivePageBackground();
323
+ await waitForImages(target);
298
324
  const canvas = await snapshotToCanvas(imgLib, target, so);
299
325
  const dataUrl = canvas.toDataURL('image/png');
300
326
  const img = await loadImage(dataUrl);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mnfst",
3
- "version": "0.5.79",
3
+ "version": "0.5.80",
4
4
  "private": false,
5
5
  "workspaces": [
6
6
  "templates/starter",