19
|
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 |
/******/ } |
9
|
16 |
/******/ }; |
19
|
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 |
/******/ |
9
|
35 |
/************************************************************************/ |
19
|
36 |
var __webpack_exports__ = {}; |
9
|
37 |
__webpack_require__.r(__webpack_exports__); |
19
|
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 */ "isBlobURL": function() { return /* binding */ isBlobURL; }, |
|
43 |
/* harmony export */ "revokeBlobURL": function() { return /* binding */ revokeBlobURL; } |
|
44 |
/* harmony export */ }); |
9
|
45 |
/** |
|
46 |
* Browser dependencies |
|
47 |
*/ |
18
|
48 |
const { |
|
49 |
createObjectURL, |
|
50 |
revokeObjectURL |
|
51 |
} = window.URL; |
16
|
52 |
/** |
|
53 |
* @type {Record<string, File|undefined>} |
|
54 |
*/ |
|
55 |
|
18
|
56 |
const cache = {}; |
9
|
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) { |
18
|
66 |
const url = createObjectURL(file); |
9
|
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 |
* |
16
|
77 |
* @return {File|undefined} The file for the blob URL. |
9
|
78 |
*/ |
|
79 |
|
|
80 |
function getBlobByURL(url) { |
|
81 |
return cache[url]; |
|
82 |
} |
|
83 |
/** |
18
|
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 |
/** |
9
|
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 |
|
19
|
127 |
(window.wp = window.wp || {}).blob = __webpack_exports__; |
|
128 |
/******/ })() |
|
129 |
; |