@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 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
- var f=Object.defineProperty;var g=(a,b)=>{for(var c in b)f(a,c,{get:b[c],enumerable:!0});};var e=(a,b,c)=>{if(!b.has(a))throw TypeError("Cannot "+c)};var h=(a,b,c)=>(e(a,b,"read from private field"),c?c.call(a):b.get(a)),i$1=(a,b,c)=>{if(b.has(a))throw TypeError("Cannot add the same private member more than once");b instanceof WeakSet?b.add(a):b.set(a,c);},j=(a,b,c,d)=>(e(a,b,"write to private field"),d?d.call(a,c):b.set(a,c),c);
1
+ 'use strict';
2
2
 
3
- var T={};g(T,{Channel:()=>i,PluginListener:()=>o,addPluginListener:()=>l,convertFileSrc:()=>v,invoke:()=>u,transformCallback:()=>_});function _(e,n=!1){return window.__TAURI_INTERNALS__.transformCallback(e,n)}var r,i=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0;i$1(this,r,()=>{});this.id=_(n=>{h(this,r).call(this,n);});}set onmessage(n){j(this,r,n);}get onmessage(){return h(this,r)}toJSON(){return `__CHANNEL__:${this.id}`}};r=new WeakMap;var o=class{constructor(n,s,t){this.plugin=n,this.event=s,this.channelId=t;}async unregister(){return u(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function l(e,n,s){let t=new i;return t.onmessage=s,u(`plugin:${e}|register_listener`,{event:n,handler:t}).then(()=>new o(e,n,t.id))}async function u(e,n={},s){return window.__TAURI_INTERNALS__.invoke(e,n,s)}function v(e,n="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(e,n)}
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 === null || init === void 0 ? void 0 : init.maxRedirections;
45
- const connectTimeout = init === null || init === void 0 ? void 0 : init.maxRedirections;
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 u("plugin:http|fetch", {
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
- u("plugin:http|fetch_cancel", {
63
+ primitives.invoke("plugin:http|fetch_cancel", {
64
64
  rid,
65
65
  });
66
66
  });
67
- const { status, statusText, url, headers } = await u("plugin:http|fetch_send", {
67
+ const { status, statusText, url, headers } = await primitives.invoke("plugin:http|fetch_send", {
68
68
  rid,
69
69
  });
70
- const body = await u("plugin:http|fetch_read_body", {
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
- export { fetch };
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 === null || init === void 0 ? void 0 : init.maxRedirections;
43
- const connectTimeout = init === null || init === void 0 ? void 0 : init.maxRedirections;
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.2",
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
- "browser": "dist-js/index.min.js",
10
- "module": "dist-js/index.mjs",
11
- "types": "dist-js/index.d.ts",
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
- "browser": "./dist-js/index.min.js"
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.9"
23
+ "@tauri-apps/api": "2.0.0-alpha.12"
28
24
  },
29
25
  "scripts": {
30
26
  "build": "rollup -c"