@mushi-mushi/web 1.30.0 → 1.31.1

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/headless.js CHANGED
@@ -348,7 +348,7 @@ function createScreenshotCapture(options = {}) {
348
348
  try {
349
349
  if (typeof document === "undefined") return null;
350
350
  const canvas = document.createElement("canvas");
351
- const ctx = canvas.getContext("2d");
351
+ const ctx = canvas.getContext("2d", { willReadFrequently: true });
352
352
  if (!ctx) {
353
353
  activeOptions.onFailed?.("unsupported");
354
354
  emitScreenshotFailed("unsupported");
@@ -433,6 +433,8 @@ function buildPrivacySafeDocument(privacy) {
433
433
  clone.querySelector("#mushi-mushi-widget")?.remove();
434
434
  stripTaintSources(clone);
435
435
  inlineDocumentStyles(clone);
436
+ freezeMotion(clone);
437
+ fillViewport(clone);
436
438
  const redactSelectors = [
437
439
  ALWAYS_REDACT_SELECTORS,
438
440
  ...privacy?.redactSelectors ?? DEFAULT_REDACT_SELECTORS
@@ -522,6 +524,20 @@ function inlineDocumentStyles(clone) {
522
524
  styleEl.textContent = css;
523
525
  (clone.querySelector("head") ?? clone).appendChild(styleEl);
524
526
  }
527
+ var FREEZE_MOTION_CSS = "*,*::before,*::after{animation:none!important;transition:none!important}";
528
+ function fillViewport(clone) {
529
+ const clear = (c) => !c || c === "transparent" || /^rgba\(.*,\s*0\)$/.test(c);
530
+ let bg = getComputedStyle(document.documentElement).backgroundColor;
531
+ if (clear(bg) && document.body) bg = getComputedStyle(document.body).backgroundColor;
532
+ const root = clone;
533
+ root.style.setProperty("background-color", clear(bg) ? "Canvas" : bg);
534
+ root.style.setProperty("min-height", `${window.innerHeight}px`);
535
+ }
536
+ function freezeMotion(clone) {
537
+ const styleEl = document.createElement("style");
538
+ styleEl.textContent = FREEZE_MOTION_CSS;
539
+ (clone.querySelector("head") ?? clone).appendChild(styleEl);
540
+ }
525
541
  function serializeSheet(sheet) {
526
542
  let rules;
527
543
  try {