@useinsider/guido 3.8.1 → 3.8.2-beta.189e91c
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/@types/config/schemas.js +70 -66
- package/dist/components/organisms/email-preview/desktop-preview/DesktopPreview.vue.js +8 -8
- package/dist/components/organisms/email-preview/desktop-preview/DesktopPreview.vue2.js +15 -12
- package/dist/components/organisms/email-preview/mobile-preview/ContentView.vue.js +5 -5
- package/dist/components/organisms/email-preview/mobile-preview/ContentView.vue2.js +16 -15
- package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue.js +5 -5
- package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue2.js +42 -37
- package/dist/components/organisms/unsubscribe/UnsubscribeTypeSelection.vue.js +3 -3
- package/dist/components/organisms/unsubscribe/UnsubscribeTypeSelection.vue2.js +40 -37
- package/dist/composables/useHtmlCompiler.js +13 -10
- package/dist/composables/useHtmlValidator.js +180 -133
- package/dist/composables/usePreviewInteractionGuard.js +17 -0
- package/dist/composables/usePreviewMode.js +15 -14
- package/dist/composables/useRecommendationPreview.js +111 -0
- package/dist/composables/useSave.js +14 -14
- package/dist/composables/validators/useUnsubscribeBlockValidator.js +26 -17
- package/dist/config/compiler/htmlCompilerRules.js +38 -10
- package/dist/config/compiler/recommendationCompilerRules.js +84 -109
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +98 -89
- package/dist/config/compiler/utils/recommendationIgnoreUtils.js +15 -0
- package/dist/config/migrator/recommendation/extractors.js +44 -22
- package/dist/config/migrator/recommendation/htmlBuilder.js +170 -163
- package/dist/config/migrator/recommendation/settingsMapper.js +38 -33
- package/dist/config/migrator/recommendationMigrator.js +30 -31
- package/dist/extensions/Blocks/Recommendation/block.js +60 -41
- package/dist/extensions/Blocks/Recommendation/canvasPreview.css.js +16 -0
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +41 -32
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +26 -20
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +359 -264
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +96 -83
- package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +43 -31
- package/dist/extensions/Blocks/Recommendation/controls/main/pricePlacement.js +133 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/productCount.js +3 -2
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +55 -45
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +175 -166
- package/dist/extensions/Blocks/Recommendation/controls/syncInfoMessage.js +7 -6
- package/dist/extensions/Blocks/Recommendation/extension.js +31 -29
- package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +21 -7
- package/dist/extensions/Blocks/Recommendation/recommendation.css.js +64 -4
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +3 -2
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +6 -3
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +130 -96
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +43 -53
- package/dist/extensions/Blocks/Recommendation/templates/index.js +20 -16
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +86 -80
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +31 -40
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +155 -102
- package/dist/extensions/Blocks/Unsubscribe/block.js +40 -37
- package/dist/extensions/Blocks/Unsubscribe/control.js +19 -16
- package/dist/guido.css +1 -1
- package/dist/src/@types/config/schemas.d.ts +16 -0
- package/dist/src/composables/useConfig.d.ts +4 -0
- package/dist/src/composables/useHtmlValidator.d.ts +27 -0
- package/dist/src/composables/useHtmlValidator.test.d.ts +1 -0
- package/dist/src/composables/usePreviewInteractionGuard.d.ts +3 -0
- package/dist/src/composables/useRecommendationPreview.d.ts +10 -0
- package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +1 -0
- package/dist/src/config/compiler/utils/recommendationIgnoreUtils.d.ts +17 -0
- package/dist/src/config/compiler/utils/recommendationIgnoreUtils.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/extractors.d.ts +15 -0
- package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +8 -0
- package/dist/src/config/migrator/recommendation/settingsMapper.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +10 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +21 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +36 -3
- package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +3 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/layoutOrientation.d.ts +5 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/pricePlacement.d.ts +59 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +9 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +13 -1
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
- package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +10 -1
- package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +3 -3
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +51 -1
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +15 -0
- package/dist/src/stores/config.d.ts +36 -0
- package/dist/src/stores/unsubscribe.d.ts +11 -1
- package/dist/src/utils/ampErrorFilter.d.ts +1 -0
- package/dist/stores/unsubscribe.js +8 -7
- package/dist/utils/ampErrorFilter.js +6 -5
- package/package.json +1 -1
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { BLOCK_ROOT_SELECTOR as S, CURRENCY_ATTR as p, CONTAINER_SELECTOR as O } from "../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
2
|
+
import { useRecommendationExtensionStore as h } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
3
|
+
import { formatPrice as E } from "../extensions/Blocks/Recommendation/utils/priceFormatter.js";
|
|
4
|
+
const f = `${S}[recommendation-id]`, C = ".product-old-price", R = /\{\{(?:reco_)?(\d+_\d+_[a-zA-Z0-9_.]+)\}\}/g, T = new RegExp(
|
|
5
|
+
"\\{%\\s*if\\s+([\\s\\S]+?)\\s*%\\}([\\s\\S]*?)(?:\\{%\\s*else\\s*%\\}([\\s\\S]*?))?\\{%\\s*endif\\s*%\\}",
|
|
6
|
+
"g"
|
|
7
|
+
);
|
|
8
|
+
function b(e) {
|
|
9
|
+
return e.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
10
|
+
}
|
|
11
|
+
function _(e) {
|
|
12
|
+
var s;
|
|
13
|
+
const n = (s = e.replace(/[\u0000-\u0020]+/g, "").toLowerCase().match(/^([a-z][a-z0-9+.-]*):/)) == null ? void 0 : s[1];
|
|
14
|
+
return n && n !== "http" && n !== "https" && n !== "mailto" ? "" : e;
|
|
15
|
+
}
|
|
16
|
+
function N(e) {
|
|
17
|
+
const t = e.getAttribute(p.CURRENCY) || "USD", n = e.getAttribute(p.DECIMAL_SEPARATOR) || ".", s = e.getAttribute(p.THOUSAND_SEPARATOR) || ",";
|
|
18
|
+
return {
|
|
19
|
+
code: t,
|
|
20
|
+
symbol: e.getAttribute(p.SYMBOL) || t,
|
|
21
|
+
alignment: e.getAttribute(p.ALIGNMENT) === "0" ? "before" : "after",
|
|
22
|
+
decimalCount: parseInt(e.getAttribute(p.DECIMAL_COUNT) || "2") || 2,
|
|
23
|
+
decimalSeparator: n,
|
|
24
|
+
thousandSeparator: s
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function g(e, t) {
|
|
28
|
+
return (e == null ? void 0 : e[t]) ?? Object.values(e ?? {})[0] ?? 0;
|
|
29
|
+
}
|
|
30
|
+
function L(e, t) {
|
|
31
|
+
const n = g(e.original_price, t), s = g(e.price, t), o = n > 0 ? Math.round((n - s) / n * 100) : 0;
|
|
32
|
+
return o > 0 ? `${o}%` : "0%";
|
|
33
|
+
}
|
|
34
|
+
function P(e, t, n, s, o, a) {
|
|
35
|
+
s.forEach((i, c) => {
|
|
36
|
+
const r = (m) => `${n}_${c}_${m}`, u = E({ price: g(i.price, o.code), currency: o }), l = E({ price: g(i.original_price, o.code), currency: o }), d = L(i, o.code);
|
|
37
|
+
e.set(r("name"), i.name ?? ""), e.set(r("image_url"), _(i.image_url ?? "")), e.set(r("url"), _(i.url ?? "")), e.set(r("item_id"), i.item_id ?? ""), e.set(r("currency"), ""), e.set(r("price"), u), e.set(r("original_price"), l), e.set(r("discount"), d), e.set(r("omnibus_price"), l), e.set(r("omnibus_discount"), d), a && u === l && t.add(`${n}_${c}`), Object.entries(i.product_attributes ?? {}).forEach(([m, A]) => {
|
|
38
|
+
e.set(r(`product_attribute.${m}`), String(A)), e.set(r(m), String(A));
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function $(e, t) {
|
|
43
|
+
const n = e.match(/^(.+?)\s*(!=|==)\s*"([^"]*)"$/);
|
|
44
|
+
if (!n)
|
|
45
|
+
return !0;
|
|
46
|
+
const [, s, o, a] = n, i = t.get(s.trim()) ?? "";
|
|
47
|
+
return o === "!=" ? i !== a : i === a;
|
|
48
|
+
}
|
|
49
|
+
function z(e, t) {
|
|
50
|
+
return e.replace(
|
|
51
|
+
T,
|
|
52
|
+
(n, s, o, a) => s.split(/\s+and\s+/).every((c) => $(c.trim(), t)) ? o : a ?? ""
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
function w(e) {
|
|
56
|
+
let t = e;
|
|
57
|
+
for (; t.children.length === 1; )
|
|
58
|
+
[t] = t.children;
|
|
59
|
+
return t;
|
|
60
|
+
}
|
|
61
|
+
function D(e, t) {
|
|
62
|
+
var i;
|
|
63
|
+
if (!t.size)
|
|
64
|
+
return e;
|
|
65
|
+
const n = e.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), s = new DOMParser().parseFromString(n, "text/html");
|
|
66
|
+
s.querySelectorAll(f).forEach((c) => {
|
|
67
|
+
const r = Number(c.getAttribute("recommendation-id"));
|
|
68
|
+
if (!Number.isFinite(r))
|
|
69
|
+
return;
|
|
70
|
+
const u = c.querySelectorAll(O);
|
|
71
|
+
(u.length ? Array.from(u) : [c]).forEach((d) => {
|
|
72
|
+
d.querySelectorAll(C).forEach((m, A) => {
|
|
73
|
+
t.has(`${r}_${A}`) && (w(m).textContent = "");
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
const o = (i = e.match(/<!DOCTYPE[^>]*>/i)) == null ? void 0 : i[0];
|
|
78
|
+
return ((o ? `${o}
|
|
79
|
+
` : "") + s.documentElement.outerHTML).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
80
|
+
}
|
|
81
|
+
function I(e) {
|
|
82
|
+
if (!e || !e.includes("recommendation-block-v2"))
|
|
83
|
+
return e;
|
|
84
|
+
const t = h(), n = new DOMParser().parseFromString(e, "text/html"), s = Array.from(n.querySelectorAll(f)), o = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set();
|
|
85
|
+
if (s.forEach((c) => {
|
|
86
|
+
var l;
|
|
87
|
+
const r = Number(c.getAttribute("recommendation-id"));
|
|
88
|
+
if (!Number.isFinite(r))
|
|
89
|
+
return;
|
|
90
|
+
const u = ((l = t.blockStates[r]) == null ? void 0 : l.recommendationProducts) ?? [];
|
|
91
|
+
u.length && P(
|
|
92
|
+
o,
|
|
93
|
+
a,
|
|
94
|
+
r,
|
|
95
|
+
u,
|
|
96
|
+
N(c),
|
|
97
|
+
c.getAttribute("hide-price") === "true"
|
|
98
|
+
);
|
|
99
|
+
}), !o.size)
|
|
100
|
+
return e;
|
|
101
|
+
let i = D(e, a);
|
|
102
|
+
return i = i.replace(
|
|
103
|
+
R,
|
|
104
|
+
(c, r) => o.has(r) ? b(o.get(r)) : c
|
|
105
|
+
), i = z(i, o), i;
|
|
106
|
+
}
|
|
107
|
+
const q = () => ({ substituteRecommendationPreview: I });
|
|
108
|
+
export {
|
|
109
|
+
I as substituteRecommendationPreview,
|
|
110
|
+
q as useRecommendationPreview
|
|
111
|
+
};
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
1
|
+
import { useActionsApi as H } from "./useActionsApi.js";
|
|
2
2
|
import { useConfig as y } from "./useConfig.js";
|
|
3
|
-
import { useSaveStart as w, useSaveComplete as
|
|
3
|
+
import { useSaveStart as w, useSaveComplete as k } from "./useGuidoActions.js";
|
|
4
4
|
import { useSyncModuleExtractor as q } from "./useSyncModuleExtractor.js";
|
|
5
5
|
import { useStripoApi as C } from "../services/stripoApi.js";
|
|
6
6
|
import { useTemplatePreparation as E } from "../utils/templatePreparation.js";
|
|
7
|
-
import { useHtmlValidator as
|
|
7
|
+
import { useHtmlValidator as B } from "./useHtmlValidator.js";
|
|
8
8
|
import { useCouponBlockValidator as L } from "./validators/useCouponBlockValidator.js";
|
|
9
9
|
import { useLiquidValidator as P } from "./validators/useLiquidValidator.js";
|
|
10
|
-
import { useUnsubscribeBlockValidator as
|
|
11
|
-
const
|
|
12
|
-
const o = w(), s =
|
|
13
|
-
return { save: async (f = !1,
|
|
10
|
+
import { useUnsubscribeBlockValidator as U } from "./validators/useUnsubscribeBlockValidator.js";
|
|
11
|
+
const K = () => {
|
|
12
|
+
const o = w(), s = k(), { validateHtml: r } = B(), { validateLiquidSyntax: l } = P(), { validateCouponBlockTags: n } = L(), { validateUnsubscribeBlockUniqueness: d, validateUnsubscribeBlockHasTemplate: c } = U(), { callbacks: i, isFeatureEnabled: u } = y(), { extractSyncModuleData: m } = q(), { setSyncModuleUnsubscriptionPages: p } = C(), { editorSave: v } = H();
|
|
13
|
+
return { save: async (f = !1, S = !1) => {
|
|
14
14
|
var a;
|
|
15
15
|
o();
|
|
16
|
-
const { prepareTemplateDetails:
|
|
17
|
-
if (!
|
|
16
|
+
const { prepareTemplateDetails: V } = E(), t = await V();
|
|
17
|
+
if (!n(t.compiledHtml) || !d(t.compiledHtml) || !c(t.compiledHtml))
|
|
18
18
|
return;
|
|
19
19
|
if (u("liquidSyntax")) {
|
|
20
|
-
if (!await
|
|
20
|
+
if (!await l(t.compiledHtml))
|
|
21
21
|
return;
|
|
22
22
|
} else if (!await r(t.compiledHtml, t.dynamicContentList, !0))
|
|
23
23
|
return;
|
|
24
|
-
if ((a = i.value) != null && a.externalValidation && !await i.value.externalValidation(t) || !await
|
|
24
|
+
if ((a = i.value) != null && a.externalValidation && !await i.value.externalValidation(t) || !await v())
|
|
25
25
|
return;
|
|
26
|
-
const { unsubscribePayload:
|
|
27
|
-
return await
|
|
26
|
+
const { unsubscribePayload: b, stripoModules: x } = m(t.rawHtml);
|
|
27
|
+
return await p(b), t.modules = x, f || s({ ...t, silent: S }), t;
|
|
28
28
|
} };
|
|
29
29
|
};
|
|
30
30
|
export {
|
|
31
|
-
|
|
31
|
+
K as useSave
|
|
32
32
|
};
|
|
@@ -1,32 +1,41 @@
|
|
|
1
1
|
import { ToasterTypeOptions as i } from "../../enums/toaster.js";
|
|
2
|
-
import { PAGE_TYPES as
|
|
3
|
-
import { UNSUBSCRIBE_BLOCK_SELECTOR as
|
|
4
|
-
import { useToaster as
|
|
2
|
+
import { PAGE_TYPES as u } from "../../enums/unsubscribe.js";
|
|
3
|
+
import { UNSUBSCRIBE_BLOCK_SELECTOR as l, DATA_ATTRIBUTES as a } from "../../extensions/Blocks/Unsubscribe/utils/constants.js";
|
|
4
|
+
import { useToaster as m } from "../useToaster.js";
|
|
5
5
|
import { useTranslations as E } from "../useTranslations.js";
|
|
6
|
-
const
|
|
6
|
+
const T = [
|
|
7
7
|
{
|
|
8
|
-
pageType:
|
|
8
|
+
pageType: u.GLOBAL_UNSUBSCRIBE,
|
|
9
9
|
messageKey: "unsubscription-preference.duplicate-global-unsub"
|
|
10
10
|
},
|
|
11
11
|
{
|
|
12
|
-
pageType:
|
|
12
|
+
pageType: u.SUBSCRIPTION_PREFERENCE_CENTER,
|
|
13
13
|
messageKey: "unsubscription-preference.duplicate-pref-center"
|
|
14
14
|
}
|
|
15
|
-
], g = "unsubscription-preference.duplicate-both",
|
|
16
|
-
const { showToaster:
|
|
17
|
-
return { validateUnsubscribeBlockUniqueness: (
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
const r = Number(e.getAttribute(
|
|
21
|
-
|
|
15
|
+
], g = "unsubscription-preference.duplicate-both", b = "unsubscription-preference.select-page-to-continue", P = () => {
|
|
16
|
+
const { showToaster: c } = m(), p = E();
|
|
17
|
+
return { validateUnsubscribeBlockUniqueness: (n) => {
|
|
18
|
+
const o = new DOMParser().parseFromString(n, "text/html"), s = /* @__PURE__ */ new Map();
|
|
19
|
+
o.querySelectorAll(l).forEach((e) => {
|
|
20
|
+
const r = Number(e.getAttribute(a.PAGE_TYPE));
|
|
21
|
+
s.set(r, (s.get(r) ?? 0) + 1);
|
|
22
22
|
});
|
|
23
|
-
const
|
|
24
|
-
return
|
|
23
|
+
const t = T.filter((e) => (s.get(e.pageType) ?? 0) > 1).map((e) => e.messageKey);
|
|
24
|
+
return t.length ? (c({
|
|
25
25
|
type: i.Alert,
|
|
26
|
-
message:
|
|
26
|
+
message: p(t.length > 1 ? g : t[0])
|
|
27
|
+
}), !1) : !0;
|
|
28
|
+
}, validateUnsubscribeBlockHasTemplate: (n) => {
|
|
29
|
+
const o = new DOMParser().parseFromString(n, "text/html");
|
|
30
|
+
return Array.from(o.querySelectorAll(l)).some((t) => {
|
|
31
|
+
const e = t.getAttribute(a.PAGE_TYPE), r = t.getAttribute(a.PAGE_LIST);
|
|
32
|
+
return !e || !r;
|
|
33
|
+
}) ? (c({
|
|
34
|
+
type: i.Warning,
|
|
35
|
+
message: p(b)
|
|
27
36
|
}), !1) : !0;
|
|
28
37
|
} };
|
|
29
38
|
};
|
|
30
39
|
export {
|
|
31
|
-
|
|
40
|
+
P as useUnsubscribeBlockValidator
|
|
32
41
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { stripFontTags as
|
|
2
|
-
const
|
|
1
|
+
import { stripFontTags as p } from "../../utils/stripFontTags.js";
|
|
2
|
+
const d = [
|
|
3
3
|
{
|
|
4
4
|
id: "fix-url-encoding-start",
|
|
5
5
|
description: "Replace {%22 with %7B%22 to fix URL encoding",
|
|
@@ -58,7 +58,7 @@ const l = [
|
|
|
58
58
|
id: "strip-font-tags",
|
|
59
59
|
description: 'Unwrap browser-translate-injected <font dir="auto"> tags, keeping inner content; other <font> elements are left intact.',
|
|
60
60
|
type: "custom",
|
|
61
|
-
processor: (e) =>
|
|
61
|
+
processor: (e) => p(e),
|
|
62
62
|
priority: 15
|
|
63
63
|
},
|
|
64
64
|
{
|
|
@@ -99,7 +99,7 @@ const l = [
|
|
|
99
99
|
description: "Adding MSO Conditions",
|
|
100
100
|
type: "custom",
|
|
101
101
|
processor: (e) => {
|
|
102
|
-
const
|
|
102
|
+
const t = [
|
|
103
103
|
`<!--[if gte mso 9]>
|
|
104
104
|
<style>sup {
|
|
105
105
|
font-size: 100% !important;
|
|
@@ -119,13 +119,13 @@ const l = [
|
|
|
119
119
|
<w:DontUseAdvancedTypographyReadingMail></w:DontUseAdvancedTypographyReadingMail>
|
|
120
120
|
</w:WordDocument>
|
|
121
121
|
</xml><![endif]-->`
|
|
122
|
-
],
|
|
122
|
+
], i = /<head>([\S\s]*)<\/head>/, o = new RegExp(i);
|
|
123
123
|
if (!e.match(o))
|
|
124
124
|
return e;
|
|
125
|
-
let
|
|
126
|
-
return
|
|
127
|
-
|
|
128
|
-
}),
|
|
125
|
+
let s = e;
|
|
126
|
+
return t.forEach((r) => {
|
|
127
|
+
s = s.replace("</head>", `${r}</head>`);
|
|
128
|
+
}), s;
|
|
129
129
|
},
|
|
130
130
|
priority: 30
|
|
131
131
|
},
|
|
@@ -146,8 +146,36 @@ const l = [
|
|
|
146
146
|
replacement: "email-static.useinsider.com",
|
|
147
147
|
replaceAll: !0,
|
|
148
148
|
priority: 41
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
id: "convert-rgb-to-hex",
|
|
152
|
+
// SD-142395: rgb()/6-digit hex are verbose; hex/3-digit shorthand is byte-identical
|
|
153
|
+
// to render. Shrinks the whole email to stay under Gmail's ~102KB clip threshold.
|
|
154
|
+
// Leaves rgba()/8-digit hex (alpha) untouched.
|
|
155
|
+
description: "Convert rgb() colors to hex and collapse 6-digit hex to shorthand",
|
|
156
|
+
type: "custom",
|
|
157
|
+
processor: (e) => {
|
|
158
|
+
const t = (i) => i.toString(16).padStart(2, "0");
|
|
159
|
+
return e.replace(/rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)/gi, (i, o, n, s) => {
|
|
160
|
+
const [r, a, c] = [Number(o), Number(n), Number(s)];
|
|
161
|
+
return r > 255 || a > 255 || c > 255 ? i : `#${t(r)}${t(a)}${t(c)}`;
|
|
162
|
+
}).replace(/#([0-9a-f])\1([0-9a-f])\2([0-9a-f])\3\b/gi, "#$1$2$3");
|
|
163
|
+
},
|
|
164
|
+
priority: 44
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
id: "remove-contenteditable",
|
|
168
|
+
// SD-142395: contenteditable is a Stripo editor flag with zero effect in a
|
|
169
|
+
// delivered email. Stripping it globally shaves bytes off every text block,
|
|
170
|
+
// helping the whole email stay under Gmail's ~102KB clip threshold.
|
|
171
|
+
description: "Strip editor-only contenteditable attributes from compiled output",
|
|
172
|
+
type: "regex",
|
|
173
|
+
pattern: '\\s+contenteditable="[^"]*"',
|
|
174
|
+
replacement: "",
|
|
175
|
+
flags: "g",
|
|
176
|
+
priority: 45
|
|
149
177
|
}
|
|
150
178
|
];
|
|
151
179
|
export {
|
|
152
|
-
|
|
180
|
+
d as defaultHtmlCompilerRules
|
|
153
181
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { useRecommendation as
|
|
2
|
-
import { DUMMY_IMAGE_MAPPINGS as
|
|
3
|
-
import { prepareRecommendationBlocks as
|
|
4
|
-
const
|
|
1
|
+
import { useRecommendation as N } from "../../composables/useRecommendation.js";
|
|
2
|
+
import { DUMMY_IMAGE_MAPPINGS as M, REGEX as d, VerticalOrientation as $, CSS as n, ATTRIBUTES as p, CONDITIONS as T, HTML as g } from "../../enums/recommendation.js";
|
|
3
|
+
import { prepareRecommendationBlocks as O } from "./utils/recommendationCompilerUtils.js";
|
|
4
|
+
const U = [
|
|
5
5
|
{
|
|
6
6
|
id: "replace-images-with-variable-names",
|
|
7
7
|
description: "Replacing dummy images with variable names in recommendation module",
|
|
8
8
|
type: "custom",
|
|
9
|
-
processor: (
|
|
10
|
-
let e =
|
|
11
|
-
return Object.entries(
|
|
12
|
-
Object.entries(
|
|
13
|
-
e = e.replaceAll(
|
|
9
|
+
processor: (o) => {
|
|
10
|
+
let e = o;
|
|
11
|
+
return Object.entries(M).forEach(([, r]) => {
|
|
12
|
+
Object.entries(r).forEach(([t, i]) => {
|
|
13
|
+
e = e.replaceAll(i, `{{${t}}}`);
|
|
14
14
|
});
|
|
15
15
|
}), e;
|
|
16
16
|
},
|
|
@@ -41,21 +41,21 @@ const w = [
|
|
|
41
41
|
id: "add-recommendation-unresponsive-css",
|
|
42
42
|
description: "Adding recommendation unresponsive css",
|
|
43
43
|
type: "custom",
|
|
44
|
-
processor: (
|
|
45
|
-
const { calculateCardWidth: e, getRecommendationCampaignData:
|
|
46
|
-
let
|
|
47
|
-
const
|
|
48
|
-
if (
|
|
49
|
-
const
|
|
50
|
-
if (
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
}),
|
|
54
|
-
const
|
|
55
|
-
|
|
44
|
+
processor: (o) => {
|
|
45
|
+
const { calculateCardWidth: e, getRecommendationCampaignData: r } = N();
|
|
46
|
+
let t = o;
|
|
47
|
+
const i = t.match(d.ID);
|
|
48
|
+
if (i) {
|
|
49
|
+
const s = [];
|
|
50
|
+
if (i.forEach((c) => {
|
|
51
|
+
const m = /recommendation-id="(.*?)"/i.exec(c), E = m ? m[1].trim() : "", u = r(E);
|
|
52
|
+
u.textTrimming && u.orientation === $ && s.push(e(u));
|
|
53
|
+
}), s.length) {
|
|
54
|
+
const c = `width:${Math.min(...s)}px!important;`;
|
|
55
|
+
t = t.replace(n.REGULAR_NAME_HEIGHT, `${n.TRIMMED_NAME_HEIGHT} ${c} ${n.ELLIPSIS}`).replace(n.REGULAR_NAME_CONTAINER_HEIGHT, n.TRIMMED_NAME_CONTAINER_CSS).replace(n.RESPONSIVE_NAME_SIZE, `${n.RESPONSIVE_NAME_HEIGHT} ${c} ${n.ELLIPSIS}`).replace(n.RESPONSIVE_NAME_CONTAINER_HEIGHT, n.TRIMMED_RESPONSIVE_NAME_CONTAINER_CSS);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
return
|
|
58
|
+
return t;
|
|
59
59
|
},
|
|
60
60
|
priority: 52
|
|
61
61
|
},
|
|
@@ -63,34 +63,34 @@ const w = [
|
|
|
63
63
|
id: "prepare-recommendations",
|
|
64
64
|
description: "Replacing product data with template variables in recommendation blocks",
|
|
65
65
|
type: "custom",
|
|
66
|
-
processor: (
|
|
66
|
+
processor: (o) => O(o),
|
|
67
67
|
priority: 48
|
|
68
68
|
},
|
|
69
69
|
{
|
|
70
70
|
id: "add-discount-conditions",
|
|
71
71
|
description: "Adding discount conditions to the recommendation block",
|
|
72
72
|
type: "custom",
|
|
73
|
-
processor: (
|
|
74
|
-
let e =
|
|
75
|
-
const
|
|
76
|
-
return
|
|
77
|
-
const
|
|
78
|
-
if (!
|
|
73
|
+
processor: (o) => {
|
|
74
|
+
let e = o;
|
|
75
|
+
const r = e.match(d.ATTRIBUTE_PARAGRAPH), { getRecommendationCampaignData: t } = N();
|
|
76
|
+
return r !== null && r.forEach((i) => {
|
|
77
|
+
const s = i.match(d.CUSTOM_FIELD);
|
|
78
|
+
if (!s)
|
|
79
79
|
return;
|
|
80
|
-
const [
|
|
81
|
-
if (!
|
|
80
|
+
const [c] = s, m = c.match(d.CUSTOM_FIELD_INDEXES_PART), E = c.match(d.CUSTOM_FIELD_NAME_PART), u = i.match(d.ATTRIBUTE_PARAGRAPH_START_TAG);
|
|
81
|
+
if (!m || !E || !u)
|
|
82
82
|
return;
|
|
83
|
-
const [
|
|
84
|
-
let
|
|
85
|
-
if (
|
|
86
|
-
const
|
|
87
|
-
|
|
83
|
+
const [A] = m, [I] = E, [R] = u, b = I.substring(1, I.length - 2), S = R.match(d.COMPOSITION) !== null;
|
|
84
|
+
let a = c;
|
|
85
|
+
if (S) {
|
|
86
|
+
const f = A.substring(2, A.length - 3), l = t(f);
|
|
87
|
+
b === p.OMNIBUS_PRICE && (l.priceBeforeTextValue && (a = `${l.priceBeforeTextValue}${a}`), l.priceAfterTextValue && (a = `${a}${l.priceAfterTextValue}`)), b === p.OMNIBUS_DISCOUNT && (l.discountBeforeTextValue && (a = `${l.discountBeforeTextValue}${a}`), l.discountAfterTextValue && (a = `${a}${l.discountAfterTextValue}`));
|
|
88
88
|
}
|
|
89
|
-
const
|
|
90
|
-
let
|
|
91
|
-
|
|
92
|
-
const
|
|
93
|
-
e = e.replace(
|
|
89
|
+
const _ = A.substring(2);
|
|
90
|
+
let y = "";
|
|
91
|
+
b in T.IF && (y = T.IF[b].replaceAll(`{${p.DISCOUNT}}`, `${_}${p.DISCOUNT}`).replaceAll(`{${p.OMNIBUS_DISCOUNT}}`, `${_}${p.OMNIBUS_DISCOUNT}`).replaceAll(`{${p.OMNIBUS_PRICE}}`, `${_}${p.OMNIBUS_PRICE}`));
|
|
92
|
+
const C = `${R}${a}${g.PARAGRAPH_END_TAG}`, h = `${y}${S ? C : i}${T.ELSE}${R}${g.PARAGRAPH_END_TAG}${T.END_IF}`;
|
|
93
|
+
e = e.replace(i, h);
|
|
94
94
|
}), e;
|
|
95
95
|
},
|
|
96
96
|
priority: 53
|
|
@@ -110,11 +110,11 @@ const w = [
|
|
|
110
110
|
type: "custom",
|
|
111
111
|
// Scoped to REC_START/REC_END markers so it cannot strip `product-attr`
|
|
112
112
|
// from Items block elements, which the items compiler rule depends on.
|
|
113
|
-
processor: (
|
|
114
|
-
const e = /\s+(?:esd-extension-block-id|data-attribute-type|data-visibility|data-text-before|data-text-after|product-attr|composition)="[^"]*"/g;
|
|
115
|
-
return
|
|
113
|
+
processor: (o) => {
|
|
114
|
+
const e = /\s+(?:esd-extension-block-id|data-attribute-type|data-visibility|data-text-before|data-text-after|data-same-price|product-attr|composition)="[^"]*"/g;
|
|
115
|
+
return o.replace(
|
|
116
116
|
/<!--REC_START-->([\s\S]*?)<!--REC_END-->/g,
|
|
117
|
-
(
|
|
117
|
+
(r, t) => `<!--REC_START-->${t.replace(e, "")}<!--REC_END-->`
|
|
118
118
|
);
|
|
119
119
|
},
|
|
120
120
|
priority: 55
|
|
@@ -123,8 +123,8 @@ const w = [
|
|
|
123
123
|
id: "strip-unused-recommendation-classes",
|
|
124
124
|
description: "Remove CSS classes not referenced by any style rule from recommendation elements",
|
|
125
125
|
type: "custom",
|
|
126
|
-
processor: (
|
|
127
|
-
let e =
|
|
126
|
+
processor: (o) => {
|
|
127
|
+
let e = o.replace(
|
|
128
128
|
/ class="(?:product-card-segment|attribute-cell|recommendation-attribute-row|product-image|product-name|product-price|product-old-price|product-omnibus-price|product-omnibus-discount|product-button|recommendation-product-row|product-card-wrapper)"/g,
|
|
129
129
|
""
|
|
130
130
|
);
|
|
@@ -136,8 +136,8 @@ const w = [
|
|
|
136
136
|
id: "remove-empty-mobile-layout-artifacts",
|
|
137
137
|
description: "Remove empty mobile container rows and unused mobile layout CSS",
|
|
138
138
|
type: "custom",
|
|
139
|
-
processor: (
|
|
140
|
-
let e =
|
|
139
|
+
processor: (o) => {
|
|
140
|
+
let e = o;
|
|
141
141
|
return e = e.replace(
|
|
142
142
|
/<tr[^>]*class="ins-recommendation-mobile-row"[^>]*><\/tr>/g,
|
|
143
143
|
""
|
|
@@ -146,75 +146,50 @@ const w = [
|
|
|
146
146
|
""
|
|
147
147
|
), e = e.replace(
|
|
148
148
|
/@media[^{]*max-width\s*:\s*480px[^{]*\{((?:[^{}]*\{[^{}]*\})*[^{}]*)\}/g,
|
|
149
|
-
(
|
|
150
|
-
const
|
|
151
|
-
return
|
|
149
|
+
(r, t) => {
|
|
150
|
+
const i = t.match(/[^{}]+\{[^{}]*\}/g) || [], s = /ins-recommendation|product-image-cell|button-cell|product-info-cell/;
|
|
151
|
+
return i.every((m) => s.test(m)) ? "" : r;
|
|
152
152
|
}
|
|
153
153
|
)), e;
|
|
154
154
|
},
|
|
155
155
|
priority: 57
|
|
156
156
|
},
|
|
157
157
|
{
|
|
158
|
-
id: "
|
|
159
|
-
|
|
158
|
+
id: "protect-gmail-button-link-color",
|
|
159
|
+
// Gmail overrides link colors with `.ii a[href] { color: #15c }`. Force
|
|
160
|
+
// `!important` on es-button anchor colors so the intended button text color
|
|
161
|
+
// wins. Kept INLINE (never moved into a <style> class) so it survives Gmail's
|
|
162
|
+
// clipping — "view entire message" strips <style> blocks but keeps inline styles.
|
|
163
|
+
// (SD-142395: split out of the removed deduplicate-inline-styles rule.)
|
|
164
|
+
description: "Force !important on es-button link color to defeat Gmail link-color override",
|
|
160
165
|
type: "custom",
|
|
161
|
-
processor: (
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
(
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
), l = /<!--REC_START-->([\s\S]*?)<!--REC_END-->/g, n = / style="([^"]*)"/g, s = /* @__PURE__ */ new Map();
|
|
169
|
-
let a = l.exec(e);
|
|
170
|
-
for (; a !== null; ) {
|
|
171
|
-
let o = n.exec(a[1]);
|
|
172
|
-
for (; o !== null; ) {
|
|
173
|
-
const [, r] = o;
|
|
174
|
-
s.set(r, (s.get(r) || 0) + 1), o = n.exec(a[1]);
|
|
175
|
-
}
|
|
176
|
-
n.lastIndex = 0, a = l.exec(e);
|
|
177
|
-
}
|
|
178
|
-
const i = /* @__PURE__ */ new Map(), u = [];
|
|
179
|
-
let _ = 0;
|
|
180
|
-
if (s.forEach((o, r) => {
|
|
181
|
-
if (!r.includes("v-text-anchor") && o >= 6) {
|
|
182
|
-
const t = `rc${_++}`, p = r.endsWith(";") ? r : `${r};`;
|
|
183
|
-
i.set(r, t), u.push(`.${t}{${p}}`);
|
|
184
|
-
}
|
|
185
|
-
}), i.size === 0) {
|
|
186
|
-
let o = e;
|
|
187
|
-
return o = o.replaceAll("<!--REC_START-->", ""), o = o.replaceAll("<!--REC_END-->", ""), o;
|
|
188
|
-
}
|
|
189
|
-
const R = (o) => o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), b = (o, r) => `${o.slice(0, -1)} ${r}"`, I = /* @__PURE__ */ new Map();
|
|
190
|
-
i.forEach((o, r) => {
|
|
191
|
-
const t = R(r);
|
|
192
|
-
I.set(r, {
|
|
193
|
-
caseA: new RegExp(`(class="[^"]*")((?:[^>]*?)) style="${t}"`, "g"),
|
|
194
|
-
caseB: new RegExp(` style="${t}"((?:[^>]*?))(class="[^"]*")`, "g")
|
|
195
|
-
});
|
|
196
|
-
});
|
|
197
|
-
let d = e.replace("</style>", `${u.join("")}</style>`);
|
|
198
|
-
return d = d.replace(
|
|
199
|
-
/<!--REC_START-->([\s\S]*?)<!--REC_END-->/g,
|
|
200
|
-
(o, r) => {
|
|
201
|
-
let t = r;
|
|
202
|
-
return i.forEach((p, f) => {
|
|
203
|
-
const g = I.get(f);
|
|
204
|
-
t = t.replace(
|
|
205
|
-
g.caseA,
|
|
206
|
-
($, S, m) => b(S, p) + m
|
|
207
|
-
), t = t.replace(
|
|
208
|
-
g.caseB,
|
|
209
|
-
($, S, m) => S + b(m, p)
|
|
210
|
-
), t = t.replaceAll(` style="${f}"`, ` class="${p}"`);
|
|
211
|
-
}), t;
|
|
212
|
-
}
|
|
213
|
-
), d = d.replaceAll("<!--REC_START-->", ""), d = d.replaceAll("<!--REC_END-->", ""), d;
|
|
214
|
-
},
|
|
166
|
+
processor: (o) => o.replace(
|
|
167
|
+
/<a\b[^>]*\bes-button\b[^>]*>/g,
|
|
168
|
+
(e) => e.replace(
|
|
169
|
+
/([;"]color:)([^;"]+)/g,
|
|
170
|
+
(r, t, i) => i.includes("!important") ? r : `${t}${i} !important`
|
|
171
|
+
)
|
|
172
|
+
),
|
|
215
173
|
priority: 58
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
id: "minify-recommendation-whitespace",
|
|
177
|
+
// SD-142395: shrink the compiled recommendation block to keep emails under
|
|
178
|
+
// Gmail's ~102KB clip threshold. The editor templates emit deeply-indented
|
|
179
|
+
// markup that the P48 DOMParser round-trip preserves, and nothing else in the
|
|
180
|
+
// pipeline minifies it. Scoped to REC_START/REC_END so it only touches
|
|
181
|
+
// recommendation markup, and strips those markers last (relocated here from the
|
|
182
|
+
// removed deduplicate-inline-styles rule). Render-critical styles are left inline
|
|
183
|
+
// rather than classed, so they survive Gmail clipping.
|
|
184
|
+
description: "Collapse whitespace inside recommendation blocks and strip boundary markers",
|
|
185
|
+
type: "custom",
|
|
186
|
+
processor: (o) => {
|
|
187
|
+
const e = (r) => r.replace(/>\s+</g, "><").replace(/<[^>]+>/g, (t) => t.replace(/\s+/g, " "));
|
|
188
|
+
return o.replace(/<!--REC_START-->([\s\S]*?)<!--REC_END-->/g, (r, t) => e(t)).replaceAll("<!--REC_START-->", "").replaceAll("<!--REC_END-->", "");
|
|
189
|
+
},
|
|
190
|
+
priority: 99
|
|
216
191
|
}
|
|
217
192
|
];
|
|
218
193
|
export {
|
|
219
|
-
|
|
194
|
+
U as recommendationCompilerRules
|
|
220
195
|
};
|