wp/wp-includes/js/dist/blob.js
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
equal deleted inserted replaced
17:34716fd837a4 18:be944660c56a
    80 /******/ 	// __webpack_public_path__
    80 /******/ 	// __webpack_public_path__
    81 /******/ 	__webpack_require__.p = "";
    81 /******/ 	__webpack_require__.p = "";
    82 /******/
    82 /******/
    83 /******/
    83 /******/
    84 /******/ 	// Load entry module and return exports
    84 /******/ 	// Load entry module and return exports
    85 /******/ 	return __webpack_require__(__webpack_require__.s = 284);
    85 /******/ 	return __webpack_require__(__webpack_require__.s = "ca5x");
    86 /******/ })
    86 /******/ })
    87 /************************************************************************/
    87 /************************************************************************/
    88 /******/ ({
    88 /******/ ({
    89 
    89 
    90 /***/ 284:
    90 /***/ "ca5x":
    91 /***/ (function(module, __webpack_exports__, __webpack_require__) {
    91 /***/ (function(module, __webpack_exports__, __webpack_require__) {
    92 
    92 
    93 "use strict";
    93 "use strict";
    94 __webpack_require__.r(__webpack_exports__);
    94 __webpack_require__.r(__webpack_exports__);
    95 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createBlobURL", function() { return createBlobURL; });
    95 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createBlobURL", function() { return createBlobURL; });
    96 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getBlobByURL", function() { return getBlobByURL; });
    96 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getBlobByURL", function() { return getBlobByURL; });
       
    97 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getBlobTypeByURL", function() { return getBlobTypeByURL; });
    97 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "revokeBlobURL", function() { return revokeBlobURL; });
    98 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "revokeBlobURL", function() { return revokeBlobURL; });
    98 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isBlobURL", function() { return isBlobURL; });
    99 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isBlobURL", function() { return isBlobURL; });
    99 /**
   100 /**
   100  * Browser dependencies
   101  * Browser dependencies
   101  */
   102  */
   102 var _window$URL = window.URL,
   103 const {
   103     createObjectURL = _window$URL.createObjectURL,
   104   createObjectURL,
   104     revokeObjectURL = _window$URL.revokeObjectURL;
   105   revokeObjectURL
       
   106 } = window.URL;
   105 /**
   107 /**
   106  * @type {Record<string, File|undefined>}
   108  * @type {Record<string, File|undefined>}
   107  */
   109  */
   108 
   110 
   109 var cache = {};
   111 const cache = {};
   110 /**
   112 /**
   111  * Create a blob URL from a file.
   113  * Create a blob URL from a file.
   112  *
   114  *
   113  * @param {File} file The file to create a blob URL for.
   115  * @param {File} file The file to create a blob URL for.
   114  *
   116  *
   115  * @return {string} The blob URL.
   117  * @return {string} The blob URL.
   116  */
   118  */
   117 
   119 
   118 function createBlobURL(file) {
   120 function createBlobURL(file) {
   119   var url = createObjectURL(file);
   121   const url = createObjectURL(file);
   120   cache[url] = file;
   122   cache[url] = file;
   121   return url;
   123   return url;
   122 }
   124 }
   123 /**
   125 /**
   124  * Retrieve a file based on a blob URL. The file must have been created by
   126  * Retrieve a file based on a blob URL. The file must have been created by
   130  * @return {File|undefined} The file for the blob URL.
   132  * @return {File|undefined} The file for the blob URL.
   131  */
   133  */
   132 
   134 
   133 function getBlobByURL(url) {
   135 function getBlobByURL(url) {
   134   return cache[url];
   136   return cache[url];
       
   137 }
       
   138 /**
       
   139  * Retrieve a blob type based on URL. The file must have been created by
       
   140  * `createBlobURL` and not removed by `revokeBlobURL`, otherwise it will return
       
   141  * `undefined`.
       
   142  *
       
   143  * @param {string} url The blob URL.
       
   144  *
       
   145  * @return {string|undefined} The blob type.
       
   146  */
       
   147 
       
   148 function getBlobTypeByURL(url) {
       
   149   var _getBlobByURL;
       
   150 
       
   151   return (_getBlobByURL = getBlobByURL(url)) === null || _getBlobByURL === void 0 ? void 0 : _getBlobByURL.type.split('/')[0]; // 0: media type , 1: file extension eg ( type: 'image/jpeg' ).
   135 }
   152 }
   136 /**
   153 /**
   137  * Remove the resource and file cache from memory.
   154  * Remove the resource and file cache from memory.
   138  *
   155  *
   139  * @param {string} url The blob URL.
   156  * @param {string} url The blob URL.