@tauri-apps/plugin-http 2.0.0-alpha.2 → 2.0.0-alpha.4
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 +16 -0
- package/dist-js/{index.min.js → index.cjs} +9 -10
- package/dist-js/{index.mjs → index.js} +2 -3
- package/package.json +7 -11
package/README.md
CHANGED
|
@@ -71,6 +71,22 @@ const response = await fetch("http://localhost:3003/users/2", {
|
|
|
71
71
|
|
|
72
72
|
PRs accepted. Please make sure to read the Contributing Guide before making a pull request.
|
|
73
73
|
|
|
74
|
+
## Partners
|
|
75
|
+
|
|
76
|
+
<table>
|
|
77
|
+
<tbody>
|
|
78
|
+
<tr>
|
|
79
|
+
<td align="center" valign="middle">
|
|
80
|
+
<a href="https://crabnebula.dev" target="_blank">
|
|
81
|
+
<img src="https://github.com/tauri-apps/plugins-workspace/raw/v2/.github/sponsors/crabnebula.svg" alt="CrabNebula" width="283">
|
|
82
|
+
</a>
|
|
83
|
+
</td>
|
|
84
|
+
</tr>
|
|
85
|
+
</tbody>
|
|
86
|
+
</table>
|
|
87
|
+
|
|
88
|
+
For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri).
|
|
89
|
+
|
|
74
90
|
## License
|
|
75
91
|
|
|
76
92
|
Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var primitives = require('@tauri-apps/api/primitives');
|
|
4
4
|
|
|
5
5
|
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
|
6
6
|
// SPDX-License-Identifier: Apache-2.0
|
|
@@ -41,8 +41,8 @@ var T={};g(T,{Channel:()=>i,PluginListener:()=>o,addPluginListener:()=>l,convert
|
|
|
41
41
|
* @since 2.0.0
|
|
42
42
|
*/
|
|
43
43
|
async function fetch(input, init) {
|
|
44
|
-
const maxRedirections = init
|
|
45
|
-
const connectTimeout = init
|
|
44
|
+
const maxRedirections = init?.maxRedirections;
|
|
45
|
+
const connectTimeout = init?.maxRedirections;
|
|
46
46
|
// Remove these fields before creating the request
|
|
47
47
|
if (init) {
|
|
48
48
|
delete init.maxRedirections;
|
|
@@ -51,7 +51,7 @@ async function fetch(input, init) {
|
|
|
51
51
|
const req = new Request(input, init);
|
|
52
52
|
const buffer = await req.arrayBuffer();
|
|
53
53
|
const reqData = buffer.byteLength ? Array.from(new Uint8Array(buffer)) : null;
|
|
54
|
-
const rid = await
|
|
54
|
+
const rid = await primitives.invoke("plugin:http|fetch", {
|
|
55
55
|
method: req.method,
|
|
56
56
|
url: req.url,
|
|
57
57
|
headers: Array.from(req.headers.entries()),
|
|
@@ -60,14 +60,14 @@ async function fetch(input, init) {
|
|
|
60
60
|
connectTimeout,
|
|
61
61
|
});
|
|
62
62
|
req.signal.addEventListener("abort", () => {
|
|
63
|
-
|
|
63
|
+
primitives.invoke("plugin:http|fetch_cancel", {
|
|
64
64
|
rid,
|
|
65
65
|
});
|
|
66
66
|
});
|
|
67
|
-
const { status, statusText, url, headers } = await
|
|
67
|
+
const { status, statusText, url, headers } = await primitives.invoke("plugin:http|fetch_send", {
|
|
68
68
|
rid,
|
|
69
69
|
});
|
|
70
|
-
const body = await
|
|
70
|
+
const body = await primitives.invoke("plugin:http|fetch_read_body", {
|
|
71
71
|
rid,
|
|
72
72
|
});
|
|
73
73
|
const res = new Response(new Uint8Array(body), {
|
|
@@ -80,5 +80,4 @@ async function fetch(input, init) {
|
|
|
80
80
|
return res;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
//# sourceMappingURL=index.min.js.map
|
|
83
|
+
exports.fetch = fetch;
|
|
@@ -39,8 +39,8 @@ import { invoke } from '@tauri-apps/api/primitives';
|
|
|
39
39
|
* @since 2.0.0
|
|
40
40
|
*/
|
|
41
41
|
async function fetch(input, init) {
|
|
42
|
-
const maxRedirections = init
|
|
43
|
-
const connectTimeout = init
|
|
42
|
+
const maxRedirections = init?.maxRedirections;
|
|
43
|
+
const connectTimeout = init?.maxRedirections;
|
|
44
44
|
// Remove these fields before creating the request
|
|
45
45
|
if (init) {
|
|
46
46
|
delete init.maxRedirections;
|
|
@@ -79,4 +79,3 @@ async function fetch(input, init) {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
export { fetch };
|
|
82
|
-
//# sourceMappingURL=index.mjs.map
|
package/package.json
CHANGED
|
@@ -1,30 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tauri-apps/plugin-http",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.4",
|
|
4
4
|
"license": "MIT or APACHE-2.0",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Tauri Programme within The Commons Conservancy"
|
|
7
7
|
],
|
|
8
8
|
"type": "module",
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
9
|
+
"types": "./dist-js/index.d.ts",
|
|
10
|
+
"main": "./dist-js/index.cjs",
|
|
11
|
+
"module": "./dist-js/index.js",
|
|
12
12
|
"exports": {
|
|
13
|
-
"import": "./dist-js/index.mjs",
|
|
14
13
|
"types": "./dist-js/index.d.ts",
|
|
15
|
-
"
|
|
14
|
+
"import": "./dist-js/index.js",
|
|
15
|
+
"require": "./dist-js/index.cjs"
|
|
16
16
|
},
|
|
17
17
|
"files": [
|
|
18
18
|
"dist-js",
|
|
19
|
-
"!dist-js/**/*.map",
|
|
20
19
|
"README.md",
|
|
21
20
|
"LICENSE"
|
|
22
21
|
],
|
|
23
|
-
"devDependencies": {
|
|
24
|
-
"tslib": "^2.5.0"
|
|
25
|
-
},
|
|
26
22
|
"dependencies": {
|
|
27
|
-
"@tauri-apps/api": "2.0.0-alpha.
|
|
23
|
+
"@tauri-apps/api": "2.0.0-alpha.12"
|
|
28
24
|
},
|
|
29
25
|
"scripts": {
|
|
30
26
|
"build": "rollup -c"
|