PluginProbe
Gutenberg / 12.1.0
Gutenberg v12.1.0
23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 7.4.0 All 402 releases
gutenberg / build / blob / index.js

index.js in Gutenberg 12.1.0, at build/blob/index.js

129 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (function() { // webpackBootstrap
2 /******/ "use strict";
3 /******/ // The require scope
4 /******/ var __webpack_require__ = {};
5 /******/
6 /************************************************************************/
7 /******/ /* webpack/runtime/define property getters */
8 /******/ !function() {
9 /******/ // define getter functions for harmony exports
10 /******/ __webpack_require__.d = function(exports, definition) {
11 /******/ for(var key in definition) {
12 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
13 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
14 /******/ }
15 /******/ }
16 /******/ };
17 /******/ }();
18 /******/
19 /******/ /* webpack/runtime/hasOwnProperty shorthand */
20 /******/ !function() {
21 /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
22 /******/ }();
23 /******/
24 /******/ /* webpack/runtime/make namespace object */
25 /******/ !function() {
26 /******/ // define __esModule on exports
27 /******/ __webpack_require__.r = function(exports) {
28 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
29 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
30 /******/ }
31 /******/ Object.defineProperty(exports, '__esModule', { value: true });
32 /******/ };
33 /******/ }();
34 /******/
35 /************************************************************************/
36 var __webpack_exports__ = {};
37 __webpack_require__.r(__webpack_exports__);
38 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
39 /* harmony export */ "createBlobURL": function() { return /* binding */ createBlobURL; },
40 /* harmony export */ "getBlobByURL": function() { return /* binding */ getBlobByURL; },
41 /* harmony export */ "getBlobTypeByURL": function() { return /* binding */ getBlobTypeByURL; },
42 /* harmony export */ "revokeBlobURL": function() { return /* binding */ revokeBlobURL; },
43 /* harmony export */ "isBlobURL": function() { return /* binding */ isBlobURL; }
44 /* harmony export */ });
45 /**
46 * Browser dependencies
47 */
48 const {
49 createObjectURL,
50 revokeObjectURL
51 } = window.URL;
52 /**
53 * @type {Record<string, File|undefined>}
54 */
55
56 const cache = {};
57 /**
58 * Create a blob URL from a file.
59 *
60 * @param {File} file The file to create a blob URL for.
61 *
62 * @return {string} The blob URL.
63 */
64
65 function createBlobURL(file) {
66 const url = createObjectURL(file);
67 cache[url] = file;
68 return url;
69 }
70 /**
71 * Retrieve a file based on a blob URL. The file must have been created by
72 * `createBlobURL` and not removed by `revokeBlobURL`, otherwise it will return
73 * `undefined`.
74 *
75 * @param {string} url The blob URL.
76 *
77 * @return {File|undefined} The file for the blob URL.
78 */
79
80 function getBlobByURL(url) {
81 return cache[url];
82 }
83 /**
84 * Retrieve a blob type based on URL. The file must have been created by
85 * `createBlobURL` and not removed by `revokeBlobURL`, otherwise it will return
86 * `undefined`.
87 *
88 * @param {string} url The blob URL.
89 *
90 * @return {string|undefined} The blob type.
91 */
92
93 function getBlobTypeByURL(url) {
94 var _getBlobByURL;
95
96 return (_getBlobByURL = getBlobByURL(url)) === null || _getBlobByURL === void 0 ? void 0 : _getBlobByURL.type.split('/')[0]; // 0: media type , 1: file extension eg ( type: 'image/jpeg' ).
97 }
98 /**
99 * Remove the resource and file cache from memory.
100 *
101 * @param {string} url The blob URL.
102 */
103
104 function revokeBlobURL(url) {
105 if (cache[url]) {
106 revokeObjectURL(url);
107 }
108
109 delete cache[url];
110 }
111 /**
112 * Check whether a url is a blob url.
113 *
114 * @param {string} url The URL.
115 *
116 * @return {boolean} Is the url a blob url?
117 */
118
119 function isBlobURL(url) {
120 if (!url || !url.indexOf) {
121 return false;
122 }
123
124 return url.indexOf('blob:') === 0;
125 }
126 //# sourceMappingURL=index.js.map
127 (window.wp = window.wp || {}).blob = __webpack_exports__;
128 /******/ })()
129 ;