@useinsider/guido 1.0.3-beta.001f60f → 1.0.3-beta.031021e

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.
Files changed (67) hide show
  1. package/dist/components/Guido.vue.js +10 -10
  2. package/dist/components/Guido.vue2.js +65 -89
  3. package/dist/composables/useHttp.js +60 -127
  4. package/dist/composables/useStripo.js +64 -198
  5. package/dist/extensions/Blocks/RadioButton/template.js +6 -6
  6. package/dist/guido.css +1 -1
  7. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +72 -83
  8. package/dist/package.json.js +1 -1
  9. package/dist/services/stripoApi.js +19 -51
  10. package/dist/src/@types/generic.d.ts +0 -4
  11. package/dist/src/components/Guido.vue.d.ts +0 -1
  12. package/dist/src/composables/useHttp.d.ts +0 -2
  13. package/dist/src/composables/useStripo.d.ts +0 -1
  14. package/dist/src/services/stripoApi.d.ts +1 -1
  15. package/dist/src/stores/editor.d.ts +0 -21
  16. package/dist/src/utils/genericUtil.d.ts +0 -1
  17. package/dist/stores/editor.js +1 -2
  18. package/dist/utils/genericUtil.js +7 -8
  19. package/package.json +3 -3
  20. package/dist/components/organisms/extensions/recommendation/FilterItem.vue.js +0 -28
  21. package/dist/components/organisms/extensions/recommendation/FilterItem.vue2.js +0 -38
  22. package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue.js +0 -17
  23. package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue2.js +0 -37
  24. package/dist/components/organisms/extensions/recommendation/Filters.vue.js +0 -20
  25. package/dist/components/organisms/extensions/recommendation/Filters.vue2.js +0 -44
  26. package/dist/components/organisms/extensions/recommendation/LogicAdapter.vue.js +0 -17
  27. package/dist/components/organisms/extensions/recommendation/LogicAdapter.vue2.js +0 -27
  28. package/dist/composables/useApiErrorTracking.js +0 -137
  29. package/dist/composables/useErrorTracking.js +0 -98
  30. package/dist/composables/useStripoErrorCategory.js +0 -138
  31. package/dist/composables/useStripoSlackNotifier.js +0 -47
  32. package/dist/enums/extensions/recommendationBlock.js +0 -80
  33. package/dist/extensions/Blocks/Recommendation/block.js +0 -27
  34. package/dist/extensions/Blocks/Recommendation/control.js +0 -277
  35. package/dist/extensions/Blocks/Recommendation/extension.js +0 -10
  36. package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +0 -51
  37. package/dist/extensions/Blocks/Recommendation/recommendation.css.js +0 -19
  38. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +0 -32
  39. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +0 -266
  40. package/dist/extensions/Blocks/Recommendation/template.js +0 -200
  41. package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +0 -28
  42. package/dist/extensions/Blocks/common-control.js +0 -102
  43. package/dist/services/recommendationApi.js +0 -43
  44. package/dist/services/slackNotificationService.js +0 -167
  45. package/dist/services/stripoErrorDeduplicationService.js +0 -91
  46. package/dist/src/components/organisms/extensions/recommendation/FilterItem.vue.d.ts +0 -19
  47. package/dist/src/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue.d.ts +0 -2
  48. package/dist/src/components/organisms/extensions/recommendation/Filters.vue.d.ts +0 -2
  49. package/dist/src/components/organisms/extensions/recommendation/LogicAdapter.vue.d.ts +0 -16
  50. package/dist/src/composables/useApiErrorTracking.d.ts +0 -28
  51. package/dist/src/composables/useErrorTracking.d.ts +0 -30
  52. package/dist/src/composables/useStripoErrorCategory.d.ts +0 -29
  53. package/dist/src/composables/useStripoSlackNotifier.d.ts +0 -8
  54. package/dist/src/enums/extensions/recommendationBlock.d.ts +0 -16
  55. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +0 -10
  56. package/dist/src/extensions/Blocks/Recommendation/control.d.ts +0 -29
  57. package/dist/src/extensions/Blocks/Recommendation/extension.d.ts +0 -2
  58. package/dist/src/extensions/Blocks/Recommendation/iconsRegistry.d.ts +0 -4
  59. package/dist/src/extensions/Blocks/Recommendation/settingsPanel.d.ts +0 -4
  60. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +0 -555
  61. package/dist/src/extensions/Blocks/Recommendation/template.d.ts +0 -6
  62. package/dist/src/extensions/Blocks/Recommendation/utils/filterUtil.d.ts +0 -7
  63. package/dist/src/extensions/Blocks/common-control.d.ts +0 -66
  64. package/dist/src/mock/api/recommendation.d.ts +0 -2
  65. package/dist/src/services/recommendationApi.d.ts +0 -6
  66. package/dist/src/services/slackNotificationService.d.ts +0 -110
  67. package/dist/src/services/stripoErrorDeduplicationService.d.ts +0 -75
