[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/js/dist/ -> blob.js (source)

   1  (function() {
   2  "use strict";
   3  var wp;
   4  (wp ||= {}).blob = (() => {
   5    var __defProp = Object.defineProperty;
   6    var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
   7    var __getOwnPropNames = Object.getOwnPropertyNames;
   8    var __hasOwnProp = Object.prototype.hasOwnProperty;
   9    var __export = (target, all) => {
  10      for (var name in all)
  11        __defProp(target, name, { get: all[name], enumerable: true });
  12    };
  13    var __copyProps = (to, from, except, desc) => {
  14      if (from && typeof from === "object" || typeof from === "function") {
  15        for (let key of __getOwnPropNames(from))
  16          if (!__hasOwnProp.call(to, key) && key !== except)
  17            __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  18      }
  19      return to;
  20    };
  21    var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  22  
  23    // packages/blob/build-module/index.mjs
  24    var index_exports = {};
  25    __export(index_exports, {
  26      createBlobURL: () => createBlobURL,
  27      downloadBlob: () => downloadBlob,
  28      getBlobByURL: () => getBlobByURL,
  29      getBlobTypeByURL: () => getBlobTypeByURL,
  30      isBlobURL: () => isBlobURL,
  31      revokeBlobURL: () => revokeBlobURL
  32    });
  33    var cache = {};
  34    function createBlobURL(file) {
  35      const url = window.URL.createObjectURL(file);
  36      cache[url] = file;
  37      return url;
  38    }
  39    function getBlobByURL(url) {
  40      return cache[url];
  41    }
  42    function getBlobTypeByURL(url) {
  43      return getBlobByURL(url)?.type.split("/")[0];
  44    }
  45    function revokeBlobURL(url) {
  46      if (cache[url]) {
  47        window.URL.revokeObjectURL(url);
  48      }
  49      delete cache[url];
  50    }
  51    function isBlobURL(url) {
  52      if (!url || !url.indexOf) {
  53        return false;
  54      }
  55      return url.indexOf("blob:") === 0;
  56    }
  57    function downloadBlob(filename, content, contentType = "") {
  58      if (!filename || !content) {
  59        return;
  60      }
  61      const file = new window.Blob([content], { type: contentType });
  62      const url = window.URL.createObjectURL(file);
  63      const anchorElement = document.createElement("a");
  64      anchorElement.href = url;
  65      anchorElement.download = filename;
  66      anchorElement.style.display = "none";
  67      document.body.appendChild(anchorElement);
  68      anchorElement.click();
  69      document.body.removeChild(anchorElement);
  70      window.URL.revokeObjectURL(url);
  71    }
  72    return __toCommonJS(index_exports);
  73  })();
  74  (window.wp ||= {}).blob = wp.blob;
  75  })();


Generated : Wed Aug 26 08:20:24 2026 Cross-referenced by PHPXref