@tauri-apps/plugin-http 3.0.0-alpha.1 → 3.0.0-alpha.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/README.md +1 -1
- package/dist-js/index.cjs +10 -0
- package/dist-js/index.d.ts +23 -3
- package/dist-js/index.js +10 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ Access the HTTP client written in Rust.
|
|
|
12
12
|
|
|
13
13
|
## Install
|
|
14
14
|
|
|
15
|
-
_This plugin requires a Rust version of at least **1.
|
|
15
|
+
_This plugin requires a Rust version of at least **1.95**_
|
|
16
16
|
|
|
17
17
|
There are three general methods of installation that we can recommend.
|
|
18
18
|
|
package/dist-js/index.cjs
CHANGED
|
@@ -33,14 +33,24 @@ const ERROR_REQUEST_CANCELLED = 'Request cancelled';
|
|
|
33
33
|
* Fetch a resource from the network. It returns a `Promise` that resolves to the
|
|
34
34
|
* `Response` to that `Request`, whether it is successful or not.
|
|
35
35
|
*
|
|
36
|
+
* The request is performed by the Rust backend instead of the webview, so it is not subject to
|
|
37
|
+
* CORS, but the URL must be allowed by the plugin scope.
|
|
38
|
+
*
|
|
36
39
|
* @example
|
|
37
40
|
* ```typescript
|
|
41
|
+
* import { fetch } from '@tauri-apps/plugin-http';
|
|
38
42
|
* const response = await fetch("http://my.json.host/data.json");
|
|
39
43
|
* console.log(response.status); // e.g. 200
|
|
40
44
|
* console.log(response.statusText); // e.g. "OK"
|
|
41
45
|
* const jsonData = await response.json();
|
|
42
46
|
* ```
|
|
43
47
|
*
|
|
48
|
+
* @param input The resource to fetch, as a URL, a string or a `Request` object.
|
|
49
|
+
* @param init The standard `fetch` request options, extended with the Rust client options from
|
|
50
|
+
* {@linkcode ClientOptions}: `maxRedirections`, `connectTimeout`, `proxy` and `danger`. The
|
|
51
|
+
* `signal` option can be used to abort the request.
|
|
52
|
+
* @returns A promise resolving to the `Response` of the request.
|
|
53
|
+
*
|
|
44
54
|
* @since 2.0.0
|
|
45
55
|
*/
|
|
46
56
|
async function fetch(input, init) {
|
package/dist-js/index.d.ts
CHANGED
|
@@ -17,6 +17,11 @@ export interface Proxy {
|
|
|
17
17
|
*/
|
|
18
18
|
https?: string | ProxyConfig;
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Detailed configuration of a single proxy server, used when a plain URL string is not enough.
|
|
22
|
+
*
|
|
23
|
+
* @since 2.0.0
|
|
24
|
+
*/
|
|
20
25
|
export interface ProxyConfig {
|
|
21
26
|
/**
|
|
22
27
|
* The URL of the proxy server.
|
|
@@ -26,7 +31,13 @@ export interface ProxyConfig {
|
|
|
26
31
|
* Set the `Proxy-Authorization` header using Basic auth.
|
|
27
32
|
*/
|
|
28
33
|
basicAuth?: {
|
|
34
|
+
/**
|
|
35
|
+
* The user name sent to the proxy server.
|
|
36
|
+
*/
|
|
29
37
|
username: string;
|
|
38
|
+
/**
|
|
39
|
+
* The password sent to the proxy server.
|
|
40
|
+
*/
|
|
30
41
|
password: string;
|
|
31
42
|
};
|
|
32
43
|
/**
|
|
@@ -45,9 +56,8 @@ export interface ClientOptions {
|
|
|
45
56
|
* Defines the maximum number of redirects the client should follow.
|
|
46
57
|
* If set to 0, no redirects will be followed.
|
|
47
58
|
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* instead of being followed.
|
|
59
|
+
* Every redirect must also be allowed by the configured scope,
|
|
60
|
+
* otherwise the request fails instead of being followed.
|
|
51
61
|
*/
|
|
52
62
|
maxRedirections?: number;
|
|
53
63
|
/** Timeout in milliseconds */
|
|
@@ -80,14 +90,24 @@ export interface DangerousSettings {
|
|
|
80
90
|
* Fetch a resource from the network. It returns a `Promise` that resolves to the
|
|
81
91
|
* `Response` to that `Request`, whether it is successful or not.
|
|
82
92
|
*
|
|
93
|
+
* The request is performed by the Rust backend instead of the webview, so it is not subject to
|
|
94
|
+
* CORS, but the URL must be allowed by the plugin scope.
|
|
95
|
+
*
|
|
83
96
|
* @example
|
|
84
97
|
* ```typescript
|
|
98
|
+
* import { fetch } from '@tauri-apps/plugin-http';
|
|
85
99
|
* const response = await fetch("http://my.json.host/data.json");
|
|
86
100
|
* console.log(response.status); // e.g. 200
|
|
87
101
|
* console.log(response.statusText); // e.g. "OK"
|
|
88
102
|
* const jsonData = await response.json();
|
|
89
103
|
* ```
|
|
90
104
|
*
|
|
105
|
+
* @param input The resource to fetch, as a URL, a string or a `Request` object.
|
|
106
|
+
* @param init The standard `fetch` request options, extended with the Rust client options from
|
|
107
|
+
* {@linkcode ClientOptions}: `maxRedirections`, `connectTimeout`, `proxy` and `danger`. The
|
|
108
|
+
* `signal` option can be used to abort the request.
|
|
109
|
+
* @returns A promise resolving to the `Response` of the request.
|
|
110
|
+
*
|
|
91
111
|
* @since 2.0.0
|
|
92
112
|
*/
|
|
93
113
|
export declare function fetch(input: URL | Request | string, init?: RequestInit & ClientOptions): Promise<Response>;
|
package/dist-js/index.js
CHANGED
|
@@ -31,14 +31,24 @@ const ERROR_REQUEST_CANCELLED = 'Request cancelled';
|
|
|
31
31
|
* Fetch a resource from the network. It returns a `Promise` that resolves to the
|
|
32
32
|
* `Response` to that `Request`, whether it is successful or not.
|
|
33
33
|
*
|
|
34
|
+
* The request is performed by the Rust backend instead of the webview, so it is not subject to
|
|
35
|
+
* CORS, but the URL must be allowed by the plugin scope.
|
|
36
|
+
*
|
|
34
37
|
* @example
|
|
35
38
|
* ```typescript
|
|
39
|
+
* import { fetch } from '@tauri-apps/plugin-http';
|
|
36
40
|
* const response = await fetch("http://my.json.host/data.json");
|
|
37
41
|
* console.log(response.status); // e.g. 200
|
|
38
42
|
* console.log(response.statusText); // e.g. "OK"
|
|
39
43
|
* const jsonData = await response.json();
|
|
40
44
|
* ```
|
|
41
45
|
*
|
|
46
|
+
* @param input The resource to fetch, as a URL, a string or a `Request` object.
|
|
47
|
+
* @param init The standard `fetch` request options, extended with the Rust client options from
|
|
48
|
+
* {@linkcode ClientOptions}: `maxRedirections`, `connectTimeout`, `proxy` and `danger`. The
|
|
49
|
+
* `signal` option can be used to abort the request.
|
|
50
|
+
* @returns A promise resolving to the `Response` of the request.
|
|
51
|
+
*
|
|
42
52
|
* @since 2.0.0
|
|
43
53
|
*/
|
|
44
54
|
async function fetch(input, init) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tauri-apps/plugin-http",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.3",
|
|
4
4
|
"license": "MIT OR Apache-2.0",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Tauri Programme within The Commons Conservancy"
|
|
@@ -24,6 +24,6 @@
|
|
|
24
24
|
"LICENSE"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@tauri-apps/api": "^3.0.0-alpha.
|
|
27
|
+
"@tauri-apps/api": "^3.0.0-alpha.2"
|
|
28
28
|
}
|
|
29
29
|
}
|