CoreFiles by mySites.guru
view.js44 lines, 1,111 bytes, from wordpress-7.0.zip
Raw History Compare with 6.9.12
md5
9e28fb5c1cd82acc86a687ffd20b526a
sha1
0cb5c710dbce84e71ba71a9324f20752d9dc35f7
sha256
faf0b6fb697caf41af713b7852309c1b75d6c69c05efecd5186295facc8ec7d5
// packages/block-library/build-module/file/view.mjs
import { store } from "@wordpress/interactivity";

// packages/block-library/build-module/file/utils/index.mjs
var browserSupportsPdfs = () => {
  if (window.navigator.pdfViewerEnabled) {
    return true;
  }
  if (window.navigator.userAgent.indexOf("Mobi") > -1) {
    return false;
  }
  if (window.navigator.userAgent.indexOf("Android") > -1) {
    return false;
  }
  if (window.navigator.userAgent.indexOf("Macintosh") > -1 && window.navigator.maxTouchPoints && window.navigator.maxTouchPoints > 2) {
    return false;
  }
  if (!!(window.ActiveXObject || "ActiveXObject" in window) && !(createActiveXObject("AcroPDF.PDF") || createActiveXObject("PDF.PdfCtrl"))) {
    return false;
  }
  return true;
};
var createActiveXObject = (type) => {
  let ax;
  try {
    ax = new window.ActiveXObject(type);
  } catch (e) {
    ax = void 0;
  }
  return ax;
};

// packages/block-library/build-module/file/view.mjs
store(
  "core/file",
  {
    state: {
      get hasPdfPreview() {
        return browserSupportsPdfs();
      }
    }
  },
  { lock: true }
);

The same content is in 19 releases, WordPress 7.0-beta4 to 7.0.9. See them all, or every version of this file.