happy-dom 2.50.0 → 2.52.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.
Potentially problematic release.
This version of happy-dom might be problematic. Click here for more details.
- package/lib/async-task-manager/AsyncTaskManager.d.ts +65 -0
- package/lib/{window → async-task-manager}/AsyncTaskManager.js +52 -55
- package/lib/async-task-manager/AsyncTaskManager.js.map +1 -0
- package/lib/fetch/FetchHandler.d.ts +17 -0
- package/lib/fetch/FetchHandler.js +59 -0
- package/lib/fetch/FetchHandler.js.map +1 -0
- package/lib/fetch/Headers.d.ts +7 -0
- package/lib/fetch/Headers.js +53 -0
- package/lib/fetch/Headers.js.map +1 -0
- package/lib/fetch/IAbortSignal.d.ts +16 -0
- package/lib/fetch/IAbortSignal.js +4 -0
- package/lib/fetch/IAbortSignal.js.map +1 -0
- package/lib/fetch/IBody.d.ts +17 -0
- package/lib/{window/IFetchOptions.js → fetch/IBody.js} +1 -1
- package/lib/fetch/IBody.js.map +1 -0
- package/lib/fetch/IHeaders.d.ts +18 -0
- package/lib/fetch/IHeaders.js +3 -0
- package/lib/fetch/IHeaders.js.map +1 -0
- package/lib/fetch/IHeadersInit.d.ts +5 -0
- package/lib/fetch/IHeadersInit.js +3 -0
- package/lib/fetch/IHeadersInit.js.map +1 -0
- package/lib/fetch/IRequest.d.ts +18 -0
- package/lib/fetch/IRequest.js +3 -0
- package/lib/fetch/IRequest.js.map +1 -0
- package/lib/fetch/IRequestInit.d.ts +15 -0
- package/lib/fetch/IRequestInit.js +3 -0
- package/lib/fetch/IRequestInit.js.map +1 -0
- package/lib/fetch/IResponse.d.ts +20 -0
- package/lib/{window → fetch}/IResponse.js +0 -0
- package/lib/{window → fetch}/IResponse.js.map +1 -1
- package/lib/fetch/IResponseInit.d.ts +9 -0
- package/lib/fetch/IResponseInit.js +3 -0
- package/lib/fetch/IResponseInit.js.map +1 -0
- package/lib/fetch/Request.d.ts +69 -0
- package/lib/fetch/Request.js +179 -0
- package/lib/fetch/Request.js.map +1 -0
- package/lib/fetch/ResourceFetchHandler.d.ts +22 -0
- package/lib/fetch/{ResourceFetcher.js → ResourceFetchHandler.js} +19 -26
- package/lib/fetch/ResourceFetchHandler.js.map +1 -0
- package/lib/fetch/Response.d.ts +69 -0
- package/lib/fetch/Response.js +179 -0
- package/lib/fetch/Response.js.map +1 -0
- package/lib/file/Blob.d.ts +8 -1
- package/lib/file/Blob.js +48 -0
- package/lib/file/Blob.js.map +1 -1
- package/lib/file/IBlob.d.ts +10 -0
- package/lib/file/IBlob.js +3 -0
- package/lib/file/IBlob.js.map +1 -0
- package/lib/form-data/IFormData.d.ts +30 -0
- package/lib/form-data/IFormData.js +3 -0
- package/lib/form-data/IFormData.js.map +1 -0
- package/lib/index.d.ts +3 -5
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/lib/nodes/document/Document.js +9 -0
- package/lib/nodes/document/Document.js.map +1 -1
- package/lib/nodes/html-link-element/HTMLLinkElement.js +3 -3
- package/lib/nodes/html-link-element/HTMLLinkElement.js.map +1 -1
- package/lib/nodes/html-script-element/ScriptUtility.js +3 -9
- package/lib/nodes/html-script-element/ScriptUtility.js.map +1 -1
- package/lib/nodes/node/INode.d.ts +6 -0
- package/lib/nodes/node/Node.d.ts +6 -0
- package/lib/nodes/node/Node.js +6 -0
- package/lib/nodes/node/Node.js.map +1 -1
- package/lib/window/IWindow.d.ts +20 -16
- package/lib/window/Window.d.ts +45 -10
- package/lib/window/Window.js +72 -66
- package/lib/window/Window.js.map +1 -1
- package/package.json +3 -2
- package/src/async-task-manager/AsyncTaskManager.ts +128 -0
- package/src/fetch/FetchHandler.ts +54 -0
- package/src/fetch/Headers.ts +7 -0
- package/src/fetch/IAbortSignal.ts +34 -0
- package/src/fetch/IBody.ts +18 -0
- package/src/fetch/IHeaders.ts +18 -0
- package/src/fetch/IHeadersInit.ts +5 -0
- package/src/fetch/IRequest.ts +59 -0
- package/src/fetch/IRequestInit.ts +41 -0
- package/src/fetch/IResponse.ts +22 -0
- package/src/fetch/IResponseInit.ts +10 -0
- package/src/fetch/Request.ts +149 -0
- package/src/fetch/ResourceFetchHandler.ts +47 -0
- package/src/fetch/Response.ts +149 -0
- package/src/file/Blob.ts +12 -1
- package/src/file/IBlob.ts +10 -0
- package/src/form-data/IFormData.ts +33 -0
- package/src/index.ts +2 -6
- package/src/nodes/document/Document.ts +12 -0
- package/src/nodes/html-link-element/HTMLLinkElement.ts +3 -3
- package/src/nodes/html-script-element/ScriptUtility.ts +3 -9
- package/src/nodes/node/INode.ts +6 -0
- package/src/nodes/node/Node.ts +6 -0
- package/src/window/IWindow.ts +14 -16
- package/src/window/Window.ts +68 -67
- package/lib/fetch/ResourceFetcher.d.ts +0 -30
- package/lib/fetch/ResourceFetcher.js.map +0 -1
- package/lib/url-search-params/URLSearchParams.d.ts +0 -87
- package/lib/url-search-params/URLSearchParams.js +0 -196
- package/lib/url-search-params/URLSearchParams.js.map +0 -1
- package/lib/window/AsyncTaskManager.d.ts +0 -54
- package/lib/window/AsyncTaskManager.js.map +0 -1
- package/lib/window/AsyncTaskTypeEnum.d.ts +0 -5
- package/lib/window/AsyncTaskTypeEnum.js +0 -9
- package/lib/window/AsyncTaskTypeEnum.js.map +0 -1
- package/lib/window/IFetchOptions.d.ts +0 -13
- package/lib/window/IFetchOptions.js.map +0 -1
- package/lib/window/IResponse.d.ts +0 -32
- package/src/fetch/ResourceFetcher.ts +0 -55
- package/src/url-search-params/URLSearchParams.ts +0 -198
- package/src/window/AsyncTaskManager.ts +0 -127
- package/src/window/AsyncTaskTypeEnum.ts +0 -5
- package/src/window/IFetchOptions.ts +0 -11
- package/src/window/IResponse.ts +0 -34
@@ -1,9 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
var AsyncTaskTypeEnum;
|
4
|
-
(function (AsyncTaskTypeEnum) {
|
5
|
-
AsyncTaskTypeEnum["timer"] = "timer";
|
6
|
-
AsyncTaskTypeEnum["fetch"] = "fetch";
|
7
|
-
})(AsyncTaskTypeEnum || (AsyncTaskTypeEnum = {}));
|
8
|
-
exports.default = AsyncTaskTypeEnum;
|
9
|
-
//# sourceMappingURL=AsyncTaskTypeEnum.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"AsyncTaskTypeEnum.js","sourceRoot":"","sources":["../../src/window/AsyncTaskTypeEnum.ts"],"names":[],"mappings":";;AAAA,IAAK,iBAGJ;AAHD,WAAK,iBAAiB;IACrB,oCAAe,CAAA;IACf,oCAAe,CAAA;AAChB,CAAC,EAHI,iBAAiB,KAAjB,iBAAiB,QAGrB;AACD,kBAAe,iBAAiB,CAAC"}
|
@@ -1,13 +0,0 @@
|
|
1
|
-
/// <reference types="node" />
|
2
|
-
import { URLSearchParams } from 'url';
|
3
|
-
/**
|
4
|
-
* Fetch options.
|
5
|
-
*/
|
6
|
-
export default interface IFetchOptions {
|
7
|
-
method?: string;
|
8
|
-
headers?: Map<string, string> | {
|
9
|
-
[k: string]: string;
|
10
|
-
};
|
11
|
-
body?: URLSearchParams | string;
|
12
|
-
redirect?: string;
|
13
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"IFetchOptions.js","sourceRoot":"","sources":["../../src/window/IFetchOptions.ts"],"names":[],"mappings":""}
|
@@ -1,32 +0,0 @@
|
|
1
|
-
import Blob from '../file/Blob';
|
2
|
-
/**
|
3
|
-
* Fetch response.
|
4
|
-
*/
|
5
|
-
export default interface IResponse {
|
6
|
-
readonly url: string;
|
7
|
-
readonly status: number;
|
8
|
-
readonly ok: boolean;
|
9
|
-
readonly redirected: boolean;
|
10
|
-
readonly statusText: string;
|
11
|
-
readonly headers: {
|
12
|
-
[k: string]: string;
|
13
|
-
};
|
14
|
-
/**
|
15
|
-
* Returns JSON.
|
16
|
-
*
|
17
|
-
* @returns JSON.
|
18
|
-
*/
|
19
|
-
json(): Promise<string>;
|
20
|
-
/**
|
21
|
-
* Returns Text.
|
22
|
-
*
|
23
|
-
* @returns Text.
|
24
|
-
*/
|
25
|
-
text(): Promise<string>;
|
26
|
-
/**
|
27
|
-
* Returns blob.
|
28
|
-
*
|
29
|
-
* @returns Blob.
|
30
|
-
*/
|
31
|
-
blob(): Promise<Blob>;
|
32
|
-
}
|
@@ -1,55 +0,0 @@
|
|
1
|
-
import RelativeURL from '../location/RelativeURL';
|
2
|
-
import Window from '../window/Window';
|
3
|
-
import DOMException from '../exception/DOMException';
|
4
|
-
|
5
|
-
/**
|
6
|
-
* Helper class for performing an asynchonous or synchrounous request to a resource.
|
7
|
-
*/
|
8
|
-
export default class ResourceFetcher {
|
9
|
-
/**
|
10
|
-
* Returns resource data asynchonously.
|
11
|
-
*
|
12
|
-
* @param options Options.
|
13
|
-
* @param options.window Location.
|
14
|
-
* @param options.url URL.
|
15
|
-
* @returns Response.
|
16
|
-
*/
|
17
|
-
public static async fetch(options: { window: Window; url: string }): Promise<string> {
|
18
|
-
const response = await options.window.fetch(options.url);
|
19
|
-
if (!response.ok) {
|
20
|
-
throw new DOMException(
|
21
|
-
`Failed to perform request to "${options.url}". Status code: ${response.status}`
|
22
|
-
);
|
23
|
-
}
|
24
|
-
return await response.text();
|
25
|
-
}
|
26
|
-
|
27
|
-
/**
|
28
|
-
* Returns resource data synchonously.
|
29
|
-
*
|
30
|
-
* @param options Options.
|
31
|
-
* @param options.window Location.
|
32
|
-
* @param options.url URL.
|
33
|
-
* @returns Response.
|
34
|
-
*/
|
35
|
-
public static fetchSync(options: { window: Window; url: string }): string {
|
36
|
-
const url = RelativeURL.getAbsoluteURL(options.window.location, options.url);
|
37
|
-
let request = null;
|
38
|
-
|
39
|
-
try {
|
40
|
-
request = require('sync-request');
|
41
|
-
} catch (error) {
|
42
|
-
throw new DOMException('Failed to load script. "sync-request" could not be loaded.');
|
43
|
-
}
|
44
|
-
|
45
|
-
const response = request('GET', url);
|
46
|
-
|
47
|
-
if (response.isError()) {
|
48
|
-
throw new DOMException(
|
49
|
-
`Failed to perform request to "${url}". Status code: ${response.statusCode}`
|
50
|
-
);
|
51
|
-
}
|
52
|
-
|
53
|
-
return response.getBody();
|
54
|
-
}
|
55
|
-
}
|
@@ -1,198 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* URLSearchParams.
|
3
|
-
*
|
4
|
-
* Reference:
|
5
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams.
|
6
|
-
*/
|
7
|
-
export default class URLSearchParams {
|
8
|
-
private _params: Array<[string, string]> = [];
|
9
|
-
|
10
|
-
/**
|
11
|
-
* Constructor.
|
12
|
-
*
|
13
|
-
* @param [params] Params string.
|
14
|
-
*/
|
15
|
-
constructor(params?: string) {
|
16
|
-
if (params) {
|
17
|
-
for (const entry of params.split('&')) {
|
18
|
-
const [name, value] = entry.split('=');
|
19
|
-
if (name) {
|
20
|
-
this._params.push([name, value]);
|
21
|
-
}
|
22
|
-
}
|
23
|
-
}
|
24
|
-
}
|
25
|
-
|
26
|
-
/**
|
27
|
-
* Appends a specified key/value pair as a new search parameter.
|
28
|
-
*
|
29
|
-
* @param name Name.
|
30
|
-
* @param value Value.
|
31
|
-
*/
|
32
|
-
public append(name: string, value: string): void {
|
33
|
-
this._params.push([name, value]);
|
34
|
-
}
|
35
|
-
|
36
|
-
/**
|
37
|
-
* Deletes the given search parameter, and its associated value, from the list of all search parameters.
|
38
|
-
*
|
39
|
-
* @param name Name.
|
40
|
-
*/
|
41
|
-
public delete(name: string): void {
|
42
|
-
for (let i = 0, max = this._params.length; i < max; i++) {
|
43
|
-
if (this._params[i][0] === name) {
|
44
|
-
this._params.splice(i, 1);
|
45
|
-
i--;
|
46
|
-
max--;
|
47
|
-
}
|
48
|
-
}
|
49
|
-
}
|
50
|
-
|
51
|
-
/**
|
52
|
-
* Returns an iterator.
|
53
|
-
*
|
54
|
-
* @returns Entries.
|
55
|
-
*/
|
56
|
-
public entries(): IterableIterator<[string, string]> {
|
57
|
-
const params = this._params;
|
58
|
-
const Iterator = function Iterator(): void {
|
59
|
-
let index = 0;
|
60
|
-
this.next = () => {
|
61
|
-
const value = params[index];
|
62
|
-
const done = index >= params.length;
|
63
|
-
index++;
|
64
|
-
return { value, done: done };
|
65
|
-
};
|
66
|
-
this[Symbol.iterator] = () => new Iterator();
|
67
|
-
};
|
68
|
-
return <IterableIterator<[string, string]>>new Iterator();
|
69
|
-
}
|
70
|
-
|
71
|
-
/**
|
72
|
-
* For each.
|
73
|
-
*
|
74
|
-
* @param callback Callback.
|
75
|
-
*/
|
76
|
-
public forEach(callback: (value, key) => void): void {
|
77
|
-
for (const param of this._params) {
|
78
|
-
callback(param[0], param[1]);
|
79
|
-
}
|
80
|
-
}
|
81
|
-
|
82
|
-
/**
|
83
|
-
* Returns value.
|
84
|
-
*
|
85
|
-
* @param name Name.
|
86
|
-
*/
|
87
|
-
public get(name: string): string {
|
88
|
-
for (const param of this._params) {
|
89
|
-
if (param[0] === name) {
|
90
|
-
return param[1];
|
91
|
-
}
|
92
|
-
}
|
93
|
-
return undefined;
|
94
|
-
}
|
95
|
-
|
96
|
-
/**
|
97
|
-
* Returns all values associated with a name.
|
98
|
-
*
|
99
|
-
* @param name Name.
|
100
|
-
* @returns Values.
|
101
|
-
*/
|
102
|
-
public getAll(name: string): string[] {
|
103
|
-
const values = [];
|
104
|
-
for (const param of this._params) {
|
105
|
-
if (param[0] === name) {
|
106
|
-
values.push(param[1]);
|
107
|
-
}
|
108
|
-
}
|
109
|
-
return values;
|
110
|
-
}
|
111
|
-
|
112
|
-
/**
|
113
|
-
* Returns "true" if param exists.
|
114
|
-
*
|
115
|
-
* @param name Name.
|
116
|
-
* @returns "true" if param exists.
|
117
|
-
*/
|
118
|
-
public has(name: string): boolean {
|
119
|
-
for (const param of this._params) {
|
120
|
-
if (param[0] === name) {
|
121
|
-
return true;
|
122
|
-
}
|
123
|
-
}
|
124
|
-
return false;
|
125
|
-
}
|
126
|
-
|
127
|
-
/**
|
128
|
-
* Returns an iterator.
|
129
|
-
*
|
130
|
-
* @returns Keys iterator.
|
131
|
-
*/
|
132
|
-
public keys(): IterableIterator<string> {
|
133
|
-
const params = this._params;
|
134
|
-
const Iterator = function Iterator(): void {
|
135
|
-
let index = 0;
|
136
|
-
this.next = () => {
|
137
|
-
const value = params[index] !== undefined ? params[index][0] : undefined;
|
138
|
-
const done = index >= params.length;
|
139
|
-
index++;
|
140
|
-
return { value, done: done };
|
141
|
-
};
|
142
|
-
this[Symbol.iterator] = () => new Iterator();
|
143
|
-
};
|
144
|
-
return <IterableIterator<string>>new Iterator();
|
145
|
-
}
|
146
|
-
|
147
|
-
/**
|
148
|
-
* Sets the value associated with a given search parameter to the given value. If there are several values, the others are deleted.
|
149
|
-
*
|
150
|
-
* @param name Name.
|
151
|
-
* @param value Value.
|
152
|
-
*/
|
153
|
-
public set(name: string, value: string): void {
|
154
|
-
this.delete(name);
|
155
|
-
this.append(name, value);
|
156
|
-
}
|
157
|
-
|
158
|
-
/**
|
159
|
-
* Sorts all key/value pairs, if any, by their keys.
|
160
|
-
*/
|
161
|
-
public sort(): void {
|
162
|
-
this._params.sort((a, b) => {
|
163
|
-
if (a[0] < b[0]) {
|
164
|
-
return -1;
|
165
|
-
} else if (a[0] > b[0]) {
|
166
|
-
return 1;
|
167
|
-
}
|
168
|
-
return 0;
|
169
|
-
});
|
170
|
-
}
|
171
|
-
|
172
|
-
/**
|
173
|
-
* Returns a string containing a query string suitable for use in a URL.
|
174
|
-
*/
|
175
|
-
public toString(): string {
|
176
|
-
return this._params.map((param) => param.join('=')).join('&');
|
177
|
-
}
|
178
|
-
|
179
|
-
/**
|
180
|
-
* Returns an iterator.
|
181
|
-
*
|
182
|
-
* @returns Values iterator.
|
183
|
-
*/
|
184
|
-
public values(): IterableIterator<string> {
|
185
|
-
const params = this._params;
|
186
|
-
const Iterator = function Iterator(): void {
|
187
|
-
let index = 0;
|
188
|
-
this.next = () => {
|
189
|
-
const value = params[index] !== undefined ? params[index][1] : undefined;
|
190
|
-
const done = index >= params.length;
|
191
|
-
index++;
|
192
|
-
return { value, done: done };
|
193
|
-
};
|
194
|
-
this[Symbol.iterator] = () => new Iterator();
|
195
|
-
};
|
196
|
-
return <IterableIterator<string>>new Iterator();
|
197
|
-
}
|
198
|
-
}
|
@@ -1,127 +0,0 @@
|
|
1
|
-
import AsyncTaskTypeEnum from './AsyncTaskTypeEnum';
|
2
|
-
|
3
|
-
/**
|
4
|
-
* Handles async tasks.
|
5
|
-
*/
|
6
|
-
export default class AsyncTaskManager {
|
7
|
-
private tasks: { [k: string]: (NodeJS.Timeout | string)[] } = {};
|
8
|
-
private queue: { resolve: () => void; reject: (error: Error) => void }[] = [];
|
9
|
-
|
10
|
-
/**
|
11
|
-
* Returns a promise that is fulfilled when async tasks are complete.
|
12
|
-
* This method is not part of the HTML standard.
|
13
|
-
*
|
14
|
-
* @returns Promise.
|
15
|
-
*/
|
16
|
-
public async whenComplete(): Promise<void> {
|
17
|
-
return new Promise((resolve, reject) => {
|
18
|
-
const timerID = global.setTimeout(() => {
|
19
|
-
this.endTimer(timerID);
|
20
|
-
}, 0);
|
21
|
-
this.startTimer(timerID);
|
22
|
-
this.queue.push({ resolve, reject });
|
23
|
-
});
|
24
|
-
}
|
25
|
-
|
26
|
-
/**
|
27
|
-
* Cancels all tasks.
|
28
|
-
*
|
29
|
-
* @param [error] Error.
|
30
|
-
*/
|
31
|
-
public cancelAllTasks(error?: Error): void {
|
32
|
-
if (this.tasks[AsyncTaskTypeEnum.timer]) {
|
33
|
-
for (const id of this.tasks[AsyncTaskTypeEnum.timer]) {
|
34
|
-
global.clearTimeout(<NodeJS.Timeout>id);
|
35
|
-
}
|
36
|
-
}
|
37
|
-
|
38
|
-
const promises = this.queue;
|
39
|
-
|
40
|
-
this.tasks = {};
|
41
|
-
this.queue = [];
|
42
|
-
|
43
|
-
for (const promise of promises) {
|
44
|
-
if (error) {
|
45
|
-
promise.reject(error);
|
46
|
-
} else {
|
47
|
-
promise.resolve();
|
48
|
-
}
|
49
|
-
}
|
50
|
-
}
|
51
|
-
|
52
|
-
/**
|
53
|
-
* Starts a timer.
|
54
|
-
*
|
55
|
-
* @param id Timer ID.
|
56
|
-
*/
|
57
|
-
public startTimer(id: NodeJS.Timeout = null): void {
|
58
|
-
this.tasks[AsyncTaskTypeEnum.timer] = this.tasks[AsyncTaskTypeEnum.timer] || [];
|
59
|
-
this.tasks[AsyncTaskTypeEnum.timer].push(id);
|
60
|
-
}
|
61
|
-
|
62
|
-
/**
|
63
|
-
* Ends a timer.
|
64
|
-
*
|
65
|
-
* @param id Timer ID.
|
66
|
-
*/
|
67
|
-
public endTimer(id: NodeJS.Timeout = null): void {
|
68
|
-
if (this.tasks[AsyncTaskTypeEnum.timer]) {
|
69
|
-
const index = this.tasks[AsyncTaskTypeEnum.timer].indexOf(id);
|
70
|
-
if (index !== -1) {
|
71
|
-
this.tasks[AsyncTaskTypeEnum.timer].splice(index, 1);
|
72
|
-
if (this.tasks[AsyncTaskTypeEnum.timer].length === 0) {
|
73
|
-
delete this.tasks[AsyncTaskTypeEnum.timer];
|
74
|
-
|
75
|
-
if (Object.keys(this.tasks).length === 0) {
|
76
|
-
this.cancelAllTasks();
|
77
|
-
}
|
78
|
-
}
|
79
|
-
}
|
80
|
-
}
|
81
|
-
}
|
82
|
-
|
83
|
-
/**
|
84
|
-
* Starts an async task.
|
85
|
-
*
|
86
|
-
* @param type Task type.
|
87
|
-
*/
|
88
|
-
public startTask(type: AsyncTaskTypeEnum): void {
|
89
|
-
this.tasks[type] = this.tasks[type] || [];
|
90
|
-
this.tasks[type].push(type);
|
91
|
-
}
|
92
|
-
|
93
|
-
/**
|
94
|
-
* Ends an async task.
|
95
|
-
*
|
96
|
-
* @param type Task type.
|
97
|
-
* @param [error] Error.
|
98
|
-
*/
|
99
|
-
public endTask(type: AsyncTaskTypeEnum, error?: Error): void {
|
100
|
-
if (error) {
|
101
|
-
this.cancelAllTasks(error);
|
102
|
-
} else if (this.tasks[type]) {
|
103
|
-
this.tasks[type].pop();
|
104
|
-
|
105
|
-
if (this.tasks[type].length === 0) {
|
106
|
-
delete this.tasks[type];
|
107
|
-
|
108
|
-
if (Object.keys(this.tasks).length === 0) {
|
109
|
-
this.cancelAllTasks();
|
110
|
-
}
|
111
|
-
}
|
112
|
-
}
|
113
|
-
}
|
114
|
-
|
115
|
-
/**
|
116
|
-
* Returns the amount of running tasks by type.
|
117
|
-
*
|
118
|
-
* @param type Task type.
|
119
|
-
* @returns Count.
|
120
|
-
*/
|
121
|
-
public getRunningCount(type: AsyncTaskTypeEnum): number {
|
122
|
-
if (this.tasks[type]) {
|
123
|
-
return this.tasks[type].length;
|
124
|
-
}
|
125
|
-
return 0;
|
126
|
-
}
|
127
|
-
}
|
package/src/window/IResponse.ts
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
import Blob from '../file/Blob';
|
2
|
-
|
3
|
-
/**
|
4
|
-
* Fetch response.
|
5
|
-
*/
|
6
|
-
export default interface IResponse {
|
7
|
-
readonly url: string;
|
8
|
-
readonly status: number;
|
9
|
-
readonly ok: boolean;
|
10
|
-
readonly redirected: boolean;
|
11
|
-
readonly statusText: string;
|
12
|
-
readonly headers: { [k: string]: string };
|
13
|
-
|
14
|
-
/**
|
15
|
-
* Returns JSON.
|
16
|
-
*
|
17
|
-
* @returns JSON.
|
18
|
-
*/
|
19
|
-
json(): Promise<string>;
|
20
|
-
|
21
|
-
/**
|
22
|
-
* Returns Text.
|
23
|
-
*
|
24
|
-
* @returns Text.
|
25
|
-
*/
|
26
|
-
text(): Promise<string>;
|
27
|
-
|
28
|
-
/**
|
29
|
-
* Returns blob.
|
30
|
-
*
|
31
|
-
* @returns Blob.
|
32
|
-
*/
|
33
|
-
blob(): Promise<Blob>;
|
34
|
-
}
|