@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.
- package/dist/components/Guido.vue.js +10 -10
- package/dist/components/Guido.vue2.js +65 -89
- package/dist/composables/useHttp.js +60 -127
- package/dist/composables/useStripo.js +64 -198
- package/dist/extensions/Blocks/RadioButton/template.js +6 -6
- package/dist/guido.css +1 -1
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +72 -83
- package/dist/package.json.js +1 -1
- package/dist/services/stripoApi.js +19 -51
- package/dist/src/@types/generic.d.ts +0 -4
- package/dist/src/components/Guido.vue.d.ts +0 -1
- package/dist/src/composables/useHttp.d.ts +0 -2
- package/dist/src/composables/useStripo.d.ts +0 -1
- package/dist/src/services/stripoApi.d.ts +1 -1
- package/dist/src/stores/editor.d.ts +0 -21
- package/dist/src/utils/genericUtil.d.ts +0 -1
- package/dist/stores/editor.js +1 -2
- package/dist/utils/genericUtil.js +7 -8
- package/package.json +3 -3
- package/dist/components/organisms/extensions/recommendation/FilterItem.vue.js +0 -28
- package/dist/components/organisms/extensions/recommendation/FilterItem.vue2.js +0 -38
- package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue.js +0 -17
- package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue2.js +0 -37
- package/dist/components/organisms/extensions/recommendation/Filters.vue.js +0 -20
- package/dist/components/organisms/extensions/recommendation/Filters.vue2.js +0 -44
- package/dist/components/organisms/extensions/recommendation/LogicAdapter.vue.js +0 -17
- package/dist/components/organisms/extensions/recommendation/LogicAdapter.vue2.js +0 -27
- package/dist/composables/useApiErrorTracking.js +0 -137
- package/dist/composables/useErrorTracking.js +0 -98
- package/dist/composables/useStripoErrorCategory.js +0 -138
- package/dist/composables/useStripoSlackNotifier.js +0 -47
- package/dist/enums/extensions/recommendationBlock.js +0 -80
- package/dist/extensions/Blocks/Recommendation/block.js +0 -27
- package/dist/extensions/Blocks/Recommendation/control.js +0 -277
- package/dist/extensions/Blocks/Recommendation/extension.js +0 -10
- package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +0 -51
- package/dist/extensions/Blocks/Recommendation/recommendation.css.js +0 -19
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +0 -32
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +0 -266
- package/dist/extensions/Blocks/Recommendation/template.js +0 -200
- package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +0 -28
- package/dist/extensions/Blocks/common-control.js +0 -102
- package/dist/services/recommendationApi.js +0 -43
- package/dist/services/slackNotificationService.js +0 -167
- package/dist/services/stripoErrorDeduplicationService.js +0 -91
- package/dist/src/components/organisms/extensions/recommendation/FilterItem.vue.d.ts +0 -19
- package/dist/src/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue.d.ts +0 -2
- package/dist/src/components/organisms/extensions/recommendation/Filters.vue.d.ts +0 -2
- package/dist/src/components/organisms/extensions/recommendation/LogicAdapter.vue.d.ts +0 -16
- package/dist/src/composables/useApiErrorTracking.d.ts +0 -28
- package/dist/src/composables/useErrorTracking.d.ts +0 -30
- package/dist/src/composables/useStripoErrorCategory.d.ts +0 -29
- package/dist/src/composables/useStripoSlackNotifier.d.ts +0 -8
- package/dist/src/enums/extensions/recommendationBlock.d.ts +0 -16
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +0 -10
- package/dist/src/extensions/Blocks/Recommendation/control.d.ts +0 -29
- package/dist/src/extensions/Blocks/Recommendation/extension.d.ts +0 -2
- package/dist/src/extensions/Blocks/Recommendation/iconsRegistry.d.ts +0 -4
- package/dist/src/extensions/Blocks/Recommendation/settingsPanel.d.ts +0 -4
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +0 -555
- package/dist/src/extensions/Blocks/Recommendation/template.d.ts +0 -6
- package/dist/src/extensions/Blocks/Recommendation/utils/filterUtil.d.ts +0 -7
- package/dist/src/extensions/Blocks/common-control.d.ts +0 -66
- package/dist/src/mock/api/recommendation.d.ts +0 -2
- package/dist/src/services/recommendationApi.d.ts +0 -6
- package/dist/src/services/slackNotificationService.d.ts +0 -110
- package/dist/src/services/stripoErrorDeduplicationService.d.ts +0 -75
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import a from "./Guido.vue2.js";
|
|
2
2
|
/* empty css */
|
|
3
3
|
import i from "../_virtual/_plugin-vue2_normalizer.js";
|
|
4
|
-
var
|
|
5
|
-
var
|
|
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) :
|
|
7
|
-
},
|
|
8
|
-
|
|
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
|
-
"
|
|
13
|
+
"96687c1d"
|
|
14
14
|
);
|
|
15
|
-
const
|
|
15
|
+
const v = d.exports;
|
|
16
16
|
export {
|
|
17
|
-
|
|
17
|
+
v as default
|
|
18
18
|
};
|
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { provideGuidoActions as
|
|
3
|
-
import { usePartner as
|
|
4
|
-
import { useStripo as
|
|
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 {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import
|
|
19
|
-
|
|
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(
|
|
37
|
-
const
|
|
34
|
+
setup(_, { expose: L, emit: t }) {
|
|
35
|
+
const d = _, k = U(
|
|
38
36
|
() => import("./organisms/email-preview/PreviewContainer.vue.js")
|
|
39
|
-
),
|
|
37
|
+
), A = U(
|
|
40
38
|
() => import("./organisms/onboarding/OnboardingWrapper.vue.js")
|
|
41
|
-
),
|
|
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 =
|
|
41
|
+
return (e = m.value) == null ? void 0 : e.handleSave(!0);
|
|
44
42
|
}, {
|
|
45
|
-
templateId:
|
|
46
|
-
userId:
|
|
43
|
+
templateId: v,
|
|
44
|
+
userId: b,
|
|
47
45
|
guidoConfig: C,
|
|
48
46
|
templateConfig: o,
|
|
49
|
-
html:
|
|
50
|
-
css:
|
|
51
|
-
partnerName:
|
|
52
|
-
productType:
|
|
53
|
-
messageType:
|
|
54
|
-
username:
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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:
|
|
69
|
+
}), { getDefaultTemplate: T } = ee(), R = I(() => {
|
|
73
70
|
var e;
|
|
74
71
|
return !((e = window.GuidoConfig) != null && e.useHeader);
|
|
75
72
|
});
|
|
76
|
-
|
|
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),
|
|
89
|
-
},
|
|
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
|
|
93
|
-
t("on-change",
|
|
94
|
-
}),
|
|
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
|
-
|
|
94
|
+
u.selectedUnsubscribePages = (o == null ? void 0 : o.selectedUnsubscribePages) || [];
|
|
98
95
|
let e = {
|
|
99
|
-
html:
|
|
100
|
-
css:
|
|
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
|
|
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)
|
|
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
|
|
131
|
-
console.debug("dynamic-content:open",
|
|
106
|
+
const G = e;
|
|
107
|
+
console.debug("dynamic-content:open", G.detail), t("dynamic-content:open", G.detail);
|
|
132
108
|
});
|
|
133
|
-
}),
|
|
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:
|
|
118
|
+
close: P
|
|
143
119
|
},
|
|
144
|
-
hasChanges:
|
|
145
|
-
saveSilent:
|
|
146
|
-
}), { __sfc: !0, PreviewContainer: k, OnboardingWrapper:
|
|
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
|
-
|
|
126
|
+
Ee as default
|
|
151
127
|
};
|
|
@@ -1,153 +1,86 @@
|
|
|
1
|
-
import { getCsrfToken as
|
|
2
|
-
import { ref as
|
|
3
|
-
|
|
4
|
-
const
|
|
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":
|
|
11
|
+
"X-CSRF-TOKEN": H()
|
|
23
12
|
},
|
|
24
|
-
...
|
|
25
|
-
},
|
|
26
|
-
if (
|
|
27
|
-
return
|
|
28
|
-
const
|
|
29
|
-
return
|
|
30
|
-
},
|
|
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
|
-
|
|
33
|
-
},
|
|
34
|
-
}),
|
|
35
|
-
setTimeout(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
47
|
-
const
|
|
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(
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
if (!
|
|
53
|
-
|
|
54
|
-
|
|
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
|
|
91
|
-
const
|
|
92
|
-
return
|
|
93
|
-
data:
|
|
94
|
-
status:
|
|
95
|
-
statusText:
|
|
96
|
-
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
|
|
100
|
-
if (
|
|
101
|
-
return await
|
|
102
|
-
|
|
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
|
|
59
|
+
return await E();
|
|
127
60
|
} finally {
|
|
128
|
-
|
|
61
|
+
h.value = !1, u.value = null;
|
|
129
62
|
}
|
|
130
|
-
},
|
|
131
|
-
|
|
132
|
-
},
|
|
133
|
-
|
|
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:
|
|
138
|
-
error:
|
|
139
|
-
hasError:
|
|
70
|
+
loading: g,
|
|
71
|
+
error: T(() => a.value),
|
|
72
|
+
hasError: y,
|
|
140
73
|
// Methods
|
|
141
|
-
request:
|
|
142
|
-
get:
|
|
143
|
-
post:
|
|
144
|
-
put:
|
|
145
|
-
patch:
|
|
146
|
-
delete:
|
|
147
|
-
cancel:
|
|
148
|
-
clearError:
|
|
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
|
-
|
|
85
|
+
k as useHttp
|
|
153
86
|
};
|