@useinsider/guido 3.20.1-beta.8a05319 → 3.20.1-beta.991508
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/composables/useLegacyStrategyConversion.js +16 -16
- package/dist/config/compiler/itemsCompilerRules.js +12 -5
- package/dist/config/compiler/utils/itemsCompilerUtils.js +65 -45
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +103 -91
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +296 -223
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +219 -205
- package/dist/extensions/Blocks/Recommendation/utils/blockRefresh.js +19 -0
- package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +72 -70
- package/dist/extensions/Blocks/Recommendation/utils/compositionKeys.js +69 -60
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +51 -36
- package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +31 -35
- package/dist/src/config/compiler/utils/itemsCompilerUtils.d.ts +5 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +3 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +18 -3
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +8 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/blockRefresh.d.ts +17 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/compositionKeys.d.ts +4 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/nodeConfigWriter.d.ts +7 -0
- package/package.json +1 -1
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { useRecommendation as
|
|
1
|
+
import { useRecommendation as S } from "./useRecommendation.js";
|
|
2
2
|
import { useToaster as I } from "./useToaster.js";
|
|
3
3
|
import { useTranslations as v } from "./useTranslations.js";
|
|
4
4
|
import { ToasterTypeOptions as g } from "../enums/toaster.js";
|
|
5
5
|
import "../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
6
6
|
import { CURRENT_CONFIG_VERSION as L } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
|
|
7
|
-
import { useRecommendationExtensionStore as
|
|
8
|
-
import { resolveMigrationTarget as
|
|
7
|
+
import { useRecommendationExtensionStore as R } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
8
|
+
import { resolveMigrationTarget as b, buildLegacyMigrationPayload as k } from "../extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js";
|
|
9
9
|
import { commitBlockChangeOutsidePanel as T } from "../extensions/Blocks/Recommendation/utils/nodeConfigWriter.js";
|
|
10
10
|
import { useConfigStore as h } from "../stores/config.js";
|
|
11
11
|
const F = () => {
|
|
12
|
-
const e =
|
|
12
|
+
const e = R(), o = h(), { buildCampaignUrl: m } = S(), { showToaster: c } = I(), a = v();
|
|
13
13
|
return { convertLegacyStrategy: async () => {
|
|
14
14
|
const t = e.currentRecommendationId;
|
|
15
15
|
if (t === null || !e.isLegacyStrategyBlock || e.legacyConversionLoading)
|
|
16
16
|
return "";
|
|
17
|
-
const { strategy: d, productIds: y, size: l, strategyId: p, nodeConfigVersion: u } = e.recommendationConfigs, f = { strategyId: p, size: l, nodeConfigVersion: u }, s =
|
|
18
|
-
campaignId:
|
|
19
|
-
templateLibraryId:
|
|
20
|
-
}),
|
|
17
|
+
const { strategy: d, productIds: y, size: l, strategyId: p, nodeConfigVersion: u } = e.recommendationConfigs, f = { strategyId: p, size: l, nodeConfigVersion: u }, s = b({
|
|
18
|
+
campaignId: o.campaignId,
|
|
19
|
+
templateLibraryId: o.templateLibraryId
|
|
20
|
+
}), C = k({
|
|
21
21
|
blockId: t,
|
|
22
22
|
url: m(String(t)),
|
|
23
|
-
campaignId:
|
|
24
|
-
variationId:
|
|
23
|
+
campaignId: o.campaignId,
|
|
24
|
+
variationId: o.variationId,
|
|
25
25
|
strategy: d,
|
|
26
26
|
productIds: y,
|
|
27
27
|
target: s
|
|
28
28
|
});
|
|
29
|
-
let
|
|
29
|
+
let r;
|
|
30
30
|
try {
|
|
31
|
-
|
|
31
|
+
r = await e.convertLegacyStrategy(C, s);
|
|
32
32
|
} catch (i) {
|
|
33
33
|
return console.error("[useLegacyStrategyConversion] migration failed", i), c({
|
|
34
34
|
type: g.Error,
|
|
@@ -40,7 +40,7 @@ const F = () => {
|
|
|
40
40
|
}), "";
|
|
41
41
|
}
|
|
42
42
|
try {
|
|
43
|
-
await e.
|
|
43
|
+
await e.fetchRecommendationProductsForBlock(t);
|
|
44
44
|
} catch (i) {
|
|
45
45
|
console.error("[useLegacyStrategyConversion] product refetch failed", i);
|
|
46
46
|
}
|
|
@@ -48,16 +48,16 @@ const F = () => {
|
|
|
48
48
|
return n ? T(
|
|
49
49
|
t,
|
|
50
50
|
{
|
|
51
|
-
strategyId:
|
|
51
|
+
strategyId: r,
|
|
52
52
|
size: n.recommendationConfigs.size,
|
|
53
53
|
configVersion: L
|
|
54
54
|
},
|
|
55
55
|
n.recommendationProducts,
|
|
56
56
|
"Converted legacy recommendation strategy"
|
|
57
|
-
) ? (e.currentRecommendationId === t && e.openLegacyStrategyUpdatedModal(),
|
|
57
|
+
) ? (e.currentRecommendationId === t && e.openLegacyStrategyUpdatedModal(), r) : (console.error("[useLegacyStrategyConversion] node write failed", t), e.revertLegacyConversion(t, f), c({
|
|
58
58
|
type: g.Error,
|
|
59
59
|
message: a("email-editor.legacy-strategy-update-failed")
|
|
60
|
-
}), "") :
|
|
60
|
+
}), "") : r;
|
|
61
61
|
} };
|
|
62
62
|
};
|
|
63
63
|
export {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { pairProductVariables as o } from "../../utils/pairProductVariables.js";
|
|
2
|
-
import { normalizeItemsBlockWidths as r, wrapHiddenPriceTdsForOutlook as e, MSO_ITEMS_HIDE_START as
|
|
3
|
-
const
|
|
2
|
+
import { normalizeItemsBlockWidths as r, wrapHiddenPriceTdsForOutlook as t, lockHorizontalItemImageWidths as e, MSO_ITEMS_HIDE_START as s, MSO_ITEMS_HIDE_END as p } from "./utils/itemsCompilerUtils.js";
|
|
3
|
+
const c = [
|
|
4
4
|
{
|
|
5
5
|
id: "normalize-items-block-widths",
|
|
6
6
|
// Runs before the other items rules so they see non-zero widths; not AMP-safe.
|
|
@@ -25,20 +25,27 @@ const d = [
|
|
|
25
25
|
// with safe placeholder comments and collapse them inline for web-engine Outlook.
|
|
26
26
|
description: "Mark hidden Items price tds for Outlook conditional hiding",
|
|
27
27
|
type: "custom",
|
|
28
|
-
processor:
|
|
28
|
+
processor: t,
|
|
29
29
|
priority: 65
|
|
30
30
|
// After pair-product-variables (60), before outlook rules (70+)
|
|
31
31
|
},
|
|
32
|
+
{
|
|
33
|
+
id: "lock-horizontal-item-image-widths",
|
|
34
|
+
description: "Pin horizontal Items thumbnails to their width so narrow rows cannot collapse them",
|
|
35
|
+
type: "custom",
|
|
36
|
+
processor: e,
|
|
37
|
+
priority: 66
|
|
38
|
+
},
|
|
32
39
|
{
|
|
33
40
|
id: "swap-items-mso-markers",
|
|
34
41
|
// Injecting the delicate `<!-- -->` ghost token LAST (after reco minify P99
|
|
35
42
|
// and reco swap P100) keeps it out of every whitespace/comment-mangling pass.
|
|
36
43
|
description: "Swap Items MSO markers into [if !mso] conditional comments",
|
|
37
44
|
type: "custom",
|
|
38
|
-
processor: (i) => i.replaceAll(`<!--${
|
|
45
|
+
processor: (i) => i.replaceAll(`<!--${s}-->`, "<!--[if !mso]><!-- -->").replaceAll(`<!--${p}-->`, "<!--<![endif]-->"),
|
|
39
46
|
priority: 101
|
|
40
47
|
}
|
|
41
48
|
];
|
|
42
49
|
export {
|
|
43
|
-
|
|
50
|
+
c as itemsCompilerRules
|
|
44
51
|
};
|
|
@@ -1,55 +1,75 @@
|
|
|
1
|
-
import { PRODUCT_WRAPPER_SELECTOR as
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { PRODUCT_WRAPPER_SELECTOR as h, hasZeroWidthDeclaration as E, isZeroWidthValue as f, withWidthPin as T, PRODUCT_TD_SELECTOR as _, withoutZeroWidth as y } from "../../../extensions/Blocks/Items/constants/cardWidth.js";
|
|
2
|
+
import { DefaultConfigValues as D } from "../../../extensions/Blocks/Items/enums/settingsEnums.js";
|
|
3
|
+
import { protectLiquid as p, restoreLiquid as A } from "../../../utils/liquidProtection.js";
|
|
4
|
+
const m = "MSO_ITEMS_HIDE_START", S = "MSO_ITEMS_HIDE_END", M = "mso-hide:all; max-height:0; overflow:hidden; font-size:0; line-height:0;", I = ".ins-product-cart td.horizontal-price, .ins-product-cart td.vertical-price", O = ".ins-product-td td.product-image-class img[width]", g = Number(D.productImageWidth);
|
|
5
|
+
function C(t) {
|
|
6
|
+
if (!t.includes("vertical-price") || !t.includes("ins-product-cart"))
|
|
7
|
+
return t;
|
|
8
|
+
const s = t.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), o = new DOMParser().parseFromString(s, "text/html");
|
|
9
|
+
let n = !1;
|
|
10
|
+
if (o.querySelectorAll(I).forEach((e) => {
|
|
11
|
+
var d, u;
|
|
12
|
+
const r = e.getAttribute("style") || "";
|
|
13
|
+
if (!/display\s*:\s*none/i.test(r))
|
|
13
14
|
return;
|
|
14
|
-
const l =
|
|
15
|
-
if (((l == null ? void 0 : l.nodeType) !== Node.COMMENT_NODE || l.data !==
|
|
16
|
-
const
|
|
17
|
-
|
|
15
|
+
const l = e.previousSibling;
|
|
16
|
+
if (((l == null ? void 0 : l.nodeType) !== Node.COMMENT_NODE || l.data !== m) && ((d = e.parentNode) == null || d.insertBefore(o.createComment(m), e), (u = e.parentNode) == null || u.insertBefore(o.createComment(S), e.nextSibling)), !/mso-hide/i.test(r)) {
|
|
17
|
+
const a = r.trim().endsWith(";") ? " " : "; ";
|
|
18
|
+
e.setAttribute("style", `${r}${a}${M}`);
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
-
}), !
|
|
21
|
-
return
|
|
22
|
-
const c =
|
|
20
|
+
n = !0;
|
|
21
|
+
}), !n)
|
|
22
|
+
return t;
|
|
23
|
+
const c = s.match(/<!DOCTYPE[^>]*>/i);
|
|
23
24
|
return ((c ? `${c[0]}
|
|
24
|
-
` : "") +
|
|
25
|
+
` : "") + o.documentElement.outerHTML).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
25
26
|
}
|
|
26
|
-
function
|
|
27
|
-
if (!
|
|
28
|
-
return
|
|
29
|
-
const
|
|
30
|
-
let
|
|
31
|
-
if (
|
|
32
|
-
const
|
|
33
|
-
if (!E(
|
|
27
|
+
function N(t) {
|
|
28
|
+
if (!t.includes("ins-product-wrapper") && !t.includes("ins-product-td"))
|
|
29
|
+
return t;
|
|
30
|
+
const s = new DOMParser().parseFromString(p(t), "text/html");
|
|
31
|
+
let o = !1;
|
|
32
|
+
if (s.querySelectorAll(h).forEach((i) => {
|
|
33
|
+
const e = i.getAttribute("style") || "";
|
|
34
|
+
if (!E(e) && !f(i.getAttribute("width")))
|
|
34
35
|
return;
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
}),
|
|
38
|
-
const
|
|
39
|
-
if (E(
|
|
40
|
-
const
|
|
41
|
-
|
|
36
|
+
const r = T(e);
|
|
37
|
+
r !== e && (i.setAttribute("style", r), o = !0), f(i.getAttribute("width")) && (i.setAttribute("width", "100%"), o = !0);
|
|
38
|
+
}), s.querySelectorAll(_).forEach((i) => {
|
|
39
|
+
const e = i.getAttribute("style") || "";
|
|
40
|
+
if (E(e)) {
|
|
41
|
+
const r = y(e);
|
|
42
|
+
r ? i.setAttribute("style", r) : i.removeAttribute("style"), o = !0;
|
|
42
43
|
}
|
|
43
|
-
|
|
44
|
-
}), !
|
|
45
|
-
return
|
|
46
|
-
const
|
|
44
|
+
f(i.getAttribute("width")) && (i.removeAttribute("width"), o = !0);
|
|
45
|
+
}), !o)
|
|
46
|
+
return t;
|
|
47
|
+
const n = t.match(/<!DOCTYPE[^>]*>/i), c = n ? `${n[0]}
|
|
47
48
|
` : "";
|
|
48
|
-
return
|
|
49
|
+
return A(c + s.documentElement.outerHTML);
|
|
50
|
+
}
|
|
51
|
+
function L(t) {
|
|
52
|
+
if (!t.includes("product-image-class"))
|
|
53
|
+
return t;
|
|
54
|
+
const s = new DOMParser().parseFromString(p(t), "text/html");
|
|
55
|
+
let o = !1;
|
|
56
|
+
if (s.querySelectorAll(O).forEach((i) => {
|
|
57
|
+
var u, a;
|
|
58
|
+
const e = ((u = i.getAttribute("width")) == null ? void 0 : u.trim()) ?? "", r = ((a = i.getAttribute("style")) == null ? void 0 : a.trim()) ?? "";
|
|
59
|
+
if (!/^\d+$/.test(e) || /(^|;)\s*min-width\s*:/i.test(r))
|
|
60
|
+
return;
|
|
61
|
+
const l = r && !r.endsWith(";") ? ";" : "", d = Math.min(Number(e), g);
|
|
62
|
+
i.setAttribute("style", `${r}${l}min-width:${d}px;max-width:${e}px`), o = !0;
|
|
63
|
+
}), !o)
|
|
64
|
+
return t;
|
|
65
|
+
const n = t.match(/<!DOCTYPE[^>]*>/i), c = n ? `${n[0]}
|
|
66
|
+
` : "";
|
|
67
|
+
return A(c + s.documentElement.outerHTML);
|
|
49
68
|
}
|
|
50
69
|
export {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
70
|
+
S as MSO_ITEMS_HIDE_END,
|
|
71
|
+
m as MSO_ITEMS_HIDE_START,
|
|
72
|
+
L as lockHorizontalItemImageWidths,
|
|
73
|
+
N as normalizeItemsBlockWidths,
|
|
74
|
+
C as wrapHiddenPriceTdsForOutlook
|
|
55
75
|
};
|