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/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: () => atob2,
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, atob2, 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) => {
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
- atob2 = globalThis.atob;
744
+ atob = globalThis.atob;
869
745
  File = globalThis.File;
870
746
  Blob2 = globalThis.Blob;
871
747
  constants = { MAX_LENGTH: kMaxLength, MAX_STRING_LENGTH: kStringMaxLength };
@@ -14426,7 +14302,6 @@ var filter = (node) => {
14426
14302
  };
14427
14303
 
14428
14304
  // src/capture/download-images.ts
14429
- var import_downloadjs = __toESM(require_download(), 1);
14430
14305
  var import_jszip = __toESM(require_lib(), 1);
14431
14306
 
14432
14307
  // src/config.ts
@@ -14453,11 +14328,24 @@ async function downloadImages(images, userConfig = defaultConfig) {
14453
14328
  const uniqueImages = ensureUniqueFileNames(images);
14454
14329
  if (uniqueImages.length === 1) {
14455
14330
  const image = uniqueImages[0];
14456
- await import_downloadjs.default(image.dataURL, image.fileName);
14331
+ triggerDownload(image.dataURL, image.fileName);
14457
14332
  } else if (uniqueImages.length > 1) {
14458
14333
  const imagesBlob = await zipUpImages(uniqueImages);
14459
14334
  if (imagesBlob)
14460
- await import_downloadjs.default(imagesBlob, parseLabel(config));
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);
14461
14349
  }
14462
14350
  }
14463
14351
  async function zipUpImages(images) {
@@ -14891,4 +14779,4 @@ if (typeof window !== "undefined") {
14891
14779
  window.imageExporterDownload = downloadImages;
14892
14780
  }
14893
14781
 
14894
- //# debugId=26234370B1A3CB5F64756E2164756E21
14782
+ //# debugId=28EE3D9412C9BAAF64756E2164756E21