@useinsider/guido 3.24.0-beta.88c24c1 → 3.24.0-beta.8e9f4e2
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/README.md +6 -2
- package/dist/@types/config/schemas.js +9 -11
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +1 -1
- package/dist/composables/useActionsApi.js +2 -2
- package/dist/composables/useEditorTrackingIds.js +49 -0
- package/dist/composables/useHtmlCompiler.js +2 -0
- package/dist/composables/useSave.js +52 -57
- package/dist/composables/useSaveValidation.js +110 -118
- package/dist/composables/useStripo.js +70 -70
- package/dist/composables/validators/useUnsubscribeBlockValidator.js +33 -48
- package/dist/config/compiler/htmlCompilerRules.js +14 -6
- package/dist/config/migrator/recommendation/inferLegacyConfig.js +133 -0
- package/dist/config/migrator/recommendationMigrator.js +69 -63
- package/dist/enums/save-validation.js +1 -1
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +10 -8
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +28 -24
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +23 -22
- package/dist/guido.css +1 -1
- package/dist/package.json.js +4 -4
- package/dist/services/templateLibraryApi.js +39 -36
- package/dist/src/@types/config/schemas.d.ts +0 -4
- package/dist/src/composables/useConfig.d.ts +0 -2
- package/dist/src/composables/useEditorTrackingIds.d.ts +7 -0
- package/dist/src/composables/useSaveValidation.d.ts +1 -1
- package/dist/src/composables/useStripo.d.ts +1 -1
- package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +0 -4
- package/dist/src/config/migrator/recommendation/inferLegacyConfig.d.ts +6 -0
- package/dist/src/config/migrator/recommendation/parseLegacyConfig.d.ts +1 -1
- package/dist/src/config/migrator/recommendationMigrator.d.ts +1 -5
- package/dist/src/enums/save-validation.d.ts +1 -2
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +2 -0
- package/dist/src/stores/config.d.ts +0 -20
- package/dist/src/utils/linkTrackingIds.d.ts +19 -0
- package/dist/src/utils/trimHrefWhitespace.d.ts +5 -0
- package/dist/utils/linkTrackingIds.js +82 -48
- package/dist/utils/templatePreparation.js +30 -33
- package/dist/utils/trimHrefWhitespace.js +10 -0
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ToasterTypeOptions as
|
|
2
|
-
import {
|
|
3
|
-
import { UNSUBSCRIBE_BLOCK_SELECTOR as
|
|
4
|
-
import { useToaster as
|
|
5
|
-
import { useTranslations as
|
|
1
|
+
import { ToasterTypeOptions as c } from "../../enums/toaster.js";
|
|
2
|
+
import { PAGE_TYPES as u } from "../../enums/unsubscribe.js";
|
|
3
|
+
import { UNSUBSCRIBE_BLOCK_SELECTOR as i, DATA_ATTRIBUTES as a } from "../../extensions/Blocks/Unsubscribe/utils/constants.js";
|
|
4
|
+
import { useToaster as p } from "../useToaster.js";
|
|
5
|
+
import { useTranslations as l } from "../useTranslations.js";
|
|
6
6
|
const T = [
|
|
7
7
|
{
|
|
8
8
|
pageType: u.GLOBAL_UNSUBSCRIBE,
|
|
@@ -12,52 +12,37 @@ const T = [
|
|
|
12
12
|
pageType: u.SUBSCRIPTION_PREFERENCE_CENTER,
|
|
13
13
|
messageKey: "unsubscription-preference.duplicate-pref-center"
|
|
14
14
|
}
|
|
15
|
-
], g = "unsubscription-preference.duplicate-both",
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
)
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
], g = "unsubscription-preference.duplicate-both", E = "unsubscription-preference.select-page-to-continue";
|
|
16
|
+
function m(r) {
|
|
17
|
+
const s = new DOMParser().parseFromString(r, "text/html"), t = /* @__PURE__ */ new Map();
|
|
18
|
+
return s.querySelectorAll(i).forEach((n) => {
|
|
19
|
+
const e = Number(n.getAttribute(a.PAGE_TYPE));
|
|
20
|
+
t.set(e, (t.get(e) ?? 0) + 1);
|
|
21
|
+
}), T.filter((n) => (t.get(n.pageType) ?? 0) > 1);
|
|
21
22
|
}
|
|
22
|
-
function
|
|
23
|
-
const
|
|
24
|
-
return
|
|
25
|
-
const n =
|
|
26
|
-
|
|
27
|
-
}), T.filter((r) => (s.get(r.pageType) ?? 0) > 1);
|
|
28
|
-
}
|
|
29
|
-
function B(e) {
|
|
30
|
-
const t = new DOMParser().parseFromString(e, "text/html");
|
|
31
|
-
return Array.from(t.querySelectorAll(l)).filter((s) => {
|
|
32
|
-
const r = s.getAttribute(c.PAGE_TYPE), n = s.getAttribute(c.PAGE_LIST);
|
|
33
|
-
return !r || !n;
|
|
23
|
+
function b(r) {
|
|
24
|
+
const s = new DOMParser().parseFromString(r, "text/html");
|
|
25
|
+
return Array.from(s.querySelectorAll(i)).filter((t) => {
|
|
26
|
+
const n = t.getAttribute(a.PAGE_TYPE), e = t.getAttribute(a.PAGE_LIST);
|
|
27
|
+
return !n || !e;
|
|
34
28
|
}).length;
|
|
35
29
|
}
|
|
36
|
-
const
|
|
37
|
-
const { showToaster:
|
|
38
|
-
return {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
message: t(_)
|
|
49
|
-
}), !1),
|
|
50
|
-
validateNoInsiderUnsubscribeCode: (o, a = !1) => S(o) ? (a || e({
|
|
51
|
-
type: i.Warning,
|
|
52
|
-
message: t(m)
|
|
53
|
-
}), !1) : !0
|
|
54
|
-
};
|
|
30
|
+
const y = () => {
|
|
31
|
+
const { showToaster: r } = p(), s = l();
|
|
32
|
+
return { validateUnsubscribeBlockUniqueness: (e) => {
|
|
33
|
+
const o = m(e);
|
|
34
|
+
return o.length ? (r({
|
|
35
|
+
type: c.Error,
|
|
36
|
+
message: s(o.length > 1 ? g : o[0].messageKey)
|
|
37
|
+
}), !1) : !0;
|
|
38
|
+
}, validateUnsubscribeBlockHasTemplate: (e) => b(e) === 0 ? !0 : (r({
|
|
39
|
+
type: c.Warning,
|
|
40
|
+
message: s(E)
|
|
41
|
+
}), !1) };
|
|
55
42
|
};
|
|
56
43
|
export {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
S as hasInsiderUnsubscribeCode,
|
|
62
|
-
I as useUnsubscribeBlockValidator
|
|
44
|
+
E as EMPTY_BLOCK_KEY,
|
|
45
|
+
b as countUnsubBlocksWithoutPage,
|
|
46
|
+
m as findDuplicateUnsubPageTypes,
|
|
47
|
+
y as useUnsubscribeBlockValidator
|
|
63
48
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { stripFontTags as
|
|
2
|
-
|
|
1
|
+
import { stripFontTags as c } from "../../utils/stripFontTags.js";
|
|
2
|
+
import { trimHrefWhitespace as l } from "../../utils/trimHrefWhitespace.js";
|
|
3
|
+
const f = [
|
|
3
4
|
{
|
|
4
5
|
id: "fix-url-encoding-start",
|
|
5
6
|
description: "Replace {%22 with %7B%22 to fix URL encoding",
|
|
@@ -58,9 +59,16 @@ const d = [
|
|
|
58
59
|
id: "strip-font-tags",
|
|
59
60
|
description: 'Unwrap browser-translate-injected <font dir="auto"> tags, keeping inner content; other <font> elements are left intact.',
|
|
60
61
|
type: "custom",
|
|
61
|
-
processor: (e) =>
|
|
62
|
+
processor: (e) => c(e),
|
|
62
63
|
priority: 15
|
|
63
64
|
},
|
|
65
|
+
{
|
|
66
|
+
id: "trim-href-whitespace",
|
|
67
|
+
description: "Trim leading/trailing whitespace and from every href value",
|
|
68
|
+
type: "custom",
|
|
69
|
+
processor: (e) => l(e),
|
|
70
|
+
priority: 16
|
|
71
|
+
},
|
|
64
72
|
{
|
|
65
73
|
id: "remove-apty-iframe",
|
|
66
74
|
description: "Cleanup Apty Iframe Code",
|
|
@@ -157,8 +165,8 @@ const d = [
|
|
|
157
165
|
processor: (e) => {
|
|
158
166
|
const t = (i) => i.toString(16).padStart(2, "0");
|
|
159
167
|
return e.replace(/rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)/gi, (i, o, n, r) => {
|
|
160
|
-
const [s, a,
|
|
161
|
-
return s > 255 || a > 255 ||
|
|
168
|
+
const [s, a, p] = [Number(o), Number(n), Number(r)];
|
|
169
|
+
return s > 255 || a > 255 || p > 255 ? i : `#${t(s)}${t(a)}${t(p)}`;
|
|
162
170
|
}).replace(/#([0-9a-f])\1([0-9a-f])\2([0-9a-f])\3\b/gi, "#$1$2$3");
|
|
163
171
|
},
|
|
164
172
|
priority: 44
|
|
@@ -200,5 +208,5 @@ const d = [
|
|
|
200
208
|
}
|
|
201
209
|
];
|
|
202
210
|
export {
|
|
203
|
-
|
|
211
|
+
f as defaultHtmlCompilerRules
|
|
204
212
|
};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { MAX_PRODUCTS_PER_ROW as _ } from "../../../extensions/Blocks/Recommendation/constants/layout.js";
|
|
2
|
+
const T = "td.product-card", x = '[class*="ext-product-"]', d = ".ext-ins-attr p[product-attr]", y = ".ext-ins-attr", S = ["font-family", "font-size", "font-weight", "font-style"], l = [
|
|
3
|
+
["p_image", ".ext-product-image"],
|
|
4
|
+
["p_name", ".ext-product-name"],
|
|
5
|
+
["p_price", ".ext-product-price"],
|
|
6
|
+
["p_original_price", ".ext-product-original-price"],
|
|
7
|
+
["p_omnibus_price", ".ext-product-omnibus-price", !0],
|
|
8
|
+
["p_omnibus_discount", ".ext-product-omnibus-discount", !0],
|
|
9
|
+
["p_button", ".ext-product-button"]
|
|
10
|
+
], a = l.map(([, t]) => t).join(", ");
|
|
11
|
+
function s(t, e) {
|
|
12
|
+
const n = new RegExp(`(?:^|;)\\s*${e}\\s*:\\s*([^;]+)`, "i"), r = ((t == null ? void 0 : t.getAttribute("style")) ?? "").match(n);
|
|
13
|
+
return (r == null ? void 0 : r[1].trim()) || void 0;
|
|
14
|
+
}
|
|
15
|
+
function p(t) {
|
|
16
|
+
return /^none\b/.test(s(t, "display") ?? "");
|
|
17
|
+
}
|
|
18
|
+
function h(t) {
|
|
19
|
+
return p(t) || p(t.closest("tr"));
|
|
20
|
+
}
|
|
21
|
+
function f(t) {
|
|
22
|
+
const e = {};
|
|
23
|
+
return S.forEach((n) => {
|
|
24
|
+
const r = s(t, n);
|
|
25
|
+
r && (e[n] = r);
|
|
26
|
+
}), Object.keys(e).length > 0 ? e : void 0;
|
|
27
|
+
}
|
|
28
|
+
function g(t) {
|
|
29
|
+
return Object.keys(t).length > 0 ? t : void 0;
|
|
30
|
+
}
|
|
31
|
+
function m(t) {
|
|
32
|
+
const e = t.querySelector("p") ?? t, n = f(e), r = s(e, "color"), i = t.getAttribute("align") ?? s(e, "text-align"), o = s(e, "line-height");
|
|
33
|
+
return g({
|
|
34
|
+
...n ? { textStyle: n } : {},
|
|
35
|
+
...r ? { textColor: { color: r } } : {},
|
|
36
|
+
...i ? { textAlign: { align: i } } : {},
|
|
37
|
+
...o ? { textLineSpacing: { lineSpacing: o } } : {}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function A(t) {
|
|
41
|
+
var u;
|
|
42
|
+
const e = t.querySelector("a") ?? t, n = (u = e.textContent) == null ? void 0 : u.trim(), r = s(e, "background-color") ?? s(e, "background"), i = s(e, "color"), o = f(e), c = t.getAttribute("align");
|
|
43
|
+
return g({
|
|
44
|
+
...n ? { buttonText: { text: n } } : {},
|
|
45
|
+
...r ? { buttonColor: { color: r } } : {},
|
|
46
|
+
...i ? { textButtonColor: { color: i } } : {},
|
|
47
|
+
...o ? { buttonStyle: o } : {},
|
|
48
|
+
...c ? { buttonAlign: { align: c } } : {}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function C(t) {
|
|
52
|
+
const e = t.querySelector("img"), n = Number(e == null ? void 0 : e.getAttribute("width")), r = Number(e == null ? void 0 : e.getAttribute("height")), i = { ...n > 0 ? { width: n } : {}, ...r > 0 ? { height: r } : {} };
|
|
53
|
+
return Object.keys(i).length > 0 ? { imageSize: i } : void 0;
|
|
54
|
+
}
|
|
55
|
+
function R(t, e) {
|
|
56
|
+
switch (t) {
|
|
57
|
+
case "p_image":
|
|
58
|
+
return C(e);
|
|
59
|
+
case "p_button":
|
|
60
|
+
return A(e);
|
|
61
|
+
default:
|
|
62
|
+
return m(e);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function L(t, e) {
|
|
66
|
+
const n = Array.from(t.querySelectorAll(`[class*="show-recommendation-${e}-"]`));
|
|
67
|
+
return n.length > 0 ? n : Array.from(t.querySelectorAll(T));
|
|
68
|
+
}
|
|
69
|
+
function w(t, e) {
|
|
70
|
+
const n = (o) => e.filter((c) => o.contains(c)).length;
|
|
71
|
+
let r = e[0].parentElement;
|
|
72
|
+
for (; r && r !== t && n(r) < 2; )
|
|
73
|
+
r = r.parentElement;
|
|
74
|
+
if (!r || r === t)
|
|
75
|
+
return e.length === 1 ? 1 : void 0;
|
|
76
|
+
const i = r.tagName === "TBODY" || r.tagName === "TABLE" ? 1 : n(r);
|
|
77
|
+
return Math.min(i, _);
|
|
78
|
+
}
|
|
79
|
+
function v(t) {
|
|
80
|
+
const e = Array.from(t.querySelectorAll(x)).filter((n) => !n.matches(a) && !n.closest(a) && !n.querySelector(a)).flatMap((n) => Array.from(n.classList).filter((r) => r.startsWith("ext-product-")));
|
|
81
|
+
return [...new Set(e)];
|
|
82
|
+
}
|
|
83
|
+
function O(t, e, n) {
|
|
84
|
+
const r = t.closest(y) ?? t, i = m(r);
|
|
85
|
+
return {
|
|
86
|
+
variable: `p_attribute_${e}`,
|
|
87
|
+
variableType: "p_attribute",
|
|
88
|
+
value: t.getAttribute("product-attr") ?? "",
|
|
89
|
+
positionIdx: n,
|
|
90
|
+
hidden: h(r),
|
|
91
|
+
...i ? { theme: i } : {}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function N(t) {
|
|
95
|
+
const e = /* @__PURE__ */ new Set(), n = [];
|
|
96
|
+
let r = 0;
|
|
97
|
+
t.querySelectorAll(`${a}, ${d}`).forEach((o) => {
|
|
98
|
+
if (o.matches(d)) {
|
|
99
|
+
n.push(O(o, r, n.length)), r += 1;
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const c = l.find(
|
|
103
|
+
([b, E]) => !e.has(b) && o.matches(E)
|
|
104
|
+
);
|
|
105
|
+
if (!c)
|
|
106
|
+
return;
|
|
107
|
+
const u = R(c[0], o);
|
|
108
|
+
e.add(c[0]), n.push({
|
|
109
|
+
variable: c[0],
|
|
110
|
+
positionIdx: n.length,
|
|
111
|
+
hidden: h(o),
|
|
112
|
+
...u ? { theme: u } : {}
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
const i = l.filter(([o, , c]) => !c && !e.has(o)).map(([o]) => ({ variable: o, hidden: !0 }));
|
|
116
|
+
return [...n, ...i];
|
|
117
|
+
}
|
|
118
|
+
function q(t, e) {
|
|
119
|
+
const n = L(t, e);
|
|
120
|
+
if (n.length === 0)
|
|
121
|
+
return null;
|
|
122
|
+
const r = v(n[0]);
|
|
123
|
+
return r.length > 0 ? (console.warn(
|
|
124
|
+
`[RecommendationMigrator] Block id=${e} — legacy card cells the rebuild cannot map: ${r.join(", ")}`
|
|
125
|
+
), null) : {
|
|
126
|
+
totalCount: n.length,
|
|
127
|
+
rowCount: w(t, n),
|
|
128
|
+
composition: { variables: N(n[0]) }
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
export {
|
|
132
|
+
q as inferLegacyConfig
|
|
133
|
+
};
|
|
@@ -1,59 +1,63 @@
|
|
|
1
|
-
import { BlockId as
|
|
2
|
-
import { DEFAULT_NODE_CONFIG as
|
|
3
|
-
import { ATTR_RECOMMENDATION_TITLE as
|
|
4
|
-
import { useTemplateStore as
|
|
5
|
-
import { mapComposition as
|
|
6
|
-
import { isPriceOnNextLine as
|
|
7
|
-
import { buildBlockHtml as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { BlockId as R } from "../../enums/block.js";
|
|
2
|
+
import { DEFAULT_NODE_CONFIG as h } from "../../extensions/Blocks/Recommendation/constants/defaultConfig.js";
|
|
3
|
+
import { ATTR_RECOMMENDATION_TITLE as u } from "../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
4
|
+
import { useTemplateStore as x } from "../../stores/template.js";
|
|
5
|
+
import { mapComposition as b } from "./recommendation/compositionMapper.js";
|
|
6
|
+
import { isPriceOnNextLine as L, extractCurrencyFromBlock as A, isOldPriceFirst as E, withRenderedTextTheme as B, extractTitleText as O, hasEmptyTitle as S, hasVisibleTitle as w, extractCardBgColor as N, isPartnerManagedBlock as P, extractRenderedBlockPadding as H } from "./recommendation/extractors.js";
|
|
7
|
+
import { buildBlockHtml as I } from "./recommendation/htmlBuilder.js";
|
|
8
|
+
import { inferLegacyConfig as _ } from "./recommendation/inferLegacyConfig.js";
|
|
9
|
+
import { parseRecommendationId as F, parseLegacyConfig as $ } from "./recommendation/parseLegacyConfig.js";
|
|
10
|
+
import { mapSettings as D } from "./recommendation/settingsMapper.js";
|
|
11
|
+
import { mapBlockPadding as G } from "./recommendation/themeMapper.js";
|
|
12
|
+
const T = ":not(.recommendation-block-v2):not([esd-ext-config])", k = `td[class*="ins-recommendation-v3-block-"]${T}, td.product-block[esd-handler-name*="EmailRecommendationV3"]${T}`, U = "esd-dev-product-config";
|
|
13
|
+
function V(c, e, m) {
|
|
14
|
+
var p, g, f;
|
|
15
|
+
const t = F(e);
|
|
15
16
|
if (t === null)
|
|
16
17
|
return console.warn(
|
|
17
18
|
"[RecommendationMigrator] Skipping block — missing/invalid `ins-recommendation-v3-campaign-id`"
|
|
18
19
|
), !1;
|
|
19
|
-
const
|
|
20
|
-
if (!
|
|
20
|
+
const s = e.hasAttribute(U), a = s ? $(e) : _(e, t);
|
|
21
|
+
if (!a)
|
|
21
22
|
return console.warn(
|
|
22
|
-
`[RecommendationMigrator] Aborting block id=${t} — \`esd-dev-product-config\`
|
|
23
|
+
`[RecommendationMigrator] Aborting block id=${t} — \`esd-dev-product-config\` empty or unparsable, or the rendered markup could not be inferred`
|
|
23
24
|
), !1;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
),
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
s || console.info(
|
|
26
|
+
`[RecommendationMigrator] Block id=${t} has no \`esd-dev-product-config\` — rebuilt from its rendered markup`
|
|
27
|
+
);
|
|
28
|
+
const n = m[String(t)] ?? {}, r = {
|
|
29
|
+
...n,
|
|
30
|
+
currencySettings: n.currencySettings ?? A(e),
|
|
31
|
+
isPriceMovedToNextLine: n.isPriceMovedToNextLine ?? L(e)
|
|
32
|
+
}, i = D(r, a, t), o = b(
|
|
33
|
+
B((p = a.composition) == null ? void 0 : p.variables, e),
|
|
34
|
+
{ oldPriceFirst: E(e) }
|
|
35
|
+
), y = O(e);
|
|
36
|
+
S(e) ? o.visibility[u] = !1 : o.titleVariable || (o.visibility[u] = w(e));
|
|
37
|
+
const C = N(e), v = {
|
|
38
|
+
...i,
|
|
35
39
|
strategyId: "",
|
|
36
|
-
composition:
|
|
37
|
-
visibility:
|
|
38
|
-
previousTitleHtml:
|
|
39
|
-
textTrimming:
|
|
40
|
-
},
|
|
40
|
+
composition: o.composition,
|
|
41
|
+
visibility: o.visibility,
|
|
42
|
+
previousTitleHtml: h.previousTitleHtml,
|
|
43
|
+
textTrimming: o.anyTextTrimming
|
|
44
|
+
}, d = P(e), M = `
|
|
41
45
|
<table>
|
|
42
46
|
<tbody>
|
|
43
47
|
<tr>
|
|
44
48
|
<td class="esd-structure" align="left">
|
|
45
49
|
<table width="100%" cellpadding="0" cellspacing="0">
|
|
46
50
|
<tbody>
|
|
47
|
-
<tr>${
|
|
48
|
-
nodeConfig:
|
|
49
|
-
composition:
|
|
50
|
-
cardBg:
|
|
51
|
-
titleText:
|
|
51
|
+
<tr>${I({
|
|
52
|
+
nodeConfig: v,
|
|
53
|
+
composition: o,
|
|
54
|
+
cardBg: C,
|
|
55
|
+
titleText: y,
|
|
52
56
|
legacyId: e.getAttribute("id") ?? void 0,
|
|
53
57
|
legacyBgColor: e.getAttribute("bgcolor") ?? void 0,
|
|
54
|
-
preserveInnerHtml:
|
|
55
|
-
skipCompile:
|
|
56
|
-
blockPadding:
|
|
58
|
+
preserveInnerHtml: d ? e.innerHTML : void 0,
|
|
59
|
+
skipCompile: d,
|
|
60
|
+
blockPadding: G(((f = (g = a.theme) == null ? void 0 : g.blockPadding) == null ? void 0 : f.desktop) ?? H(e))
|
|
57
61
|
})}</tr>
|
|
58
62
|
</tbody>
|
|
59
63
|
</table>
|
|
@@ -61,40 +65,42 @@ function $(c, e, m) {
|
|
|
61
65
|
</tr>
|
|
62
66
|
</tbody>
|
|
63
67
|
</table>
|
|
64
|
-
`,
|
|
65
|
-
return !
|
|
68
|
+
`, l = c.parseFromString(M, "text/html").querySelector("td.esd-structure");
|
|
69
|
+
return !l || !e.parentNode ? (console.warn(
|
|
66
70
|
`[RecommendationMigrator] Aborting block id=${t} — failed to construct new HTML element`
|
|
67
|
-
), !1) : (e.parentNode.replaceChild(
|
|
71
|
+
), !1) : (e.parentNode.replaceChild(l, e), !0);
|
|
68
72
|
}
|
|
69
|
-
function
|
|
73
|
+
function oe(c, e = {}) {
|
|
70
74
|
const m = new DOMParser();
|
|
71
75
|
let t;
|
|
72
76
|
try {
|
|
73
77
|
t = m.parseFromString(c, "text/html");
|
|
74
|
-
} catch (
|
|
75
|
-
return console.error("[RecommendationMigrator] Failed to parse template:",
|
|
78
|
+
} catch (r) {
|
|
79
|
+
return console.error("[RecommendationMigrator] Failed to parse template:", r), c;
|
|
76
80
|
}
|
|
77
|
-
const
|
|
81
|
+
const s = Array.from(t.querySelectorAll(k)), a = s.filter((r) => {
|
|
82
|
+
var i;
|
|
83
|
+
return !((i = r.parentElement) != null && i.closest(".recommendation-block-v2")) && !s.some((o) => o !== r && o.contains(r));
|
|
84
|
+
});
|
|
85
|
+
let n = 0;
|
|
86
|
+
a.forEach((r) => {
|
|
87
|
+
try {
|
|
88
|
+
V(m, r, e) && (n += 1);
|
|
89
|
+
} catch (i) {
|
|
90
|
+
console.error("[RecommendationMigrator] Unexpected error migrating block:", i);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
78
93
|
try {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
...
|
|
82
|
-
[
|
|
94
|
+
x().$patch((i) => {
|
|
95
|
+
i.migrations = {
|
|
96
|
+
...i.migrations,
|
|
97
|
+
[R.Recommendation]: n
|
|
83
98
|
};
|
|
84
99
|
});
|
|
85
100
|
} catch {
|
|
86
101
|
}
|
|
87
|
-
|
|
88
|
-
return c;
|
|
89
|
-
let o = 0;
|
|
90
|
-
return r.forEach((n) => {
|
|
91
|
-
try {
|
|
92
|
-
$(m, n, e) && (o += 1);
|
|
93
|
-
} catch (a) {
|
|
94
|
-
console.error("[RecommendationMigrator] Unexpected error migrating block:", a);
|
|
95
|
-
}
|
|
96
|
-
}), o > 0 && console.info(`[RecommendationMigrator] Migrated ${o} legacy Recommendation block(s)`), t.documentElement.outerHTML;
|
|
102
|
+
return n === 0 ? c : (console.info(`[RecommendationMigrator] Migrated ${n} legacy Recommendation block(s)`), t.documentElement.outerHTML);
|
|
97
103
|
}
|
|
98
104
|
export {
|
|
99
|
-
|
|
105
|
+
oe as migrateRecommendation
|
|
100
106
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var n = /* @__PURE__ */ ((s) => (s.CouponTagModified = "coupon-tag-modified", s.DuplicateUnsubBlock = "duplicate-unsub-block", s.UnsubBlockMissingTemplate = "unsub-block-missing-template", s.LiquidSyntax = "liquid-syntax", s.InvalidLinks = "invalid-links", s.LinkCheckInProgress = "link-check-in-progress", s.CustomFieldScript = "custom-field-script", s.EmptyHtml = "empty-html", s.MismatchedBraces = "mismatched-braces", s.InvalidDynamicTag = "invalid-dynamic-tag", s.InvalidCustomField = "invalid-custom-field", s.ConditionsSyntax = "conditions-syntax", s.WrongEqualityOperator = "wrong-equality-operator", s.MissingIfEndif = "missing-if-endif", s.ConditionTagSpacing = "condition-tag-spacing", s.BracesInsideIfTag = "braces-inside-if-tag", s.RecommendationRequiredFields = "recommendation-required-fields", s.RecommendationFilters = "recommendation-filters", s.InvalidImageType = "invalid-image-type", s.CheckboxUnsubGroup = "checkbox-unsub-group", s.RadioButtonUnsubGroup = "radio-button-unsub-group", s
|
|
1
|
+
var n = /* @__PURE__ */ ((s) => (s.CouponTagModified = "coupon-tag-modified", s.DuplicateUnsubBlock = "duplicate-unsub-block", s.UnsubBlockMissingTemplate = "unsub-block-missing-template", s.LiquidSyntax = "liquid-syntax", s.InvalidLinks = "invalid-links", s.LinkCheckInProgress = "link-check-in-progress", s.CustomFieldScript = "custom-field-script", s.EmptyHtml = "empty-html", s.MismatchedBraces = "mismatched-braces", s.InvalidDynamicTag = "invalid-dynamic-tag", s.InvalidCustomField = "invalid-custom-field", s.ConditionsSyntax = "conditions-syntax", s.WrongEqualityOperator = "wrong-equality-operator", s.MissingIfEndif = "missing-if-endif", s.ConditionTagSpacing = "condition-tag-spacing", s.BracesInsideIfTag = "braces-inside-if-tag", s.RecommendationRequiredFields = "recommendation-required-fields", s.RecommendationFilters = "recommendation-filters", s.InvalidImageType = "invalid-image-type", s.CheckboxUnsubGroup = "checkbox-unsub-group", s.RadioButtonUnsubGroup = "radio-button-unsub-group", s))(n || {});
|
|
2
2
|
export {
|
|
3
3
|
n as SaveValidationRule
|
|
4
4
|
};
|
|
@@ -17,9 +17,9 @@ import { CurrencyControl as U } from "./currency.js";
|
|
|
17
17
|
import { CURRENCY_CONTROL_ID as Ie } from "./currency.js";
|
|
18
18
|
import { FiltersControl as v } from "./filters.js";
|
|
19
19
|
import { FILTERS_CONTROL_ID as ke } from "./filters.js";
|
|
20
|
-
import { LayoutOrientationControl as
|
|
20
|
+
import { LayoutOrientationControl as w } from "./layoutOrientation.js";
|
|
21
21
|
import { LAYOUT_ORIENTATION_CONTROL_ID as Oe } from "./layoutOrientation.js";
|
|
22
|
-
import { LocaleControl as
|
|
22
|
+
import { LocaleControl as A } from "./locale.js";
|
|
23
23
|
import { LOCALE_CONTROL_ID as Be } from "./locale.js";
|
|
24
24
|
import { PricePlacementControl as V } from "./pricePlacement.js";
|
|
25
25
|
import { PRICE_PLACEMENT_CONTROL_ID as Le } from "./pricePlacement.js";
|
|
@@ -28,7 +28,7 @@ import { PRODUCT_COUNT_CONTROL_ID as Ee } from "./productCount.js";
|
|
|
28
28
|
import { ProductLayoutControl as x } from "./productLayout.js";
|
|
29
29
|
import { PRODUCT_LAYOUT_CONTROL_ID as ve } from "./productLayout.js";
|
|
30
30
|
import { ShuffleControl as M } from "./shuffle.js";
|
|
31
|
-
import { SHUFFLE_CONTROL_ID as
|
|
31
|
+
import { SHUFFLE_CONTROL_ID as Ae } from "./shuffle.js";
|
|
32
32
|
import { StrategyControl as G } from "./strategy.js";
|
|
33
33
|
import { STRATEGY_CONTROL_ID as We } from "./strategy.js";
|
|
34
34
|
import { setCurrencyAttributes as $, getBlockElement as z, isPartnerManagedBlock as H, updateProductContentInPlace as Y, regenerateProductRowsWithStyles as j } from "./utils.js";
|
|
@@ -128,7 +128,7 @@ class _e extends I {
|
|
|
128
128
|
return this.rrsEnabled = f().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((t) => {
|
|
129
129
|
var o;
|
|
130
130
|
return (o = t == null ? void 0 : t.onDestroy) == null ? void 0 : o.call(t);
|
|
131
|
-
}), this.algorithmControl = new E(), this.localeControl = new
|
|
131
|
+
}), this.algorithmControl = new E(), this.localeControl = new A(), this.currencyControl = new U(), this.productCountControl = new W(), this.productLayoutControl = new x(), this.filtersControl = new v(), this.shuffleControl = new M(), this.pricePlacementControl = new V(), this.layoutOrientationControl = new w(), this.strategyControl = this.rrsEnabled ? new G() : null, this._subControls.forEach((t) => {
|
|
132
132
|
t && (t.api = this.api);
|
|
133
133
|
}), `
|
|
134
134
|
<div class="recommendation-controls-container">
|
|
@@ -452,7 +452,9 @@ class _e extends I {
|
|
|
452
452
|
e,
|
|
453
453
|
this._getNodeConfigUpdates(n.recommendationConfigs),
|
|
454
454
|
h
|
|
455
|
-
) && console.error("[recommendation] config write outside the panel did not reach a node", { blockId: e })
|
|
455
|
+
) && console.error("[recommendation] config write outside the panel did not reach a node", { blockId: e });
|
|
456
|
+
const s = o && n.drawnProducts !== n.recommendationProducts;
|
|
457
|
+
(i || s) && this._refreshOutsidePanel(e, i);
|
|
456
458
|
} catch (n) {
|
|
457
459
|
console.error("[recommendation] finishing the block outside the panel failed", n);
|
|
458
460
|
}
|
|
@@ -552,8 +554,8 @@ export {
|
|
|
552
554
|
v as FiltersControl,
|
|
553
555
|
Oe as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
554
556
|
Be as LOCALE_CONTROL_ID,
|
|
555
|
-
|
|
556
|
-
|
|
557
|
+
w as LayoutOrientationControl,
|
|
558
|
+
A as LocaleControl,
|
|
557
559
|
Le as PRICE_PLACEMENT_CONTROL_ID,
|
|
558
560
|
Ee as PRODUCT_COUNT_CONTROL_ID,
|
|
559
561
|
ve as PRODUCT_LAYOUT_CONTROL_ID,
|
|
@@ -561,7 +563,7 @@ export {
|
|
|
561
563
|
W as ProductCountControl,
|
|
562
564
|
x as ProductLayoutControl,
|
|
563
565
|
_e as RecommendationBlockControl,
|
|
564
|
-
|
|
566
|
+
Ae as SHUFFLE_CONTROL_ID,
|
|
565
567
|
We as STRATEGY_CONTROL_ID,
|
|
566
568
|
M as ShuffleControl,
|
|
567
569
|
G as StrategyControl,
|