image-exporter 1.2.1 → 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 +4 -5
- package/dist/index.cjs +19 -131
- package/dist/index.cjs.map +4 -5
- package/dist/index.js +19 -131
- package/dist/index.js.map +4 -5
- package/package.json +1 -3
package/dist/index.js
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((exports, module) => {
|
|
46
|
-
(function(root, factory) {
|
|
47
|
-
if (typeof define === "function" && define.amd) {
|
|
48
|
-
define([], factory);
|
|
49
|
-
} else if (typeof exports === "object") {
|
|
50
|
-
module.exports = factory();
|
|
51
|
-
} else {
|
|
52
|
-
root.download = factory();
|
|
53
|
-
}
|
|
54
|
-
})(exports, 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 };
|
|
@@ -14413,7 +14289,6 @@ var filter = (node) => {
|
|
|
14413
14289
|
};
|
|
14414
14290
|
|
|
14415
14291
|
// src/capture/download-images.ts
|
|
14416
|
-
var import_downloadjs = __toESM(require_download(), 1);
|
|
14417
14292
|
var import_jszip = __toESM(require_lib(), 1);
|
|
14418
14293
|
|
|
14419
14294
|
// src/config.ts
|
|
@@ -14440,11 +14315,24 @@ async function downloadImages(images, userConfig = defaultConfig) {
|
|
|
14440
14315
|
const uniqueImages = ensureUniqueFileNames(images);
|
|
14441
14316
|
if (uniqueImages.length === 1) {
|
|
14442
14317
|
const image = uniqueImages[0];
|
|
14443
|
-
|
|
14318
|
+
triggerDownload(image.dataURL, image.fileName);
|
|
14444
14319
|
} else if (uniqueImages.length > 1) {
|
|
14445
14320
|
const imagesBlob = await zipUpImages(uniqueImages);
|
|
14446
14321
|
if (imagesBlob)
|
|
14447
|
-
|
|
14322
|
+
triggerDownload(imagesBlob, parseLabel(config));
|
|
14323
|
+
}
|
|
14324
|
+
}
|
|
14325
|
+
function triggerDownload(data, fileName) {
|
|
14326
|
+
const url = typeof data === "string" ? data : URL.createObjectURL(data);
|
|
14327
|
+
const a = document.createElement("a");
|
|
14328
|
+
a.href = url;
|
|
14329
|
+
a.download = fileName;
|
|
14330
|
+
a.style.display = "none";
|
|
14331
|
+
document.body.appendChild(a);
|
|
14332
|
+
a.click();
|
|
14333
|
+
document.body.removeChild(a);
|
|
14334
|
+
if (typeof data !== "string") {
|
|
14335
|
+
setTimeout(() => URL.revokeObjectURL(url), 250);
|
|
14448
14336
|
}
|
|
14449
14337
|
}
|
|
14450
14338
|
async function zipUpImages(images) {
|
|
@@ -14882,4 +14770,4 @@ export {
|
|
|
14882
14770
|
capture
|
|
14883
14771
|
};
|
|
14884
14772
|
|
|
14885
|
-
//# debugId=
|
|
14773
|
+
//# debugId=156298500FD95FA864756E2164756E21
|