releasebird-javascript-sdk 1.0.52 → 1.0.53
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.
|
@@ -197,12 +197,23 @@ export default class RbirdScreenshotManager {
|
|
|
197
197
|
|
|
198
198
|
}).catch((e) => {
|
|
199
199
|
console.error('[Screenshot] Normal screenshot failed:', e);
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
200
|
+
|
|
201
|
+
// Check if it's an Event (image loading error)
|
|
202
|
+
if (e instanceof Event) {
|
|
203
|
+
console.error('Error is an Event - likely image loading issue');
|
|
204
|
+
console.error('Event type:', e.type);
|
|
205
|
+
console.error('Event target:', e.target);
|
|
206
|
+
if (e.target && e.target.src) {
|
|
207
|
+
console.error('Failed to load image:', e.target.src);
|
|
208
|
+
}
|
|
209
|
+
} else {
|
|
210
|
+
// Regular error
|
|
211
|
+
console.error('Error details:', {
|
|
212
|
+
message: e?.message,
|
|
213
|
+
stack: e?.stack,
|
|
214
|
+
name: e?.name
|
|
215
|
+
});
|
|
216
|
+
}
|
|
206
217
|
|
|
207
218
|
// Fallback 1: Try again with disabled external stylesheets
|
|
208
219
|
console.log('[Screenshot] Trying again with disabled external stylesheets...');
|
|
@@ -284,6 +295,22 @@ export default class RbirdScreenshotManager {
|
|
|
284
295
|
}).catch((e2) => {
|
|
285
296
|
console.error('[Screenshot] Screenshot with disabled stylesheets also failed:', e2);
|
|
286
297
|
|
|
298
|
+
// Check if it's an Event (image loading error)
|
|
299
|
+
if (e2 instanceof Event) {
|
|
300
|
+
console.error('Error is an Event - likely image loading issue');
|
|
301
|
+
console.error('Event type:', e2.type);
|
|
302
|
+
console.error('Event target:', e2.target);
|
|
303
|
+
if (e2.target && e2.target.src) {
|
|
304
|
+
console.error('Failed to load image:', e2.target.src);
|
|
305
|
+
}
|
|
306
|
+
} else {
|
|
307
|
+
console.error('Error details:', {
|
|
308
|
+
message: e2?.message,
|
|
309
|
+
stack: e2?.stack,
|
|
310
|
+
name: e2?.name
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
|
|
287
314
|
// Re-enable external stylesheets
|
|
288
315
|
externalStylesheets.forEach(({element, disabled}) => {
|
|
289
316
|
element.disabled = disabled;
|
|
@@ -369,17 +396,34 @@ export default class RbirdScreenshotManager {
|
|
|
369
396
|
}
|
|
370
397
|
});
|
|
371
398
|
|
|
372
|
-
// Handle images with CORS
|
|
399
|
+
// Handle images with CORS - remove external images completely
|
|
373
400
|
const images = clonedDocument.querySelectorAll('img');
|
|
374
401
|
images.forEach((img) => {
|
|
375
402
|
const src = img.getAttribute('src');
|
|
376
403
|
if (src && src.startsWith('http') && !src.includes(window.location.hostname)) {
|
|
377
|
-
//
|
|
378
|
-
|
|
404
|
+
// Remove external images completely to avoid CORS errors
|
|
405
|
+
console.log('[Screenshot] Removing external image from clone:', src);
|
|
406
|
+
img.remove();
|
|
379
407
|
} else {
|
|
380
408
|
img.crossOrigin = 'anonymous';
|
|
381
409
|
}
|
|
382
410
|
});
|
|
411
|
+
|
|
412
|
+
// Also remove background images from elements
|
|
413
|
+
const allElements = clonedDocument.querySelectorAll('*');
|
|
414
|
+
allElements.forEach((element) => {
|
|
415
|
+
const bgImage = window.getComputedStyle(element).backgroundImage;
|
|
416
|
+
if (bgImage && bgImage !== 'none' && bgImage.includes('http')) {
|
|
417
|
+
const urlMatch = bgImage.match(/url\(['"]?(.*?)['"]?\)/);
|
|
418
|
+
if (urlMatch && urlMatch[1]) {
|
|
419
|
+
const bgUrl = urlMatch[1];
|
|
420
|
+
if (!bgUrl.includes(window.location.hostname)) {
|
|
421
|
+
element.style.backgroundImage = 'none';
|
|
422
|
+
console.log('[Screenshot] Removing external background image:', bgUrl);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
});
|
|
383
427
|
}
|
|
384
428
|
}).then(function (dataUrl) {
|
|
385
429
|
console.log('[Screenshot] PNG fallback succeeded!');
|
|
@@ -412,6 +456,23 @@ export default class RbirdScreenshotManager {
|
|
|
412
456
|
}).catch((fallbackError) => {
|
|
413
457
|
console.error('[Screenshot] PNG fallback also failed:', fallbackError);
|
|
414
458
|
|
|
459
|
+
// Check if it's an Event (image loading error)
|
|
460
|
+
if (fallbackError instanceof Event) {
|
|
461
|
+
console.error('Final error is an Event - image loading issue');
|
|
462
|
+
console.error('Event type:', fallbackError.type);
|
|
463
|
+
console.error('Event target:', fallbackError.target);
|
|
464
|
+
if (fallbackError.target && fallbackError.target.src) {
|
|
465
|
+
console.error('Failed to load image:', fallbackError.target.src);
|
|
466
|
+
}
|
|
467
|
+
console.error('This is likely due to external images with CORS restrictions');
|
|
468
|
+
} else {
|
|
469
|
+
console.error('Final error details:', {
|
|
470
|
+
message: fallbackError?.message,
|
|
471
|
+
stack: fallbackError?.stack,
|
|
472
|
+
name: fallbackError?.name
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
|
|
415
476
|
// Re-enable external stylesheets
|
|
416
477
|
externalStylesheets2.forEach(({element, disabled}) => {
|
|
417
478
|
element.disabled = disabled;
|
|
@@ -427,13 +488,7 @@ export default class RbirdScreenshotManager {
|
|
|
427
488
|
}
|
|
428
489
|
that.hideLoader();
|
|
429
490
|
console.error('Screenshot failed with all methods');
|
|
430
|
-
|
|
431
|
-
type: fallbackError?.type,
|
|
432
|
-
target: fallbackError?.target,
|
|
433
|
-
message: fallbackError?.message,
|
|
434
|
-
stack: fallbackError?.stack
|
|
435
|
-
});
|
|
436
|
-
alert('Screenshot failed. This page has external resources that prevent screenshots from being captured. Please try on a different page or contact support.');
|
|
491
|
+
alert('Screenshot could not be created due to external images with CORS restrictions. Please try on a different page or contact support if this issue persists.');
|
|
437
492
|
});
|
|
438
493
|
});
|
|
439
494
|
});
|