kollapsminoriteten/wp-includes/js/dist/blob.js

89 lines
3.1 KiB
JavaScript
Raw Permalink Normal View History

2024-04-17 11:32:24 +02:00
/******/ (() => { // webpackBootstrap
2022-06-16 14:03:35 +02:00
/******/ "use strict";
/******/ // The require scope
/******/ var __webpack_require__ = {};
/******/
/************************************************************************/
/******/ /* webpack/runtime/define property getters */
2024-04-17 11:32:24 +02:00
/******/ (() => {
2022-06-16 14:03:35 +02:00
/******/ // define getter functions for harmony exports
2024-04-17 11:32:24 +02:00
/******/ __webpack_require__.d = (exports, definition) => {
2022-06-16 14:03:35 +02:00
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
2024-04-17 11:32:24 +02:00
/******/ })();
2022-06-16 14:03:35 +02:00
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
2024-04-17 11:32:24 +02:00
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ })();
2022-06-16 14:03:35 +02:00
/******/
/******/ /* webpack/runtime/make namespace object */
2024-04-17 11:32:24 +02:00
/******/ (() => {
2022-06-16 14:03:35 +02:00
/******/ // define __esModule on exports
2024-04-17 11:32:24 +02:00
/******/ __webpack_require__.r = (exports) => {
2022-06-16 14:03:35 +02:00
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
2019-11-02 10:38:58 +01:00
/******/ };
2024-04-17 11:32:24 +02:00
/******/ })();
2022-06-16 14:03:35 +02:00
/******/
2019-11-02 10:38:58 +01:00
/************************************************************************/
2022-06-16 14:03:35 +02:00
var __webpack_exports__ = {};
2019-11-02 10:38:58 +01:00
__webpack_require__.r(__webpack_exports__);
2022-06-16 14:03:35 +02:00
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
2024-04-17 11:32:24 +02:00
/* harmony export */ createBlobURL: () => (/* binding */ createBlobURL),
/* harmony export */ downloadBlob: () => (/* binding */ downloadBlob),
/* harmony export */ getBlobByURL: () => (/* binding */ getBlobByURL),
/* harmony export */ getBlobTypeByURL: () => (/* binding */ getBlobTypeByURL),
/* harmony export */ isBlobURL: () => (/* binding */ isBlobURL),
/* harmony export */ revokeBlobURL: () => (/* binding */ revokeBlobURL)
2022-06-16 14:03:35 +02:00
/* harmony export */ });
2021-07-23 11:58:50 +02:00
const cache = {};
2019-11-02 10:38:58 +01:00
function createBlobURL(file) {
2023-04-26 17:39:43 +02:00
const url = window.URL.createObjectURL(file);
2019-11-02 10:38:58 +01:00
cache[url] = file;
return url;
}
function getBlobByURL(url) {
return cache[url];
}
2020-12-10 14:06:04 +01:00
function getBlobTypeByURL(url) {
2025-12-12 13:15:55 +01:00
return getBlobByURL(url)?.type.split("/")[0];
2020-12-10 14:06:04 +01:00
}
2019-11-02 10:38:58 +01:00
function revokeBlobURL(url) {
if (cache[url]) {
2023-04-26 17:39:43 +02:00
window.URL.revokeObjectURL(url);
2019-11-02 10:38:58 +01:00
}
delete cache[url];
}
function isBlobURL(url) {
if (!url || !url.indexOf) {
return false;
}
2025-12-12 13:15:55 +01:00
return url.indexOf("blob:") === 0;
2019-11-02 10:38:58 +01:00
}
2025-12-12 13:15:55 +01:00
function downloadBlob(filename, content, contentType = "") {
2024-04-17 11:32:24 +02:00
if (!filename || !content) {
return;
}
2025-12-12 13:15:55 +01:00
const file = new window.Blob([content], { type: contentType });
2024-04-17 11:32:24 +02:00
const url = window.URL.createObjectURL(file);
2025-12-12 13:15:55 +01:00
const anchorElement = document.createElement("a");
2024-04-17 11:32:24 +02:00
anchorElement.href = url;
anchorElement.download = filename;
2025-12-12 13:15:55 +01:00
anchorElement.style.display = "none";
2024-04-17 11:32:24 +02:00
document.body.appendChild(anchorElement);
anchorElement.click();
document.body.removeChild(anchorElement);
window.URL.revokeObjectURL(url);
}
2025-12-12 13:15:55 +01:00
2022-06-16 14:03:35 +02:00
(window.wp = window.wp || {}).blob = __webpack_exports__;
/******/ })()
;