@useinsider/guido 3.18.1-beta.3d934c5 → 3.18.1-beta.4871655

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.
@@ -1,6 +1,6 @@
1
1
  import { getCsrfToken as S } from "../utils/genericUtil.js";
2
2
  import { ref as p, computed as v } from "vue";
3
- const k = (b = {}) => {
3
+ const F = (b = {}) => {
4
4
  const d = p(!1), n = p(null), u = p(null), g = v(() => d.value), y = v(() => n.value !== null), w = {
5
5
  baseURL: "",
6
6
  timeout: 1e4,
@@ -8,10 +8,7 @@ const k = (b = {}) => {
8
8
  retryDelay: 1e3,
9
9
  headers: {
10
10
  "Content-Type": "application/json",
11
- "X-CSRF-TOKEN": S(),
12
- // The panel backend only answers 401/419 to ajax requests; without this a guest
13
- // fetch gets a 302 to the login page and never sees an auth status.
14
- "X-Requested-With": "XMLHttpRequest"
11
+ "X-CSRF-TOKEN": S()
15
12
  },
16
13
  ...b
17
14
  }, P = (e, r) => {
@@ -40,11 +37,11 @@ const k = (b = {}) => {
40
37
  a.timeout && o.push(x(a.timeout));
41
38
  const s = await Promise.race(o);
42
39
  if (!s.ok) {
43
- const H = `HTTP Error: ${s.status} ${s.statusText}`, h = new Error(H);
44
- throw h.status = s.status, h.statusText = s.statusText, h.response = s, [401, 403, 419].includes(s.status) && Promise.resolve().then(() => s.clone().text().catch(() => "")).then((O) => window.dispatchEvent(new CustomEvent("insider:http-auth-error", {
40
+ const O = `HTTP Error: ${s.status} ${s.statusText}`, h = new Error(O);
41
+ throw h.status = s.status, h.statusText = s.statusText, h.response = s, [401, 403, 419].includes(s.status) && Promise.resolve().then(() => s.clone().text().catch(() => "")).then((H) => window.dispatchEvent(new CustomEvent("insider:http-auth-error", {
45
42
  detail: {
46
43
  status: s.status,
47
- body: O,
44
+ body: H,
48
45
  url: new URL(T, window.location.href).href
49
46
  }
50
47
  }))).catch(() => {
@@ -70,9 +67,9 @@ const k = (b = {}) => {
70
67
  } finally {
71
68
  d.value = !1, u.value = null;
72
69
  }
73
- }, R = (e, r) => i("GET", e, void 0, r), U = (e, r, t) => i("POST", e, r, t), $ = (e, r, t) => i("PUT", e, r, t), q = (e, r, t) => i("PATCH", e, r, t), L = (e, r) => i("DELETE", e, void 0, r), W = (e) => {
70
+ }, R = (e, r) => i("GET", e, void 0, r), U = (e, r, t) => i("POST", e, r, t), $ = (e, r, t) => i("PUT", e, r, t), A = (e, r, t) => i("PATCH", e, r, t), L = (e, r) => i("DELETE", e, void 0, r), W = (e) => {
74
71
  u.value && u.value.abort(e);
75
- }, A = () => {
72
+ }, q = () => {
76
73
  n.value = null;
77
74
  };
78
75
  return {
@@ -85,12 +82,12 @@ const k = (b = {}) => {
85
82
  get: R,
86
83
  post: U,
87
84
  put: $,
88
- patch: q,
85
+ patch: A,
89
86
  delete: L,
90
87
  cancel: W,
91
- clearError: A
88
+ clearError: q
92
89
  };
93
90
  };
94
91
  export {
95
- k as useHttp
92
+ F as useHttp
96
93
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.18.1-beta.3d934c5",
3
+ "version": "3.18.1-beta.4871655",
4
4
  "description": "Guido is a Vue + TypeScript wrapper for Email Plugin. Easily embed the email editor in your Vue applications.",
5
5
  "main": "./dist/guido.umd.cjs",
6
6
  "module": "./dist/library.js",