PluginProbe
Gutenberg / 24.0.0
Gutenberg v24.0.0
24.0.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 All 403 releases
gutenberg / build / scripts / blob / index.js

index.js in Gutenberg 24.0.0, at build/scripts/blob/index.js

77 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 })();
76 //# sourceMappingURL=index.js.map
77