@gkd-kit/inspect 0.0.1701678184497 → 0.0.1701762114130
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/404.html +4 -4
- package/dist/assets/ActionCard.vue_vue_type_script_setup_true_lang-f4d28c47.js +10 -0
- package/dist/assets/ActionCard.vue_vue_type_script_setup_true_lang-f4d28c47.js.map +1 -0
- package/dist/assets/DevicePage-1ca1a7a5.js +4 -0
- package/dist/assets/DevicePage-1ca1a7a5.js.map +1 -0
- package/dist/assets/HomePage-fb6363af.js +10 -0
- package/dist/assets/HomePage-fb6363af.js.map +1 -0
- package/dist/assets/ImportPage-d0a52d21.js +2 -0
- package/dist/assets/ImportPage-d0a52d21.js.map +1 -0
- package/dist/assets/SnapshotPage-dc32bf1e.js +241 -0
- package/dist/assets/SnapshotPage-dc32bf1e.js.map +1 -0
- package/dist/assets/_404Page-44f14f69.js +2 -0
- package/dist/assets/_404Page-44f14f69.js.map +1 -0
- package/dist/assets/import-27273a86.js +2 -0
- package/dist/assets/import-27273a86.js.map +1 -0
- package/dist/assets/index-6fbc76b7.css +1 -0
- package/dist/assets/index-9a74ec84.js +554 -0
- package/dist/assets/index-9a74ec84.js.map +1 -0
- package/dist/assets/index-af9eb709.js +17 -0
- package/dist/assets/index-af9eb709.js.map +1 -0
- package/dist/assets/jszip.min-14bc980b.js +13 -0
- package/dist/assets/jszip.min-14bc980b.js.map +1 -0
- package/dist/assets/node-7c87a44a.js +731 -0
- package/dist/assets/node-7c87a44a.js.map +1 -0
- package/dist/assets/polyfills-e3dd7d1e.js +1 -0
- package/dist/assets/storage-25ae3853.js +330 -0
- package/dist/assets/storage-25ae3853.js.map +1 -0
- package/dist/assets/table-318c850e.js +958 -0
- package/dist/assets/table-318c850e.js.map +1 -0
- package/dist/index.html +4 -4
- package/package.json +1 -1
- package/dist/assets/ActionCard.vue_vue_type_script_setup_true_lang-bda27d9e.js +0 -1388
- package/dist/assets/DevicePage-fee3235d.js +0 -457
- package/dist/assets/HomePage-5632f622.js +0 -400
- package/dist/assets/ImportPage-21674b0a.js +0 -87
- package/dist/assets/SnapshotPage-3157f92e.js +0 -3629
- package/dist/assets/SnapshotPage-3c2cecee.css +0 -8
- package/dist/assets/_404Page-09910a83.js +0 -32
- package/dist/assets/_404Page-1bb368b2.css +0 -9
- package/dist/assets/import-1c0da893.js +0 -288
- package/dist/assets/index-235f5a3e.js +0 -21365
- package/dist/assets/index-2bb4cdf2.js +0 -9780
- package/dist/assets/index-50ce64aa.css +0 -360
- package/dist/assets/jszip.min-9f22f6d7.js +0 -2651
- package/dist/assets/node-c1756ecf.js +0 -7817
- package/dist/assets/polyfills-bdd638aa.js +0 -11381
- package/dist/assets/storage-00dd3e29.js +0 -4479
- package/dist/assets/table-ad72f278.js +0 -8763
|
@@ -1,1388 +0,0 @@
|
|
|
1
|
-
import { d as dialog, m as message, k as commonjsGlobal, l as enhanceFetch, o as obj2form, j as delay, b as githubJpgStorage, e as githubZipStorage, u as urlStorage, p as pLimit, i as screenshotStorage, a as snapshotStorage, g as githubUrlToSelfUrl } from "./storage-00dd3e29.js";
|
|
2
|
-
import { N as NInput, u as useTask, d as NIcon, b as NPopover, c as NSpace } from "./node-c1756ecf.js";
|
|
3
|
-
import { b as createVNode, ap as store, d as defineComponent, ao as useRouter, c as computed, o as openBlock, ag as createBlock, g as withCtx, f as createElementBlock, u as unref, j as NButton, m as createCommentVNode, k as createTextVNode, h as createBaseVNode } from "./index-235f5a3e.js";
|
|
4
|
-
import { J as JSZip } from "./jszip.min-9f22f6d7.js";
|
|
5
|
-
const showTextDLg = ({
|
|
6
|
-
title = `批量分享链接`,
|
|
7
|
-
content = ""
|
|
8
|
-
}) => {
|
|
9
|
-
dialog.success({
|
|
10
|
-
title,
|
|
11
|
-
style: {
|
|
12
|
-
width: `800px`
|
|
13
|
-
},
|
|
14
|
-
content() {
|
|
15
|
-
return createVNode(NInput, {
|
|
16
|
-
"type": "textarea",
|
|
17
|
-
"autosize": {
|
|
18
|
-
minRows: 8,
|
|
19
|
-
maxRows: 16
|
|
20
|
-
},
|
|
21
|
-
"inputProps": {
|
|
22
|
-
style: `white-space: nowrap;`,
|
|
23
|
-
class: `gkd_code`
|
|
24
|
-
},
|
|
25
|
-
"value": content
|
|
26
|
-
}, null);
|
|
27
|
-
},
|
|
28
|
-
positiveText: `复制`,
|
|
29
|
-
onPositiveClick() {
|
|
30
|
-
navigator.clipboard.writeText(content).then(() => {
|
|
31
|
-
message.success(`复制成功`);
|
|
32
|
-
}).catch(() => {
|
|
33
|
-
message.success(`复制失败`);
|
|
34
|
-
});
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
var FileSaver_min = { exports: {} };
|
|
40
|
-
(function(module, exports) {
|
|
41
|
-
(function(a, b) {
|
|
42
|
-
b();
|
|
43
|
-
})(commonjsGlobal, function() {
|
|
44
|
-
function b(a2, b2) {
|
|
45
|
-
return "undefined" == typeof b2 ? b2 = { autoBom: false } : "object" != typeof b2 && (console.warn("Deprecated: Expected third argument to be a object"), b2 = { autoBom: !b2 }), b2.autoBom && /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(a2.type) ? new Blob(["\uFEFF", a2], { type: a2.type }) : a2;
|
|
46
|
-
}
|
|
47
|
-
function c(a2, b2, c2) {
|
|
48
|
-
var d2 = new XMLHttpRequest();
|
|
49
|
-
d2.open("GET", a2), d2.responseType = "blob", d2.onload = function() {
|
|
50
|
-
g(d2.response, b2, c2);
|
|
51
|
-
}, d2.onerror = function() {
|
|
52
|
-
console.error("could not download file");
|
|
53
|
-
}, d2.send();
|
|
54
|
-
}
|
|
55
|
-
function d(a2) {
|
|
56
|
-
var b2 = new XMLHttpRequest();
|
|
57
|
-
b2.open("HEAD", a2, false);
|
|
58
|
-
try {
|
|
59
|
-
b2.send();
|
|
60
|
-
} catch (a3) {
|
|
61
|
-
}
|
|
62
|
-
return 200 <= b2.status && 299 >= b2.status;
|
|
63
|
-
}
|
|
64
|
-
function e(a2) {
|
|
65
|
-
try {
|
|
66
|
-
a2.dispatchEvent(new MouseEvent("click"));
|
|
67
|
-
} catch (c2) {
|
|
68
|
-
var b2 = document.createEvent("MouseEvents");
|
|
69
|
-
b2.initMouseEvent("click", true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null), a2.dispatchEvent(b2);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
var f = "object" == typeof window && window.window === window ? window : "object" == typeof self && self.self === self ? self : "object" == typeof commonjsGlobal && commonjsGlobal.global === commonjsGlobal ? commonjsGlobal : void 0, a = f.navigator && /Macintosh/.test(navigator.userAgent) && /AppleWebKit/.test(navigator.userAgent) && !/Safari/.test(navigator.userAgent), g = f.saveAs || ("object" != typeof window || window !== f ? function() {
|
|
73
|
-
} : "download" in HTMLAnchorElement.prototype && !a ? function(b2, g2, h) {
|
|
74
|
-
var i = f.URL || f.webkitURL, j = document.createElement("a");
|
|
75
|
-
g2 = g2 || b2.name || "download", j.download = g2, j.rel = "noopener", "string" == typeof b2 ? (j.href = b2, j.origin === location.origin ? e(j) : d(j.href) ? c(b2, g2, h) : e(j, j.target = "_blank")) : (j.href = i.createObjectURL(b2), setTimeout(function() {
|
|
76
|
-
i.revokeObjectURL(j.href);
|
|
77
|
-
}, 4e4), setTimeout(function() {
|
|
78
|
-
e(j);
|
|
79
|
-
}, 0));
|
|
80
|
-
} : "msSaveOrOpenBlob" in navigator ? function(f2, g2, h) {
|
|
81
|
-
if (g2 = g2 || f2.name || "download", "string" != typeof f2)
|
|
82
|
-
navigator.msSaveOrOpenBlob(b(f2, h), g2);
|
|
83
|
-
else if (d(f2))
|
|
84
|
-
c(f2, g2, h);
|
|
85
|
-
else {
|
|
86
|
-
var i = document.createElement("a");
|
|
87
|
-
i.href = f2, i.target = "_blank", setTimeout(function() {
|
|
88
|
-
e(i);
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
} : function(b2, d2, e2, g2) {
|
|
92
|
-
if (g2 = g2 || open("", "_blank"), g2 && (g2.document.title = g2.document.body.innerText = "downloading..."), "string" == typeof b2)
|
|
93
|
-
return c(b2, d2, e2);
|
|
94
|
-
var h = "application/octet-stream" === b2.type, i = /constructor/i.test(f.HTMLElement) || f.safari, j = /CriOS\/[\d]+/.test(navigator.userAgent);
|
|
95
|
-
if ((j || h && i || a) && "undefined" != typeof FileReader) {
|
|
96
|
-
var k = new FileReader();
|
|
97
|
-
k.onloadend = function() {
|
|
98
|
-
var a2 = k.result;
|
|
99
|
-
a2 = j ? a2 : a2.replace(/^data:[^;]*;/, "data:attachment/file;"), g2 ? g2.location.href = a2 : location = a2, g2 = null;
|
|
100
|
-
}, k.readAsDataURL(b2);
|
|
101
|
-
} else {
|
|
102
|
-
var l = f.URL || f.webkitURL, m = l.createObjectURL(b2);
|
|
103
|
-
g2 ? g2.location = m : location.href = m, g2 = null, setTimeout(function() {
|
|
104
|
-
l.revokeObjectURL(m);
|
|
105
|
-
}, 4e4);
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
f.saveAs = g.saveAs = g, module.exports = g;
|
|
109
|
-
});
|
|
110
|
-
})(FileSaver_min);
|
|
111
|
-
var FileSaver_minExports = FileSaver_min.exports;
|
|
112
|
-
const authenticityTokenPageUrl = `https://github.com/gkd-kit/inspect/issues/new`;
|
|
113
|
-
const repository_id = `661952005`;
|
|
114
|
-
const commonHeaders = {
|
|
115
|
-
origin: `https://github.com`,
|
|
116
|
-
referer: authenticityTokenPageUrl
|
|
117
|
-
};
|
|
118
|
-
const getCsrfToken = async () => {
|
|
119
|
-
var _a;
|
|
120
|
-
const csrfSelector = `[data-upload-policy-url="/upload/policies/assets"] input.js-data-upload-policy-url-csrf`;
|
|
121
|
-
const resp = await enhanceFetch(authenticityTokenPageUrl);
|
|
122
|
-
const responseDoc = new DOMParser().parseFromString(
|
|
123
|
-
await resp.text(),
|
|
124
|
-
"text/html"
|
|
125
|
-
);
|
|
126
|
-
const csrfToken = (_a = responseDoc.querySelector(csrfSelector)) == null ? void 0 : _a.getAttribute(`value`);
|
|
127
|
-
return csrfToken;
|
|
128
|
-
};
|
|
129
|
-
const uploadPoliciesAssets = async (bf, name, content_type) => {
|
|
130
|
-
return uploadPoliciesAssetsByExtension(bf, name, content_type);
|
|
131
|
-
};
|
|
132
|
-
const uploadPoliciesAssetsByExtension = async (bf, name, content_type) => {
|
|
133
|
-
const authenticity_token = await getCsrfToken();
|
|
134
|
-
if (!authenticity_token) {
|
|
135
|
-
store.githubErrorDlgVisible = true;
|
|
136
|
-
throw new Error(`failed get csrfToken`);
|
|
137
|
-
}
|
|
138
|
-
const policiesResp = await enhanceFetch(
|
|
139
|
-
`https://github.com/upload/policies/assets`,
|
|
140
|
-
{
|
|
141
|
-
method: `POST`,
|
|
142
|
-
body: obj2form({
|
|
143
|
-
authenticity_token,
|
|
144
|
-
content_type,
|
|
145
|
-
name,
|
|
146
|
-
size: bf.byteLength,
|
|
147
|
-
repository_id
|
|
148
|
-
}),
|
|
149
|
-
headers: commonHeaders
|
|
150
|
-
}
|
|
151
|
-
).then((r) => {
|
|
152
|
-
if (!r.ok) {
|
|
153
|
-
throw new Error(`failed upload policies assets`);
|
|
154
|
-
}
|
|
155
|
-
return r.json();
|
|
156
|
-
});
|
|
157
|
-
const s3Resp = await enhanceFetch(policiesResp.upload_url, {
|
|
158
|
-
method: `POST`,
|
|
159
|
-
body: obj2form(policiesResp.form, {
|
|
160
|
-
file: new File([bf], name, { type: content_type })
|
|
161
|
-
}),
|
|
162
|
-
headers: commonHeaders
|
|
163
|
-
});
|
|
164
|
-
if (!s3Resp.ok) {
|
|
165
|
-
throw new Error(`upload s3 failed`);
|
|
166
|
-
}
|
|
167
|
-
const assetsResp = await enhanceFetch(
|
|
168
|
-
new URL(policiesResp.asset_upload_url, `https://github.com/`).href,
|
|
169
|
-
{
|
|
170
|
-
method: `PUT`,
|
|
171
|
-
body: obj2form({
|
|
172
|
-
authenticity_token: policiesResp.asset_upload_authenticity_token
|
|
173
|
-
}),
|
|
174
|
-
headers: {
|
|
175
|
-
...commonHeaders,
|
|
176
|
-
// api must add `Accept` request headers
|
|
177
|
-
Accept: `application/json`
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
);
|
|
181
|
-
if (assetsResp.status != 200) {
|
|
182
|
-
throw new Error(`failed check authenticity upload`);
|
|
183
|
-
}
|
|
184
|
-
return policiesResp.asset;
|
|
185
|
-
};
|
|
186
|
-
/*!
|
|
187
|
-
* Compressor.js v1.2.1
|
|
188
|
-
* https://fengyuanchen.github.io/compressorjs
|
|
189
|
-
*
|
|
190
|
-
* Copyright 2018-present Chen Fengyuan
|
|
191
|
-
* Released under the MIT license
|
|
192
|
-
*
|
|
193
|
-
* Date: 2023-02-28T14:09:41.732Z
|
|
194
|
-
*/
|
|
195
|
-
function ownKeys(object, enumerableOnly) {
|
|
196
|
-
var keys = Object.keys(object);
|
|
197
|
-
if (Object.getOwnPropertySymbols) {
|
|
198
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
199
|
-
enumerableOnly && (symbols = symbols.filter(function(sym) {
|
|
200
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
201
|
-
})), keys.push.apply(keys, symbols);
|
|
202
|
-
}
|
|
203
|
-
return keys;
|
|
204
|
-
}
|
|
205
|
-
function _objectSpread2(target) {
|
|
206
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
207
|
-
var source = null != arguments[i] ? arguments[i] : {};
|
|
208
|
-
i % 2 ? ownKeys(Object(source), true).forEach(function(key) {
|
|
209
|
-
_defineProperty(target, key, source[key]);
|
|
210
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
|
211
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
return target;
|
|
215
|
-
}
|
|
216
|
-
function _classCallCheck(instance, Constructor) {
|
|
217
|
-
if (!(instance instanceof Constructor)) {
|
|
218
|
-
throw new TypeError("Cannot call a class as a function");
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
function _defineProperties(target, props) {
|
|
222
|
-
for (var i = 0; i < props.length; i++) {
|
|
223
|
-
var descriptor = props[i];
|
|
224
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
225
|
-
descriptor.configurable = true;
|
|
226
|
-
if ("value" in descriptor)
|
|
227
|
-
descriptor.writable = true;
|
|
228
|
-
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
232
|
-
if (protoProps)
|
|
233
|
-
_defineProperties(Constructor.prototype, protoProps);
|
|
234
|
-
if (staticProps)
|
|
235
|
-
_defineProperties(Constructor, staticProps);
|
|
236
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
237
|
-
writable: false
|
|
238
|
-
});
|
|
239
|
-
return Constructor;
|
|
240
|
-
}
|
|
241
|
-
function _defineProperty(obj, key, value) {
|
|
242
|
-
key = _toPropertyKey(key);
|
|
243
|
-
if (key in obj) {
|
|
244
|
-
Object.defineProperty(obj, key, {
|
|
245
|
-
value,
|
|
246
|
-
enumerable: true,
|
|
247
|
-
configurable: true,
|
|
248
|
-
writable: true
|
|
249
|
-
});
|
|
250
|
-
} else {
|
|
251
|
-
obj[key] = value;
|
|
252
|
-
}
|
|
253
|
-
return obj;
|
|
254
|
-
}
|
|
255
|
-
function _extends() {
|
|
256
|
-
_extends = Object.assign ? Object.assign.bind() : function(target) {
|
|
257
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
258
|
-
var source = arguments[i];
|
|
259
|
-
for (var key in source) {
|
|
260
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
261
|
-
target[key] = source[key];
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
return target;
|
|
266
|
-
};
|
|
267
|
-
return _extends.apply(this, arguments);
|
|
268
|
-
}
|
|
269
|
-
function _toPrimitive(input, hint) {
|
|
270
|
-
if (typeof input !== "object" || input === null)
|
|
271
|
-
return input;
|
|
272
|
-
var prim = input[Symbol.toPrimitive];
|
|
273
|
-
if (prim !== void 0) {
|
|
274
|
-
var res = prim.call(input, hint || "default");
|
|
275
|
-
if (typeof res !== "object")
|
|
276
|
-
return res;
|
|
277
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
278
|
-
}
|
|
279
|
-
return (hint === "string" ? String : Number)(input);
|
|
280
|
-
}
|
|
281
|
-
function _toPropertyKey(arg) {
|
|
282
|
-
var key = _toPrimitive(arg, "string");
|
|
283
|
-
return typeof key === "symbol" ? key : String(key);
|
|
284
|
-
}
|
|
285
|
-
var canvasToBlob = { exports: {} };
|
|
286
|
-
(function(module) {
|
|
287
|
-
if (typeof window === "undefined") {
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
290
|
-
(function(window2) {
|
|
291
|
-
var CanvasPrototype = window2.HTMLCanvasElement && window2.HTMLCanvasElement.prototype;
|
|
292
|
-
var hasBlobConstructor = window2.Blob && function() {
|
|
293
|
-
try {
|
|
294
|
-
return Boolean(new Blob());
|
|
295
|
-
} catch (e) {
|
|
296
|
-
return false;
|
|
297
|
-
}
|
|
298
|
-
}();
|
|
299
|
-
var hasArrayBufferViewSupport = hasBlobConstructor && window2.Uint8Array && function() {
|
|
300
|
-
try {
|
|
301
|
-
return new Blob([new Uint8Array(100)]).size === 100;
|
|
302
|
-
} catch (e) {
|
|
303
|
-
return false;
|
|
304
|
-
}
|
|
305
|
-
}();
|
|
306
|
-
var BlobBuilder = window2.BlobBuilder || window2.WebKitBlobBuilder || window2.MozBlobBuilder || window2.MSBlobBuilder;
|
|
307
|
-
var dataURIPattern = /^data:((.*?)(;charset=.*?)?)(;base64)?,/;
|
|
308
|
-
var dataURLtoBlob = (hasBlobConstructor || BlobBuilder) && window2.atob && window2.ArrayBuffer && window2.Uint8Array && function(dataURI) {
|
|
309
|
-
var matches, mediaType, isBase64, dataString, byteString, arrayBuffer, intArray, i, bb;
|
|
310
|
-
matches = dataURI.match(dataURIPattern);
|
|
311
|
-
if (!matches) {
|
|
312
|
-
throw new Error("invalid data URI");
|
|
313
|
-
}
|
|
314
|
-
mediaType = matches[2] ? matches[1] : "text/plain" + (matches[3] || ";charset=US-ASCII");
|
|
315
|
-
isBase64 = !!matches[4];
|
|
316
|
-
dataString = dataURI.slice(matches[0].length);
|
|
317
|
-
if (isBase64) {
|
|
318
|
-
byteString = atob(dataString);
|
|
319
|
-
} else {
|
|
320
|
-
byteString = decodeURIComponent(dataString);
|
|
321
|
-
}
|
|
322
|
-
arrayBuffer = new ArrayBuffer(byteString.length);
|
|
323
|
-
intArray = new Uint8Array(arrayBuffer);
|
|
324
|
-
for (i = 0; i < byteString.length; i += 1) {
|
|
325
|
-
intArray[i] = byteString.charCodeAt(i);
|
|
326
|
-
}
|
|
327
|
-
if (hasBlobConstructor) {
|
|
328
|
-
return new Blob([hasArrayBufferViewSupport ? intArray : arrayBuffer], {
|
|
329
|
-
type: mediaType
|
|
330
|
-
});
|
|
331
|
-
}
|
|
332
|
-
bb = new BlobBuilder();
|
|
333
|
-
bb.append(arrayBuffer);
|
|
334
|
-
return bb.getBlob(mediaType);
|
|
335
|
-
};
|
|
336
|
-
if (window2.HTMLCanvasElement && !CanvasPrototype.toBlob) {
|
|
337
|
-
if (CanvasPrototype.mozGetAsFile) {
|
|
338
|
-
CanvasPrototype.toBlob = function(callback, type, quality) {
|
|
339
|
-
var self2 = this;
|
|
340
|
-
setTimeout(function() {
|
|
341
|
-
if (quality && CanvasPrototype.toDataURL && dataURLtoBlob) {
|
|
342
|
-
callback(dataURLtoBlob(self2.toDataURL(type, quality)));
|
|
343
|
-
} else {
|
|
344
|
-
callback(self2.mozGetAsFile("blob", type));
|
|
345
|
-
}
|
|
346
|
-
});
|
|
347
|
-
};
|
|
348
|
-
} else if (CanvasPrototype.toDataURL && dataURLtoBlob) {
|
|
349
|
-
if (CanvasPrototype.msToBlob) {
|
|
350
|
-
CanvasPrototype.toBlob = function(callback, type, quality) {
|
|
351
|
-
var self2 = this;
|
|
352
|
-
setTimeout(function() {
|
|
353
|
-
if ((type && type !== "image/png" || quality) && CanvasPrototype.toDataURL && dataURLtoBlob) {
|
|
354
|
-
callback(dataURLtoBlob(self2.toDataURL(type, quality)));
|
|
355
|
-
} else {
|
|
356
|
-
callback(self2.msToBlob(type));
|
|
357
|
-
}
|
|
358
|
-
});
|
|
359
|
-
};
|
|
360
|
-
} else {
|
|
361
|
-
CanvasPrototype.toBlob = function(callback, type, quality) {
|
|
362
|
-
var self2 = this;
|
|
363
|
-
setTimeout(function() {
|
|
364
|
-
callback(dataURLtoBlob(self2.toDataURL(type, quality)));
|
|
365
|
-
});
|
|
366
|
-
};
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
if (module.exports) {
|
|
371
|
-
module.exports = dataURLtoBlob;
|
|
372
|
-
} else {
|
|
373
|
-
window2.dataURLtoBlob = dataURLtoBlob;
|
|
374
|
-
}
|
|
375
|
-
})(window);
|
|
376
|
-
})(canvasToBlob);
|
|
377
|
-
var toBlob = canvasToBlob.exports;
|
|
378
|
-
var isBlob = function isBlob2(value) {
|
|
379
|
-
if (typeof Blob === "undefined") {
|
|
380
|
-
return false;
|
|
381
|
-
}
|
|
382
|
-
return value instanceof Blob || Object.prototype.toString.call(value) === "[object Blob]";
|
|
383
|
-
};
|
|
384
|
-
var DEFAULTS = {
|
|
385
|
-
/**
|
|
386
|
-
* Indicates if output the original image instead of the compressed one
|
|
387
|
-
* when the size of the compressed image is greater than the original one's
|
|
388
|
-
* @type {boolean}
|
|
389
|
-
*/
|
|
390
|
-
strict: true,
|
|
391
|
-
/**
|
|
392
|
-
* Indicates if read the image's Exif Orientation information,
|
|
393
|
-
* and then rotate or flip the image automatically.
|
|
394
|
-
* @type {boolean}
|
|
395
|
-
*/
|
|
396
|
-
checkOrientation: true,
|
|
397
|
-
/**
|
|
398
|
-
* Indicates if retain the image's Exif information after compressed.
|
|
399
|
-
* @type {boolean}
|
|
400
|
-
*/
|
|
401
|
-
retainExif: false,
|
|
402
|
-
/**
|
|
403
|
-
* The max width of the output image.
|
|
404
|
-
* @type {number}
|
|
405
|
-
*/
|
|
406
|
-
maxWidth: Infinity,
|
|
407
|
-
/**
|
|
408
|
-
* The max height of the output image.
|
|
409
|
-
* @type {number}
|
|
410
|
-
*/
|
|
411
|
-
maxHeight: Infinity,
|
|
412
|
-
/**
|
|
413
|
-
* The min width of the output image.
|
|
414
|
-
* @type {number}
|
|
415
|
-
*/
|
|
416
|
-
minWidth: 0,
|
|
417
|
-
/**
|
|
418
|
-
* The min height of the output image.
|
|
419
|
-
* @type {number}
|
|
420
|
-
*/
|
|
421
|
-
minHeight: 0,
|
|
422
|
-
/**
|
|
423
|
-
* The width of the output image.
|
|
424
|
-
* If not specified, the natural width of the source image will be used.
|
|
425
|
-
* @type {number}
|
|
426
|
-
*/
|
|
427
|
-
width: void 0,
|
|
428
|
-
/**
|
|
429
|
-
* The height of the output image.
|
|
430
|
-
* If not specified, the natural height of the source image will be used.
|
|
431
|
-
* @type {number}
|
|
432
|
-
*/
|
|
433
|
-
height: void 0,
|
|
434
|
-
/**
|
|
435
|
-
* Sets how the size of the image should be resized to the container
|
|
436
|
-
* specified by the `width` and `height` options.
|
|
437
|
-
* @type {string}
|
|
438
|
-
*/
|
|
439
|
-
resize: "none",
|
|
440
|
-
/**
|
|
441
|
-
* The quality of the output image.
|
|
442
|
-
* It must be a number between `0` and `1`,
|
|
443
|
-
* and only available for `image/jpeg` and `image/webp` images.
|
|
444
|
-
* Check out {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob canvas.toBlob}.
|
|
445
|
-
* @type {number}
|
|
446
|
-
*/
|
|
447
|
-
quality: 0.8,
|
|
448
|
-
/**
|
|
449
|
-
* The mime type of the output image.
|
|
450
|
-
* By default, the original mime type of the source image file will be used.
|
|
451
|
-
* @type {string}
|
|
452
|
-
*/
|
|
453
|
-
mimeType: "auto",
|
|
454
|
-
/**
|
|
455
|
-
* Files whose file type is included in this list,
|
|
456
|
-
* and whose file size exceeds the `convertSize` value will be converted to JPEGs.
|
|
457
|
-
* @type {string|Array}
|
|
458
|
-
*/
|
|
459
|
-
convertTypes: ["image/png"],
|
|
460
|
-
/**
|
|
461
|
-
* PNG files over this size (5 MB by default) will be converted to JPEGs.
|
|
462
|
-
* To disable this, just set the value to `Infinity`.
|
|
463
|
-
* @type {number}
|
|
464
|
-
*/
|
|
465
|
-
convertSize: 5e6,
|
|
466
|
-
/**
|
|
467
|
-
* The hook function to execute before draw the image into the canvas for compression.
|
|
468
|
-
* @type {Function}
|
|
469
|
-
* @param {CanvasRenderingContext2D} context - The 2d rendering context of the canvas.
|
|
470
|
-
* @param {HTMLCanvasElement} canvas - The canvas for compression.
|
|
471
|
-
* @example
|
|
472
|
-
* function (context, canvas) {
|
|
473
|
-
* context.fillStyle = '#fff';
|
|
474
|
-
* }
|
|
475
|
-
*/
|
|
476
|
-
beforeDraw: null,
|
|
477
|
-
/**
|
|
478
|
-
* The hook function to execute after drew the image into the canvas for compression.
|
|
479
|
-
* @type {Function}
|
|
480
|
-
* @param {CanvasRenderingContext2D} context - The 2d rendering context of the canvas.
|
|
481
|
-
* @param {HTMLCanvasElement} canvas - The canvas for compression.
|
|
482
|
-
* @example
|
|
483
|
-
* function (context, canvas) {
|
|
484
|
-
* context.filter = 'grayscale(100%)';
|
|
485
|
-
* }
|
|
486
|
-
*/
|
|
487
|
-
drew: null,
|
|
488
|
-
/**
|
|
489
|
-
* The hook function to execute when success to compress the image.
|
|
490
|
-
* @type {Function}
|
|
491
|
-
* @param {File} file - The compressed image File object.
|
|
492
|
-
* @example
|
|
493
|
-
* function (file) {
|
|
494
|
-
* console.log(file);
|
|
495
|
-
* }
|
|
496
|
-
*/
|
|
497
|
-
success: null,
|
|
498
|
-
/**
|
|
499
|
-
* The hook function to execute when fail to compress the image.
|
|
500
|
-
* @type {Function}
|
|
501
|
-
* @param {Error} err - An Error object.
|
|
502
|
-
* @example
|
|
503
|
-
* function (err) {
|
|
504
|
-
* console.log(err.message);
|
|
505
|
-
* }
|
|
506
|
-
*/
|
|
507
|
-
error: null
|
|
508
|
-
};
|
|
509
|
-
var IS_BROWSER = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
510
|
-
var WINDOW = IS_BROWSER ? window : {};
|
|
511
|
-
var isPositiveNumber = function isPositiveNumber2(value) {
|
|
512
|
-
return value > 0 && value < Infinity;
|
|
513
|
-
};
|
|
514
|
-
var slice = Array.prototype.slice;
|
|
515
|
-
function toArray(value) {
|
|
516
|
-
return Array.from ? Array.from(value) : slice.call(value);
|
|
517
|
-
}
|
|
518
|
-
var REGEXP_IMAGE_TYPE = /^image\/.+$/;
|
|
519
|
-
function isImageType(value) {
|
|
520
|
-
return REGEXP_IMAGE_TYPE.test(value);
|
|
521
|
-
}
|
|
522
|
-
function imageTypeToExtension(value) {
|
|
523
|
-
var extension = isImageType(value) ? value.substr(6) : "";
|
|
524
|
-
if (extension === "jpeg") {
|
|
525
|
-
extension = "jpg";
|
|
526
|
-
}
|
|
527
|
-
return ".".concat(extension);
|
|
528
|
-
}
|
|
529
|
-
var fromCharCode = String.fromCharCode;
|
|
530
|
-
function getStringFromCharCode(dataView, start, length) {
|
|
531
|
-
var str = "";
|
|
532
|
-
var i;
|
|
533
|
-
length += start;
|
|
534
|
-
for (i = start; i < length; i += 1) {
|
|
535
|
-
str += fromCharCode(dataView.getUint8(i));
|
|
536
|
-
}
|
|
537
|
-
return str;
|
|
538
|
-
}
|
|
539
|
-
var btoa = WINDOW.btoa;
|
|
540
|
-
function arrayBufferToDataURL(arrayBuffer, mimeType) {
|
|
541
|
-
var chunks = [];
|
|
542
|
-
var chunkSize = 8192;
|
|
543
|
-
var uint8 = new Uint8Array(arrayBuffer);
|
|
544
|
-
while (uint8.length > 0) {
|
|
545
|
-
chunks.push(fromCharCode.apply(null, toArray(uint8.subarray(0, chunkSize))));
|
|
546
|
-
uint8 = uint8.subarray(chunkSize);
|
|
547
|
-
}
|
|
548
|
-
return "data:".concat(mimeType, ";base64,").concat(btoa(chunks.join("")));
|
|
549
|
-
}
|
|
550
|
-
function resetAndGetOrientation(arrayBuffer) {
|
|
551
|
-
var dataView = new DataView(arrayBuffer);
|
|
552
|
-
var orientation;
|
|
553
|
-
try {
|
|
554
|
-
var littleEndian;
|
|
555
|
-
var app1Start;
|
|
556
|
-
var ifdStart;
|
|
557
|
-
if (dataView.getUint8(0) === 255 && dataView.getUint8(1) === 216) {
|
|
558
|
-
var length = dataView.byteLength;
|
|
559
|
-
var offset = 2;
|
|
560
|
-
while (offset + 1 < length) {
|
|
561
|
-
if (dataView.getUint8(offset) === 255 && dataView.getUint8(offset + 1) === 225) {
|
|
562
|
-
app1Start = offset;
|
|
563
|
-
break;
|
|
564
|
-
}
|
|
565
|
-
offset += 1;
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
if (app1Start) {
|
|
569
|
-
var exifIDCode = app1Start + 4;
|
|
570
|
-
var tiffOffset = app1Start + 10;
|
|
571
|
-
if (getStringFromCharCode(dataView, exifIDCode, 4) === "Exif") {
|
|
572
|
-
var endianness = dataView.getUint16(tiffOffset);
|
|
573
|
-
littleEndian = endianness === 18761;
|
|
574
|
-
if (littleEndian || endianness === 19789) {
|
|
575
|
-
if (dataView.getUint16(tiffOffset + 2, littleEndian) === 42) {
|
|
576
|
-
var firstIFDOffset = dataView.getUint32(tiffOffset + 4, littleEndian);
|
|
577
|
-
if (firstIFDOffset >= 8) {
|
|
578
|
-
ifdStart = tiffOffset + firstIFDOffset;
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
if (ifdStart) {
|
|
585
|
-
var _length = dataView.getUint16(ifdStart, littleEndian);
|
|
586
|
-
var _offset;
|
|
587
|
-
var i;
|
|
588
|
-
for (i = 0; i < _length; i += 1) {
|
|
589
|
-
_offset = ifdStart + i * 12 + 2;
|
|
590
|
-
if (dataView.getUint16(_offset, littleEndian) === 274) {
|
|
591
|
-
_offset += 8;
|
|
592
|
-
orientation = dataView.getUint16(_offset, littleEndian);
|
|
593
|
-
dataView.setUint16(_offset, 1, littleEndian);
|
|
594
|
-
break;
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
} catch (e) {
|
|
599
|
-
orientation = 1;
|
|
600
|
-
}
|
|
601
|
-
return orientation;
|
|
602
|
-
}
|
|
603
|
-
function parseOrientation(orientation) {
|
|
604
|
-
var rotate = 0;
|
|
605
|
-
var scaleX = 1;
|
|
606
|
-
var scaleY = 1;
|
|
607
|
-
switch (orientation) {
|
|
608
|
-
case 2:
|
|
609
|
-
scaleX = -1;
|
|
610
|
-
break;
|
|
611
|
-
case 3:
|
|
612
|
-
rotate = -180;
|
|
613
|
-
break;
|
|
614
|
-
case 4:
|
|
615
|
-
scaleY = -1;
|
|
616
|
-
break;
|
|
617
|
-
case 5:
|
|
618
|
-
rotate = 90;
|
|
619
|
-
scaleY = -1;
|
|
620
|
-
break;
|
|
621
|
-
case 6:
|
|
622
|
-
rotate = 90;
|
|
623
|
-
break;
|
|
624
|
-
case 7:
|
|
625
|
-
rotate = 90;
|
|
626
|
-
scaleX = -1;
|
|
627
|
-
break;
|
|
628
|
-
case 8:
|
|
629
|
-
rotate = -90;
|
|
630
|
-
break;
|
|
631
|
-
}
|
|
632
|
-
return {
|
|
633
|
-
rotate,
|
|
634
|
-
scaleX,
|
|
635
|
-
scaleY
|
|
636
|
-
};
|
|
637
|
-
}
|
|
638
|
-
var REGEXP_DECIMALS = /\.\d*(?:0|9){12}\d*$/;
|
|
639
|
-
function normalizeDecimalNumber(value) {
|
|
640
|
-
var times = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1e11;
|
|
641
|
-
return REGEXP_DECIMALS.test(value) ? Math.round(value * times) / times : value;
|
|
642
|
-
}
|
|
643
|
-
function getAdjustedSizes(_ref) {
|
|
644
|
-
var aspectRatio = _ref.aspectRatio, height = _ref.height, width = _ref.width;
|
|
645
|
-
var type = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "none";
|
|
646
|
-
var isValidWidth = isPositiveNumber(width);
|
|
647
|
-
var isValidHeight = isPositiveNumber(height);
|
|
648
|
-
if (isValidWidth && isValidHeight) {
|
|
649
|
-
var adjustedWidth = height * aspectRatio;
|
|
650
|
-
if ((type === "contain" || type === "none") && adjustedWidth > width || type === "cover" && adjustedWidth < width) {
|
|
651
|
-
height = width / aspectRatio;
|
|
652
|
-
} else {
|
|
653
|
-
width = height * aspectRatio;
|
|
654
|
-
}
|
|
655
|
-
} else if (isValidWidth) {
|
|
656
|
-
height = width / aspectRatio;
|
|
657
|
-
} else if (isValidHeight) {
|
|
658
|
-
width = height * aspectRatio;
|
|
659
|
-
}
|
|
660
|
-
return {
|
|
661
|
-
width,
|
|
662
|
-
height
|
|
663
|
-
};
|
|
664
|
-
}
|
|
665
|
-
function getExif(arrayBuffer) {
|
|
666
|
-
var array = toArray(new Uint8Array(arrayBuffer));
|
|
667
|
-
var length = array.length;
|
|
668
|
-
var segments = [];
|
|
669
|
-
var start = 0;
|
|
670
|
-
while (start + 3 < length) {
|
|
671
|
-
var value = array[start];
|
|
672
|
-
var next = array[start + 1];
|
|
673
|
-
if (value === 255 && next === 218) {
|
|
674
|
-
break;
|
|
675
|
-
}
|
|
676
|
-
if (value === 255 && next === 216) {
|
|
677
|
-
start += 2;
|
|
678
|
-
} else {
|
|
679
|
-
var offset = array[start + 2] * 256 + array[start + 3];
|
|
680
|
-
var end = start + offset + 2;
|
|
681
|
-
var segment = array.slice(start, end);
|
|
682
|
-
segments.push(segment);
|
|
683
|
-
start = end;
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
return segments.reduce(function(exifArray, current) {
|
|
687
|
-
if (current[0] === 255 && current[1] === 225) {
|
|
688
|
-
return exifArray.concat(current);
|
|
689
|
-
}
|
|
690
|
-
return exifArray;
|
|
691
|
-
}, []);
|
|
692
|
-
}
|
|
693
|
-
function insertExif(arrayBuffer, exifArray) {
|
|
694
|
-
var array = toArray(new Uint8Array(arrayBuffer));
|
|
695
|
-
if (array[2] !== 255 || array[3] !== 224) {
|
|
696
|
-
return arrayBuffer;
|
|
697
|
-
}
|
|
698
|
-
var app0Length = array[4] * 256 + array[5];
|
|
699
|
-
var newArrayBuffer = [255, 216].concat(exifArray, array.slice(4 + app0Length));
|
|
700
|
-
return new Uint8Array(newArrayBuffer);
|
|
701
|
-
}
|
|
702
|
-
var ArrayBuffer$1 = WINDOW.ArrayBuffer, FileReader$1 = WINDOW.FileReader;
|
|
703
|
-
var URL$1 = WINDOW.URL || WINDOW.webkitURL;
|
|
704
|
-
var REGEXP_EXTENSION = /\.\w+$/;
|
|
705
|
-
var AnotherCompressor = WINDOW.Compressor;
|
|
706
|
-
var Compressor = /* @__PURE__ */ function() {
|
|
707
|
-
function Compressor2(file, options) {
|
|
708
|
-
_classCallCheck(this, Compressor2);
|
|
709
|
-
this.file = file;
|
|
710
|
-
this.exif = [];
|
|
711
|
-
this.image = new Image();
|
|
712
|
-
this.options = _objectSpread2(_objectSpread2({}, DEFAULTS), options);
|
|
713
|
-
this.aborted = false;
|
|
714
|
-
this.result = null;
|
|
715
|
-
this.init();
|
|
716
|
-
}
|
|
717
|
-
_createClass(Compressor2, [{
|
|
718
|
-
key: "init",
|
|
719
|
-
value: function init() {
|
|
720
|
-
var _this = this;
|
|
721
|
-
var file = this.file, options = this.options;
|
|
722
|
-
if (!isBlob(file)) {
|
|
723
|
-
this.fail(new Error("The first argument must be a File or Blob object."));
|
|
724
|
-
return;
|
|
725
|
-
}
|
|
726
|
-
var mimeType = file.type;
|
|
727
|
-
if (!isImageType(mimeType)) {
|
|
728
|
-
this.fail(new Error("The first argument must be an image File or Blob object."));
|
|
729
|
-
return;
|
|
730
|
-
}
|
|
731
|
-
if (!URL$1 || !FileReader$1) {
|
|
732
|
-
this.fail(new Error("The current browser does not support image compression."));
|
|
733
|
-
return;
|
|
734
|
-
}
|
|
735
|
-
if (!ArrayBuffer$1) {
|
|
736
|
-
options.checkOrientation = false;
|
|
737
|
-
options.retainExif = false;
|
|
738
|
-
}
|
|
739
|
-
var isJPEGImage = mimeType === "image/jpeg";
|
|
740
|
-
var checkOrientation = isJPEGImage && options.checkOrientation;
|
|
741
|
-
var retainExif = isJPEGImage && options.retainExif;
|
|
742
|
-
if (URL$1 && !checkOrientation && !retainExif) {
|
|
743
|
-
this.load({
|
|
744
|
-
url: URL$1.createObjectURL(file)
|
|
745
|
-
});
|
|
746
|
-
} else {
|
|
747
|
-
var reader = new FileReader$1();
|
|
748
|
-
this.reader = reader;
|
|
749
|
-
reader.onload = function(_ref) {
|
|
750
|
-
var target = _ref.target;
|
|
751
|
-
var result = target.result;
|
|
752
|
-
var data = {};
|
|
753
|
-
var orientation = 1;
|
|
754
|
-
if (checkOrientation) {
|
|
755
|
-
orientation = resetAndGetOrientation(result);
|
|
756
|
-
if (orientation > 1) {
|
|
757
|
-
_extends(data, parseOrientation(orientation));
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
if (retainExif) {
|
|
761
|
-
_this.exif = getExif(result);
|
|
762
|
-
}
|
|
763
|
-
if (checkOrientation || retainExif) {
|
|
764
|
-
if (!URL$1 || orientation > 1) {
|
|
765
|
-
data.url = arrayBufferToDataURL(result, mimeType);
|
|
766
|
-
} else {
|
|
767
|
-
data.url = URL$1.createObjectURL(file);
|
|
768
|
-
}
|
|
769
|
-
} else {
|
|
770
|
-
data.url = result;
|
|
771
|
-
}
|
|
772
|
-
_this.load(data);
|
|
773
|
-
};
|
|
774
|
-
reader.onabort = function() {
|
|
775
|
-
_this.fail(new Error("Aborted to read the image with FileReader."));
|
|
776
|
-
};
|
|
777
|
-
reader.onerror = function() {
|
|
778
|
-
_this.fail(new Error("Failed to read the image with FileReader."));
|
|
779
|
-
};
|
|
780
|
-
reader.onloadend = function() {
|
|
781
|
-
_this.reader = null;
|
|
782
|
-
};
|
|
783
|
-
if (checkOrientation || retainExif) {
|
|
784
|
-
reader.readAsArrayBuffer(file);
|
|
785
|
-
} else {
|
|
786
|
-
reader.readAsDataURL(file);
|
|
787
|
-
}
|
|
788
|
-
}
|
|
789
|
-
}
|
|
790
|
-
}, {
|
|
791
|
-
key: "load",
|
|
792
|
-
value: function load(data) {
|
|
793
|
-
var _this2 = this;
|
|
794
|
-
var file = this.file, image = this.image;
|
|
795
|
-
image.onload = function() {
|
|
796
|
-
_this2.draw(_objectSpread2(_objectSpread2({}, data), {}, {
|
|
797
|
-
naturalWidth: image.naturalWidth,
|
|
798
|
-
naturalHeight: image.naturalHeight
|
|
799
|
-
}));
|
|
800
|
-
};
|
|
801
|
-
image.onabort = function() {
|
|
802
|
-
_this2.fail(new Error("Aborted to load the image."));
|
|
803
|
-
};
|
|
804
|
-
image.onerror = function() {
|
|
805
|
-
_this2.fail(new Error("Failed to load the image."));
|
|
806
|
-
};
|
|
807
|
-
if (WINDOW.navigator && /(?:iPad|iPhone|iPod).*?AppleWebKit/i.test(WINDOW.navigator.userAgent)) {
|
|
808
|
-
image.crossOrigin = "anonymous";
|
|
809
|
-
}
|
|
810
|
-
image.alt = file.name;
|
|
811
|
-
image.src = data.url;
|
|
812
|
-
}
|
|
813
|
-
}, {
|
|
814
|
-
key: "draw",
|
|
815
|
-
value: function draw(_ref2) {
|
|
816
|
-
var _this3 = this;
|
|
817
|
-
var naturalWidth = _ref2.naturalWidth, naturalHeight = _ref2.naturalHeight, _ref2$rotate = _ref2.rotate, rotate = _ref2$rotate === void 0 ? 0 : _ref2$rotate, _ref2$scaleX = _ref2.scaleX, scaleX = _ref2$scaleX === void 0 ? 1 : _ref2$scaleX, _ref2$scaleY = _ref2.scaleY, scaleY = _ref2$scaleY === void 0 ? 1 : _ref2$scaleY;
|
|
818
|
-
var file = this.file, image = this.image, options = this.options;
|
|
819
|
-
var canvas = document.createElement("canvas");
|
|
820
|
-
var context = canvas.getContext("2d");
|
|
821
|
-
var is90DegreesRotated = Math.abs(rotate) % 180 === 90;
|
|
822
|
-
var resizable = (options.resize === "contain" || options.resize === "cover") && isPositiveNumber(options.width) && isPositiveNumber(options.height);
|
|
823
|
-
var maxWidth = Math.max(options.maxWidth, 0) || Infinity;
|
|
824
|
-
var maxHeight = Math.max(options.maxHeight, 0) || Infinity;
|
|
825
|
-
var minWidth = Math.max(options.minWidth, 0) || 0;
|
|
826
|
-
var minHeight = Math.max(options.minHeight, 0) || 0;
|
|
827
|
-
var aspectRatio = naturalWidth / naturalHeight;
|
|
828
|
-
var width = options.width, height = options.height;
|
|
829
|
-
if (is90DegreesRotated) {
|
|
830
|
-
var _ref3 = [maxHeight, maxWidth];
|
|
831
|
-
maxWidth = _ref3[0];
|
|
832
|
-
maxHeight = _ref3[1];
|
|
833
|
-
var _ref4 = [minHeight, minWidth];
|
|
834
|
-
minWidth = _ref4[0];
|
|
835
|
-
minHeight = _ref4[1];
|
|
836
|
-
var _ref5 = [height, width];
|
|
837
|
-
width = _ref5[0];
|
|
838
|
-
height = _ref5[1];
|
|
839
|
-
}
|
|
840
|
-
if (resizable) {
|
|
841
|
-
aspectRatio = width / height;
|
|
842
|
-
}
|
|
843
|
-
var _getAdjustedSizes = getAdjustedSizes({
|
|
844
|
-
aspectRatio,
|
|
845
|
-
width: maxWidth,
|
|
846
|
-
height: maxHeight
|
|
847
|
-
}, "contain");
|
|
848
|
-
maxWidth = _getAdjustedSizes.width;
|
|
849
|
-
maxHeight = _getAdjustedSizes.height;
|
|
850
|
-
var _getAdjustedSizes2 = getAdjustedSizes({
|
|
851
|
-
aspectRatio,
|
|
852
|
-
width: minWidth,
|
|
853
|
-
height: minHeight
|
|
854
|
-
}, "cover");
|
|
855
|
-
minWidth = _getAdjustedSizes2.width;
|
|
856
|
-
minHeight = _getAdjustedSizes2.height;
|
|
857
|
-
if (resizable) {
|
|
858
|
-
var _getAdjustedSizes3 = getAdjustedSizes({
|
|
859
|
-
aspectRatio,
|
|
860
|
-
width,
|
|
861
|
-
height
|
|
862
|
-
}, options.resize);
|
|
863
|
-
width = _getAdjustedSizes3.width;
|
|
864
|
-
height = _getAdjustedSizes3.height;
|
|
865
|
-
} else {
|
|
866
|
-
var _getAdjustedSizes4 = getAdjustedSizes({
|
|
867
|
-
aspectRatio,
|
|
868
|
-
width,
|
|
869
|
-
height
|
|
870
|
-
});
|
|
871
|
-
var _getAdjustedSizes4$wi = _getAdjustedSizes4.width;
|
|
872
|
-
width = _getAdjustedSizes4$wi === void 0 ? naturalWidth : _getAdjustedSizes4$wi;
|
|
873
|
-
var _getAdjustedSizes4$he = _getAdjustedSizes4.height;
|
|
874
|
-
height = _getAdjustedSizes4$he === void 0 ? naturalHeight : _getAdjustedSizes4$he;
|
|
875
|
-
}
|
|
876
|
-
width = Math.floor(normalizeDecimalNumber(Math.min(Math.max(width, minWidth), maxWidth)));
|
|
877
|
-
height = Math.floor(normalizeDecimalNumber(Math.min(Math.max(height, minHeight), maxHeight)));
|
|
878
|
-
var destX = -width / 2;
|
|
879
|
-
var destY = -height / 2;
|
|
880
|
-
var destWidth = width;
|
|
881
|
-
var destHeight = height;
|
|
882
|
-
var params = [];
|
|
883
|
-
if (resizable) {
|
|
884
|
-
var srcX = 0;
|
|
885
|
-
var srcY = 0;
|
|
886
|
-
var srcWidth = naturalWidth;
|
|
887
|
-
var srcHeight = naturalHeight;
|
|
888
|
-
var _getAdjustedSizes5 = getAdjustedSizes({
|
|
889
|
-
aspectRatio,
|
|
890
|
-
width: naturalWidth,
|
|
891
|
-
height: naturalHeight
|
|
892
|
-
}, {
|
|
893
|
-
contain: "cover",
|
|
894
|
-
cover: "contain"
|
|
895
|
-
}[options.resize]);
|
|
896
|
-
srcWidth = _getAdjustedSizes5.width;
|
|
897
|
-
srcHeight = _getAdjustedSizes5.height;
|
|
898
|
-
srcX = (naturalWidth - srcWidth) / 2;
|
|
899
|
-
srcY = (naturalHeight - srcHeight) / 2;
|
|
900
|
-
params.push(srcX, srcY, srcWidth, srcHeight);
|
|
901
|
-
}
|
|
902
|
-
params.push(destX, destY, destWidth, destHeight);
|
|
903
|
-
if (is90DegreesRotated) {
|
|
904
|
-
var _ref6 = [height, width];
|
|
905
|
-
width = _ref6[0];
|
|
906
|
-
height = _ref6[1];
|
|
907
|
-
}
|
|
908
|
-
canvas.width = width;
|
|
909
|
-
canvas.height = height;
|
|
910
|
-
if (!isImageType(options.mimeType)) {
|
|
911
|
-
options.mimeType = file.type;
|
|
912
|
-
}
|
|
913
|
-
var fillStyle = "transparent";
|
|
914
|
-
if (file.size > options.convertSize && options.convertTypes.indexOf(options.mimeType) >= 0) {
|
|
915
|
-
options.mimeType = "image/jpeg";
|
|
916
|
-
}
|
|
917
|
-
var isJPEGImage = options.mimeType === "image/jpeg";
|
|
918
|
-
if (isJPEGImage) {
|
|
919
|
-
fillStyle = "#fff";
|
|
920
|
-
}
|
|
921
|
-
context.fillStyle = fillStyle;
|
|
922
|
-
context.fillRect(0, 0, width, height);
|
|
923
|
-
if (options.beforeDraw) {
|
|
924
|
-
options.beforeDraw.call(this, context, canvas);
|
|
925
|
-
}
|
|
926
|
-
if (this.aborted) {
|
|
927
|
-
return;
|
|
928
|
-
}
|
|
929
|
-
context.save();
|
|
930
|
-
context.translate(width / 2, height / 2);
|
|
931
|
-
context.rotate(rotate * Math.PI / 180);
|
|
932
|
-
context.scale(scaleX, scaleY);
|
|
933
|
-
context.drawImage.apply(context, [image].concat(params));
|
|
934
|
-
context.restore();
|
|
935
|
-
if (options.drew) {
|
|
936
|
-
options.drew.call(this, context, canvas);
|
|
937
|
-
}
|
|
938
|
-
if (this.aborted) {
|
|
939
|
-
return;
|
|
940
|
-
}
|
|
941
|
-
var callback = function callback2(blob) {
|
|
942
|
-
if (!_this3.aborted) {
|
|
943
|
-
var done = function done2(result) {
|
|
944
|
-
return _this3.done({
|
|
945
|
-
naturalWidth,
|
|
946
|
-
naturalHeight,
|
|
947
|
-
result
|
|
948
|
-
});
|
|
949
|
-
};
|
|
950
|
-
if (blob && isJPEGImage && options.retainExif && _this3.exif && _this3.exif.length > 0) {
|
|
951
|
-
var next = function next2(arrayBuffer) {
|
|
952
|
-
return done(toBlob(arrayBufferToDataURL(insertExif(arrayBuffer, _this3.exif), options.mimeType)));
|
|
953
|
-
};
|
|
954
|
-
if (blob.arrayBuffer) {
|
|
955
|
-
blob.arrayBuffer().then(next).catch(function() {
|
|
956
|
-
_this3.fail(new Error("Failed to read the compressed image with Blob.arrayBuffer()."));
|
|
957
|
-
});
|
|
958
|
-
} else {
|
|
959
|
-
var reader = new FileReader$1();
|
|
960
|
-
_this3.reader = reader;
|
|
961
|
-
reader.onload = function(_ref7) {
|
|
962
|
-
var target = _ref7.target;
|
|
963
|
-
next(target.result);
|
|
964
|
-
};
|
|
965
|
-
reader.onabort = function() {
|
|
966
|
-
_this3.fail(new Error("Aborted to read the compressed image with FileReader."));
|
|
967
|
-
};
|
|
968
|
-
reader.onerror = function() {
|
|
969
|
-
_this3.fail(new Error("Failed to read the compressed image with FileReader."));
|
|
970
|
-
};
|
|
971
|
-
reader.onloadend = function() {
|
|
972
|
-
_this3.reader = null;
|
|
973
|
-
};
|
|
974
|
-
reader.readAsArrayBuffer(blob);
|
|
975
|
-
}
|
|
976
|
-
} else {
|
|
977
|
-
done(blob);
|
|
978
|
-
}
|
|
979
|
-
}
|
|
980
|
-
};
|
|
981
|
-
if (canvas.toBlob) {
|
|
982
|
-
canvas.toBlob(callback, options.mimeType, options.quality);
|
|
983
|
-
} else {
|
|
984
|
-
callback(toBlob(canvas.toDataURL(options.mimeType, options.quality)));
|
|
985
|
-
}
|
|
986
|
-
}
|
|
987
|
-
}, {
|
|
988
|
-
key: "done",
|
|
989
|
-
value: function done(_ref8) {
|
|
990
|
-
var naturalWidth = _ref8.naturalWidth, naturalHeight = _ref8.naturalHeight, result = _ref8.result;
|
|
991
|
-
var file = this.file, image = this.image, options = this.options;
|
|
992
|
-
if (URL$1 && image.src.indexOf("blob:") === 0) {
|
|
993
|
-
URL$1.revokeObjectURL(image.src);
|
|
994
|
-
}
|
|
995
|
-
if (result) {
|
|
996
|
-
if (options.strict && !options.retainExif && result.size > file.size && options.mimeType === file.type && !(options.width > naturalWidth || options.height > naturalHeight || options.minWidth > naturalWidth || options.minHeight > naturalHeight || options.maxWidth < naturalWidth || options.maxHeight < naturalHeight)) {
|
|
997
|
-
result = file;
|
|
998
|
-
} else {
|
|
999
|
-
var date = /* @__PURE__ */ new Date();
|
|
1000
|
-
result.lastModified = date.getTime();
|
|
1001
|
-
result.lastModifiedDate = date;
|
|
1002
|
-
result.name = file.name;
|
|
1003
|
-
if (result.name && result.type !== file.type) {
|
|
1004
|
-
result.name = result.name.replace(REGEXP_EXTENSION, imageTypeToExtension(result.type));
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
1007
|
-
} else {
|
|
1008
|
-
result = file;
|
|
1009
|
-
}
|
|
1010
|
-
this.result = result;
|
|
1011
|
-
if (options.success) {
|
|
1012
|
-
options.success.call(this, result);
|
|
1013
|
-
}
|
|
1014
|
-
}
|
|
1015
|
-
}, {
|
|
1016
|
-
key: "fail",
|
|
1017
|
-
value: function fail(err) {
|
|
1018
|
-
var options = this.options;
|
|
1019
|
-
if (options.error) {
|
|
1020
|
-
options.error.call(this, err);
|
|
1021
|
-
} else {
|
|
1022
|
-
throw err;
|
|
1023
|
-
}
|
|
1024
|
-
}
|
|
1025
|
-
}, {
|
|
1026
|
-
key: "abort",
|
|
1027
|
-
value: function abort() {
|
|
1028
|
-
if (!this.aborted) {
|
|
1029
|
-
this.aborted = true;
|
|
1030
|
-
if (this.reader) {
|
|
1031
|
-
this.reader.abort();
|
|
1032
|
-
} else if (!this.image.complete) {
|
|
1033
|
-
this.image.onload = null;
|
|
1034
|
-
this.image.onabort();
|
|
1035
|
-
} else {
|
|
1036
|
-
this.fail(new Error("The compression process has been aborted."));
|
|
1037
|
-
}
|
|
1038
|
-
}
|
|
1039
|
-
}
|
|
1040
|
-
/**
|
|
1041
|
-
* Get the no conflict compressor class.
|
|
1042
|
-
* @returns {Compressor} The compressor class.
|
|
1043
|
-
*/
|
|
1044
|
-
}], [{
|
|
1045
|
-
key: "noConflict",
|
|
1046
|
-
value: function noConflict() {
|
|
1047
|
-
window.Compressor = AnotherCompressor;
|
|
1048
|
-
return Compressor2;
|
|
1049
|
-
}
|
|
1050
|
-
/**
|
|
1051
|
-
* Change the default options.
|
|
1052
|
-
* @param {Object} options - The new default options.
|
|
1053
|
-
*/
|
|
1054
|
-
}, {
|
|
1055
|
-
key: "setDefaults",
|
|
1056
|
-
value: function setDefaults(options) {
|
|
1057
|
-
_extends(DEFAULTS, options);
|
|
1058
|
-
}
|
|
1059
|
-
}]);
|
|
1060
|
-
return Compressor2;
|
|
1061
|
-
}();
|
|
1062
|
-
const snapshotAsZip = async (snapshot) => {
|
|
1063
|
-
const zip = new JSZip();
|
|
1064
|
-
zip.file(`snapshot.json`, JSON.stringify(snapshot)).file(`screenshot.png`, await screenshotStorage.getItem(snapshot.id));
|
|
1065
|
-
const content = await zip.generateAsync({
|
|
1066
|
-
type: "blob",
|
|
1067
|
-
compression: `STORE`
|
|
1068
|
-
});
|
|
1069
|
-
return content;
|
|
1070
|
-
};
|
|
1071
|
-
const exportSnapshotAsZip = async (snapshot) => {
|
|
1072
|
-
const fileName = `snapshot-${snapshot.id}.zip`;
|
|
1073
|
-
FileSaver_minExports.saveAs(await snapshotAsZip(snapshot), fileName);
|
|
1074
|
-
};
|
|
1075
|
-
const snapshotAsJpg = async (snapshot) => {
|
|
1076
|
-
const imgBf = await screenshotStorage.getItem(snapshot.id);
|
|
1077
|
-
const jpgBlob = await new Promise((res, rej) => {
|
|
1078
|
-
new Compressor(new Blob([imgBf], { type: "image/png" }), {
|
|
1079
|
-
quality: 0.75,
|
|
1080
|
-
convertSize: 2e5,
|
|
1081
|
-
success(file) {
|
|
1082
|
-
res(file);
|
|
1083
|
-
},
|
|
1084
|
-
error(error) {
|
|
1085
|
-
rej(error);
|
|
1086
|
-
}
|
|
1087
|
-
});
|
|
1088
|
-
});
|
|
1089
|
-
const content = new Blob([jpgBlob], { type: "image/jpeg" });
|
|
1090
|
-
return content;
|
|
1091
|
-
};
|
|
1092
|
-
const exportSnapshotAsJpg = async (snapshot) => {
|
|
1093
|
-
const fileName = `snapshot-${snapshot.id}.jpg`;
|
|
1094
|
-
FileSaver_minExports.saveAs(await snapshotAsJpg(snapshot), fileName);
|
|
1095
|
-
};
|
|
1096
|
-
const batchJpgDownloadZip = async (snapshots) => {
|
|
1097
|
-
const zip = new JSZip();
|
|
1098
|
-
for (const snapshot of snapshots) {
|
|
1099
|
-
await delay();
|
|
1100
|
-
zip.file(snapshot.id + `.jpg`, snapshotAsJpg(snapshot));
|
|
1101
|
-
}
|
|
1102
|
-
const batchZipFile = await zip.generateAsync({
|
|
1103
|
-
type: "blob",
|
|
1104
|
-
compression: `STORE`
|
|
1105
|
-
});
|
|
1106
|
-
FileSaver_minExports.saveAs(batchZipFile, `batch-png-${snapshots.length}.zip`);
|
|
1107
|
-
};
|
|
1108
|
-
const batchZipDownloadZip = async (snapshots) => {
|
|
1109
|
-
const zip = new JSZip();
|
|
1110
|
-
for (const snapshot of snapshots) {
|
|
1111
|
-
await delay();
|
|
1112
|
-
zip.file(snapshot.id + `.zip`, await snapshotAsZip(snapshot));
|
|
1113
|
-
}
|
|
1114
|
-
const batchZipFile = await zip.generateAsync({
|
|
1115
|
-
type: "blob",
|
|
1116
|
-
compression: `STORE`
|
|
1117
|
-
});
|
|
1118
|
-
FileSaver_minExports.saveAs(batchZipFile, `batch-zip-${snapshots.length}.zip`);
|
|
1119
|
-
};
|
|
1120
|
-
const exportSnapshotAsJpgUrl = async (snapshot) => {
|
|
1121
|
-
return githubJpgStorage[snapshot.id] ?? uploadPoliciesAssets(
|
|
1122
|
-
await snapshotAsJpg(snapshot).then((r) => r.arrayBuffer()),
|
|
1123
|
-
"file.jpg",
|
|
1124
|
-
"image/jpeg"
|
|
1125
|
-
).then((r) => {
|
|
1126
|
-
githubJpgStorage[snapshot.id] = r.href;
|
|
1127
|
-
return r.href;
|
|
1128
|
-
});
|
|
1129
|
-
};
|
|
1130
|
-
const exportSnapshotAsZipUrl = async (snapshot) => {
|
|
1131
|
-
return githubZipStorage[snapshot.id] ?? uploadPoliciesAssets(
|
|
1132
|
-
await snapshotAsZip(snapshot).then((r) => r.arrayBuffer()),
|
|
1133
|
-
"file.zip",
|
|
1134
|
-
"application/x-zip-compressed"
|
|
1135
|
-
).then((r) => {
|
|
1136
|
-
githubZipStorage[snapshot.id] = r.href;
|
|
1137
|
-
urlStorage[r.href] = snapshot.id;
|
|
1138
|
-
return r.href;
|
|
1139
|
-
});
|
|
1140
|
-
};
|
|
1141
|
-
const batchCreateJpgUrl = async (snapshots) => {
|
|
1142
|
-
const limit = pLimit(3);
|
|
1143
|
-
return (await Promise.allSettled(
|
|
1144
|
-
snapshots.map((s) => limit(() => exportSnapshotAsJpgUrl(s)))
|
|
1145
|
-
)).reduce((p, c) => {
|
|
1146
|
-
if (c.status == "fulfilled") {
|
|
1147
|
-
p.push(c.value);
|
|
1148
|
-
}
|
|
1149
|
-
return p;
|
|
1150
|
-
}, []);
|
|
1151
|
-
};
|
|
1152
|
-
const batchCreateZipUrl = async (snapshots) => {
|
|
1153
|
-
const limit = pLimit(3);
|
|
1154
|
-
return (await Promise.allSettled(
|
|
1155
|
-
snapshots.map((s) => limit(() => exportSnapshotAsZipUrl(s)))
|
|
1156
|
-
)).reduce((p, c) => {
|
|
1157
|
-
if (c.status == "fulfilled") {
|
|
1158
|
-
p.push(c.value);
|
|
1159
|
-
}
|
|
1160
|
-
return p;
|
|
1161
|
-
}, []);
|
|
1162
|
-
};
|
|
1163
|
-
const _hoisted_1 = ["href"];
|
|
1164
|
-
const _hoisted_2 = /* @__PURE__ */ createBaseVNode("svg", {
|
|
1165
|
-
viewBox: "0 0 1024 1024",
|
|
1166
|
-
version: "1.1",
|
|
1167
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1168
|
-
width: "200",
|
|
1169
|
-
height: "200"
|
|
1170
|
-
}, [/* @__PURE__ */ createBaseVNode("path", {
|
|
1171
|
-
d: "M549.973333 128 633.6 145.066667 474.026667 896 390.4 878.933333 549.973333 128M835.84 512 682.666667 358.826667 682.666667 238.08 956.586667 512 682.666667 785.493333 682.666667 664.746667 835.84 512M67.413333 512 341.333333 238.08 341.333333 358.826667 188.16 512 341.333333 664.746667 341.333333 785.493333 67.413333 512Z"
|
|
1172
|
-
})], -1);
|
|
1173
|
-
const _hoisted_3 = /* @__PURE__ */ createBaseVNode("svg", {
|
|
1174
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1175
|
-
"xmlns:xlink": "http://www.w3.org/1999/xlink",
|
|
1176
|
-
viewBox: "0 0 24 24"
|
|
1177
|
-
}, [/* @__PURE__ */ createBaseVNode("g", {
|
|
1178
|
-
fill: "none",
|
|
1179
|
-
stroke: "currentColor",
|
|
1180
|
-
"stroke-width": "2",
|
|
1181
|
-
"stroke-linecap": "round",
|
|
1182
|
-
"stroke-linejoin": "round"
|
|
1183
|
-
}, [/* @__PURE__ */ createBaseVNode("path", {
|
|
1184
|
-
d: "M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2"
|
|
1185
|
-
}), /* @__PURE__ */ createBaseVNode("path", {
|
|
1186
|
-
d: "M7 11l5 5l5-5"
|
|
1187
|
-
}), /* @__PURE__ */ createBaseVNode("path", {
|
|
1188
|
-
d: "M12 4v12"
|
|
1189
|
-
})])], -1);
|
|
1190
|
-
const _hoisted_4 = /* @__PURE__ */ createBaseVNode("svg", {
|
|
1191
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1192
|
-
"xmlns:xlink": "http://www.w3.org/1999/xlink",
|
|
1193
|
-
viewBox: "0 0 24 24"
|
|
1194
|
-
}, [/* @__PURE__ */ createBaseVNode("path", {
|
|
1195
|
-
d: "M18 16.08c-.76 0-1.44.3-1.96.77L8.91 12.7c.05-.23.09-.46.09-.7s-.04-.47-.09-.7l7.05-4.11c.54.5 1.25.81 2.04.81c1.66 0 3-1.34 3-3s-1.34-3-3-3s-3 1.34-3 3c0 .24.04.47.09.7L8.04 9.81C7.5 9.31 6.79 9 6 9c-1.66 0-3 1.34-3 3s1.34 3 3 3c.79 0 1.5-.31 2.04-.81l7.12 4.16c-.05.21-.08.43-.08.65c0 1.61 1.31 2.92 2.92 2.92s2.92-1.31 2.92-2.92s-1.31-2.92-2.92-2.92z",
|
|
1196
|
-
fill: "currentColor"
|
|
1197
|
-
})], -1);
|
|
1198
|
-
const _hoisted_5 = /* @__PURE__ */ createBaseVNode("svg", {
|
|
1199
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1200
|
-
"xmlns:xlink": "http://www.w3.org/1999/xlink",
|
|
1201
|
-
viewBox: "0 0 24 24"
|
|
1202
|
-
}, [/* @__PURE__ */ createBaseVNode("g", {
|
|
1203
|
-
fill: "none"
|
|
1204
|
-
}, [/* @__PURE__ */ createBaseVNode("path", {
|
|
1205
|
-
d: "M12 1.75a3.25 3.25 0 0 1 3.245 3.066L15.25 5h5.25a.75.75 0 0 1 .102 1.493L20.5 6.5h-.796l-1.28 13.02a2.75 2.75 0 0 1-2.561 2.474l-.176.006H8.313a2.75 2.75 0 0 1-2.714-2.307l-.023-.174L4.295 6.5H3.5a.75.75 0 0 1-.743-.648L2.75 5.75a.75.75 0 0 1 .648-.743L3.5 5h5.25A3.25 3.25 0 0 1 12 1.75zm6.197 4.75H5.802l1.267 12.872a1.25 1.25 0 0 0 1.117 1.122l.127.006h7.374c.6 0 1.109-.425 1.225-1.002l.02-.126L18.196 6.5zM13.75 9.25a.75.75 0 0 1 .743.648L14.5 10v7a.75.75 0 0 1-1.493.102L13 17v-7a.75.75 0 0 1 .75-.75zm-3.5 0a.75.75 0 0 1 .743.648L11 10v7a.75.75 0 0 1-1.493.102L9.5 17v-7a.75.75 0 0 1 .75-.75zm1.75-6a1.75 1.75 0 0 0-1.744 1.606L10.25 5h3.5A1.75 1.75 0 0 0 12 3.25z",
|
|
1206
|
-
fill: "currentColor"
|
|
1207
|
-
})])], -1);
|
|
1208
|
-
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
1209
|
-
__name: "ActionCard",
|
|
1210
|
-
props: {
|
|
1211
|
-
snapshot: {},
|
|
1212
|
-
onDelete: {
|
|
1213
|
-
type: Function,
|
|
1214
|
-
default: () => () => {
|
|
1215
|
-
}
|
|
1216
|
-
},
|
|
1217
|
-
showPreview: {
|
|
1218
|
-
type: Boolean,
|
|
1219
|
-
default: true
|
|
1220
|
-
},
|
|
1221
|
-
showExport: {
|
|
1222
|
-
type: Boolean,
|
|
1223
|
-
default: true
|
|
1224
|
-
},
|
|
1225
|
-
showDelete: {
|
|
1226
|
-
type: Boolean,
|
|
1227
|
-
default: true
|
|
1228
|
-
},
|
|
1229
|
-
showShare: {
|
|
1230
|
-
type: Boolean,
|
|
1231
|
-
default: true
|
|
1232
|
-
}
|
|
1233
|
-
},
|
|
1234
|
-
setup(__props) {
|
|
1235
|
-
const props = __props;
|
|
1236
|
-
const router = useRouter();
|
|
1237
|
-
const exportJpg = useTask(async () => exportSnapshotAsJpg(await snapshotStorage.getItem(props.snapshot.id)));
|
|
1238
|
-
const exportZip = useTask(async () => exportSnapshotAsZip(await snapshotStorage.getItem(props.snapshot.id)));
|
|
1239
|
-
const previewUrl = computed(() => {
|
|
1240
|
-
return router.resolve({
|
|
1241
|
-
name: "snapshot",
|
|
1242
|
-
params: {
|
|
1243
|
-
snapshotId: props.snapshot.id
|
|
1244
|
-
}
|
|
1245
|
-
}).href;
|
|
1246
|
-
});
|
|
1247
|
-
const exportJpgUrl = useTask(async () => {
|
|
1248
|
-
const pngUrl = await exportSnapshotAsJpgUrl(await snapshotStorage.getItem(props.snapshot.id));
|
|
1249
|
-
showTextDLg({
|
|
1250
|
-
title: `分享链接`,
|
|
1251
|
-
content: githubUrlToSelfUrl(pngUrl)
|
|
1252
|
-
});
|
|
1253
|
-
});
|
|
1254
|
-
const exportZipUrl = useTask(async () => {
|
|
1255
|
-
const zipUrl = await exportSnapshotAsZipUrl(await snapshotStorage.getItem(props.snapshot.id));
|
|
1256
|
-
showTextDLg({
|
|
1257
|
-
title: `分享链接`,
|
|
1258
|
-
content: githubUrlToSelfUrl(zipUrl)
|
|
1259
|
-
});
|
|
1260
|
-
});
|
|
1261
|
-
const deleteSnapshot = async () => {
|
|
1262
|
-
await snapshotStorage.removeItem(props.snapshot.id);
|
|
1263
|
-
await delay(500);
|
|
1264
|
-
props.onDelete();
|
|
1265
|
-
};
|
|
1266
|
-
const copy = async (content) => {
|
|
1267
|
-
return navigator.clipboard.writeText(content).then(() => {
|
|
1268
|
-
message.success(`复制成功`);
|
|
1269
|
-
}).catch(() => {
|
|
1270
|
-
message.success(`复制失败`);
|
|
1271
|
-
});
|
|
1272
|
-
};
|
|
1273
|
-
return (_ctx, _cache) => {
|
|
1274
|
-
return openBlock(), createBlock(unref(NSpace), null, {
|
|
1275
|
-
default: withCtx(() => [_ctx.showPreview ? (openBlock(), createElementBlock("a", {
|
|
1276
|
-
key: 0,
|
|
1277
|
-
target: "_blank",
|
|
1278
|
-
href: previewUrl.value
|
|
1279
|
-
}, [createVNode(unref(NButton), {
|
|
1280
|
-
size: "small"
|
|
1281
|
-
}, {
|
|
1282
|
-
icon: withCtx(() => [createVNode(unref(NIcon), null, {
|
|
1283
|
-
default: withCtx(() => [_hoisted_2]),
|
|
1284
|
-
_: 1
|
|
1285
|
-
})]),
|
|
1286
|
-
_: 1
|
|
1287
|
-
})], 8, _hoisted_1)) : createCommentVNode("", true), _ctx.showExport ? (openBlock(), createBlock(unref(NPopover), {
|
|
1288
|
-
key: 1
|
|
1289
|
-
}, {
|
|
1290
|
-
trigger: withCtx(() => [createVNode(unref(NButton), {
|
|
1291
|
-
size: "small"
|
|
1292
|
-
}, {
|
|
1293
|
-
icon: withCtx(() => [createVNode(unref(NIcon), null, {
|
|
1294
|
-
default: withCtx(() => [_hoisted_3]),
|
|
1295
|
-
_: 1
|
|
1296
|
-
})]),
|
|
1297
|
-
_: 1
|
|
1298
|
-
})]),
|
|
1299
|
-
default: withCtx(() => [createVNode(unref(NSpace), {
|
|
1300
|
-
vertical: ""
|
|
1301
|
-
}, {
|
|
1302
|
-
default: withCtx(() => [createVNode(unref(NButton), {
|
|
1303
|
-
onClick: unref(exportZip).invoke,
|
|
1304
|
-
loading: unref(exportZip).loading
|
|
1305
|
-
}, {
|
|
1306
|
-
default: withCtx(() => [createTextVNode(" 下载-快照 ")]),
|
|
1307
|
-
_: 1
|
|
1308
|
-
}, 8, ["onClick", "loading"]), createVNode(unref(NButton), {
|
|
1309
|
-
onClick: unref(exportJpg).invoke,
|
|
1310
|
-
loading: unref(exportJpg).loading
|
|
1311
|
-
}, {
|
|
1312
|
-
default: withCtx(() => [createTextVNode(" 下载-图片 ")]),
|
|
1313
|
-
_: 1
|
|
1314
|
-
}, 8, ["onClick", "loading"])]),
|
|
1315
|
-
_: 1
|
|
1316
|
-
})]),
|
|
1317
|
-
_: 1
|
|
1318
|
-
})) : createCommentVNode("", true), _ctx.showShare ? (openBlock(), createBlock(unref(NPopover), {
|
|
1319
|
-
key: 2
|
|
1320
|
-
}, {
|
|
1321
|
-
trigger: withCtx(() => [createVNode(unref(NButton), {
|
|
1322
|
-
size: "small"
|
|
1323
|
-
}, {
|
|
1324
|
-
icon: withCtx(() => [createVNode(unref(NIcon), null, {
|
|
1325
|
-
default: withCtx(() => [_hoisted_4]),
|
|
1326
|
-
_: 1
|
|
1327
|
-
})]),
|
|
1328
|
-
_: 1
|
|
1329
|
-
})]),
|
|
1330
|
-
default: withCtx(() => [createVNode(unref(NSpace), {
|
|
1331
|
-
vertical: ""
|
|
1332
|
-
}, {
|
|
1333
|
-
default: withCtx(() => [unref(githubZipStorage)[_ctx.snapshot.id] ? (openBlock(), createBlock(unref(NButton), {
|
|
1334
|
-
key: 0,
|
|
1335
|
-
onClick: _cache[0] || (_cache[0] = ($event) => copy(unref(githubUrlToSelfUrl)(unref(githubZipStorage)[_ctx.snapshot.id])))
|
|
1336
|
-
}, {
|
|
1337
|
-
default: withCtx(() => [createTextVNode(" 复制链接-快照 ")]),
|
|
1338
|
-
_: 1
|
|
1339
|
-
})) : (openBlock(), createBlock(unref(NButton), {
|
|
1340
|
-
key: 1,
|
|
1341
|
-
onClick: unref(exportZipUrl).invoke,
|
|
1342
|
-
loading: unref(exportZipUrl).loading
|
|
1343
|
-
}, {
|
|
1344
|
-
default: withCtx(() => [createTextVNode(" 生成链接-快照 ")]),
|
|
1345
|
-
_: 1
|
|
1346
|
-
}, 8, ["onClick", "loading"])), unref(githubJpgStorage)[_ctx.snapshot.id] ? (openBlock(), createBlock(unref(NButton), {
|
|
1347
|
-
key: 2,
|
|
1348
|
-
onClick: _cache[1] || (_cache[1] = ($event) => copy(unref(githubUrlToSelfUrl)(unref(githubJpgStorage)[_ctx.snapshot.id])))
|
|
1349
|
-
}, {
|
|
1350
|
-
default: withCtx(() => [createTextVNode(" 复制链接-图片 ")]),
|
|
1351
|
-
_: 1
|
|
1352
|
-
})) : (openBlock(), createBlock(unref(NButton), {
|
|
1353
|
-
key: 3,
|
|
1354
|
-
onClick: unref(exportJpgUrl).invoke,
|
|
1355
|
-
loading: unref(exportJpgUrl).loading
|
|
1356
|
-
}, {
|
|
1357
|
-
default: withCtx(() => [createTextVNode(" 生成链接-图片 ")]),
|
|
1358
|
-
_: 1
|
|
1359
|
-
}, 8, ["onClick", "loading"]))]),
|
|
1360
|
-
_: 1
|
|
1361
|
-
})]),
|
|
1362
|
-
_: 1
|
|
1363
|
-
})) : createCommentVNode("", true), _ctx.showDelete ? (openBlock(), createBlock(unref(NButton), {
|
|
1364
|
-
key: 3,
|
|
1365
|
-
size: "small",
|
|
1366
|
-
onClick: deleteSnapshot
|
|
1367
|
-
}, {
|
|
1368
|
-
icon: withCtx(() => [createVNode(unref(NIcon), null, {
|
|
1369
|
-
default: withCtx(() => [_hoisted_5]),
|
|
1370
|
-
_: 1
|
|
1371
|
-
})]),
|
|
1372
|
-
_: 1
|
|
1373
|
-
})) : createCommentVNode("", true)]),
|
|
1374
|
-
_: 1
|
|
1375
|
-
});
|
|
1376
|
-
};
|
|
1377
|
-
}
|
|
1378
|
-
});
|
|
1379
|
-
export {
|
|
1380
|
-
_sfc_main as _,
|
|
1381
|
-
batchZipDownloadZip as a,
|
|
1382
|
-
batchJpgDownloadZip as b,
|
|
1383
|
-
batchCreateJpgUrl as c,
|
|
1384
|
-
batchCreateZipUrl as d,
|
|
1385
|
-
exportSnapshotAsJpgUrl as e,
|
|
1386
|
-
exportSnapshotAsZipUrl as f,
|
|
1387
|
-
showTextDLg as s
|
|
1388
|
-
};
|