@useinsider/guido 3.9.0-beta.7583926 → 3.9.0-beta.8ad06e1
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/config/compiler/utils/recommendationCompilerUtils.js +118 -110
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +15 -15
- package/dist/services/blankTemplate.js +32 -0
- package/dist/services/stripoApi.js +45 -69
- package/dist/src/services/blankTemplate.d.ts +11 -0
- package/package.json +1 -1
|
@@ -1,181 +1,189 @@
|
|
|
1
|
-
import { useConfig as
|
|
2
|
-
import { useRecommendation as
|
|
3
|
-
import { CSS_CLASS_RECO_BUTTON as
|
|
4
|
-
import { useRecommendationExtensionStore as
|
|
5
|
-
import { isIgnoredRecommendationBlock as
|
|
6
|
-
function
|
|
7
|
-
const i = `{{${
|
|
8
|
-
return
|
|
1
|
+
import { useConfig as q } from "../../../composables/useConfig.js";
|
|
2
|
+
import { useRecommendation as C } from "../../../composables/useRecommendation.js";
|
|
3
|
+
import { CSS_CLASS_RECO_BUTTON as E } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
4
|
+
import { useRecommendationExtensionStore as w } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
5
|
+
import { isIgnoredRecommendationBlock as P } from "./recommendationIgnoreUtils.js";
|
|
6
|
+
function f(t, o, e, n, s = "") {
|
|
7
|
+
const i = `{{${s}${t}_${o}_${e}}}`, r = `{{${s}${t}_${o}_currency}}`;
|
|
8
|
+
return n === "before" ? `${r} ${i}` : `${i} ${r}`;
|
|
9
9
|
}
|
|
10
|
-
function m(
|
|
11
|
-
let
|
|
12
|
-
for (;
|
|
13
|
-
[
|
|
14
|
-
return
|
|
10
|
+
function m(t) {
|
|
11
|
+
let o = t;
|
|
12
|
+
for (; o.children.length === 1; )
|
|
13
|
+
[o] = o.children;
|
|
14
|
+
return o;
|
|
15
15
|
}
|
|
16
|
-
function h(
|
|
17
|
-
switch (
|
|
16
|
+
function h(t, o, e, n, s, i) {
|
|
17
|
+
switch (o) {
|
|
18
18
|
case "productImage": {
|
|
19
|
-
const r =
|
|
20
|
-
r && (r.setAttribute("src", `{{${i}${
|
|
21
|
-
const
|
|
22
|
-
|
|
19
|
+
const r = t.querySelector("img");
|
|
20
|
+
r && (r.setAttribute("src", `{{${i}${e}_${n}_image_url}}`), r.setAttribute("alt", `{{${i}${e}_${n}_name}}`));
|
|
21
|
+
const c = t.querySelector("a");
|
|
22
|
+
c && (c.setAttribute("href", `{{${i}${e}_${n}_url}}`), c.classList.add(E));
|
|
23
23
|
break;
|
|
24
24
|
}
|
|
25
25
|
case "productName": {
|
|
26
|
-
const r =
|
|
27
|
-
r && (m(r).textContent = `{{${i}${
|
|
26
|
+
const r = t.querySelector("p");
|
|
27
|
+
r && (m(r).textContent = `{{${i}${e}_${n}_name}}`);
|
|
28
28
|
break;
|
|
29
29
|
}
|
|
30
30
|
case "productPrice": {
|
|
31
|
-
const r =
|
|
32
|
-
r && (m(r).textContent =
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
const r = t.querySelector(".product-price p") ?? t.querySelector("p");
|
|
32
|
+
r && (m(r).textContent = f(
|
|
33
|
+
e,
|
|
34
|
+
n,
|
|
35
35
|
"price",
|
|
36
|
-
|
|
36
|
+
s,
|
|
37
37
|
i
|
|
38
38
|
));
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
const c = t.querySelector(".product-old-price p");
|
|
40
|
+
c && (m(c).textContent = f(
|
|
41
|
+
e,
|
|
42
|
+
n,
|
|
43
43
|
"original_price",
|
|
44
|
-
|
|
44
|
+
s,
|
|
45
45
|
i
|
|
46
46
|
));
|
|
47
47
|
break;
|
|
48
48
|
}
|
|
49
49
|
case "productOldPrice": {
|
|
50
|
-
const r =
|
|
51
|
-
r && (m(r).textContent =
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
const r = t.querySelector("p");
|
|
51
|
+
r && (m(r).textContent = f(
|
|
52
|
+
e,
|
|
53
|
+
n,
|
|
54
54
|
"original_price",
|
|
55
|
-
|
|
55
|
+
s,
|
|
56
56
|
i
|
|
57
57
|
));
|
|
58
58
|
break;
|
|
59
59
|
}
|
|
60
60
|
case "productButton": {
|
|
61
|
-
const r =
|
|
62
|
-
r && r.setAttribute("href", `{{${i}${
|
|
61
|
+
const r = t.querySelector("a");
|
|
62
|
+
r && r.setAttribute("href", `{{${i}${e}_${n}_url}}`);
|
|
63
63
|
break;
|
|
64
64
|
}
|
|
65
65
|
case "productOmnibusPrice": {
|
|
66
|
-
const r =
|
|
66
|
+
const r = t.querySelector(".omnibus-price-value");
|
|
67
67
|
if (r) {
|
|
68
|
-
r.textContent = `{{${i}${
|
|
69
|
-
const
|
|
70
|
-
|
|
68
|
+
r.textContent = `{{${i}${e}_${n}_omnibus_price}}`;
|
|
69
|
+
const c = r.closest("p");
|
|
70
|
+
c && (c.setAttribute("product-attr", "omnibus_price"), c.setAttribute("composition", "true"));
|
|
71
71
|
}
|
|
72
72
|
break;
|
|
73
73
|
}
|
|
74
74
|
case "productOmnibusDiscount": {
|
|
75
|
-
const r =
|
|
75
|
+
const r = t.querySelector(".omnibus-discount-value");
|
|
76
76
|
if (r) {
|
|
77
|
-
r.textContent = `{{${i}${
|
|
78
|
-
const
|
|
79
|
-
|
|
77
|
+
r.textContent = `{{${i}${e}_${n}_omnibus_discount}}`;
|
|
78
|
+
const c = r.closest("p");
|
|
79
|
+
c && (c.setAttribute("product-attr", "omnibus_discount"), c.setAttribute("composition", "true"));
|
|
80
80
|
}
|
|
81
81
|
break;
|
|
82
82
|
}
|
|
83
83
|
default: {
|
|
84
|
-
const r =
|
|
84
|
+
const r = t.getAttribute("product-attr") ? t : t.querySelector("[product-attr]");
|
|
85
85
|
if (r) {
|
|
86
|
-
const
|
|
87
|
-
|
|
86
|
+
const c = r.getAttribute("product-attr"), l = r.querySelector("p");
|
|
87
|
+
l && (m(l).textContent = `{{${i}${e}_${n}_${c}}}`);
|
|
88
88
|
}
|
|
89
89
|
break;
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
function
|
|
94
|
-
|
|
95
|
-
i.querySelectorAll("[data-attribute-type]").forEach((
|
|
96
|
-
const u =
|
|
97
|
-
p.length > 0 ? p.forEach((
|
|
98
|
-
h(
|
|
99
|
-
}) : h(
|
|
93
|
+
function R(t, o, e, n) {
|
|
94
|
+
t.querySelectorAll(".recommendation-product-row").forEach((i, r) => {
|
|
95
|
+
i.querySelectorAll("[data-attribute-type]").forEach((l) => {
|
|
96
|
+
const u = l.getAttribute("data-attribute-type") || "", p = l.querySelectorAll(".attribute-cell");
|
|
97
|
+
p.length > 0 ? p.forEach((a) => {
|
|
98
|
+
h(a, u, o, r, e, n);
|
|
99
|
+
}) : h(l, u, o, r, e, n);
|
|
100
100
|
});
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
|
-
function
|
|
104
|
-
const
|
|
105
|
-
if (!
|
|
103
|
+
function W(t, o, e, n) {
|
|
104
|
+
const s = t.querySelectorAll(".recommendation-product-row");
|
|
105
|
+
if (!s.length)
|
|
106
106
|
return;
|
|
107
|
-
const [i] =
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
const d =
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
h(
|
|
107
|
+
const [i] = s, r = i.querySelector("[data-attribute-type]"), c = r ? r.querySelectorAll(".attribute-cell").length : 1;
|
|
108
|
+
s.forEach((l, u) => {
|
|
109
|
+
l.querySelectorAll("[data-attribute-type]").forEach((a) => {
|
|
110
|
+
const d = a.getAttribute("data-attribute-type") || "";
|
|
111
|
+
a.querySelectorAll(".attribute-cell").forEach((S, _) => {
|
|
112
|
+
const g = u * c + _;
|
|
113
|
+
h(S, d, o, g, e, n);
|
|
114
114
|
});
|
|
115
115
|
});
|
|
116
116
|
});
|
|
117
117
|
}
|
|
118
|
-
function
|
|
119
|
-
|
|
120
|
-
|
|
118
|
+
function v(t, o, e, n) {
|
|
119
|
+
t.querySelectorAll(".ins-recommendation-product-container").forEach((i) => {
|
|
120
|
+
W(i, o, e, n);
|
|
121
121
|
});
|
|
122
122
|
}
|
|
123
|
-
function O(
|
|
124
|
-
const
|
|
125
|
-
|
|
123
|
+
function O(t, o, e) {
|
|
124
|
+
const n = t.getAttribute("data-layout") || "grid", s = t.getAttribute("currency-alignment") || "after";
|
|
125
|
+
n === "list" ? R(t, o, s, e) : v(t, o, s, e);
|
|
126
126
|
}
|
|
127
|
-
function
|
|
128
|
-
const
|
|
129
|
-
return
|
|
127
|
+
function b(t, o, e) {
|
|
128
|
+
const n = new RegExp(`${o}\\s*:\\s*(\\d+)\\s*px`, "i"), s = t.match(n);
|
|
129
|
+
return s ? parseInt(s[1]) : e;
|
|
130
130
|
}
|
|
131
|
-
function
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
131
|
+
function A(t) {
|
|
132
|
+
const o = t.trim();
|
|
133
|
+
return o.endsWith("%") ? parseFloat(o) < 100 : /^\d+(?:\.\d+)?(?:px)?$/.test(o) && parseInt(o) > 0;
|
|
134
|
+
}
|
|
135
|
+
function $(t) {
|
|
136
|
+
const o = t.getAttribute("width");
|
|
137
|
+
if (o && A(o))
|
|
138
|
+
return o.trim();
|
|
139
|
+
const e = (t.getAttribute("style") || "").match(/(?:^|[;\s])width\s*:\s*(\d+(?:\.\d+)?(?:px|%))/i);
|
|
140
|
+
return e && A(e[1]) ? e[1] : null;
|
|
141
|
+
}
|
|
142
|
+
function T(t, o) {
|
|
143
|
+
let e = t.parentElement;
|
|
144
|
+
for (; e && e !== o; ) {
|
|
145
|
+
if (e.tagName === "TD" && $(e))
|
|
146
|
+
return e;
|
|
147
|
+
e = e.parentElement;
|
|
140
148
|
}
|
|
141
149
|
return null;
|
|
142
150
|
}
|
|
143
|
-
function
|
|
144
|
-
const
|
|
145
|
-
|
|
151
|
+
function M(t) {
|
|
152
|
+
const o = t.getAttribute("style") || "", e = b(o, "width", 600), n = b(o, "padding", 0) * 2, s = Math.max(0, e - n);
|
|
153
|
+
s !== 0 && t.querySelectorAll("img.adapt-img").forEach((i) => {
|
|
146
154
|
if (i.hasAttribute("width"))
|
|
147
155
|
return;
|
|
148
|
-
const r = T(i,
|
|
156
|
+
const r = T(i, t);
|
|
149
157
|
if (!r)
|
|
150
158
|
return;
|
|
151
|
-
const
|
|
152
|
-
i.setAttribute("width", String(
|
|
153
|
-
const
|
|
154
|
-
if (!/\bwidth\s*:\s*\d/i.test(
|
|
155
|
-
const
|
|
156
|
-
i.setAttribute("style", `${
|
|
159
|
+
const c = $(r), l = b(r.getAttribute("style") || "", "padding", 0) * 2, u = c.endsWith("%") ? Math.floor(s * parseFloat(c) / 100) : parseInt(c), p = Math.max(1, u - l);
|
|
160
|
+
i.setAttribute("width", String(p));
|
|
161
|
+
const a = i.getAttribute("style") || "";
|
|
162
|
+
if (!/\bwidth\s*:\s*\d/i.test(a)) {
|
|
163
|
+
const d = a && !a.trim().endsWith(";") ? "; " : "";
|
|
164
|
+
i.setAttribute("style", `${a}${d}width: ${p}px`);
|
|
157
165
|
}
|
|
158
166
|
});
|
|
159
167
|
}
|
|
160
|
-
function
|
|
161
|
-
const
|
|
162
|
-
return (
|
|
163
|
-
` : "") +
|
|
168
|
+
function B(t, o) {
|
|
169
|
+
const e = t.match(/<!DOCTYPE[^>]*>/i);
|
|
170
|
+
return (e ? `${e[0]}
|
|
171
|
+
` : "") + o.documentElement.outerHTML;
|
|
164
172
|
}
|
|
165
|
-
function
|
|
166
|
-
const
|
|
167
|
-
if (!
|
|
168
|
-
return
|
|
169
|
-
const { buildCampaignUrl:
|
|
173
|
+
function G(t) {
|
|
174
|
+
const o = t.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(o, "text/html"), n = e.querySelectorAll(".recommendation-block-v2");
|
|
175
|
+
if (!n.length)
|
|
176
|
+
return t;
|
|
177
|
+
const { buildCampaignUrl: s } = C(), i = w();
|
|
170
178
|
i.recommendationCampaignUrls = {};
|
|
171
|
-
const { isFeatureEnabled: r } =
|
|
172
|
-
return
|
|
173
|
-
var
|
|
179
|
+
const { isFeatureEnabled: r } = q(), c = r("liquidSyntax") ? "reco_" : "";
|
|
180
|
+
return n.forEach((u) => {
|
|
181
|
+
var a, d;
|
|
174
182
|
const p = u.getAttribute("recommendation-id");
|
|
175
|
-
p && ((
|
|
176
|
-
}),
|
|
183
|
+
p && ((a = u.parentNode) == null || a.insertBefore(e.createComment("REC_START"), u), (d = u.parentNode) == null || d.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((y) => y.remove()), s(p), P(u) || O(u, p, c), M(u));
|
|
184
|
+
}), B(o, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
177
185
|
}
|
|
178
186
|
export {
|
|
179
|
-
|
|
180
|
-
|
|
187
|
+
f as formatPriceVariable,
|
|
188
|
+
G as prepareRecommendationBlocks
|
|
181
189
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ATTR_PRODUCT_IMAGE as p, ATTR_PRODUCT_BUTTON as C, ATTR_PRODUCT_OLD_PRICE as
|
|
2
|
-
import { buildSpacer as I, DEFAULT_CARD_COMPOSITION as g, buildElementRenderer as E, buildCellOptions as
|
|
1
|
+
import { ATTR_PRODUCT_IMAGE as p, ATTR_PRODUCT_BUTTON as C, ATTR_PRODUCT_OLD_PRICE as A, ATTR_PRODUCT_PRICE as m } from "../../constants/selectors.js";
|
|
2
|
+
import { buildSpacer as I, DEFAULT_CARD_COMPOSITION as g, buildElementRenderer as E, buildCellOptions as i, resolveInlinePriceOrder as w, DEFAULT_CARD_VISIBILITY as y } from "../utils.js";
|
|
3
3
|
import { listElementRenderer as L, renderInlineListPriceRow as O } from "./elementRenderer.js";
|
|
4
4
|
const S = "0 5px";
|
|
5
5
|
function U(l, r, n) {
|
|
@@ -27,40 +27,40 @@ const N = `
|
|
|
27
27
|
</td>
|
|
28
28
|
</tr>
|
|
29
29
|
`;
|
|
30
|
-
function
|
|
30
|
+
function x(l, r = g, n = {}, e = {}) {
|
|
31
31
|
const {
|
|
32
32
|
cellPadding: o = S,
|
|
33
33
|
cardBackgroundColor: d,
|
|
34
34
|
visibility: c,
|
|
35
|
-
priceInline:
|
|
36
|
-
} = e, u = d ? ` style="background-color: ${d};"` : "", s = E(L, r, n), P = s[p](l,
|
|
35
|
+
priceInline: a = !1
|
|
36
|
+
} = e, u = d ? ` style="table-layout: fixed; background-color: ${d};"` : ' style="table-layout: fixed;"', s = E(L, r, n), P = s[p](l, i(p, e)), R = w(r), T = `
|
|
37
37
|
<td class="product-info-cell" valign="middle" style="padding: 15px;">
|
|
38
38
|
<table cellpadding="0" cellspacing="0" role="presentation" width="100%" style="table-layout: fixed;">
|
|
39
39
|
<tbody>
|
|
40
|
-
${r.filter((t) => t !== p && t !== C).filter((t) => !(
|
|
41
|
-
const b = (c == null ? void 0 : c[t]) ?? y[t] ?? !0,
|
|
40
|
+
${r.filter((t) => t !== p && t !== C).filter((t) => !(a && t === R.skip)).filter((t) => s[t]).map((t) => {
|
|
41
|
+
const b = (c == null ? void 0 : c[t]) ?? y[t] ?? !0, f = a && t === R.anchor ? O(
|
|
42
42
|
l,
|
|
43
43
|
R.originalFirst,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
) : s[t](l,
|
|
47
|
-
return U(
|
|
44
|
+
i(m, e),
|
|
45
|
+
i(A, e)
|
|
46
|
+
) : s[t](l, i(t, e));
|
|
47
|
+
return U(f, t, b);
|
|
48
48
|
}).join(`
|
|
49
49
|
`)}
|
|
50
50
|
</tbody>
|
|
51
51
|
</table>
|
|
52
52
|
</td>
|
|
53
|
-
`, _ = s[C](l,
|
|
53
|
+
`, _ = s[C](l, i(C, e)), D = P + T + _;
|
|
54
54
|
return N.replace("{-{-CARD_PADDING-}-}", o).replace("{-{-WRAPPER_STYLE-}-}", u).replace("{-{-PRODUCT_CONTENT-}-}", D);
|
|
55
55
|
}
|
|
56
56
|
function W(l, r, n = {}, e = {}) {
|
|
57
57
|
const o = I(e.rowSpacingPx);
|
|
58
58
|
return l.map((d, c) => {
|
|
59
|
-
const
|
|
60
|
-
return c > 0 ? o +
|
|
59
|
+
const a = x(d, r, n, e);
|
|
60
|
+
return c > 0 ? o + a : a;
|
|
61
61
|
}).join("");
|
|
62
62
|
}
|
|
63
63
|
export {
|
|
64
|
-
|
|
64
|
+
x as getListProductCard,
|
|
65
65
|
W as prepareProductRows
|
|
66
66
|
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useToaster as m } from "../composables/useToaster.js";
|
|
2
|
+
import { useTranslations as c } from "../composables/useTranslations.js";
|
|
3
|
+
import { BLANK_TEMPLATE_HTML_URL as p, BLANK_TEMPLATE_CSS_URL as T } from "../enums/defaults.js";
|
|
4
|
+
import { ToasterTypeOptions as i } from "../enums/toaster.js";
|
|
5
|
+
const a = 3;
|
|
6
|
+
let e = null;
|
|
7
|
+
const n = async (r) => {
|
|
8
|
+
const t = await fetch(r);
|
|
9
|
+
if (!t.ok)
|
|
10
|
+
throw new Error(`Blank template request failed: ${t.status}`);
|
|
11
|
+
return t.text();
|
|
12
|
+
}, L = () => {
|
|
13
|
+
const { showToaster: r } = m(), t = c();
|
|
14
|
+
return { getBlankTemplate: async () => {
|
|
15
|
+
if (e)
|
|
16
|
+
return e;
|
|
17
|
+
for (let s = 1; s <= a; s++)
|
|
18
|
+
try {
|
|
19
|
+
const [o, l] = await Promise.all([
|
|
20
|
+
n(p),
|
|
21
|
+
n(T)
|
|
22
|
+
]);
|
|
23
|
+
return e = { html: o, css: l }, e;
|
|
24
|
+
} catch (o) {
|
|
25
|
+
console.error(`Failed to fetch blank template (attempt ${s}/${a}):`, o);
|
|
26
|
+
}
|
|
27
|
+
return r({ type: i.Alert, message: t("errors-pages.undefined-response") }), { html: "", css: "" };
|
|
28
|
+
} };
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
L as useBlankTemplate
|
|
32
|
+
};
|
|
@@ -1,77 +1,53 @@
|
|
|
1
|
-
import { useHttp as
|
|
2
|
-
import { useToaster as
|
|
3
|
-
import { MAX_DEFAULT_TEMPLATE_ID as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
let o = null;
|
|
9
|
-
const A = () => {
|
|
10
|
-
const { get: s, post: i } = y(), { handleError: a } = g(), p = async () => {
|
|
11
|
-
try {
|
|
12
|
-
const { data: t } = await s("/stripo/get-user-token");
|
|
13
|
-
return t.body.token;
|
|
14
|
-
} catch (t) {
|
|
15
|
-
return a(t, "Failed to fetch token"), "";
|
|
16
|
-
}
|
|
17
|
-
}, m = async () => {
|
|
18
|
-
try {
|
|
19
|
-
const { data: t = [] } = await s("/stripo/get-partner-custom-fonts");
|
|
20
|
-
return t.map((e) => ({
|
|
21
|
-
...e,
|
|
22
|
-
active: !0
|
|
23
|
-
}));
|
|
24
|
-
} catch (t) {
|
|
25
|
-
return a(t, "Failed to fetch custom fonts"), [];
|
|
26
|
-
}
|
|
27
|
-
}, f = async () => {
|
|
28
|
-
try {
|
|
29
|
-
const { data: t } = await s("/newsletter/settings/synchronisation-in-modules-status");
|
|
30
|
-
return t.status;
|
|
31
|
-
} catch (t) {
|
|
32
|
-
return a(t, "Failed to fetch sync modules status"), !1;
|
|
33
|
-
}
|
|
34
|
-
}, c = async () => {
|
|
35
|
-
if (o)
|
|
36
|
-
return o;
|
|
37
|
-
try {
|
|
38
|
-
const [t, e] = await Promise.all([
|
|
39
|
-
fetch(T).then((r) => {
|
|
40
|
-
if (!r.ok)
|
|
41
|
-
throw new Error(`Blank template HTML request failed: ${r.status}`);
|
|
42
|
-
return r.text();
|
|
43
|
-
}),
|
|
44
|
-
fetch(M).then((r) => {
|
|
45
|
-
if (!r.ok)
|
|
46
|
-
throw new Error(`Blank template CSS request failed: ${r.status}`);
|
|
47
|
-
return r.text();
|
|
48
|
-
})
|
|
49
|
-
]);
|
|
50
|
-
return o = { html: t, css: e }, o;
|
|
51
|
-
} catch (t) {
|
|
52
|
-
return a(t, "Failed to fetch blank template"), S;
|
|
53
|
-
}
|
|
54
|
-
};
|
|
1
|
+
import { useHttp as d } from "../composables/useHttp.js";
|
|
2
|
+
import { useToaster as m } from "../composables/useToaster.js";
|
|
3
|
+
import { MAX_DEFAULT_TEMPLATE_ID as y } from "../enums/defaults.js";
|
|
4
|
+
import { useBlankTemplate as f } from "./blankTemplate.js";
|
|
5
|
+
const D = () => {
|
|
6
|
+
const { get: s, post: u } = d(), { handleError: r } = m(), { getBlankTemplate: o } = f();
|
|
55
7
|
return {
|
|
56
|
-
getToken:
|
|
57
|
-
|
|
8
|
+
getToken: async () => {
|
|
9
|
+
try {
|
|
10
|
+
const { data: t } = await s("/stripo/get-user-token");
|
|
11
|
+
return t.body.token;
|
|
12
|
+
} catch (t) {
|
|
13
|
+
return r(t, "Failed to fetch token"), "";
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
getCustomFonts: async () => {
|
|
17
|
+
try {
|
|
18
|
+
const { data: t = [] } = await s("/stripo/get-partner-custom-fonts");
|
|
19
|
+
return t.map((e) => ({
|
|
20
|
+
...e,
|
|
21
|
+
active: !0
|
|
22
|
+
}));
|
|
23
|
+
} catch (t) {
|
|
24
|
+
return r(t, "Failed to fetch custom fonts"), [];
|
|
25
|
+
}
|
|
26
|
+
},
|
|
58
27
|
getDefaultTemplate: async () => {
|
|
59
28
|
try {
|
|
60
|
-
const t = new URLSearchParams(window.location.search), e = t.get("default-template"),
|
|
61
|
-
if (!
|
|
62
|
-
return await
|
|
63
|
-
const
|
|
64
|
-
return !
|
|
29
|
+
const t = new URLSearchParams(window.location.search), e = t.get("default-template"), l = t.get("master"), n = e ? parseInt(e) : 0, i = n >= 1 && n <= y ? n : 0;
|
|
30
|
+
if (!i && !l)
|
|
31
|
+
return await o();
|
|
32
|
+
const p = `/stripo/default-template/${i}`, { data: c } = await s(p), a = typeof c == "string" ? JSON.parse(c) : c;
|
|
33
|
+
return !a || typeof a != "object" || !("html" in a) || !("css" in a) ? await o() : a;
|
|
34
|
+
} catch (t) {
|
|
35
|
+
return r(t, "Failed to fetch default template"), o();
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
getSyncModulesStatus: async () => {
|
|
39
|
+
try {
|
|
40
|
+
const { data: t } = await s("/newsletter/settings/synchronisation-in-modules-status");
|
|
41
|
+
return t.status;
|
|
65
42
|
} catch (t) {
|
|
66
|
-
return
|
|
43
|
+
return r(t, "Failed to fetch sync modules status"), !1;
|
|
67
44
|
}
|
|
68
45
|
},
|
|
69
|
-
getSyncModulesStatus: f,
|
|
70
46
|
updateSyncModule: async (t) => {
|
|
71
47
|
try {
|
|
72
|
-
return await
|
|
48
|
+
return await u(`/stripo/stripo-modules/${t.moduleId}/update`), !0;
|
|
73
49
|
} catch (e) {
|
|
74
|
-
return
|
|
50
|
+
return r(e, "Failed to update sync module"), !1;
|
|
75
51
|
}
|
|
76
52
|
},
|
|
77
53
|
getSyncModule: async (t) => {
|
|
@@ -79,7 +55,7 @@ const A = () => {
|
|
|
79
55
|
const { data: e } = await s(`/stripo/stripo-modules/${t}/get`);
|
|
80
56
|
return e;
|
|
81
57
|
} catch (e) {
|
|
82
|
-
return
|
|
58
|
+
return r(e, "Failed to get sync module"), {
|
|
83
59
|
id: 0,
|
|
84
60
|
stripoId: 0,
|
|
85
61
|
unsubscriptionPreferencePages: []
|
|
@@ -90,13 +66,13 @@ const A = () => {
|
|
|
90
66
|
if (t.length === 0)
|
|
91
67
|
return !0;
|
|
92
68
|
try {
|
|
93
|
-
return await
|
|
69
|
+
return await u("/stripo/stripo-modules/set-unsubscription-preference-pages", t), !0;
|
|
94
70
|
} catch (e) {
|
|
95
|
-
return
|
|
71
|
+
return r(e, "Failed to set unsubscription preference pages"), !1;
|
|
96
72
|
}
|
|
97
73
|
}
|
|
98
74
|
};
|
|
99
75
|
};
|
|
100
76
|
export {
|
|
101
|
-
|
|
77
|
+
D as useStripoApi
|
|
102
78
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Template } from '@@/Types/stripo';
|
|
2
|
+
/**
|
|
3
|
+
* Fetches the blank starter template (html + css) from the email CDN — the single
|
|
4
|
+
* source of truth shared with email-fe. Retries a few times, caches the result for
|
|
5
|
+
* the session, and on persistent failure returns an empty template (the editor still
|
|
6
|
+
* opens) plus a toaster. Kept separate from stripoApi: this is a CDN asset fetch, not
|
|
7
|
+
* a Stripo backend call.
|
|
8
|
+
*/
|
|
9
|
+
export declare const useBlankTemplate: () => {
|
|
10
|
+
getBlankTemplate: () => Promise<Template>;
|
|
11
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.9.0-beta.
|
|
3
|
+
"version": "3.9.0-beta.8ad06e1",
|
|
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",
|