@useinsider/guido 3.9.1-beta.c521c3a → 3.9.1-beta.de8e72f
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/recommendationCompilerRules.js +55 -38
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +143 -119
- package/dist/enums/defaults.js +4 -7
- package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +1 -1
- package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +69 -75
- package/dist/extensions/Blocks/Recommendation/validation/requiredFields.js +17 -18
- package/dist/services/stripoApi.js +18 -13
- package/dist/src/enums/defaults.d.ts +0 -3
- package/dist/src/extensions/Blocks/Recommendation/utils/captureStyleTemplates.d.ts +0 -6
- package/dist/src/extensions/Blocks/Recommendation/validation/requiredFields.d.ts +0 -1
- package/dist/static/templates/empty/index.html.js +74 -0
- package/dist/static/templates/empty/style.css.js +779 -0
- package/dist/utils/pairProductVariables.js +65 -64
- package/package.json +1 -1
- package/dist/services/blankTemplate.js +0 -34
- package/dist/src/services/blankTemplate.d.ts +0 -11
|
@@ -1,84 +1,85 @@
|
|
|
1
|
-
import { productPairs as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (d)
|
|
1
|
+
import { productPairs as L } from "../extensions/Blocks/Items/enums/productEnums.js";
|
|
2
|
+
function q(w) {
|
|
3
|
+
const y = w.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), T = new DOMParser().parseFromString(y, "text/html"), C = L.PAIRS_FOR_EXTENSION;
|
|
4
|
+
Object.entries(C).forEach(([r, f]) => {
|
|
5
|
+
T.querySelectorAll(".ins-product-td").forEach((o) => {
|
|
6
|
+
const A = o.getAttribute("data-number") || "1", b = o.getAttribute("data-type") || "CART_ITEMS";
|
|
7
|
+
o.querySelectorAll(`[product-attr="${r}"]`).forEach((e) => {
|
|
8
|
+
var k, F, I;
|
|
9
|
+
const $ = e.getAttribute("data-type") || b, d = e.getAttribute("data-number") || A, u = f[$];
|
|
10
|
+
if (u)
|
|
12
11
|
switch (r) {
|
|
13
12
|
case "imageSrc": {
|
|
14
13
|
let t = null, i = null;
|
|
15
14
|
if (e.tagName === "IMG" ? (t = e, i = t.closest("a")) : (t = e.querySelector("img"), i = e.querySelector("a") || e.closest("a")), !t)
|
|
16
15
|
break;
|
|
17
|
-
const a =
|
|
16
|
+
const a = u.DEFAULT, s = u.ATTR;
|
|
18
17
|
if (a && t.src) {
|
|
19
|
-
const
|
|
18
|
+
const c = t.src;
|
|
20
19
|
a.some((h) => {
|
|
21
|
-
const l = h.split("/").pop() || "",
|
|
22
|
-
return
|
|
23
|
-
}) && (t.src = `{{${s}_${
|
|
20
|
+
const l = h.split("/").pop() || "", g = c.split("/").pop() || "";
|
|
21
|
+
return c.includes(h) || c.includes(l) || g === l;
|
|
22
|
+
}) && (t.src = `{{${s}_${d}}}`);
|
|
24
23
|
}
|
|
25
|
-
const n = (
|
|
26
|
-
if (n && t.setAttribute("alt", `{{${n}_${
|
|
27
|
-
const
|
|
28
|
-
if (
|
|
29
|
-
const E =
|
|
30
|
-
(l === "#" || l === "" || l.endsWith("#!") || l.endsWith(h) || l === `${window.location.href}${h}` || !l || l === window.location.href) && (i.href = `{{${E}_${
|
|
24
|
+
const n = (F = (k = C.name) == null ? void 0 : k[$]) == null ? void 0 : F.ATTR;
|
|
25
|
+
if (n && t.setAttribute("alt", `{{${n}_${d}}}`), i) {
|
|
26
|
+
const c = (I = C.itemLink) == null ? void 0 : I[$];
|
|
27
|
+
if (c) {
|
|
28
|
+
const E = c.HREF, h = c.DEFAULT_HREF || "#!", l = i.href;
|
|
29
|
+
(l === "#" || l === "" || l.endsWith("#!") || l.endsWith(h) || l === `${window.location.href}${h}` || !l || l === window.location.href) && (i.href = `{{${E}_${d}}}`);
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
32
|
break;
|
|
34
33
|
}
|
|
35
34
|
case "name": {
|
|
36
|
-
const t =
|
|
37
|
-
e.textContent && (e.textContent = `{{${i}_${
|
|
35
|
+
const t = u, i = t.ATTR, a = t.DEFAULT_HREF || "#!", s = t.HREF;
|
|
36
|
+
e.textContent && (e.textContent = `{{${i}_${d}}}`);
|
|
38
37
|
const n = e.closest("a") || (e.tagName === "A" ? e : null);
|
|
39
38
|
if (n && s) {
|
|
40
|
-
const
|
|
41
|
-
(
|
|
39
|
+
const c = n.href, E = `${window.location.href}${a}`;
|
|
40
|
+
(c === E || c.endsWith(a)) && (n.href = `{{${s}_${d}}}`);
|
|
42
41
|
}
|
|
43
42
|
break;
|
|
44
43
|
}
|
|
45
44
|
case "price":
|
|
46
45
|
case "originalPrice": {
|
|
47
|
-
const t =
|
|
46
|
+
const t = u, i = e.getAttribute("data-formated"), a = e.getAttribute("data-single_price"), s = i === "true", n = a === "true", c = e.getAttribute("data-curency") || "before";
|
|
48
47
|
let E;
|
|
49
48
|
n ? E = s ? t.SINGLE_PRICE_FORMATTED : t.SINGLE_PRICE : E = s ? t.PRICE_FORMATTED : t.PRICE;
|
|
50
49
|
const h = t.CURRENCY;
|
|
51
|
-
let l = `{{${E}_${
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
let l = `{{${E}_${d}}}`;
|
|
51
|
+
if (h) {
|
|
52
|
+
const g = `{{${h}_${d}}}`;
|
|
53
|
+
l = c === "after" ? `${l} ${g}` : `${g} ${l}`;
|
|
54
|
+
}
|
|
55
|
+
e.textContent = l;
|
|
55
56
|
break;
|
|
56
57
|
}
|
|
57
58
|
case "quantity": {
|
|
58
|
-
const t =
|
|
59
|
-
e.textContent && e.textContent.trim() === a && (e.textContent = `{{${i}_${
|
|
59
|
+
const t = u, i = t.ATTR, a = t.DEFAULT;
|
|
60
|
+
e.textContent && e.textContent.trim() === a && (e.textContent = `{{${i}_${d}}}`);
|
|
60
61
|
break;
|
|
61
62
|
}
|
|
62
63
|
case "button": {
|
|
63
|
-
const t =
|
|
64
|
+
const t = u, i = t.HREF, a = t.DEFAULT_HREF || "#!", s = e.tagName === "A" ? e : e.querySelector("a");
|
|
64
65
|
if (s) {
|
|
65
|
-
const n = s.href || "",
|
|
66
|
-
(n === "" || n === "#" || n ===
|
|
66
|
+
const n = s.href || "", c = `${window.location.href}${a}`;
|
|
67
|
+
(n === "" || n === "#" || n === c || n.endsWith(a) || n.endsWith("#!") || n === window.location.href) && (s.href = `{{${i}_${d}}}`);
|
|
67
68
|
}
|
|
68
69
|
break;
|
|
69
70
|
}
|
|
70
71
|
case "itemLink": {
|
|
71
|
-
const t =
|
|
72
|
+
const t = u, i = t.HREF, a = t.DEFAULT_HREF || "#!", s = e;
|
|
72
73
|
if (s.href) {
|
|
73
|
-
const n = s.href,
|
|
74
|
-
(n ===
|
|
74
|
+
const n = s.href, c = `${window.location.href}${a}`;
|
|
75
|
+
(n === c || n.endsWith(a)) && (s.href = `{{${i}_${d}}}`);
|
|
75
76
|
}
|
|
76
77
|
break;
|
|
77
78
|
}
|
|
78
79
|
default: {
|
|
79
|
-
if ("ATTR" in
|
|
80
|
-
const t =
|
|
81
|
-
e.textContent && (e.textContent = `{{${t}_${
|
|
80
|
+
if ("ATTR" in u) {
|
|
81
|
+
const t = u.ATTR;
|
|
82
|
+
e.textContent && (e.textContent = `{{${t}_${d}}}`);
|
|
82
83
|
}
|
|
83
84
|
break;
|
|
84
85
|
}
|
|
@@ -86,48 +87,48 @@ function W(M) {
|
|
|
86
87
|
});
|
|
87
88
|
});
|
|
88
89
|
});
|
|
89
|
-
const
|
|
90
|
-
` : "",
|
|
91
|
-
|
|
92
|
-
const f = r.getAttribute("data-type") || "CART_ITEMS", p = r.getAttribute("data-number") || "1",
|
|
93
|
-
|
|
90
|
+
const S = y.match(/<!DOCTYPE[^>]*>/i), M = S ? `${S[0]}
|
|
91
|
+
` : "", P = T.querySelectorAll(".ins-product-td"), H = [];
|
|
92
|
+
P.forEach((r) => {
|
|
93
|
+
const f = r.getAttribute("data-type") || "CART_ITEMS", p = r.getAttribute("data-number") || "1", o = r.getAttribute("data-nodup"), A = r.outerHTML;
|
|
94
|
+
H.push({
|
|
94
95
|
element: r,
|
|
95
96
|
outerHtml: A,
|
|
96
97
|
type: f,
|
|
97
98
|
number: p,
|
|
98
|
-
nodup:
|
|
99
|
+
nodup: o || void 0
|
|
99
100
|
});
|
|
100
101
|
});
|
|
101
|
-
let _ =
|
|
102
|
-
|
|
103
|
-
let
|
|
102
|
+
let _ = M + T.documentElement.outerHTML;
|
|
103
|
+
H.reverse().forEach(({ outerHtml: r, type: f, number: p }) => {
|
|
104
|
+
let o = "";
|
|
104
105
|
switch (f) {
|
|
105
106
|
case "CART_ITEMS":
|
|
106
|
-
|
|
107
|
+
o = "ins_apr_total_product_kind";
|
|
107
108
|
break;
|
|
108
109
|
case "BROWSED_ITEMS":
|
|
109
|
-
|
|
110
|
+
o = "browsed_item_total_product_kind";
|
|
110
111
|
break;
|
|
111
112
|
case "PURCHASED_ITEMS":
|
|
112
|
-
|
|
113
|
+
o = "purchased_item_total_product_kind";
|
|
113
114
|
break;
|
|
114
115
|
}
|
|
115
|
-
if (
|
|
116
|
-
const
|
|
116
|
+
if (o) {
|
|
117
|
+
const b = parseInt(p) - 1, $ = `${`{% if ${o} > ${b} %}`}${r}{% endif %}`;
|
|
117
118
|
_ = _.replace(r, $);
|
|
118
119
|
}
|
|
119
120
|
});
|
|
120
|
-
const
|
|
121
|
-
return
|
|
121
|
+
const D = T.querySelectorAll('[product-attr="originalPrice"][data-type="CART_ITEMS"]'), R = [];
|
|
122
|
+
return D.forEach((r) => {
|
|
122
123
|
const f = r.getAttribute("data-number"), p = r.getAttribute("data-type");
|
|
123
124
|
if (!f || p !== "CART_ITEMS")
|
|
124
125
|
return;
|
|
125
|
-
const
|
|
126
|
-
if (
|
|
127
|
-
const A =
|
|
128
|
-
|
|
126
|
+
const o = r.closest(".product-original-price-class");
|
|
127
|
+
if (o) {
|
|
128
|
+
const A = o.outerHTML;
|
|
129
|
+
R.some((m) => m.tdOuterHtml === A) || R.push({ tdOuterHtml: A, number: f });
|
|
129
130
|
}
|
|
130
|
-
}),
|
|
131
|
+
}), R.reverse().forEach(({ tdOuterHtml: r, number: f }) => {
|
|
131
132
|
const p = `{% if ins_apr_price_${f} != ins_apr_originalprice_${f} %}`;
|
|
132
133
|
if (!_.includes(p) && !r.includes("{% if")) {
|
|
133
134
|
const A = `${p}${r}{% endif %}`;
|
|
@@ -136,5 +137,5 @@ function W(M) {
|
|
|
136
137
|
}), _.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
137
138
|
}
|
|
138
139
|
export {
|
|
139
|
-
|
|
140
|
+
q as pairProductVariables
|
|
140
141
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.9.1-beta.
|
|
3
|
+
"version": "3.9.1-beta.de8e72f",
|
|
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",
|
|
@@ -1,34 +0,0 @@
|
|
|
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 T, BLANK_TEMPLATE_CSS_URL as i } from "../enums/defaults.js";
|
|
4
|
-
import { ToasterTypeOptions as p } from "../enums/toaster.js";
|
|
5
|
-
const a = 3, f = 1e3;
|
|
6
|
-
let s = null;
|
|
7
|
-
const u = (e) => new Promise((t) => {
|
|
8
|
-
setTimeout(t, e);
|
|
9
|
-
}), n = async (e) => {
|
|
10
|
-
const t = await fetch(e);
|
|
11
|
-
if (!t.ok)
|
|
12
|
-
throw new Error(`Blank template request failed: ${t.status}`);
|
|
13
|
-
return t.text();
|
|
14
|
-
}, k = () => {
|
|
15
|
-
const { showToaster: e } = m(), t = c();
|
|
16
|
-
return { getBlankTemplate: async () => {
|
|
17
|
-
if (s)
|
|
18
|
-
return s;
|
|
19
|
-
for (let r = 1; r <= a; r++)
|
|
20
|
-
try {
|
|
21
|
-
const [o, l] = await Promise.all([
|
|
22
|
-
n(T),
|
|
23
|
-
n(i)
|
|
24
|
-
]);
|
|
25
|
-
return s = { html: o, css: l }, s;
|
|
26
|
-
} catch (o) {
|
|
27
|
-
console.error(`Failed to fetch blank template (attempt ${r}/${a}):`, o), r < a && await u(r * f);
|
|
28
|
-
}
|
|
29
|
-
return e({ type: p.Alert, message: t("errors-pages.undefined-response") }), { html: "", css: "" };
|
|
30
|
-
} };
|
|
31
|
-
};
|
|
32
|
-
export {
|
|
33
|
-
k as useBlankTemplate
|
|
34
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
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
|
-
};
|