wcz-test 6.24.4 → 6.24.6
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.
|
@@ -0,0 +1,3478 @@
|
|
|
1
|
+
import { c } from "react/compiler-runtime";
|
|
2
|
+
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import saveAs from "file-saver";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { uuidv7 } from "uuidv7";
|
|
6
|
+
import z__default from "zod";
|
|
7
|
+
import { F as FileMetaSchema } from "./FileMeta-G1oT3mYK.js";
|
|
8
|
+
import { t as toKebabCase, h as httpClient } from "./utils-MD9YwOtu.js";
|
|
9
|
+
import { c as clientEnv } from "./env-gsqZ6zZD.js";
|
|
10
|
+
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
11
|
+
function _typeof$8(o) {
|
|
12
|
+
"@babel/helpers - typeof";
|
|
13
|
+
return _typeof$8 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
|
|
14
|
+
return typeof o2;
|
|
15
|
+
} : function(o2) {
|
|
16
|
+
return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
|
|
17
|
+
}, _typeof$8(o);
|
|
18
|
+
}
|
|
19
|
+
function _createClass$8(Constructor, protoProps, staticProps) {
|
|
20
|
+
Object.defineProperty(Constructor, "prototype", { writable: false });
|
|
21
|
+
return Constructor;
|
|
22
|
+
}
|
|
23
|
+
function _classCallCheck$8(instance, Constructor) {
|
|
24
|
+
if (!(instance instanceof Constructor)) {
|
|
25
|
+
throw new TypeError("Cannot call a class as a function");
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function _callSuper$1(t, o, e) {
|
|
29
|
+
return o = _getPrototypeOf$1(o), _possibleConstructorReturn$1(t, _isNativeReflectConstruct$1() ? Reflect.construct(o, e || [], _getPrototypeOf$1(t).constructor) : o.apply(t, e));
|
|
30
|
+
}
|
|
31
|
+
function _possibleConstructorReturn$1(self2, call) {
|
|
32
|
+
if (call && (_typeof$8(call) === "object" || typeof call === "function")) {
|
|
33
|
+
return call;
|
|
34
|
+
} else if (call !== void 0) {
|
|
35
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
36
|
+
}
|
|
37
|
+
return _assertThisInitialized$1(self2);
|
|
38
|
+
}
|
|
39
|
+
function _assertThisInitialized$1(self2) {
|
|
40
|
+
if (self2 === void 0) {
|
|
41
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
42
|
+
}
|
|
43
|
+
return self2;
|
|
44
|
+
}
|
|
45
|
+
function _inherits$1(subClass, superClass) {
|
|
46
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
47
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
48
|
+
}
|
|
49
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } });
|
|
50
|
+
Object.defineProperty(subClass, "prototype", { writable: false });
|
|
51
|
+
if (superClass) _setPrototypeOf$1(subClass, superClass);
|
|
52
|
+
}
|
|
53
|
+
function _wrapNativeSuper(Class) {
|
|
54
|
+
var _cache = typeof Map === "function" ? /* @__PURE__ */ new Map() : void 0;
|
|
55
|
+
_wrapNativeSuper = function _wrapNativeSuper2(Class2) {
|
|
56
|
+
if (Class2 === null || !_isNativeFunction(Class2)) return Class2;
|
|
57
|
+
if (typeof Class2 !== "function") {
|
|
58
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
59
|
+
}
|
|
60
|
+
if (typeof _cache !== "undefined") {
|
|
61
|
+
if (_cache.has(Class2)) return _cache.get(Class2);
|
|
62
|
+
_cache.set(Class2, Wrapper);
|
|
63
|
+
}
|
|
64
|
+
function Wrapper() {
|
|
65
|
+
return _construct(Class2, arguments, _getPrototypeOf$1(this).constructor);
|
|
66
|
+
}
|
|
67
|
+
Wrapper.prototype = Object.create(Class2.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } });
|
|
68
|
+
return _setPrototypeOf$1(Wrapper, Class2);
|
|
69
|
+
};
|
|
70
|
+
return _wrapNativeSuper(Class);
|
|
71
|
+
}
|
|
72
|
+
function _construct(t, e, r) {
|
|
73
|
+
if (_isNativeReflectConstruct$1()) return Reflect.construct.apply(null, arguments);
|
|
74
|
+
var o = [null];
|
|
75
|
+
o.push.apply(o, e);
|
|
76
|
+
var p = new (t.bind.apply(t, o))();
|
|
77
|
+
return r && _setPrototypeOf$1(p, r.prototype), p;
|
|
78
|
+
}
|
|
79
|
+
function _isNativeReflectConstruct$1() {
|
|
80
|
+
try {
|
|
81
|
+
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
|
|
82
|
+
}));
|
|
83
|
+
} catch (t2) {
|
|
84
|
+
}
|
|
85
|
+
return (_isNativeReflectConstruct$1 = function _isNativeReflectConstruct2() {
|
|
86
|
+
return !!t;
|
|
87
|
+
})();
|
|
88
|
+
}
|
|
89
|
+
function _isNativeFunction(fn) {
|
|
90
|
+
try {
|
|
91
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
92
|
+
} catch (e) {
|
|
93
|
+
return typeof fn === "function";
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function _setPrototypeOf$1(o, p) {
|
|
97
|
+
_setPrototypeOf$1 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf2(o2, p2) {
|
|
98
|
+
o2.__proto__ = p2;
|
|
99
|
+
return o2;
|
|
100
|
+
};
|
|
101
|
+
return _setPrototypeOf$1(o, p);
|
|
102
|
+
}
|
|
103
|
+
function _getPrototypeOf$1(o) {
|
|
104
|
+
_getPrototypeOf$1 = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf2(o2) {
|
|
105
|
+
return o2.__proto__ || Object.getPrototypeOf(o2);
|
|
106
|
+
};
|
|
107
|
+
return _getPrototypeOf$1(o);
|
|
108
|
+
}
|
|
109
|
+
var DetailedError = /* @__PURE__ */ (function(_Error) {
|
|
110
|
+
function DetailedError2(message) {
|
|
111
|
+
var _this;
|
|
112
|
+
var causingErr = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : null;
|
|
113
|
+
var req = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : null;
|
|
114
|
+
var res = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : null;
|
|
115
|
+
_classCallCheck$8(this, DetailedError2);
|
|
116
|
+
_this = _callSuper$1(this, DetailedError2, [message]);
|
|
117
|
+
_this.originalRequest = req;
|
|
118
|
+
_this.originalResponse = res;
|
|
119
|
+
_this.causingError = causingErr;
|
|
120
|
+
if (causingErr != null) {
|
|
121
|
+
message += ", caused by ".concat(causingErr.toString());
|
|
122
|
+
}
|
|
123
|
+
if (req != null) {
|
|
124
|
+
var requestId = req.getHeader("X-Request-ID") || "n/a";
|
|
125
|
+
var method = req.getMethod();
|
|
126
|
+
var url = req.getURL();
|
|
127
|
+
var status = res ? res.getStatus() : "n/a";
|
|
128
|
+
var body = res ? res.getBody() || "" : "n/a";
|
|
129
|
+
message += ", originated from request (method: ".concat(method, ", url: ").concat(url, ", response code: ").concat(status, ", response text: ").concat(body, ", request id: ").concat(requestId, ")");
|
|
130
|
+
}
|
|
131
|
+
_this.message = message;
|
|
132
|
+
return _this;
|
|
133
|
+
}
|
|
134
|
+
_inherits$1(DetailedError2, _Error);
|
|
135
|
+
return _createClass$8(DetailedError2);
|
|
136
|
+
})(/* @__PURE__ */ _wrapNativeSuper(Error));
|
|
137
|
+
function log(msg) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
function _typeof$7(o) {
|
|
141
|
+
"@babel/helpers - typeof";
|
|
142
|
+
return _typeof$7 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
|
|
143
|
+
return typeof o2;
|
|
144
|
+
} : function(o2) {
|
|
145
|
+
return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
|
|
146
|
+
}, _typeof$7(o);
|
|
147
|
+
}
|
|
148
|
+
function _classCallCheck$7(instance, Constructor) {
|
|
149
|
+
if (!(instance instanceof Constructor)) {
|
|
150
|
+
throw new TypeError("Cannot call a class as a function");
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
function _defineProperties$7(target, props) {
|
|
154
|
+
for (var i = 0; i < props.length; i++) {
|
|
155
|
+
var descriptor = props[i];
|
|
156
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
157
|
+
descriptor.configurable = true;
|
|
158
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
159
|
+
Object.defineProperty(target, _toPropertyKey$7(descriptor.key), descriptor);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
function _createClass$7(Constructor, protoProps, staticProps) {
|
|
163
|
+
if (protoProps) _defineProperties$7(Constructor.prototype, protoProps);
|
|
164
|
+
Object.defineProperty(Constructor, "prototype", { writable: false });
|
|
165
|
+
return Constructor;
|
|
166
|
+
}
|
|
167
|
+
function _toPropertyKey$7(t) {
|
|
168
|
+
var i = _toPrimitive$7(t, "string");
|
|
169
|
+
return "symbol" == _typeof$7(i) ? i : i + "";
|
|
170
|
+
}
|
|
171
|
+
function _toPrimitive$7(t, r) {
|
|
172
|
+
if ("object" != _typeof$7(t) || !t) return t;
|
|
173
|
+
var e = t[Symbol.toPrimitive];
|
|
174
|
+
if (void 0 !== e) {
|
|
175
|
+
var i = e.call(t, r);
|
|
176
|
+
if ("object" != _typeof$7(i)) return i;
|
|
177
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
178
|
+
}
|
|
179
|
+
return String(t);
|
|
180
|
+
}
|
|
181
|
+
var NoopUrlStorage = /* @__PURE__ */ (function() {
|
|
182
|
+
function NoopUrlStorage2() {
|
|
183
|
+
_classCallCheck$7(this, NoopUrlStorage2);
|
|
184
|
+
}
|
|
185
|
+
return _createClass$7(NoopUrlStorage2, [{
|
|
186
|
+
key: "listAllUploads",
|
|
187
|
+
value: function listAllUploads() {
|
|
188
|
+
return Promise.resolve([]);
|
|
189
|
+
}
|
|
190
|
+
}, {
|
|
191
|
+
key: "findUploadsByFingerprint",
|
|
192
|
+
value: function findUploadsByFingerprint(_fingerprint) {
|
|
193
|
+
return Promise.resolve([]);
|
|
194
|
+
}
|
|
195
|
+
}, {
|
|
196
|
+
key: "removeUpload",
|
|
197
|
+
value: function removeUpload(_urlStorageKey) {
|
|
198
|
+
return Promise.resolve();
|
|
199
|
+
}
|
|
200
|
+
}, {
|
|
201
|
+
key: "addUpload",
|
|
202
|
+
value: function addUpload(_fingerprint, _upload) {
|
|
203
|
+
return Promise.resolve(null);
|
|
204
|
+
}
|
|
205
|
+
}]);
|
|
206
|
+
})();
|
|
207
|
+
const version = "3.7.8";
|
|
208
|
+
const VERSION = version;
|
|
209
|
+
const _hasBuffer = typeof Buffer === "function";
|
|
210
|
+
const _TD = typeof TextDecoder === "function" ? new TextDecoder() : void 0;
|
|
211
|
+
const _TE = typeof TextEncoder === "function" ? new TextEncoder() : void 0;
|
|
212
|
+
const b64ch = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
|
213
|
+
const b64chs = Array.prototype.slice.call(b64ch);
|
|
214
|
+
const b64tab = ((a) => {
|
|
215
|
+
let tab = {};
|
|
216
|
+
a.forEach((c2, i) => tab[c2] = i);
|
|
217
|
+
return tab;
|
|
218
|
+
})(b64chs);
|
|
219
|
+
const b64re = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;
|
|
220
|
+
const _fromCC = String.fromCharCode.bind(String);
|
|
221
|
+
const _U8Afrom = typeof Uint8Array.from === "function" ? Uint8Array.from.bind(Uint8Array) : (it) => new Uint8Array(Array.prototype.slice.call(it, 0));
|
|
222
|
+
const _mkUriSafe = (src) => src.replace(/=/g, "").replace(/[+\/]/g, (m0) => m0 == "+" ? "-" : "_");
|
|
223
|
+
const _tidyB64 = (s) => s.replace(/[^A-Za-z0-9\+\/]/g, "");
|
|
224
|
+
const btoaPolyfill = (bin) => {
|
|
225
|
+
let u32, c0, c1, c2, asc = "";
|
|
226
|
+
const pad = bin.length % 3;
|
|
227
|
+
for (let i = 0; i < bin.length; ) {
|
|
228
|
+
if ((c0 = bin.charCodeAt(i++)) > 255 || (c1 = bin.charCodeAt(i++)) > 255 || (c2 = bin.charCodeAt(i++)) > 255)
|
|
229
|
+
throw new TypeError("invalid character found");
|
|
230
|
+
u32 = c0 << 16 | c1 << 8 | c2;
|
|
231
|
+
asc += b64chs[u32 >> 18 & 63] + b64chs[u32 >> 12 & 63] + b64chs[u32 >> 6 & 63] + b64chs[u32 & 63];
|
|
232
|
+
}
|
|
233
|
+
return pad ? asc.slice(0, pad - 3) + "===".substring(pad) : asc;
|
|
234
|
+
};
|
|
235
|
+
const _btoa = typeof btoa === "function" ? (bin) => btoa(bin) : _hasBuffer ? (bin) => Buffer.from(bin, "binary").toString("base64") : btoaPolyfill;
|
|
236
|
+
const _fromUint8Array = _hasBuffer ? (u8a) => Buffer.from(u8a).toString("base64") : (u8a) => {
|
|
237
|
+
const maxargs = 4096;
|
|
238
|
+
let strs = [];
|
|
239
|
+
for (let i = 0, l = u8a.length; i < l; i += maxargs) {
|
|
240
|
+
strs.push(_fromCC.apply(null, u8a.subarray(i, i + maxargs)));
|
|
241
|
+
}
|
|
242
|
+
return _btoa(strs.join(""));
|
|
243
|
+
};
|
|
244
|
+
const fromUint8Array = (u8a, urlsafe = false) => urlsafe ? _mkUriSafe(_fromUint8Array(u8a)) : _fromUint8Array(u8a);
|
|
245
|
+
const cb_utob = (c2) => {
|
|
246
|
+
if (c2.length < 2) {
|
|
247
|
+
var cc = c2.charCodeAt(0);
|
|
248
|
+
return cc < 128 ? c2 : cc < 2048 ? _fromCC(192 | cc >>> 6) + _fromCC(128 | cc & 63) : _fromCC(224 | cc >>> 12 & 15) + _fromCC(128 | cc >>> 6 & 63) + _fromCC(128 | cc & 63);
|
|
249
|
+
} else {
|
|
250
|
+
var cc = 65536 + (c2.charCodeAt(0) - 55296) * 1024 + (c2.charCodeAt(1) - 56320);
|
|
251
|
+
return _fromCC(240 | cc >>> 18 & 7) + _fromCC(128 | cc >>> 12 & 63) + _fromCC(128 | cc >>> 6 & 63) + _fromCC(128 | cc & 63);
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
const re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;
|
|
255
|
+
const utob = (u) => u.replace(re_utob, cb_utob);
|
|
256
|
+
const _encode = _hasBuffer ? (s) => Buffer.from(s, "utf8").toString("base64") : _TE ? (s) => _fromUint8Array(_TE.encode(s)) : (s) => _btoa(utob(s));
|
|
257
|
+
const encode = (src, urlsafe = false) => urlsafe ? _mkUriSafe(_encode(src)) : _encode(src);
|
|
258
|
+
const encodeURI = (src) => encode(src, true);
|
|
259
|
+
const re_btou = /[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g;
|
|
260
|
+
const cb_btou = (cccc) => {
|
|
261
|
+
switch (cccc.length) {
|
|
262
|
+
case 4:
|
|
263
|
+
var cp = (7 & cccc.charCodeAt(0)) << 18 | (63 & cccc.charCodeAt(1)) << 12 | (63 & cccc.charCodeAt(2)) << 6 | 63 & cccc.charCodeAt(3), offset = cp - 65536;
|
|
264
|
+
return _fromCC((offset >>> 10) + 55296) + _fromCC((offset & 1023) + 56320);
|
|
265
|
+
case 3:
|
|
266
|
+
return _fromCC((15 & cccc.charCodeAt(0)) << 12 | (63 & cccc.charCodeAt(1)) << 6 | 63 & cccc.charCodeAt(2));
|
|
267
|
+
default:
|
|
268
|
+
return _fromCC((31 & cccc.charCodeAt(0)) << 6 | 63 & cccc.charCodeAt(1));
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
const btou = (b) => b.replace(re_btou, cb_btou);
|
|
272
|
+
const atobPolyfill = (asc) => {
|
|
273
|
+
asc = asc.replace(/\s+/g, "");
|
|
274
|
+
if (!b64re.test(asc))
|
|
275
|
+
throw new TypeError("malformed base64.");
|
|
276
|
+
asc += "==".slice(2 - (asc.length & 3));
|
|
277
|
+
let u24, r1, r2;
|
|
278
|
+
let binArray = [];
|
|
279
|
+
for (let i = 0; i < asc.length; ) {
|
|
280
|
+
u24 = b64tab[asc.charAt(i++)] << 18 | b64tab[asc.charAt(i++)] << 12 | (r1 = b64tab[asc.charAt(i++)]) << 6 | (r2 = b64tab[asc.charAt(i++)]);
|
|
281
|
+
if (r1 === 64) {
|
|
282
|
+
binArray.push(_fromCC(u24 >> 16 & 255));
|
|
283
|
+
} else if (r2 === 64) {
|
|
284
|
+
binArray.push(_fromCC(u24 >> 16 & 255, u24 >> 8 & 255));
|
|
285
|
+
} else {
|
|
286
|
+
binArray.push(_fromCC(u24 >> 16 & 255, u24 >> 8 & 255, u24 & 255));
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
return binArray.join("");
|
|
290
|
+
};
|
|
291
|
+
const _atob = typeof atob === "function" ? (asc) => atob(_tidyB64(asc)) : _hasBuffer ? (asc) => Buffer.from(asc, "base64").toString("binary") : atobPolyfill;
|
|
292
|
+
const _toUint8Array = _hasBuffer ? (a) => _U8Afrom(Buffer.from(a, "base64")) : (a) => _U8Afrom(_atob(a).split("").map((c2) => c2.charCodeAt(0)));
|
|
293
|
+
const toUint8Array = (a) => _toUint8Array(_unURI(a));
|
|
294
|
+
const _decode = _hasBuffer ? (a) => Buffer.from(a, "base64").toString("utf8") : _TD ? (a) => _TD.decode(_toUint8Array(a)) : (a) => btou(_atob(a));
|
|
295
|
+
const _unURI = (a) => _tidyB64(a.replace(/[-_]/g, (m0) => m0 == "-" ? "+" : "/"));
|
|
296
|
+
const decode = (src) => _decode(_unURI(src));
|
|
297
|
+
const isValid = (src) => {
|
|
298
|
+
if (typeof src !== "string")
|
|
299
|
+
return false;
|
|
300
|
+
const s = src.replace(/\s+/g, "").replace(/={0,2}$/, "");
|
|
301
|
+
return !/[^\s0-9a-zA-Z\+/]/.test(s) || !/[^\s0-9a-zA-Z\-_]/.test(s);
|
|
302
|
+
};
|
|
303
|
+
const _noEnum = (v) => {
|
|
304
|
+
return {
|
|
305
|
+
value: v,
|
|
306
|
+
enumerable: false,
|
|
307
|
+
writable: true,
|
|
308
|
+
configurable: true
|
|
309
|
+
};
|
|
310
|
+
};
|
|
311
|
+
const extendString = function() {
|
|
312
|
+
const _add = (name, body) => Object.defineProperty(String.prototype, name, _noEnum(body));
|
|
313
|
+
_add("fromBase64", function() {
|
|
314
|
+
return decode(this);
|
|
315
|
+
});
|
|
316
|
+
_add("toBase64", function(urlsafe) {
|
|
317
|
+
return encode(this, urlsafe);
|
|
318
|
+
});
|
|
319
|
+
_add("toBase64URI", function() {
|
|
320
|
+
return encode(this, true);
|
|
321
|
+
});
|
|
322
|
+
_add("toBase64URL", function() {
|
|
323
|
+
return encode(this, true);
|
|
324
|
+
});
|
|
325
|
+
_add("toUint8Array", function() {
|
|
326
|
+
return toUint8Array(this);
|
|
327
|
+
});
|
|
328
|
+
};
|
|
329
|
+
const extendUint8Array = function() {
|
|
330
|
+
const _add = (name, body) => Object.defineProperty(Uint8Array.prototype, name, _noEnum(body));
|
|
331
|
+
_add("toBase64", function(urlsafe) {
|
|
332
|
+
return fromUint8Array(this, urlsafe);
|
|
333
|
+
});
|
|
334
|
+
_add("toBase64URI", function() {
|
|
335
|
+
return fromUint8Array(this, true);
|
|
336
|
+
});
|
|
337
|
+
_add("toBase64URL", function() {
|
|
338
|
+
return fromUint8Array(this, true);
|
|
339
|
+
});
|
|
340
|
+
};
|
|
341
|
+
const extendBuiltins = () => {
|
|
342
|
+
extendString();
|
|
343
|
+
extendUint8Array();
|
|
344
|
+
};
|
|
345
|
+
const gBase64 = {
|
|
346
|
+
version,
|
|
347
|
+
VERSION,
|
|
348
|
+
atob: _atob,
|
|
349
|
+
atobPolyfill,
|
|
350
|
+
btoa: _btoa,
|
|
351
|
+
btoaPolyfill,
|
|
352
|
+
fromBase64: decode,
|
|
353
|
+
toBase64: encode,
|
|
354
|
+
encode,
|
|
355
|
+
encodeURI,
|
|
356
|
+
encodeURL: encodeURI,
|
|
357
|
+
utob,
|
|
358
|
+
btou,
|
|
359
|
+
decode,
|
|
360
|
+
isValid,
|
|
361
|
+
fromUint8Array,
|
|
362
|
+
toUint8Array,
|
|
363
|
+
extendString,
|
|
364
|
+
extendUint8Array,
|
|
365
|
+
extendBuiltins
|
|
366
|
+
};
|
|
367
|
+
var requiresPort;
|
|
368
|
+
var hasRequiredRequiresPort;
|
|
369
|
+
function requireRequiresPort() {
|
|
370
|
+
if (hasRequiredRequiresPort) return requiresPort;
|
|
371
|
+
hasRequiredRequiresPort = 1;
|
|
372
|
+
requiresPort = function required(port, protocol) {
|
|
373
|
+
protocol = protocol.split(":")[0];
|
|
374
|
+
port = +port;
|
|
375
|
+
if (!port) return false;
|
|
376
|
+
switch (protocol) {
|
|
377
|
+
case "http":
|
|
378
|
+
case "ws":
|
|
379
|
+
return port !== 80;
|
|
380
|
+
case "https":
|
|
381
|
+
case "wss":
|
|
382
|
+
return port !== 443;
|
|
383
|
+
case "ftp":
|
|
384
|
+
return port !== 21;
|
|
385
|
+
case "gopher":
|
|
386
|
+
return port !== 70;
|
|
387
|
+
case "file":
|
|
388
|
+
return false;
|
|
389
|
+
}
|
|
390
|
+
return port !== 0;
|
|
391
|
+
};
|
|
392
|
+
return requiresPort;
|
|
393
|
+
}
|
|
394
|
+
var querystringify = {};
|
|
395
|
+
var hasRequiredQuerystringify;
|
|
396
|
+
function requireQuerystringify() {
|
|
397
|
+
if (hasRequiredQuerystringify) return querystringify;
|
|
398
|
+
hasRequiredQuerystringify = 1;
|
|
399
|
+
var has = Object.prototype.hasOwnProperty, undef;
|
|
400
|
+
function decode2(input) {
|
|
401
|
+
try {
|
|
402
|
+
return decodeURIComponent(input.replace(/\+/g, " "));
|
|
403
|
+
} catch (e) {
|
|
404
|
+
return null;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
function encode2(input) {
|
|
408
|
+
try {
|
|
409
|
+
return encodeURIComponent(input);
|
|
410
|
+
} catch (e) {
|
|
411
|
+
return null;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
function querystring(query) {
|
|
415
|
+
var parser = /([^=?#&]+)=?([^&]*)/g, result = {}, part;
|
|
416
|
+
while (part = parser.exec(query)) {
|
|
417
|
+
var key = decode2(part[1]), value = decode2(part[2]);
|
|
418
|
+
if (key === null || value === null || key in result) continue;
|
|
419
|
+
result[key] = value;
|
|
420
|
+
}
|
|
421
|
+
return result;
|
|
422
|
+
}
|
|
423
|
+
function querystringify$1(obj, prefix) {
|
|
424
|
+
prefix = prefix || "";
|
|
425
|
+
var pairs = [], value, key;
|
|
426
|
+
if ("string" !== typeof prefix) prefix = "?";
|
|
427
|
+
for (key in obj) {
|
|
428
|
+
if (has.call(obj, key)) {
|
|
429
|
+
value = obj[key];
|
|
430
|
+
if (!value && (value === null || value === undef || isNaN(value))) {
|
|
431
|
+
value = "";
|
|
432
|
+
}
|
|
433
|
+
key = encode2(key);
|
|
434
|
+
value = encode2(value);
|
|
435
|
+
if (key === null || value === null) continue;
|
|
436
|
+
pairs.push(key + "=" + value);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
return pairs.length ? prefix + pairs.join("&") : "";
|
|
440
|
+
}
|
|
441
|
+
querystringify.stringify = querystringify$1;
|
|
442
|
+
querystringify.parse = querystring;
|
|
443
|
+
return querystringify;
|
|
444
|
+
}
|
|
445
|
+
var urlParse;
|
|
446
|
+
var hasRequiredUrlParse;
|
|
447
|
+
function requireUrlParse() {
|
|
448
|
+
if (hasRequiredUrlParse) return urlParse;
|
|
449
|
+
hasRequiredUrlParse = 1;
|
|
450
|
+
var required = requireRequiresPort(), qs = requireQuerystringify(), controlOrWhitespace = /^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/, CRHTLF = /[\n\r\t]/g, slashes = /^[A-Za-z][A-Za-z0-9+-.]*:\/\//, port = /:\d+$/, protocolre = /^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i, windowsDriveLetter = /^[a-zA-Z]:/;
|
|
451
|
+
function trimLeft(str) {
|
|
452
|
+
return (str ? str : "").toString().replace(controlOrWhitespace, "");
|
|
453
|
+
}
|
|
454
|
+
var rules = [
|
|
455
|
+
["#", "hash"],
|
|
456
|
+
// Extract from the back.
|
|
457
|
+
["?", "query"],
|
|
458
|
+
// Extract from the back.
|
|
459
|
+
function sanitize(address, url) {
|
|
460
|
+
return isSpecial(url.protocol) ? address.replace(/\\/g, "/") : address;
|
|
461
|
+
},
|
|
462
|
+
["/", "pathname"],
|
|
463
|
+
// Extract from the back.
|
|
464
|
+
["@", "auth", 1],
|
|
465
|
+
// Extract from the front.
|
|
466
|
+
[NaN, "host", void 0, 1, 1],
|
|
467
|
+
// Set left over value.
|
|
468
|
+
[/:(\d*)$/, "port", void 0, 1],
|
|
469
|
+
// RegExp the back.
|
|
470
|
+
[NaN, "hostname", void 0, 1, 1]
|
|
471
|
+
// Set left over.
|
|
472
|
+
];
|
|
473
|
+
var ignore = { hash: 1, query: 1 };
|
|
474
|
+
function lolcation(loc) {
|
|
475
|
+
var globalVar;
|
|
476
|
+
if (typeof window !== "undefined") globalVar = window;
|
|
477
|
+
else if (typeof commonjsGlobal !== "undefined") globalVar = commonjsGlobal;
|
|
478
|
+
else if (typeof self !== "undefined") globalVar = self;
|
|
479
|
+
else globalVar = {};
|
|
480
|
+
var location = globalVar.location || {};
|
|
481
|
+
loc = loc || location;
|
|
482
|
+
var finaldestination = {}, type = typeof loc, key;
|
|
483
|
+
if ("blob:" === loc.protocol) {
|
|
484
|
+
finaldestination = new Url(unescape(loc.pathname), {});
|
|
485
|
+
} else if ("string" === type) {
|
|
486
|
+
finaldestination = new Url(loc, {});
|
|
487
|
+
for (key in ignore) delete finaldestination[key];
|
|
488
|
+
} else if ("object" === type) {
|
|
489
|
+
for (key in loc) {
|
|
490
|
+
if (key in ignore) continue;
|
|
491
|
+
finaldestination[key] = loc[key];
|
|
492
|
+
}
|
|
493
|
+
if (finaldestination.slashes === void 0) {
|
|
494
|
+
finaldestination.slashes = slashes.test(loc.href);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
return finaldestination;
|
|
498
|
+
}
|
|
499
|
+
function isSpecial(scheme) {
|
|
500
|
+
return scheme === "file:" || scheme === "ftp:" || scheme === "http:" || scheme === "https:" || scheme === "ws:" || scheme === "wss:";
|
|
501
|
+
}
|
|
502
|
+
function extractProtocol(address, location) {
|
|
503
|
+
address = trimLeft(address);
|
|
504
|
+
address = address.replace(CRHTLF, "");
|
|
505
|
+
location = location || {};
|
|
506
|
+
var match = protocolre.exec(address);
|
|
507
|
+
var protocol = match[1] ? match[1].toLowerCase() : "";
|
|
508
|
+
var forwardSlashes = !!match[2];
|
|
509
|
+
var otherSlashes = !!match[3];
|
|
510
|
+
var slashesCount = 0;
|
|
511
|
+
var rest;
|
|
512
|
+
if (forwardSlashes) {
|
|
513
|
+
if (otherSlashes) {
|
|
514
|
+
rest = match[2] + match[3] + match[4];
|
|
515
|
+
slashesCount = match[2].length + match[3].length;
|
|
516
|
+
} else {
|
|
517
|
+
rest = match[2] + match[4];
|
|
518
|
+
slashesCount = match[2].length;
|
|
519
|
+
}
|
|
520
|
+
} else {
|
|
521
|
+
if (otherSlashes) {
|
|
522
|
+
rest = match[3] + match[4];
|
|
523
|
+
slashesCount = match[3].length;
|
|
524
|
+
} else {
|
|
525
|
+
rest = match[4];
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
if (protocol === "file:") {
|
|
529
|
+
if (slashesCount >= 2) {
|
|
530
|
+
rest = rest.slice(2);
|
|
531
|
+
}
|
|
532
|
+
} else if (isSpecial(protocol)) {
|
|
533
|
+
rest = match[4];
|
|
534
|
+
} else if (protocol) {
|
|
535
|
+
if (forwardSlashes) {
|
|
536
|
+
rest = rest.slice(2);
|
|
537
|
+
}
|
|
538
|
+
} else if (slashesCount >= 2 && isSpecial(location.protocol)) {
|
|
539
|
+
rest = match[4];
|
|
540
|
+
}
|
|
541
|
+
return {
|
|
542
|
+
protocol,
|
|
543
|
+
slashes: forwardSlashes || isSpecial(protocol),
|
|
544
|
+
slashesCount,
|
|
545
|
+
rest
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
function resolve(relative, base) {
|
|
549
|
+
if (relative === "") return base;
|
|
550
|
+
var path = (base || "/").split("/").slice(0, -1).concat(relative.split("/")), i = path.length, last = path[i - 1], unshift = false, up = 0;
|
|
551
|
+
while (i--) {
|
|
552
|
+
if (path[i] === ".") {
|
|
553
|
+
path.splice(i, 1);
|
|
554
|
+
} else if (path[i] === "..") {
|
|
555
|
+
path.splice(i, 1);
|
|
556
|
+
up++;
|
|
557
|
+
} else if (up) {
|
|
558
|
+
if (i === 0) unshift = true;
|
|
559
|
+
path.splice(i, 1);
|
|
560
|
+
up--;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
if (unshift) path.unshift("");
|
|
564
|
+
if (last === "." || last === "..") path.push("");
|
|
565
|
+
return path.join("/");
|
|
566
|
+
}
|
|
567
|
+
function Url(address, location, parser) {
|
|
568
|
+
address = trimLeft(address);
|
|
569
|
+
address = address.replace(CRHTLF, "");
|
|
570
|
+
if (!(this instanceof Url)) {
|
|
571
|
+
return new Url(address, location, parser);
|
|
572
|
+
}
|
|
573
|
+
var relative, extracted, parse, instruction, index, key, instructions = rules.slice(), type = typeof location, url = this, i = 0;
|
|
574
|
+
if ("object" !== type && "string" !== type) {
|
|
575
|
+
parser = location;
|
|
576
|
+
location = null;
|
|
577
|
+
}
|
|
578
|
+
if (parser && "function" !== typeof parser) parser = qs.parse;
|
|
579
|
+
location = lolcation(location);
|
|
580
|
+
extracted = extractProtocol(address || "", location);
|
|
581
|
+
relative = !extracted.protocol && !extracted.slashes;
|
|
582
|
+
url.slashes = extracted.slashes || relative && location.slashes;
|
|
583
|
+
url.protocol = extracted.protocol || location.protocol || "";
|
|
584
|
+
address = extracted.rest;
|
|
585
|
+
if (extracted.protocol === "file:" && (extracted.slashesCount !== 2 || windowsDriveLetter.test(address)) || !extracted.slashes && (extracted.protocol || extracted.slashesCount < 2 || !isSpecial(url.protocol))) {
|
|
586
|
+
instructions[3] = [/(.*)/, "pathname"];
|
|
587
|
+
}
|
|
588
|
+
for (; i < instructions.length; i++) {
|
|
589
|
+
instruction = instructions[i];
|
|
590
|
+
if (typeof instruction === "function") {
|
|
591
|
+
address = instruction(address, url);
|
|
592
|
+
continue;
|
|
593
|
+
}
|
|
594
|
+
parse = instruction[0];
|
|
595
|
+
key = instruction[1];
|
|
596
|
+
if (parse !== parse) {
|
|
597
|
+
url[key] = address;
|
|
598
|
+
} else if ("string" === typeof parse) {
|
|
599
|
+
index = parse === "@" ? address.lastIndexOf(parse) : address.indexOf(parse);
|
|
600
|
+
if (~index) {
|
|
601
|
+
if ("number" === typeof instruction[2]) {
|
|
602
|
+
url[key] = address.slice(0, index);
|
|
603
|
+
address = address.slice(index + instruction[2]);
|
|
604
|
+
} else {
|
|
605
|
+
url[key] = address.slice(index);
|
|
606
|
+
address = address.slice(0, index);
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
} else if (index = parse.exec(address)) {
|
|
610
|
+
url[key] = index[1];
|
|
611
|
+
address = address.slice(0, index.index);
|
|
612
|
+
}
|
|
613
|
+
url[key] = url[key] || (relative && instruction[3] ? location[key] || "" : "");
|
|
614
|
+
if (instruction[4]) url[key] = url[key].toLowerCase();
|
|
615
|
+
}
|
|
616
|
+
if (parser) url.query = parser(url.query);
|
|
617
|
+
if (relative && location.slashes && url.pathname.charAt(0) !== "/" && (url.pathname !== "" || location.pathname !== "")) {
|
|
618
|
+
url.pathname = resolve(url.pathname, location.pathname);
|
|
619
|
+
}
|
|
620
|
+
if (url.pathname.charAt(0) !== "/" && isSpecial(url.protocol)) {
|
|
621
|
+
url.pathname = "/" + url.pathname;
|
|
622
|
+
}
|
|
623
|
+
if (!required(url.port, url.protocol)) {
|
|
624
|
+
url.host = url.hostname;
|
|
625
|
+
url.port = "";
|
|
626
|
+
}
|
|
627
|
+
url.username = url.password = "";
|
|
628
|
+
if (url.auth) {
|
|
629
|
+
index = url.auth.indexOf(":");
|
|
630
|
+
if (~index) {
|
|
631
|
+
url.username = url.auth.slice(0, index);
|
|
632
|
+
url.username = encodeURIComponent(decodeURIComponent(url.username));
|
|
633
|
+
url.password = url.auth.slice(index + 1);
|
|
634
|
+
url.password = encodeURIComponent(decodeURIComponent(url.password));
|
|
635
|
+
} else {
|
|
636
|
+
url.username = encodeURIComponent(decodeURIComponent(url.auth));
|
|
637
|
+
}
|
|
638
|
+
url.auth = url.password ? url.username + ":" + url.password : url.username;
|
|
639
|
+
}
|
|
640
|
+
url.origin = url.protocol !== "file:" && isSpecial(url.protocol) && url.host ? url.protocol + "//" + url.host : "null";
|
|
641
|
+
url.href = url.toString();
|
|
642
|
+
}
|
|
643
|
+
function set(part, value, fn) {
|
|
644
|
+
var url = this;
|
|
645
|
+
switch (part) {
|
|
646
|
+
case "query":
|
|
647
|
+
if ("string" === typeof value && value.length) {
|
|
648
|
+
value = (fn || qs.parse)(value);
|
|
649
|
+
}
|
|
650
|
+
url[part] = value;
|
|
651
|
+
break;
|
|
652
|
+
case "port":
|
|
653
|
+
url[part] = value;
|
|
654
|
+
if (!required(value, url.protocol)) {
|
|
655
|
+
url.host = url.hostname;
|
|
656
|
+
url[part] = "";
|
|
657
|
+
} else if (value) {
|
|
658
|
+
url.host = url.hostname + ":" + value;
|
|
659
|
+
}
|
|
660
|
+
break;
|
|
661
|
+
case "hostname":
|
|
662
|
+
url[part] = value;
|
|
663
|
+
if (url.port) value += ":" + url.port;
|
|
664
|
+
url.host = value;
|
|
665
|
+
break;
|
|
666
|
+
case "host":
|
|
667
|
+
url[part] = value;
|
|
668
|
+
if (port.test(value)) {
|
|
669
|
+
value = value.split(":");
|
|
670
|
+
url.port = value.pop();
|
|
671
|
+
url.hostname = value.join(":");
|
|
672
|
+
} else {
|
|
673
|
+
url.hostname = value;
|
|
674
|
+
url.port = "";
|
|
675
|
+
}
|
|
676
|
+
break;
|
|
677
|
+
case "protocol":
|
|
678
|
+
url.protocol = value.toLowerCase();
|
|
679
|
+
url.slashes = !fn;
|
|
680
|
+
break;
|
|
681
|
+
case "pathname":
|
|
682
|
+
case "hash":
|
|
683
|
+
if (value) {
|
|
684
|
+
var char = part === "pathname" ? "/" : "#";
|
|
685
|
+
url[part] = value.charAt(0) !== char ? char + value : value;
|
|
686
|
+
} else {
|
|
687
|
+
url[part] = value;
|
|
688
|
+
}
|
|
689
|
+
break;
|
|
690
|
+
case "username":
|
|
691
|
+
case "password":
|
|
692
|
+
url[part] = encodeURIComponent(value);
|
|
693
|
+
break;
|
|
694
|
+
case "auth":
|
|
695
|
+
var index = value.indexOf(":");
|
|
696
|
+
if (~index) {
|
|
697
|
+
url.username = value.slice(0, index);
|
|
698
|
+
url.username = encodeURIComponent(decodeURIComponent(url.username));
|
|
699
|
+
url.password = value.slice(index + 1);
|
|
700
|
+
url.password = encodeURIComponent(decodeURIComponent(url.password));
|
|
701
|
+
} else {
|
|
702
|
+
url.username = encodeURIComponent(decodeURIComponent(value));
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
for (var i = 0; i < rules.length; i++) {
|
|
706
|
+
var ins = rules[i];
|
|
707
|
+
if (ins[4]) url[ins[1]] = url[ins[1]].toLowerCase();
|
|
708
|
+
}
|
|
709
|
+
url.auth = url.password ? url.username + ":" + url.password : url.username;
|
|
710
|
+
url.origin = url.protocol !== "file:" && isSpecial(url.protocol) && url.host ? url.protocol + "//" + url.host : "null";
|
|
711
|
+
url.href = url.toString();
|
|
712
|
+
return url;
|
|
713
|
+
}
|
|
714
|
+
function toString(stringify) {
|
|
715
|
+
if (!stringify || "function" !== typeof stringify) stringify = qs.stringify;
|
|
716
|
+
var query, url = this, host = url.host, protocol = url.protocol;
|
|
717
|
+
if (protocol && protocol.charAt(protocol.length - 1) !== ":") protocol += ":";
|
|
718
|
+
var result = protocol + (url.protocol && url.slashes || isSpecial(url.protocol) ? "//" : "");
|
|
719
|
+
if (url.username) {
|
|
720
|
+
result += url.username;
|
|
721
|
+
if (url.password) result += ":" + url.password;
|
|
722
|
+
result += "@";
|
|
723
|
+
} else if (url.password) {
|
|
724
|
+
result += ":" + url.password;
|
|
725
|
+
result += "@";
|
|
726
|
+
} else if (url.protocol !== "file:" && isSpecial(url.protocol) && !host && url.pathname !== "/") {
|
|
727
|
+
result += "@";
|
|
728
|
+
}
|
|
729
|
+
if (host[host.length - 1] === ":" || port.test(url.hostname) && !url.port) {
|
|
730
|
+
host += ":";
|
|
731
|
+
}
|
|
732
|
+
result += host + url.pathname;
|
|
733
|
+
query = "object" === typeof url.query ? stringify(url.query) : url.query;
|
|
734
|
+
if (query) result += "?" !== query.charAt(0) ? "?" + query : query;
|
|
735
|
+
if (url.hash) result += url.hash;
|
|
736
|
+
return result;
|
|
737
|
+
}
|
|
738
|
+
Url.prototype = { set, toString };
|
|
739
|
+
Url.extractProtocol = extractProtocol;
|
|
740
|
+
Url.location = lolcation;
|
|
741
|
+
Url.trimLeft = trimLeft;
|
|
742
|
+
Url.qs = qs;
|
|
743
|
+
urlParse = Url;
|
|
744
|
+
return urlParse;
|
|
745
|
+
}
|
|
746
|
+
var urlParseExports = requireUrlParse();
|
|
747
|
+
function uuid() {
|
|
748
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c2) {
|
|
749
|
+
var r = Math.random() * 16 | 0;
|
|
750
|
+
var v = c2 === "x" ? r : r & 3 | 8;
|
|
751
|
+
return v.toString(16);
|
|
752
|
+
});
|
|
753
|
+
}
|
|
754
|
+
function _regeneratorRuntime$1() {
|
|
755
|
+
_regeneratorRuntime$1 = function _regeneratorRuntime2() {
|
|
756
|
+
return e;
|
|
757
|
+
};
|
|
758
|
+
var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function(t2, e2, r2) {
|
|
759
|
+
t2[e2] = r2.value;
|
|
760
|
+
}, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c2 = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag";
|
|
761
|
+
function define(t2, e2, r2) {
|
|
762
|
+
return Object.defineProperty(t2, e2, { value: r2, enumerable: true, configurable: true, writable: true }), t2[e2];
|
|
763
|
+
}
|
|
764
|
+
try {
|
|
765
|
+
define({}, "");
|
|
766
|
+
} catch (t2) {
|
|
767
|
+
define = function define2(t3, e2, r2) {
|
|
768
|
+
return t3[e2] = r2;
|
|
769
|
+
};
|
|
770
|
+
}
|
|
771
|
+
function wrap(t2, e2, r2, n2) {
|
|
772
|
+
var i2 = e2 && e2.prototype instanceof Generator ? e2 : Generator, a2 = Object.create(i2.prototype), c3 = new Context(n2 || []);
|
|
773
|
+
return o(a2, "_invoke", { value: makeInvokeMethod(t2, r2, c3) }), a2;
|
|
774
|
+
}
|
|
775
|
+
function tryCatch(t2, e2, r2) {
|
|
776
|
+
try {
|
|
777
|
+
return { type: "normal", arg: t2.call(e2, r2) };
|
|
778
|
+
} catch (t3) {
|
|
779
|
+
return { type: "throw", arg: t3 };
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
e.wrap = wrap;
|
|
783
|
+
var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {};
|
|
784
|
+
function Generator() {
|
|
785
|
+
}
|
|
786
|
+
function GeneratorFunction() {
|
|
787
|
+
}
|
|
788
|
+
function GeneratorFunctionPrototype() {
|
|
789
|
+
}
|
|
790
|
+
var p = {};
|
|
791
|
+
define(p, a, function() {
|
|
792
|
+
return this;
|
|
793
|
+
});
|
|
794
|
+
var d = Object.getPrototypeOf, v = d && d(d(values([])));
|
|
795
|
+
v && v !== r && n.call(v, a) && (p = v);
|
|
796
|
+
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
|
797
|
+
function defineIteratorMethods(t2) {
|
|
798
|
+
["next", "throw", "return"].forEach(function(e2) {
|
|
799
|
+
define(t2, e2, function(t3) {
|
|
800
|
+
return this._invoke(e2, t3);
|
|
801
|
+
});
|
|
802
|
+
});
|
|
803
|
+
}
|
|
804
|
+
function AsyncIterator(t2, e2) {
|
|
805
|
+
function invoke(r3, o2, i2, a2) {
|
|
806
|
+
var c3 = tryCatch(t2[r3], t2, o2);
|
|
807
|
+
if ("throw" !== c3.type) {
|
|
808
|
+
var u2 = c3.arg, h2 = u2.value;
|
|
809
|
+
return h2 && "object" == _typeof$6(h2) && n.call(h2, "__await") ? e2.resolve(h2.__await).then(function(t3) {
|
|
810
|
+
invoke("next", t3, i2, a2);
|
|
811
|
+
}, function(t3) {
|
|
812
|
+
invoke("throw", t3, i2, a2);
|
|
813
|
+
}) : e2.resolve(h2).then(function(t3) {
|
|
814
|
+
u2.value = t3, i2(u2);
|
|
815
|
+
}, function(t3) {
|
|
816
|
+
return invoke("throw", t3, i2, a2);
|
|
817
|
+
});
|
|
818
|
+
}
|
|
819
|
+
a2(c3.arg);
|
|
820
|
+
}
|
|
821
|
+
var r2;
|
|
822
|
+
o(this, "_invoke", { value: function value(t3, n2) {
|
|
823
|
+
function callInvokeWithMethodAndArg() {
|
|
824
|
+
return new e2(function(e3, r3) {
|
|
825
|
+
invoke(t3, n2, e3, r3);
|
|
826
|
+
});
|
|
827
|
+
}
|
|
828
|
+
return r2 = r2 ? r2.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
829
|
+
} });
|
|
830
|
+
}
|
|
831
|
+
function makeInvokeMethod(e2, r2, n2) {
|
|
832
|
+
var o2 = h;
|
|
833
|
+
return function(i2, a2) {
|
|
834
|
+
if (o2 === f) throw Error("Generator is already running");
|
|
835
|
+
if (o2 === s) {
|
|
836
|
+
if ("throw" === i2) throw a2;
|
|
837
|
+
return { value: t, done: true };
|
|
838
|
+
}
|
|
839
|
+
for (n2.method = i2, n2.arg = a2; ; ) {
|
|
840
|
+
var c3 = n2.delegate;
|
|
841
|
+
if (c3) {
|
|
842
|
+
var u2 = maybeInvokeDelegate(c3, n2);
|
|
843
|
+
if (u2) {
|
|
844
|
+
if (u2 === y) continue;
|
|
845
|
+
return u2;
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
if ("next" === n2.method) n2.sent = n2._sent = n2.arg;
|
|
849
|
+
else if ("throw" === n2.method) {
|
|
850
|
+
if (o2 === h) throw o2 = s, n2.arg;
|
|
851
|
+
n2.dispatchException(n2.arg);
|
|
852
|
+
} else "return" === n2.method && n2.abrupt("return", n2.arg);
|
|
853
|
+
o2 = f;
|
|
854
|
+
var p2 = tryCatch(e2, r2, n2);
|
|
855
|
+
if ("normal" === p2.type) {
|
|
856
|
+
if (o2 = n2.done ? s : l, p2.arg === y) continue;
|
|
857
|
+
return { value: p2.arg, done: n2.done };
|
|
858
|
+
}
|
|
859
|
+
"throw" === p2.type && (o2 = s, n2.method = "throw", n2.arg = p2.arg);
|
|
860
|
+
}
|
|
861
|
+
};
|
|
862
|
+
}
|
|
863
|
+
function maybeInvokeDelegate(e2, r2) {
|
|
864
|
+
var n2 = r2.method, o2 = e2.iterator[n2];
|
|
865
|
+
if (o2 === t) return r2.delegate = null, "throw" === n2 && e2.iterator["return"] && (r2.method = "return", r2.arg = t, maybeInvokeDelegate(e2, r2), "throw" === r2.method) || "return" !== n2 && (r2.method = "throw", r2.arg = new TypeError("The iterator does not provide a '" + n2 + "' method")), y;
|
|
866
|
+
var i2 = tryCatch(o2, e2.iterator, r2.arg);
|
|
867
|
+
if ("throw" === i2.type) return r2.method = "throw", r2.arg = i2.arg, r2.delegate = null, y;
|
|
868
|
+
var a2 = i2.arg;
|
|
869
|
+
return a2 ? a2.done ? (r2[e2.resultName] = a2.value, r2.next = e2.nextLoc, "return" !== r2.method && (r2.method = "next", r2.arg = t), r2.delegate = null, y) : a2 : (r2.method = "throw", r2.arg = new TypeError("iterator result is not an object"), r2.delegate = null, y);
|
|
870
|
+
}
|
|
871
|
+
function pushTryEntry(t2) {
|
|
872
|
+
var e2 = { tryLoc: t2[0] };
|
|
873
|
+
1 in t2 && (e2.catchLoc = t2[1]), 2 in t2 && (e2.finallyLoc = t2[2], e2.afterLoc = t2[3]), this.tryEntries.push(e2);
|
|
874
|
+
}
|
|
875
|
+
function resetTryEntry(t2) {
|
|
876
|
+
var e2 = t2.completion || {};
|
|
877
|
+
e2.type = "normal", delete e2.arg, t2.completion = e2;
|
|
878
|
+
}
|
|
879
|
+
function Context(t2) {
|
|
880
|
+
this.tryEntries = [{ tryLoc: "root" }], t2.forEach(pushTryEntry, this), this.reset(true);
|
|
881
|
+
}
|
|
882
|
+
function values(e2) {
|
|
883
|
+
if (e2 || "" === e2) {
|
|
884
|
+
var r2 = e2[a];
|
|
885
|
+
if (r2) return r2.call(e2);
|
|
886
|
+
if ("function" == typeof e2.next) return e2;
|
|
887
|
+
if (!isNaN(e2.length)) {
|
|
888
|
+
var o2 = -1, i2 = function next() {
|
|
889
|
+
for (; ++o2 < e2.length; ) if (n.call(e2, o2)) return next.value = e2[o2], next.done = false, next;
|
|
890
|
+
return next.value = t, next.done = true, next;
|
|
891
|
+
};
|
|
892
|
+
return i2.next = i2;
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
throw new TypeError(_typeof$6(e2) + " is not iterable");
|
|
896
|
+
}
|
|
897
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: true }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: true }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function(t2) {
|
|
898
|
+
var e2 = "function" == typeof t2 && t2.constructor;
|
|
899
|
+
return !!e2 && (e2 === GeneratorFunction || "GeneratorFunction" === (e2.displayName || e2.name));
|
|
900
|
+
}, e.mark = function(t2) {
|
|
901
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(t2, GeneratorFunctionPrototype) : (t2.__proto__ = GeneratorFunctionPrototype, define(t2, u, "GeneratorFunction")), t2.prototype = Object.create(g), t2;
|
|
902
|
+
}, e.awrap = function(t2) {
|
|
903
|
+
return { __await: t2 };
|
|
904
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c2, function() {
|
|
905
|
+
return this;
|
|
906
|
+
}), e.AsyncIterator = AsyncIterator, e.async = function(t2, r2, n2, o2, i2) {
|
|
907
|
+
void 0 === i2 && (i2 = Promise);
|
|
908
|
+
var a2 = new AsyncIterator(wrap(t2, r2, n2, o2), i2);
|
|
909
|
+
return e.isGeneratorFunction(r2) ? a2 : a2.next().then(function(t3) {
|
|
910
|
+
return t3.done ? t3.value : a2.next();
|
|
911
|
+
});
|
|
912
|
+
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function() {
|
|
913
|
+
return this;
|
|
914
|
+
}), define(g, "toString", function() {
|
|
915
|
+
return "[object Generator]";
|
|
916
|
+
}), e.keys = function(t2) {
|
|
917
|
+
var e2 = Object(t2), r2 = [];
|
|
918
|
+
for (var n2 in e2) r2.push(n2);
|
|
919
|
+
return r2.reverse(), function next() {
|
|
920
|
+
for (; r2.length; ) {
|
|
921
|
+
var t3 = r2.pop();
|
|
922
|
+
if (t3 in e2) return next.value = t3, next.done = false, next;
|
|
923
|
+
}
|
|
924
|
+
return next.done = true, next;
|
|
925
|
+
};
|
|
926
|
+
}, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e2) {
|
|
927
|
+
if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = false, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e2) for (var r2 in this) "t" === r2.charAt(0) && n.call(this, r2) && !isNaN(+r2.slice(1)) && (this[r2] = t);
|
|
928
|
+
}, stop: function stop() {
|
|
929
|
+
this.done = true;
|
|
930
|
+
var t2 = this.tryEntries[0].completion;
|
|
931
|
+
if ("throw" === t2.type) throw t2.arg;
|
|
932
|
+
return this.rval;
|
|
933
|
+
}, dispatchException: function dispatchException(e2) {
|
|
934
|
+
if (this.done) throw e2;
|
|
935
|
+
var r2 = this;
|
|
936
|
+
function handle(n2, o3) {
|
|
937
|
+
return a2.type = "throw", a2.arg = e2, r2.next = n2, o3 && (r2.method = "next", r2.arg = t), !!o3;
|
|
938
|
+
}
|
|
939
|
+
for (var o2 = this.tryEntries.length - 1; o2 >= 0; --o2) {
|
|
940
|
+
var i2 = this.tryEntries[o2], a2 = i2.completion;
|
|
941
|
+
if ("root" === i2.tryLoc) return handle("end");
|
|
942
|
+
if (i2.tryLoc <= this.prev) {
|
|
943
|
+
var c3 = n.call(i2, "catchLoc"), u2 = n.call(i2, "finallyLoc");
|
|
944
|
+
if (c3 && u2) {
|
|
945
|
+
if (this.prev < i2.catchLoc) return handle(i2.catchLoc, true);
|
|
946
|
+
if (this.prev < i2.finallyLoc) return handle(i2.finallyLoc);
|
|
947
|
+
} else if (c3) {
|
|
948
|
+
if (this.prev < i2.catchLoc) return handle(i2.catchLoc, true);
|
|
949
|
+
} else {
|
|
950
|
+
if (!u2) throw Error("try statement without catch or finally");
|
|
951
|
+
if (this.prev < i2.finallyLoc) return handle(i2.finallyLoc);
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
}, abrupt: function abrupt(t2, e2) {
|
|
956
|
+
for (var r2 = this.tryEntries.length - 1; r2 >= 0; --r2) {
|
|
957
|
+
var o2 = this.tryEntries[r2];
|
|
958
|
+
if (o2.tryLoc <= this.prev && n.call(o2, "finallyLoc") && this.prev < o2.finallyLoc) {
|
|
959
|
+
var i2 = o2;
|
|
960
|
+
break;
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
i2 && ("break" === t2 || "continue" === t2) && i2.tryLoc <= e2 && e2 <= i2.finallyLoc && (i2 = null);
|
|
964
|
+
var a2 = i2 ? i2.completion : {};
|
|
965
|
+
return a2.type = t2, a2.arg = e2, i2 ? (this.method = "next", this.next = i2.finallyLoc, y) : this.complete(a2);
|
|
966
|
+
}, complete: function complete(t2, e2) {
|
|
967
|
+
if ("throw" === t2.type) throw t2.arg;
|
|
968
|
+
return "break" === t2.type || "continue" === t2.type ? this.next = t2.arg : "return" === t2.type ? (this.rval = this.arg = t2.arg, this.method = "return", this.next = "end") : "normal" === t2.type && e2 && (this.next = e2), y;
|
|
969
|
+
}, finish: function finish(t2) {
|
|
970
|
+
for (var e2 = this.tryEntries.length - 1; e2 >= 0; --e2) {
|
|
971
|
+
var r2 = this.tryEntries[e2];
|
|
972
|
+
if (r2.finallyLoc === t2) return this.complete(r2.completion, r2.afterLoc), resetTryEntry(r2), y;
|
|
973
|
+
}
|
|
974
|
+
}, "catch": function _catch(t2) {
|
|
975
|
+
for (var e2 = this.tryEntries.length - 1; e2 >= 0; --e2) {
|
|
976
|
+
var r2 = this.tryEntries[e2];
|
|
977
|
+
if (r2.tryLoc === t2) {
|
|
978
|
+
var n2 = r2.completion;
|
|
979
|
+
if ("throw" === n2.type) {
|
|
980
|
+
var o2 = n2.arg;
|
|
981
|
+
resetTryEntry(r2);
|
|
982
|
+
}
|
|
983
|
+
return o2;
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
throw Error("illegal catch attempt");
|
|
987
|
+
}, delegateYield: function delegateYield(e2, r2, n2) {
|
|
988
|
+
return this.delegate = { iterator: values(e2), resultName: r2, nextLoc: n2 }, "next" === this.method && (this.arg = t), y;
|
|
989
|
+
} }, e;
|
|
990
|
+
}
|
|
991
|
+
function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
|
|
992
|
+
try {
|
|
993
|
+
var info = gen[key](arg);
|
|
994
|
+
var value = info.value;
|
|
995
|
+
} catch (error) {
|
|
996
|
+
reject(error);
|
|
997
|
+
return;
|
|
998
|
+
}
|
|
999
|
+
if (info.done) {
|
|
1000
|
+
resolve(value);
|
|
1001
|
+
} else {
|
|
1002
|
+
Promise.resolve(value).then(_next, _throw);
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
function _asyncToGenerator$1(fn) {
|
|
1006
|
+
return function() {
|
|
1007
|
+
var self2 = this, args = arguments;
|
|
1008
|
+
return new Promise(function(resolve, reject) {
|
|
1009
|
+
var gen = fn.apply(self2, args);
|
|
1010
|
+
function _next(value) {
|
|
1011
|
+
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
|
|
1012
|
+
}
|
|
1013
|
+
function _throw(err) {
|
|
1014
|
+
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
|
|
1015
|
+
}
|
|
1016
|
+
_next(void 0);
|
|
1017
|
+
});
|
|
1018
|
+
};
|
|
1019
|
+
}
|
|
1020
|
+
function _slicedToArray(arr, i) {
|
|
1021
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
1022
|
+
}
|
|
1023
|
+
function _nonIterableRest() {
|
|
1024
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1025
|
+
}
|
|
1026
|
+
function _iterableToArrayLimit(r, l) {
|
|
1027
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
1028
|
+
if (null != t) {
|
|
1029
|
+
var e, n, i, u, a = [], f = true, o = false;
|
|
1030
|
+
try {
|
|
1031
|
+
if (i = (t = t.call(r)).next, 0 === l) ;
|
|
1032
|
+
else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = true) ;
|
|
1033
|
+
} catch (r2) {
|
|
1034
|
+
o = true, n = r2;
|
|
1035
|
+
} finally {
|
|
1036
|
+
try {
|
|
1037
|
+
if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
|
|
1038
|
+
} finally {
|
|
1039
|
+
if (o) throw n;
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
return a;
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
function _arrayWithHoles(arr) {
|
|
1046
|
+
if (Array.isArray(arr)) return arr;
|
|
1047
|
+
}
|
|
1048
|
+
function _typeof$6(o) {
|
|
1049
|
+
"@babel/helpers - typeof";
|
|
1050
|
+
return _typeof$6 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
|
|
1051
|
+
return typeof o2;
|
|
1052
|
+
} : function(o2) {
|
|
1053
|
+
return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
|
|
1054
|
+
}, _typeof$6(o);
|
|
1055
|
+
}
|
|
1056
|
+
function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
1057
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
1058
|
+
if (!it) {
|
|
1059
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike) {
|
|
1060
|
+
if (it) o = it;
|
|
1061
|
+
var i = 0;
|
|
1062
|
+
var F = function F2() {
|
|
1063
|
+
};
|
|
1064
|
+
return { s: F, n: function n() {
|
|
1065
|
+
if (i >= o.length) return { done: true };
|
|
1066
|
+
return { done: false, value: o[i++] };
|
|
1067
|
+
}, e: function e(_e) {
|
|
1068
|
+
throw _e;
|
|
1069
|
+
}, f: F };
|
|
1070
|
+
}
|
|
1071
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1072
|
+
}
|
|
1073
|
+
var normalCompletion = true, didErr = false, err;
|
|
1074
|
+
return { s: function s() {
|
|
1075
|
+
it = it.call(o);
|
|
1076
|
+
}, n: function n() {
|
|
1077
|
+
var step = it.next();
|
|
1078
|
+
normalCompletion = step.done;
|
|
1079
|
+
return step;
|
|
1080
|
+
}, e: function e(_e2) {
|
|
1081
|
+
didErr = true;
|
|
1082
|
+
err = _e2;
|
|
1083
|
+
}, f: function f() {
|
|
1084
|
+
try {
|
|
1085
|
+
if (!normalCompletion && it["return"] != null) it["return"]();
|
|
1086
|
+
} finally {
|
|
1087
|
+
if (didErr) throw err;
|
|
1088
|
+
}
|
|
1089
|
+
} };
|
|
1090
|
+
}
|
|
1091
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
1092
|
+
if (!o) return;
|
|
1093
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
1094
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1095
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
1096
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
1097
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
1098
|
+
}
|
|
1099
|
+
function _arrayLikeToArray(arr, len2) {
|
|
1100
|
+
if (len2 == null || len2 > arr.length) len2 = arr.length;
|
|
1101
|
+
for (var i = 0, arr2 = new Array(len2); i < len2; i++) arr2[i] = arr[i];
|
|
1102
|
+
return arr2;
|
|
1103
|
+
}
|
|
1104
|
+
function ownKeys$1(e, r) {
|
|
1105
|
+
var t = Object.keys(e);
|
|
1106
|
+
if (Object.getOwnPropertySymbols) {
|
|
1107
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
1108
|
+
r && (o = o.filter(function(r2) {
|
|
1109
|
+
return Object.getOwnPropertyDescriptor(e, r2).enumerable;
|
|
1110
|
+
})), t.push.apply(t, o);
|
|
1111
|
+
}
|
|
1112
|
+
return t;
|
|
1113
|
+
}
|
|
1114
|
+
function _objectSpread$1(e) {
|
|
1115
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
1116
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
1117
|
+
r % 2 ? ownKeys$1(Object(t), true).forEach(function(r2) {
|
|
1118
|
+
_defineProperty$1(e, r2, t[r2]);
|
|
1119
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function(r2) {
|
|
1120
|
+
Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
|
|
1121
|
+
});
|
|
1122
|
+
}
|
|
1123
|
+
return e;
|
|
1124
|
+
}
|
|
1125
|
+
function _defineProperty$1(obj, key, value) {
|
|
1126
|
+
key = _toPropertyKey$6(key);
|
|
1127
|
+
if (key in obj) {
|
|
1128
|
+
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
|
1129
|
+
} else {
|
|
1130
|
+
obj[key] = value;
|
|
1131
|
+
}
|
|
1132
|
+
return obj;
|
|
1133
|
+
}
|
|
1134
|
+
function _classCallCheck$6(instance, Constructor) {
|
|
1135
|
+
if (!(instance instanceof Constructor)) {
|
|
1136
|
+
throw new TypeError("Cannot call a class as a function");
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
function _defineProperties$6(target, props) {
|
|
1140
|
+
for (var i = 0; i < props.length; i++) {
|
|
1141
|
+
var descriptor = props[i];
|
|
1142
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
1143
|
+
descriptor.configurable = true;
|
|
1144
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
1145
|
+
Object.defineProperty(target, _toPropertyKey$6(descriptor.key), descriptor);
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
function _createClass$6(Constructor, protoProps, staticProps) {
|
|
1149
|
+
if (protoProps) _defineProperties$6(Constructor.prototype, protoProps);
|
|
1150
|
+
if (staticProps) _defineProperties$6(Constructor, staticProps);
|
|
1151
|
+
Object.defineProperty(Constructor, "prototype", { writable: false });
|
|
1152
|
+
return Constructor;
|
|
1153
|
+
}
|
|
1154
|
+
function _toPropertyKey$6(t) {
|
|
1155
|
+
var i = _toPrimitive$6(t, "string");
|
|
1156
|
+
return "symbol" == _typeof$6(i) ? i : i + "";
|
|
1157
|
+
}
|
|
1158
|
+
function _toPrimitive$6(t, r) {
|
|
1159
|
+
if ("object" != _typeof$6(t) || !t) return t;
|
|
1160
|
+
var e = t[Symbol.toPrimitive];
|
|
1161
|
+
if (void 0 !== e) {
|
|
1162
|
+
var i = e.call(t, r);
|
|
1163
|
+
if ("object" != _typeof$6(i)) return i;
|
|
1164
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1165
|
+
}
|
|
1166
|
+
return String(t);
|
|
1167
|
+
}
|
|
1168
|
+
var PROTOCOL_TUS_V1 = "tus-v1";
|
|
1169
|
+
var PROTOCOL_IETF_DRAFT_03 = "ietf-draft-03";
|
|
1170
|
+
var PROTOCOL_IETF_DRAFT_05 = "ietf-draft-05";
|
|
1171
|
+
var defaultOptions$1 = {
|
|
1172
|
+
endpoint: null,
|
|
1173
|
+
uploadUrl: null,
|
|
1174
|
+
metadata: {},
|
|
1175
|
+
metadataForPartialUploads: {},
|
|
1176
|
+
fingerprint: null,
|
|
1177
|
+
uploadSize: null,
|
|
1178
|
+
onProgress: null,
|
|
1179
|
+
onChunkComplete: null,
|
|
1180
|
+
onSuccess: null,
|
|
1181
|
+
onError: null,
|
|
1182
|
+
onUploadUrlAvailable: null,
|
|
1183
|
+
overridePatchMethod: false,
|
|
1184
|
+
headers: {},
|
|
1185
|
+
addRequestId: false,
|
|
1186
|
+
onBeforeRequest: null,
|
|
1187
|
+
onAfterResponse: null,
|
|
1188
|
+
onShouldRetry: defaultOnShouldRetry,
|
|
1189
|
+
chunkSize: Number.POSITIVE_INFINITY,
|
|
1190
|
+
retryDelays: [0, 1e3, 3e3, 5e3],
|
|
1191
|
+
parallelUploads: 1,
|
|
1192
|
+
parallelUploadBoundaries: null,
|
|
1193
|
+
storeFingerprintForResuming: true,
|
|
1194
|
+
removeFingerprintOnSuccess: false,
|
|
1195
|
+
uploadLengthDeferred: false,
|
|
1196
|
+
uploadDataDuringCreation: false,
|
|
1197
|
+
urlStorage: null,
|
|
1198
|
+
fileReader: null,
|
|
1199
|
+
httpStack: null,
|
|
1200
|
+
protocol: PROTOCOL_TUS_V1
|
|
1201
|
+
};
|
|
1202
|
+
var BaseUpload = /* @__PURE__ */ (function() {
|
|
1203
|
+
function BaseUpload2(file, options) {
|
|
1204
|
+
_classCallCheck$6(this, BaseUpload2);
|
|
1205
|
+
if ("resume" in options) {
|
|
1206
|
+
console.log("tus: The `resume` option has been removed in tus-js-client v2. Please use the URL storage API instead.");
|
|
1207
|
+
}
|
|
1208
|
+
this.options = options;
|
|
1209
|
+
this.options.chunkSize = Number(this.options.chunkSize);
|
|
1210
|
+
this._urlStorage = this.options.urlStorage;
|
|
1211
|
+
this.file = file;
|
|
1212
|
+
this.url = null;
|
|
1213
|
+
this._req = null;
|
|
1214
|
+
this._fingerprint = null;
|
|
1215
|
+
this._urlStorageKey = null;
|
|
1216
|
+
this._offset = null;
|
|
1217
|
+
this._aborted = false;
|
|
1218
|
+
this._size = null;
|
|
1219
|
+
this._source = null;
|
|
1220
|
+
this._retryAttempt = 0;
|
|
1221
|
+
this._retryTimeout = null;
|
|
1222
|
+
this._offsetBeforeRetry = 0;
|
|
1223
|
+
this._parallelUploads = null;
|
|
1224
|
+
this._parallelUploadUrls = null;
|
|
1225
|
+
}
|
|
1226
|
+
return _createClass$6(BaseUpload2, [{
|
|
1227
|
+
key: "findPreviousUploads",
|
|
1228
|
+
value: function findPreviousUploads() {
|
|
1229
|
+
var _this = this;
|
|
1230
|
+
return this.options.fingerprint(this.file, this.options).then(function(fingerprint2) {
|
|
1231
|
+
return _this._urlStorage.findUploadsByFingerprint(fingerprint2);
|
|
1232
|
+
});
|
|
1233
|
+
}
|
|
1234
|
+
}, {
|
|
1235
|
+
key: "resumeFromPreviousUpload",
|
|
1236
|
+
value: function resumeFromPreviousUpload(previousUpload) {
|
|
1237
|
+
this.url = previousUpload.uploadUrl || null;
|
|
1238
|
+
this._parallelUploadUrls = previousUpload.parallelUploadUrls || null;
|
|
1239
|
+
this._urlStorageKey = previousUpload.urlStorageKey;
|
|
1240
|
+
}
|
|
1241
|
+
}, {
|
|
1242
|
+
key: "start",
|
|
1243
|
+
value: function start() {
|
|
1244
|
+
var _this2 = this;
|
|
1245
|
+
var file = this.file;
|
|
1246
|
+
if (!file) {
|
|
1247
|
+
this._emitError(new Error("tus: no file or stream to upload provided"));
|
|
1248
|
+
return;
|
|
1249
|
+
}
|
|
1250
|
+
if (![PROTOCOL_TUS_V1, PROTOCOL_IETF_DRAFT_03, PROTOCOL_IETF_DRAFT_05].includes(this.options.protocol)) {
|
|
1251
|
+
this._emitError(new Error("tus: unsupported protocol ".concat(this.options.protocol)));
|
|
1252
|
+
return;
|
|
1253
|
+
}
|
|
1254
|
+
if (!this.options.endpoint && !this.options.uploadUrl && !this.url) {
|
|
1255
|
+
this._emitError(new Error("tus: neither an endpoint or an upload URL is provided"));
|
|
1256
|
+
return;
|
|
1257
|
+
}
|
|
1258
|
+
var retryDelays = this.options.retryDelays;
|
|
1259
|
+
if (retryDelays != null && Object.prototype.toString.call(retryDelays) !== "[object Array]") {
|
|
1260
|
+
this._emitError(new Error("tus: the `retryDelays` option must either be an array or null"));
|
|
1261
|
+
return;
|
|
1262
|
+
}
|
|
1263
|
+
if (this.options.parallelUploads > 1) {
|
|
1264
|
+
for (var _i = 0, _arr = ["uploadUrl", "uploadSize", "uploadLengthDeferred"]; _i < _arr.length; _i++) {
|
|
1265
|
+
var optionName = _arr[_i];
|
|
1266
|
+
if (this.options[optionName]) {
|
|
1267
|
+
this._emitError(new Error("tus: cannot use the ".concat(optionName, " option when parallelUploads is enabled")));
|
|
1268
|
+
return;
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
if (this.options.parallelUploadBoundaries) {
|
|
1273
|
+
if (this.options.parallelUploads <= 1) {
|
|
1274
|
+
this._emitError(new Error("tus: cannot use the `parallelUploadBoundaries` option when `parallelUploads` is disabled"));
|
|
1275
|
+
return;
|
|
1276
|
+
}
|
|
1277
|
+
if (this.options.parallelUploads !== this.options.parallelUploadBoundaries.length) {
|
|
1278
|
+
this._emitError(new Error("tus: the `parallelUploadBoundaries` must have the same length as the value of `parallelUploads`"));
|
|
1279
|
+
return;
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
this.options.fingerprint(file, this.options).then(function(fingerprint2) {
|
|
1283
|
+
_this2._fingerprint = fingerprint2;
|
|
1284
|
+
if (_this2._source) {
|
|
1285
|
+
return _this2._source;
|
|
1286
|
+
}
|
|
1287
|
+
return _this2.options.fileReader.openFile(file, _this2.options.chunkSize);
|
|
1288
|
+
}).then(function(source) {
|
|
1289
|
+
_this2._source = source;
|
|
1290
|
+
if (_this2.options.uploadLengthDeferred) {
|
|
1291
|
+
_this2._size = null;
|
|
1292
|
+
} else if (_this2.options.uploadSize != null) {
|
|
1293
|
+
_this2._size = Number(_this2.options.uploadSize);
|
|
1294
|
+
if (Number.isNaN(_this2._size)) {
|
|
1295
|
+
_this2._emitError(new Error("tus: cannot convert `uploadSize` option into a number"));
|
|
1296
|
+
return;
|
|
1297
|
+
}
|
|
1298
|
+
} else {
|
|
1299
|
+
_this2._size = _this2._source.size;
|
|
1300
|
+
if (_this2._size == null) {
|
|
1301
|
+
_this2._emitError(new Error("tus: cannot automatically derive upload's size from input. Specify it manually using the `uploadSize` option or use the `uploadLengthDeferred` option"));
|
|
1302
|
+
return;
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
if (_this2.options.parallelUploads > 1 || _this2._parallelUploadUrls != null) {
|
|
1306
|
+
_this2._startParallelUpload();
|
|
1307
|
+
} else {
|
|
1308
|
+
_this2._startSingleUpload();
|
|
1309
|
+
}
|
|
1310
|
+
})["catch"](function(err) {
|
|
1311
|
+
_this2._emitError(err);
|
|
1312
|
+
});
|
|
1313
|
+
}
|
|
1314
|
+
/**
|
|
1315
|
+
* Initiate the uploading procedure for a parallelized upload, where one file is split into
|
|
1316
|
+
* multiple request which are run in parallel.
|
|
1317
|
+
*
|
|
1318
|
+
* @api private
|
|
1319
|
+
*/
|
|
1320
|
+
}, {
|
|
1321
|
+
key: "_startParallelUpload",
|
|
1322
|
+
value: function _startParallelUpload() {
|
|
1323
|
+
var _this$options$paralle, _this3 = this;
|
|
1324
|
+
var totalSize = this._size;
|
|
1325
|
+
var totalProgress = 0;
|
|
1326
|
+
this._parallelUploads = [];
|
|
1327
|
+
var partCount = this._parallelUploadUrls != null ? this._parallelUploadUrls.length : this.options.parallelUploads;
|
|
1328
|
+
var parts = (_this$options$paralle = this.options.parallelUploadBoundaries) !== null && _this$options$paralle !== void 0 ? _this$options$paralle : splitSizeIntoParts(this._source.size, partCount);
|
|
1329
|
+
if (this._parallelUploadUrls) {
|
|
1330
|
+
parts.forEach(function(part, index) {
|
|
1331
|
+
part.uploadUrl = _this3._parallelUploadUrls[index] || null;
|
|
1332
|
+
});
|
|
1333
|
+
}
|
|
1334
|
+
this._parallelUploadUrls = new Array(parts.length);
|
|
1335
|
+
var uploads = parts.map(function(part, index) {
|
|
1336
|
+
var lastPartProgress = 0;
|
|
1337
|
+
return _this3._source.slice(part.start, part.end).then(function(_ref) {
|
|
1338
|
+
var value = _ref.value;
|
|
1339
|
+
return new Promise(function(resolve, reject) {
|
|
1340
|
+
var options = _objectSpread$1(_objectSpread$1({}, _this3.options), {}, {
|
|
1341
|
+
// If available, the partial upload should be resumed from a previous URL.
|
|
1342
|
+
uploadUrl: part.uploadUrl || null,
|
|
1343
|
+
// We take manually care of resuming for partial uploads, so they should
|
|
1344
|
+
// not be stored in the URL storage.
|
|
1345
|
+
storeFingerprintForResuming: false,
|
|
1346
|
+
removeFingerprintOnSuccess: false,
|
|
1347
|
+
// Reset the parallelUploads option to not cause recursion.
|
|
1348
|
+
parallelUploads: 1,
|
|
1349
|
+
// Reset this option as we are not doing a parallel upload.
|
|
1350
|
+
parallelUploadBoundaries: null,
|
|
1351
|
+
metadata: _this3.options.metadataForPartialUploads,
|
|
1352
|
+
// Add the header to indicate the this is a partial upload.
|
|
1353
|
+
headers: _objectSpread$1(_objectSpread$1({}, _this3.options.headers), {}, {
|
|
1354
|
+
"Upload-Concat": "partial"
|
|
1355
|
+
}),
|
|
1356
|
+
// Reject or resolve the promise if the upload errors or completes.
|
|
1357
|
+
onSuccess: resolve,
|
|
1358
|
+
onError: reject,
|
|
1359
|
+
// Based in the progress for this partial upload, calculate the progress
|
|
1360
|
+
// for the entire final upload.
|
|
1361
|
+
onProgress: function onProgress(newPartProgress) {
|
|
1362
|
+
totalProgress = totalProgress - lastPartProgress + newPartProgress;
|
|
1363
|
+
lastPartProgress = newPartProgress;
|
|
1364
|
+
_this3._emitProgress(totalProgress, totalSize);
|
|
1365
|
+
},
|
|
1366
|
+
// Wait until every partial upload has an upload URL, so we can add
|
|
1367
|
+
// them to the URL storage.
|
|
1368
|
+
onUploadUrlAvailable: function onUploadUrlAvailable() {
|
|
1369
|
+
_this3._parallelUploadUrls[index] = upload.url;
|
|
1370
|
+
if (_this3._parallelUploadUrls.filter(function(u) {
|
|
1371
|
+
return Boolean(u);
|
|
1372
|
+
}).length === parts.length) {
|
|
1373
|
+
_this3._saveUploadInUrlStorage();
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
});
|
|
1377
|
+
var upload = new BaseUpload2(value, options);
|
|
1378
|
+
upload.start();
|
|
1379
|
+
_this3._parallelUploads.push(upload);
|
|
1380
|
+
});
|
|
1381
|
+
});
|
|
1382
|
+
});
|
|
1383
|
+
var req;
|
|
1384
|
+
Promise.all(uploads).then(function() {
|
|
1385
|
+
req = _this3._openRequest("POST", _this3.options.endpoint);
|
|
1386
|
+
req.setHeader("Upload-Concat", "final;".concat(_this3._parallelUploadUrls.join(" ")));
|
|
1387
|
+
var metadata = encodeMetadata(_this3.options.metadata);
|
|
1388
|
+
if (metadata !== "") {
|
|
1389
|
+
req.setHeader("Upload-Metadata", metadata);
|
|
1390
|
+
}
|
|
1391
|
+
return _this3._sendRequest(req, null);
|
|
1392
|
+
}).then(function(res) {
|
|
1393
|
+
if (!inStatusCategory(res.getStatus(), 200)) {
|
|
1394
|
+
_this3._emitHttpError(req, res, "tus: unexpected response while creating upload");
|
|
1395
|
+
return;
|
|
1396
|
+
}
|
|
1397
|
+
var location = res.getHeader("Location");
|
|
1398
|
+
if (location == null) {
|
|
1399
|
+
_this3._emitHttpError(req, res, "tus: invalid or missing Location header");
|
|
1400
|
+
return;
|
|
1401
|
+
}
|
|
1402
|
+
_this3.url = resolveUrl(_this3.options.endpoint, location);
|
|
1403
|
+
log("Created upload at ".concat(_this3.url));
|
|
1404
|
+
_this3._emitSuccess(res);
|
|
1405
|
+
})["catch"](function(err) {
|
|
1406
|
+
_this3._emitError(err);
|
|
1407
|
+
});
|
|
1408
|
+
}
|
|
1409
|
+
/**
|
|
1410
|
+
* Initiate the uploading procedure for a non-parallel upload. Here the entire file is
|
|
1411
|
+
* uploaded in a sequential matter.
|
|
1412
|
+
*
|
|
1413
|
+
* @api private
|
|
1414
|
+
*/
|
|
1415
|
+
}, {
|
|
1416
|
+
key: "_startSingleUpload",
|
|
1417
|
+
value: function _startSingleUpload() {
|
|
1418
|
+
this._aborted = false;
|
|
1419
|
+
if (this.url != null) {
|
|
1420
|
+
log("Resuming upload from previous URL: ".concat(this.url));
|
|
1421
|
+
this._resumeUpload();
|
|
1422
|
+
return;
|
|
1423
|
+
}
|
|
1424
|
+
if (this.options.uploadUrl != null) {
|
|
1425
|
+
log("Resuming upload from provided URL: ".concat(this.options.uploadUrl));
|
|
1426
|
+
this.url = this.options.uploadUrl;
|
|
1427
|
+
this._resumeUpload();
|
|
1428
|
+
return;
|
|
1429
|
+
}
|
|
1430
|
+
this._createUpload();
|
|
1431
|
+
}
|
|
1432
|
+
/**
|
|
1433
|
+
* Abort any running request and stop the current upload. After abort is called, no event
|
|
1434
|
+
* handler will be invoked anymore. You can use the `start` method to resume the upload
|
|
1435
|
+
* again.
|
|
1436
|
+
* If `shouldTerminate` is true, the `terminate` function will be called to remove the
|
|
1437
|
+
* current upload from the server.
|
|
1438
|
+
*
|
|
1439
|
+
* @param {boolean} shouldTerminate True if the upload should be deleted from the server.
|
|
1440
|
+
* @return {Promise} The Promise will be resolved/rejected when the requests finish.
|
|
1441
|
+
*/
|
|
1442
|
+
}, {
|
|
1443
|
+
key: "abort",
|
|
1444
|
+
value: function abort(shouldTerminate) {
|
|
1445
|
+
var _this4 = this;
|
|
1446
|
+
if (this._parallelUploads != null) {
|
|
1447
|
+
var _iterator = _createForOfIteratorHelper(this._parallelUploads), _step;
|
|
1448
|
+
try {
|
|
1449
|
+
for (_iterator.s(); !(_step = _iterator.n()).done; ) {
|
|
1450
|
+
var upload = _step.value;
|
|
1451
|
+
upload.abort(shouldTerminate);
|
|
1452
|
+
}
|
|
1453
|
+
} catch (err) {
|
|
1454
|
+
_iterator.e(err);
|
|
1455
|
+
} finally {
|
|
1456
|
+
_iterator.f();
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
if (this._req !== null) {
|
|
1460
|
+
this._req.abort();
|
|
1461
|
+
}
|
|
1462
|
+
this._aborted = true;
|
|
1463
|
+
if (this._retryTimeout != null) {
|
|
1464
|
+
clearTimeout(this._retryTimeout);
|
|
1465
|
+
this._retryTimeout = null;
|
|
1466
|
+
}
|
|
1467
|
+
if (!shouldTerminate || this.url == null) {
|
|
1468
|
+
return Promise.resolve();
|
|
1469
|
+
}
|
|
1470
|
+
return BaseUpload2.terminate(this.url, this.options).then(function() {
|
|
1471
|
+
return _this4._removeFromUrlStorage();
|
|
1472
|
+
});
|
|
1473
|
+
}
|
|
1474
|
+
}, {
|
|
1475
|
+
key: "_emitHttpError",
|
|
1476
|
+
value: function _emitHttpError(req, res, message, causingErr) {
|
|
1477
|
+
this._emitError(new DetailedError(message, causingErr, req, res));
|
|
1478
|
+
}
|
|
1479
|
+
}, {
|
|
1480
|
+
key: "_emitError",
|
|
1481
|
+
value: function _emitError(err) {
|
|
1482
|
+
var _this5 = this;
|
|
1483
|
+
if (this._aborted) return;
|
|
1484
|
+
if (this.options.retryDelays != null) {
|
|
1485
|
+
var shouldResetDelays = this._offset != null && this._offset > this._offsetBeforeRetry;
|
|
1486
|
+
if (shouldResetDelays) {
|
|
1487
|
+
this._retryAttempt = 0;
|
|
1488
|
+
}
|
|
1489
|
+
if (shouldRetry(err, this._retryAttempt, this.options)) {
|
|
1490
|
+
var delay = this.options.retryDelays[this._retryAttempt++];
|
|
1491
|
+
this._offsetBeforeRetry = this._offset;
|
|
1492
|
+
this._retryTimeout = setTimeout(function() {
|
|
1493
|
+
_this5.start();
|
|
1494
|
+
}, delay);
|
|
1495
|
+
return;
|
|
1496
|
+
}
|
|
1497
|
+
}
|
|
1498
|
+
if (typeof this.options.onError === "function") {
|
|
1499
|
+
this.options.onError(err);
|
|
1500
|
+
} else {
|
|
1501
|
+
throw err;
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
/**
|
|
1505
|
+
* Publishes notification if the upload has been successfully completed.
|
|
1506
|
+
*
|
|
1507
|
+
* @param {object} lastResponse Last HTTP response.
|
|
1508
|
+
* @api private
|
|
1509
|
+
*/
|
|
1510
|
+
}, {
|
|
1511
|
+
key: "_emitSuccess",
|
|
1512
|
+
value: function _emitSuccess(lastResponse) {
|
|
1513
|
+
if (this.options.removeFingerprintOnSuccess) {
|
|
1514
|
+
this._removeFromUrlStorage();
|
|
1515
|
+
}
|
|
1516
|
+
if (typeof this.options.onSuccess === "function") {
|
|
1517
|
+
this.options.onSuccess({
|
|
1518
|
+
lastResponse
|
|
1519
|
+
});
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1522
|
+
/**
|
|
1523
|
+
* Publishes notification when data has been sent to the server. This
|
|
1524
|
+
* data may not have been accepted by the server yet.
|
|
1525
|
+
*
|
|
1526
|
+
* @param {number} bytesSent Number of bytes sent to the server.
|
|
1527
|
+
* @param {number} bytesTotal Total number of bytes to be sent to the server.
|
|
1528
|
+
* @api private
|
|
1529
|
+
*/
|
|
1530
|
+
}, {
|
|
1531
|
+
key: "_emitProgress",
|
|
1532
|
+
value: function _emitProgress(bytesSent, bytesTotal) {
|
|
1533
|
+
if (typeof this.options.onProgress === "function") {
|
|
1534
|
+
this.options.onProgress(bytesSent, bytesTotal);
|
|
1535
|
+
}
|
|
1536
|
+
}
|
|
1537
|
+
/**
|
|
1538
|
+
* Publishes notification when a chunk of data has been sent to the server
|
|
1539
|
+
* and accepted by the server.
|
|
1540
|
+
* @param {number} chunkSize Size of the chunk that was accepted by the server.
|
|
1541
|
+
* @param {number} bytesAccepted Total number of bytes that have been
|
|
1542
|
+
* accepted by the server.
|
|
1543
|
+
* @param {number} bytesTotal Total number of bytes to be sent to the server.
|
|
1544
|
+
* @api private
|
|
1545
|
+
*/
|
|
1546
|
+
}, {
|
|
1547
|
+
key: "_emitChunkComplete",
|
|
1548
|
+
value: function _emitChunkComplete(chunkSize, bytesAccepted, bytesTotal) {
|
|
1549
|
+
if (typeof this.options.onChunkComplete === "function") {
|
|
1550
|
+
this.options.onChunkComplete(chunkSize, bytesAccepted, bytesTotal);
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
/**
|
|
1554
|
+
* Create a new upload using the creation extension by sending a POST
|
|
1555
|
+
* request to the endpoint. After successful creation the file will be
|
|
1556
|
+
* uploaded
|
|
1557
|
+
*
|
|
1558
|
+
* @api private
|
|
1559
|
+
*/
|
|
1560
|
+
}, {
|
|
1561
|
+
key: "_createUpload",
|
|
1562
|
+
value: function _createUpload() {
|
|
1563
|
+
var _this6 = this;
|
|
1564
|
+
if (!this.options.endpoint) {
|
|
1565
|
+
this._emitError(new Error("tus: unable to create upload because no endpoint is provided"));
|
|
1566
|
+
return;
|
|
1567
|
+
}
|
|
1568
|
+
var req = this._openRequest("POST", this.options.endpoint);
|
|
1569
|
+
if (this.options.uploadLengthDeferred) {
|
|
1570
|
+
req.setHeader("Upload-Defer-Length", "1");
|
|
1571
|
+
} else {
|
|
1572
|
+
req.setHeader("Upload-Length", "".concat(this._size));
|
|
1573
|
+
}
|
|
1574
|
+
var metadata = encodeMetadata(this.options.metadata);
|
|
1575
|
+
if (metadata !== "") {
|
|
1576
|
+
req.setHeader("Upload-Metadata", metadata);
|
|
1577
|
+
}
|
|
1578
|
+
var promise;
|
|
1579
|
+
if (this.options.uploadDataDuringCreation && !this.options.uploadLengthDeferred) {
|
|
1580
|
+
this._offset = 0;
|
|
1581
|
+
promise = this._addChunkToRequest(req);
|
|
1582
|
+
} else {
|
|
1583
|
+
if (this.options.protocol === PROTOCOL_IETF_DRAFT_03 || this.options.protocol === PROTOCOL_IETF_DRAFT_05) {
|
|
1584
|
+
req.setHeader("Upload-Complete", "?0");
|
|
1585
|
+
}
|
|
1586
|
+
promise = this._sendRequest(req, null);
|
|
1587
|
+
}
|
|
1588
|
+
promise.then(function(res) {
|
|
1589
|
+
if (!inStatusCategory(res.getStatus(), 200)) {
|
|
1590
|
+
_this6._emitHttpError(req, res, "tus: unexpected response while creating upload");
|
|
1591
|
+
return;
|
|
1592
|
+
}
|
|
1593
|
+
var location = res.getHeader("Location");
|
|
1594
|
+
if (location == null) {
|
|
1595
|
+
_this6._emitHttpError(req, res, "tus: invalid or missing Location header");
|
|
1596
|
+
return;
|
|
1597
|
+
}
|
|
1598
|
+
_this6.url = resolveUrl(_this6.options.endpoint, location);
|
|
1599
|
+
log("Created upload at ".concat(_this6.url));
|
|
1600
|
+
if (typeof _this6.options.onUploadUrlAvailable === "function") {
|
|
1601
|
+
_this6.options.onUploadUrlAvailable();
|
|
1602
|
+
}
|
|
1603
|
+
if (_this6._size === 0) {
|
|
1604
|
+
_this6._emitSuccess(res);
|
|
1605
|
+
_this6._source.close();
|
|
1606
|
+
return;
|
|
1607
|
+
}
|
|
1608
|
+
_this6._saveUploadInUrlStorage().then(function() {
|
|
1609
|
+
if (_this6.options.uploadDataDuringCreation) {
|
|
1610
|
+
_this6._handleUploadResponse(req, res);
|
|
1611
|
+
} else {
|
|
1612
|
+
_this6._offset = 0;
|
|
1613
|
+
_this6._performUpload();
|
|
1614
|
+
}
|
|
1615
|
+
});
|
|
1616
|
+
})["catch"](function(err) {
|
|
1617
|
+
_this6._emitHttpError(req, null, "tus: failed to create upload", err);
|
|
1618
|
+
});
|
|
1619
|
+
}
|
|
1620
|
+
/*
|
|
1621
|
+
* Try to resume an existing upload. First a HEAD request will be sent
|
|
1622
|
+
* to retrieve the offset. If the request fails a new upload will be
|
|
1623
|
+
* created. In the case of a successful response the file will be uploaded.
|
|
1624
|
+
*
|
|
1625
|
+
* @api private
|
|
1626
|
+
*/
|
|
1627
|
+
}, {
|
|
1628
|
+
key: "_resumeUpload",
|
|
1629
|
+
value: function _resumeUpload() {
|
|
1630
|
+
var _this7 = this;
|
|
1631
|
+
var req = this._openRequest("HEAD", this.url);
|
|
1632
|
+
var promise = this._sendRequest(req, null);
|
|
1633
|
+
promise.then(function(res) {
|
|
1634
|
+
var status = res.getStatus();
|
|
1635
|
+
if (!inStatusCategory(status, 200)) {
|
|
1636
|
+
if (status === 423) {
|
|
1637
|
+
_this7._emitHttpError(req, res, "tus: upload is currently locked; retry later");
|
|
1638
|
+
return;
|
|
1639
|
+
}
|
|
1640
|
+
if (inStatusCategory(status, 400)) {
|
|
1641
|
+
_this7._removeFromUrlStorage();
|
|
1642
|
+
}
|
|
1643
|
+
if (!_this7.options.endpoint) {
|
|
1644
|
+
_this7._emitHttpError(req, res, "tus: unable to resume upload (new upload cannot be created without an endpoint)");
|
|
1645
|
+
return;
|
|
1646
|
+
}
|
|
1647
|
+
_this7.url = null;
|
|
1648
|
+
_this7._createUpload();
|
|
1649
|
+
return;
|
|
1650
|
+
}
|
|
1651
|
+
var offset = Number.parseInt(res.getHeader("Upload-Offset"), 10);
|
|
1652
|
+
if (Number.isNaN(offset)) {
|
|
1653
|
+
_this7._emitHttpError(req, res, "tus: invalid or missing offset value");
|
|
1654
|
+
return;
|
|
1655
|
+
}
|
|
1656
|
+
var length = Number.parseInt(res.getHeader("Upload-Length"), 10);
|
|
1657
|
+
if (Number.isNaN(length) && !_this7.options.uploadLengthDeferred && _this7.options.protocol === PROTOCOL_TUS_V1) {
|
|
1658
|
+
_this7._emitHttpError(req, res, "tus: invalid or missing length value");
|
|
1659
|
+
return;
|
|
1660
|
+
}
|
|
1661
|
+
if (typeof _this7.options.onUploadUrlAvailable === "function") {
|
|
1662
|
+
_this7.options.onUploadUrlAvailable();
|
|
1663
|
+
}
|
|
1664
|
+
_this7._saveUploadInUrlStorage().then(function() {
|
|
1665
|
+
if (offset === length) {
|
|
1666
|
+
_this7._emitProgress(length, length);
|
|
1667
|
+
_this7._emitSuccess(res);
|
|
1668
|
+
return;
|
|
1669
|
+
}
|
|
1670
|
+
_this7._offset = offset;
|
|
1671
|
+
_this7._performUpload();
|
|
1672
|
+
});
|
|
1673
|
+
})["catch"](function(err) {
|
|
1674
|
+
_this7._emitHttpError(req, null, "tus: failed to resume upload", err);
|
|
1675
|
+
});
|
|
1676
|
+
}
|
|
1677
|
+
/**
|
|
1678
|
+
* Start uploading the file using PATCH requests. The file will be divided
|
|
1679
|
+
* into chunks as specified in the chunkSize option. During the upload
|
|
1680
|
+
* the onProgress event handler may be invoked multiple times.
|
|
1681
|
+
*
|
|
1682
|
+
* @api private
|
|
1683
|
+
*/
|
|
1684
|
+
}, {
|
|
1685
|
+
key: "_performUpload",
|
|
1686
|
+
value: function _performUpload() {
|
|
1687
|
+
var _this8 = this;
|
|
1688
|
+
if (this._aborted) {
|
|
1689
|
+
return;
|
|
1690
|
+
}
|
|
1691
|
+
var req;
|
|
1692
|
+
if (this.options.overridePatchMethod) {
|
|
1693
|
+
req = this._openRequest("POST", this.url);
|
|
1694
|
+
req.setHeader("X-HTTP-Method-Override", "PATCH");
|
|
1695
|
+
} else {
|
|
1696
|
+
req = this._openRequest("PATCH", this.url);
|
|
1697
|
+
}
|
|
1698
|
+
req.setHeader("Upload-Offset", "".concat(this._offset));
|
|
1699
|
+
var promise = this._addChunkToRequest(req);
|
|
1700
|
+
promise.then(function(res) {
|
|
1701
|
+
if (!inStatusCategory(res.getStatus(), 200)) {
|
|
1702
|
+
_this8._emitHttpError(req, res, "tus: unexpected response while uploading chunk");
|
|
1703
|
+
return;
|
|
1704
|
+
}
|
|
1705
|
+
_this8._handleUploadResponse(req, res);
|
|
1706
|
+
})["catch"](function(err) {
|
|
1707
|
+
if (_this8._aborted) {
|
|
1708
|
+
return;
|
|
1709
|
+
}
|
|
1710
|
+
_this8._emitHttpError(req, null, "tus: failed to upload chunk at offset ".concat(_this8._offset), err);
|
|
1711
|
+
});
|
|
1712
|
+
}
|
|
1713
|
+
/**
|
|
1714
|
+
* _addChunktoRequest reads a chunk from the source and sends it using the
|
|
1715
|
+
* supplied request object. It will not handle the response.
|
|
1716
|
+
*
|
|
1717
|
+
* @api private
|
|
1718
|
+
*/
|
|
1719
|
+
}, {
|
|
1720
|
+
key: "_addChunkToRequest",
|
|
1721
|
+
value: function _addChunkToRequest(req) {
|
|
1722
|
+
var _this9 = this;
|
|
1723
|
+
var start = this._offset;
|
|
1724
|
+
var end = this._offset + this.options.chunkSize;
|
|
1725
|
+
req.setProgressHandler(function(bytesSent) {
|
|
1726
|
+
_this9._emitProgress(start + bytesSent, _this9._size);
|
|
1727
|
+
});
|
|
1728
|
+
if (this.options.protocol === PROTOCOL_TUS_V1) {
|
|
1729
|
+
req.setHeader("Content-Type", "application/offset+octet-stream");
|
|
1730
|
+
} else if (this.options.protocol === PROTOCOL_IETF_DRAFT_05) {
|
|
1731
|
+
req.setHeader("Content-Type", "application/partial-upload");
|
|
1732
|
+
}
|
|
1733
|
+
if ((end === Number.POSITIVE_INFINITY || end > this._size) && !this.options.uploadLengthDeferred) {
|
|
1734
|
+
end = this._size;
|
|
1735
|
+
}
|
|
1736
|
+
return this._source.slice(start, end).then(function(_ref2) {
|
|
1737
|
+
var value = _ref2.value, done = _ref2.done;
|
|
1738
|
+
var valueSize = value !== null && value !== void 0 && value.size ? value.size : 0;
|
|
1739
|
+
if (_this9.options.uploadLengthDeferred && done) {
|
|
1740
|
+
_this9._size = _this9._offset + valueSize;
|
|
1741
|
+
req.setHeader("Upload-Length", "".concat(_this9._size));
|
|
1742
|
+
}
|
|
1743
|
+
var newSize = _this9._offset + valueSize;
|
|
1744
|
+
if (!_this9.options.uploadLengthDeferred && done && newSize !== _this9._size) {
|
|
1745
|
+
return Promise.reject(new Error("upload was configured with a size of ".concat(_this9._size, " bytes, but the source is done after ").concat(newSize, " bytes")));
|
|
1746
|
+
}
|
|
1747
|
+
if (value === null) {
|
|
1748
|
+
return _this9._sendRequest(req);
|
|
1749
|
+
}
|
|
1750
|
+
if (_this9.options.protocol === PROTOCOL_IETF_DRAFT_03 || _this9.options.protocol === PROTOCOL_IETF_DRAFT_05) {
|
|
1751
|
+
req.setHeader("Upload-Complete", done ? "?1" : "?0");
|
|
1752
|
+
}
|
|
1753
|
+
_this9._emitProgress(_this9._offset, _this9._size);
|
|
1754
|
+
return _this9._sendRequest(req, value);
|
|
1755
|
+
});
|
|
1756
|
+
}
|
|
1757
|
+
/**
|
|
1758
|
+
* _handleUploadResponse is used by requests that haven been sent using _addChunkToRequest
|
|
1759
|
+
* and already have received a response.
|
|
1760
|
+
*
|
|
1761
|
+
* @api private
|
|
1762
|
+
*/
|
|
1763
|
+
}, {
|
|
1764
|
+
key: "_handleUploadResponse",
|
|
1765
|
+
value: function _handleUploadResponse(req, res) {
|
|
1766
|
+
var offset = Number.parseInt(res.getHeader("Upload-Offset"), 10);
|
|
1767
|
+
if (Number.isNaN(offset)) {
|
|
1768
|
+
this._emitHttpError(req, res, "tus: invalid or missing offset value");
|
|
1769
|
+
return;
|
|
1770
|
+
}
|
|
1771
|
+
this._emitProgress(offset, this._size);
|
|
1772
|
+
this._emitChunkComplete(offset - this._offset, offset, this._size);
|
|
1773
|
+
this._offset = offset;
|
|
1774
|
+
if (offset === this._size) {
|
|
1775
|
+
this._emitSuccess(res);
|
|
1776
|
+
this._source.close();
|
|
1777
|
+
return;
|
|
1778
|
+
}
|
|
1779
|
+
this._performUpload();
|
|
1780
|
+
}
|
|
1781
|
+
/**
|
|
1782
|
+
* Create a new HTTP request object with the given method and URL.
|
|
1783
|
+
*
|
|
1784
|
+
* @api private
|
|
1785
|
+
*/
|
|
1786
|
+
}, {
|
|
1787
|
+
key: "_openRequest",
|
|
1788
|
+
value: function _openRequest(method, url) {
|
|
1789
|
+
var req = openRequest(method, url, this.options);
|
|
1790
|
+
this._req = req;
|
|
1791
|
+
return req;
|
|
1792
|
+
}
|
|
1793
|
+
/**
|
|
1794
|
+
* Remove the entry in the URL storage, if it has been saved before.
|
|
1795
|
+
*
|
|
1796
|
+
* @api private
|
|
1797
|
+
*/
|
|
1798
|
+
}, {
|
|
1799
|
+
key: "_removeFromUrlStorage",
|
|
1800
|
+
value: function _removeFromUrlStorage() {
|
|
1801
|
+
var _this10 = this;
|
|
1802
|
+
if (!this._urlStorageKey) return;
|
|
1803
|
+
this._urlStorage.removeUpload(this._urlStorageKey)["catch"](function(err) {
|
|
1804
|
+
_this10._emitError(err);
|
|
1805
|
+
});
|
|
1806
|
+
this._urlStorageKey = null;
|
|
1807
|
+
}
|
|
1808
|
+
/**
|
|
1809
|
+
* Add the upload URL to the URL storage, if possible.
|
|
1810
|
+
*
|
|
1811
|
+
* @api private
|
|
1812
|
+
*/
|
|
1813
|
+
}, {
|
|
1814
|
+
key: "_saveUploadInUrlStorage",
|
|
1815
|
+
value: function _saveUploadInUrlStorage() {
|
|
1816
|
+
var _this11 = this;
|
|
1817
|
+
if (!this.options.storeFingerprintForResuming || !this._fingerprint || this._urlStorageKey !== null) {
|
|
1818
|
+
return Promise.resolve();
|
|
1819
|
+
}
|
|
1820
|
+
var storedUpload = {
|
|
1821
|
+
size: this._size,
|
|
1822
|
+
metadata: this.options.metadata,
|
|
1823
|
+
creationTime: (/* @__PURE__ */ new Date()).toString()
|
|
1824
|
+
};
|
|
1825
|
+
if (this._parallelUploads) {
|
|
1826
|
+
storedUpload.parallelUploadUrls = this._parallelUploadUrls;
|
|
1827
|
+
} else {
|
|
1828
|
+
storedUpload.uploadUrl = this.url;
|
|
1829
|
+
}
|
|
1830
|
+
return this._urlStorage.addUpload(this._fingerprint, storedUpload).then(function(urlStorageKey) {
|
|
1831
|
+
_this11._urlStorageKey = urlStorageKey;
|
|
1832
|
+
});
|
|
1833
|
+
}
|
|
1834
|
+
/**
|
|
1835
|
+
* Send a request with the provided body.
|
|
1836
|
+
*
|
|
1837
|
+
* @api private
|
|
1838
|
+
*/
|
|
1839
|
+
}, {
|
|
1840
|
+
key: "_sendRequest",
|
|
1841
|
+
value: function _sendRequest(req) {
|
|
1842
|
+
var body = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : null;
|
|
1843
|
+
return sendRequest(req, body, this.options);
|
|
1844
|
+
}
|
|
1845
|
+
}], [{
|
|
1846
|
+
key: "terminate",
|
|
1847
|
+
value: function terminate(url) {
|
|
1848
|
+
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
1849
|
+
var req = openRequest("DELETE", url, options);
|
|
1850
|
+
return sendRequest(req, null, options).then(function(res) {
|
|
1851
|
+
if (res.getStatus() === 204) {
|
|
1852
|
+
return;
|
|
1853
|
+
}
|
|
1854
|
+
throw new DetailedError("tus: unexpected response while terminating upload", null, req, res);
|
|
1855
|
+
})["catch"](function(err) {
|
|
1856
|
+
if (!(err instanceof DetailedError)) {
|
|
1857
|
+
err = new DetailedError("tus: failed to terminate upload", err, req, null);
|
|
1858
|
+
}
|
|
1859
|
+
if (!shouldRetry(err, 0, options)) {
|
|
1860
|
+
throw err;
|
|
1861
|
+
}
|
|
1862
|
+
var delay = options.retryDelays[0];
|
|
1863
|
+
var remainingDelays = options.retryDelays.slice(1);
|
|
1864
|
+
var newOptions = _objectSpread$1(_objectSpread$1({}, options), {}, {
|
|
1865
|
+
retryDelays: remainingDelays
|
|
1866
|
+
});
|
|
1867
|
+
return new Promise(function(resolve) {
|
|
1868
|
+
return setTimeout(resolve, delay);
|
|
1869
|
+
}).then(function() {
|
|
1870
|
+
return BaseUpload2.terminate(url, newOptions);
|
|
1871
|
+
});
|
|
1872
|
+
});
|
|
1873
|
+
}
|
|
1874
|
+
}]);
|
|
1875
|
+
})();
|
|
1876
|
+
function encodeMetadata(metadata) {
|
|
1877
|
+
return Object.entries(metadata).map(function(_ref3) {
|
|
1878
|
+
var _ref4 = _slicedToArray(_ref3, 2), key = _ref4[0], value = _ref4[1];
|
|
1879
|
+
return "".concat(key, " ").concat(gBase64.encode(String(value)));
|
|
1880
|
+
}).join(",");
|
|
1881
|
+
}
|
|
1882
|
+
function inStatusCategory(status, category) {
|
|
1883
|
+
return status >= category && status < category + 100;
|
|
1884
|
+
}
|
|
1885
|
+
function openRequest(method, url, options) {
|
|
1886
|
+
var req = options.httpStack.createRequest(method, url);
|
|
1887
|
+
if (options.protocol === PROTOCOL_IETF_DRAFT_03) {
|
|
1888
|
+
req.setHeader("Upload-Draft-Interop-Version", "5");
|
|
1889
|
+
} else if (options.protocol === PROTOCOL_IETF_DRAFT_05) {
|
|
1890
|
+
req.setHeader("Upload-Draft-Interop-Version", "6");
|
|
1891
|
+
} else {
|
|
1892
|
+
req.setHeader("Tus-Resumable", "1.0.0");
|
|
1893
|
+
}
|
|
1894
|
+
var headers = options.headers || {};
|
|
1895
|
+
for (var _i2 = 0, _Object$entries = Object.entries(headers); _i2 < _Object$entries.length; _i2++) {
|
|
1896
|
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i2], 2), name = _Object$entries$_i[0], value = _Object$entries$_i[1];
|
|
1897
|
+
req.setHeader(name, value);
|
|
1898
|
+
}
|
|
1899
|
+
if (options.addRequestId) {
|
|
1900
|
+
var requestId = uuid();
|
|
1901
|
+
req.setHeader("X-Request-ID", requestId);
|
|
1902
|
+
}
|
|
1903
|
+
return req;
|
|
1904
|
+
}
|
|
1905
|
+
function sendRequest(_x, _x2, _x3) {
|
|
1906
|
+
return _sendRequest2.apply(this, arguments);
|
|
1907
|
+
}
|
|
1908
|
+
function _sendRequest2() {
|
|
1909
|
+
_sendRequest2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee(req, body, options) {
|
|
1910
|
+
var res;
|
|
1911
|
+
return _regeneratorRuntime$1().wrap(function _callee$(_context) {
|
|
1912
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1913
|
+
case 0:
|
|
1914
|
+
if (!(typeof options.onBeforeRequest === "function")) {
|
|
1915
|
+
_context.next = 3;
|
|
1916
|
+
break;
|
|
1917
|
+
}
|
|
1918
|
+
_context.next = 3;
|
|
1919
|
+
return options.onBeforeRequest(req);
|
|
1920
|
+
case 3:
|
|
1921
|
+
_context.next = 5;
|
|
1922
|
+
return req.send(body);
|
|
1923
|
+
case 5:
|
|
1924
|
+
res = _context.sent;
|
|
1925
|
+
if (!(typeof options.onAfterResponse === "function")) {
|
|
1926
|
+
_context.next = 9;
|
|
1927
|
+
break;
|
|
1928
|
+
}
|
|
1929
|
+
_context.next = 9;
|
|
1930
|
+
return options.onAfterResponse(req, res);
|
|
1931
|
+
case 9:
|
|
1932
|
+
return _context.abrupt("return", res);
|
|
1933
|
+
case 10:
|
|
1934
|
+
case "end":
|
|
1935
|
+
return _context.stop();
|
|
1936
|
+
}
|
|
1937
|
+
}, _callee);
|
|
1938
|
+
}));
|
|
1939
|
+
return _sendRequest2.apply(this, arguments);
|
|
1940
|
+
}
|
|
1941
|
+
function isOnline() {
|
|
1942
|
+
var online = true;
|
|
1943
|
+
if (typeof navigator !== "undefined" && navigator.onLine === false) {
|
|
1944
|
+
online = false;
|
|
1945
|
+
}
|
|
1946
|
+
return online;
|
|
1947
|
+
}
|
|
1948
|
+
function shouldRetry(err, retryAttempt, options) {
|
|
1949
|
+
if (options.retryDelays == null || retryAttempt >= options.retryDelays.length || err.originalRequest == null) {
|
|
1950
|
+
return false;
|
|
1951
|
+
}
|
|
1952
|
+
if (options && typeof options.onShouldRetry === "function") {
|
|
1953
|
+
return options.onShouldRetry(err, retryAttempt, options);
|
|
1954
|
+
}
|
|
1955
|
+
return defaultOnShouldRetry(err);
|
|
1956
|
+
}
|
|
1957
|
+
function defaultOnShouldRetry(err) {
|
|
1958
|
+
var status = err.originalResponse ? err.originalResponse.getStatus() : 0;
|
|
1959
|
+
return (!inStatusCategory(status, 400) || status === 409 || status === 423) && isOnline();
|
|
1960
|
+
}
|
|
1961
|
+
function resolveUrl(origin, link) {
|
|
1962
|
+
return new urlParseExports(link, origin).toString();
|
|
1963
|
+
}
|
|
1964
|
+
function splitSizeIntoParts(totalSize, partCount) {
|
|
1965
|
+
var partSize = Math.floor(totalSize / partCount);
|
|
1966
|
+
var parts = [];
|
|
1967
|
+
for (var i = 0; i < partCount; i++) {
|
|
1968
|
+
parts.push({
|
|
1969
|
+
start: partSize * i,
|
|
1970
|
+
end: partSize * (i + 1)
|
|
1971
|
+
});
|
|
1972
|
+
}
|
|
1973
|
+
parts[partCount - 1].end = totalSize;
|
|
1974
|
+
return parts;
|
|
1975
|
+
}
|
|
1976
|
+
BaseUpload.defaultOptions = defaultOptions$1;
|
|
1977
|
+
var isReactNative = function isReactNative2() {
|
|
1978
|
+
return typeof navigator !== "undefined" && typeof navigator.product === "string" && navigator.product.toLowerCase() === "reactnative";
|
|
1979
|
+
};
|
|
1980
|
+
function uriToBlob(uri) {
|
|
1981
|
+
return new Promise(function(resolve, reject) {
|
|
1982
|
+
var xhr = new XMLHttpRequest();
|
|
1983
|
+
xhr.responseType = "blob";
|
|
1984
|
+
xhr.onload = function() {
|
|
1985
|
+
var blob = xhr.response;
|
|
1986
|
+
resolve(blob);
|
|
1987
|
+
};
|
|
1988
|
+
xhr.onerror = function(err) {
|
|
1989
|
+
reject(err);
|
|
1990
|
+
};
|
|
1991
|
+
xhr.open("GET", uri);
|
|
1992
|
+
xhr.send();
|
|
1993
|
+
});
|
|
1994
|
+
}
|
|
1995
|
+
var isCordova = function isCordova2() {
|
|
1996
|
+
return typeof window !== "undefined" && (typeof window.PhoneGap !== "undefined" || typeof window.Cordova !== "undefined" || typeof window.cordova !== "undefined");
|
|
1997
|
+
};
|
|
1998
|
+
function readAsByteArray(chunk) {
|
|
1999
|
+
return new Promise(function(resolve, reject) {
|
|
2000
|
+
var reader = new FileReader();
|
|
2001
|
+
reader.onload = function() {
|
|
2002
|
+
var value = new Uint8Array(reader.result);
|
|
2003
|
+
resolve({
|
|
2004
|
+
value
|
|
2005
|
+
});
|
|
2006
|
+
};
|
|
2007
|
+
reader.onerror = function(err) {
|
|
2008
|
+
reject(err);
|
|
2009
|
+
};
|
|
2010
|
+
reader.readAsArrayBuffer(chunk);
|
|
2011
|
+
});
|
|
2012
|
+
}
|
|
2013
|
+
function _typeof$5(o) {
|
|
2014
|
+
"@babel/helpers - typeof";
|
|
2015
|
+
return _typeof$5 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
|
|
2016
|
+
return typeof o2;
|
|
2017
|
+
} : function(o2) {
|
|
2018
|
+
return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
|
|
2019
|
+
}, _typeof$5(o);
|
|
2020
|
+
}
|
|
2021
|
+
function _classCallCheck$5(instance, Constructor) {
|
|
2022
|
+
if (!(instance instanceof Constructor)) {
|
|
2023
|
+
throw new TypeError("Cannot call a class as a function");
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2026
|
+
function _defineProperties$5(target, props) {
|
|
2027
|
+
for (var i = 0; i < props.length; i++) {
|
|
2028
|
+
var descriptor = props[i];
|
|
2029
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
2030
|
+
descriptor.configurable = true;
|
|
2031
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
2032
|
+
Object.defineProperty(target, _toPropertyKey$5(descriptor.key), descriptor);
|
|
2033
|
+
}
|
|
2034
|
+
}
|
|
2035
|
+
function _createClass$5(Constructor, protoProps, staticProps) {
|
|
2036
|
+
if (protoProps) _defineProperties$5(Constructor.prototype, protoProps);
|
|
2037
|
+
Object.defineProperty(Constructor, "prototype", { writable: false });
|
|
2038
|
+
return Constructor;
|
|
2039
|
+
}
|
|
2040
|
+
function _toPropertyKey$5(t) {
|
|
2041
|
+
var i = _toPrimitive$5(t, "string");
|
|
2042
|
+
return "symbol" == _typeof$5(i) ? i : i + "";
|
|
2043
|
+
}
|
|
2044
|
+
function _toPrimitive$5(t, r) {
|
|
2045
|
+
if ("object" != _typeof$5(t) || !t) return t;
|
|
2046
|
+
var e = t[Symbol.toPrimitive];
|
|
2047
|
+
if (void 0 !== e) {
|
|
2048
|
+
var i = e.call(t, r);
|
|
2049
|
+
if ("object" != _typeof$5(i)) return i;
|
|
2050
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
2051
|
+
}
|
|
2052
|
+
return String(t);
|
|
2053
|
+
}
|
|
2054
|
+
var FileSource = /* @__PURE__ */ (function() {
|
|
2055
|
+
function FileSource2(file) {
|
|
2056
|
+
_classCallCheck$5(this, FileSource2);
|
|
2057
|
+
this._file = file;
|
|
2058
|
+
this.size = file.size;
|
|
2059
|
+
}
|
|
2060
|
+
return _createClass$5(FileSource2, [{
|
|
2061
|
+
key: "slice",
|
|
2062
|
+
value: function slice(start, end) {
|
|
2063
|
+
if (isCordova()) {
|
|
2064
|
+
return readAsByteArray(this._file.slice(start, end));
|
|
2065
|
+
}
|
|
2066
|
+
var value = this._file.slice(start, end);
|
|
2067
|
+
var done = end >= this.size;
|
|
2068
|
+
return Promise.resolve({
|
|
2069
|
+
value,
|
|
2070
|
+
done
|
|
2071
|
+
});
|
|
2072
|
+
}
|
|
2073
|
+
}, {
|
|
2074
|
+
key: "close",
|
|
2075
|
+
value: function close() {
|
|
2076
|
+
}
|
|
2077
|
+
}]);
|
|
2078
|
+
})();
|
|
2079
|
+
function _typeof$4(o) {
|
|
2080
|
+
"@babel/helpers - typeof";
|
|
2081
|
+
return _typeof$4 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
|
|
2082
|
+
return typeof o2;
|
|
2083
|
+
} : function(o2) {
|
|
2084
|
+
return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
|
|
2085
|
+
}, _typeof$4(o);
|
|
2086
|
+
}
|
|
2087
|
+
function _classCallCheck$4(instance, Constructor) {
|
|
2088
|
+
if (!(instance instanceof Constructor)) {
|
|
2089
|
+
throw new TypeError("Cannot call a class as a function");
|
|
2090
|
+
}
|
|
2091
|
+
}
|
|
2092
|
+
function _defineProperties$4(target, props) {
|
|
2093
|
+
for (var i = 0; i < props.length; i++) {
|
|
2094
|
+
var descriptor = props[i];
|
|
2095
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
2096
|
+
descriptor.configurable = true;
|
|
2097
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
2098
|
+
Object.defineProperty(target, _toPropertyKey$4(descriptor.key), descriptor);
|
|
2099
|
+
}
|
|
2100
|
+
}
|
|
2101
|
+
function _createClass$4(Constructor, protoProps, staticProps) {
|
|
2102
|
+
if (protoProps) _defineProperties$4(Constructor.prototype, protoProps);
|
|
2103
|
+
Object.defineProperty(Constructor, "prototype", { writable: false });
|
|
2104
|
+
return Constructor;
|
|
2105
|
+
}
|
|
2106
|
+
function _toPropertyKey$4(t) {
|
|
2107
|
+
var i = _toPrimitive$4(t, "string");
|
|
2108
|
+
return "symbol" == _typeof$4(i) ? i : i + "";
|
|
2109
|
+
}
|
|
2110
|
+
function _toPrimitive$4(t, r) {
|
|
2111
|
+
if ("object" != _typeof$4(t) || !t) return t;
|
|
2112
|
+
var e = t[Symbol.toPrimitive];
|
|
2113
|
+
if (void 0 !== e) {
|
|
2114
|
+
var i = e.call(t, r);
|
|
2115
|
+
if ("object" != _typeof$4(i)) return i;
|
|
2116
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
2117
|
+
}
|
|
2118
|
+
return String(t);
|
|
2119
|
+
}
|
|
2120
|
+
function len(blobOrArray) {
|
|
2121
|
+
if (blobOrArray === void 0) return 0;
|
|
2122
|
+
if (blobOrArray.size !== void 0) return blobOrArray.size;
|
|
2123
|
+
return blobOrArray.length;
|
|
2124
|
+
}
|
|
2125
|
+
function concat(a, b) {
|
|
2126
|
+
if (a.concat) {
|
|
2127
|
+
return a.concat(b);
|
|
2128
|
+
}
|
|
2129
|
+
if (a instanceof Blob) {
|
|
2130
|
+
return new Blob([a, b], {
|
|
2131
|
+
type: a.type
|
|
2132
|
+
});
|
|
2133
|
+
}
|
|
2134
|
+
if (a.set) {
|
|
2135
|
+
var c2 = new a.constructor(a.length + b.length);
|
|
2136
|
+
c2.set(a);
|
|
2137
|
+
c2.set(b, a.length);
|
|
2138
|
+
return c2;
|
|
2139
|
+
}
|
|
2140
|
+
throw new Error("Unknown data type");
|
|
2141
|
+
}
|
|
2142
|
+
var StreamSource = /* @__PURE__ */ (function() {
|
|
2143
|
+
function StreamSource2(reader) {
|
|
2144
|
+
_classCallCheck$4(this, StreamSource2);
|
|
2145
|
+
this._buffer = void 0;
|
|
2146
|
+
this._bufferOffset = 0;
|
|
2147
|
+
this._reader = reader;
|
|
2148
|
+
this._done = false;
|
|
2149
|
+
}
|
|
2150
|
+
return _createClass$4(StreamSource2, [{
|
|
2151
|
+
key: "slice",
|
|
2152
|
+
value: function slice(start, end) {
|
|
2153
|
+
if (start < this._bufferOffset) {
|
|
2154
|
+
return Promise.reject(new Error("Requested data is before the reader's current offset"));
|
|
2155
|
+
}
|
|
2156
|
+
return this._readUntilEnoughDataOrDone(start, end);
|
|
2157
|
+
}
|
|
2158
|
+
}, {
|
|
2159
|
+
key: "_readUntilEnoughDataOrDone",
|
|
2160
|
+
value: function _readUntilEnoughDataOrDone(start, end) {
|
|
2161
|
+
var _this = this;
|
|
2162
|
+
var hasEnoughData = end <= this._bufferOffset + len(this._buffer);
|
|
2163
|
+
if (this._done || hasEnoughData) {
|
|
2164
|
+
var value = this._getDataFromBuffer(start, end);
|
|
2165
|
+
var done = value == null ? this._done : false;
|
|
2166
|
+
return Promise.resolve({
|
|
2167
|
+
value,
|
|
2168
|
+
done
|
|
2169
|
+
});
|
|
2170
|
+
}
|
|
2171
|
+
return this._reader.read().then(function(_ref) {
|
|
2172
|
+
var value2 = _ref.value, done2 = _ref.done;
|
|
2173
|
+
if (done2) {
|
|
2174
|
+
_this._done = true;
|
|
2175
|
+
} else if (_this._buffer === void 0) {
|
|
2176
|
+
_this._buffer = value2;
|
|
2177
|
+
} else {
|
|
2178
|
+
_this._buffer = concat(_this._buffer, value2);
|
|
2179
|
+
}
|
|
2180
|
+
return _this._readUntilEnoughDataOrDone(start, end);
|
|
2181
|
+
});
|
|
2182
|
+
}
|
|
2183
|
+
}, {
|
|
2184
|
+
key: "_getDataFromBuffer",
|
|
2185
|
+
value: function _getDataFromBuffer(start, end) {
|
|
2186
|
+
if (start > this._bufferOffset) {
|
|
2187
|
+
this._buffer = this._buffer.slice(start - this._bufferOffset);
|
|
2188
|
+
this._bufferOffset = start;
|
|
2189
|
+
}
|
|
2190
|
+
var hasAllDataBeenRead = len(this._buffer) === 0;
|
|
2191
|
+
if (this._done && hasAllDataBeenRead) {
|
|
2192
|
+
return null;
|
|
2193
|
+
}
|
|
2194
|
+
return this._buffer.slice(0, end - start);
|
|
2195
|
+
}
|
|
2196
|
+
}, {
|
|
2197
|
+
key: "close",
|
|
2198
|
+
value: function close() {
|
|
2199
|
+
if (this._reader.cancel) {
|
|
2200
|
+
this._reader.cancel();
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
2203
|
+
}]);
|
|
2204
|
+
})();
|
|
2205
|
+
function _typeof$3(o) {
|
|
2206
|
+
"@babel/helpers - typeof";
|
|
2207
|
+
return _typeof$3 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
|
|
2208
|
+
return typeof o2;
|
|
2209
|
+
} : function(o2) {
|
|
2210
|
+
return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
|
|
2211
|
+
}, _typeof$3(o);
|
|
2212
|
+
}
|
|
2213
|
+
function _regeneratorRuntime() {
|
|
2214
|
+
_regeneratorRuntime = function _regeneratorRuntime2() {
|
|
2215
|
+
return e;
|
|
2216
|
+
};
|
|
2217
|
+
var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function(t2, e2, r2) {
|
|
2218
|
+
t2[e2] = r2.value;
|
|
2219
|
+
}, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c2 = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag";
|
|
2220
|
+
function define(t2, e2, r2) {
|
|
2221
|
+
return Object.defineProperty(t2, e2, { value: r2, enumerable: true, configurable: true, writable: true }), t2[e2];
|
|
2222
|
+
}
|
|
2223
|
+
try {
|
|
2224
|
+
define({}, "");
|
|
2225
|
+
} catch (t2) {
|
|
2226
|
+
define = function define2(t3, e2, r2) {
|
|
2227
|
+
return t3[e2] = r2;
|
|
2228
|
+
};
|
|
2229
|
+
}
|
|
2230
|
+
function wrap(t2, e2, r2, n2) {
|
|
2231
|
+
var i2 = e2 && e2.prototype instanceof Generator ? e2 : Generator, a2 = Object.create(i2.prototype), c3 = new Context(n2 || []);
|
|
2232
|
+
return o(a2, "_invoke", { value: makeInvokeMethod(t2, r2, c3) }), a2;
|
|
2233
|
+
}
|
|
2234
|
+
function tryCatch(t2, e2, r2) {
|
|
2235
|
+
try {
|
|
2236
|
+
return { type: "normal", arg: t2.call(e2, r2) };
|
|
2237
|
+
} catch (t3) {
|
|
2238
|
+
return { type: "throw", arg: t3 };
|
|
2239
|
+
}
|
|
2240
|
+
}
|
|
2241
|
+
e.wrap = wrap;
|
|
2242
|
+
var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {};
|
|
2243
|
+
function Generator() {
|
|
2244
|
+
}
|
|
2245
|
+
function GeneratorFunction() {
|
|
2246
|
+
}
|
|
2247
|
+
function GeneratorFunctionPrototype() {
|
|
2248
|
+
}
|
|
2249
|
+
var p = {};
|
|
2250
|
+
define(p, a, function() {
|
|
2251
|
+
return this;
|
|
2252
|
+
});
|
|
2253
|
+
var d = Object.getPrototypeOf, v = d && d(d(values([])));
|
|
2254
|
+
v && v !== r && n.call(v, a) && (p = v);
|
|
2255
|
+
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
|
2256
|
+
function defineIteratorMethods(t2) {
|
|
2257
|
+
["next", "throw", "return"].forEach(function(e2) {
|
|
2258
|
+
define(t2, e2, function(t3) {
|
|
2259
|
+
return this._invoke(e2, t3);
|
|
2260
|
+
});
|
|
2261
|
+
});
|
|
2262
|
+
}
|
|
2263
|
+
function AsyncIterator(t2, e2) {
|
|
2264
|
+
function invoke(r3, o2, i2, a2) {
|
|
2265
|
+
var c3 = tryCatch(t2[r3], t2, o2);
|
|
2266
|
+
if ("throw" !== c3.type) {
|
|
2267
|
+
var u2 = c3.arg, h2 = u2.value;
|
|
2268
|
+
return h2 && "object" == _typeof$3(h2) && n.call(h2, "__await") ? e2.resolve(h2.__await).then(function(t3) {
|
|
2269
|
+
invoke("next", t3, i2, a2);
|
|
2270
|
+
}, function(t3) {
|
|
2271
|
+
invoke("throw", t3, i2, a2);
|
|
2272
|
+
}) : e2.resolve(h2).then(function(t3) {
|
|
2273
|
+
u2.value = t3, i2(u2);
|
|
2274
|
+
}, function(t3) {
|
|
2275
|
+
return invoke("throw", t3, i2, a2);
|
|
2276
|
+
});
|
|
2277
|
+
}
|
|
2278
|
+
a2(c3.arg);
|
|
2279
|
+
}
|
|
2280
|
+
var r2;
|
|
2281
|
+
o(this, "_invoke", { value: function value(t3, n2) {
|
|
2282
|
+
function callInvokeWithMethodAndArg() {
|
|
2283
|
+
return new e2(function(e3, r3) {
|
|
2284
|
+
invoke(t3, n2, e3, r3);
|
|
2285
|
+
});
|
|
2286
|
+
}
|
|
2287
|
+
return r2 = r2 ? r2.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
2288
|
+
} });
|
|
2289
|
+
}
|
|
2290
|
+
function makeInvokeMethod(e2, r2, n2) {
|
|
2291
|
+
var o2 = h;
|
|
2292
|
+
return function(i2, a2) {
|
|
2293
|
+
if (o2 === f) throw Error("Generator is already running");
|
|
2294
|
+
if (o2 === s) {
|
|
2295
|
+
if ("throw" === i2) throw a2;
|
|
2296
|
+
return { value: t, done: true };
|
|
2297
|
+
}
|
|
2298
|
+
for (n2.method = i2, n2.arg = a2; ; ) {
|
|
2299
|
+
var c3 = n2.delegate;
|
|
2300
|
+
if (c3) {
|
|
2301
|
+
var u2 = maybeInvokeDelegate(c3, n2);
|
|
2302
|
+
if (u2) {
|
|
2303
|
+
if (u2 === y) continue;
|
|
2304
|
+
return u2;
|
|
2305
|
+
}
|
|
2306
|
+
}
|
|
2307
|
+
if ("next" === n2.method) n2.sent = n2._sent = n2.arg;
|
|
2308
|
+
else if ("throw" === n2.method) {
|
|
2309
|
+
if (o2 === h) throw o2 = s, n2.arg;
|
|
2310
|
+
n2.dispatchException(n2.arg);
|
|
2311
|
+
} else "return" === n2.method && n2.abrupt("return", n2.arg);
|
|
2312
|
+
o2 = f;
|
|
2313
|
+
var p2 = tryCatch(e2, r2, n2);
|
|
2314
|
+
if ("normal" === p2.type) {
|
|
2315
|
+
if (o2 = n2.done ? s : l, p2.arg === y) continue;
|
|
2316
|
+
return { value: p2.arg, done: n2.done };
|
|
2317
|
+
}
|
|
2318
|
+
"throw" === p2.type && (o2 = s, n2.method = "throw", n2.arg = p2.arg);
|
|
2319
|
+
}
|
|
2320
|
+
};
|
|
2321
|
+
}
|
|
2322
|
+
function maybeInvokeDelegate(e2, r2) {
|
|
2323
|
+
var n2 = r2.method, o2 = e2.iterator[n2];
|
|
2324
|
+
if (o2 === t) return r2.delegate = null, "throw" === n2 && e2.iterator["return"] && (r2.method = "return", r2.arg = t, maybeInvokeDelegate(e2, r2), "throw" === r2.method) || "return" !== n2 && (r2.method = "throw", r2.arg = new TypeError("The iterator does not provide a '" + n2 + "' method")), y;
|
|
2325
|
+
var i2 = tryCatch(o2, e2.iterator, r2.arg);
|
|
2326
|
+
if ("throw" === i2.type) return r2.method = "throw", r2.arg = i2.arg, r2.delegate = null, y;
|
|
2327
|
+
var a2 = i2.arg;
|
|
2328
|
+
return a2 ? a2.done ? (r2[e2.resultName] = a2.value, r2.next = e2.nextLoc, "return" !== r2.method && (r2.method = "next", r2.arg = t), r2.delegate = null, y) : a2 : (r2.method = "throw", r2.arg = new TypeError("iterator result is not an object"), r2.delegate = null, y);
|
|
2329
|
+
}
|
|
2330
|
+
function pushTryEntry(t2) {
|
|
2331
|
+
var e2 = { tryLoc: t2[0] };
|
|
2332
|
+
1 in t2 && (e2.catchLoc = t2[1]), 2 in t2 && (e2.finallyLoc = t2[2], e2.afterLoc = t2[3]), this.tryEntries.push(e2);
|
|
2333
|
+
}
|
|
2334
|
+
function resetTryEntry(t2) {
|
|
2335
|
+
var e2 = t2.completion || {};
|
|
2336
|
+
e2.type = "normal", delete e2.arg, t2.completion = e2;
|
|
2337
|
+
}
|
|
2338
|
+
function Context(t2) {
|
|
2339
|
+
this.tryEntries = [{ tryLoc: "root" }], t2.forEach(pushTryEntry, this), this.reset(true);
|
|
2340
|
+
}
|
|
2341
|
+
function values(e2) {
|
|
2342
|
+
if (e2 || "" === e2) {
|
|
2343
|
+
var r2 = e2[a];
|
|
2344
|
+
if (r2) return r2.call(e2);
|
|
2345
|
+
if ("function" == typeof e2.next) return e2;
|
|
2346
|
+
if (!isNaN(e2.length)) {
|
|
2347
|
+
var o2 = -1, i2 = function next() {
|
|
2348
|
+
for (; ++o2 < e2.length; ) if (n.call(e2, o2)) return next.value = e2[o2], next.done = false, next;
|
|
2349
|
+
return next.value = t, next.done = true, next;
|
|
2350
|
+
};
|
|
2351
|
+
return i2.next = i2;
|
|
2352
|
+
}
|
|
2353
|
+
}
|
|
2354
|
+
throw new TypeError(_typeof$3(e2) + " is not iterable");
|
|
2355
|
+
}
|
|
2356
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: true }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: true }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function(t2) {
|
|
2357
|
+
var e2 = "function" == typeof t2 && t2.constructor;
|
|
2358
|
+
return !!e2 && (e2 === GeneratorFunction || "GeneratorFunction" === (e2.displayName || e2.name));
|
|
2359
|
+
}, e.mark = function(t2) {
|
|
2360
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(t2, GeneratorFunctionPrototype) : (t2.__proto__ = GeneratorFunctionPrototype, define(t2, u, "GeneratorFunction")), t2.prototype = Object.create(g), t2;
|
|
2361
|
+
}, e.awrap = function(t2) {
|
|
2362
|
+
return { __await: t2 };
|
|
2363
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c2, function() {
|
|
2364
|
+
return this;
|
|
2365
|
+
}), e.AsyncIterator = AsyncIterator, e.async = function(t2, r2, n2, o2, i2) {
|
|
2366
|
+
void 0 === i2 && (i2 = Promise);
|
|
2367
|
+
var a2 = new AsyncIterator(wrap(t2, r2, n2, o2), i2);
|
|
2368
|
+
return e.isGeneratorFunction(r2) ? a2 : a2.next().then(function(t3) {
|
|
2369
|
+
return t3.done ? t3.value : a2.next();
|
|
2370
|
+
});
|
|
2371
|
+
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function() {
|
|
2372
|
+
return this;
|
|
2373
|
+
}), define(g, "toString", function() {
|
|
2374
|
+
return "[object Generator]";
|
|
2375
|
+
}), e.keys = function(t2) {
|
|
2376
|
+
var e2 = Object(t2), r2 = [];
|
|
2377
|
+
for (var n2 in e2) r2.push(n2);
|
|
2378
|
+
return r2.reverse(), function next() {
|
|
2379
|
+
for (; r2.length; ) {
|
|
2380
|
+
var t3 = r2.pop();
|
|
2381
|
+
if (t3 in e2) return next.value = t3, next.done = false, next;
|
|
2382
|
+
}
|
|
2383
|
+
return next.done = true, next;
|
|
2384
|
+
};
|
|
2385
|
+
}, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e2) {
|
|
2386
|
+
if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = false, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e2) for (var r2 in this) "t" === r2.charAt(0) && n.call(this, r2) && !isNaN(+r2.slice(1)) && (this[r2] = t);
|
|
2387
|
+
}, stop: function stop() {
|
|
2388
|
+
this.done = true;
|
|
2389
|
+
var t2 = this.tryEntries[0].completion;
|
|
2390
|
+
if ("throw" === t2.type) throw t2.arg;
|
|
2391
|
+
return this.rval;
|
|
2392
|
+
}, dispatchException: function dispatchException(e2) {
|
|
2393
|
+
if (this.done) throw e2;
|
|
2394
|
+
var r2 = this;
|
|
2395
|
+
function handle(n2, o3) {
|
|
2396
|
+
return a2.type = "throw", a2.arg = e2, r2.next = n2, o3 && (r2.method = "next", r2.arg = t), !!o3;
|
|
2397
|
+
}
|
|
2398
|
+
for (var o2 = this.tryEntries.length - 1; o2 >= 0; --o2) {
|
|
2399
|
+
var i2 = this.tryEntries[o2], a2 = i2.completion;
|
|
2400
|
+
if ("root" === i2.tryLoc) return handle("end");
|
|
2401
|
+
if (i2.tryLoc <= this.prev) {
|
|
2402
|
+
var c3 = n.call(i2, "catchLoc"), u2 = n.call(i2, "finallyLoc");
|
|
2403
|
+
if (c3 && u2) {
|
|
2404
|
+
if (this.prev < i2.catchLoc) return handle(i2.catchLoc, true);
|
|
2405
|
+
if (this.prev < i2.finallyLoc) return handle(i2.finallyLoc);
|
|
2406
|
+
} else if (c3) {
|
|
2407
|
+
if (this.prev < i2.catchLoc) return handle(i2.catchLoc, true);
|
|
2408
|
+
} else {
|
|
2409
|
+
if (!u2) throw Error("try statement without catch or finally");
|
|
2410
|
+
if (this.prev < i2.finallyLoc) return handle(i2.finallyLoc);
|
|
2411
|
+
}
|
|
2412
|
+
}
|
|
2413
|
+
}
|
|
2414
|
+
}, abrupt: function abrupt(t2, e2) {
|
|
2415
|
+
for (var r2 = this.tryEntries.length - 1; r2 >= 0; --r2) {
|
|
2416
|
+
var o2 = this.tryEntries[r2];
|
|
2417
|
+
if (o2.tryLoc <= this.prev && n.call(o2, "finallyLoc") && this.prev < o2.finallyLoc) {
|
|
2418
|
+
var i2 = o2;
|
|
2419
|
+
break;
|
|
2420
|
+
}
|
|
2421
|
+
}
|
|
2422
|
+
i2 && ("break" === t2 || "continue" === t2) && i2.tryLoc <= e2 && e2 <= i2.finallyLoc && (i2 = null);
|
|
2423
|
+
var a2 = i2 ? i2.completion : {};
|
|
2424
|
+
return a2.type = t2, a2.arg = e2, i2 ? (this.method = "next", this.next = i2.finallyLoc, y) : this.complete(a2);
|
|
2425
|
+
}, complete: function complete(t2, e2) {
|
|
2426
|
+
if ("throw" === t2.type) throw t2.arg;
|
|
2427
|
+
return "break" === t2.type || "continue" === t2.type ? this.next = t2.arg : "return" === t2.type ? (this.rval = this.arg = t2.arg, this.method = "return", this.next = "end") : "normal" === t2.type && e2 && (this.next = e2), y;
|
|
2428
|
+
}, finish: function finish(t2) {
|
|
2429
|
+
for (var e2 = this.tryEntries.length - 1; e2 >= 0; --e2) {
|
|
2430
|
+
var r2 = this.tryEntries[e2];
|
|
2431
|
+
if (r2.finallyLoc === t2) return this.complete(r2.completion, r2.afterLoc), resetTryEntry(r2), y;
|
|
2432
|
+
}
|
|
2433
|
+
}, "catch": function _catch(t2) {
|
|
2434
|
+
for (var e2 = this.tryEntries.length - 1; e2 >= 0; --e2) {
|
|
2435
|
+
var r2 = this.tryEntries[e2];
|
|
2436
|
+
if (r2.tryLoc === t2) {
|
|
2437
|
+
var n2 = r2.completion;
|
|
2438
|
+
if ("throw" === n2.type) {
|
|
2439
|
+
var o2 = n2.arg;
|
|
2440
|
+
resetTryEntry(r2);
|
|
2441
|
+
}
|
|
2442
|
+
return o2;
|
|
2443
|
+
}
|
|
2444
|
+
}
|
|
2445
|
+
throw Error("illegal catch attempt");
|
|
2446
|
+
}, delegateYield: function delegateYield(e2, r2, n2) {
|
|
2447
|
+
return this.delegate = { iterator: values(e2), resultName: r2, nextLoc: n2 }, "next" === this.method && (this.arg = t), y;
|
|
2448
|
+
} }, e;
|
|
2449
|
+
}
|
|
2450
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2451
|
+
try {
|
|
2452
|
+
var info = gen[key](arg);
|
|
2453
|
+
var value = info.value;
|
|
2454
|
+
} catch (error) {
|
|
2455
|
+
reject(error);
|
|
2456
|
+
return;
|
|
2457
|
+
}
|
|
2458
|
+
if (info.done) {
|
|
2459
|
+
resolve(value);
|
|
2460
|
+
} else {
|
|
2461
|
+
Promise.resolve(value).then(_next, _throw);
|
|
2462
|
+
}
|
|
2463
|
+
}
|
|
2464
|
+
function _asyncToGenerator(fn) {
|
|
2465
|
+
return function() {
|
|
2466
|
+
var self2 = this, args = arguments;
|
|
2467
|
+
return new Promise(function(resolve, reject) {
|
|
2468
|
+
var gen = fn.apply(self2, args);
|
|
2469
|
+
function _next(value) {
|
|
2470
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
2471
|
+
}
|
|
2472
|
+
function _throw(err) {
|
|
2473
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
2474
|
+
}
|
|
2475
|
+
_next(void 0);
|
|
2476
|
+
});
|
|
2477
|
+
};
|
|
2478
|
+
}
|
|
2479
|
+
function _classCallCheck$3(instance, Constructor) {
|
|
2480
|
+
if (!(instance instanceof Constructor)) {
|
|
2481
|
+
throw new TypeError("Cannot call a class as a function");
|
|
2482
|
+
}
|
|
2483
|
+
}
|
|
2484
|
+
function _defineProperties$3(target, props) {
|
|
2485
|
+
for (var i = 0; i < props.length; i++) {
|
|
2486
|
+
var descriptor = props[i];
|
|
2487
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
2488
|
+
descriptor.configurable = true;
|
|
2489
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
2490
|
+
Object.defineProperty(target, _toPropertyKey$3(descriptor.key), descriptor);
|
|
2491
|
+
}
|
|
2492
|
+
}
|
|
2493
|
+
function _createClass$3(Constructor, protoProps, staticProps) {
|
|
2494
|
+
if (protoProps) _defineProperties$3(Constructor.prototype, protoProps);
|
|
2495
|
+
Object.defineProperty(Constructor, "prototype", { writable: false });
|
|
2496
|
+
return Constructor;
|
|
2497
|
+
}
|
|
2498
|
+
function _toPropertyKey$3(t) {
|
|
2499
|
+
var i = _toPrimitive$3(t, "string");
|
|
2500
|
+
return "symbol" == _typeof$3(i) ? i : i + "";
|
|
2501
|
+
}
|
|
2502
|
+
function _toPrimitive$3(t, r) {
|
|
2503
|
+
if ("object" != _typeof$3(t) || !t) return t;
|
|
2504
|
+
var e = t[Symbol.toPrimitive];
|
|
2505
|
+
if (void 0 !== e) {
|
|
2506
|
+
var i = e.call(t, r);
|
|
2507
|
+
if ("object" != _typeof$3(i)) return i;
|
|
2508
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
2509
|
+
}
|
|
2510
|
+
return String(t);
|
|
2511
|
+
}
|
|
2512
|
+
var FileReader$1 = /* @__PURE__ */ (function() {
|
|
2513
|
+
function FileReader2() {
|
|
2514
|
+
_classCallCheck$3(this, FileReader2);
|
|
2515
|
+
}
|
|
2516
|
+
return _createClass$3(FileReader2, [{
|
|
2517
|
+
key: "openFile",
|
|
2518
|
+
value: (function() {
|
|
2519
|
+
var _openFile = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee(input, chunkSize) {
|
|
2520
|
+
var blob;
|
|
2521
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
2522
|
+
while (1) switch (_context.prev = _context.next) {
|
|
2523
|
+
case 0:
|
|
2524
|
+
if (!(isReactNative() && input && typeof input.uri !== "undefined")) {
|
|
2525
|
+
_context.next = 11;
|
|
2526
|
+
break;
|
|
2527
|
+
}
|
|
2528
|
+
_context.prev = 1;
|
|
2529
|
+
_context.next = 4;
|
|
2530
|
+
return uriToBlob(input.uri);
|
|
2531
|
+
case 4:
|
|
2532
|
+
blob = _context.sent;
|
|
2533
|
+
return _context.abrupt("return", new FileSource(blob));
|
|
2534
|
+
case 8:
|
|
2535
|
+
_context.prev = 8;
|
|
2536
|
+
_context.t0 = _context["catch"](1);
|
|
2537
|
+
throw new Error("tus: cannot fetch `file.uri` as Blob, make sure the uri is correct and accessible. ".concat(_context.t0));
|
|
2538
|
+
case 11:
|
|
2539
|
+
if (!(typeof input.slice === "function" && typeof input.size !== "undefined")) {
|
|
2540
|
+
_context.next = 13;
|
|
2541
|
+
break;
|
|
2542
|
+
}
|
|
2543
|
+
return _context.abrupt("return", Promise.resolve(new FileSource(input)));
|
|
2544
|
+
case 13:
|
|
2545
|
+
if (!(typeof input.read === "function")) {
|
|
2546
|
+
_context.next = 18;
|
|
2547
|
+
break;
|
|
2548
|
+
}
|
|
2549
|
+
chunkSize = Number(chunkSize);
|
|
2550
|
+
if (Number.isFinite(chunkSize)) {
|
|
2551
|
+
_context.next = 17;
|
|
2552
|
+
break;
|
|
2553
|
+
}
|
|
2554
|
+
return _context.abrupt("return", Promise.reject(new Error("cannot create source for stream without a finite value for the `chunkSize` option")));
|
|
2555
|
+
case 17:
|
|
2556
|
+
return _context.abrupt("return", Promise.resolve(new StreamSource(input, chunkSize)));
|
|
2557
|
+
case 18:
|
|
2558
|
+
return _context.abrupt("return", Promise.reject(new Error("source object may only be an instance of File, Blob, or Reader in this environment")));
|
|
2559
|
+
case 19:
|
|
2560
|
+
case "end":
|
|
2561
|
+
return _context.stop();
|
|
2562
|
+
}
|
|
2563
|
+
}, _callee, null, [[1, 8]]);
|
|
2564
|
+
}));
|
|
2565
|
+
function openFile(_x, _x2) {
|
|
2566
|
+
return _openFile.apply(this, arguments);
|
|
2567
|
+
}
|
|
2568
|
+
return openFile;
|
|
2569
|
+
})()
|
|
2570
|
+
}]);
|
|
2571
|
+
})();
|
|
2572
|
+
function fingerprint(file, options) {
|
|
2573
|
+
if (isReactNative()) {
|
|
2574
|
+
return Promise.resolve(reactNativeFingerprint(file, options));
|
|
2575
|
+
}
|
|
2576
|
+
return Promise.resolve(["tus-br", file.name, file.type, file.size, file.lastModified, options.endpoint].join("-"));
|
|
2577
|
+
}
|
|
2578
|
+
function reactNativeFingerprint(file, options) {
|
|
2579
|
+
var exifHash = file.exif ? hashCode(JSON.stringify(file.exif)) : "noexif";
|
|
2580
|
+
return ["tus-rn", file.name || "noname", file.size || "nosize", exifHash, options.endpoint].join("/");
|
|
2581
|
+
}
|
|
2582
|
+
function hashCode(str) {
|
|
2583
|
+
var hash = 0;
|
|
2584
|
+
if (str.length === 0) {
|
|
2585
|
+
return hash;
|
|
2586
|
+
}
|
|
2587
|
+
for (var i = 0; i < str.length; i++) {
|
|
2588
|
+
var _char = str.charCodeAt(i);
|
|
2589
|
+
hash = (hash << 5) - hash + _char;
|
|
2590
|
+
hash &= hash;
|
|
2591
|
+
}
|
|
2592
|
+
return hash;
|
|
2593
|
+
}
|
|
2594
|
+
function _typeof$2(o) {
|
|
2595
|
+
"@babel/helpers - typeof";
|
|
2596
|
+
return _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
|
|
2597
|
+
return typeof o2;
|
|
2598
|
+
} : function(o2) {
|
|
2599
|
+
return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
|
|
2600
|
+
}, _typeof$2(o);
|
|
2601
|
+
}
|
|
2602
|
+
function _classCallCheck$2(instance, Constructor) {
|
|
2603
|
+
if (!(instance instanceof Constructor)) {
|
|
2604
|
+
throw new TypeError("Cannot call a class as a function");
|
|
2605
|
+
}
|
|
2606
|
+
}
|
|
2607
|
+
function _defineProperties$2(target, props) {
|
|
2608
|
+
for (var i = 0; i < props.length; i++) {
|
|
2609
|
+
var descriptor = props[i];
|
|
2610
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
2611
|
+
descriptor.configurable = true;
|
|
2612
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
2613
|
+
Object.defineProperty(target, _toPropertyKey$2(descriptor.key), descriptor);
|
|
2614
|
+
}
|
|
2615
|
+
}
|
|
2616
|
+
function _createClass$2(Constructor, protoProps, staticProps) {
|
|
2617
|
+
if (protoProps) _defineProperties$2(Constructor.prototype, protoProps);
|
|
2618
|
+
Object.defineProperty(Constructor, "prototype", { writable: false });
|
|
2619
|
+
return Constructor;
|
|
2620
|
+
}
|
|
2621
|
+
function _toPropertyKey$2(t) {
|
|
2622
|
+
var i = _toPrimitive$2(t, "string");
|
|
2623
|
+
return "symbol" == _typeof$2(i) ? i : i + "";
|
|
2624
|
+
}
|
|
2625
|
+
function _toPrimitive$2(t, r) {
|
|
2626
|
+
if ("object" != _typeof$2(t) || !t) return t;
|
|
2627
|
+
var e = t[Symbol.toPrimitive];
|
|
2628
|
+
if (void 0 !== e) {
|
|
2629
|
+
var i = e.call(t, r);
|
|
2630
|
+
if ("object" != _typeof$2(i)) return i;
|
|
2631
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
2632
|
+
}
|
|
2633
|
+
return String(t);
|
|
2634
|
+
}
|
|
2635
|
+
var XHRHttpStack = /* @__PURE__ */ (function() {
|
|
2636
|
+
function XHRHttpStack2() {
|
|
2637
|
+
_classCallCheck$2(this, XHRHttpStack2);
|
|
2638
|
+
}
|
|
2639
|
+
return _createClass$2(XHRHttpStack2, [{
|
|
2640
|
+
key: "createRequest",
|
|
2641
|
+
value: function createRequest(method, url) {
|
|
2642
|
+
return new Request(method, url);
|
|
2643
|
+
}
|
|
2644
|
+
}, {
|
|
2645
|
+
key: "getName",
|
|
2646
|
+
value: function getName() {
|
|
2647
|
+
return "XHRHttpStack";
|
|
2648
|
+
}
|
|
2649
|
+
}]);
|
|
2650
|
+
})();
|
|
2651
|
+
var Request = /* @__PURE__ */ (function() {
|
|
2652
|
+
function Request2(method, url) {
|
|
2653
|
+
_classCallCheck$2(this, Request2);
|
|
2654
|
+
this._xhr = new XMLHttpRequest();
|
|
2655
|
+
this._xhr.open(method, url, true);
|
|
2656
|
+
this._method = method;
|
|
2657
|
+
this._url = url;
|
|
2658
|
+
this._headers = {};
|
|
2659
|
+
}
|
|
2660
|
+
return _createClass$2(Request2, [{
|
|
2661
|
+
key: "getMethod",
|
|
2662
|
+
value: function getMethod() {
|
|
2663
|
+
return this._method;
|
|
2664
|
+
}
|
|
2665
|
+
}, {
|
|
2666
|
+
key: "getURL",
|
|
2667
|
+
value: function getURL() {
|
|
2668
|
+
return this._url;
|
|
2669
|
+
}
|
|
2670
|
+
}, {
|
|
2671
|
+
key: "setHeader",
|
|
2672
|
+
value: function setHeader(header, value) {
|
|
2673
|
+
this._xhr.setRequestHeader(header, value);
|
|
2674
|
+
this._headers[header] = value;
|
|
2675
|
+
}
|
|
2676
|
+
}, {
|
|
2677
|
+
key: "getHeader",
|
|
2678
|
+
value: function getHeader(header) {
|
|
2679
|
+
return this._headers[header];
|
|
2680
|
+
}
|
|
2681
|
+
}, {
|
|
2682
|
+
key: "setProgressHandler",
|
|
2683
|
+
value: function setProgressHandler(progressHandler) {
|
|
2684
|
+
if (!("upload" in this._xhr)) {
|
|
2685
|
+
return;
|
|
2686
|
+
}
|
|
2687
|
+
this._xhr.upload.onprogress = function(e) {
|
|
2688
|
+
if (!e.lengthComputable) {
|
|
2689
|
+
return;
|
|
2690
|
+
}
|
|
2691
|
+
progressHandler(e.loaded);
|
|
2692
|
+
};
|
|
2693
|
+
}
|
|
2694
|
+
}, {
|
|
2695
|
+
key: "send",
|
|
2696
|
+
value: function send() {
|
|
2697
|
+
var _this = this;
|
|
2698
|
+
var body = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : null;
|
|
2699
|
+
return new Promise(function(resolve, reject) {
|
|
2700
|
+
_this._xhr.onload = function() {
|
|
2701
|
+
resolve(new Response(_this._xhr));
|
|
2702
|
+
};
|
|
2703
|
+
_this._xhr.onerror = function(err) {
|
|
2704
|
+
reject(err);
|
|
2705
|
+
};
|
|
2706
|
+
_this._xhr.send(body);
|
|
2707
|
+
});
|
|
2708
|
+
}
|
|
2709
|
+
}, {
|
|
2710
|
+
key: "abort",
|
|
2711
|
+
value: function abort() {
|
|
2712
|
+
this._xhr.abort();
|
|
2713
|
+
return Promise.resolve();
|
|
2714
|
+
}
|
|
2715
|
+
}, {
|
|
2716
|
+
key: "getUnderlyingObject",
|
|
2717
|
+
value: function getUnderlyingObject() {
|
|
2718
|
+
return this._xhr;
|
|
2719
|
+
}
|
|
2720
|
+
}]);
|
|
2721
|
+
})();
|
|
2722
|
+
var Response = /* @__PURE__ */ (function() {
|
|
2723
|
+
function Response2(xhr) {
|
|
2724
|
+
_classCallCheck$2(this, Response2);
|
|
2725
|
+
this._xhr = xhr;
|
|
2726
|
+
}
|
|
2727
|
+
return _createClass$2(Response2, [{
|
|
2728
|
+
key: "getStatus",
|
|
2729
|
+
value: function getStatus() {
|
|
2730
|
+
return this._xhr.status;
|
|
2731
|
+
}
|
|
2732
|
+
}, {
|
|
2733
|
+
key: "getHeader",
|
|
2734
|
+
value: function getHeader(header) {
|
|
2735
|
+
return this._xhr.getResponseHeader(header);
|
|
2736
|
+
}
|
|
2737
|
+
}, {
|
|
2738
|
+
key: "getBody",
|
|
2739
|
+
value: function getBody() {
|
|
2740
|
+
return this._xhr.responseText;
|
|
2741
|
+
}
|
|
2742
|
+
}, {
|
|
2743
|
+
key: "getUnderlyingObject",
|
|
2744
|
+
value: function getUnderlyingObject() {
|
|
2745
|
+
return this._xhr;
|
|
2746
|
+
}
|
|
2747
|
+
}]);
|
|
2748
|
+
})();
|
|
2749
|
+
function _typeof$1(o) {
|
|
2750
|
+
"@babel/helpers - typeof";
|
|
2751
|
+
return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
|
|
2752
|
+
return typeof o2;
|
|
2753
|
+
} : function(o2) {
|
|
2754
|
+
return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
|
|
2755
|
+
}, _typeof$1(o);
|
|
2756
|
+
}
|
|
2757
|
+
function _classCallCheck$1(instance, Constructor) {
|
|
2758
|
+
if (!(instance instanceof Constructor)) {
|
|
2759
|
+
throw new TypeError("Cannot call a class as a function");
|
|
2760
|
+
}
|
|
2761
|
+
}
|
|
2762
|
+
function _defineProperties$1(target, props) {
|
|
2763
|
+
for (var i = 0; i < props.length; i++) {
|
|
2764
|
+
var descriptor = props[i];
|
|
2765
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
2766
|
+
descriptor.configurable = true;
|
|
2767
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
2768
|
+
Object.defineProperty(target, _toPropertyKey$1(descriptor.key), descriptor);
|
|
2769
|
+
}
|
|
2770
|
+
}
|
|
2771
|
+
function _createClass$1(Constructor, protoProps, staticProps) {
|
|
2772
|
+
if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
|
|
2773
|
+
Object.defineProperty(Constructor, "prototype", { writable: false });
|
|
2774
|
+
return Constructor;
|
|
2775
|
+
}
|
|
2776
|
+
function _toPropertyKey$1(t) {
|
|
2777
|
+
var i = _toPrimitive$1(t, "string");
|
|
2778
|
+
return "symbol" == _typeof$1(i) ? i : i + "";
|
|
2779
|
+
}
|
|
2780
|
+
function _toPrimitive$1(t, r) {
|
|
2781
|
+
if ("object" != _typeof$1(t) || !t) return t;
|
|
2782
|
+
var e = t[Symbol.toPrimitive];
|
|
2783
|
+
if (void 0 !== e) {
|
|
2784
|
+
var i = e.call(t, r);
|
|
2785
|
+
if ("object" != _typeof$1(i)) return i;
|
|
2786
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
2787
|
+
}
|
|
2788
|
+
return String(t);
|
|
2789
|
+
}
|
|
2790
|
+
var hasStorage = false;
|
|
2791
|
+
try {
|
|
2792
|
+
hasStorage = "localStorage" in window;
|
|
2793
|
+
var key = "tusSupport";
|
|
2794
|
+
var originalValue = localStorage.getItem(key);
|
|
2795
|
+
localStorage.setItem(key, originalValue);
|
|
2796
|
+
if (originalValue === null) localStorage.removeItem(key);
|
|
2797
|
+
} catch (e) {
|
|
2798
|
+
if (e.code === e.SECURITY_ERR || e.code === e.QUOTA_EXCEEDED_ERR) {
|
|
2799
|
+
hasStorage = false;
|
|
2800
|
+
} else {
|
|
2801
|
+
throw e;
|
|
2802
|
+
}
|
|
2803
|
+
}
|
|
2804
|
+
var canStoreURLs = hasStorage;
|
|
2805
|
+
var WebStorageUrlStorage = /* @__PURE__ */ (function() {
|
|
2806
|
+
function WebStorageUrlStorage2() {
|
|
2807
|
+
_classCallCheck$1(this, WebStorageUrlStorage2);
|
|
2808
|
+
}
|
|
2809
|
+
return _createClass$1(WebStorageUrlStorage2, [{
|
|
2810
|
+
key: "findAllUploads",
|
|
2811
|
+
value: function findAllUploads() {
|
|
2812
|
+
var results = this._findEntries("tus::");
|
|
2813
|
+
return Promise.resolve(results);
|
|
2814
|
+
}
|
|
2815
|
+
}, {
|
|
2816
|
+
key: "findUploadsByFingerprint",
|
|
2817
|
+
value: function findUploadsByFingerprint(fingerprint2) {
|
|
2818
|
+
var results = this._findEntries("tus::".concat(fingerprint2, "::"));
|
|
2819
|
+
return Promise.resolve(results);
|
|
2820
|
+
}
|
|
2821
|
+
}, {
|
|
2822
|
+
key: "removeUpload",
|
|
2823
|
+
value: function removeUpload(urlStorageKey) {
|
|
2824
|
+
localStorage.removeItem(urlStorageKey);
|
|
2825
|
+
return Promise.resolve();
|
|
2826
|
+
}
|
|
2827
|
+
}, {
|
|
2828
|
+
key: "addUpload",
|
|
2829
|
+
value: function addUpload(fingerprint2, upload) {
|
|
2830
|
+
var id = Math.round(Math.random() * 1e12);
|
|
2831
|
+
var key = "tus::".concat(fingerprint2, "::").concat(id);
|
|
2832
|
+
localStorage.setItem(key, JSON.stringify(upload));
|
|
2833
|
+
return Promise.resolve(key);
|
|
2834
|
+
}
|
|
2835
|
+
}, {
|
|
2836
|
+
key: "_findEntries",
|
|
2837
|
+
value: function _findEntries(prefix) {
|
|
2838
|
+
var results = [];
|
|
2839
|
+
for (var i = 0; i < localStorage.length; i++) {
|
|
2840
|
+
var _key = localStorage.key(i);
|
|
2841
|
+
if (_key.indexOf(prefix) !== 0) continue;
|
|
2842
|
+
try {
|
|
2843
|
+
var upload = JSON.parse(localStorage.getItem(_key));
|
|
2844
|
+
upload.urlStorageKey = _key;
|
|
2845
|
+
results.push(upload);
|
|
2846
|
+
} catch (_e) {
|
|
2847
|
+
}
|
|
2848
|
+
}
|
|
2849
|
+
return results;
|
|
2850
|
+
}
|
|
2851
|
+
}]);
|
|
2852
|
+
})();
|
|
2853
|
+
function _typeof(o) {
|
|
2854
|
+
"@babel/helpers - typeof";
|
|
2855
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
|
|
2856
|
+
return typeof o2;
|
|
2857
|
+
} : function(o2) {
|
|
2858
|
+
return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
|
|
2859
|
+
}, _typeof(o);
|
|
2860
|
+
}
|
|
2861
|
+
function _classCallCheck(instance, Constructor) {
|
|
2862
|
+
if (!(instance instanceof Constructor)) {
|
|
2863
|
+
throw new TypeError("Cannot call a class as a function");
|
|
2864
|
+
}
|
|
2865
|
+
}
|
|
2866
|
+
function _defineProperties(target, props) {
|
|
2867
|
+
for (var i = 0; i < props.length; i++) {
|
|
2868
|
+
var descriptor = props[i];
|
|
2869
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
2870
|
+
descriptor.configurable = true;
|
|
2871
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
2872
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
2873
|
+
}
|
|
2874
|
+
}
|
|
2875
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
2876
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
2877
|
+
Object.defineProperty(Constructor, "prototype", { writable: false });
|
|
2878
|
+
return Constructor;
|
|
2879
|
+
}
|
|
2880
|
+
function _callSuper(t, o, e) {
|
|
2881
|
+
return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
|
|
2882
|
+
}
|
|
2883
|
+
function _possibleConstructorReturn(self2, call) {
|
|
2884
|
+
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
2885
|
+
return call;
|
|
2886
|
+
} else if (call !== void 0) {
|
|
2887
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
2888
|
+
}
|
|
2889
|
+
return _assertThisInitialized(self2);
|
|
2890
|
+
}
|
|
2891
|
+
function _assertThisInitialized(self2) {
|
|
2892
|
+
if (self2 === void 0) {
|
|
2893
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
2894
|
+
}
|
|
2895
|
+
return self2;
|
|
2896
|
+
}
|
|
2897
|
+
function _isNativeReflectConstruct() {
|
|
2898
|
+
try {
|
|
2899
|
+
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
|
|
2900
|
+
}));
|
|
2901
|
+
} catch (t2) {
|
|
2902
|
+
}
|
|
2903
|
+
return (_isNativeReflectConstruct = function _isNativeReflectConstruct2() {
|
|
2904
|
+
return !!t;
|
|
2905
|
+
})();
|
|
2906
|
+
}
|
|
2907
|
+
function _getPrototypeOf(o) {
|
|
2908
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf2(o2) {
|
|
2909
|
+
return o2.__proto__ || Object.getPrototypeOf(o2);
|
|
2910
|
+
};
|
|
2911
|
+
return _getPrototypeOf(o);
|
|
2912
|
+
}
|
|
2913
|
+
function _inherits(subClass, superClass) {
|
|
2914
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
2915
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
2916
|
+
}
|
|
2917
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } });
|
|
2918
|
+
Object.defineProperty(subClass, "prototype", { writable: false });
|
|
2919
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
2920
|
+
}
|
|
2921
|
+
function _setPrototypeOf(o, p) {
|
|
2922
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf2(o2, p2) {
|
|
2923
|
+
o2.__proto__ = p2;
|
|
2924
|
+
return o2;
|
|
2925
|
+
};
|
|
2926
|
+
return _setPrototypeOf(o, p);
|
|
2927
|
+
}
|
|
2928
|
+
function ownKeys(e, r) {
|
|
2929
|
+
var t = Object.keys(e);
|
|
2930
|
+
if (Object.getOwnPropertySymbols) {
|
|
2931
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
2932
|
+
r && (o = o.filter(function(r2) {
|
|
2933
|
+
return Object.getOwnPropertyDescriptor(e, r2).enumerable;
|
|
2934
|
+
})), t.push.apply(t, o);
|
|
2935
|
+
}
|
|
2936
|
+
return t;
|
|
2937
|
+
}
|
|
2938
|
+
function _objectSpread(e) {
|
|
2939
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
2940
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
2941
|
+
r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
|
|
2942
|
+
_defineProperty(e, r2, t[r2]);
|
|
2943
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
|
|
2944
|
+
Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
|
|
2945
|
+
});
|
|
2946
|
+
}
|
|
2947
|
+
return e;
|
|
2948
|
+
}
|
|
2949
|
+
function _defineProperty(obj, key, value) {
|
|
2950
|
+
key = _toPropertyKey(key);
|
|
2951
|
+
if (key in obj) {
|
|
2952
|
+
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
|
2953
|
+
} else {
|
|
2954
|
+
obj[key] = value;
|
|
2955
|
+
}
|
|
2956
|
+
return obj;
|
|
2957
|
+
}
|
|
2958
|
+
function _toPropertyKey(t) {
|
|
2959
|
+
var i = _toPrimitive(t, "string");
|
|
2960
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
2961
|
+
}
|
|
2962
|
+
function _toPrimitive(t, r) {
|
|
2963
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
2964
|
+
var e = t[Symbol.toPrimitive];
|
|
2965
|
+
if (void 0 !== e) {
|
|
2966
|
+
var i = e.call(t, r);
|
|
2967
|
+
if ("object" != _typeof(i)) return i;
|
|
2968
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
2969
|
+
}
|
|
2970
|
+
return ("string" === r ? String : Number)(t);
|
|
2971
|
+
}
|
|
2972
|
+
var defaultOptions = _objectSpread(_objectSpread({}, BaseUpload.defaultOptions), {}, {
|
|
2973
|
+
httpStack: new XHRHttpStack(),
|
|
2974
|
+
fileReader: new FileReader$1(),
|
|
2975
|
+
urlStorage: canStoreURLs ? new WebStorageUrlStorage() : new NoopUrlStorage(),
|
|
2976
|
+
fingerprint
|
|
2977
|
+
});
|
|
2978
|
+
var Upload = /* @__PURE__ */ (function(_BaseUpload) {
|
|
2979
|
+
function Upload2() {
|
|
2980
|
+
var file = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : null;
|
|
2981
|
+
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
2982
|
+
_classCallCheck(this, Upload2);
|
|
2983
|
+
options = _objectSpread(_objectSpread({}, defaultOptions), options);
|
|
2984
|
+
return _callSuper(this, Upload2, [file, options]);
|
|
2985
|
+
}
|
|
2986
|
+
_inherits(Upload2, _BaseUpload);
|
|
2987
|
+
return _createClass(Upload2, null, [{
|
|
2988
|
+
key: "terminate",
|
|
2989
|
+
value: function terminate(url) {
|
|
2990
|
+
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
2991
|
+
options = _objectSpread(_objectSpread({}, defaultOptions), options);
|
|
2992
|
+
return BaseUpload.terminate(url, options);
|
|
2993
|
+
}
|
|
2994
|
+
}]);
|
|
2995
|
+
})(BaseUpload);
|
|
2996
|
+
const QUERY_KEY = "file";
|
|
2997
|
+
const HOUR = 1e3 * 60 * 60;
|
|
2998
|
+
const APP_NAME = toKebabCase(clientEnv.VITE_APP_TITLE);
|
|
2999
|
+
z__default.object({
|
|
3000
|
+
appName: z__default.string().min(1).max(255).default(APP_NAME).optional(),
|
|
3001
|
+
subId: z__default.uuid()
|
|
3002
|
+
});
|
|
3003
|
+
const useGetFileMetas = (params, options) => {
|
|
3004
|
+
const $ = c(12);
|
|
3005
|
+
let queryParams;
|
|
3006
|
+
if ($[0] !== params.appName || $[1] !== params.subId) {
|
|
3007
|
+
queryParams = new URLSearchParams();
|
|
3008
|
+
queryParams.append("appName", params.appName ?? APP_NAME);
|
|
3009
|
+
queryParams.append("subId", params.subId);
|
|
3010
|
+
$[0] = params.appName;
|
|
3011
|
+
$[1] = params.subId;
|
|
3012
|
+
$[2] = queryParams;
|
|
3013
|
+
} else {
|
|
3014
|
+
queryParams = $[2];
|
|
3015
|
+
}
|
|
3016
|
+
const t0 = params.appName ?? APP_NAME;
|
|
3017
|
+
let t1;
|
|
3018
|
+
if ($[3] !== params.subId || $[4] !== t0) {
|
|
3019
|
+
t1 = [QUERY_KEY, "meta", t0, params.subId];
|
|
3020
|
+
$[3] = params.subId;
|
|
3021
|
+
$[4] = t0;
|
|
3022
|
+
$[5] = t1;
|
|
3023
|
+
} else {
|
|
3024
|
+
t1 = $[5];
|
|
3025
|
+
}
|
|
3026
|
+
let t2;
|
|
3027
|
+
if ($[6] !== queryParams) {
|
|
3028
|
+
t2 = (t32) => {
|
|
3029
|
+
const {
|
|
3030
|
+
signal
|
|
3031
|
+
} = t32;
|
|
3032
|
+
return httpClient.request({
|
|
3033
|
+
url: `/${QUERY_KEY}/v1/meta?${queryParams.toString()}`,
|
|
3034
|
+
method: "GET",
|
|
3035
|
+
signal
|
|
3036
|
+
}).then(_temp);
|
|
3037
|
+
};
|
|
3038
|
+
$[6] = queryParams;
|
|
3039
|
+
$[7] = t2;
|
|
3040
|
+
} else {
|
|
3041
|
+
t2 = $[7];
|
|
3042
|
+
}
|
|
3043
|
+
let t3;
|
|
3044
|
+
if ($[8] !== options || $[9] !== t1 || $[10] !== t2) {
|
|
3045
|
+
t3 = {
|
|
3046
|
+
...options,
|
|
3047
|
+
queryKey: t1,
|
|
3048
|
+
queryFn: t2,
|
|
3049
|
+
staleTime: HOUR,
|
|
3050
|
+
gcTime: HOUR,
|
|
3051
|
+
refetchOnWindowFocus: false
|
|
3052
|
+
};
|
|
3053
|
+
$[8] = options;
|
|
3054
|
+
$[9] = t1;
|
|
3055
|
+
$[10] = t2;
|
|
3056
|
+
$[11] = t3;
|
|
3057
|
+
} else {
|
|
3058
|
+
t3 = $[11];
|
|
3059
|
+
}
|
|
3060
|
+
return useQuery(t3);
|
|
3061
|
+
};
|
|
3062
|
+
z__default.object({
|
|
3063
|
+
appName: z__default.string().min(1).max(255).default(APP_NAME).optional(),
|
|
3064
|
+
meta: FileMetaSchema.nullish()
|
|
3065
|
+
});
|
|
3066
|
+
const useGetFileThumbnail = (params, options) => {
|
|
3067
|
+
const $ = c(13);
|
|
3068
|
+
let queryParams;
|
|
3069
|
+
if ($[0] !== params.appName || $[1] !== params.meta?.id) {
|
|
3070
|
+
queryParams = new URLSearchParams();
|
|
3071
|
+
queryParams.append("appName", params.appName ?? APP_NAME);
|
|
3072
|
+
queryParams.append("id", params.meta?.id ?? "");
|
|
3073
|
+
$[0] = params.appName;
|
|
3074
|
+
$[1] = params.meta?.id;
|
|
3075
|
+
$[2] = queryParams;
|
|
3076
|
+
} else {
|
|
3077
|
+
queryParams = $[2];
|
|
3078
|
+
}
|
|
3079
|
+
const t0 = params.appName ?? APP_NAME;
|
|
3080
|
+
const t1 = params.meta?.id;
|
|
3081
|
+
let t2;
|
|
3082
|
+
if ($[3] !== t0 || $[4] !== t1) {
|
|
3083
|
+
t2 = [QUERY_KEY, "thumbnail", t0, t1];
|
|
3084
|
+
$[3] = t0;
|
|
3085
|
+
$[4] = t1;
|
|
3086
|
+
$[5] = t2;
|
|
3087
|
+
} else {
|
|
3088
|
+
t2 = $[5];
|
|
3089
|
+
}
|
|
3090
|
+
let t3;
|
|
3091
|
+
if ($[6] !== queryParams) {
|
|
3092
|
+
t3 = (t42) => {
|
|
3093
|
+
const {
|
|
3094
|
+
signal
|
|
3095
|
+
} = t42;
|
|
3096
|
+
return httpClient.request({
|
|
3097
|
+
url: `/${QUERY_KEY}/v1/thumbnail?${queryParams.toString()}`,
|
|
3098
|
+
method: "GET",
|
|
3099
|
+
signal,
|
|
3100
|
+
responseType: "blob"
|
|
3101
|
+
}).then(_temp2);
|
|
3102
|
+
};
|
|
3103
|
+
$[6] = queryParams;
|
|
3104
|
+
$[7] = t3;
|
|
3105
|
+
} else {
|
|
3106
|
+
t3 = $[7];
|
|
3107
|
+
}
|
|
3108
|
+
const t4 = !!params.meta && options?.enabled !== false;
|
|
3109
|
+
let t5;
|
|
3110
|
+
if ($[8] !== options || $[9] !== t2 || $[10] !== t3 || $[11] !== t4) {
|
|
3111
|
+
t5 = {
|
|
3112
|
+
...options,
|
|
3113
|
+
queryKey: t2,
|
|
3114
|
+
queryFn: t3,
|
|
3115
|
+
select: _temp3,
|
|
3116
|
+
staleTime: HOUR,
|
|
3117
|
+
gcTime: HOUR,
|
|
3118
|
+
refetchOnWindowFocus: false,
|
|
3119
|
+
enabled: t4
|
|
3120
|
+
};
|
|
3121
|
+
$[8] = options;
|
|
3122
|
+
$[9] = t2;
|
|
3123
|
+
$[10] = t3;
|
|
3124
|
+
$[11] = t4;
|
|
3125
|
+
$[12] = t5;
|
|
3126
|
+
} else {
|
|
3127
|
+
t5 = $[12];
|
|
3128
|
+
}
|
|
3129
|
+
return useQuery(t5);
|
|
3130
|
+
};
|
|
3131
|
+
z__default.object({
|
|
3132
|
+
appName: z__default.string().min(1).max(255).default(APP_NAME).optional(),
|
|
3133
|
+
meta: FileMetaSchema.nullish()
|
|
3134
|
+
});
|
|
3135
|
+
const useGetFile = (params, options) => {
|
|
3136
|
+
const $ = c(13);
|
|
3137
|
+
let queryParams;
|
|
3138
|
+
if ($[0] !== params.appName || $[1] !== params.meta?.id) {
|
|
3139
|
+
queryParams = new URLSearchParams();
|
|
3140
|
+
queryParams.append("appName", params.appName ?? APP_NAME);
|
|
3141
|
+
queryParams.append("id", params.meta?.id ?? "");
|
|
3142
|
+
$[0] = params.appName;
|
|
3143
|
+
$[1] = params.meta?.id;
|
|
3144
|
+
$[2] = queryParams;
|
|
3145
|
+
} else {
|
|
3146
|
+
queryParams = $[2];
|
|
3147
|
+
}
|
|
3148
|
+
const t0 = params.appName ?? APP_NAME;
|
|
3149
|
+
const t1 = params.meta?.id;
|
|
3150
|
+
let t2;
|
|
3151
|
+
if ($[3] !== t0 || $[4] !== t1) {
|
|
3152
|
+
t2 = [QUERY_KEY, t0, t1];
|
|
3153
|
+
$[3] = t0;
|
|
3154
|
+
$[4] = t1;
|
|
3155
|
+
$[5] = t2;
|
|
3156
|
+
} else {
|
|
3157
|
+
t2 = $[5];
|
|
3158
|
+
}
|
|
3159
|
+
let t3;
|
|
3160
|
+
if ($[6] !== queryParams) {
|
|
3161
|
+
t3 = (t42) => {
|
|
3162
|
+
const {
|
|
3163
|
+
signal
|
|
3164
|
+
} = t42;
|
|
3165
|
+
return httpClient.request({
|
|
3166
|
+
url: `/${QUERY_KEY}/v1?${queryParams.toString()}`,
|
|
3167
|
+
method: "GET",
|
|
3168
|
+
signal,
|
|
3169
|
+
responseType: "blob"
|
|
3170
|
+
}).then(_temp4);
|
|
3171
|
+
};
|
|
3172
|
+
$[6] = queryParams;
|
|
3173
|
+
$[7] = t3;
|
|
3174
|
+
} else {
|
|
3175
|
+
t3 = $[7];
|
|
3176
|
+
}
|
|
3177
|
+
const t4 = !!params.meta && options?.enabled !== false;
|
|
3178
|
+
let t5;
|
|
3179
|
+
if ($[8] !== options || $[9] !== t2 || $[10] !== t3 || $[11] !== t4) {
|
|
3180
|
+
t5 = {
|
|
3181
|
+
...options,
|
|
3182
|
+
queryKey: t2,
|
|
3183
|
+
queryFn: t3,
|
|
3184
|
+
select: _temp5,
|
|
3185
|
+
staleTime: HOUR,
|
|
3186
|
+
gcTime: HOUR,
|
|
3187
|
+
refetchOnWindowFocus: false,
|
|
3188
|
+
enabled: t4
|
|
3189
|
+
};
|
|
3190
|
+
$[8] = options;
|
|
3191
|
+
$[9] = t2;
|
|
3192
|
+
$[10] = t3;
|
|
3193
|
+
$[11] = t4;
|
|
3194
|
+
$[12] = t5;
|
|
3195
|
+
} else {
|
|
3196
|
+
t5 = $[12];
|
|
3197
|
+
}
|
|
3198
|
+
return useQuery(t5);
|
|
3199
|
+
};
|
|
3200
|
+
const useDownloadFile = (options) => {
|
|
3201
|
+
const $ = c(2);
|
|
3202
|
+
let t0;
|
|
3203
|
+
if ($[0] !== options) {
|
|
3204
|
+
t0 = {
|
|
3205
|
+
...options,
|
|
3206
|
+
mutationFn: _temp7,
|
|
3207
|
+
onSuccess: _temp8
|
|
3208
|
+
};
|
|
3209
|
+
$[0] = options;
|
|
3210
|
+
$[1] = t0;
|
|
3211
|
+
} else {
|
|
3212
|
+
t0 = $[1];
|
|
3213
|
+
}
|
|
3214
|
+
return useMutation(t0);
|
|
3215
|
+
};
|
|
3216
|
+
const useOpenFile = (options) => {
|
|
3217
|
+
const $ = c(2);
|
|
3218
|
+
let t0;
|
|
3219
|
+
if ($[0] !== options) {
|
|
3220
|
+
t0 = {
|
|
3221
|
+
...options,
|
|
3222
|
+
mutationFn: _temp0,
|
|
3223
|
+
onSuccess: _temp1
|
|
3224
|
+
};
|
|
3225
|
+
$[0] = options;
|
|
3226
|
+
$[1] = t0;
|
|
3227
|
+
} else {
|
|
3228
|
+
t0 = $[1];
|
|
3229
|
+
}
|
|
3230
|
+
return useMutation(t0);
|
|
3231
|
+
};
|
|
3232
|
+
const useUpdateFileMeta = (options) => {
|
|
3233
|
+
const $ = c(5);
|
|
3234
|
+
const queryClient = useQueryClient();
|
|
3235
|
+
let t0;
|
|
3236
|
+
if ($[0] !== queryClient) {
|
|
3237
|
+
t0 = () => queryClient.invalidateQueries({
|
|
3238
|
+
queryKey: [QUERY_KEY, "meta"],
|
|
3239
|
+
exact: false
|
|
3240
|
+
});
|
|
3241
|
+
$[0] = queryClient;
|
|
3242
|
+
$[1] = t0;
|
|
3243
|
+
} else {
|
|
3244
|
+
t0 = $[1];
|
|
3245
|
+
}
|
|
3246
|
+
let t1;
|
|
3247
|
+
if ($[2] !== options || $[3] !== t0) {
|
|
3248
|
+
t1 = {
|
|
3249
|
+
...options,
|
|
3250
|
+
mutationFn: _temp11,
|
|
3251
|
+
onSettled: t0
|
|
3252
|
+
};
|
|
3253
|
+
$[2] = options;
|
|
3254
|
+
$[3] = t0;
|
|
3255
|
+
$[4] = t1;
|
|
3256
|
+
} else {
|
|
3257
|
+
t1 = $[4];
|
|
3258
|
+
}
|
|
3259
|
+
return useMutation(t1);
|
|
3260
|
+
};
|
|
3261
|
+
const useDeleteFile = (options) => {
|
|
3262
|
+
const $ = c(5);
|
|
3263
|
+
const queryClient = useQueryClient();
|
|
3264
|
+
let t0;
|
|
3265
|
+
if ($[0] !== queryClient) {
|
|
3266
|
+
t0 = () => queryClient.invalidateQueries({
|
|
3267
|
+
queryKey: [QUERY_KEY, "meta"],
|
|
3268
|
+
exact: false
|
|
3269
|
+
});
|
|
3270
|
+
$[0] = queryClient;
|
|
3271
|
+
$[1] = t0;
|
|
3272
|
+
} else {
|
|
3273
|
+
t0 = $[1];
|
|
3274
|
+
}
|
|
3275
|
+
let t1;
|
|
3276
|
+
if ($[2] !== options || $[3] !== t0) {
|
|
3277
|
+
t1 = {
|
|
3278
|
+
...options,
|
|
3279
|
+
mutationFn: _temp13,
|
|
3280
|
+
onSettled: t0
|
|
3281
|
+
};
|
|
3282
|
+
$[2] = options;
|
|
3283
|
+
$[3] = t0;
|
|
3284
|
+
$[4] = t1;
|
|
3285
|
+
} else {
|
|
3286
|
+
t1 = $[4];
|
|
3287
|
+
}
|
|
3288
|
+
return useMutation(t1);
|
|
3289
|
+
};
|
|
3290
|
+
const useDeleteFiles = (options) => {
|
|
3291
|
+
const $ = c(5);
|
|
3292
|
+
const queryClient = useQueryClient();
|
|
3293
|
+
let t0;
|
|
3294
|
+
if ($[0] !== queryClient) {
|
|
3295
|
+
t0 = () => queryClient.invalidateQueries({
|
|
3296
|
+
queryKey: [QUERY_KEY, "meta"],
|
|
3297
|
+
exact: false
|
|
3298
|
+
});
|
|
3299
|
+
$[0] = queryClient;
|
|
3300
|
+
$[1] = t0;
|
|
3301
|
+
} else {
|
|
3302
|
+
t0 = $[1];
|
|
3303
|
+
}
|
|
3304
|
+
let t1;
|
|
3305
|
+
if ($[2] !== options || $[3] !== t0) {
|
|
3306
|
+
t1 = {
|
|
3307
|
+
...options,
|
|
3308
|
+
mutationFn: _temp15,
|
|
3309
|
+
onSettled: t0
|
|
3310
|
+
};
|
|
3311
|
+
$[2] = options;
|
|
3312
|
+
$[3] = t0;
|
|
3313
|
+
$[4] = t1;
|
|
3314
|
+
} else {
|
|
3315
|
+
t1 = $[4];
|
|
3316
|
+
}
|
|
3317
|
+
return useMutation(t1);
|
|
3318
|
+
};
|
|
3319
|
+
const useUploadFile = (t0) => {
|
|
3320
|
+
const $ = c(8);
|
|
3321
|
+
const {
|
|
3322
|
+
subId,
|
|
3323
|
+
onSuccess,
|
|
3324
|
+
onError
|
|
3325
|
+
} = t0;
|
|
3326
|
+
const [progress, setProgress] = useState(0);
|
|
3327
|
+
const queryClient = useQueryClient();
|
|
3328
|
+
let t1;
|
|
3329
|
+
if ($[0] !== onError || $[1] !== onSuccess || $[2] !== queryClient || $[3] !== subId) {
|
|
3330
|
+
t1 = async (file) => {
|
|
3331
|
+
if (!subId) {
|
|
3332
|
+
throw new Error("subId is required for file upload");
|
|
3333
|
+
}
|
|
3334
|
+
const metadata = {
|
|
3335
|
+
id: uuidv7(),
|
|
3336
|
+
appName: APP_NAME,
|
|
3337
|
+
subId,
|
|
3338
|
+
fileName: file.name
|
|
3339
|
+
};
|
|
3340
|
+
const upload = new Upload(file, {
|
|
3341
|
+
endpoint: `${clientEnv.VITE_API_URL}/${QUERY_KEY}/v1/upload`,
|
|
3342
|
+
chunkSize: 1048576,
|
|
3343
|
+
metadata: {
|
|
3344
|
+
id: metadata.id,
|
|
3345
|
+
appName: metadata.appName,
|
|
3346
|
+
subId: metadata.subId,
|
|
3347
|
+
fileName: metadata.fileName,
|
|
3348
|
+
fileExtension: file.type
|
|
3349
|
+
},
|
|
3350
|
+
headers: {
|
|
3351
|
+
"Authorization": "Bearer YOUR_ACCESS_TOKEN_HERE"
|
|
3352
|
+
},
|
|
3353
|
+
onError: (error) => {
|
|
3354
|
+
setProgress(0);
|
|
3355
|
+
onError?.(error);
|
|
3356
|
+
},
|
|
3357
|
+
onProgress: (bytesUploaded, bytesTotal) => {
|
|
3358
|
+
setProgress(bytesUploaded / bytesTotal * 100);
|
|
3359
|
+
},
|
|
3360
|
+
onSuccess: () => {
|
|
3361
|
+
setProgress(0);
|
|
3362
|
+
queryClient.invalidateQueries({
|
|
3363
|
+
queryKey: [QUERY_KEY, "meta", subId],
|
|
3364
|
+
exact: false
|
|
3365
|
+
});
|
|
3366
|
+
onSuccess?.(metadata);
|
|
3367
|
+
}
|
|
3368
|
+
});
|
|
3369
|
+
const previousUploads = await upload.findPreviousUploads();
|
|
3370
|
+
if (previousUploads.length > 0) {
|
|
3371
|
+
upload.resumeFromPreviousUpload(previousUploads[0]);
|
|
3372
|
+
}
|
|
3373
|
+
upload.start();
|
|
3374
|
+
};
|
|
3375
|
+
$[0] = onError;
|
|
3376
|
+
$[1] = onSuccess;
|
|
3377
|
+
$[2] = queryClient;
|
|
3378
|
+
$[3] = subId;
|
|
3379
|
+
$[4] = t1;
|
|
3380
|
+
} else {
|
|
3381
|
+
t1 = $[4];
|
|
3382
|
+
}
|
|
3383
|
+
const mutate = t1;
|
|
3384
|
+
let t2;
|
|
3385
|
+
if ($[5] !== mutate || $[6] !== progress) {
|
|
3386
|
+
t2 = {
|
|
3387
|
+
mutate,
|
|
3388
|
+
progress
|
|
3389
|
+
};
|
|
3390
|
+
$[5] = mutate;
|
|
3391
|
+
$[6] = progress;
|
|
3392
|
+
$[7] = t2;
|
|
3393
|
+
} else {
|
|
3394
|
+
t2 = $[7];
|
|
3395
|
+
}
|
|
3396
|
+
return t2;
|
|
3397
|
+
};
|
|
3398
|
+
function _temp(request) {
|
|
3399
|
+
return request.data;
|
|
3400
|
+
}
|
|
3401
|
+
function _temp2(request) {
|
|
3402
|
+
return request.data;
|
|
3403
|
+
}
|
|
3404
|
+
function _temp3(data) {
|
|
3405
|
+
return URL.createObjectURL(data);
|
|
3406
|
+
}
|
|
3407
|
+
function _temp4(request) {
|
|
3408
|
+
return request.data;
|
|
3409
|
+
}
|
|
3410
|
+
function _temp5(data) {
|
|
3411
|
+
return URL.createObjectURL(data);
|
|
3412
|
+
}
|
|
3413
|
+
function _temp6(request) {
|
|
3414
|
+
return request.data;
|
|
3415
|
+
}
|
|
3416
|
+
function _temp7(meta) {
|
|
3417
|
+
return httpClient.request({
|
|
3418
|
+
url: `/${QUERY_KEY}/v1/download?appName=${APP_NAME}&id=${meta.id}`,
|
|
3419
|
+
method: "GET",
|
|
3420
|
+
responseType: "blob"
|
|
3421
|
+
}).then(_temp6);
|
|
3422
|
+
}
|
|
3423
|
+
function _temp8(data, variables) {
|
|
3424
|
+
return saveAs(data, `${variables.fileName}.${variables.fileExtension}`);
|
|
3425
|
+
}
|
|
3426
|
+
function _temp9(request) {
|
|
3427
|
+
return request.data;
|
|
3428
|
+
}
|
|
3429
|
+
function _temp0(meta) {
|
|
3430
|
+
return httpClient.request({
|
|
3431
|
+
url: `/${QUERY_KEY}/v1?appName=${APP_NAME}&id=${meta.id}`,
|
|
3432
|
+
method: "GET",
|
|
3433
|
+
responseType: "blob"
|
|
3434
|
+
}).then(_temp9);
|
|
3435
|
+
}
|
|
3436
|
+
function _temp1(data) {
|
|
3437
|
+
window.open(URL.createObjectURL(data));
|
|
3438
|
+
}
|
|
3439
|
+
function _temp10(request) {
|
|
3440
|
+
return request.data;
|
|
3441
|
+
}
|
|
3442
|
+
function _temp11(meta) {
|
|
3443
|
+
return httpClient.request({
|
|
3444
|
+
url: `/${QUERY_KEY}/v1/meta?appName=${APP_NAME}&id=${meta.id}`,
|
|
3445
|
+
method: "PUT",
|
|
3446
|
+
data: meta
|
|
3447
|
+
}).then(_temp10);
|
|
3448
|
+
}
|
|
3449
|
+
function _temp12(request) {
|
|
3450
|
+
return request.data;
|
|
3451
|
+
}
|
|
3452
|
+
function _temp13(meta) {
|
|
3453
|
+
return httpClient.request({
|
|
3454
|
+
url: `/${QUERY_KEY}/v1?appName=${APP_NAME}&id=${meta.id}`,
|
|
3455
|
+
method: "DELETE"
|
|
3456
|
+
}).then(_temp12);
|
|
3457
|
+
}
|
|
3458
|
+
function _temp14(request) {
|
|
3459
|
+
return request.data;
|
|
3460
|
+
}
|
|
3461
|
+
function _temp15(subId) {
|
|
3462
|
+
return httpClient.request({
|
|
3463
|
+
url: `/${QUERY_KEY}/v1?appName=${APP_NAME}&subId=${subId}`,
|
|
3464
|
+
method: "DELETE"
|
|
3465
|
+
}).then(_temp14);
|
|
3466
|
+
}
|
|
3467
|
+
export {
|
|
3468
|
+
useGetFileThumbnail as a,
|
|
3469
|
+
useGetFile as b,
|
|
3470
|
+
useDownloadFile as c,
|
|
3471
|
+
useOpenFile as d,
|
|
3472
|
+
useUpdateFileMeta as e,
|
|
3473
|
+
useDeleteFile as f,
|
|
3474
|
+
useDeleteFiles as g,
|
|
3475
|
+
useUploadFile as h,
|
|
3476
|
+
useGetFileMetas as u
|
|
3477
|
+
};
|
|
3478
|
+
//# sourceMappingURL=FileHooks-DdKh9cZa.js.map
|