@@ -1,18 +1,18 @@
1
- import o from "./Guido.vue2.js";
1
+ import a from "./Guido.vue2.js";
2
2
  /* empty css */
3
3
  import i from "../_virtual/_plugin-vue2_normalizer.js";
4
- var t = function() {
5
- var a = this, r = a._self._c, e = a._self._setupProxy;
6
- return r("div", { staticClass: "guido-editor__wrapper", class: { "guido-editor__no-header": e.noHeader } }, [r(e.HeaderWrapper, { ref: "headerWrapperRef" }), e.editorStore.isPreviewModeOpen ? r(e.PreviewContainer) : a._e(), r("div", { directives: [{ name: "show", rawName: "v-show", value: !e.previewStore.isLoaded, expression: "!previewStore.isLoaded" }], staticClass: "guido-editor__container", class: { "guido-editor__no-header": e.noHeader }, attrs: { id: "guido-editor" } }), r(e.Toaster), r(e.FilterSelectionDrawer), r(e.SaveAsTemplateDrawer), e.isTestPartner() ? a._e() : r(e.OnboardingWrapper), r(e.UnsubscribeWrapper), r(e.LoadingWrapper)], 1);
7
- }, s = [], d = /* @__PURE__ */ i(
8
- o,
9
- t,
4
+ var s = function() {
5
+ var o = this, r = o._self._c, e = o._self._setupProxy;
6
+ return r("div", { staticClass: "guido-editor__wrapper", class: { "guido-editor__no-header": e.noHeader } }, [r(e.HeaderWrapper, { ref: "headerWrapperRef" }), e.editorStore.isPreviewModeOpen ? r(e.PreviewContainer) : o._e(), r("div", { directives: [{ name: "show", rawName: "v-show", value: !e.previewStore.isLoaded, expression: "!previewStore.isLoaded" }], staticClass: "guido-editor__container", class: { "guido-editor__no-header": e.noHeader }, attrs: { id: "guido-editor" } }), r(e.Toaster), r(e.SaveAsTemplateDrawer), e.isTestPartner() ? o._e() : r(e.OnboardingWrapper), r(e.UnsubscribeWrapper), r(e.LoadingWrapper)], 1);
7
+ }, t = [], d = /* @__PURE__ */ i(
8
+ a,
10
9
  s,
10
+ t,
11
11
  !1,
12
12
  null,
13
- "5a4aa0bc"
13
+ "96687c1d"
14
14
  );
15
- const l = d.exports;
15
+ const v = d.exports;
16
16
  export {
17
- l as default
17
+ v as default
18
18
  };
@@ -1,23 +1,22 @@
1
- import { defineComponent as M, defineAsyncComponent as G, ref as R, computed as U, watch as z, onMounted as B, onUnmounted as K } from "vue";
2
- import { provideGuidoActions as O } from "../composables/useGuidoActions.js";
3
- import { usePartner as j } from "../composables/usePartner.js";
4
- import { useStripo as q } from "../composables/useStripo.js";
1
+ import { defineComponent as x, defineAsyncComponent as U, ref as F, computed as I, watch as M, onMounted as z, onUnmounted as B } from "vue";
2
+ import { provideGuidoActions as K } from "../composables/useGuidoActions.js";
3
+ import { usePartner as O } from "../composables/usePartner.js";
4
+ import { useStripo as j } from "../composables/useStripo.js";
5
5
  import { migrate as W } from "../config/migrator/index.js";
6
- import { DefaultMessageType as J, DefaultUsername as Q, DefaultGuidoConfig as V } from "../enums/defaults.js";
7
- import X from "./organisms/base/Toaster.vue.js";
8
- import Y from "./organisms/extensions/recommendation/FilterSelectionDrawer.vue.js";
9
- import Z from "./organisms/header/HeaderWrapper.vue.js";
10
- import $ from "./organisms/LoadingWrapper.vue.js";
11
- import ee from "./organisms/save-as-template/SaveAsTemplateDrawer.vue.js";
12
- import oe from "./organisms/unsubscribe/UnsubscribeWrapper.vue.js";
13
- import { useStripoApi as te } from "../services/stripoApi.js";
14
- import { useConfigStore as ne } from "../stores/config.js";
15
- import { useDynamicContentStore as re } from "../stores/dynamic-content.js";
16
- import { useEditorStore as ie } from "../stores/editor.js";
17
- import { usePreviewStore as se } from "../stores/preview.js";
18
- import { useUnsubscribeStore as ae } from "../stores/unsubscribe.js";
19
- import ce from "../node_modules/lodash-es/merge.js";
20
- const Pe = /* @__PURE__ */ M({
6
+ import { DefaultUsername as q, DefaultMessageType as J, DefaultGuidoConfig as Q } from "../enums/defaults.js";
7
+ import V from "./organisms/base/Toaster.vue.js";
8
+ import X from "./organisms/header/HeaderWrapper.vue.js";
9
+ import Y from "./organisms/LoadingWrapper.vue.js";
10
+ import Z from "./organisms/save-as-template/SaveAsTemplateDrawer.vue.js";
11
+ import $ from "./organisms/unsubscribe/UnsubscribeWrapper.vue.js";
12
+ import { useStripoApi as ee } from "../services/stripoApi.js";
13
+ import { useConfigStore as oe } from "../stores/config.js";
14
+ import { useDynamicContentStore as te } from "../stores/dynamic-content.js";
15
+ import { useEditorStore as ne } from "../stores/editor.js";
16
+ import { usePreviewStore as re } from "../stores/preview.js";
17
+ import { useUnsubscribeStore as se } from "../stores/unsubscribe.js";
18
+ import ae from "../node_modules/lodash-es/merge.js";
19
+ const Ee = /* @__PURE__ */ x({
21
20
  __name: "Guido",
22
21
  props: {
23
22
  templateId: null,
@@ -29,51 +28,49 @@ const Pe = /* @__PURE__ */ M({
29
28
  html: null,
30
29
  css: null,
31
30
  guidoConfig: null,
32
- templateConfig: null,
33
- traceId: null
31
+ templateConfig: null
34
32
  },
35
33
  emits: ["dynamic-content:open", "back", "save:start", "save:complete", "on-change", "ready"],
36
- setup(F, { expose: L, emit: t }) {
37
- const p = F, k = G(
34
+ setup(_, { expose: L, emit: t }) {
35
+ const d = _, k = U(
38
36
  () => import("./organisms/email-preview/PreviewContainer.vue.js")
39
- ), x = G(
37
+ ), A = U(
40
38
  () => import("./organisms/onboarding/OnboardingWrapper.vue.js")
41
- ), g = R(), c = re(), f = ae(), y = ne(), d = ie(), A = se(), i = U(() => d.hasChanges), { getPartnerName: w, getProductType: v, isTestPartner: N } = j(), S = () => {
39
+ ), m = F(), s = te(), u = se(), l = oe(), p = ne(), N = re(), n = I(() => p.hasChanges), { getPartnerName: g, getProductType: f, isTestPartner: H } = O(), y = () => {
42
40
  var e;
43
- return (e = g.value) == null ? void 0 : e.handleSave(!0);
41
+ return (e = m.value) == null ? void 0 : e.handleSave(!0);
44
42
  }, {
45
- templateId: n,
46
- userId: s,
43
+ templateId: v,
44
+ userId: b,
47
45
  guidoConfig: C,
48
46
  templateConfig: o,
49
- html: a = "",
50
- css: b = "",
51
- partnerName: m = w(),
52
- productType: u = v(),
53
- messageType: h = J,
54
- username: D = Q,
55
- traceId: r
56
- } = p, l = (o == null ? void 0 : o.preselectedDynamicContentList) || [];
57
- d.templateId = n, window.GuidoConfig = ce(V, C), window.GuidoConfig.partner = {
58
- partnerName: m,
59
- productType: u,
60
- messageType: h
61
- }, r && (window.GuidoConfig.traceId = r), y.templateConfig = o;
62
- const { initPlugin: I } = q({
63
- emailId: n,
64
- userId: s,
65
- username: D,
66
- partnerName: m,
67
- productType: u,
68
- preselectedDynamicContentList: l,
47
+ html: r = "",
48
+ css: h = "",
49
+ partnerName: a = g(),
50
+ productType: i = f(),
51
+ messageType: S = J,
52
+ username: w = q
53
+ } = d, c = (o == null ? void 0 : o.preselectedDynamicContentList) || [];
54
+ window.GuidoConfig = ae(Q, C), window.GuidoConfig.partner = {
55
+ partnerName: a,
56
+ productType: i,
57
+ messageType: S
58
+ }, l.templateConfig = o;
59
+ const { initPlugin: D } = j({
60
+ emailId: v,
61
+ userId: b,
62
+ username: w,
63
+ partnerName: a,
64
+ productType: i,
65
+ preselectedDynamicContentList: c,
69
66
  onReady: () => {
70
67
  console.debug("guido:ready"), t("ready");
71
68
  }
72
- }), { getDefaultTemplate: _ } = te(), H = U(() => {
69
+ }), { getDefaultTemplate: T } = ee(), R = I(() => {
73
70
  var e;
74
71
  return !((e = window.GuidoConfig) != null && e.useHeader);
75
72
  });
76
- O({
73
+ K({
77
74
  onBack: () => {
78
75
  console.debug("guido:back"), t("back");
79
76
  },
@@ -85,52 +82,31 @@ const Pe = /* @__PURE__ */ M({
85
82
  }
86
83
  });
87
84
  const E = (e) => {
88
- console.debug("dynamic-content:close", e), c.setSelectedDynamicContent(e), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: e }));
89
- }, T = () => {
85
+ console.debug("dynamic-content:close", e), s.setSelectedDynamicContent(e), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: e }));
86
+ }, P = () => {
90
87
  console.debug("dynamic-content:close", "Without Data"), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: { text: "", value: "" } }));
91
88
  };
92
- return z(() => i.value, () => {
93
- t("on-change", i.value);
94
- }), B(async () => {
89
+ return M(() => n.value, () => {
90
+ t("on-change", n.value);
91
+ }), z(async () => {
95
92
  console.debug("Guido says happy coding 🎉"), console.debug("🚗 Ka-Chow");
96
93
  try {
97
- f.selectedUnsubscribePages = (o == null ? void 0 : o.selectedUnsubscribePages) || [];
94
+ u.selectedUnsubscribePages = (o == null ? void 0 : o.selectedUnsubscribePages) || [];
98
95
  let e = {
99
- html: a && await W(a),
100
- css: b,
96
+ html: r && await W(r),
97
+ css: h,
101
98
  forceRecreate: !0
102
99
  // TODO: It should be false for old templates. We will communicate with Stripo
103
100
  };
104
- e.html || (e = await _(), e.html = await W(e.html)), await I(e), c.selectedDynamicContentList = l;
101
+ e.html || (e = await T(), e.html = await W(e.html)), await D(e), s.selectedDynamicContentList = c;
105
102
  } catch (e) {
106
- console.error("Failed to initialize Stripo editor:", e), window.Sentry && window.Sentry.captureException(e, {
107
- tags: {
108
- component: "guido-component",
109
- operation: "mount"
110
- },
111
- contexts: {
112
- guido: {
113
- templateId: n,
114
- userId: s,
115
- traceId: r
116
- }
117
- }
118
- }), window.FS && window.FS("event", "guido_mount_error", {
119
- // eslint-disable-next-line camelcase
120
- errorMessage_str: e instanceof Error ? e.message : String(e),
121
- // eslint-disable-next-line camelcase
122
- templateId_str: n,
123
- // eslint-disable-next-line camelcase
124
- userId_str: s,
125
- // eslint-disable-next-line camelcase
126
- traceId_str: r || ""
127
- });
103
+ console.error("Failed to initialize Stripo editor:", e);
128
104
  }
129
105
  document.addEventListener("dynamic-content:open", (e) => {
130
- const P = e;
131
- console.debug("dynamic-content:open", P.detail), t("dynamic-content:open", P.detail);
106
+ const G = e;
107
+ console.debug("dynamic-content:open", G.detail), t("dynamic-content:open", G.detail);
132
108
  });
133
- }), K(() => {
109
+ }), B(() => {
134
110
  try {
135
111
  window.UIEditor.removeEditor();
136
112
  } catch {
@@ -139,13 +115,13 @@ const Pe = /* @__PURE__ */ M({
139
115
  }), L({
140
116
  dynamicContent: {
141
117
  insert: E,
142
- close: T
118
+ close: P
143
119
  },
144
- hasChanges: i,
145
- saveSilent: S
146
- }), { __sfc: !0, PreviewContainer: k, OnboardingWrapper: x, headerWrapperRef: g, dynamicContentStore: c, unsubscribeStore: f, props: p, configStore: y, editorStore: d, previewStore: A, hasChanges: i, getPartnerName: w, getProductType: v, isTestPartner: N, saveSilent: S, templateId: n, userId: s, guidoConfig: C, templateConfig: o, html: a, css: b, partnerName: m, productType: u, messageType: h, username: D, traceId: r, preselectedDynamicContentList: l, emit: t, initPlugin: I, getDefaultTemplate: _, noHeader: H, insertDynamicContent: E, closeDynamicContent: T, Toaster: X, FilterSelectionDrawer: Y, HeaderWrapper: Z, LoadingWrapper: $, SaveAsTemplateDrawer: ee, UnsubscribeWrapper: oe };
120
+ hasChanges: n,
121
+ saveSilent: y
122
+ }), { __sfc: !0, PreviewContainer: k, OnboardingWrapper: A, headerWrapperRef: m, dynamicContentStore: s, unsubscribeStore: u, props: d, configStore: l, editorStore: p, previewStore: N, hasChanges: n, getPartnerName: g, getProductType: f, isTestPartner: H, saveSilent: y, templateId: v, userId: b, guidoConfig: C, templateConfig: o, html: r, css: h, partnerName: a, productType: i, messageType: S, username: w, preselectedDynamicContentList: c, emit: t, initPlugin: D, getDefaultTemplate: T, noHeader: R, insertDynamicContent: E, closeDynamicContent: P, Toaster: V, HeaderWrapper: X, LoadingWrapper: Y, SaveAsTemplateDrawer: Z, UnsubscribeWrapper: $ };
147
123
  }
148
124
  });
149
125
  export {
150
- Pe as default
126
+ Ee as default
151
127
  };
@@ -1,153 +1,86 @@
1
- import { getCsrfToken as P } from "../utils/genericUtil.js";
2
- import { ref as v, computed as b } from "vue";
3
- let x;
4
- const m = async () => {
5
- if (!x)
6
- try {
7
- const { useApiErrorTracking: k } = await import("./useApiErrorTracking.js");
8
- x = k();
9
- } catch {
10
- }
11
- return x;
12
- }, M = (k = {}) => {
13
- const g = v(!1), c = v(null), T = v(null);
14
- let w = !1;
15
- const A = b(() => g.value), $ = b(() => c.value !== null), R = {
1
+ import { getCsrfToken as H } from "../utils/genericUtil.js";
2
+ import { ref as p, computed as T } from "vue";
3
+ const k = (b = {}) => {
4
+ const h = p(!1), a = p(null), u = p(null), g = T(() => h.value), y = T(() => a.value !== null), v = {
16
5
  baseURL: "",
17
6
  timeout: 1e4,
18
7
  retry: 0,
19
8
  retryDelay: 1e3,
20
9
  headers: {
21
10
  "Content-Type": "application/json",
22
- "X-CSRF-TOKEN": P()
11
+ "X-CSRF-TOKEN": H()
23
12
  },
24
- ...k
25
- }, U = (t, s) => {
26
- if (t.startsWith("http://") || t.startsWith("https://"))
27
- return t;
28
- const r = s || R.baseURL || "";
29
- return r.endsWith("/") && t.startsWith("/") ? `${r}${t.slice(1)}` : r.endsWith("/") || t.startsWith("/") ? `${r}${t}` : `${r}/${t}`;
30
- }, N = (t) => new Promise((s, r) => {
13
+ ...b
14
+ }, w = (e, s) => {
15
+ if (e.startsWith("http://") || e.startsWith("https://"))
16
+ return e;
17
+ const t = s || v.baseURL || "";
18
+ return t.endsWith("/") && e.startsWith("/") ? `${t}${e.slice(1)}` : t.endsWith("/") || e.startsWith("/") ? `${t}${e}` : `${t}/${e}`;
19
+ }, P = (e) => new Promise((s, t) => {
31
20
  setTimeout(() => {
32
- r(new Error("Request timeout"));
33
- }, t);
34
- }), H = (t) => new Promise((s) => {
35
- setTimeout(() => {
36
- s();
37
- }, t);
38
- }), u = async (t, s, r, _ = {}) => {
39
- c.value = null, g.value = !0, T.value = new AbortController();
40
- const a = { ...R, ..._ }, h = U(s, a.baseURL), p = {
41
- method: t,
42
- headers: { ...a.headers },
43
- signal: T.value.signal,
44
- ...a
21
+ t(new Error("Request timeout"));
22
+ }, e);
23
+ }), x = (e) => new Promise((s) => {
24
+ setTimeout(s, e);
25
+ }), i = async (e, s, t, D = {}) => {
26
+ a.value = null, h.value = !0, u.value = new AbortController();
27
+ const n = { ...v, ...D }, L = w(s, n.baseURL), c = {
28
+ method: e,
29
+ headers: { ...n.headers },
30
+ signal: u.value.signal,
31
+ ...n
45
32
  };
46
- r && ["POST", "PUT", "PATCH"].includes(t) && (r instanceof FormData ? (delete p.headers["Content-Type"], p.body = r) : p.body = JSON.stringify(r));
47
- const y = async (l = 0) => {
33
+ t && ["POST", "PUT", "PATCH"].includes(e) && (t instanceof FormData ? (delete c.headers["Content-Type"], c.body = t) : c.body = JSON.stringify(t));
34
+ const E = async (m = 0) => {
48
35
  try {
49
- const o = [fetch(h, p)];
50
- a.timeout && o.push(N(a.timeout));
51
- const e = await Promise.race(o);
52
- if (!e.ok) {
53
- if (e.status === 401 && a.onTokenRefresh && !a.skipTokenRefreshRetry && !w) {
54
- w = !0;
55
- try {
56
- const i = await a.onTokenRefresh();
57
- if (i) {
58
- const E = p.headers;
59
- return E.Authorization = `Bearer ${i}`, E["X-CSRF-TOKEN"] = P(), w = !1, await y(l);
60
- }
61
- } catch (i) {
62
- w = !1;
63
- const E = await m();
64
- E && i instanceof Error && E.captureHttpError(
65
- i,
66
- h,
67
- {
68
- method: t,
69
- statusCode: 401,
70
- statusText: "Unauthorized - Token Refresh Failed",
71
- context: "stale_token_refresh"
72
- }
73
- );
74
- }
75
- }
76
- const j = `HTTP Error: ${e.status} ${e.statusText}`, d = new Error(j);
77
- d.status = e.status, d.statusText = e.statusText, d.response = e;
78
- const C = await m();
79
- if (C) {
80
- const i = e.status === 404 ? "asset_missing" : void 0;
81
- C.captureHttpError(d, h, {
82
- method: t,
83
- statusCode: e.status,
84
- statusText: e.statusText,
85
- ...i && { context: i }
86
- });
87
- }
88
- throw d;
36
+ const o = [fetch(L, c)];
37
+ n.timeout && o.push(P(n.timeout));
38
+ const r = await Promise.race(o);
39
+ if (!r.ok) {
40
+ const O = `HTTP Error: ${r.status} ${r.statusText}`, d = new Error(O);
41
+ throw d.status = r.status, d.statusText = r.statusText, d.response = r, d;
89
42
  }
90
- let n;
91
- const f = e.headers.get("content-type");
92
- return f != null && f.includes("application/json") ? n = await e.json() : f != null && f.includes("text/") ? n = await e.text() : n = await e.blob(), {
93
- data: n,
94
- status: e.status,
95
- statusText: e.statusText,
96
- headers: e.headers
43
+ let f;
44
+ const l = r.headers.get("content-type");
45
+ return l != null && l.includes("application/json") ? f = await r.json() : l != null && l.includes("text/") ? f = await r.text() : f = await r.blob(), {
46
+ data: f,
47
+ status: r.status,
48
+ statusText: r.statusText,
49
+ headers: r.headers
97
50
  };
98
51
  } catch (o) {
99
- const e = o instanceof Error && o.name === "AbortError";
100
- if (l < (a.retry || 0) && !e)
101
- return await H(a.retryDelay || 1e3), y(l + 1);
102
- if (o instanceof Error)
103
- if (o.name === "AbortError")
104
- c.value = { message: "Request was cancelled" };
105
- else {
106
- c.value = { message: o.message };
107
- const n = await m();
108
- n && n.captureNetworkError(o, h, {
109
- method: t,
110
- attemptNumber: l + 1,
111
- timeoutMs: a.timeout
112
- });
113
- }
114
- else {
115
- c.value = o;
116
- const n = await m();
117
- n && o instanceof Error && n.captureNetworkError(o, h, {
118
- method: t,
119
- attemptNumber: l + 1
120
- });
121
- }
122
- throw o;
52
+ const r = o instanceof Error && o.name === "AbortError";
53
+ if (m < (n.retry || 0) && !r)
54
+ return await x(n.retryDelay || 1e3), E(m + 1);
55
+ throw o instanceof Error ? o.name === "AbortError" ? a.value = { message: "Request was cancelled" } : a.value = { message: o.message } : a.value = o, o;
123
56
  }
124
57
  };
125
58
  try {
126
- return await y();
59
+ return await E();
127
60
  } finally {
128
- g.value = !1, T.value = null;
61
+ h.value = !1, u.value = null;
129
62
  }
130
- }, O = (t, s) => u("GET", t, void 0, s), W = (t, s, r) => u("POST", t, s, r), q = (t, s, r) => u("PUT", t, s, r), D = (t, s, r) => u("PATCH", t, s, r), L = (t, s) => u("DELETE", t, void 0, s), S = (t) => {
131
- T.value && T.value.abort(t);
132
- }, F = () => {
133
- c.value = null;
63
+ }, C = (e, s) => i("GET", e, void 0, s), $ = (e, s, t) => i("POST", e, s, t), R = (e, s, t) => i("PUT", e, s, t), U = (e, s, t) => i("PATCH", e, s, t), A = (e, s) => i("DELETE", e, void 0, s), W = (e) => {
64
+ u.value && u.value.abort(e);
65
+ }, q = () => {
66
+ a.value = null;
134
67
  };
135
68
  return {
136
69
  // State
137
- loading: A,
138
- error: b(() => c.value),
139
- hasError: $,
70
+ loading: g,
71
+ error: T(() => a.value),
72
+ hasError: y,
140
73
  // Methods
141
- request: u,
142
- get: O,
143
- post: W,
144
- put: q,
145
- patch: D,
146
- delete: L,
147
- cancel: S,
148
- clearError: F
74
+ request: i,
75
+ get: C,
76
+ post: $,
77
+ put: R,
78
+ patch: U,
79
+ delete: A,
80
+ cancel: W,
81
+ clearError: q
149
82
  };
150
83
  };
151
84
  export {
152
- M as useHttp
85
+ k as useHttp
153
86
  };