@useinsider/guido 3.22.0-beta.e1b5da2 → 3.22.0-beta.e9b6f94
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 +35 -4
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +118 -108
- package/dist/composables/useEditorOpenMetrics.js +167 -0
- package/dist/composables/useStripo.js +93 -82
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +22 -22
- package/dist/config/migrator/recommendation/compositionMapper.js +49 -56
- package/dist/config/migrator/recommendation/extractors.js +40 -100
- package/dist/config/migrator/recommendation/htmlBuilder.js +207 -285
- package/dist/config/migrator/recommendation/settingsMapper.js +36 -37
- package/dist/config/migrator/recommendation/themeMapper.js +41 -53
- package/dist/config/migrator/recommendationMigrator.js +61 -68
- package/dist/config/migrator/unsubscribeMigrator.js +60 -87
- package/dist/extensions/Blocks/Recommendation/block.js +24 -33
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +19 -20
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +163 -148
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +22 -23
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +18 -19
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +91 -82
- package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMap.js +2 -3
- package/dist/guido.css +1 -1
- package/dist/library.js +12 -10
- package/dist/package.json.js +6 -4
- package/dist/public/prefetchRuntime.js +4 -0
- package/dist/src/composables/useEditorOpenMetrics.d.ts +27 -0
- package/dist/src/composables/useStripo.d.ts +2 -1
- package/dist/src/config/migrator/recommendation/compositionMapper.d.ts +1 -3
- package/dist/src/config/migrator/recommendation/extractors.d.ts +6 -35
- package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +1 -3
- package/dist/src/config/migrator/recommendation/themeMapper.d.ts +1 -3
- package/dist/src/config/migrator/recommendation/types.d.ts +1 -11
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +8 -2
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +13 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.d.ts +19 -2
- package/dist/src/library.d.ts +1 -0
- package/dist/src/public/prefetchRuntime.d.ts +1 -0
- package/dist/src/utils/runtimePrefetch.d.ts +4 -0
- package/dist/src/utils/stripoRuntime.d.ts +3 -0
- package/dist/static/stripo-runtime-manifest.json.js +9 -0
- package/dist/utils/runtimePrefetch.js +26 -0
- package/dist/utils/stripoRuntime.js +13 -0
- package/package.json +6 -1
- package/dist/extensions/Blocks/Recommendation/utils/inlinePriceOrder.js +0 -12
- package/dist/src/extensions/Blocks/Recommendation/utils/inlinePriceOrder.d.ts +0 -9
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { PRE_RRS_CONFIG_VERSION as
|
|
2
|
-
import { DEFAULT_CARDS_IN_ROW as
|
|
3
|
-
import { mapLegacyStrategy as
|
|
4
|
-
function
|
|
1
|
+
import { PRE_RRS_CONFIG_VERSION as s, DEFAULT_CURRENCY as i } from "../../../extensions/Blocks/Recommendation/constants/defaultConfig.js";
|
|
2
|
+
import { DEFAULT_CARDS_IN_ROW as m, DEFAULT_MOBILE_ROW_SPACING as p, DEFAULT_MOBILE_COLUMN_SPACING as d, DEFAULT_ROW_SPACING as S, DEFAULT_COLUMN_SPACING as f, DEFAULT_MOBILE_CARDS_IN_ROW as a } from "../../../extensions/Blocks/Recommendation/constants/layout.js";
|
|
3
|
+
import { mapLegacyStrategy as l } from "../../../extensions/Blocks/Recommendation/utils/legacyStrategyMap.js";
|
|
4
|
+
function c(t) {
|
|
5
5
|
return t === "0" || t === 0 ? "before" : "after";
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function _(t) {
|
|
8
8
|
if (typeof t == "number" && Number.isFinite(t))
|
|
9
9
|
return t;
|
|
10
10
|
if (typeof t == "string") {
|
|
@@ -14,52 +14,51 @@ function A(t) {
|
|
|
14
14
|
}
|
|
15
15
|
return i.decimalCount;
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function I(t) {
|
|
18
18
|
return t === "." || t === "," || t === " " || t === "" ? t : ",";
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function A(t) {
|
|
21
21
|
return t === "." || t === "," || t === " " ? t : ".";
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function L(t) {
|
|
24
24
|
if (!t || typeof t != "object")
|
|
25
25
|
return { ...i };
|
|
26
|
-
const o = t, n = o.value ?? o.name ?? i.code,
|
|
26
|
+
const o = t, n = o.value ?? o.name ?? i.code, r = o.symbol ?? n;
|
|
27
27
|
return {
|
|
28
28
|
code: n,
|
|
29
|
-
symbol:
|
|
30
|
-
alignment:
|
|
31
|
-
decimalCount:
|
|
32
|
-
decimalSeparator:
|
|
33
|
-
thousandSeparator:
|
|
29
|
+
symbol: r,
|
|
30
|
+
alignment: c(o.alignment),
|
|
31
|
+
decimalCount: _(o.decimalCount),
|
|
32
|
+
decimalSeparator: A(o.decimalSeparator),
|
|
33
|
+
thousandSeparator: I(o.thousandSeparator)
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function N(t) {
|
|
37
37
|
return t === "horizontal" || t === "list" ? "list" : "grid";
|
|
38
38
|
}
|
|
39
|
-
function
|
|
40
|
-
return
|
|
39
|
+
function R(t) {
|
|
40
|
+
return l(t) || "mostPopular";
|
|
41
41
|
}
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
const e = o.rowCount ?? t.cardsInRow ?? d, m = o.totalCount ?? (typeof t.size == "string" ? parseInt(t.size) : t.size) ?? 6;
|
|
42
|
+
function O(t, o, n) {
|
|
43
|
+
const r = o.rowCount ?? t.cardsInRow ?? m, u = o.totalCount ?? (typeof t.size == "string" ? parseInt(t.size) : t.size) ?? 6;
|
|
45
44
|
return {
|
|
46
45
|
recommendationId: n,
|
|
47
|
-
strategy:
|
|
48
|
-
productIds: (t.productIds ?? []).map((
|
|
49
|
-
size: String(
|
|
46
|
+
strategy: R(t.strategy),
|
|
47
|
+
productIds: (t.productIds ?? []).map((e) => String(e)),
|
|
48
|
+
size: String(u),
|
|
50
49
|
shuffleProducts: !!t.shuffleProducts,
|
|
51
50
|
language: t.language ?? "en_US",
|
|
52
|
-
currency:
|
|
53
|
-
filters: (t.filters ?? []).map((
|
|
54
|
-
layout:
|
|
55
|
-
cardsInRow:
|
|
56
|
-
mobileCardsInRow:
|
|
57
|
-
mobileLayoutEnabled:
|
|
58
|
-
previousMobileCardsInRow:
|
|
59
|
-
columnSpacing:
|
|
60
|
-
rowSpacing:
|
|
61
|
-
mobileColumnSpacing:
|
|
62
|
-
mobileRowSpacing:
|
|
51
|
+
currency: L(t.currencySettings),
|
|
52
|
+
filters: (t.filters ?? []).map((e) => ({ ...e })),
|
|
53
|
+
layout: N(t.orientation ?? o.orientation),
|
|
54
|
+
cardsInRow: r,
|
|
55
|
+
mobileCardsInRow: a,
|
|
56
|
+
mobileLayoutEnabled: !1,
|
|
57
|
+
previousMobileCardsInRow: a,
|
|
58
|
+
columnSpacing: f,
|
|
59
|
+
rowSpacing: S,
|
|
60
|
+
mobileColumnSpacing: d,
|
|
61
|
+
mobileRowSpacing: p,
|
|
63
62
|
omnibusPrice: { textBefore: "", textAfter: "" },
|
|
64
63
|
omnibusDiscount: { textBefore: "", textAfter: "" },
|
|
65
64
|
// Preserve the legacy price-placement toggles. Absent legacy keys map to
|
|
@@ -67,10 +66,10 @@ function U(t, o, n) {
|
|
|
67
66
|
// gated). New Guido blocks default differently (see DEFAULT_NODE_CONFIG).
|
|
68
67
|
priceMovedToNextLine: !!t.isPriceMovedToNextLine,
|
|
69
68
|
priceHideIfSameAsDiscounted: !!t.isPriceDeletedForZeroSale,
|
|
70
|
-
configVersion:
|
|
69
|
+
configVersion: s
|
|
71
70
|
};
|
|
72
71
|
}
|
|
73
72
|
export {
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
L as mapCurrency,
|
|
74
|
+
O as mapSettings
|
|
76
75
|
};
|
|
@@ -1,44 +1,34 @@
|
|
|
1
1
|
function r(n, t, o) {
|
|
2
2
|
o != null && o !== "" && n.push(`${t}: ${o}`);
|
|
3
3
|
}
|
|
4
|
-
function
|
|
5
|
-
if (typeof n == "number" && Number.isFinite(n) && n >= 0)
|
|
6
|
-
return Math.trunc(n);
|
|
7
|
-
if (typeof n == "string" && /^\d+$/.test(n.trim())) {
|
|
8
|
-
const t = Number(n.trim());
|
|
9
|
-
if (Number.isFinite(t) && t >= 0)
|
|
10
|
-
return t;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
function P(n) {
|
|
4
|
+
function $(n) {
|
|
14
5
|
if (!n)
|
|
15
6
|
return null;
|
|
16
7
|
const t = n.top ?? n.all ?? 0, o = n.right ?? n.all ?? 0, i = n.bottom ?? n.all ?? 0, l = n.left ?? n.all ?? 0;
|
|
17
8
|
return t === 0 && o === 0 && i === 0 && l === 0 ? null : `${t}px ${o}px ${i}px ${l}px`;
|
|
18
9
|
}
|
|
19
|
-
function
|
|
10
|
+
function j(n) {
|
|
20
11
|
if (!n)
|
|
21
12
|
return null;
|
|
22
13
|
const { top: t, right: o, bottom: i, left: l } = n;
|
|
23
14
|
return t === void 0 ? null : t === o && t === i && t === l ? t : null;
|
|
24
15
|
}
|
|
25
|
-
function
|
|
26
|
-
const l =
|
|
16
|
+
function S(n, t, o, i) {
|
|
17
|
+
const l = j(o);
|
|
27
18
|
if (l !== null) {
|
|
28
19
|
r(n, `border-${t}`, i(l));
|
|
29
20
|
return;
|
|
30
21
|
}
|
|
31
22
|
o && (r(n, `border-top-${t}`, o.top !== void 0 ? i(o.top) : null), r(n, `border-right-${t}`, o.right !== void 0 ? i(o.right) : null), r(n, `border-bottom-${t}`, o.bottom !== void 0 ? i(o.bottom) : null), r(n, `border-left-${t}`, o.left !== void 0 ? i(o.left) : null));
|
|
32
23
|
}
|
|
33
|
-
function
|
|
24
|
+
function C(n) {
|
|
34
25
|
if (!n)
|
|
35
26
|
return null;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return `${t}px`;
|
|
27
|
+
if (typeof n.radius == "number")
|
|
28
|
+
return `${n.radius}px`;
|
|
39
29
|
if (typeof n.lt == "number" || typeof n.rt == "number" || typeof n.rb == "number" || typeof n.lb == "number") {
|
|
40
|
-
const
|
|
41
|
-
return `${
|
|
30
|
+
const t = n.lt ?? 0, o = n.rt ?? 0, i = n.rb ?? 0, l = n.lb ?? 0;
|
|
31
|
+
return `${t}px ${o}px ${i}px ${l}px`;
|
|
42
32
|
}
|
|
43
33
|
return null;
|
|
44
34
|
}
|
|
@@ -46,60 +36,58 @@ function I(n) {
|
|
|
46
36
|
var t, o;
|
|
47
37
|
return ((t = n.textLineSpacing) == null ? void 0 : t.lineSpacing) ?? ((o = n.textLineSpacing) == null ? void 0 : o["font-lineSpacing"]);
|
|
48
38
|
}
|
|
49
|
-
function
|
|
50
|
-
var
|
|
51
|
-
const t = [], o = [], i = (
|
|
52
|
-
return r(t, "background-color", (
|
|
39
|
+
function L(n) {
|
|
40
|
+
var f, u, a, g, d, b, p, s;
|
|
41
|
+
const t = [], o = [], i = (f = n == null ? void 0 : n.textAlign) == null ? void 0 : f.align, l = $((u = n == null ? void 0 : n.textPadding) == null ? void 0 : u.desktop), x = (a = n == null ? void 0 : n.textStyle) == null ? void 0 : a["font-weight"], c = (g = n == null ? void 0 : n.textStyle) == null ? void 0 : g["font-style"];
|
|
42
|
+
return r(t, "background-color", (d = n == null ? void 0 : n.textBackgroundColor) == null ? void 0 : d.color), r(t, "padding", l), r(o, "font-family", (b = n == null ? void 0 : n.textStyle) == null ? void 0 : b["font-family"]), r(o, "font-size", (p = n == null ? void 0 : n.textStyle) == null ? void 0 : p["font-size"]), r(o, "font-weight", x), r(o, "font-style", c), r(o, "color", (s = n == null ? void 0 : n.textColor) == null ? void 0 : s.color), r(o, "line-height", I(n ?? {})), r(o, "text-align", i), {
|
|
53
43
|
tdStyle: t.join("; "),
|
|
54
44
|
pStyle: o.join("; "),
|
|
55
45
|
align: i || void 0,
|
|
56
|
-
wrapBold:
|
|
46
|
+
wrapBold: x === "bold",
|
|
57
47
|
wrapItalic: c === "italic",
|
|
58
48
|
textTrimming: (n == null ? void 0 : n.textTrimming) === !0
|
|
59
49
|
};
|
|
60
50
|
}
|
|
61
|
-
function
|
|
62
|
-
var
|
|
51
|
+
function N(n) {
|
|
52
|
+
var u, a, g, d, b, p, s, k, w, P, B, z;
|
|
63
53
|
const t = [], o = [], i = [];
|
|
64
|
-
r(t, "padding",
|
|
65
|
-
const l = (
|
|
66
|
-
r(o, "background", l), r(i, "background", l), r(i, "color",
|
|
54
|
+
r(t, "padding", $((u = n == null ? void 0 : n.buttonExternalPadding) == null ? void 0 : u.desktop)), r(i, "padding", $((a = n == null ? void 0 : n.buttonInternalPadding) == null ? void 0 : a.desktop)), r(i, "font-family", (g = n == null ? void 0 : n.buttonStyle) == null ? void 0 : g["font-family"]), r(i, "font-size", (d = n == null ? void 0 : n.buttonStyle) == null ? void 0 : d["font-size"]), r(i, "font-weight", (b = n == null ? void 0 : n.buttonStyle) == null ? void 0 : b["font-weight"]), r(i, "font-style", (p = n == null ? void 0 : n.buttonStyle) == null ? void 0 : p["font-style"]);
|
|
55
|
+
const l = (s = n == null ? void 0 : n.buttonColor) == null ? void 0 : s.color, x = (k = n == null ? void 0 : n.textButtonColor) == null ? void 0 : k.color;
|
|
56
|
+
r(o, "background", l), r(i, "background", l), r(i, "color", x);
|
|
67
57
|
const c = n == null ? void 0 : n.buttonBorder;
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
return
|
|
58
|
+
S(o, "width", c == null ? void 0 : c.width, (y) => `${y}px`), S(o, "style", c == null ? void 0 : c.style, (y) => y), S(o, "color", c == null ? void 0 : c.color, (y) => y);
|
|
59
|
+
const f = C(n == null ? void 0 : n.buttonBorderRadius);
|
|
60
|
+
return f && (r(o, "border-radius", f), r(i, "border-radius", f)), ((w = n == null ? void 0 : n.buttonStretch) == null ? void 0 : w.stretched) === !1 ? (r(o, "display", "inline-block"), r(i, "display", "inline-block")) : ((P = n == null ? void 0 : n.buttonStretch) == null ? void 0 : P.stretched) === !0 && (r(o, "display", "block"), r(i, "display", "block")), {
|
|
71
61
|
tdStyle: t.join("; "),
|
|
72
|
-
align: ((
|
|
62
|
+
align: ((B = n == null ? void 0 : n.buttonAlign) == null ? void 0 : B.align) || void 0,
|
|
73
63
|
spanStyle: o.join("; "),
|
|
74
64
|
aStyle: i.join("; "),
|
|
75
|
-
text: (
|
|
65
|
+
text: (z = n == null ? void 0 : n.buttonText) == null ? void 0 : z.text
|
|
76
66
|
};
|
|
77
67
|
}
|
|
78
|
-
function
|
|
68
|
+
function T(n) {
|
|
69
|
+
if (typeof n == "number" && Number.isFinite(n) && n >= 0)
|
|
70
|
+
return Math.trunc(n);
|
|
71
|
+
if (typeof n == "string" && /^\d+$/.test(n.trim())) {
|
|
72
|
+
const t = Number(n.trim());
|
|
73
|
+
if (Number.isFinite(t) && t >= 0)
|
|
74
|
+
return t;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function A(n) {
|
|
79
78
|
var t, o;
|
|
80
79
|
return {
|
|
81
|
-
width:
|
|
82
|
-
height:
|
|
80
|
+
width: T((t = n == null ? void 0 : n.imageSize) == null ? void 0 : t.width),
|
|
81
|
+
height: T((o = n == null ? void 0 : n.imageSize) == null ? void 0 : o.height)
|
|
83
82
|
};
|
|
84
83
|
}
|
|
85
|
-
|
|
86
|
-
function R(n) {
|
|
87
|
-
if (!n)
|
|
88
|
-
return;
|
|
89
|
-
const t = [], o = [];
|
|
90
|
-
return C.forEach(([i, l]) => {
|
|
91
|
-
const f = x(n[l] ?? n.all) ?? 0;
|
|
92
|
-
A.has(f) ? t.push(`es-p${f}${i}`) : f > 0 && o.push(`padding-${l}: ${f}px`);
|
|
93
|
-
}), { classes: t.join(" "), style: o.join("; ") };
|
|
94
|
-
}
|
|
95
|
-
function v(n, t) {
|
|
84
|
+
function F(n, t) {
|
|
96
85
|
const o = (n ?? "").trim().replace(/;$/, "").trim(), i = (t ?? "").trim().replace(/;$/, "").trim();
|
|
97
86
|
return o ? i ? `${o}; ${i}` : o : i;
|
|
98
87
|
}
|
|
99
88
|
export {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
L as
|
|
104
|
-
N as mapTextTheme
|
|
89
|
+
F as appendStyle,
|
|
90
|
+
N as mapButtonTheme,
|
|
91
|
+
A as mapImageTheme,
|
|
92
|
+
L as mapTextTheme
|
|
105
93
|
};
|
|
@@ -1,59 +1,52 @@
|
|
|
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 {
|
|
7
|
-
import { buildBlockHtml as
|
|
8
|
-
import { parseRecommendationId as
|
|
9
|
-
import { mapSettings as
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (t === null)
|
|
1
|
+
import { BlockId as f } from "../../enums/block.js";
|
|
2
|
+
import { DEFAULT_NODE_CONFIG as y } from "../../extensions/Blocks/Recommendation/constants/defaultConfig.js";
|
|
3
|
+
import { ATTR_RECOMMENDATION_TITLE as b } from "../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
4
|
+
import { useTemplateStore as T } from "../../stores/template.js";
|
|
5
|
+
import { mapComposition as v } from "./recommendation/compositionMapper.js";
|
|
6
|
+
import { extractCurrencyFromBlock as C, extractTitleText as M, hasVisibleTitle as R, extractCardBgColor as S, isPartnerManagedBlock as h } from "./recommendation/extractors.js";
|
|
7
|
+
import { buildBlockHtml as w } from "./recommendation/htmlBuilder.js";
|
|
8
|
+
import { parseRecommendationId as x, parseLegacyConfig as E } from "./recommendation/parseLegacyConfig.js";
|
|
9
|
+
import { mapSettings as A } from "./recommendation/settingsMapper.js";
|
|
10
|
+
const H = 'td[esd-dev-product-config][class*="ins-recommendation-v3-block-"]:not(.recommendation-block-v2), td.product-block[esd-handler-name*="EmailRecommendationV3"][esd-dev-product-config]:not(.recommendation-block-v2)';
|
|
11
|
+
function B(n, t, c) {
|
|
12
|
+
var l;
|
|
13
|
+
const r = x(t);
|
|
14
|
+
if (r === null)
|
|
16
15
|
return console.warn(
|
|
17
16
|
"[RecommendationMigrator] Skipping block — missing/invalid `ins-recommendation-v3-campaign-id`"
|
|
18
17
|
), !1;
|
|
19
|
-
const
|
|
20
|
-
if (!
|
|
18
|
+
const o = E(t);
|
|
19
|
+
if (!o)
|
|
21
20
|
return console.warn(
|
|
22
|
-
`[RecommendationMigrator] Aborting block id=${
|
|
21
|
+
`[RecommendationMigrator] Aborting block id=${r} — \`esd-dev-product-config\` missing or unable to be parsed`
|
|
23
22
|
), !1;
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
{ oldPriceFirst: S(e) }
|
|
31
|
-
), u = E(e);
|
|
32
|
-
L(e) ? i.visibility[f] = !1 : i.titleVariable || (i.visibility[f] = B(e));
|
|
33
|
-
const y = P(e), T = {
|
|
34
|
-
...a,
|
|
23
|
+
const a = c[String(r)] ?? {
|
|
24
|
+
currencySettings: C(t)
|
|
25
|
+
}, i = A(a, o, r), e = v((l = o.composition) == null ? void 0 : l.variables), d = M(t);
|
|
26
|
+
e.titleVariable || (e.visibility[b] = R(t));
|
|
27
|
+
const p = S(t), g = {
|
|
28
|
+
...i,
|
|
35
29
|
strategyId: "",
|
|
36
|
-
composition:
|
|
37
|
-
visibility:
|
|
38
|
-
previousTitleHtml:
|
|
39
|
-
textTrimming:
|
|
40
|
-
},
|
|
30
|
+
composition: e.composition,
|
|
31
|
+
visibility: e.visibility,
|
|
32
|
+
previousTitleHtml: y.previousTitleHtml,
|
|
33
|
+
textTrimming: e.anyTextTrimming
|
|
34
|
+
}, m = h(t), u = `
|
|
41
35
|
<table>
|
|
42
36
|
<tbody>
|
|
43
37
|
<tr>
|
|
44
38
|
<td class="esd-structure" align="left">
|
|
45
39
|
<table width="100%" cellpadding="0" cellspacing="0">
|
|
46
40
|
<tbody>
|
|
47
|
-
<tr>${
|
|
48
|
-
nodeConfig:
|
|
49
|
-
composition:
|
|
50
|
-
cardBg:
|
|
51
|
-
titleText:
|
|
52
|
-
legacyId:
|
|
53
|
-
legacyBgColor:
|
|
54
|
-
preserveInnerHtml:
|
|
55
|
-
skipCompile:
|
|
56
|
-
blockPadding: _(((p = (g = r.theme) == null ? void 0 : g.blockPadding) == null ? void 0 : p.desktop) ?? H(e))
|
|
41
|
+
<tr>${w({
|
|
42
|
+
nodeConfig: g,
|
|
43
|
+
composition: e,
|
|
44
|
+
cardBg: p,
|
|
45
|
+
titleText: d,
|
|
46
|
+
legacyId: t.getAttribute("id") ?? void 0,
|
|
47
|
+
legacyBgColor: t.getAttribute("bgcolor") ?? void 0,
|
|
48
|
+
preserveInnerHtml: m ? t.innerHTML : void 0,
|
|
49
|
+
skipCompile: m
|
|
57
50
|
})}</tr>
|
|
58
51
|
</tbody>
|
|
59
52
|
</table>
|
|
@@ -61,40 +54,40 @@ function $(c, e, m) {
|
|
|
61
54
|
</tr>
|
|
62
55
|
</tbody>
|
|
63
56
|
</table>
|
|
64
|
-
`,
|
|
65
|
-
return !
|
|
66
|
-
`[RecommendationMigrator] Aborting block id=${
|
|
67
|
-
), !1) : (
|
|
57
|
+
`, s = n.parseFromString(u, "text/html").querySelector("td.esd-structure");
|
|
58
|
+
return !s || !t.parentNode ? (console.warn(
|
|
59
|
+
`[RecommendationMigrator] Aborting block id=${r} — failed to construct new HTML element`
|
|
60
|
+
), !1) : (t.parentNode.replaceChild(s, t), !0);
|
|
68
61
|
}
|
|
69
|
-
function
|
|
70
|
-
const
|
|
71
|
-
let
|
|
62
|
+
function G(n, t = {}) {
|
|
63
|
+
const c = new DOMParser();
|
|
64
|
+
let r;
|
|
72
65
|
try {
|
|
73
|
-
|
|
74
|
-
} catch (
|
|
75
|
-
return console.error("[RecommendationMigrator] Failed to parse template:",
|
|
66
|
+
r = c.parseFromString(n, "text/html");
|
|
67
|
+
} catch (i) {
|
|
68
|
+
return console.error("[RecommendationMigrator] Failed to parse template:", i), n;
|
|
76
69
|
}
|
|
77
|
-
const
|
|
70
|
+
const o = Array.from(r.querySelectorAll(H));
|
|
78
71
|
try {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
...
|
|
82
|
-
[
|
|
72
|
+
T().$patch((e) => {
|
|
73
|
+
e.migrations = {
|
|
74
|
+
...e.migrations,
|
|
75
|
+
[f.Recommendation]: o.length
|
|
83
76
|
};
|
|
84
77
|
});
|
|
85
78
|
} catch {
|
|
86
79
|
}
|
|
87
|
-
if (
|
|
88
|
-
return
|
|
89
|
-
let
|
|
90
|
-
return
|
|
80
|
+
if (o.length === 0)
|
|
81
|
+
return n;
|
|
82
|
+
let a = 0;
|
|
83
|
+
return o.forEach((i) => {
|
|
91
84
|
try {
|
|
92
|
-
|
|
93
|
-
} catch (
|
|
94
|
-
console.error("[RecommendationMigrator] Unexpected error migrating block:",
|
|
85
|
+
B(c, i, t) && (a += 1);
|
|
86
|
+
} catch (e) {
|
|
87
|
+
console.error("[RecommendationMigrator] Unexpected error migrating block:", e);
|
|
95
88
|
}
|
|
96
|
-
}),
|
|
89
|
+
}), a > 0 && console.info(`[RecommendationMigrator] Migrated ${a} legacy Recommendation block(s)`), r.documentElement.outerHTML;
|
|
97
90
|
}
|
|
98
91
|
export {
|
|
99
|
-
|
|
92
|
+
G as migrateRecommendation
|
|
100
93
|
};
|
|
@@ -1,65 +1,66 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { MERGE_TAGS as
|
|
5
|
-
import { UNSUBSCRIBE_BLOCK_SELECTOR as
|
|
6
|
-
import { useUnsubscribeStore as
|
|
7
|
-
|
|
1
|
+
var C = Object.defineProperty;
|
|
2
|
+
var $ = (l, e, r) => e in l ? C(l, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : l[e] = r;
|
|
3
|
+
var E = (l, e, r) => $(l, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
+
import { MERGE_TAGS as c, PAGE_TYPES as T } from "../../enums/unsubscribe.js";
|
|
5
|
+
import { UNSUBSCRIBE_BLOCK_SELECTOR as A, DATA_ATTRIBUTES as f } from "../../extensions/Blocks/Unsubscribe/utils/constants.js";
|
|
6
|
+
import { useUnsubscribeStore as L } from "../../stores/unsubscribe.js";
|
|
7
|
+
const k = "unsubscribe", _ = "You can ", B = " from our emails, if you need to.", m = "{-{-UNSUBSCRIBE-LINK-}-}";
|
|
8
|
+
class H {
|
|
8
9
|
constructor() {
|
|
9
|
-
|
|
10
|
+
E(this, "parser");
|
|
10
11
|
this.parser = new DOMParser();
|
|
11
12
|
}
|
|
12
13
|
async migrate(e) {
|
|
13
14
|
try {
|
|
14
15
|
const r = this.parser.parseFromString(e, "text/html"), t = r.querySelectorAll("td.unsubscribe-block");
|
|
15
16
|
if (t.length) {
|
|
16
|
-
const
|
|
17
|
-
await
|
|
17
|
+
const n = L();
|
|
18
|
+
await n.fetchTemplates(), this.migrateLegacyBlocks(t, n);
|
|
18
19
|
}
|
|
19
|
-
const
|
|
20
|
-
return !t.length && !
|
|
20
|
+
const i = this.repairUnsubscribeLinks(r);
|
|
21
|
+
return !t.length && !i ? e : r.documentElement.outerHTML;
|
|
21
22
|
} catch (r) {
|
|
22
23
|
return console.error("UnsubscribeMigrator failed:", r), e;
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
migrateLegacyBlocks(e, r) {
|
|
26
27
|
e.forEach((t) => {
|
|
27
|
-
const
|
|
28
|
+
const i = t.getAttribute("id"), n = this.extractPaddingClass(t), s = t.getAttribute("bgcolor") || "", o = this.extractUnsubscribeContent(t), a = this.getCollectionTypeFromMergeTag(o.linkHref), g = r.getSelectedUnsubscribePagesByCollection(a);
|
|
28
29
|
console.debug("[UnsubscribeMigrator]", {
|
|
29
|
-
mergeTag:
|
|
30
|
-
collectionType:
|
|
31
|
-
pageIds:
|
|
32
|
-
paddingClass:
|
|
33
|
-
bgColor:
|
|
30
|
+
mergeTag: o.linkHref,
|
|
31
|
+
collectionType: a,
|
|
32
|
+
pageIds: g,
|
|
33
|
+
paddingClass: n,
|
|
34
|
+
bgColor: s
|
|
34
35
|
});
|
|
35
36
|
const u = this.buildUnsubscribeBlock(
|
|
36
|
-
a,
|
|
37
37
|
o,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
a,
|
|
39
|
+
g,
|
|
40
|
+
n,
|
|
41
|
+
s
|
|
42
|
+
), p = this.parser.parseFromString(
|
|
42
43
|
`<table id="tempDoc"><tbody><tr>${u}</tr></tbody></table>`,
|
|
43
44
|
"text/html"
|
|
44
|
-
).querySelector(
|
|
45
|
-
|
|
45
|
+
).querySelector(A);
|
|
46
|
+
p && t.parentNode && (p.setAttribute("id", i || ""), t.parentNode.replaceChild(p, t));
|
|
46
47
|
});
|
|
47
48
|
}
|
|
48
49
|
// Re-derives the typed merge tag from data-unsubscribe-page-type for any v2
|
|
49
50
|
// block whose anchor href is missing or the legacy default. Returns true when
|
|
50
51
|
// at least one href was rewritten. Typed tags and custom URLs are left intact.
|
|
51
52
|
repairUnsubscribeLinks(e) {
|
|
52
|
-
const r = e.querySelectorAll(`${
|
|
53
|
+
const r = e.querySelectorAll(`${A}[${f.PAGE_TYPE}]`);
|
|
53
54
|
let t = !1;
|
|
54
|
-
return r.forEach((
|
|
55
|
-
const
|
|
56
|
-
if (!
|
|
55
|
+
return r.forEach((i) => {
|
|
56
|
+
const n = i.querySelector('a[data-unsubscribe-link="true"], a.unsubscribe-link');
|
|
57
|
+
if (!n)
|
|
57
58
|
return;
|
|
58
|
-
const
|
|
59
|
-
if (
|
|
59
|
+
const s = n.getAttribute("href") || "";
|
|
60
|
+
if (s && s !== c.default)
|
|
60
61
|
return;
|
|
61
|
-
const
|
|
62
|
-
|
|
62
|
+
const o = Number(i.getAttribute(f.PAGE_TYPE)), a = c[o];
|
|
63
|
+
a && (n.setAttribute("href", a), t = !0);
|
|
63
64
|
}), t;
|
|
64
65
|
}
|
|
65
66
|
extractPaddingClass(e) {
|
|
@@ -67,70 +68,42 @@ class $ {
|
|
|
67
68
|
return t ? t[0] : "";
|
|
68
69
|
}
|
|
69
70
|
extractUnsubscribeContent(e) {
|
|
70
|
-
var
|
|
71
|
-
const r = e.querySelector("a.unsubscribe-link") ||
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
textAfter: " from our emails, if you need to.",
|
|
79
|
-
isBold: !1,
|
|
80
|
-
isItalic: !1,
|
|
81
|
-
align: "center",
|
|
82
|
-
paragraphStyle: ""
|
|
83
|
-
};
|
|
84
|
-
const n = e.getAttribute("align") || t.getAttribute("align") || "center", s = t.getAttribute("style") || "";
|
|
85
|
-
if (!r)
|
|
86
|
-
return {
|
|
87
|
-
textBefore: "You can ",
|
|
88
|
-
linkText: "unsubscribe",
|
|
89
|
-
linkHref: "{{ins-unsubscribe-link}}",
|
|
90
|
-
linkStyle: "",
|
|
91
|
-
textAfter: " from our emails, if you need to.",
|
|
92
|
-
isBold: !1,
|
|
93
|
-
isItalic: !1,
|
|
94
|
-
align: n,
|
|
95
|
-
paragraphStyle: s
|
|
96
|
-
};
|
|
97
|
-
const l = ((d = r.textContent) == null ? void 0 : d.trim()) || "unsubscribe", a = r.getAttribute("href") || "{{ins-unsubscribe-link}}", o = r.getAttribute("style") || "", b = t.textContent || "", u = b.indexOf(l), g = u >= 0 ? b.substring(0, u).trim() : "You can ", i = u >= 0 ? b.substring(u + l.length).trim() : " from our emails, if you need to.", m = !!t.querySelector("b, strong"), y = !!t.querySelector("i, em");
|
|
98
|
-
return {
|
|
99
|
-
textBefore: g,
|
|
100
|
-
linkText: l,
|
|
101
|
-
linkHref: this.normalizeUnsubscribeHref(a),
|
|
102
|
-
linkStyle: o,
|
|
103
|
-
textAfter: i,
|
|
104
|
-
isBold: m,
|
|
105
|
-
isItalic: y,
|
|
106
|
-
align: n,
|
|
107
|
-
paragraphStyle: s
|
|
71
|
+
var a;
|
|
72
|
+
const r = e.cloneNode(!0), t = r.querySelector("a.unsubscribe-link") || r.querySelector('a[href*="unsubscribe"]'), i = (t == null ? void 0 : t.closest("p")) ?? null, n = i || r.querySelector("p"), s = {
|
|
73
|
+
paragraphsHtml: "",
|
|
74
|
+
linkText: k,
|
|
75
|
+
linkHref: c.default,
|
|
76
|
+
linkStyle: "",
|
|
77
|
+
align: "center",
|
|
78
|
+
paragraphStyle: ""
|
|
108
79
|
};
|
|
80
|
+
if (!n || (s.align = e.getAttribute("align") || n.getAttribute("align") || "center", s.paragraphStyle = n.getAttribute("style") || "", !t))
|
|
81
|
+
return s;
|
|
82
|
+
const o = !!((a = t.textContent) != null && a.trim() || t.querySelector("img"));
|
|
83
|
+
if (s.linkText = o ? t.innerHTML.trim() : k, s.linkHref = this.normalizeUnsubscribeHref(t.getAttribute("href") || c.default), s.linkStyle = t.getAttribute("style") || "", i) {
|
|
84
|
+
const g = this.getCollectionTypeFromMergeTag(s.linkHref), u = c[g];
|
|
85
|
+
r.querySelectorAll(`a[href="${c.default}"]`).forEach((b) => b.setAttribute("href", u)), t.replaceWith(r.ownerDocument.createTextNode(m)), s.paragraphsHtml = Array.from(r.querySelectorAll("p"), (b) => b.outerHTML).join("");
|
|
86
|
+
}
|
|
87
|
+
return s;
|
|
109
88
|
}
|
|
110
|
-
buildUnsubscribeBlock(e, r, t,
|
|
111
|
-
const
|
|
112
|
-
e.textBefore && g.push(e.textBefore), g.push(u), e.textAfter && g.push(e.textAfter);
|
|
113
|
-
let i = g.join(" ");
|
|
114
|
-
e.isBold && e.isItalic ? i = `<strong path="1,0"><em path="1,0,0">${i}</em></strong>` : e.isBold ? i = `<strong path="1,0">${i}</strong>` : e.isItalic && (i = `<em path="1,0">${i}</em>`);
|
|
115
|
-
const m = e.align ? ` align="${e.align}"` : "", y = s ? ` bgcolor="${s}"` : "", d = e.paragraphStyle ? ` style="${e.paragraphStyle}"` : "", T = t.length > 0 ? ` ${k.PAGE_LIST}="${t.join(",")}"` : "", E = ` ${k.PAGE_TYPE}="${r}"`, S = "esd-block-text unsubscribe-block-v2 esd-block-unsubscribe esd-unsubscribe-block esd-extension-block";
|
|
89
|
+
buildUnsubscribeBlock(e, r, t, i, n) {
|
|
90
|
+
const s = e.linkStyle ? ` style="${e.linkStyle}"` : "", u = `<a ${`href="${Object.values(c).includes(e.linkHref) ? c[r] : e.linkHref}" class="unsubscribe-link" target="_blank" data-unsubscribe-link="true"`}${s}>${e.linkText}</a>`, b = e.paragraphStyle ? ` style="${e.paragraphStyle}"` : "", p = e.paragraphsHtml ? e.paragraphsHtml.replace(m, () => u) : `<p path="1"${b}>${_}${u}${B}</p>`, y = e.align ? ` align="${e.align}"` : "", S = n ? ` bgcolor="${n}"` : "", h = t.length > 0 ? ` ${f.PAGE_LIST}="${t.join(",")}"` : "", U = ` ${f.PAGE_TYPE}="${r}"`, d = "esd-block-text unsubscribe-block-v2 esd-block-unsubscribe esd-unsubscribe-block esd-extension-block";
|
|
116
91
|
return `
|
|
117
92
|
<td
|
|
118
93
|
data-migration="true"
|
|
119
94
|
esd-extension-block-id="unsubscribe-block"
|
|
120
|
-
class="${
|
|
121
|
-
${
|
|
95
|
+
class="${i ? `${d} ${i}` : d}"
|
|
96
|
+
${y}${S}${U}${h}
|
|
122
97
|
>
|
|
123
|
-
|
|
124
|
-
${i}
|
|
125
|
-
</p>
|
|
98
|
+
${p}
|
|
126
99
|
</td>
|
|
127
100
|
`;
|
|
128
101
|
}
|
|
129
102
|
getCollectionTypeFromMergeTag(e) {
|
|
130
|
-
return e ===
|
|
103
|
+
return e === c[T.SUBSCRIPTION_PREFERENCE_CENTER] ? T.SUBSCRIPTION_PREFERENCE_CENTER : e === c[T.GLOBAL_UNSUBSCRIBE] ? T.GLOBAL_UNSUBSCRIBE : T.GLOBAL_UNSUBSCRIBE;
|
|
131
104
|
}
|
|
132
105
|
normalizeUnsubscribeHref(e) {
|
|
133
|
-
if (Object.values(
|
|
106
|
+
if (Object.values(c).includes(e))
|
|
134
107
|
return e;
|
|
135
108
|
const t = e.match(/{{ins-(?:global-)?(?:preferences-)?unsubscribe-link}}/);
|
|
136
109
|
return t ? t[0] : e.includes("unsubscribe") || e.includes("unsub") ? (console.warn(
|
|
@@ -138,9 +111,9 @@ class $ {
|
|
|
138
111
|
), "{{ins-unsubscribe-link}}") : e;
|
|
139
112
|
}
|
|
140
113
|
}
|
|
141
|
-
async function
|
|
142
|
-
return new
|
|
114
|
+
async function I(l) {
|
|
115
|
+
return new H().migrate(l);
|
|
143
116
|
}
|
|
144
117
|
export {
|
|
145
|
-
|
|
118
|
+
I as migrateUnsubscribe
|
|
146
119
|
};
|