mobx-downloader 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ReadMe.md +185 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +861 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/package.json +76 -0
- package/source/HTTP.ts +58 -0
- package/source/Task.ts +127 -0
- package/source/index.ts +73 -0
- package/tsconfig.json +22 -0
|
@@ -0,0 +1,861 @@
|
|
|
1
|
+
import {observable as $42h8L$observable, computed as $42h8L$computed} from "mobx";
|
|
2
|
+
import {restore as $42h8L$restore, persist as $42h8L$persist, destroy as $42h8L$destroy} from "mobx-restful";
|
|
3
|
+
import {HTTPClient as $42h8L$HTTPClient} from "koajax";
|
|
4
|
+
import * as $42h8L$nativefilesystemadapter from "native-file-system-adapter";
|
|
5
|
+
import {ByteSize as $42h8L$ByteSize} from "web-utility";
|
|
6
|
+
import * as $42h8L$webstreamspolyfill from "web-streams-polyfill";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
function $parcel$export(e, n, v, s) {
|
|
10
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
var $eaae1d79f358eeb1$exports = {};
|
|
15
|
+
|
|
16
|
+
$parcel$export($eaae1d79f358eeb1$exports, "HTTPDownloadTask", function () { return $eaae1d79f358eeb1$export$54a5aef4e85ae85; });
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
var $2305cbd960c24ac6$exports = {};
|
|
20
|
+
|
|
21
|
+
$parcel$export($2305cbd960c24ac6$exports, "DownloadTask", function () { return $2305cbd960c24ac6$export$e9ba70c733fe1cb8; });
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
var $2305cbd960c24ac6$var$__runInitializers = undefined && undefined.__runInitializers || function(thisArg, initializers, value) {
|
|
26
|
+
var useValue = arguments.length > 2;
|
|
27
|
+
for(var i = 0; i < initializers.length; i++)value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
28
|
+
return useValue ? value : void 0;
|
|
29
|
+
};
|
|
30
|
+
var $2305cbd960c24ac6$var$__esDecorate = undefined && undefined.__esDecorate || function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
31
|
+
function accept(f) {
|
|
32
|
+
if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected");
|
|
33
|
+
return f;
|
|
34
|
+
}
|
|
35
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
36
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
37
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
38
|
+
var _, done = false;
|
|
39
|
+
for(var i = decorators.length - 1; i >= 0; i--){
|
|
40
|
+
var context = {};
|
|
41
|
+
for(var p in contextIn)context[p] = p === "access" ? {} : contextIn[p];
|
|
42
|
+
for(var p in contextIn.access)context.access[p] = contextIn.access[p];
|
|
43
|
+
context.addInitializer = function(f) {
|
|
44
|
+
if (done) throw new TypeError("Cannot add initializers after decoration has completed");
|
|
45
|
+
extraInitializers.push(accept(f || null));
|
|
46
|
+
};
|
|
47
|
+
var result = (0, decorators[i])(kind === "accessor" ? {
|
|
48
|
+
get: descriptor.get,
|
|
49
|
+
set: descriptor.set
|
|
50
|
+
} : descriptor[key], context);
|
|
51
|
+
if (kind === "accessor") {
|
|
52
|
+
if (result === void 0) continue;
|
|
53
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
54
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
55
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
56
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
57
|
+
} else if (_ = accept(result)) {
|
|
58
|
+
if (kind === "field") initializers.unshift(_);
|
|
59
|
+
else descriptor[key] = _;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
63
|
+
done = true;
|
|
64
|
+
};
|
|
65
|
+
var $2305cbd960c24ac6$var$__awaiter = undefined && undefined.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
66
|
+
function adopt(value) {
|
|
67
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
68
|
+
resolve(value);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
72
|
+
function fulfilled(value) {
|
|
73
|
+
try {
|
|
74
|
+
step(generator.next(value));
|
|
75
|
+
} catch (e) {
|
|
76
|
+
reject(e);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function rejected(value) {
|
|
80
|
+
try {
|
|
81
|
+
step(generator["throw"](value));
|
|
82
|
+
} catch (e) {
|
|
83
|
+
reject(e);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function step(result) {
|
|
87
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
88
|
+
}
|
|
89
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
var $2305cbd960c24ac6$var$__classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) {
|
|
93
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
94
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
95
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
96
|
+
};
|
|
97
|
+
var $2305cbd960c24ac6$var$__classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
|
|
98
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
99
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
100
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
101
|
+
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
102
|
+
};
|
|
103
|
+
var $2305cbd960c24ac6$var$__rest = undefined && undefined.__rest || function(s, e) {
|
|
104
|
+
var t = {};
|
|
105
|
+
for(var p in s)if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
106
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") {
|
|
107
|
+
for(var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
108
|
+
}
|
|
109
|
+
return t;
|
|
110
|
+
};
|
|
111
|
+
var $2305cbd960c24ac6$var$__asyncValues = undefined && undefined.__asyncValues || function(o) {
|
|
112
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
113
|
+
var m = o[Symbol.asyncIterator], i;
|
|
114
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() {
|
|
115
|
+
return this;
|
|
116
|
+
}, i);
|
|
117
|
+
function verb(n) {
|
|
118
|
+
i[n] = o[n] && function(v) {
|
|
119
|
+
return new Promise(function(resolve, reject) {
|
|
120
|
+
v = o[n](v), settle(resolve, reject, v.done, v.value);
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
function settle(resolve, reject, d, v) {
|
|
125
|
+
Promise.resolve(v).then(function(v) {
|
|
126
|
+
resolve({
|
|
127
|
+
value: v,
|
|
128
|
+
done: d
|
|
129
|
+
});
|
|
130
|
+
}, reject);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
let $2305cbd960c24ac6$export$e9ba70c733fe1cb8 = (()=>{
|
|
135
|
+
var _a, _DownloadTask_id_accessor_storage, _DownloadTask_name_accessor_storage, _DownloadTask_path_accessor_storage, _DownloadTask_fsHandle_accessor_storage, _DownloadTask_total_accessor_storage, _DownloadTask_loaded_accessor_storage, _DownloadTask_percent_accessor_storage, _DownloadTask_executing_accessor_storage, _DownloadTask_options_accessor_storage;
|
|
136
|
+
var _b;
|
|
137
|
+
let _instanceExtraInitializers = [];
|
|
138
|
+
let _id_decorators;
|
|
139
|
+
let _id_initializers = [];
|
|
140
|
+
let _id_extraInitializers = [];
|
|
141
|
+
let _name_decorators;
|
|
142
|
+
let _name_initializers = [];
|
|
143
|
+
let _name_extraInitializers = [];
|
|
144
|
+
let _path_decorators;
|
|
145
|
+
let _path_initializers = [];
|
|
146
|
+
let _path_extraInitializers = [];
|
|
147
|
+
let _fsHandle_decorators;
|
|
148
|
+
let _fsHandle_initializers = [];
|
|
149
|
+
let _fsHandle_extraInitializers = [];
|
|
150
|
+
let _total_decorators;
|
|
151
|
+
let _total_initializers = [];
|
|
152
|
+
let _total_extraInitializers = [];
|
|
153
|
+
let _loaded_decorators;
|
|
154
|
+
let _loaded_initializers = [];
|
|
155
|
+
let _loaded_extraInitializers = [];
|
|
156
|
+
let _percent_decorators;
|
|
157
|
+
let _percent_initializers = [];
|
|
158
|
+
let _percent_extraInitializers = [];
|
|
159
|
+
let _executing_decorators;
|
|
160
|
+
let _executing_initializers = [];
|
|
161
|
+
let _executing_extraInitializers = [];
|
|
162
|
+
let _options_decorators;
|
|
163
|
+
let _options_initializers = [];
|
|
164
|
+
let _options_extraInitializers = [];
|
|
165
|
+
let _get_totalSize_decorators;
|
|
166
|
+
let _get_loadedSize_decorators;
|
|
167
|
+
return _a = class DownloadTask {
|
|
168
|
+
get id() {
|
|
169
|
+
return $2305cbd960c24ac6$var$__classPrivateFieldGet(this, _DownloadTask_id_accessor_storage, "f");
|
|
170
|
+
}
|
|
171
|
+
set id(value) {
|
|
172
|
+
$2305cbd960c24ac6$var$__classPrivateFieldSet(this, _DownloadTask_id_accessor_storage, value, "f");
|
|
173
|
+
}
|
|
174
|
+
get name() {
|
|
175
|
+
return $2305cbd960c24ac6$var$__classPrivateFieldGet(this, _DownloadTask_name_accessor_storage, "f");
|
|
176
|
+
}
|
|
177
|
+
set name(value) {
|
|
178
|
+
$2305cbd960c24ac6$var$__classPrivateFieldSet(this, _DownloadTask_name_accessor_storage, value, "f");
|
|
179
|
+
}
|
|
180
|
+
get path() {
|
|
181
|
+
return $2305cbd960c24ac6$var$__classPrivateFieldGet(this, _DownloadTask_path_accessor_storage, "f");
|
|
182
|
+
}
|
|
183
|
+
set path(value) {
|
|
184
|
+
$2305cbd960c24ac6$var$__classPrivateFieldSet(this, _DownloadTask_path_accessor_storage, value, "f");
|
|
185
|
+
}
|
|
186
|
+
get fsHandle() {
|
|
187
|
+
return $2305cbd960c24ac6$var$__classPrivateFieldGet(this, _DownloadTask_fsHandle_accessor_storage, "f");
|
|
188
|
+
}
|
|
189
|
+
set fsHandle(value) {
|
|
190
|
+
$2305cbd960c24ac6$var$__classPrivateFieldSet(this, _DownloadTask_fsHandle_accessor_storage, value, "f");
|
|
191
|
+
}
|
|
192
|
+
get total() {
|
|
193
|
+
return $2305cbd960c24ac6$var$__classPrivateFieldGet(this, _DownloadTask_total_accessor_storage, "f");
|
|
194
|
+
}
|
|
195
|
+
set total(value) {
|
|
196
|
+
$2305cbd960c24ac6$var$__classPrivateFieldSet(this, _DownloadTask_total_accessor_storage, value, "f");
|
|
197
|
+
}
|
|
198
|
+
get loaded() {
|
|
199
|
+
return $2305cbd960c24ac6$var$__classPrivateFieldGet(this, _DownloadTask_loaded_accessor_storage, "f");
|
|
200
|
+
}
|
|
201
|
+
set loaded(value) {
|
|
202
|
+
$2305cbd960c24ac6$var$__classPrivateFieldSet(this, _DownloadTask_loaded_accessor_storage, value, "f");
|
|
203
|
+
}
|
|
204
|
+
get percent() {
|
|
205
|
+
return $2305cbd960c24ac6$var$__classPrivateFieldGet(this, _DownloadTask_percent_accessor_storage, "f");
|
|
206
|
+
}
|
|
207
|
+
set percent(value) {
|
|
208
|
+
$2305cbd960c24ac6$var$__classPrivateFieldSet(this, _DownloadTask_percent_accessor_storage, value, "f");
|
|
209
|
+
}
|
|
210
|
+
get executing() {
|
|
211
|
+
return $2305cbd960c24ac6$var$__classPrivateFieldGet(this, _DownloadTask_executing_accessor_storage, "f");
|
|
212
|
+
}
|
|
213
|
+
set executing(value) {
|
|
214
|
+
$2305cbd960c24ac6$var$__classPrivateFieldSet(this, _DownloadTask_executing_accessor_storage, value, "f");
|
|
215
|
+
}
|
|
216
|
+
get options() {
|
|
217
|
+
return $2305cbd960c24ac6$var$__classPrivateFieldGet(this, _DownloadTask_options_accessor_storage, "f");
|
|
218
|
+
}
|
|
219
|
+
set options(value) {
|
|
220
|
+
$2305cbd960c24ac6$var$__classPrivateFieldSet(this, _DownloadTask_options_accessor_storage, value, "f");
|
|
221
|
+
}
|
|
222
|
+
get totalSize() {
|
|
223
|
+
return new (0, $42h8L$ByteSize)(this.total);
|
|
224
|
+
}
|
|
225
|
+
get loadedSize() {
|
|
226
|
+
return new (0, $42h8L$ByteSize)(this.loaded);
|
|
227
|
+
}
|
|
228
|
+
static nameOf(URI) {
|
|
229
|
+
return decodeURI(new URL(URI).pathname.split("/").filter(Boolean).at(-1));
|
|
230
|
+
}
|
|
231
|
+
constructor(path, name = _a.nameOf(path)){
|
|
232
|
+
_DownloadTask_id_accessor_storage.set(this, ($2305cbd960c24ac6$var$__runInitializers(this, _instanceExtraInitializers), $2305cbd960c24ac6$var$__runInitializers(this, _id_initializers, "")));
|
|
233
|
+
_DownloadTask_name_accessor_storage.set(this, ($2305cbd960c24ac6$var$__runInitializers(this, _id_extraInitializers), $2305cbd960c24ac6$var$__runInitializers(this, _name_initializers, "")));
|
|
234
|
+
_DownloadTask_path_accessor_storage.set(this, ($2305cbd960c24ac6$var$__runInitializers(this, _name_extraInitializers), $2305cbd960c24ac6$var$__runInitializers(this, _path_initializers, "")));
|
|
235
|
+
_DownloadTask_fsHandle_accessor_storage.set(this, ($2305cbd960c24ac6$var$__runInitializers(this, _path_extraInitializers), $2305cbd960c24ac6$var$__runInitializers(this, _fsHandle_initializers, void 0)));
|
|
236
|
+
_DownloadTask_total_accessor_storage.set(this, ($2305cbd960c24ac6$var$__runInitializers(this, _fsHandle_extraInitializers), $2305cbd960c24ac6$var$__runInitializers(this, _total_initializers, 0)));
|
|
237
|
+
_DownloadTask_loaded_accessor_storage.set(this, ($2305cbd960c24ac6$var$__runInitializers(this, _total_extraInitializers), $2305cbd960c24ac6$var$__runInitializers(this, _loaded_initializers, 0)));
|
|
238
|
+
_DownloadTask_percent_accessor_storage.set(this, ($2305cbd960c24ac6$var$__runInitializers(this, _loaded_extraInitializers), $2305cbd960c24ac6$var$__runInitializers(this, _percent_initializers, 0)));
|
|
239
|
+
_DownloadTask_executing_accessor_storage.set(this, ($2305cbd960c24ac6$var$__runInitializers(this, _percent_extraInitializers), $2305cbd960c24ac6$var$__runInitializers(this, _executing_initializers, false)));
|
|
240
|
+
_DownloadTask_options_accessor_storage.set(this, ($2305cbd960c24ac6$var$__runInitializers(this, _executing_extraInitializers), $2305cbd960c24ac6$var$__runInitializers(this, _options_initializers, void 0)));
|
|
241
|
+
Object.defineProperty(this, "stream", {
|
|
242
|
+
enumerable: true,
|
|
243
|
+
configurable: true,
|
|
244
|
+
writable: true,
|
|
245
|
+
value: $2305cbd960c24ac6$var$__runInitializers(this, _options_extraInitializers)
|
|
246
|
+
});
|
|
247
|
+
this.path = path;
|
|
248
|
+
this.name = name;
|
|
249
|
+
}
|
|
250
|
+
toJSON() {
|
|
251
|
+
const { id: id, name: name, path: path, fsHandle: fsHandle, total: total, loaded: loaded, percent: percent, options: options } = this;
|
|
252
|
+
return Object.assign({
|
|
253
|
+
id: id,
|
|
254
|
+
name: name,
|
|
255
|
+
path: path,
|
|
256
|
+
fsHandle: fsHandle,
|
|
257
|
+
options: options
|
|
258
|
+
}, {
|
|
259
|
+
total: total,
|
|
260
|
+
loaded: loaded,
|
|
261
|
+
percent: percent
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
saveMeta(data = {}) {
|
|
265
|
+
const { buffer: buffer } = data, progress = $2305cbd960c24ac6$var$__rest(data, [
|
|
266
|
+
"buffer"
|
|
267
|
+
]);
|
|
268
|
+
Object.assign(this, progress);
|
|
269
|
+
return data;
|
|
270
|
+
}
|
|
271
|
+
start() {
|
|
272
|
+
return $2305cbd960c24ac6$var$__awaiter(this, arguments, void 0, function*(options = this.options) {
|
|
273
|
+
this.options = options;
|
|
274
|
+
const started = Promise.withResolvers();
|
|
275
|
+
const [innerStream, outerStream] = (yield $42h8L$webstreamspolyfill).ReadableStream.from(this.loadStream(options)).tee();
|
|
276
|
+
(()=>$2305cbd960c24ac6$var$__awaiter(this, void 0, void 0, function*() {
|
|
277
|
+
var _b, e_1, _c, _d;
|
|
278
|
+
try {
|
|
279
|
+
try {
|
|
280
|
+
for(var _e = true, innerStream_1 = $2305cbd960c24ac6$var$__asyncValues(innerStream), innerStream_1_1; innerStream_1_1 = yield innerStream_1.next(), _b = innerStream_1_1.done, !_b; _e = true){
|
|
281
|
+
_d = innerStream_1_1.value;
|
|
282
|
+
_e = false;
|
|
283
|
+
const chunk = _d;
|
|
284
|
+
started.resolve();
|
|
285
|
+
console.table(chunk);
|
|
286
|
+
}
|
|
287
|
+
} catch (e_1_1) {
|
|
288
|
+
e_1 = {
|
|
289
|
+
error: e_1_1
|
|
290
|
+
};
|
|
291
|
+
} finally{
|
|
292
|
+
try {
|
|
293
|
+
if (!_e && !_b && (_c = innerStream_1.return)) yield _c.call(innerStream_1);
|
|
294
|
+
} finally{
|
|
295
|
+
if (e_1) throw e_1.error;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
} catch (error) {
|
|
299
|
+
started.reject(error);
|
|
300
|
+
}
|
|
301
|
+
}))();
|
|
302
|
+
yield started.promise;
|
|
303
|
+
return this.stream = outerStream;
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
pause() {
|
|
307
|
+
return $2305cbd960c24ac6$var$__awaiter(this, void 0, void 0, function*() {
|
|
308
|
+
this.executing = false;
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
destroy() {
|
|
312
|
+
return $2305cbd960c24ac6$var$__awaiter(this, void 0, void 0, function*() {
|
|
313
|
+
yield this.pause();
|
|
314
|
+
return (0, $42h8L$destroy)(this, this.id);
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
}, _DownloadTask_id_accessor_storage = new WeakMap(), _DownloadTask_name_accessor_storage = new WeakMap(), _DownloadTask_path_accessor_storage = new WeakMap(), _DownloadTask_fsHandle_accessor_storage = new WeakMap(), _DownloadTask_total_accessor_storage = new WeakMap(), _DownloadTask_loaded_accessor_storage = new WeakMap(), _DownloadTask_percent_accessor_storage = new WeakMap(), _DownloadTask_executing_accessor_storage = new WeakMap(), _DownloadTask_options_accessor_storage = new WeakMap(), (()=>{
|
|
318
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
319
|
+
_id_decorators = [
|
|
320
|
+
(0, $42h8L$persist)(),
|
|
321
|
+
(0, $42h8L$observable)
|
|
322
|
+
];
|
|
323
|
+
_name_decorators = [
|
|
324
|
+
(0, $42h8L$persist)(),
|
|
325
|
+
(0, $42h8L$observable)
|
|
326
|
+
];
|
|
327
|
+
_path_decorators = [
|
|
328
|
+
(0, $42h8L$persist)(),
|
|
329
|
+
(0, $42h8L$observable)
|
|
330
|
+
];
|
|
331
|
+
_fsHandle_decorators = [
|
|
332
|
+
(0, $42h8L$persist)(),
|
|
333
|
+
(_b = (0, $42h8L$observable)).ref.bind(_b)
|
|
334
|
+
];
|
|
335
|
+
_total_decorators = [
|
|
336
|
+
(0, $42h8L$persist)(),
|
|
337
|
+
(0, $42h8L$observable)
|
|
338
|
+
];
|
|
339
|
+
_loaded_decorators = [
|
|
340
|
+
(0, $42h8L$persist)(),
|
|
341
|
+
(0, $42h8L$observable)
|
|
342
|
+
];
|
|
343
|
+
_percent_decorators = [
|
|
344
|
+
(0, $42h8L$persist)(),
|
|
345
|
+
(0, $42h8L$observable)
|
|
346
|
+
];
|
|
347
|
+
_executing_decorators = [
|
|
348
|
+
(0, $42h8L$observable)
|
|
349
|
+
];
|
|
350
|
+
_options_decorators = [
|
|
351
|
+
(0, $42h8L$persist)(),
|
|
352
|
+
(0, $42h8L$observable)
|
|
353
|
+
];
|
|
354
|
+
_get_totalSize_decorators = [
|
|
355
|
+
(0, $42h8L$computed)
|
|
356
|
+
];
|
|
357
|
+
_get_loadedSize_decorators = [
|
|
358
|
+
(0, $42h8L$computed)
|
|
359
|
+
];
|
|
360
|
+
$2305cbd960c24ac6$var$__esDecorate(_a, null, _id_decorators, {
|
|
361
|
+
kind: "accessor",
|
|
362
|
+
name: "id",
|
|
363
|
+
static: false,
|
|
364
|
+
private: false,
|
|
365
|
+
access: {
|
|
366
|
+
has: (obj)=>"id" in obj,
|
|
367
|
+
get: (obj)=>obj.id,
|
|
368
|
+
set: (obj, value)=>{
|
|
369
|
+
obj.id = value;
|
|
370
|
+
}
|
|
371
|
+
},
|
|
372
|
+
metadata: _metadata
|
|
373
|
+
}, _id_initializers, _id_extraInitializers);
|
|
374
|
+
$2305cbd960c24ac6$var$__esDecorate(_a, null, _name_decorators, {
|
|
375
|
+
kind: "accessor",
|
|
376
|
+
name: "name",
|
|
377
|
+
static: false,
|
|
378
|
+
private: false,
|
|
379
|
+
access: {
|
|
380
|
+
has: (obj)=>"name" in obj,
|
|
381
|
+
get: (obj)=>obj.name,
|
|
382
|
+
set: (obj, value)=>{
|
|
383
|
+
obj.name = value;
|
|
384
|
+
}
|
|
385
|
+
},
|
|
386
|
+
metadata: _metadata
|
|
387
|
+
}, _name_initializers, _name_extraInitializers);
|
|
388
|
+
$2305cbd960c24ac6$var$__esDecorate(_a, null, _path_decorators, {
|
|
389
|
+
kind: "accessor",
|
|
390
|
+
name: "path",
|
|
391
|
+
static: false,
|
|
392
|
+
private: false,
|
|
393
|
+
access: {
|
|
394
|
+
has: (obj)=>"path" in obj,
|
|
395
|
+
get: (obj)=>obj.path,
|
|
396
|
+
set: (obj, value)=>{
|
|
397
|
+
obj.path = value;
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
metadata: _metadata
|
|
401
|
+
}, _path_initializers, _path_extraInitializers);
|
|
402
|
+
$2305cbd960c24ac6$var$__esDecorate(_a, null, _fsHandle_decorators, {
|
|
403
|
+
kind: "accessor",
|
|
404
|
+
name: "fsHandle",
|
|
405
|
+
static: false,
|
|
406
|
+
private: false,
|
|
407
|
+
access: {
|
|
408
|
+
has: (obj)=>"fsHandle" in obj,
|
|
409
|
+
get: (obj)=>obj.fsHandle,
|
|
410
|
+
set: (obj, value)=>{
|
|
411
|
+
obj.fsHandle = value;
|
|
412
|
+
}
|
|
413
|
+
},
|
|
414
|
+
metadata: _metadata
|
|
415
|
+
}, _fsHandle_initializers, _fsHandle_extraInitializers);
|
|
416
|
+
$2305cbd960c24ac6$var$__esDecorate(_a, null, _total_decorators, {
|
|
417
|
+
kind: "accessor",
|
|
418
|
+
name: "total",
|
|
419
|
+
static: false,
|
|
420
|
+
private: false,
|
|
421
|
+
access: {
|
|
422
|
+
has: (obj)=>"total" in obj,
|
|
423
|
+
get: (obj)=>obj.total,
|
|
424
|
+
set: (obj, value)=>{
|
|
425
|
+
obj.total = value;
|
|
426
|
+
}
|
|
427
|
+
},
|
|
428
|
+
metadata: _metadata
|
|
429
|
+
}, _total_initializers, _total_extraInitializers);
|
|
430
|
+
$2305cbd960c24ac6$var$__esDecorate(_a, null, _loaded_decorators, {
|
|
431
|
+
kind: "accessor",
|
|
432
|
+
name: "loaded",
|
|
433
|
+
static: false,
|
|
434
|
+
private: false,
|
|
435
|
+
access: {
|
|
436
|
+
has: (obj)=>"loaded" in obj,
|
|
437
|
+
get: (obj)=>obj.loaded,
|
|
438
|
+
set: (obj, value)=>{
|
|
439
|
+
obj.loaded = value;
|
|
440
|
+
}
|
|
441
|
+
},
|
|
442
|
+
metadata: _metadata
|
|
443
|
+
}, _loaded_initializers, _loaded_extraInitializers);
|
|
444
|
+
$2305cbd960c24ac6$var$__esDecorate(_a, null, _percent_decorators, {
|
|
445
|
+
kind: "accessor",
|
|
446
|
+
name: "percent",
|
|
447
|
+
static: false,
|
|
448
|
+
private: false,
|
|
449
|
+
access: {
|
|
450
|
+
has: (obj)=>"percent" in obj,
|
|
451
|
+
get: (obj)=>obj.percent,
|
|
452
|
+
set: (obj, value)=>{
|
|
453
|
+
obj.percent = value;
|
|
454
|
+
}
|
|
455
|
+
},
|
|
456
|
+
metadata: _metadata
|
|
457
|
+
}, _percent_initializers, _percent_extraInitializers);
|
|
458
|
+
$2305cbd960c24ac6$var$__esDecorate(_a, null, _executing_decorators, {
|
|
459
|
+
kind: "accessor",
|
|
460
|
+
name: "executing",
|
|
461
|
+
static: false,
|
|
462
|
+
private: false,
|
|
463
|
+
access: {
|
|
464
|
+
has: (obj)=>"executing" in obj,
|
|
465
|
+
get: (obj)=>obj.executing,
|
|
466
|
+
set: (obj, value)=>{
|
|
467
|
+
obj.executing = value;
|
|
468
|
+
}
|
|
469
|
+
},
|
|
470
|
+
metadata: _metadata
|
|
471
|
+
}, _executing_initializers, _executing_extraInitializers);
|
|
472
|
+
$2305cbd960c24ac6$var$__esDecorate(_a, null, _options_decorators, {
|
|
473
|
+
kind: "accessor",
|
|
474
|
+
name: "options",
|
|
475
|
+
static: false,
|
|
476
|
+
private: false,
|
|
477
|
+
access: {
|
|
478
|
+
has: (obj)=>"options" in obj,
|
|
479
|
+
get: (obj)=>obj.options,
|
|
480
|
+
set: (obj, value)=>{
|
|
481
|
+
obj.options = value;
|
|
482
|
+
}
|
|
483
|
+
},
|
|
484
|
+
metadata: _metadata
|
|
485
|
+
}, _options_initializers, _options_extraInitializers);
|
|
486
|
+
$2305cbd960c24ac6$var$__esDecorate(_a, null, _get_totalSize_decorators, {
|
|
487
|
+
kind: "getter",
|
|
488
|
+
name: "totalSize",
|
|
489
|
+
static: false,
|
|
490
|
+
private: false,
|
|
491
|
+
access: {
|
|
492
|
+
has: (obj)=>"totalSize" in obj,
|
|
493
|
+
get: (obj)=>obj.totalSize
|
|
494
|
+
},
|
|
495
|
+
metadata: _metadata
|
|
496
|
+
}, null, _instanceExtraInitializers);
|
|
497
|
+
$2305cbd960c24ac6$var$__esDecorate(_a, null, _get_loadedSize_decorators, {
|
|
498
|
+
kind: "getter",
|
|
499
|
+
name: "loadedSize",
|
|
500
|
+
static: false,
|
|
501
|
+
private: false,
|
|
502
|
+
access: {
|
|
503
|
+
has: (obj)=>"loadedSize" in obj,
|
|
504
|
+
get: (obj)=>obj.loadedSize
|
|
505
|
+
},
|
|
506
|
+
metadata: _metadata
|
|
507
|
+
}, null, _instanceExtraInitializers);
|
|
508
|
+
if (_metadata) Object.defineProperty(_a, Symbol.metadata, {
|
|
509
|
+
enumerable: true,
|
|
510
|
+
configurable: true,
|
|
511
|
+
writable: true,
|
|
512
|
+
value: _metadata
|
|
513
|
+
});
|
|
514
|
+
})(), _a;
|
|
515
|
+
})();
|
|
516
|
+
|
|
517
|
+
|
|
518
|
+
var $eaae1d79f358eeb1$var$__await = undefined && undefined.__await || function(v) {
|
|
519
|
+
return this instanceof $eaae1d79f358eeb1$var$__await ? (this.v = v, this) : new $eaae1d79f358eeb1$var$__await(v);
|
|
520
|
+
};
|
|
521
|
+
var $eaae1d79f358eeb1$var$__asyncValues = undefined && undefined.__asyncValues || function(o) {
|
|
522
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
523
|
+
var m = o[Symbol.asyncIterator], i;
|
|
524
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() {
|
|
525
|
+
return this;
|
|
526
|
+
}, i);
|
|
527
|
+
function verb(n) {
|
|
528
|
+
i[n] = o[n] && function(v) {
|
|
529
|
+
return new Promise(function(resolve, reject) {
|
|
530
|
+
v = o[n](v), settle(resolve, reject, v.done, v.value);
|
|
531
|
+
});
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
function settle(resolve, reject, d, v) {
|
|
535
|
+
Promise.resolve(v).then(function(v) {
|
|
536
|
+
resolve({
|
|
537
|
+
value: v,
|
|
538
|
+
done: d
|
|
539
|
+
});
|
|
540
|
+
}, reject);
|
|
541
|
+
}
|
|
542
|
+
};
|
|
543
|
+
var $eaae1d79f358eeb1$var$__asyncGenerator = undefined && undefined.__asyncGenerator || function(thisArg, _arguments, generator) {
|
|
544
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
545
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
546
|
+
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function() {
|
|
547
|
+
return this;
|
|
548
|
+
}, i;
|
|
549
|
+
function awaitReturn(f) {
|
|
550
|
+
return function(v) {
|
|
551
|
+
return Promise.resolve(v).then(f, reject);
|
|
552
|
+
};
|
|
553
|
+
}
|
|
554
|
+
function verb(n, f) {
|
|
555
|
+
if (g[n]) {
|
|
556
|
+
i[n] = function(v) {
|
|
557
|
+
return new Promise(function(a, b) {
|
|
558
|
+
q.push([
|
|
559
|
+
n,
|
|
560
|
+
v,
|
|
561
|
+
a,
|
|
562
|
+
b
|
|
563
|
+
]) > 1 || resume(n, v);
|
|
564
|
+
});
|
|
565
|
+
};
|
|
566
|
+
if (f) i[n] = f(i[n]);
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
function resume(n, v) {
|
|
570
|
+
try {
|
|
571
|
+
step(g[n](v));
|
|
572
|
+
} catch (e) {
|
|
573
|
+
settle(q[0][3], e);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
function step(r) {
|
|
577
|
+
r.value instanceof $eaae1d79f358eeb1$var$__await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r);
|
|
578
|
+
}
|
|
579
|
+
function fulfill(value) {
|
|
580
|
+
resume("next", value);
|
|
581
|
+
}
|
|
582
|
+
function reject(value) {
|
|
583
|
+
resume("throw", value);
|
|
584
|
+
}
|
|
585
|
+
function settle(f, v) {
|
|
586
|
+
if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]);
|
|
587
|
+
}
|
|
588
|
+
};
|
|
589
|
+
|
|
590
|
+
class $eaae1d79f358eeb1$export$54a5aef4e85ae85 extends (0, $2305cbd960c24ac6$export$e9ba70c733fe1cb8) {
|
|
591
|
+
constructor(path, name){
|
|
592
|
+
super(path, name);
|
|
593
|
+
Object.defineProperty(this, "client", {
|
|
594
|
+
enumerable: true,
|
|
595
|
+
configurable: true,
|
|
596
|
+
writable: true,
|
|
597
|
+
value: new (0, $42h8L$HTTPClient)({
|
|
598
|
+
responseType: "arraybuffer"
|
|
599
|
+
})
|
|
600
|
+
});
|
|
601
|
+
this.id = `http-download-task-${this.name}`;
|
|
602
|
+
(0, $42h8L$restore)(this, this.id);
|
|
603
|
+
}
|
|
604
|
+
loadStream(options) {
|
|
605
|
+
return $eaae1d79f358eeb1$var$__asyncGenerator(this, arguments, function* loadStream_1() {
|
|
606
|
+
var _a, e_1, _b, _c;
|
|
607
|
+
const { path: path } = this;
|
|
608
|
+
const suggestedName = (0, $2305cbd960c24ac6$export$e9ba70c733fe1cb8).nameOf(path);
|
|
609
|
+
this.fsHandle || (this.fsHandle = yield $eaae1d79f358eeb1$var$__await((yield $eaae1d79f358eeb1$var$__await($42h8L$nativefilesystemadapter)).showSaveFilePicker({
|
|
610
|
+
suggestedName: suggestedName
|
|
611
|
+
})));
|
|
612
|
+
const writer = yield $eaae1d79f358eeb1$var$__await(this.fsHandle.createWritable({
|
|
613
|
+
keepExistingData: true
|
|
614
|
+
})), stream = this.client.download(path, Object.assign({
|
|
615
|
+
range: [
|
|
616
|
+
this.loaded
|
|
617
|
+
]
|
|
618
|
+
}, options));
|
|
619
|
+
try {
|
|
620
|
+
this.executing = true;
|
|
621
|
+
try {
|
|
622
|
+
for(var _d = true, stream_1 = $eaae1d79f358eeb1$var$__asyncValues(stream), stream_1_1; stream_1_1 = yield $eaae1d79f358eeb1$var$__await(stream_1.next()), _a = stream_1_1.done, !_a; _d = true){
|
|
623
|
+
_c = stream_1_1.value;
|
|
624
|
+
_d = false;
|
|
625
|
+
const chunk = _c;
|
|
626
|
+
yield $eaae1d79f358eeb1$var$__await(writer.write({
|
|
627
|
+
type: "write",
|
|
628
|
+
position: this.loaded,
|
|
629
|
+
data: chunk.buffer
|
|
630
|
+
}));
|
|
631
|
+
yield yield $eaae1d79f358eeb1$var$__await(this.saveMeta(chunk));
|
|
632
|
+
if (!this.executing) break;
|
|
633
|
+
}
|
|
634
|
+
} catch (e_1_1) {
|
|
635
|
+
e_1 = {
|
|
636
|
+
error: e_1_1
|
|
637
|
+
};
|
|
638
|
+
} finally{
|
|
639
|
+
try {
|
|
640
|
+
if (!_d && !_a && (_b = stream_1.return)) yield $eaae1d79f358eeb1$var$__await(_b.call(stream_1));
|
|
641
|
+
} finally{
|
|
642
|
+
if (e_1) throw e_1.error;
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
} finally{
|
|
646
|
+
yield $eaae1d79f358eeb1$var$__await(writer.close());
|
|
647
|
+
this.executing = false;
|
|
648
|
+
}
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
|
|
654
|
+
|
|
655
|
+
var $53eb72fe5615c114$var$__runInitializers = undefined && undefined.__runInitializers || function(thisArg, initializers, value) {
|
|
656
|
+
var useValue = arguments.length > 2;
|
|
657
|
+
for(var i = 0; i < initializers.length; i++)value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
658
|
+
return useValue ? value : void 0;
|
|
659
|
+
};
|
|
660
|
+
var $53eb72fe5615c114$var$__esDecorate = undefined && undefined.__esDecorate || function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
661
|
+
function accept(f) {
|
|
662
|
+
if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected");
|
|
663
|
+
return f;
|
|
664
|
+
}
|
|
665
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
666
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
667
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
668
|
+
var _, done = false;
|
|
669
|
+
for(var i = decorators.length - 1; i >= 0; i--){
|
|
670
|
+
var context = {};
|
|
671
|
+
for(var p in contextIn)context[p] = p === "access" ? {} : contextIn[p];
|
|
672
|
+
for(var p in contextIn.access)context.access[p] = contextIn.access[p];
|
|
673
|
+
context.addInitializer = function(f) {
|
|
674
|
+
if (done) throw new TypeError("Cannot add initializers after decoration has completed");
|
|
675
|
+
extraInitializers.push(accept(f || null));
|
|
676
|
+
};
|
|
677
|
+
var result = (0, decorators[i])(kind === "accessor" ? {
|
|
678
|
+
get: descriptor.get,
|
|
679
|
+
set: descriptor.set
|
|
680
|
+
} : descriptor[key], context);
|
|
681
|
+
if (kind === "accessor") {
|
|
682
|
+
if (result === void 0) continue;
|
|
683
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
684
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
685
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
686
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
687
|
+
} else if (_ = accept(result)) {
|
|
688
|
+
if (kind === "field") initializers.unshift(_);
|
|
689
|
+
else descriptor[key] = _;
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
693
|
+
done = true;
|
|
694
|
+
};
|
|
695
|
+
var $53eb72fe5615c114$var$__awaiter = undefined && undefined.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
696
|
+
function adopt(value) {
|
|
697
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
698
|
+
resolve(value);
|
|
699
|
+
});
|
|
700
|
+
}
|
|
701
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
702
|
+
function fulfilled(value) {
|
|
703
|
+
try {
|
|
704
|
+
step(generator.next(value));
|
|
705
|
+
} catch (e) {
|
|
706
|
+
reject(e);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
function rejected(value) {
|
|
710
|
+
try {
|
|
711
|
+
step(generator["throw"](value));
|
|
712
|
+
} catch (e) {
|
|
713
|
+
reject(e);
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
function step(result) {
|
|
717
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
718
|
+
}
|
|
719
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
720
|
+
});
|
|
721
|
+
};
|
|
722
|
+
var $53eb72fe5615c114$var$__classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) {
|
|
723
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
724
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
725
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
726
|
+
};
|
|
727
|
+
var $53eb72fe5615c114$var$__classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
|
|
728
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
729
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
730
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
731
|
+
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
732
|
+
};
|
|
733
|
+
let $53eb72fe5615c114$export$ef06e7620d37c296 = (()=>{
|
|
734
|
+
var _a, _Downloader_tasks_accessor_storage;
|
|
735
|
+
let _instanceExtraInitializers = [];
|
|
736
|
+
let _tasks_decorators;
|
|
737
|
+
let _tasks_initializers = [];
|
|
738
|
+
let _tasks_extraInitializers = [];
|
|
739
|
+
let _get_unfinishedCount_decorators;
|
|
740
|
+
let _get_executingCount_decorators;
|
|
741
|
+
return _a = class Downloader {
|
|
742
|
+
static createTask(path, name) {
|
|
743
|
+
const [protocol] = path.split(":");
|
|
744
|
+
const ProtocolTask = _a.protocolMap[protocol];
|
|
745
|
+
if (!ProtocolTask) throw new URIError(`Protocol "${protocol} has not been registered"`);
|
|
746
|
+
return new ProtocolTask(path, name);
|
|
747
|
+
}
|
|
748
|
+
constructor(){
|
|
749
|
+
_Downloader_tasks_accessor_storage.set(this, ($53eb72fe5615c114$var$__runInitializers(this, _instanceExtraInitializers), $53eb72fe5615c114$var$__runInitializers(this, _tasks_initializers, [])));
|
|
750
|
+
$53eb72fe5615c114$var$__runInitializers(this, _tasks_extraInitializers);
|
|
751
|
+
(0, $42h8L$restore)(this, "downloader");
|
|
752
|
+
}
|
|
753
|
+
get tasks() {
|
|
754
|
+
return $53eb72fe5615c114$var$__classPrivateFieldGet(this, _Downloader_tasks_accessor_storage, "f");
|
|
755
|
+
}
|
|
756
|
+
set tasks(value) {
|
|
757
|
+
$53eb72fe5615c114$var$__classPrivateFieldSet(this, _Downloader_tasks_accessor_storage, value, "f");
|
|
758
|
+
}
|
|
759
|
+
get unfinishedCount() {
|
|
760
|
+
return this.tasks.filter(({ percent: percent })=>percent < 100).length;
|
|
761
|
+
}
|
|
762
|
+
get executingCount() {
|
|
763
|
+
return this.tasks.filter(({ executing: executing })=>executing).length;
|
|
764
|
+
}
|
|
765
|
+
createTask(path, name) {
|
|
766
|
+
const { tasks: tasks } = this;
|
|
767
|
+
const sameTask = tasks.find((task)=>task.path === path);
|
|
768
|
+
if (sameTask) return sameTask;
|
|
769
|
+
const task = _a.createTask(path, name);
|
|
770
|
+
this.tasks = [
|
|
771
|
+
...tasks,
|
|
772
|
+
task
|
|
773
|
+
];
|
|
774
|
+
return task;
|
|
775
|
+
}
|
|
776
|
+
destroyTask(name) {
|
|
777
|
+
return $53eb72fe5615c114$var$__awaiter(this, void 0, void 0, function*() {
|
|
778
|
+
const { tasks: tasks } = this;
|
|
779
|
+
const index = tasks.findIndex(({ name: N })=>N === name);
|
|
780
|
+
if (index < 0) throw new ReferenceError(`${name} isn't found`);
|
|
781
|
+
yield tasks[index].destroy();
|
|
782
|
+
this.tasks = [
|
|
783
|
+
...tasks.slice(0, index),
|
|
784
|
+
...tasks.slice(index + 1)
|
|
785
|
+
];
|
|
786
|
+
});
|
|
787
|
+
}
|
|
788
|
+
}, _Downloader_tasks_accessor_storage = new WeakMap(), (()=>{
|
|
789
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
790
|
+
_tasks_decorators = [
|
|
791
|
+
(0, $42h8L$persist)({
|
|
792
|
+
set: (tasks)=>tasks.map(({ name: name, path: path })=>({
|
|
793
|
+
name: name,
|
|
794
|
+
path: path
|
|
795
|
+
})),
|
|
796
|
+
get: (list)=>list === null || list === void 0 ? void 0 : list.map(({ name: name, path: path })=>$53eb72fe5615c114$export$ef06e7620d37c296.createTask(path, name))
|
|
797
|
+
}),
|
|
798
|
+
(0, $42h8L$observable)
|
|
799
|
+
];
|
|
800
|
+
_get_unfinishedCount_decorators = [
|
|
801
|
+
(0, $42h8L$computed)
|
|
802
|
+
];
|
|
803
|
+
_get_executingCount_decorators = [
|
|
804
|
+
(0, $42h8L$computed)
|
|
805
|
+
];
|
|
806
|
+
$53eb72fe5615c114$var$__esDecorate(_a, null, _tasks_decorators, {
|
|
807
|
+
kind: "accessor",
|
|
808
|
+
name: "tasks",
|
|
809
|
+
static: false,
|
|
810
|
+
private: false,
|
|
811
|
+
access: {
|
|
812
|
+
has: (obj)=>"tasks" in obj,
|
|
813
|
+
get: (obj)=>obj.tasks,
|
|
814
|
+
set: (obj, value)=>{
|
|
815
|
+
obj.tasks = value;
|
|
816
|
+
}
|
|
817
|
+
},
|
|
818
|
+
metadata: _metadata
|
|
819
|
+
}, _tasks_initializers, _tasks_extraInitializers);
|
|
820
|
+
$53eb72fe5615c114$var$__esDecorate(_a, null, _get_unfinishedCount_decorators, {
|
|
821
|
+
kind: "getter",
|
|
822
|
+
name: "unfinishedCount",
|
|
823
|
+
static: false,
|
|
824
|
+
private: false,
|
|
825
|
+
access: {
|
|
826
|
+
has: (obj)=>"unfinishedCount" in obj,
|
|
827
|
+
get: (obj)=>obj.unfinishedCount
|
|
828
|
+
},
|
|
829
|
+
metadata: _metadata
|
|
830
|
+
}, null, _instanceExtraInitializers);
|
|
831
|
+
$53eb72fe5615c114$var$__esDecorate(_a, null, _get_executingCount_decorators, {
|
|
832
|
+
kind: "getter",
|
|
833
|
+
name: "executingCount",
|
|
834
|
+
static: false,
|
|
835
|
+
private: false,
|
|
836
|
+
access: {
|
|
837
|
+
has: (obj)=>"executingCount" in obj,
|
|
838
|
+
get: (obj)=>obj.executingCount
|
|
839
|
+
},
|
|
840
|
+
metadata: _metadata
|
|
841
|
+
}, null, _instanceExtraInitializers);
|
|
842
|
+
if (_metadata) Object.defineProperty(_a, Symbol.metadata, {
|
|
843
|
+
enumerable: true,
|
|
844
|
+
configurable: true,
|
|
845
|
+
writable: true,
|
|
846
|
+
value: _metadata
|
|
847
|
+
});
|
|
848
|
+
})(), Object.defineProperty(_a, "protocolMap", {
|
|
849
|
+
enumerable: true,
|
|
850
|
+
configurable: true,
|
|
851
|
+
writable: true,
|
|
852
|
+
value: {
|
|
853
|
+
http: (0, $eaae1d79f358eeb1$export$54a5aef4e85ae85),
|
|
854
|
+
https: (0, $eaae1d79f358eeb1$export$54a5aef4e85ae85)
|
|
855
|
+
}
|
|
856
|
+
}), _a;
|
|
857
|
+
})();
|
|
858
|
+
|
|
859
|
+
|
|
860
|
+
export {$53eb72fe5615c114$export$ef06e7620d37c296 as Downloader, $eaae1d79f358eeb1$export$54a5aef4e85ae85 as HTTPDownloadTask, $2305cbd960c24ac6$export$e9ba70c733fe1cb8 as DownloadTask};
|
|
861
|
+
//# sourceMappingURL=index.esm.js.map
|