image-exporter 1.2.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -2
- package/dist/capture/download-images.d.ts.map +1 -1
- package/dist/index.browser.js +21 -23
- package/dist/index.browser.js.map +6 -7
- package/dist/index.cjs +36 -132
- package/dist/index.cjs.map +6 -7
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -132
- package/dist/index.js.map +6 -7
- package/package.json +1 -3
package/dist/index.cjs
CHANGED
|
@@ -41,130 +41,6 @@ var __export = (target, all) => {
|
|
|
41
41
|
};
|
|
42
42
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
43
43
|
|
|
44
|
-
// node_modules/downloadjs/download.js
|
|
45
|
-
var require_download = __commonJS((exports2, module2) => {
|
|
46
|
-
(function(root, factory) {
|
|
47
|
-
if (typeof define === "function" && define.amd) {
|
|
48
|
-
define([], factory);
|
|
49
|
-
} else if (typeof exports2 === "object") {
|
|
50
|
-
module2.exports = factory();
|
|
51
|
-
} else {
|
|
52
|
-
root.download = factory();
|
|
53
|
-
}
|
|
54
|
-
})(exports2, function() {
|
|
55
|
-
return function download(data, strFileName, strMimeType) {
|
|
56
|
-
var self2 = window, defaultMime = "application/octet-stream", mimeType = strMimeType || defaultMime, payload = data, url = !strFileName && !strMimeType && payload, anchor = document.createElement("a"), toString = function(a) {
|
|
57
|
-
return String(a);
|
|
58
|
-
}, myBlob = self2.Blob || self2.MozBlob || self2.WebKitBlob || toString, fileName = strFileName || "download", blob, reader;
|
|
59
|
-
myBlob = myBlob.call ? myBlob.bind(self2) : Blob;
|
|
60
|
-
if (String(this) === "true") {
|
|
61
|
-
payload = [payload, mimeType];
|
|
62
|
-
mimeType = payload[0];
|
|
63
|
-
payload = payload[1];
|
|
64
|
-
}
|
|
65
|
-
if (url && url.length < 2048) {
|
|
66
|
-
fileName = url.split("/").pop().split("?")[0];
|
|
67
|
-
anchor.href = url;
|
|
68
|
-
if (anchor.href.indexOf(url) !== -1) {
|
|
69
|
-
var ajax = new XMLHttpRequest;
|
|
70
|
-
ajax.open("GET", url, true);
|
|
71
|
-
ajax.responseType = "blob";
|
|
72
|
-
ajax.onload = function(e) {
|
|
73
|
-
download(e.target.response, fileName, defaultMime);
|
|
74
|
-
};
|
|
75
|
-
setTimeout(function() {
|
|
76
|
-
ajax.send();
|
|
77
|
-
}, 0);
|
|
78
|
-
return ajax;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
if (/^data:([\w+-]+\/[\w+.-]+)?[,;]/.test(payload)) {
|
|
82
|
-
if (payload.length > 1024 * 1024 * 1.999 && myBlob !== toString) {
|
|
83
|
-
payload = dataUrlToBlob(payload);
|
|
84
|
-
mimeType = payload.type || defaultMime;
|
|
85
|
-
} else {
|
|
86
|
-
return navigator.msSaveBlob ? navigator.msSaveBlob(dataUrlToBlob(payload), fileName) : saver(payload);
|
|
87
|
-
}
|
|
88
|
-
} else {
|
|
89
|
-
if (/([\x80-\xff])/.test(payload)) {
|
|
90
|
-
var i = 0, tempUiArr = new Uint8Array(payload.length), mx = tempUiArr.length;
|
|
91
|
-
for (i;i < mx; ++i)
|
|
92
|
-
tempUiArr[i] = payload.charCodeAt(i);
|
|
93
|
-
payload = new myBlob([tempUiArr], { type: mimeType });
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
blob = payload instanceof myBlob ? payload : new myBlob([payload], { type: mimeType });
|
|
97
|
-
function dataUrlToBlob(strUrl) {
|
|
98
|
-
var parts = strUrl.split(/[:;,]/), type = parts[1], decoder = parts[2] == "base64" ? atob : decodeURIComponent, binData = decoder(parts.pop()), mx2 = binData.length, i2 = 0, uiArr = new Uint8Array(mx2);
|
|
99
|
-
for (i2;i2 < mx2; ++i2)
|
|
100
|
-
uiArr[i2] = binData.charCodeAt(i2);
|
|
101
|
-
return new myBlob([uiArr], { type });
|
|
102
|
-
}
|
|
103
|
-
function saver(url2, winMode) {
|
|
104
|
-
if ("download" in anchor) {
|
|
105
|
-
anchor.href = url2;
|
|
106
|
-
anchor.setAttribute("download", fileName);
|
|
107
|
-
anchor.className = "download-js-link";
|
|
108
|
-
anchor.innerHTML = "downloading...";
|
|
109
|
-
anchor.style.display = "none";
|
|
110
|
-
document.body.appendChild(anchor);
|
|
111
|
-
setTimeout(function() {
|
|
112
|
-
anchor.click();
|
|
113
|
-
document.body.removeChild(anchor);
|
|
114
|
-
if (winMode === true) {
|
|
115
|
-
setTimeout(function() {
|
|
116
|
-
self2.URL.revokeObjectURL(anchor.href);
|
|
117
|
-
}, 250);
|
|
118
|
-
}
|
|
119
|
-
}, 66);
|
|
120
|
-
return true;
|
|
121
|
-
}
|
|
122
|
-
if (/(Version)\/(\d+)\.(\d+)(?:\.(\d+))?.*Safari\//.test(navigator.userAgent)) {
|
|
123
|
-
if (/^data:/.test(url2))
|
|
124
|
-
url2 = "data:" + url2.replace(/^data:([\w\/\-\+]+)/, defaultMime);
|
|
125
|
-
if (!window.open(url2)) {
|
|
126
|
-
if (confirm(`Displaying New Document
|
|
127
|
-
|
|
128
|
-
Use Save As... to download, then click back to return to this page.`)) {
|
|
129
|
-
location.href = url2;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
return true;
|
|
133
|
-
}
|
|
134
|
-
var f = document.createElement("iframe");
|
|
135
|
-
document.body.appendChild(f);
|
|
136
|
-
if (!winMode && /^data:/.test(url2)) {
|
|
137
|
-
url2 = "data:" + url2.replace(/^data:([\w\/\-\+]+)/, defaultMime);
|
|
138
|
-
}
|
|
139
|
-
f.src = url2;
|
|
140
|
-
setTimeout(function() {
|
|
141
|
-
document.body.removeChild(f);
|
|
142
|
-
}, 333);
|
|
143
|
-
}
|
|
144
|
-
if (navigator.msSaveBlob) {
|
|
145
|
-
return navigator.msSaveBlob(blob, fileName);
|
|
146
|
-
}
|
|
147
|
-
if (self2.URL) {
|
|
148
|
-
saver(self2.URL.createObjectURL(blob), true);
|
|
149
|
-
} else {
|
|
150
|
-
if (typeof blob === "string" || blob.constructor === toString) {
|
|
151
|
-
try {
|
|
152
|
-
return saver("data:" + mimeType + ";base64," + self2.btoa(blob));
|
|
153
|
-
} catch (y) {
|
|
154
|
-
return saver("data:" + mimeType + "," + encodeURIComponent(blob));
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
reader = new FileReader;
|
|
158
|
-
reader.onload = function(e) {
|
|
159
|
-
saver(this.result);
|
|
160
|
-
};
|
|
161
|
-
reader.readAsDataURL(blob);
|
|
162
|
-
}
|
|
163
|
-
return true;
|
|
164
|
-
};
|
|
165
|
-
});
|
|
166
|
-
});
|
|
167
|
-
|
|
168
44
|
// node:buffer
|
|
169
45
|
var exports_buffer = {};
|
|
170
46
|
__export(exports_buffer, {
|
|
@@ -177,7 +53,7 @@ __export(exports_buffer, {
|
|
|
177
53
|
default: () => buffer_default,
|
|
178
54
|
constants: () => constants,
|
|
179
55
|
btoa: () => btoa,
|
|
180
|
-
atob: () =>
|
|
56
|
+
atob: () => atob,
|
|
181
57
|
INSPECT_MAX_BYTES: () => INSPECT_MAX_BYTES,
|
|
182
58
|
File: () => File,
|
|
183
59
|
Buffer: () => Buffer2,
|
|
@@ -850,7 +726,7 @@ function notimpl(name) {
|
|
|
850
726
|
throw Error(name + " is not implemented for node:buffer browser polyfill");
|
|
851
727
|
};
|
|
852
728
|
}
|
|
853
|
-
var lookup, revLookup, code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", i, len, customInspectSymbol, INSPECT_MAX_BYTES = 50, kMaxLength = 2147483647, kStringMaxLength = 536870888, btoa,
|
|
729
|
+
var lookup, revLookup, code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", i, len, customInspectSymbol, INSPECT_MAX_BYTES = 50, kMaxLength = 2147483647, kStringMaxLength = 536870888, btoa, atob, File, Blob2, constants, ERR_BUFFER_OUT_OF_BOUNDS, ERR_INVALID_ARG_TYPE, ERR_OUT_OF_RANGE, MAX_ARGUMENTS_LENGTH = 4096, INVALID_BASE64_RE, hexSliceLookupTable, resolveObjectURL, isUtf8, isAscii = (str) => {
|
|
854
730
|
for (let char of str)
|
|
855
731
|
if (char.charCodeAt(0) > 127)
|
|
856
732
|
return false;
|
|
@@ -865,7 +741,7 @@ var init_buffer = __esm(() => {
|
|
|
865
741
|
revLookup[95] = 63;
|
|
866
742
|
customInspectSymbol = typeof Symbol === "function" && typeof Symbol.for === "function" ? Symbol.for("nodejs.util.inspect.custom") : null;
|
|
867
743
|
btoa = globalThis.btoa;
|
|
868
|
-
|
|
744
|
+
atob = globalThis.atob;
|
|
869
745
|
File = globalThis.File;
|
|
870
746
|
Blob2 = globalThis.Blob;
|
|
871
747
|
constants = { MAX_LENGTH: kMaxLength, MAX_STRING_LENGTH: kStringMaxLength };
|
|
@@ -12985,6 +12861,7 @@ var IN_FIREFOX = USER_AGENT.includes("Firefox");
|
|
|
12985
12861
|
var isContext = (value) => value && ("__CONTEXT__" in value);
|
|
12986
12862
|
var isCssFontFaceRule = (rule) => rule.constructor.name === "CSSFontFaceRule";
|
|
12987
12863
|
var isCSSImportRule = (rule) => rule.constructor.name === "CSSImportRule";
|
|
12864
|
+
var isLayerBlockRule = (rule) => rule.constructor.name === "CSSLayerBlockRule";
|
|
12988
12865
|
var isElementNode = (node) => node.nodeType === 1;
|
|
12989
12866
|
var isSVGElementNode = (node) => typeof node.className === "object";
|
|
12990
12867
|
var isSVGImageElementNode = (node) => node.tagName === "image";
|
|
@@ -14146,7 +14023,10 @@ async function embedWebFont(clone, context) {
|
|
|
14146
14023
|
}
|
|
14147
14024
|
});
|
|
14148
14025
|
}));
|
|
14149
|
-
const cssRules =
|
|
14026
|
+
const cssRules = [];
|
|
14027
|
+
styleSheets.forEach((sheet) => {
|
|
14028
|
+
unwrapCssLayers(sheet.cssRules, cssRules);
|
|
14029
|
+
});
|
|
14150
14030
|
cssRules.filter((cssRule) => isCssFontFaceRule(cssRule) && hasCssUrl(cssRule.style.getPropertyValue("src")) && splitFontFamily(cssRule.style.getPropertyValue("font-family"))?.some((val) => fontFamilies.has(val))).forEach((value) => {
|
|
14151
14031
|
const rule = value;
|
|
14152
14032
|
const cssText = fontCssTexts.get(rule.cssText);
|
|
@@ -14211,6 +14091,18 @@ function filterPreferredFormat(str, context) {
|
|
|
14211
14091
|
}
|
|
14212
14092
|
}) : str;
|
|
14213
14093
|
}
|
|
14094
|
+
function unwrapCssLayers(rules, out = []) {
|
|
14095
|
+
for (const rule of Array.from(rules)) {
|
|
14096
|
+
if (isLayerBlockRule(rule)) {
|
|
14097
|
+
out.push(...unwrapCssLayers(rule.cssRules));
|
|
14098
|
+
} else if ("cssRules" in rule) {
|
|
14099
|
+
unwrapCssLayers(rule.cssRules, out);
|
|
14100
|
+
} else {
|
|
14101
|
+
out.push(rule);
|
|
14102
|
+
}
|
|
14103
|
+
}
|
|
14104
|
+
return out;
|
|
14105
|
+
}
|
|
14214
14106
|
async function domToForeignObjectSvg(node, options) {
|
|
14215
14107
|
const context = await orCreateContext(node, options);
|
|
14216
14108
|
if (isElementNode(context.node) && isSVGElementNode(context.node))
|
|
@@ -14410,7 +14302,6 @@ var filter = (node) => {
|
|
|
14410
14302
|
};
|
|
14411
14303
|
|
|
14412
14304
|
// src/capture/download-images.ts
|
|
14413
|
-
var import_downloadjs = __toESM(require_download(), 1);
|
|
14414
14305
|
var import_jszip = __toESM(require_lib(), 1);
|
|
14415
14306
|
|
|
14416
14307
|
// src/config.ts
|
|
@@ -14437,11 +14328,24 @@ async function downloadImages(images, userConfig = defaultConfig) {
|
|
|
14437
14328
|
const uniqueImages = ensureUniqueFileNames(images);
|
|
14438
14329
|
if (uniqueImages.length === 1) {
|
|
14439
14330
|
const image = uniqueImages[0];
|
|
14440
|
-
|
|
14331
|
+
triggerDownload(image.dataURL, image.fileName);
|
|
14441
14332
|
} else if (uniqueImages.length > 1) {
|
|
14442
14333
|
const imagesBlob = await zipUpImages(uniqueImages);
|
|
14443
14334
|
if (imagesBlob)
|
|
14444
|
-
|
|
14335
|
+
triggerDownload(imagesBlob, parseLabel(config));
|
|
14336
|
+
}
|
|
14337
|
+
}
|
|
14338
|
+
function triggerDownload(data, fileName) {
|
|
14339
|
+
const url = typeof data === "string" ? data : URL.createObjectURL(data);
|
|
14340
|
+
const a = document.createElement("a");
|
|
14341
|
+
a.href = url;
|
|
14342
|
+
a.download = fileName;
|
|
14343
|
+
a.style.display = "none";
|
|
14344
|
+
document.body.appendChild(a);
|
|
14345
|
+
a.click();
|
|
14346
|
+
document.body.removeChild(a);
|
|
14347
|
+
if (typeof data !== "string") {
|
|
14348
|
+
setTimeout(() => URL.revokeObjectURL(url), 250);
|
|
14445
14349
|
}
|
|
14446
14350
|
}
|
|
14447
14351
|
async function zipUpImages(images) {
|
|
@@ -14875,4 +14779,4 @@ if (typeof window !== "undefined") {
|
|
|
14875
14779
|
window.imageExporterDownload = downloadImages;
|
|
14876
14780
|
}
|
|
14877
14781
|
|
|
14878
|
-
//# debugId=
|
|
14782
|
+
//# debugId=28EE3D9412C9BAAF64756E2164756E21
|