@tauri-apps/plugin-http 2.0.0-beta.2 → 2.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-js/index.cjs +6 -6
- package/dist-js/index.d.ts +3 -3
- package/dist-js/index.js +6 -6
- package/package.json +2 -2
package/dist-js/index.cjs
CHANGED
|
@@ -45,13 +45,13 @@ async function fetch(input, init) {
|
|
|
45
45
|
const connectTimeout = init?.connectTimeout;
|
|
46
46
|
const proxy = init?.proxy;
|
|
47
47
|
// Remove these fields before creating the request
|
|
48
|
-
if (init) {
|
|
48
|
+
if (init != null) {
|
|
49
49
|
delete init.maxRedirections;
|
|
50
50
|
delete init.connectTimeout;
|
|
51
51
|
delete init.proxy;
|
|
52
52
|
}
|
|
53
53
|
const signal = init?.signal;
|
|
54
|
-
const headers =
|
|
54
|
+
const headers = init?.headers == null
|
|
55
55
|
? []
|
|
56
56
|
: init.headers instanceof Headers
|
|
57
57
|
? Array.from(init.headers.entries())
|
|
@@ -66,7 +66,7 @@ async function fetch(input, init) {
|
|
|
66
66
|
]);
|
|
67
67
|
const req = new Request(input, init);
|
|
68
68
|
const buffer = await req.arrayBuffer();
|
|
69
|
-
const reqData = buffer.byteLength ? Array.from(new Uint8Array(buffer)) : null;
|
|
69
|
+
const reqData = buffer.byteLength !== 0 ? Array.from(new Uint8Array(buffer)) : null;
|
|
70
70
|
const rid = await core.invoke("plugin:http|fetch", {
|
|
71
71
|
clientConfig: {
|
|
72
72
|
method: req.method,
|
|
@@ -79,7 +79,7 @@ async function fetch(input, init) {
|
|
|
79
79
|
},
|
|
80
80
|
});
|
|
81
81
|
signal?.addEventListener("abort", () => {
|
|
82
|
-
core.invoke("plugin:http|fetch_cancel", {
|
|
82
|
+
void core.invoke("plugin:http|fetch_cancel", {
|
|
83
83
|
rid,
|
|
84
84
|
});
|
|
85
85
|
});
|
|
@@ -89,9 +89,9 @@ async function fetch(input, init) {
|
|
|
89
89
|
const body = await core.invoke("plugin:http|fetch_read_body", {
|
|
90
90
|
rid: responseRid,
|
|
91
91
|
});
|
|
92
|
-
const res = new Response(body instanceof ArrayBuffer && body.byteLength
|
|
92
|
+
const res = new Response(body instanceof ArrayBuffer && body.byteLength !== 0
|
|
93
93
|
? body
|
|
94
|
-
: body instanceof Array && body.length
|
|
94
|
+
: body instanceof Array && body.length > 0
|
|
95
95
|
? new Uint8Array(body)
|
|
96
96
|
: null, {
|
|
97
97
|
headers: responseHeaders,
|
package/dist-js/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @since 2.0.0
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
6
|
+
export interface Proxy {
|
|
7
7
|
/**
|
|
8
8
|
* Proxy all traffic to the passed URL.
|
|
9
9
|
*/
|
|
@@ -16,7 +16,7 @@ export type Proxy = {
|
|
|
16
16
|
* Proxy all HTTPS traffic to the passed URL.
|
|
17
17
|
*/
|
|
18
18
|
https?: string | ProxyConfig;
|
|
19
|
-
}
|
|
19
|
+
}
|
|
20
20
|
export interface ProxyConfig {
|
|
21
21
|
/**
|
|
22
22
|
* The URL of the proxy server.
|
|
@@ -30,7 +30,7 @@ export interface ProxyConfig {
|
|
|
30
30
|
password: string;
|
|
31
31
|
};
|
|
32
32
|
/**
|
|
33
|
-
* A configuration for filtering out requests that shouldn
|
|
33
|
+
* A configuration for filtering out requests that shouldn't be proxied.
|
|
34
34
|
* Entries are expected to be comma-separated (whitespace between entries is ignored)
|
|
35
35
|
*/
|
|
36
36
|
noProxy?: string;
|
package/dist-js/index.js
CHANGED
|
@@ -43,13 +43,13 @@ async function fetch(input, init) {
|
|
|
43
43
|
const connectTimeout = init?.connectTimeout;
|
|
44
44
|
const proxy = init?.proxy;
|
|
45
45
|
// Remove these fields before creating the request
|
|
46
|
-
if (init) {
|
|
46
|
+
if (init != null) {
|
|
47
47
|
delete init.maxRedirections;
|
|
48
48
|
delete init.connectTimeout;
|
|
49
49
|
delete init.proxy;
|
|
50
50
|
}
|
|
51
51
|
const signal = init?.signal;
|
|
52
|
-
const headers =
|
|
52
|
+
const headers = init?.headers == null
|
|
53
53
|
? []
|
|
54
54
|
: init.headers instanceof Headers
|
|
55
55
|
? Array.from(init.headers.entries())
|
|
@@ -64,7 +64,7 @@ async function fetch(input, init) {
|
|
|
64
64
|
]);
|
|
65
65
|
const req = new Request(input, init);
|
|
66
66
|
const buffer = await req.arrayBuffer();
|
|
67
|
-
const reqData = buffer.byteLength ? Array.from(new Uint8Array(buffer)) : null;
|
|
67
|
+
const reqData = buffer.byteLength !== 0 ? Array.from(new Uint8Array(buffer)) : null;
|
|
68
68
|
const rid = await invoke("plugin:http|fetch", {
|
|
69
69
|
clientConfig: {
|
|
70
70
|
method: req.method,
|
|
@@ -77,7 +77,7 @@ async function fetch(input, init) {
|
|
|
77
77
|
},
|
|
78
78
|
});
|
|
79
79
|
signal?.addEventListener("abort", () => {
|
|
80
|
-
invoke("plugin:http|fetch_cancel", {
|
|
80
|
+
void invoke("plugin:http|fetch_cancel", {
|
|
81
81
|
rid,
|
|
82
82
|
});
|
|
83
83
|
});
|
|
@@ -87,9 +87,9 @@ async function fetch(input, init) {
|
|
|
87
87
|
const body = await invoke("plugin:http|fetch_read_body", {
|
|
88
88
|
rid: responseRid,
|
|
89
89
|
});
|
|
90
|
-
const res = new Response(body instanceof ArrayBuffer && body.byteLength
|
|
90
|
+
const res = new Response(body instanceof ArrayBuffer && body.byteLength !== 0
|
|
91
91
|
? body
|
|
92
|
-
: body instanceof Array && body.length
|
|
92
|
+
: body instanceof Array && body.length > 0
|
|
93
93
|
? new Uint8Array(body)
|
|
94
94
|
: null, {
|
|
95
95
|
headers: responseHeaders,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tauri-apps/plugin-http",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.3",
|
|
4
4
|
"license": "MIT or APACHE-2.0",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Tauri Programme within The Commons Conservancy"
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"LICENSE"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@tauri-apps/api": "2.0.0-beta.
|
|
23
|
+
"@tauri-apps/api": "2.0.0-beta.11"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
26
|
"build": "rollup -c"
|